35 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 50 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
58 vec_free (ep->pending_requests);
80 return VNET_API_ERROR_NO_NAME_SERVERS;
104 vl_api_dns_enable_disable_reply_t *rmp;
115 u8 * server_address_as_u8,
int is_add)
131 clib_memcpy (ap, server_address_as_u8,
sizeof (*ap));
144 return VNET_API_ERROR_NAME_SERVER_NOT_FOUND;
151 u8 * server_address_as_u8,
int is_add)
167 clib_memcpy (ap, server_address_as_u8,
sizeof (*ap));
180 return VNET_API_ERROR_NAME_SERVER_NOT_FOUND;
189 vl_api_dns_name_server_add_del_reply_t *rmp;
197 REPLY_MACRO (VL_API_DNS_NAME_SERVER_ADD_DEL_REPLY);
211 u32 sw_if_index, fib_index;
229 if (fib_index == (
u32) ~ 0)
246 if (sw_if_index == ~0)
249 (
"route to %U exists, fei %d, get_resolving_interface returned" 258 goto found_src_address;
281 memset (ip, 0,
sizeof (*ip));
283 memset (udp, 0,
sizeof (*udp));
285 dns_request = (
u8 *) (udp + 1);
297 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns_reply);
298 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
327 u32 sw_if_index, fib_index;
336 int junk __attribute__ ((unused));
346 if (fib_index == (
u32) ~ 0)
366 goto found_src_address;
387 memset (ip, 0,
sizeof (*ip));
389 memset (udp, 0,
sizeof (*udp));
391 dns_request = (
u8 *) (udp + 1);
395 clib_host_to_net_u32 (0x6 << 28);
406 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns_reply);
407 udp->
dst_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
433 int last_label_index;
440 last_label_index = 0;
447 rv[last_label_index] = (i - last_label_index) - 1;
448 if ((i - last_label_index) > 63)
450 i - last_label_index);
451 last_label_index =
i;
457 rv[last_label_index] = (i - last_label_index) - 1;
480 *parse_from_here = 0;
483 if ((label[0] & 0xC0) == 0xC0)
485 *parse_from_here = label + 2;
486 offset = ((label[0] & 0x3f) << 8) + label[1];
487 label = full_text +
offset;
494 for (i = 0; i < len; i++)
498 if ((label[0] & 0xC0) == 0xC0)
500 *parse_from_here = label + 2;
501 offset = ((label[0] & 0x3f) << 8) + label[1];
502 label = full_text +
offset;
509 if (*parse_from_here == 0)
510 *parse_from_here = label;
539 vec_validate (request, qp_offset +
sizeof (dns_query_t) - 1);
541 qp = (dns_query_t *) (request + qp_offset);
543 qp->type = clib_host_to_net_u16 (DNS_TYPE_ALL);
547 vec_insert (request,
sizeof (dns_header_t), 0);
549 h = (dns_header_t *) request;
552 h->id = clib_host_to_net_u16 (ep - dm->
entries);
556 h->flags = clib_host_to_net_u16 (tmp);
557 h->qdcount = clib_host_to_net_u16 (1);
626 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
629 return VNET_API_ERROR_NO_SUCH_ENTRY;
640 clib_warning (
"pool elt %d supposedly pending, but not found...",
660 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
667 return VNET_API_ERROR_NO_SUCH_ENTRY;
680 u32 victim_index, start_index,
i;
685 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
693 return VNET_API_ERROR_UNSPECIFIED;
700 for (i = 0; i < limit; i++)
702 victim_index = (start_index +
i) % limit;
720 return VNET_API_ERROR_UNSPECIFIED;
731 return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
738 return VNET_API_ERROR_ENTRY_ALREADY_EXISTS;
753 memset (ep, 0,
sizeof (*ep));
794 u32 *indices_to_delete = 0;
817 for (i = 0; i <
vec_len (indices_to_delete); i++)
823 indices_to_delete[i]);
828 (dm, indices_to_delete[i]);
852 memcpy (pr, t,
sizeof (*pr));
872 memset (ep, 0,
sizeof (*ep));
910 #define foreach_notification_to_move \ 935 h = (dns_header_t *) reply;
936 flags = clib_net_to_host_u16 (h->flags);
953 curpos = (
u8 *) (h + 1);
958 for (i = 0; i < clib_net_to_host_u16 (h->qdcount); i++)
965 pos +=
sizeof (dns_query_t);
969 if ((pos2[0] & 0xC0) == 0xC0)
974 rr = (dns_rr_t *) pos;
977 if (clib_net_to_host_u16 (rr->type) != DNS_TYPE_CNAME)
987 goto found_last_request;
989 clib_warning (
"pool elt %d supposedly pending, but not found...", ep_index);
997 _vec_len (cname) -= 1;
1011 memset (next_ep, 0,
sizeof (*next_ep));
1014 _vec_len (next_ep->
name) -= 1;
1024 #define _(a) next_ep->a = ep->a; ep->a = 0; 1030 qp_offset =
vec_len (request);
1033 vec_validate (request, qp_offset +
sizeof (dns_query_t) - 1);
1035 qp = (dns_query_t *) (request + qp_offset);
1037 qp->type = clib_host_to_net_u16 (DNS_TYPE_ALL);
1041 vec_insert (request,
sizeof (dns_header_t), 0);
1043 h = (dns_header_t *) request;
1046 h->id = clib_host_to_net_u16 (next_ep - dm->
entries);
1050 h->qdcount = clib_host_to_net_u16 (1);
1078 u8 *curpos, *pos, *pos2;
1084 h = (dns_header_t *) response;
1085 flags = clib_net_to_host_u16 (h->flags);
1097 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1102 return VNET_API_ERROR_NAME_SERVER_NEXT_SERVER;
1106 if (clib_net_to_host_u16 (h->anscount) < 1)
1107 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1109 curpos = (
u8 *) (h + 1);
1115 if ((len & 0xC0) == 0xC0)
1128 limit = clib_net_to_host_u16 (h->qdcount);
1129 qp = (dns_query_t *) curpos;
1134 limit = clib_net_to_host_u16 (h->anscount);
1136 for (i = 0; i < limit; i++)
1138 pos = pos2 = curpos;
1142 if ((pos2[0] & 0xC0) == 0xC0)
1145 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1154 if ((pos2[0] & 0xc0) == 0xc0)
1160 if (pointer_chase == 0)
1162 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1170 if (pointer_chase == 0)
1173 rr = (dns_rr_t *) pos;
1175 switch (clib_net_to_host_u16 (rr->type))
1181 ttl = clib_net_to_host_u32 (rr->ttl);
1182 if (min_ttlp && *min_ttlp > ttl)
1188 ttl = clib_net_to_host_u32 (rr->ttl);
1189 if (min_ttlp && *min_ttlp > ttl)
1200 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1205 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1219 u8 *curpos, *pos, *pos2;
1224 u8 *junk __attribute__ ((unused));
1228 h = (dns_header_t *) response;
1229 flags = clib_net_to_host_u16 (h->flags);
1241 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1246 return VNET_API_ERROR_NAME_SERVER_NEXT_SERVER;
1250 if (clib_net_to_host_u16 (h->anscount) < 1)
1251 return VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES;
1253 curpos = (
u8 *) (h + 1);
1259 if ((len & 0xC0) == 0xC0)
1272 limit = clib_net_to_host_u16 (h->qdcount);
1273 qp = (dns_query_t *) curpos;
1278 limit = clib_net_to_host_u16 (h->anscount);
1280 for (i = 0; i < limit; i++)
1282 pos = pos2 = curpos;
1286 if ((pos2[0] & 0xC0) == 0xC0)
1289 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1298 if ((pos2[0] & 0xc0) == 0xc0)
1304 if (pointer_chase == 0)
1306 pos2 = response + ((pos2[0] & 0x3f) << 8) + pos2[1];
1314 if (pointer_chase == 0)
1317 rr = (dns_rr_t *) pos;
1319 switch (clib_net_to_host_u16 (rr->type))
1324 ttl = clib_net_to_host_u32 (rr->ttl);
1336 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1341 return VNET_API_ERROR_NAME_SERVER_NO_SUCH_NAME;
1378 rmp->
retval = clib_host_to_net_u32 (rv);
1397 u8 *lookup_name = 0;
1403 for (i = 15; i >= 0; i--)
1406 nybble = (digit & 0x0F);
1408 vec_add1 (lookup_name, (nybble - 10) +
'a');
1410 vec_add1 (lookup_name, nybble +
'0');
1412 nybble = (digit & 0xF0) >> 4;
1414 vec_add1 (lookup_name, (nybble - 10) +
'a');
1416 vec_add1 (lookup_name, nybble +
'0');
1421 memcpy (lookup_name + len,
"ip6.arpa", 8);
1425 for (i = 3; i >= 0; i--)
1428 lookup_name =
format (lookup_name,
"%d.", digit);
1430 lookup_name =
format (lookup_name,
"in-addr.arpa");
1458 rmp->
retval = clib_host_to_net_u32 (rv);
1469 #define vl_msg_name_crc_list 1471 #undef vl_msg_name_crc_list 1476 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); 1477 foreach_vl_msg_name_crc_dns;
1481 #define foreach_dns_api_msg \ 1482 _(DNS_ENABLE_DISABLE, dns_enable_disable) \ 1483 _(DNS_NAME_SERVER_ADD_DEL, dns_name_server_add_del) \ 1484 _(DNS_RESOLVE_NAME, dns_resolve_name) \ 1485 _(DNS_RESOLVE_IP, dns_resolve_ip) 1491 vl_msg_api_set_handlers(VL_API_##N, #n, \ 1492 vl_api_##n##_t_handler, \ 1494 vl_api_##n##_t_endian, \ 1495 vl_api_##n##_t_print, \ 1496 sizeof(vl_api_##n##_t), 1); 1557 u8 **result = va_arg (*args,
u8 **);
1558 u8 **namep = va_arg (*args,
u8 **);
1594 if (!(a4_set + a6_set))
1602 vec_validate (ce, qp_offset +
sizeof (dns_query_t) - 1);
1603 qp = (dns_query_t *) (ce + qp_offset);
1605 qp->type = clib_host_to_net_u16 (DNS_TYPE_ALL);
1611 h = (dns_header_t *) ce;
1617 h->qdcount = clib_host_to_net_u16 (1);
1618 h->anscount = clib_host_to_net_u16 (a4_set + a6_set);
1628 vec_add2 (ce, rru8,
sizeof (*rr) + 4);
1630 rr->type = clib_host_to_net_u16 (DNS_TYPE_A);
1632 rr->ttl = clib_host_to_net_u32 (86400);
1633 rr->rdlength = clib_host_to_net_u16 (4);
1634 memcpy (rr->rdata, &a4, sizeof (a4));
1641 vec_add2 (ce, rru8,
sizeof (*rr) + 16);
1643 rr->type = clib_host_to_net_u16 (DNS_TYPE_AAAA);
1645 rr->ttl = clib_host_to_net_u32 (86400);
1646 rr->rdlength = clib_host_to_net_u16 (16);
1647 memcpy (rr->rdata, &a6, sizeof (a6));
1661 u8 **curpos = va_arg (*args,
u8 **);
1662 int verbose = va_arg (*args,
int);
1667 s =
format (s,
" Name: ");
1675 for (i = 0; i < len; i++)
1688 qp = (dns_query_t *) pos;
1691 switch (clib_net_to_host_u16 (qp->type))
1694 s =
format (s,
"type A\n");
1697 s =
format (s,
"type AAAA\n");
1700 s =
format (s,
"type ALL\n");
1704 s =
format (s,
"type %d\n", clib_net_to_host_u16 (qp->type));
1709 pos +=
sizeof (*qp);
1725 u8 *reply = va_arg (*args,
u8 *);
1726 u8 **curpos = va_arg (*args,
u8 **);
1727 int verbose = va_arg (*args,
int);
1728 int *print_ip4 = va_arg (*args,
int *);
1729 int *print_ip6 = va_arg (*args,
int *);
1734 int pointer_chase = 0;
1736 u16 rrtype_host_byte_order;
1738 pos = pos2 = *curpos;
1744 if ((pos2[0] & 0xc0) == 0xc0)
1747 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1755 for (i = 0; i < len; i++)
1761 if ((pos2[0] & 0xc0) == 0xc0)
1767 if (pointer_chase == 0)
1769 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1787 if (pointer_chase == 0)
1790 rr = (dns_rr_t *) pos;
1791 rrtype_host_byte_order = clib_net_to_host_u16 (rr->type);
1793 switch (rrtype_host_byte_order)
1798 s =
format (s,
"A: ttl %d %U\n", clib_net_to_host_u32 (rr->ttl),
1805 clib_net_to_host_u32 (rr->ttl));
1810 pos +=
sizeof (*rr) + 4;
1816 s =
format (s,
"AAAA: ttl %d %U\n", clib_net_to_host_u32 (rr->ttl),
1823 clib_net_to_host_u32 (rr->ttl));
1827 pos +=
sizeof (*rr) + 16;
1833 s =
format (s,
"TEXT: ");
1834 for (i = 0; i < clib_net_to_host_u16 (rr->rdlength); i++)
1838 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1841 case DNS_TYPE_HINFO:
1849 s =
format (s,
"HINFO: ");
1852 for (i = 0; i < *len; i++)
1857 for (i = 0; i < *len; i++)
1863 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1866 case DNS_TYPE_NAMESERVER:
1869 s =
format (s,
"Nameserver: ");
1873 if ((pos2[0] & 0xc0) == 0xc0)
1876 pos2 = reply + ((pos2[0] & 0x3f) << 8) + pos2[1];
1883 for (i = 0; i < len; i++)
1887 if (pos2[0] == 0xC0)
1888 pos2 = reply + pos2[1];
1897 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1900 case DNS_TYPE_MAIL_EXCHANGE:
1903 tp = (
u16 *) rr->rdata;
1905 s =
format (s,
"Mail Exchange: Preference %d ", (
u32)
1906 clib_net_to_host_u16 (*tp));
1908 pos2 = rr->rdata + 2;
1911 if (pos2[0] == 0xc0)
1912 pos2 = reply + pos2[1];
1918 for (i = 0; i < len; i++)
1922 if (pos2[0] == 0xC0)
1923 pos2 = reply + pos2[1];
1933 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1937 case DNS_TYPE_CNAME:
1940 tp = (
u16 *) rr->rdata;
1942 if (rrtype_host_byte_order == DNS_TYPE_CNAME)
1943 s =
format (s,
"CNAME: ");
1950 if (pos2[0] == 0xc0)
1951 pos2 = reply + pos2[1];
1957 for (i = 0; i < len; i++)
1961 if (pos2[0] == 0xC0)
1962 pos2 = reply + pos2[1];
1971 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1976 s =
format (s,
"type %d: len %d\n",
1977 (
int) clib_net_to_host_u16 (rr->type),
1978 sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength));
1979 pos +=
sizeof (*rr) + clib_net_to_host_u16 (rr->rdlength);
1991 u8 *reply_as_u8 = va_arg (*args,
u8 *);
1992 int verbose = va_arg (*args,
int);
2000 h = (dns_header_t *) reply_as_u8;
2001 id = clib_net_to_host_u16 (h->id);
2002 flags = clib_net_to_host_u16 (h->flags);
2006 s =
format (s,
"DNS %s: id %d\n", (flags &
DNS_QR) ?
"reply" :
"query",
2008 s =
format (s,
" %s %s %s %s\n",
2009 (flags &
DNS_RA) ?
"recur" :
"no-recur",
2010 (flags &
DNS_RD) ?
"recur-des" :
"no-recur-des",
2011 (flags &
DNS_TC) ?
"trunc" :
"no-trunc",
2012 (flags &
DNS_AA) ?
"auth" :
"non-auth");
2013 s =
format (s,
" %d queries, %d answers, %d name-servers," 2015 clib_net_to_host_u16 (h->qdcount),
2016 clib_net_to_host_u16 (h->anscount),
2017 clib_net_to_host_u16 (h->nscount),
2018 clib_net_to_host_u16 (h->arcount));
2021 curpos = (
u8 *) (h + 1);
2026 s =
format (s,
" Queries:\n");
2027 for (i = 0; i < clib_net_to_host_u16 (h->qdcount); i++)
2036 s =
format (s,
" Replies:\n");
2038 for (i = 0; i < clib_net_to_host_u16 (h->anscount); i++)
2042 verbose, &print_ip4, &print_ip6);
2052 f64 now = va_arg (*args,
f64);
2053 int verbose = va_arg (*args,
int);
2054 u8 *name = va_arg (*args,
u8 *);
2061 s =
format (s,
"The DNS cache is disabled...");
2067 s =
format (s,
"The DNS cache is empty...");
2078 s =
format (s,
"%s is not in the cache...", name);
2088 s =
format (s,
"static u8 dns_reply_data_initializer[] =\n");
2120 if (time_left > 0.0)
2121 s =
format (s,
" TTL left %.1f", time_left);
2123 s =
format (s,
" EXPIRED");
2140 if (ep->flags & DNS_CACHE_ENTRY_FLAG_VALID)
2142 ASSERT (ep->dns_response);
2143 if (ep->flags & DNS_CACHE_ENTRY_FLAG_STATIC)
2148 if (verbose < 2 && ep->flags & DNS_CACHE_ENTRY_FLAG_CNAME)
2149 s = format (s,
"%s%s -> %s", ss, ep->name, ep->cname);
2151 s = format (s,
"%s%s -> %U", ss, ep->name,
2155 if (!(ep->flags & DNS_CACHE_ENTRY_FLAG_STATIC))
2157 f64 time_left = ep->expiration_time - now;
2158 if (time_left > 0.0)
2159 s = format (s,
" TTL left %.1f", time_left);
2161 s = format (s,
" EXPIRED");
2164 s = format (s,
" %d client notifications pending\n",
2165 vec_len(ep->pending_requests));
2170 ASSERT (ep->dns_request);
2171 s = format (s,
"[P] %U", format_dns_reply, ep->dns_request,
2194 if (
unformat (input,
"verbose %d", &verbose))
2196 else if (
unformat (input,
"verbose"))
2198 else if (
unformat (input,
"name %s", &name))
2213 .path =
"show dns cache",
2214 .short_help =
"show dns cache [verbose [nn]]",
2239 if (is_add == -1 && is_clear == -1)
2250 case VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED:
2264 case VNET_API_ERROR_NO_SUCH_ENTRY:
2269 case VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED:
2295 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
2314 .path =
"dns cache",
2315 .short_help =
"dns cache [add|del|clear] <name> [ip4][ip6]",
2320 #define DNS_FORMAT_TEST 0 2322 #if DNS_FORMAT_TEST > 0 2325 static u8 dns_reply_data_initializer[] =
2326 { 0x0, 0x0, 0x81, 0x80, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x5,
2327 0x79, 0x61, 0x68, 0x6f, 0x6f, 0x3, 0x63, 0x6f, 0x6d,
2332 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0, 0x24, 0x23,
2333 0x76, 0x3d, 0x73, 0x70, 0x66, 0x31, 0x20, 0x72, 0x65, 0x64, 0x69, 0x72,
2334 0x65, 0x63, 0x74, 0x3d, 0x5f, 0x73, 0x70, 0x66, 0x2e, 0x6d, 0x61, 0x69,
2335 0x6c, 0x2e, 0x79, 0x61, 0x68, 0x6f, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0xc0,
2336 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x50, 0xd4, 0x0, 0x6, 0x3, 0x6e, 0x73,
2337 0x35, 0xc0, 0xc, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x50, 0xd4, 0x0,
2338 0x6, 0x3, 0x6e, 0x73, 0x34, 0xc0, 0xc, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0,
2339 0x1, 0x50, 0xd4, 0x0, 0x6, 0x3, 0x6e, 0x73, 0x31, 0xc0, 0xc, 0xc0, 0xc,
2340 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x50, 0xd4, 0x0, 0x6, 0x3, 0x6e, 0x73, 0x32,
2341 0xc0, 0xc, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x50, 0xd4, 0x0, 0x6,
2342 0x3, 0x6e, 0x73, 0x33, 0xc0, 0xc, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0,
2343 0x6, 0x5c, 0x0, 0x19, 0x0, 0x1, 0x4, 0x6d, 0x74, 0x61, 0x36, 0x3, 0x61,
2344 0x6d, 0x30, 0x8, 0x79, 0x61, 0x68, 0x6f, 0x6f, 0x64, 0x6e, 0x73, 0x3,
2346 0x65, 0x74, 0x0, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0,
2347 0x9, 0x0, 0x1, 0x4, 0x6d, 0x74, 0x61, 0x37, 0xc0, 0xb8, 0xc0, 0xc, 0x0,
2348 0xf, 0x0, 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0, 0x9, 0x0, 0x1, 0x4, 0x6d, 0x74,
2349 0x61, 0x35, 0xc0, 0xb8, 0xc0, 0xc, 0x0, 0x1c, 0x0, 0x1, 0x0, 0x0, 0x6,
2350 0x5c, 0x0, 0x10, 0x20, 0x1, 0x49, 0x98, 0x0, 0x44, 0x2, 0x4, 0x0, 0x0,
2352 0x0, 0x0, 0x0, 0x0, 0xa7, 0xc0, 0xc, 0x0, 0x1c, 0x0, 0x1, 0x0, 0x0, 0x6,
2353 0x5c, 0x0, 0x10, 0x20, 0x1, 0x49, 0x98, 0x0, 0xc, 0xa, 0x6, 0x0, 0x0, 0x0,
2354 0x0, 0x0, 0x2, 0x40, 0x8, 0xc0, 0xc, 0x0, 0x1c, 0x0, 0x1, 0x0, 0x0, 0x6,
2355 0x5c, 0x0, 0x10, 0x20, 0x1, 0x49, 0x98, 0x0, 0x58, 0xc, 0x2, 0x0, 0x0,
2357 0x0, 0x0, 0x0, 0x0, 0xa9, 0xc0, 0xc, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x6,
2358 0x5c, 0x0, 0x4, 0x62, 0x8a, 0xfd, 0x6d, 0xc0, 0xc, 0x0, 0x1, 0x0, 0x1,
2360 0x0, 0x6, 0x5c, 0x0, 0x4, 0xce, 0xbe, 0x24, 0x2d, 0xc0, 0xc, 0x0, 0x1,
2362 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0, 0x4, 0x62, 0x8b, 0xb4, 0x95, 0xc0, 0xc,
2364 0x6, 0x0, 0x1, 0x0, 0x0, 0x6, 0x5c, 0x0, 0x2d, 0xc0, 0x7b, 0xa, 0x68,
2366 0x73, 0x74, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x9, 0x79, 0x61, 0x68,
2367 0x6f, 0x6f, 0x2d, 0x69, 0x6e, 0x63, 0xc0, 0x12, 0x78, 0x3a, 0x85, 0x44,
2368 0x0, 0x0, 0xe, 0x10, 0x0, 0x0, 0x1, 0x2c, 0x0, 0x1b, 0xaf, 0x80, 0x0, 0x0,
2373 static u8 dns_reply_data_initializer[] = {
2374 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01,
2375 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x05,
2376 0x63, 0x69, 0x73, 0x63, 0x6f, 0x03, 0x63, 0x6f, 0x6d,
2378 0x00, 0x00, 0xff, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x05,
2379 0x00, 0x01, 0x00, 0x00, 0x0b, 0xd3, 0x00, 0x1a, 0x03,
2380 0x77, 0x77, 0x77, 0x05, 0x63, 0x69, 0x73, 0x63, 0x6f,
2381 0x03, 0x63, 0x6f, 0x6d, 0x06, 0x61, 0x6b, 0x61, 0x64,
2382 0x6e, 0x73, 0x03, 0x6e, 0x65, 0x74, 0x00,
2386 static u8 dns_reply_data_initializer[] = {
2388 0x00, 0x01, 0x81, 0x80, 0x00, 0x01, 0x00, 0x08,
2390 0x00, 0x06, 0x00, 0x06, 0x0a, 0x6f, 0x72, 0x69,
2392 0x67, 0x69, 0x6e, 0x2d, 0x77, 0x77, 0x77, 0x05,
2394 0x63, 0x69, 0x73, 0x63, 0x6f, 0x03, 0x63, 0x6f,
2396 0x6d, 0x00, 0x00, 0xff, 0x00, 0x01, 0x0a, 0x6f,
2398 0x72, 0x69, 0x67, 0x69, 0x6e, 0x2d, 0x77, 0x77,
2400 0x77, 0x05, 0x43, 0x49, 0x53, 0x43, 0x4f, 0xc0,
2403 0x1d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05,
2406 0x9a, 0x00, 0x18, 0x15, 0x72, 0x63, 0x64,
2407 0x6e, 0x39, 0x2d, 0x31, 0x34, 0x70, 0x2d, 0x64, 0x63,
2408 0x7a, 0x30, 0x35, 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31,
2409 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02, 0x00, 0x01, 0x00,
2410 0x00, 0x05, 0x9a, 0x00, 0x1a, 0x17, 0x61, 0x6c, 0x6c,
2411 0x6e, 0x30, 0x31, 0x2d, 0x61, 0x67, 0x30, 0x39, 0x2d,
2412 0x64, 0x63, 0x7a, 0x30, 0x33, 0x6e, 0x2d, 0x67, 0x73,
2413 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02, 0x00,
2414 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x10, 0x0d, 0x72,
2415 0x74, 0x70, 0x35, 0x2d, 0x64, 0x6d, 0x7a, 0x2d, 0x67,
2416 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02,
2417 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x18, 0x15,
2418 0x6d, 0x74, 0x76, 0x35, 0x2d, 0x61, 0x70, 0x31, 0x30,
2419 0x2d, 0x64, 0x63, 0x7a, 0x30, 0x36, 0x6e, 0x2d, 0x67,
2420 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0, 0x26, 0x00, 0x02,
2421 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x1b, 0x18,
2422 0x73, 0x6e, 0x67, 0x64, 0x63, 0x30, 0x31, 0x2d, 0x61,
2423 0x62, 0x30, 0x37, 0x2d, 0x64, 0x63, 0x7a, 0x30, 0x31,
2424 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31, 0xc0, 0x17, 0xc0,
2425 0x26, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a,
2426 0x00, 0x1a, 0x17, 0x61, 0x65, 0x72, 0x30, 0x31, 0x2d,
2427 0x72, 0x34, 0x63, 0x32, 0x35, 0x2d, 0x64, 0x63, 0x7a,
2428 0x30, 0x31, 0x6e, 0x2d, 0x67, 0x73, 0x73, 0x31, 0xc0,
2429 0x17, 0xc0, 0x26, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
2430 0x00, 0x81, 0x00, 0x04, 0x48, 0xa3, 0x04, 0xa1, 0xc0,
2431 0x26, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82,
2432 0x00, 0x10, 0x20, 0x01, 0x04, 0x20, 0x12, 0x01, 0x00,
2433 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
2434 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05,
2435 0x9a, 0x00, 0x02, 0xc0, 0xf4, 0xc0, 0x0c, 0x00, 0x02,
2436 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x02, 0xc0,
2437 0xcd, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00,
2438 0x05, 0x9a, 0x00, 0x02, 0xc0, 0x8d, 0xc0, 0x0c, 0x00,
2439 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00, 0x02,
2440 0xc0, 0x43, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00,
2441 0x00, 0x05, 0x9a, 0x00, 0x02, 0xc0, 0xa9, 0xc0, 0x0c,
2442 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x9a, 0x00,
2443 0x02, 0xc0, 0x67, 0xc0, 0x8d, 0x00, 0x01, 0x00, 0x01,
2444 0x00, 0x00, 0x07, 0x08, 0x00, 0x04, 0x40, 0x66, 0xf6,
2445 0x05, 0xc0, 0xa9, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
2446 0x07, 0x08, 0x00, 0x04, 0xad, 0x24, 0xe0, 0x64, 0xc0,
2447 0x43, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x07, 0x08,
2448 0x00, 0x04, 0x48, 0xa3, 0x04, 0x1c, 0xc0, 0xf4, 0x00,
2449 0x01, 0x00, 0x01, 0x00, 0x00, 0x07, 0x08, 0x00, 0x04,
2450 0xad, 0x26, 0xd4, 0x6c, 0xc0, 0x67, 0x00, 0x01, 0x00,
2451 0x01, 0x00, 0x00, 0x07, 0x08, 0x00, 0x04, 0xad, 0x25,
2452 0x90, 0x64, 0xc0, 0xcd, 0x00, 0x01, 0x00, 0x01, 0x00,
2453 0x00, 0x07, 0x08, 0x00, 0x04, 0xad, 0x27, 0x70, 0x44,
2458 static u8 dns_reply_data_initializer[] =
2459 { 0x0, 0x0, 0x81, 0x80, 0x0, 0x1, 0x0, 0xe, 0x0, 0x0, 0x0, 0x0, 0x6,
2460 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3, 0x63, 0x6f, 0x6d, 0x0, 0x0, 0xff,
2461 0x0, 0x1, 0xc0, 0xc, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x2b, 0x0, 0x4,
2462 0xac, 0xd9, 0x3, 0x2e, 0xc0, 0xc, 0x0, 0x1c, 0x0, 0x1, 0x0, 0x0, 0x1,
2464 0x0, 0x10, 0x26, 0x7, 0xf8, 0xb0, 0x40, 0x4, 0x8, 0xf, 0x0, 0x0, 0x0, 0x0,
2465 0x0, 0x0, 0x20, 0xe, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x51, 0x7f,
2466 0x0, 0x6, 0x3, 0x6e, 0x73, 0x31, 0xc0, 0xc, 0xc0, 0xc, 0x0, 0x6, 0x0, 0x1,
2467 0x0, 0x0, 0x0, 0x3b, 0x0, 0x22, 0xc0, 0x54, 0x9, 0x64, 0x6e, 0x73, 0x2d,
2468 0x61, 0x64, 0x6d, 0x69, 0x6e, 0xc0, 0xc, 0xa, 0x3d, 0xc7, 0x30, 0x0, 0x0,
2469 0x3, 0x84, 0x0, 0x0, 0x3, 0x84, 0x0, 0x0, 0x7, 0x8, 0x0, 0x0, 0x0, 0x3c,
2470 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x57, 0x0, 0x11, 0x0, 0x1e,
2471 0x4, 0x61, 0x6c, 0x74, 0x32, 0x5, 0x61, 0x73, 0x70, 0x6d, 0x78, 0x1, 0x6c,
2472 0xc0, 0xc, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x57, 0x0, 0x4,
2473 0x0, 0xa, 0xc0, 0x9b, 0xc0, 0xc, 0x0, 0x10, 0x0, 0x1, 0x0, 0x0, 0xe, 0xf,
2474 0x0, 0x24, 0x23, 0x76, 0x3d, 0x73, 0x70, 0x66, 0x31, 0x20, 0x69, 0x6e,
2475 0x63, 0x6c, 0x75, 0x64, 0x65, 0x3a, 0x5f, 0x73, 0x70, 0x66, 0x2e, 0x67,
2476 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x20, 0x7e, 0x61,
2477 0x6c, 0x6c, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1, 0x51, 0x7f, 0x0, 0x6,
2478 0x3, 0x6e, 0x73, 0x32, 0xc0, 0xc, 0xc0, 0xc, 0x1, 0x1, 0x0, 0x1, 0x0, 0x1,
2479 0x51, 0x7f, 0x0, 0xf, 0x0, 0x5, 0x69, 0x73, 0x73, 0x75, 0x65, 0x70, 0x6b,
2480 0x69, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0,
2481 0x1, 0x51, 0x7f, 0x0, 0x6, 0x3, 0x6e, 0x73, 0x34, 0xc0, 0xc, 0xc0, 0xc,
2482 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x57, 0x0, 0x9, 0x0, 0x28, 0x4, 0x61,
2483 0x6c, 0x74, 0x33, 0xc0, 0x9b, 0xc0, 0xc, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1,
2484 0x51, 0x7f, 0x0, 0x6, 0x3, 0x6e, 0x73, 0x33, 0xc0, 0xc, 0xc0, 0xc, 0x0,
2485 0xf, 0x0, 0x1, 0x0, 0x0, 0x2, 0x57, 0x0, 0x9, 0x0, 0x32, 0x4, 0x61, 0x6c,
2486 0x74, 0x34, 0xc0, 0x9b, 0xc0, 0xc, 0x0, 0xf, 0x0, 0x1, 0x0, 0x0, 0x2,
2488 0x0, 0x9, 0x0, 0x14, 0x4, 0x61, 0x6c, 0x74, 0x31, 0xc0, 0x9b
2496 u8 *dns_reply_data = 0;
2503 if (
unformat (input,
"verbose %d", &verbose))
2505 else if (
unformat (input,
"verbose"))
2514 memcpy (dns_reply_data, dns_reply_data_initializer,
2515 ARRAY_LEN (dns_reply_data_initializer));
2519 memset (rmp, 0,
sizeof (*rmp));
2525 case VNET_API_ERROR_NAME_SERVER_NO_ADDRESSES:
2552 .path =
"test dns format",
2553 .short_help =
"test dns format",
2554 .function = test_dns_fmt_command_fn,
2562 u8 *dns_reply_data = 0;
2568 if (
unformat (input,
"verbose %d", &verbose))
2570 else if (
unformat (input,
"verbose"))
2592 .path =
"test dns unformat",
2593 .short_help =
"test dns unformat <name> [ip4][ip6]",
2594 .function = test_dns_unfmt_command_fn,
2612 _vec_len (name) -= 1;
2636 .path =
"test dns expire",
2637 .short_help =
"test dns expire <name>",
2638 .function = test_dns_expire_command_fn,
2659 u32 sw_if_index, fib_index;
2685 memset (rnr, 0,
sizeof (*rnr));
2699 memset (rir, 0,
sizeof (*rir));
2731 b0->
flags |= (VNET_BUFFER_F_LOCALLY_ORIGINATED
2745 if (fib_index == (
u32) ~ 0)
2762 if (sw_if_index == ~0)
2765 (
"route to %U exists, fei %d, get_resolving_interface returned" 2774 goto found_src_address;
2785 dns_response = (
u8 *) (udp + 1);
2786 memset (ip, 0,
sizeof (*ip) +
sizeof (*udp));
2799 vec_validate (reply, qp_offset +
sizeof (dns_query_t) - 1);
2801 qp = (dns_query_t *) (reply + qp_offset);
2804 qp->type = clib_host_to_net_u16 (DNS_TYPE_A);
2806 qp->type = clib_host_to_net_u16 (DNS_TYPE_PTR);
2811 vec_insert (reply,
sizeof (dns_header_t), 0);
2813 dh = (dns_header_t *) reply;
2822 dh->flags = clib_host_to_net_u16 (tmp);
2823 dh->qdcount = clib_host_to_net_u16 (1);
2824 dh->anscount = (is_fail == 0) ? clib_host_to_net_u16 (1) : 0;
2839 rr = (dns_rr_t *) rrptr;
2841 rr->type = clib_host_to_net_u16 (DNS_TYPE_A);
2842 rr->class = clib_host_to_net_u16 (1 );
2843 rr->ttl = clib_host_to_net_u32 (ttl);
2844 rr->rdlength = clib_host_to_net_u16 (
sizeof (
ip4_address_t));
2855 rr = (dns_rr_t *) rrptr;
2856 rr->type = clib_host_to_net_u16 (DNS_TYPE_PTR);
2857 rr->class = clib_host_to_net_u16 (1 );
2858 rr->ttl = clib_host_to_net_u32 (ttl);
2859 rr->rdlength = clib_host_to_net_u16 (
vec_len (label_vec));
2880 udp->
src_port = clib_host_to_net_u16 (UDP_DST_PORT_dns);
#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)
fib_protocol_t fp_proto
protocol type
#define foreach_notification_to_move
static void setup_message_id_table(api_main_t *am)
sll srl srl sll sra u16x4 i
ip6_address_t * ip6_name_servers
vnet_main_t * vnet_get_main(void)
#define DNS_CACHE_ENTRY_FLAG_VALID
we have Actual Data
VLIB_API_INIT_FUNCTION(dns_api_hookup)
#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)
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.
int vnet_dns_response_to_name(u8 *response, vl_api_dns_resolve_ip_reply_t *rmp, u32 *min_ttlp)
#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.
#define hash_set_mem(h, key, value)
ip_lookup_main_t lookup_main
#define DNS_CACHE_ENTRY_FLAG_STATIC
static entry
#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 VLIB_BUFFER_NEXT_PRESENT
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
void vnet_send_dns_request(dns_main_t *dm, dns_cache_entry_t *ep)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#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)
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Aggregrate type for a prefix.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
#define clib_error_return(e, args...)
u8 * format_dns_reply(u8 *s, va_list *args)
static void send_dns4_request(dns_main_t *dm, dns_cache_entry_t *ep, ip4_address_t *server)
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.
#define foreach_dns_api_msg
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...
#define hash_create_string(elts, value_bytes)
#define DNS_RETRIES_PER_SERVER
ip4_address_t * ip4_name_servers
upstream name servers, e.g.
#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.
u16 current_length
Nbytes between current data and the end of this buffer.
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
#define VLIB_BUFFER_FREE_LIST_INDEX_MASK
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)
static clib_error_t * dns_api_hookup(vlib_main_t *vm)
#define VLIB_CONFIG_FUNCTION(x, n,...)
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 void send_dns6_request(dns_main_t *dm, dns_cache_entry_t *ep, ip6_address_t *server)
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)
API main structure, used by both vpp and binary API clients.
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)
#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 void dns_cache_lock(dns_main_t *dm)
#define clib_memcpy(a, b, c)
static int dns6_name_server_add_del(dns_main_t *dm, u8 *server_address_as_u8, int is_add)
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.
#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.
u32 next_buffer
Next buffer for this linked-list of buffers.
#define DNS_OPCODE_QUERY
standard query
static clib_error_t * dns_config_fn(vlib_main_t *vm, unformat_input_t *input)
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 dns_resolver_node
(constructor) VLIB_REGISTER_NODE (dns_resolver_node)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
vlib_node_registration_t dns6_request_node
(constructor) VLIB_REGISTER_NODE (dns6_request_node)
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 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)
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 void * clib_mem_alloc_aligned(uword size, uword align)
static u32 random_u32(u32 *seed)
32-bit random number generator
ip4_main_t ip4_main
Global ip4 main structure.
static int dns4_name_server_add_del(dns_main_t *dm, u8 *server_address_as_u8, int is_add)
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.
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
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,...)
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
int is_enabled
enable / disable flag
dns_cache_entry_t * entries
Pool of cache entries.
static uword pool_elts(void *v)
Number of active elements in a pool.