24 #include <vpp/app/version.h> 41 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 47 #define vl_api_version(n,v) static u32 api_version=(v); 51 #define REPLY_MSG_ID_BASE dm->msg_id_base 57 vl_print (handle, (char *)s); \ 69 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
77 vec_free (ep->pending_requests);
103 return VNET_API_ERROR_NO_NAME_SERVERS;
124 if (n_vlib_mains > 1)
143 vl_api_dns_enable_disable_reply_t *rmp;
154 u8 * server_address_as_u8,
int is_add)
170 clib_memcpy (ap, server_address_as_u8,
sizeof (*ap));
183 return VNET_API_ERROR_NAME_SERVER_NOT_FOUND;
190 u8 * server_address_as_u8,
int is_add)
206 clib_memcpy (ap, server_address_as_u8,
sizeof (*ap));
219 return VNET_API_ERROR_NAME_SERVER_NOT_FOUND;
228 vl_api_dns_name_server_add_del_reply_t *rmp;
236 REPLY_MACRO (VL_API_DNS_NAME_SERVER_ADD_DEL_REPLY);
268 if (fib_index == (
u32) ~ 0)
287 if (sw_if_index == ~0)
291 (
"route to %U exists, fei %d, get_resolving_interface returned" 300 goto found_src_address;
318 VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_LOCALLY_ORIGINATED;
327 dns_request = (
u8 *) (udp + 1);
339 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns_reply);
340 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
378 int junk __attribute__ ((unused));
388 if (fib_index == (
u32) ~ 0)
409 goto found_src_address;
427 VLIB_BUFFER_TOTAL_LENGTH_VALID | VNET_BUFFER_F_LOCALLY_ORIGINATED;
434 dns_request = (
u8 *) (udp + 1);
438 clib_host_to_net_u32 (0x6 << 28);
449 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns_reply);
450 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
476 int last_label_index;
483 last_label_index = 0;
490 rv[last_label_index] = (i - last_label_index) - 1;
491 if ((i - last_label_index) > 63)
493 i - last_label_index);
494 last_label_index =
i;
500 rv[last_label_index] = (i - last_label_index) - 1;
523 *parse_from_here = 0;
526 if ((label[0] & 0xC0) == 0xC0)
528 *parse_from_here = label + 2;
529 offset = ((label[0] & 0x3f) << 8) + label[1];
530 label = full_text +
offset;
537 for (i = 0; i <
len; i++)
541 if ((label[0] & 0xC0) == 0xC0)
543 *parse_from_here = label + 2;
544 offset = ((label[0] & 0x3f) << 8) + label[1];
545 label = full_text +
offset;
552 if (*parse_from_here == 0)
553 *parse_from_here =
label;
590 vec_validate (request, 2 * qp_offset + 2 *
sizeof (dns_query_t) - 1);
592 qp = (dns_query_t *) (request + qp_offset);
594 qp->type = clib_host_to_net_u16 (DNS_TYPE_A);
598 qp = (dns_query_t *) (((
u8 *) qp) +
vec_len (name_copy));
601 qp->type = clib_host_to_net_u16 (DNS_TYPE_AAAA);
605 vec_insert (request,
sizeof (dns_header_t), 0);
607 h = (dns_header_t *) request;
610 h->id = clib_host_to_net_u16 (ep - dm->
entries);
614 h->flags = clib_host_to_net_u16 (tmp);
615 h->qdcount = clib_host_to_net_u16 (2);
688 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
691 return VNET_API_ERROR_NO_SUCH_ENTRY;
702 clib_warning (
"pool elt %d supposedly pending, but not found...",
722 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
729 return VNET_API_ERROR_NO_SUCH_ENTRY;
742 u32 victim_index, start_index,
i;
747 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
755 return VNET_API_ERROR_UNSPECIFIED;
762 for (i = 0; i < limit; i++)
764 victim_index = (start_index +
i) % limit;
782 return VNET_API_ERROR_UNSPECIFIED;
793 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
800 return VNET_API_ERROR_ENTRY_ALREADY_EXISTS;
847 return VNET_API_ERROR_INVALID_VALUE;
862 u32 *indices_to_delete = 0;
885 for (i = 0; i <
vec_len (indices_to_delete); i++)
891 indices_to_delete[i]);
896 (dm, indices_to_delete[i]);
919 memcpy (pr, t,
sizeof (*pr));
977 #define foreach_notification_to_move \ 1004 h = (dns_header_t *) reply;
1005 flags = clib_net_to_host_u16 (h->flags);
1022 curpos = (
u8 *) (h + 1);
1027 for (i = 0; i < clib_net_to_host_u16 (h->qdcount); i++)
1034 pos +=
sizeof (dns_query_t);
1038 if ((pos2[0] & 0xC0) == 0xC0)
1044 for (i = 0; i < clib_net_to_host_u16 (h->anscount); i++)
1046 rr = (dns_rr_t *) pos;
1047 switch (clib_net_to_host_u16 (rr->type))
1058 case DNS_TYPE_CNAME:
1066 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1068 if ((pos2[0] & 0xc0) == 0xc0)
1075 flags &= ~DNS_RCODE_MASK;
1077 h->flags = clib_host_to_net_u16 (flags);
1089 goto found_last_request;
1091 clib_warning (
"pool elt %d supposedly pending, but not found...", ep_index);
1100 _vec_len (cname) -= 1;
1119 _vec_len (next_ep->
name) -= 1;
1129 #define _(a) next_ep->a = ep->a; ep->a = 0; 1134 name_copy =
vec_dup (request);
1136 qp_offset =
vec_len (request);
1139 vec_validate (request, 2 * qp_offset + 2 *
sizeof (dns_query_t) - 1);
1141 qp = (dns_query_t *) (request + qp_offset);
1143 qp->type = clib_host_to_net_u16 (DNS_TYPE_A);
1146 qp = (dns_query_t *) (((
u8 *) qp) +
vec_len (name_copy));
1149 qp->type = clib_host_to_net_u16 (DNS_TYPE_AAAA);
1153 vec_insert (request,
sizeof (dns_header_t), 0);
1155 h = (dns_header_t *) request;
1158 h->id = clib_host_to_net_u16 (next_ep - dm->
entries);
1162 h->qdcount = clib_host_to_net_u16 (2);
1190 u8 *curpos, *pos, *pos2;
1196 h = (dns_header_t *) response;
1197 flags = clib_net_to_host_u16 (h->flags);
1209 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1214 return VNET_API_ERROR_NAME_SERVER_NEXT_SERVER;
1218 if (clib_net_to_host_u16 (h->anscount) < 1)
1219 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1221 curpos = (
u8 *) (h + 1);
1227 if ((len & 0xC0) == 0xC0)
1240 limit = clib_net_to_host_u16 (h->qdcount);
1241 qp = (dns_query_t *) curpos;
1246 limit = clib_net_to_host_u16 (h->anscount);
1248 for (i = 0; i < limit; i++)
1250 pos = pos2 = curpos;
1254 if ((pos2[0] & 0xC0) == 0xC0)
1257 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1266 if ((pos2[0] & 0xc0) == 0xc0)
1272 if (pointer_chase == 0)
1274 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1282 if (pointer_chase == 0)
1285 rr = (dns_rr_t *) pos;
1287 switch (clib_net_to_host_u16 (rr->type))
1293 ttl = clib_net_to_host_u32 (rr->ttl);
1294 if (min_ttlp && *min_ttlp > ttl)
1300 ttl = clib_net_to_host_u32 (rr->ttl);
1301 if (min_ttlp && *min_ttlp > ttl)
1312 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1317 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1331 u8 *curpos, *pos, *pos2;
1336 u8 *junk __attribute__ ((unused));
1340 h = (dns_header_t *) response;
1341 flags = clib_net_to_host_u16 (h->flags);
1353 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1358 return VNET_API_ERROR_NAME_SERVER_NEXT_SERVER;
1362 if (clib_net_to_host_u16 (h->anscount) < 1)
1363 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1365 curpos = (
u8 *) (h + 1);
1371 if ((len & 0xC0) == 0xC0)
1384 limit = clib_net_to_host_u16 (h->qdcount);
1385 qp = (dns_query_t *) curpos;
1390 limit = clib_net_to_host_u16 (h->anscount);
1392 for (i = 0; i < limit; i++)
1394 pos = pos2 = curpos;
1398 if ((pos2[0] & 0xC0) == 0xC0)
1401 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1410 if ((pos2[0] & 0xc0) == 0xc0)
1416 if (pointer_chase == 0)
1418 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1426 if (pointer_chase == 0)
1429 rr = (dns_rr_t *) pos;
1431 switch (clib_net_to_host_u16 (rr->type))
1436 ttl = clib_net_to_host_u32 (rr->ttl);
1448 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1453 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1490 rmp->
retval = clib_host_to_net_u32 (rv);
1509 u8 *lookup_name = 0;
1515 for (i = 15; i >= 0; i--)
1518 nybble = (digit & 0x0F);
1520 vec_add1 (lookup_name, (nybble - 10) +
'a');
1522 vec_add1 (lookup_name, nybble +
'0');
1524 nybble = (digit & 0xF0) >> 4;
1526 vec_add1 (lookup_name, (nybble - 10) +
'a');
1528 vec_add1 (lookup_name, nybble +
'0');
1533 memcpy (lookup_name + len,
"ip6.arpa", 8);
1537 for (i = 3; i >= 0; i--)
1540 lookup_name =
format (lookup_name,
"%d.", digit);
1542 lookup_name =
format (lookup_name,
"in-addr.arpa");
1570 rmp->
retval = clib_host_to_net_u32 (rv);
1581 #define vl_msg_name_crc_list 1583 #undef vl_msg_name_crc_list 1588 #define _(id,n,crc) \ 1589 vl_msg_api_add_msg_name_crc (dm->api_main, #n "_" #crc, dm->msg_id_base + id); 1590 foreach_vl_msg_name_crc_dns;
1594 #define foreach_dns_plugin_api_msg \ 1595 _(DNS_ENABLE_DISABLE, dns_enable_disable) \ 1596 _(DNS_NAME_SERVER_ADD_DEL, dns_name_server_add_del) \ 1597 _(DNS_RESOLVE_NAME, dns_resolve_name) \ 1598 _(DNS_RESOLVE_IP, dns_resolve_ip) 1623 u8 **result = va_arg (*args,
u8 **);
1624 u8 **namep = va_arg (*args,
u8 **);
1660 if (!(a4_set + a6_set))
1668 vec_validate (ce, qp_offset +
sizeof (dns_query_t) - 1);
1669 qp = (dns_query_t *) (ce + qp_offset);
1671 qp->type = clib_host_to_net_u16 (DNS_TYPE_ALL);
1677 h = (dns_header_t *) ce;
1683 h->qdcount = clib_host_to_net_u16 (1);
1684 h->anscount = clib_host_to_net_u16 (a4_set + a6_set);
1694 vec_add2 (ce, rru8,
sizeof (*rr) + 4);
1696 rr->type = clib_host_to_net_u16 (DNS_TYPE_A);
1698 rr->ttl = clib_host_to_net_u32 (86400);
1699 rr->rdlength = clib_host_to_net_u16 (4);
1700 memcpy (rr->rdata, &a4, sizeof (a4));
1707 vec_add2 (ce, rru8,
sizeof (*rr) + 16);
1709 rr->type = clib_host_to_net_u16 (DNS_TYPE_AAAA);
1711 rr->ttl = clib_host_to_net_u32 (86400);
1712 rr->rdlength = clib_host_to_net_u16 (16);
1713 memcpy (rr->rdata, &a6, sizeof (a6));
1727 u8 **curpos = va_arg (*args,
u8 **);
1728 int verbose = va_arg (*args,
int);
1733 s =
format (s,
" Name: ");
1741 for (i = 0; i <
len; i++)
1754 qp = (dns_query_t *) pos;
1757 switch (clib_net_to_host_u16 (qp->type))
1760 s =
format (s,
"type A\n");
1763 s =
format (s,
"type AAAA\n");
1766 s =
format (s,
"type ALL\n");
1770 s =
format (s,
"type %d\n", clib_net_to_host_u16 (qp->type));
1775 pos +=
sizeof (*qp);
1791 u8 *reply = va_arg (*args,
u8 *);
1792 u8 **curpos = va_arg (*args,
u8 **);
1793 int verbose = va_arg (*args,
int);
1794 int *print_ip4 = va_arg (*args,
int *);
1795 int *print_ip6 = va_arg (*args,
int *);
1800 int pointer_chase = 0;
1802 u16 rrtype_host_byte_order;
1804 pos = pos2 = *curpos;
1810 if ((pos2[0] & 0xc0) == 0xc0)
1813 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1821 for (i = 0; i <
len; i++)
1827 if ((pos2[0] & 0xc0) == 0xc0)
1833 if (pointer_chase == 0)
1835 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1853 if (pointer_chase == 0)
1856 rr = (dns_rr_t *) pos;
1857 rrtype_host_byte_order = clib_net_to_host_u16 (rr->type);
1859 switch (rrtype_host_byte_order)
1864 s =
format (s,
"A: ttl %d %U\n", clib_net_to_host_u32 (rr->ttl),
1871 clib_net_to_host_u32 (rr->ttl));
1876 pos +=
sizeof (*rr) + 4;
1882 s =
format (s,
"AAAA: ttl %d %U\n", clib_net_to_host_u32 (rr->ttl),
1889 clib_net_to_host_u32 (rr->ttl));
1893 pos +=
sizeof (*rr) + 16;
1899 s =
format (s,
"TEXT: ");
1900 for (i = 0; i < clib_net_to_host_u16 (rr->rdlength); i++)
1904 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1907 case DNS_TYPE_HINFO:
1915 s =
format (s,
"HINFO: ");
1918 for (i = 0; i < *
len; i++)
1923 for (i = 0; i < *
len; i++)
1929 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1932 case DNS_TYPE_NAMESERVER:
1935 s =
format (s,
"Nameserver: ");
1939 if ((pos2[0] & 0xc0) == 0xc0)
1942 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1949 for (i = 0; i <
len; i++)
1953 if (pos2[0] == 0xC0)
1954 pos2 = reply + pos2[1];
1963 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1966 case DNS_TYPE_MAIL_EXCHANGE:
1969 tp = (
u16 *) rr->rdata;
1971 s =
format (s,
"Mail Exchange: Preference %d ", (
u32)
1972 clib_net_to_host_u16 (*tp));
1974 pos2 = rr->rdata + 2;
1977 if (pos2[0] == 0xc0)
1978 pos2 = reply + pos2[1];
1984 for (i = 0; i <
len; i++)
1988 if (pos2[0] == 0xC0)
1989 pos2 = reply + pos2[1];
1999 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
2003 case DNS_TYPE_CNAME:
2006 tp = (
u16 *) rr->rdata;
2008 if (rrtype_host_byte_order == DNS_TYPE_CNAME)
2009 s =
format (s,
"CNAME: ");
2016 if (pos2[0] == 0xc0)
2017 pos2 = reply + pos2[1];
2023 for (i = 0; i <
len; i++)
2027 if (pos2[0] == 0xC0)
2028 pos2 = reply + pos2[1];
2037 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
2042 s =
format (s,
"type %d: len %d\n",
2043 (
int) clib_net_to_host_u16 (rr->type),
2044 sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength));
2045 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
2057 u8 *reply_as_u8 = va_arg (*args,
u8 *);
2058 int verbose = va_arg (*args,
int);
2066 h = (dns_header_t *) reply_as_u8;
2067 id = clib_net_to_host_u16 (h->id);
2068 flags = clib_net_to_host_u16 (h->flags);
2072 s =
format (s,
"DNS %s: id %d\n", (flags &
DNS_QR) ?
"reply" :
"query",
2074 s =
format (s,
" %s %s %s %s\n",
2075 (flags &
DNS_RA) ?
"recur" :
"no-recur",
2076 (flags &
DNS_RD) ?
"recur-des" :
"no-recur-des",
2077 (flags &
DNS_TC) ?
"trunc" :
"no-trunc",
2078 (flags &
DNS_AA) ?
"auth" :
"non-auth");
2079 s =
format (s,
" %d queries, %d answers, %d name-servers," 2081 clib_net_to_host_u16 (h->qdcount),
2082 clib_net_to_host_u16 (h->anscount),
2083 clib_net_to_host_u16 (h->nscount),
2084 clib_net_to_host_u16 (h->arcount));
2087 curpos = (
u8 *) (h + 1);
2092 s =
format (s,
" Queries:\n");
2093 for (i = 0; i < clib_net_to_host_u16 (h->qdcount); i++)
2102 s =
format (s,
" Replies:\n");
2104 for (i = 0; i < clib_net_to_host_u16 (h->anscount); i++)
2108 verbose, &print_ip4, &print_ip6);
2118 f64 now = va_arg (*args,
f64);
2119 int verbose = va_arg (*args,
int);
2127 s =
format (s,
"The DNS cache is disabled...");
2133 s =
format (s,
"The DNS cache is empty...");
2144 s =
format (s,
"%s is not in the cache...", name);
2154 s =
format (s,
"static u8 dns_reply_data_initializer[] =\n");
2186 if (time_left > 0.0)
2187 s =
format (s,
" TTL left %.1f", time_left);
2189 s =
format (s,
" EXPIRED");
2210 if (ep->flags & DNS_CACHE_ENTRY_FLAG_VALID)
2212 ASSERT (ep->dns_response);
2213 if (ep->flags & DNS_CACHE_ENTRY_FLAG_STATIC)
2218 if (verbose < 2 && ep->flags & DNS_CACHE_ENTRY_FLAG_CNAME)
2219 s = format (s,
"%s%s -> %s", ss, ep->name, ep->cname);
2221 s = format (s,
"%s%s -> %U", ss, ep->name,
2225 if (!(ep->flags & DNS_CACHE_ENTRY_FLAG_STATIC))
2227 f64 time_left = ep->expiration_time - now;
2228 if (time_left > 0.0)
2229 s = format (s,
" TTL left %.1f", time_left);
2231 s = format (s,
" EXPIRED");
2234 s = format (s,
" %d client notifications pending\n",
2235 vec_len(ep->pending_requests));
2240 ASSERT (ep->dns_request);
2241 s = format (s,
"[P] %U", format_dns_reply, ep->dns_request,
2265 if (
unformat (input,
"verbose %d", &verbose))
2267 else if (
unformat (input,
"verbose"))
2269 else if (
unformat (input,
"name %s", &name))
2284 .path =
"show dns cache",
2285 .short_help =
"show dns cache [verbose [nn]]",
2321 .path =
"show dns servers",
2322 .short_help =
"show dns servers",
2348 if (is_add == -1 && is_clear == -1)
2359 case VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED:
2373 case VNET_API_ERROR_NO_SUCH_ENTRY:
2378 case VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED:
2404 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
2423 .path =
"dns cache",
2424 .short_help =
"dns cache [add|del|clear] <name> [ip4][ip6]",
2429 #define DNS_FORMAT_TEST 1 2431 #if DNS_FORMAT_TEST > 0 2434 static u8 dns_reply_data_initializer[] =
2435 { 0x0, 0x0, 0x81, 0x80, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x5,
2436 0x79, 0x61, 0x68, 0x6f, 0x6f, 0x3, 0x63, 0x6f, 0x6d,
2441 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0, 0x24, 0x23,
2442 0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0x1, 0x2c, 0x0, 0x1b, 0xaf, 0x80, 0x0, 0x0,
2482 static u8 dns_reply_data_initializer[] = {
2483 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2484 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x05,
2485 0x63, 0x69, 0x73, 0x63, 0x6f, 0x03, 0x63, 0x6f, 0x6d,
2487 0x00, 0x00, 0xff, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05,
2488 0x00, 0x01, 0x00, 0x00, 0x0b, 0xd3, 0x00, 0x1a, 0x03,
2489 0x77, 0x77, 0x77, 0x05, 0x63, 0x69, 0x73, 0x63, 0x6f,
2490 0x03, 0x63, 0x6f, 0x6d, 0x06, 0x61, 0x6b, 0x61, 0x64,
2491 0x6e, 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00,
2495 static u8 dns_reply_data_initializer[] = {
2497 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x08,
2499 0x00, 0x06, 0x00, 0x06, 0x0a, 0x6f, 0x72, 0x69,
2501 0x67, 0x69, 0x6e, 0x2d, 0x77, 0x77, 0x77, 0x05,
2503 0x63, 0x69, 0x73, 0x63, 0x6f, 0x03, 0x63, 0x6f,
2505 0x6d, 0x00, 0x00, 0xff, 0x00, 0x01, 0x0a, 0x6f,
2507 0x72, 0x69, 0x67, 0x69, 0x6e, 0x2d, 0x77, 0x77,
2509 0x77, 0x05, 0x43, 0x49, 0x53, 0x43, 0x4f, 0xc0,
2512 0x1d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05,
2515 0x9a, 0x00, 0x18, 0x15, 0x72, 0x63, 0x64,
2516 0x6e, 0x39, 0x2d, 0x31, 0x34, 0x70, 0x2d, 0x64, 0x63,
2517 0x7a, 0x30, 0x35, 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31,
2518 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02, 0x00, 0x01, 0x00,
2519 0x00, 0x05, 0x9a, 0x00, 0x1a, 0x17, 0x61, 0x6c, 0x6c,
2520 0x6e, 0x30, 0x31, 0x2d, 0x61, 0x67, 0x30, 0x39, 0x2d,
2521 0x64, 0x63, 0x7a, 0x30, 0x33, 0x6e, 0x2d, 0x67, 0x73,
2522 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02, 0x00,
2523 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x10, 0x0d, 0x72,
2524 0x74, 0x70, 0x35, 0x2d, 0x64, 0x6d, 0x7a, 0x2d, 0x67,
2525 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02,
2526 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x18, 0x15,
2527 0x6d, 0x74, 0x76, 0x35, 0x2d, 0x61, 0x70, 0x31, 0x30,
2528 0x2d, 0x64, 0x63, 0x7a, 0x30, 0x36, 0x6e, 0x2d, 0x67,
2529 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02,
2530 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x1b, 0x18,
2531 0x73, 0x6e, 0x67, 0x64, 0x63, 0x30, 0x31, 0x2d, 0x61,
2532 0x62, 0x30, 0x37, 0x2d, 0x64, 0x63, 0x7a, 0x30, 0x31,
2533 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0,
2534 0x26, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a,
2535 0x00, 0x1a, 0x17, 0x61, 0x65, 0x72, 0x30, 0x31, 0x2d,
2536 0x72, 0x34, 0x63, 0x32, 0x35, 0x2d, 0x64, 0x63, 0x7a,
2537 0x30, 0x31, 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31, 0xc0,
2538 0x17, 0xc0, 0x26, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
2539 0x00, 0x81, 0x00, 0x04, 0x48, 0xa3, 0x04, 0xa1, 0xc0,
2540 0x26, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82,
2541 0x00, 0x10, 0x20, 0x01, 0x04, 0x20, 0x12, 0x01, 0x00,
2542 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
2543 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05,
2544 0x9a, 0x00, 0x02, 0xc0, 0xf4, 0xc0, 0x0c, 0x00, 0x02,
2545 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x02, 0xc0,
2546 0xcd, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00,
2547 0x05, 0x9a, 0x00, 0x02, 0xc0, 0x8d, 0xc0, 0x0c, 0x00,
2548 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x02,
2549 0xc0, 0x43, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00,
2550 0x00, 0x05, 0x9a, 0x00, 0x02, 0xc0, 0xa9, 0xc0, 0x0c,
2551 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00,
2552 0x02, 0xc0, 0x67, 0xc0, 0x8d, 0x00, 0x01, 0x00, 0x01,
2553 0x00, 0x00, 0x07, 0x08, 0x00, 0x04, 0x40, 0x66, 0xf6,
2554 0x05, 0xc0, 0xa9, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
2555 0x07, 0x08, 0x00, 0x04, 0xad, 0x24, 0xe0, 0x64, 0xc0,
2556 0x43, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x07, 0x08,
2557 0x00, 0x04, 0x48, 0xa3, 0x04, 0x1c, 0xc0, 0xf4, 0x00,
2558 0x01, 0x00, 0x01, 0x00, 0x00, 0x07, 0x08, 0x00, 0x04,
2559 0xad, 0x26, 0xd4, 0x6c, 0xc0, 0x67, 0x00, 0x01, 0x00,
2560 0x01, 0x00, 0x00, 0x07, 0x08, 0x00, 0x04, 0xad, 0x25,
2561 0x90, 0x64, 0xc0, 0xcd, 0x00, 0x01, 0x00, 0x01, 0x00,
2562 0x00, 0x07, 0x08, 0x00, 0x04, 0xad, 0x27, 0x70, 0x44,
2566 static u8 dns_reply_data_initializer[] =
2567 { 0x0, 0x0, 0x81, 0x80, 0x0, 0x1, 0x0, 0xe, 0x0, 0x0, 0x0, 0x0, 0x6,
2568 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3, 0x63, 0x6f, 0x6d, 0x0, 0x0, 0xff,
2569 0x0, 0x1, 0xc0, 0xc, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x2b, 0x0, 0x4,
2570 0xac, 0xd9, 0x3, 0x2e, 0xc0, 0xc, 0x0, 0x1c, 0x0, 0x1, 0x0, 0x0, 0x1,
2572 0x0, 0x10, 0x26, 0x7, 0xf8, 0xb0, 0x40, 0x4, 0x8, 0xf, 0x0, 0x0, 0x0, 0x0,
2573 0x0, 0x0, 0x20, 0xe, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x51, 0x7f,
2574 0x0, 0x6, 0x3, 0x6e, 0x73, 0x31, 0xc0, 0xc, 0xc0, 0xc, 0x0, 0x6, 0x0, 0x1,
2575 0x0, 0x0, 0x0, 0x3b, 0x0, 0x22, 0xc0, 0x54, 0x9, 0x64, 0x6e, 0x73, 0x2d,
2576 0x61, 0x64, 0x6d, 0x69, 0x6e, 0xc0, 0xc, 0xa, 0x3d, 0xc7, 0x30, 0x0, 0x0,
2577 0x3, 0x84, 0x0, 0x0, 0x3, 0x84, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x3c,
2578 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x57, 0x0, 0x11, 0x0, 0x1e,
2579 0x4, 0x61, 0x6c, 0x74, 0x32, 0x5, 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0, 0x32, 0x4, 0x61, 0x6c,
2594 0x74, 0x34, 0xc0, 0x9b, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2,
2596 0x0, 0x9, 0x0, 0x14, 0x4, 0x61, 0x6c, 0x74, 0x31, 0xc0, 0x9b
2601 static u8 dns_reply_data_initializer[] = {
2602 0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2603 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x0b,
2604 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x6c, 0x69,
2605 0x6e, 0x6b, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0xff,
2606 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00,
2607 0x00, 0x0c, 0x9e, 0x00, 0x1f, 0x0e, 0x64, 0x33, 0x6b,
2608 0x72, 0x30, 0x67, 0x75, 0x62, 0x61, 0x31, 0x64, 0x76,
2609 0x77, 0x66, 0x0a, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x66,
2610 0x72, 0x6f, 0x6e, 0x74, 0x03, 0x6e, 0x65, 0x74, 0x00,
2619 u8 *dns_reply_data = 0;
2626 if (
unformat (input,
"verbose %d", &verbose))
2628 else if (
unformat (input,
"verbose"))
2637 memcpy (dns_reply_data, dns_reply_data_initializer,
2638 ARRAY_LEN (dns_reply_data_initializer));
2648 case VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES:
2675 .path =
"test dns format",
2676 .short_help =
"test dns format",
2685 u8 *dns_reply_data = 0;
2691 if (
unformat (input,
"verbose %d", &verbose))
2693 else if (
unformat (input,
"verbose"))
2715 .path =
"test dns unformat",
2716 .short_help =
"test dns unformat <name> [ip4][ip6]",
2735 _vec_len (name) -= 1;
2761 .path =
"test dns expire",
2762 .short_help =
"test dns expire <name>",
2804 int is_recycle = (b0 != 0);
2856 if (b0->
flags & VLIB_BUFFER_NEXT_PRESENT)
2866 b0->
flags |= (VNET_BUFFER_F_LOCALLY_ORIGINATED
2867 | VLIB_BUFFER_TOTAL_LENGTH_VALID);
2877 if (fib_index == (
u32) ~ 0)
2894 if (sw_if_index == ~0)
2897 (
"route to %U exists, fei %d, get_resolving_interface returned" 2906 goto found_src_address;
2917 dns_response = (
u8 *) (udp + 1);
2918 clib_memset (ip, 0,
sizeof (*ip) +
sizeof (*udp));
2931 vec_validate (reply, qp_offset +
sizeof (dns_query_t) - 1);
2933 qp = (dns_query_t *) (reply + qp_offset);
2936 qp->type = clib_host_to_net_u16 (DNS_TYPE_A);
2938 qp->type = clib_host_to_net_u16 (DNS_TYPE_PTR);
2943 vec_insert (reply,
sizeof (dns_header_t), 0);
2945 dh = (dns_header_t *) reply;
2954 dh->flags = clib_host_to_net_u16 (tmp);
2955 dh->qdcount = clib_host_to_net_u16 (1);
2956 dh->anscount = (is_fail == 0) ? clib_host_to_net_u16 (1) : 0;
2971 rr = (dns_rr_t *) rrptr;
2973 rr->type = clib_host_to_net_u16 (DNS_TYPE_A);
2974 rr->class = clib_host_to_net_u16 (1 );
2975 rr->ttl = clib_host_to_net_u32 (ttl);
2976 rr->rdlength = clib_host_to_net_u16 (
sizeof (
ip4_address_t));
2987 rr = (dns_rr_t *) rrptr;
2988 rr->type = clib_host_to_net_u16 (DNS_TYPE_PTR);
2989 rr->class = clib_host_to_net_u16 (1 );
2990 rr->ttl = clib_host_to_net_u32 (ttl);
2991 rr->rdlength = clib_host_to_net_u16 (
vec_len (label_vec));
3012 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
3023 if (is_recycle == 0)
3038 s =
format (0,
"SCRIPT: dns_enable_disable ");
3039 s =
format (s,
"%s ", mp->
enable ?
"enable" :
"disable");
3049 s =
format (0,
"SCRIPT: dns_name_server_add_del ");
3068 s =
format (0,
"SCRIPT: dns_resolve_name ");
3078 s =
format (0,
"SCRIPT: dns_resolve_ip ");
3089 #define _(n,f) dm->api_main->msg_print_handlers \ 3090 [VL_API_##n + dm->msg_id_base] \ 3091 = (void *) vl_api_##f##_t_print; 3102 vl_msg_api_set_handlers((VL_API_##N + dmp->msg_id_base), \ 3104 vl_api_##n##_t_handler, \ 3106 vl_api_##n##_t_endian, \ 3107 vl_api_##n##_t_print, \ 3108 sizeof(vl_api_##n##_t), 1); 3128 name =
format (0,
"dns_%08x%c", api_version, 0);
3151 .version = VPP_BUILD_VER,
3152 .description =
"Simple DNS name resolver",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
fib_protocol_t fp_proto
protocol type
#define foreach_notification_to_move
static clib_error_t * test_dns_fmt_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
ip6_address_t * ip6_name_servers
static void * vl_api_dns_enable_disable_t_print(vl_api_dns_enable_disable_t *mp, void *handle)
vnet_main_t * vnet_get_main(void)
#define DNS_CACHE_ENTRY_FLAG_VALID
we have Actual Data
#define DNS_RD
recursion desired
vlib_node_registration_t dns46_reply_node
(constructor) VLIB_REGISTER_NODE (dns46_reply_node)
static int delete_random_entry(dns_main_t *dm)
int vnet_dns_cname_indirection_nolock(dns_main_t *dm, u32 ep_index, u8 *reply)
Handle cname indirection.
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
vlib_node_registration_t dns4_request_node
(constructor) VLIB_REGISTER_NODE (dns4_request_node)
#define DNS_RCODE_REFUSED
#define DNS_RCODE_NO_ERROR
u8 * dns_response
Cached dns response.
u16 current_length
Nbytes between current data and the end of this buffer.
int vnet_dns_response_to_name(u8 *response, vl_api_dns_resolve_ip_reply_t *rmp, u32 *min_ttlp)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int vnet_dns_delete_entry_by_index_nolock(dns_main_t *dm, u32 index)
int retry_count
Retry parameters.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static void setup_message_id_table(dns_main_t *dm)
#define hash_set_mem(h, key, value)
ip_lookup_main_t lookup_main
#define DNS_CACHE_ENTRY_FLAG_STATIC
static entry
#define foreach_dns_plugin_api_msg
#define DNS_CLASS_IN
The Internet.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
DNS IP -> name resolution request.
int vnet_dns_response_to_reply(u8 *response, vl_api_dns_resolve_name_reply_t *rmp, u32 *min_ttlp)
#define DNS_RCODE_NOT_IMPLEMENTED
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
#define clib_memcpy(d, s, n)
static clib_error_t * show_dns_servers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vnet_send_dns_request(dns_main_t *dm, dns_cache_entry_t *ep)
clib_spinlock_t cache_lock
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
static void vl_api_dns_resolve_ip_t_handler(vl_api_dns_resolve_ip_t *mp)
u8 * dns_request
Cached dns request, for sending retries.
static void vl_api_dns_enable_disable_t_handler(vl_api_dns_enable_disable_t *mp)
Aggregate type for a prefix.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
static void * vl_api_dns_name_server_add_del_t_print(vl_api_dns_name_server_add_del_t *mp, void *handle)
#define clib_error_return(e, args...)
static void dns_custom_dump_configure(dns_main_t *dm)
u8 * format_dns_reply(u8 *s, va_list *args)
u32 * unresolved_entries
Pool indices of unresolved entries.
void vnet_send_dns4_reply(dns_main_t *dm, dns_pending_request_t *pr, dns_cache_entry_t *ep, vlib_buffer_t *b0)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
static void * vl_api_dns_resolve_ip_t_print(vl_api_dns_resolve_ip_t *mp, void *handle)
u32 resolver_process_node_index
resolver process node index
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
dns_pending_request_t * pending_requests
Clients / peers awaiting responses.
u8 * name_to_labels(u8 *name)
Translate "foo.com" into "0x3 f o o 0x3 c o m 0x0" A historical / hysterical micro-TLV scheme...
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define hash_create_string(elts, value_bytes)
#define DNS_RETRIES_PER_SERVER
ip4_address_t * ip4_name_servers
upstream name servers, e.g.
static void clib_spinlock_init(clib_spinlock_t *p)
#define DNS_RA
recursion available
u8 * cname
For CNAME records, the "next name" to resolve.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
#define hash_unset_mem(h, key)
u8 * name
The name in "normal human being" notation, e.g.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
#define DNS_QR
query=0, response=1
#define DNS_RCODE_SERVER_FAILURE
static_always_inline void vlib_buffer_copy_template(vlib_buffer_t *b, vlib_buffer_t *bt)
DNS name resolution request.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static clib_error_t * dns_cache_add_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CONFIG_FUNCTION(x, n,...)
vl_api_address_union_t src_address
u8 * format_dns_reply_data(u8 *s, va_list *args)
format dns reply data verbose > 1, dump everything verbose == 1, dump all A and AAAA records verbose ...
DNS ip->name resolution reply.
vlib_thread_main_t vlib_thread_main
static clib_error_t * dns_init(vlib_main_t *vm)
static void vl_api_dns_resolve_name_t_handler(vl_api_dns_resolve_name_t *mp)
static clib_error_t * show_dns_cache_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
#define pool_free(p)
Free a pool.
static void dns_cache_unlock(dns_main_t *dm)
static clib_error_t * dns_plugin_api_hookup(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
static void vlib_process_signal_event_mt(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Signal event to process from any thread.
int vnet_dns_resolve_name(dns_main_t *dm, u8 *name, dns_pending_request_t *t, dns_cache_entry_t **retp)
#define clib_warning(format, args...)
static int dns6_name_server_add_del(dns_main_t *dm, u8 *server_address_as_u8, int is_add)
u16 msg_id_base
message-ID base
u32 fib_node_index_t
A typedef of a node index.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static clib_error_t * test_dns_expire_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define DNS_AA
authoritative answer
#define VLIB_CLI_COMMAND(x,...)
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
static int dns_cache_clear(dns_main_t *dm)
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
ip_lookup_main_t lookup_main
#define DNS_RCODE_FORMAT_ERROR
#define vec_delete(V, N, M)
Delete N elements starting at element M.
u8 * vnet_dns_labels_to_name(u8 *label, u8 *full_text, u8 **parse_from_here)
arc-function for the above.
#define DNS_OPCODE_QUERY
standard query
static clib_error_t * dns_config_fn(vlib_main_t *vm, unformat_input_t *input)
int udp_ports_registered
udp port registration complete
static int dns_add_static_entry(dns_main_t *dm, u8 *name, u8 *dns_reply_data)
uword * cache_entry_by_name
Find cached record by name.
add or delete an upstream name server
enable/disable name resolution
uword unformat_dns_reply(unformat_input_t *input, va_list *args)
vlib_node_registration_t dns6_request_node
(constructor) VLIB_REGISTER_NODE (dns6_request_node)
static void dns_cache_lock(dns_main_t *dm, int tag)
void vnet_dns_create_resolver_process(dns_main_t *dm)
static int dns_delete_by_name(dns_main_t *dm, u8 *name)
#define FIB_NODE_INDEX_INVALID
#define DNS_RCODE_NAME_ERROR
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
u32 name_cache_size
config parameters
void vnet_send_dns6_reply(dns_main_t *dm, dns_pending_request_t *pr, dns_cache_entry_t *ep, vlib_buffer_t *b0)
void vnet_dns_send_dns6_request(dns_main_t *dm, dns_cache_entry_t *ep, ip6_address_t *server)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void vl_api_dns_name_server_add_del_t_handler(vl_api_dns_name_server_add_del_t *mp)
#define DNS_CACHE_ENTRY_FLAG_CNAME
CNAME (indirect) entry.
#define hash_get_mem(h, key)
struct clib_bihash_value offset
template key/value backing page structure
static u32 random_u32(u32 *seed)
32-bit random number generator
ip4_main_t ip4_main
Global ip4 main structure.
void vnet_dns_send_dns4_request(dns_main_t *dm, dns_cache_entry_t *ep, ip4_address_t *server)
static int dns4_name_server_add_del(dns_main_t *dm, u8 *server_address_as_u8, int is_add)
static clib_error_t * test_dns_unfmt_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void vlib_buffer_free_one(vlib_main_t *vm, u32 buffer_index)
Free one buffer Shorthand to free a single buffer chain.
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
f64 expiration_time
Expiration time.
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
DNS name resolution reply.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
u8 * format_dns_cache(u8 *s, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
volatile u8 ref_count
Reference count for this buffer.
u8 * format_dns_query(u8 *s, va_list *args)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static int dns_enable_disable(dns_main_t *dm, int is_enable)
#define DNS_RESOLVER_EVENT_PENDING
static void * vl_api_dns_resolve_name_t_print(vl_api_dns_resolve_name_t *mp, void *handle)
int is_enabled
enable / disable flag
u16 vl_msg_api_get_msg_ids(const char *name, int n)
dns_cache_entry_t * entries
Pool of cache entries.
static uword pool_elts(void *v)
Number of active elements in a pool.