ikev2: support responder hostname
[vpp.git] / src / plugins / dns / dns.h
index 0a3f7a9..74b0778 100644 (file)
@@ -39,6 +39,11 @@ typedef struct
   u8 *name;
 } dns_pending_request_t;
 
+typedef struct
+{
+  ip_address_t address;
+} dns_resolve_name_t;
+
 typedef enum
 {
   DNS_API_PENDING_NAME_TO_IP = 1,
@@ -99,6 +104,7 @@ typedef struct
   /** Find cached record by name */
   uword *cache_entry_by_name;
   clib_spinlock_t cache_lock;
+  int cache_lock_tag;
 
   /** enable / disable flag */
   int is_enabled;
@@ -122,7 +128,6 @@ typedef struct
   u16 msg_id_base;
 
   /* convenience */
-  vlib_main_t *vlib_main;
   vnet_main_t *vnet_main;
   api_main_t *api_main;
 } dns_main_t;
@@ -138,7 +143,7 @@ _(NONE, "No error")                                                 \
 _(UNIMPLEMENTED, "Unimplemented")                                       \
 _(PROCESSED, "DNS request pkts processed")                              \
 _(IP_OPTIONS, "DNS pkts with ip options (dropped)")                     \
-_(BAD_REQUEST, "DNS pkts with serious discrepanices (dropped)")         \
+_(BAD_REQUEST, "DNS pkts with serious discrepancies (dropped)")         \
 _(TOO_MANY_REQUESTS, "DNS pkts asking too many questions")              \
 _(RESOLUTION_REQUIRED, "DNS pkts pending upstream name resolution")
 
@@ -167,42 +172,48 @@ typedef enum
     DNS46_REPLY_N_ERROR,
 } dns46_reply_error_t;
 
-void vnet_send_dns_request (dns_main_t * dm, dns_cache_entry_t * ep);
-int
-vnet_dns_cname_indirection_nolock (dns_main_t * dm, u32 ep_index, u8 * reply);
+void vnet_send_dns_request (vlib_main_t * vm, dns_main_t * dm,
+                           dns_cache_entry_t * ep);
+int vnet_dns_cname_indirection_nolock (vlib_main_t * vm, dns_main_t * dm,
+                                      u32 ep_index, u8 * reply);
 
 int vnet_dns_delete_entry_by_index_nolock (dns_main_t * dm, u32 index);
 
 int
-vnet_dns_resolve_name (dns_main_t * dm, u8 * name, dns_pending_request_t * t,
-                      dns_cache_entry_t ** retp);
+vnet_dns_resolve_name (vlib_main_t * vm, dns_main_t * dm, u8 * name,
+                      dns_pending_request_t * t, dns_cache_entry_t ** retp);
 
 void
-vnet_dns_send_dns6_request (dns_main_t * dm,
+vnet_dns_send_dns6_request (vlib_main_t * vm, dns_main_t * dm,
                            dns_cache_entry_t * ep, ip6_address_t * server);
 void
-vnet_dns_send_dns4_request (dns_main_t * dm,
+vnet_dns_send_dns4_request (vlib_main_t * vm, dns_main_t * dm,
                            dns_cache_entry_t * ep, ip4_address_t * server);
 
-void vnet_send_dns4_reply (dns_main_t * dm, dns_pending_request_t * t,
-                          dns_cache_entry_t * ep, vlib_buffer_t * b0);
+void vnet_send_dns4_reply (vlib_main_t * vm, dns_main_t * dm,
+                          dns_pending_request_t * t, dns_cache_entry_t * ep,
+                          vlib_buffer_t * b0);
 
-void vnet_send_dns6_reply (dns_main_t * dm, dns_pending_request_t * t,
-                          dns_cache_entry_t * ep, vlib_buffer_t * b0);
+void vnet_send_dns6_reply (vlib_main_t * vm, dns_main_t * dm,
+                          dns_pending_request_t * t, dns_cache_entry_t * ep,
+                          vlib_buffer_t * b0);
 
 u8 *vnet_dns_labels_to_name (u8 * label, u8 * full_text,
                             u8 ** parse_from_here);
 
-void vnet_dns_create_resolver_process (dns_main_t * dm);
+void vnet_dns_create_resolver_process (vlib_main_t * vm, dns_main_t * dm);
 
 format_function_t format_dns_reply;
 
 static inline void
-dns_cache_lock (dns_main_t * dm)
+dns_cache_lock (dns_main_t * dm, int tag)
 {
   if (dm->cache_lock)
     {
+      ASSERT (tag);
+      ASSERT (dm->cache_lock_tag == 0);
       clib_spinlock_lock (&dm->cache_lock);
+      dm->cache_lock_tag = tag;
     }
 }
 
@@ -211,10 +222,15 @@ dns_cache_unlock (dns_main_t * dm)
 {
   if (dm->cache_lock)
     {
+      ASSERT (dm->cache_lock_tag);
+      dm->cache_lock_tag = 0;
       clib_spinlock_unlock (&dm->cache_lock);
     }
 }
 
+extern int dns_resolve_name (u8 *name, dns_cache_entry_t **ep,
+                            dns_pending_request_t *t0,
+                            dns_resolve_name_t *rn);
 #endif /* included_dns_h */
 
 /*