• Home
  • Raw
  • Download

Lines Matching +full:ipv4 +full:- +full:single +full:- +full:target

3  * Copyright (C) 2007-2013 by Daniel Stenberg
99 #define ARES_CONFIG_CHECK(x) (x->lookups && x->nsort > -1 && \
100 x->nservers > -1 && \
101 x->ndomains > -1 && \
102 x->ndots > -1 && x->timeout > -1 && \
103 x->tries > -1)
133 return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ in ares_init_options()
146 channel->flags = -1; in ares_init_options()
147 channel->timeout = -1; in ares_init_options()
148 channel->tries = -1; in ares_init_options()
149 channel->ndots = -1; in ares_init_options()
150 channel->rotate = -1; in ares_init_options()
151 channel->udp_port = -1; in ares_init_options()
152 channel->tcp_port = -1; in ares_init_options()
153 channel->ednspsz = -1; in ares_init_options()
154 channel->socket_send_buffer_size = -1; in ares_init_options()
155 channel->socket_receive_buffer_size = -1; in ares_init_options()
156 channel->nservers = -1; in ares_init_options()
157 channel->ndomains = -1; in ares_init_options()
158 channel->nsort = -1; in ares_init_options()
159 channel->tcp_connection_generation = 0; in ares_init_options()
160 channel->lookups = NULL; in ares_init_options()
161 channel->domains = NULL; in ares_init_options()
162 channel->sortlist = NULL; in ares_init_options()
163 channel->servers = NULL; in ares_init_options()
164 channel->sock_state_cb = NULL; in ares_init_options()
165 channel->sock_state_cb_data = NULL; in ares_init_options()
166 channel->sock_create_cb = NULL; in ares_init_options()
167 channel->sock_create_cb_data = NULL; in ares_init_options()
168 channel->sock_config_cb = NULL; in ares_init_options()
169 channel->sock_config_cb_data = NULL; in ares_init_options()
170 channel->sock_funcs = NULL; in ares_init_options()
171 channel->sock_func_cb_data = NULL; in ares_init_options()
172 channel->resolvconf_path = NULL; in ares_init_options()
174 channel->last_server = 0; in ares_init_options()
175 channel->last_timeout_processed = (time_t)now.tv_sec; in ares_init_options()
177 memset(&channel->local_dev_name, 0, sizeof(channel->local_dev_name)); in ares_init_options()
178 channel->local_ip4 = 0; in ares_init_options()
179 memset(&channel->local_ip6, 0, sizeof(channel->local_ip6)); in ares_init_options()
182 ares__init_list_head(&(channel->all_queries)); in ares_init_options()
185 ares__init_list_head(&(channel->queries_by_qid[i])); in ares_init_options()
189 ares__init_list_head(&(channel->queries_by_timeout[i])); in ares_init_options()
200 /* If we fail to apply user-specified options, fail the whole init process */ in ares_init_options()
226 status = init_id_key(&channel->id_key, ARES_ID_KEY_LEN); in ares_init_options()
228 channel->next_id = ares__generate_new_id(&channel->id_key); in ares_init_options()
238 if (channel->servers) in ares_init_options()
239 ares_free(channel->servers); in ares_init_options()
240 if (channel->ndomains != -1) in ares_init_options()
241 ares_strsplit_free(channel->domains, channel->ndomains); in ares_init_options()
242 if (channel->sortlist) in ares_init_options()
243 ares_free(channel->sortlist); in ares_init_options()
244 if(channel->lookups) in ares_init_options()
245 ares_free(channel->lookups); in ares_init_options()
246 if(channel->resolvconf_path) in ares_init_options()
247 ares_free(channel->resolvconf_path); in ares_init_options()
253 if ((channel->flags & ARES_FLAG_PRIMARY) && channel->nservers > 1) in ares_init_options()
254 channel->nservers = 1; in ares_init_options()
293 (*dest)->sock_create_cb = src->sock_create_cb; in ares_dup()
294 (*dest)->sock_create_cb_data = src->sock_create_cb_data; in ares_dup()
295 (*dest)->sock_config_cb = src->sock_config_cb; in ares_dup()
296 (*dest)->sock_config_cb_data = src->sock_config_cb_data; in ares_dup()
297 (*dest)->sock_funcs = src->sock_funcs; in ares_dup()
298 (*dest)->sock_func_cb_data = src->sock_func_cb_data; in ares_dup()
300 strncpy((*dest)->local_dev_name, src->local_dev_name, in ares_dup()
301 sizeof((*dest)->local_dev_name)); in ares_dup()
302 (*dest)->local_ip4 = src->local_ip4; in ares_dup()
303 memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6)); in ares_dup()
305 /* Full name server cloning required if there is a non-IPv4, or non-default port, nameserver */ in ares_dup()
306 for (i = 0; i < src->nservers; i++) in ares_dup()
308 if ((src->servers[i].addr.family != AF_INET) || in ares_dup()
309 (src->servers[i].addr.udp_port != 0) || in ares_dup()
310 (src->servers[i].addr.tcp_port != 0)) { in ares_dup()
354 (*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE); in ares_save_options()
356 if (channel->resolvconf_path) in ares_save_options()
360 options->flags = channel->flags; in ares_save_options()
364 options->timeout = channel->timeout; in ares_save_options()
365 options->tries = channel->tries; in ares_save_options()
366 options->ndots = channel->ndots; in ares_save_options()
367 options->udp_port = ntohs(aresx_sitous(channel->udp_port)); in ares_save_options()
368 options->tcp_port = ntohs(aresx_sitous(channel->tcp_port)); in ares_save_options()
369 options->sock_state_cb = channel->sock_state_cb; in ares_save_options()
370 options->sock_state_cb_data = channel->sock_state_cb_data; in ares_save_options()
372 /* Copy IPv4 servers that use the default port */ in ares_save_options()
373 if (channel->nservers) { in ares_save_options()
374 for (i = 0; i < channel->nservers; i++) in ares_save_options()
376 if ((channel->servers[i].addr.family == AF_INET) && in ares_save_options()
377 (channel->servers[i].addr.udp_port == 0) && in ares_save_options()
378 (channel->servers[i].addr.tcp_port == 0)) in ares_save_options()
382 options->servers = ares_malloc(ipv4_nservers * sizeof(struct in_addr)); in ares_save_options()
383 if (!options->servers) in ares_save_options()
385 for (i = j = 0; i < channel->nservers; i++) in ares_save_options()
387 if ((channel->servers[i].addr.family == AF_INET) && in ares_save_options()
388 (channel->servers[i].addr.udp_port == 0) && in ares_save_options()
389 (channel->servers[i].addr.tcp_port == 0)) in ares_save_options()
390 memcpy(&options->servers[j++], in ares_save_options()
391 &channel->servers[i].addr.addrV4, in ares_save_options()
392 sizeof(channel->servers[i].addr.addrV4)); in ares_save_options()
396 options->nservers = ipv4_nservers; in ares_save_options()
399 if (channel->ndomains) { in ares_save_options()
400 options->domains = ares_malloc(channel->ndomains * sizeof(char *)); in ares_save_options()
401 if (!options->domains) in ares_save_options()
404 for (i = 0; i < channel->ndomains; i++) in ares_save_options()
406 options->ndomains = i; in ares_save_options()
407 options->domains[i] = ares_strdup(channel->domains[i]); in ares_save_options()
408 if (!options->domains[i]) in ares_save_options()
412 options->ndomains = channel->ndomains; in ares_save_options()
415 if (channel->lookups) { in ares_save_options()
416 options->lookups = ares_strdup(channel->lookups); in ares_save_options()
417 if (!options->lookups && channel->lookups) in ares_save_options()
422 if (channel->nsort) { in ares_save_options()
423 options->sortlist = ares_malloc(channel->nsort * sizeof(struct apattern)); in ares_save_options()
424 if (!options->sortlist) in ares_save_options()
426 for (i = 0; i < channel->nsort; i++) in ares_save_options()
427 options->sortlist[i] = channel->sortlist[i]; in ares_save_options()
429 options->nsort = channel->nsort; in ares_save_options()
432 if (channel->resolvconf_path) { in ares_save_options()
433 options->resolvconf_path = ares_strdup(channel->resolvconf_path); in ares_save_options()
434 if (!options->resolvconf_path) in ares_save_options()
448 if ((optmask & ARES_OPT_FLAGS) && channel->flags == -1) in init_by_options()
449 channel->flags = options->flags; in init_by_options()
450 if ((optmask & ARES_OPT_TIMEOUTMS) && channel->timeout == -1) in init_by_options()
451 channel->timeout = options->timeout; in init_by_options()
452 else if ((optmask & ARES_OPT_TIMEOUT) && channel->timeout == -1) in init_by_options()
453 channel->timeout = options->timeout * 1000; in init_by_options()
454 if ((optmask & ARES_OPT_TRIES) && channel->tries == -1) in init_by_options()
455 channel->tries = options->tries; in init_by_options()
456 if ((optmask & ARES_OPT_NDOTS) && channel->ndots == -1) in init_by_options()
457 channel->ndots = options->ndots; in init_by_options()
458 if ((optmask & ARES_OPT_ROTATE) && channel->rotate == -1) in init_by_options()
459 channel->rotate = 1; in init_by_options()
460 if ((optmask & ARES_OPT_NOROTATE) && channel->rotate == -1) in init_by_options()
461 channel->rotate = 0; in init_by_options()
462 if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1) in init_by_options()
463 channel->udp_port = htons(options->udp_port); in init_by_options()
464 if ((optmask & ARES_OPT_TCP_PORT) && channel->tcp_port == -1) in init_by_options()
465 channel->tcp_port = htons(options->tcp_port); in init_by_options()
466 if ((optmask & ARES_OPT_SOCK_STATE_CB) && channel->sock_state_cb == NULL) in init_by_options()
468 channel->sock_state_cb = options->sock_state_cb; in init_by_options()
469 channel->sock_state_cb_data = options->sock_state_cb_data; in init_by_options()
472 && channel->socket_send_buffer_size == -1) in init_by_options()
473 channel->socket_send_buffer_size = options->socket_send_buffer_size; in init_by_options()
475 && channel->socket_receive_buffer_size == -1) in init_by_options()
476 channel->socket_receive_buffer_size = options->socket_receive_buffer_size; in init_by_options()
478 if ((optmask & ARES_OPT_EDNSPSZ) && channel->ednspsz == -1) in init_by_options()
479 channel->ednspsz = options->ednspsz; in init_by_options()
481 /* Copy the IPv4 servers, if given. */ in init_by_options()
482 if ((optmask & ARES_OPT_SERVERS) && channel->nservers == -1) in init_by_options()
485 if (options->nservers > 0) in init_by_options()
487 channel->servers = in init_by_options()
488 ares_malloc(options->nservers * sizeof(struct server_state)); in init_by_options()
489 if (!channel->servers) in init_by_options()
491 for (i = 0; i < options->nservers; i++) in init_by_options()
493 channel->servers[i].addr.family = AF_INET; in init_by_options()
494 channel->servers[i].addr.udp_port = 0; in init_by_options()
495 channel->servers[i].addr.tcp_port = 0; in init_by_options()
496 memcpy(&channel->servers[i].addr.addrV4, in init_by_options()
497 &options->servers[i], in init_by_options()
498 sizeof(channel->servers[i].addr.addrV4)); in init_by_options()
501 channel->nservers = options->nservers; in init_by_options()
504 /* Copy the domains, if given. Keep channel->ndomains consistent so in init_by_options()
507 if ((optmask & ARES_OPT_DOMAINS) && channel->ndomains == -1) in init_by_options()
510 if (options->ndomains > 0) in init_by_options()
512 channel->domains = ares_malloc(options->ndomains * sizeof(char *)); in init_by_options()
513 if (!channel->domains) in init_by_options()
515 for (i = 0; i < options->ndomains; i++) in init_by_options()
517 channel->ndomains = i; in init_by_options()
518 channel->domains[i] = ares_strdup(options->domains[i]); in init_by_options()
519 if (!channel->domains[i]) in init_by_options()
523 channel->ndomains = options->ndomains; in init_by_options()
527 if ((optmask & ARES_OPT_LOOKUPS) && !channel->lookups) in init_by_options()
529 channel->lookups = ares_strdup(options->lookups); in init_by_options()
530 if (!channel->lookups) in init_by_options()
535 if ((optmask & ARES_OPT_SORTLIST) && (channel->nsort == -1)) { in init_by_options()
536 if (options->nsort > 0) { in init_by_options()
537 channel->sortlist = ares_malloc(options->nsort * sizeof(struct apattern)); in init_by_options()
538 if (!channel->sortlist) in init_by_options()
540 for (i = 0; i < options->nsort; i++) in init_by_options()
541 channel->sortlist[i] = options->sortlist[i]; in init_by_options()
543 channel->nsort = options->nsort; in init_by_options()
547 if ((optmask & ARES_OPT_RESOLVCONF) && !channel->resolvconf_path) in init_by_options()
549 channel->resolvconf_path = ares_strdup(options->resolvconf_path); in init_by_options()
550 if (!channel->resolvconf_path && options->resolvconf_path) in init_by_options()
554 channel->optmask = optmask; in init_by_options()
565 if (localdomain && channel->ndomains == -1) in init_by_environment()
590 * holding it as a null-terminated string.
681 * to a newly allocated memory area holding it as a null-terminated string.
778 ** are set. Additionally static DNS settings override DHCP-configured in get_DNS_Registry_NT()
787 /* Global DNS DHCP-configured parameters */ in get_DNS_Registry_NT()
807 /* Adapter specific DNS DHCP-configured parameters */ in get_DNS_Registry_NT()
826 * in *outptr to a newly allocated memory area holding a null-terminated
886 * in *outptr to a newly allocated memory area holding a null-terminated
895 * Note: Ancient PSDK required in order to build a W98 target.
908 /* Verify run-time availability of GetNetworkParams() */ in get_DNS_NetworkParams()
929 for (ipAddr = &fi->DnsServerList; ipAddr; ipAddr = ipAddr->Next) in get_DNS_NetworkParams()
931 txtaddr = &ipAddr->IpAddress.String[0]; in get_DNS_NetworkParams()
982 /* A structure to hold the string form of IPv4 and IPv6 addresses so we can
994 /* Room enough for the string form of any IPv4 or IPv6 address that
995 * ares_inet_ntop() will create. Based on the existing c-ares practice.
1009 if(left->metric < right->metric) return -1; in compareAddresses()
1010 if(left->metric > right->metric) return 1; in compareAddresses()
1012 if(left->orig_idx < right->orig_idx) return -1; in compareAddresses()
1013 if(left->orig_idx > right->orig_idx) return 1; in compareAddresses()
1022 * (and not use DNS servers on a non-preferred route even by forcing request
1023 * to go out on the associated non-preferred interface). i.e. We want to use
1072 /* If the metric is "unused" (-1) or too large for us to add the two in getBestRouteMetric()
1075 || row.Metric == (ULONG)-1 in getBestRouteMetric()
1076 || row.Metric > ((ULONG)-1) - interfaceMetric) { in getBestRouteMetric()
1078 return (ULONG)-1; in getBestRouteMetric()
1084 * http://msdn.microsoft.com/en-us/library/windows/desktop/aa814494(v=vs.85).aspx in getBestRouteMetric()
1095 * in *outptr to a newly allocated memory area holding a null-terminated
1131 /* Verify run-time availability of GetAdaptersAddresses() */ in get_DNS_AdaptersAddresses()
1156 while ((res == ERROR_BUFFER_OVERFLOW) && (--trying)) in get_DNS_AdaptersAddresses()
1174 for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next) in get_DNS_AdaptersAddresses()
1176 if(ipaaEntry->OperStatus != IfOperStatusUp) in get_DNS_AdaptersAddresses()
1179 /* For each interface, find any associated DNS servers as IPv4 or IPv6 in get_DNS_AdaptersAddresses()
1185 for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; in get_DNS_AdaptersAddresses()
1187 ipaDNSAddr = ipaDNSAddr->Next) in get_DNS_AdaptersAddresses()
1189 namesrvr.sa = ipaDNSAddr->Address.lpSockaddr; in get_DNS_AdaptersAddresses()
1191 if (namesrvr.sa->sa_family == AF_INET) in get_DNS_AdaptersAddresses()
1193 if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) || in get_DNS_AdaptersAddresses()
1194 (namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_NONE)) in get_DNS_AdaptersAddresses()
1214 getBestRouteMetric(&ipaaEntry->Luid, in get_DNS_AdaptersAddresses()
1216 ipaaEntry->Ipv4Metric); in get_DNS_AdaptersAddresses()
1220 addresses[addressesIndex].metric = (ULONG)-1; in get_DNS_AdaptersAddresses()
1226 if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, in get_DNS_AdaptersAddresses()
1233 else if (namesrvr.sa->sa_family == AF_INET6) in get_DNS_AdaptersAddresses()
1235 if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, in get_DNS_AdaptersAddresses()
1236 sizeof(namesrvr.sa6->sin6_addr)) == 0) in get_DNS_AdaptersAddresses()
1256 getBestRouteMetric(&ipaaEntry->Luid, in get_DNS_AdaptersAddresses()
1258 ipaaEntry->Ipv6Metric); in get_DNS_AdaptersAddresses()
1262 addresses[addressesIndex].metric = (ULONG)-1; in get_DNS_AdaptersAddresses()
1268 if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, in get_DNS_AdaptersAddresses()
1276 /* Skip non-IPv4/IPv6 addresses completely. */ in get_DNS_AdaptersAddresses()
1286 /* Join them all into a single string, removing duplicates. */ in get_DNS_AdaptersAddresses()
1322 * run-time no matter which Windows version it is. When located, this returns
1324 * a space or comma seperated list of DNS IP addresses, null-terminated.
1334 /* Try using IP helper API GetAdaptersAddresses(). IPv4 + IPv6, also sorts in get_DNS_Windows()
1339 /* Try using IP helper API GetNetworkParams(). IPv4 only. */ in get_DNS_Windows()
1343 /* Fall-back to registry information */ in get_DNS_Windows()
1462 int status = -1, nservers = 0, nsort = 0; in init_by_resolv_conf()
1468 if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */ in init_by_resolv_conf()
1477 if (channel->ndomains == -1 && get_SuffixList_Windows(&line)) in init_by_resolv_conf()
1572 if (channel->ndomains == -1) in init_by_resolv_conf()
1611 if (channel->nservers == -1) { in init_by_resolv_conf()
1633 if (channel->ndomains == -1) { in init_by_resolv_conf()
1638 channel->domains = ares_malloc(entries * sizeof(char *)); in init_by_resolv_conf()
1639 if (!channel->domains) { in init_by_resolv_conf()
1642 channel->ndomains = entries; in init_by_resolv_conf()
1643 for (int i = 0; i < channel->ndomains; ++i) { in init_by_resolv_conf()
1644 channel->domains[i] = ares_strdup(res.dnsrch[i]); in init_by_resolv_conf()
1645 if (!channel->domains[i]) in init_by_resolv_conf()
1650 if (channel->ndots == -1) in init_by_resolv_conf()
1651 channel->ndots = res.ndots; in init_by_resolv_conf()
1652 if (channel->tries == -1) in init_by_resolv_conf()
1653 channel->tries = res.retry; in init_by_resolv_conf()
1654 if (channel->rotate == -1) in init_by_resolv_conf()
1655 channel->rotate = res.options & RES_ROTATE; in init_by_resolv_conf()
1656 if (channel->timeout == -1) in init_by_resolv_conf()
1657 channel->timeout = res.retrans * 1000; in init_by_resolv_conf()
1675 update_domains = (channel->ndomains == -1); in init_by_resolv_conf()
1678 if(channel->resolvconf_path) { in init_by_resolv_conf()
1679 resolvconf_path = channel->resolvconf_path; in init_by_resolv_conf()
1690 else if ((p = try_config(line, "lookup", ';')) && !channel->lookups) in init_by_resolv_conf()
1695 channel->nservers == -1) in init_by_resolv_conf()
1698 channel->nsort == -1) in init_by_resolv_conf()
1724 if ((status == ARES_EOF) && (!channel->lookups)) { in init_by_resolv_conf()
1731 if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) in init_by_resolv_conf()
1754 if ((status == ARES_EOF) && (!channel->lookups)) { in init_by_resolv_conf()
1761 if ((p = try_config(line, "order", '\0')) && !channel->lookups) in init_by_resolv_conf()
1785 if ((status == ARES_EOF) && (!channel->lookups)) { in init_by_resolv_conf()
1792 if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) in init_by_resolv_conf()
1810 /* ignore error, default value will be chosen for `channel->lookups` */ in init_by_resolv_conf()
1834 channel->servers = servers; in init_by_resolv_conf()
1835 channel->nservers = nservers; in init_by_resolv_conf()
1841 channel->sortlist = sortlist; in init_by_resolv_conf()
1842 channel->nsort = nsort; in init_by_resolv_conf()
1856 if (channel->flags == -1) in init_by_defaults()
1857 channel->flags = 0; in init_by_defaults()
1858 if (channel->timeout == -1) in init_by_defaults()
1859 channel->timeout = DEFAULT_TIMEOUT; in init_by_defaults()
1860 if (channel->tries == -1) in init_by_defaults()
1861 channel->tries = DEFAULT_TRIES; in init_by_defaults()
1862 if (channel->ndots == -1) in init_by_defaults()
1863 channel->ndots = 1; in init_by_defaults()
1864 if (channel->rotate == -1) in init_by_defaults()
1865 channel->rotate = 0; in init_by_defaults()
1866 if (channel->udp_port == -1) in init_by_defaults()
1867 channel->udp_port = htons(NAMESERVER_PORT); in init_by_defaults()
1868 if (channel->tcp_port == -1) in init_by_defaults()
1869 channel->tcp_port = htons(NAMESERVER_PORT); in init_by_defaults()
1871 if (channel->ednspsz == -1) in init_by_defaults()
1872 channel->ednspsz = EDNSPACKETSZ; in init_by_defaults()
1874 if (channel->nservers == -1) { in init_by_defaults()
1876 channel->servers = ares_malloc(sizeof(struct server_state)); in init_by_defaults()
1877 if (!channel->servers) { in init_by_defaults()
1881 channel->servers[0].addr.family = AF_INET; in init_by_defaults()
1882 channel->servers[0].addr.addrV4.s_addr = htonl(INADDR_LOOPBACK); in init_by_defaults()
1883 channel->servers[0].addr.udp_port = 0; in init_by_defaults()
1884 channel->servers[0].addr.tcp_port = 0; in init_by_defaults()
1885 channel->nservers = 1; in init_by_defaults()
1889 #define toolong(x) (x == -1) && (SOCKERRNO == WSAEFAULT) in init_by_defaults()
1891 #define toolong(x) (x == -1) && ((SOCKERRNO == ENAMETOOLONG) || \ in init_by_defaults()
1894 #define toolong(x) (x == -1) && (SOCKERRNO == EINVAL) in init_by_defaults()
1897 if (channel->ndomains == -1) { in init_by_defaults()
1902 channel->ndomains = 0; /* default to none */ in init_by_defaults()
1907 channel->ndomains = 0; /* default to none */ in init_by_defaults()
1942 channel->domains = ares_malloc(sizeof(char *)); in init_by_defaults()
1943 if (!channel->domains) { in init_by_defaults()
1947 channel->domains[0] = ares_strdup(dot + 1); in init_by_defaults()
1948 if (!channel->domains[0]) { in init_by_defaults()
1952 channel->ndomains = 1; in init_by_defaults()
1957 if (channel->nsort == -1) { in init_by_defaults()
1958 channel->sortlist = NULL; in init_by_defaults()
1959 channel->nsort = 0; in init_by_defaults()
1962 if (!channel->lookups) { in init_by_defaults()
1963 channel->lookups = ares_strdup("fb"); in init_by_defaults()
1964 if (!channel->lookups) in init_by_defaults()
1970 if(channel->servers) { in init_by_defaults()
1971 ares_free(channel->servers); in init_by_defaults()
1972 channel->servers = NULL; in init_by_defaults()
1975 if(channel->domains && channel->domains[0]) in init_by_defaults()
1976 ares_free(channel->domains[0]); in init_by_defaults()
1977 if(channel->domains) { in init_by_defaults()
1978 ares_free(channel->domains); in init_by_defaults()
1979 channel->domains = NULL; in init_by_defaults()
1982 if(channel->lookups) { in init_by_defaults()
1983 ares_free(channel->lookups); in init_by_defaults()
1984 channel->lookups = NULL; in init_by_defaults()
1987 if(channel->resolvconf_path) { in init_by_defaults()
1988 ares_free(channel->resolvconf_path); in init_by_defaults()
1989 channel->resolvconf_path = NULL; in init_by_defaults()
2005 /* Set a single search domain. */ in config_domain()
2054 channel->lookups = ares_strdup(lookups); in config_lookup()
2055 return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM; in config_lookup()
2080 mask[netmask / 8] = (unsigned char)(0xff << (8 - (netmask % 8))); in ares_ipv6_subnet_matches()
2100 * Site-Local scoped address prefix. These are never valid DNS servers, in ares_ipv6_server_blacklisted()
2122 /* Add the IPv4 or IPv6 nameservers in str (separated by commas) to the
2148 /* Pointer to start of IPv4 or IPv6 address part. */ in config_nameserver()
2213 if (q - str >= 16) { in config_sortlist()
2216 memcpy(ipbuf, str, q-str); in config_sortlist()
2217 ipbuf[q-str] = '\0'; in config_sortlist()
2224 if (q - str >= 32) { in config_sortlist()
2227 memcpy(ipbufpfx, str, q-str); in config_sortlist()
2228 ipbufpfx[q-str] = '\0'; in config_sortlist()
2262 else if (ip_addr(ipbuf, q-str, &pat.addrV4) == 0) in config_sortlist()
2266 memcpy(ipbuf, str, q-str); in config_sortlist()
2267 ipbuf[q-str] = '\0'; in config_sortlist()
2268 if (ip_addr(ipbuf, q-str, &pat.mask.addr4) != 0) in config_sortlist()
2298 if(channel->ndomains != -1) { in set_search()
2299 /* LCOV_EXCL_START: all callers check ndomains == -1 */ in set_search()
2301 ares_strsplit_free(channel->domains, channel->ndomains); in set_search()
2302 channel->domains = NULL; in set_search()
2303 channel->ndomains = -1; in set_search()
2306 channel->domains = ares_strsplit(str, ", ", 1, &cnt); in set_search()
2307 channel->ndomains = (int)cnt; in set_search()
2308 if (channel->domains == NULL || channel->ndomains == 0) { in set_search()
2309 channel->domains = NULL; in set_search()
2310 channel->ndomains = -1; in set_search()
2327 if (val && channel->ndots == -1) in set_options()
2328 channel->ndots = aresx_sltosi(strtol(val, NULL, 10)); in set_options()
2330 if (val && channel->timeout == -1) in set_options()
2331 channel->timeout = aresx_sltosi(strtol(val, NULL, 10)); in set_options()
2333 if (val && channel->tries == -1) in set_options()
2334 channel->tries = aresx_sltosi(strtol(val, NULL, 10)); in set_options()
2336 if (val && channel->rotate == -1) in set_options()
2337 channel->rotate = 1; in set_options()
2349 return ((size_t)(q - p) >= len && !strncmp(p, opt, len)) ? &p[len] : NULL; in try_option()
2365 a not-NUL secondary comment char will be considered when specified. */ in try_config()
2378 q = p - 1; in try_config()
2380 q--; in try_config()
2407 if ((opt[len-1] != ':') && (opt[len-1] != '=') && !ISSPACE(*p)) in try_config()
2430 return -1; in ip_addr()
2433 return -1; in ip_addr()
2442 /* Store a host-byte-order copy of pat in a struct in_addr. Icky, in natural_mask()
2445 addr.s_addr = ntohl(pat->addrV4.s_addr); in natural_mask()
2451 pat->mask.addr4.s_addr = htonl(IN_CLASSA_NET); in natural_mask()
2453 pat->mask.addr4.s_addr = htonl(IN_CLASSB_NET); in natural_mask()
2455 pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET); in natural_mask()
2475 otherwise the code defaults to cross-platform albeit less secure mechanism
2519 state = &key->state[0]; in init_id_key()
2523 randomize_key(key->state,key_data_len); in init_id_key()
2524 key->x = 0; in init_id_key()
2525 key->y = 0; in init_id_key()
2542 channel->local_ip4 = local_ip; in ares_set_local_ip4()
2549 memcpy(&channel->local_ip6, local_ip6, sizeof(channel->local_ip6)); in ares_set_local_ip6()
2556 strncpy(channel->local_dev_name, local_dev_name, in ares_set_local_dev()
2557 sizeof(channel->local_dev_name)); in ares_set_local_dev()
2558 channel->local_dev_name[sizeof(channel->local_dev_name) - 1] = 0; in ares_set_local_dev()
2566 channel->sock_create_cb = cb; in ares_set_socket_callback()
2567 channel->sock_create_cb_data = data; in ares_set_socket_callback()
2574 channel->sock_config_cb = cb; in ares_set_socket_configure_callback()
2575 channel->sock_config_cb_data = data; in ares_set_socket_configure_callback()
2582 channel->sock_funcs = funcs; in ares_set_socket_functions()
2583 channel->sock_func_cb_data = data; in ares_set_socket_functions()
2597 if (channel->sortlist) in ares_set_sortlist()
2598 ares_free(channel->sortlist); in ares_set_sortlist()
2599 channel->sortlist = sortlist; in ares_set_sortlist()
2600 channel->nsort = nsort; in ares_set_sortlist()
2610 for (i = 0; i < channel->nservers; i++) in ares__init_servers_state()
2612 server = &channel->servers[i]; in ares__init_servers_state()
2613 server->udp_socket = ARES_SOCKET_BAD; in ares__init_servers_state()
2614 server->tcp_socket = ARES_SOCKET_BAD; in ares__init_servers_state()
2615 server->tcp_connection_generation = ++channel->tcp_connection_generation; in ares__init_servers_state()
2616 server->tcp_lenbuf_pos = 0; in ares__init_servers_state()
2617 server->tcp_buffer_pos = 0; in ares__init_servers_state()
2618 server->tcp_buffer = NULL; in ares__init_servers_state()
2619 server->tcp_length = 0; in ares__init_servers_state()
2620 server->qhead = NULL; in ares__init_servers_state()
2621 server->qtail = NULL; in ares__init_servers_state()
2622 ares__init_list_head(&server->queries_to_server); in ares__init_servers_state()
2623 server->channel = channel; in ares__init_servers_state()
2624 server->is_broken = 0; in ares__init_servers_state()