*/
#include <vnet/vnet.h>
-#include <vnet/udp/udp.h>
+#include <vnet/udp/udp_local.h>
#include <vnet/plugin/plugin.h>
#include <vnet/fib/fib_table.h>
#include <dns/dns.h>
/* Note: consumes the name vector */
ep->name = name;
+ /* make sure it NULL-terminated as hash_set_mem will use strlen() */
+ vec_terminate_c_string (ep->name);
hash_set_mem (dm->cache_entry_by_name, ep->name, ep - dm->entries);
ep->flags = DNS_CACHE_ENTRY_FLAG_VALID | DNS_CACHE_ENTRY_FLAG_STATIC;
ep->dns_response = dns_reply_data;
rmp->retval = clib_host_to_net_u32 (rv);
}));
/* *INDENT-ON* */
-
- /*
- * dns_resolve_name leaves the cache locked when it returns
- * a cached result, so unlock it here.
- */
- dns_cache_unlock (dm);
}
static void
rmp->retval = clib_host_to_net_u32 (rv);
}));
/* *INDENT-ON* */
-
- /*
- * vnet_dns_resolve_name leaves the cache locked when it returns
- * a cached result, so unlock it here.
- */
- dns_cache_unlock (dm);
}
static clib_error_t *
u8 *reply;
vl_api_dns_resolve_name_reply_t _rnr, *rnr = &_rnr;
vl_api_dns_resolve_ip_reply_t _rir, *rir = &_rir;
- u32 ttl, tmp;
+ u32 ttl = 64, tmp;
u32 qp_offset;
dns_query_t *qp;
dns_rr_t *rr;
}
}
-static void *vl_api_dns_enable_disable_t_print
- (vl_api_dns_enable_disable_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: dns_enable_disable ");
- s = format (s, "%s ", mp->enable ? "enable" : "disable");
-
- FINISH;
-}
-
-static void *vl_api_dns_name_server_add_del_t_print
- (vl_api_dns_name_server_add_del_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: dns_name_server_add_del ");
- if (mp->is_ip6)
- s = format (s, "%U ", format_ip6_address,
- (ip6_address_t *) mp->server_address);
- else
- s = format (s, "%U ", format_ip4_address,
- (ip4_address_t *) mp->server_address);
-
- if (mp->is_add == 0)
- s = format (s, "del ");
-
- FINISH;
-}
-
-static void *vl_api_dns_resolve_name_t_print
- (vl_api_dns_resolve_name_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: dns_resolve_name ");
- s = format (s, "%s ", mp->name);
- FINISH;
-}
-
-static void *vl_api_dns_resolve_ip_t_print
- (vl_api_dns_resolve_ip_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: dns_resolve_ip ");
- if (mp->is_ip6)
- s = format (s, "%U ", format_ip6_address, mp->address);
- else
- s = format (s, "%U ", format_ip4_address, mp->address);
- FINISH;
-}
-
#include <dns/dns.api.c>
static clib_error_t *
dns_init (vlib_main_t * vm)
dm->name_cache_size = 1000;
dm->max_ttl_in_seconds = 86400;
dm->random_seed = 0xDEADDABE;
- dm->api_main = &api_main;
+ dm->api_main = vlibapi_get_main ();
/* Ask for a correctly-sized block of API message decode slots */
dm->msg_id_base = setup_message_id_table ();