• Home
  • Raw
  • Download

Lines Matching +full:ipv6 +full:- +full:multi +full:- +full:target

21  * SPDX-License-Identifier: curl
75 /* alarm-based timeouts can only be used with all the dependencies satisfied */
85 * The main COMPILE-TIME DEFINES to keep in mind when reading the host*.c
88 * CURLRES_IPV6 - this host has getaddrinfo() and family, and thus we use
89 * that. The host may not be able to resolve IPv6, but we don't really have to
90 * take that into account. Hosts that aren't IPv6-enabled have CURLRES_IPV4
93 * CURLRES_ARES - is defined if libcurl is built to use c-ares for
96 * CURLRES_THREADED - is defined if libcurl is built to run under (native)
98 * supported API will be the same as for ares-builds.
106 * hostip.c - method-independent resolver functions and utility functions
107 * hostasyn.c - functions for asynchronous name resolves
108 * hostsyn.c - functions for synchronous name resolves
109 * hostip4.c - IPv4 specific functions
110 * hostip6.c - IPv6 specific functions
113 * asyn-ares.c - functions for ares-using name resolves
114 * asyn-thread.c - functions for threaded name resolves
129 addr = addr->ai_next; in Curl_num_addresses()
140 * If the conversion fails, the target buffer is empty.
148 switch(ai->ai_family) { in Curl_printable_address()
150 const struct sockaddr_in *sa4 = (const void *)ai->ai_addr; in Curl_printable_address()
151 const struct in_addr *ipaddr4 = &sa4->sin_addr; in Curl_printable_address()
152 (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr4, buf, bufsize); in Curl_printable_address()
157 const struct sockaddr_in6 *sa6 = (const void *)ai->ai_addr; in Curl_printable_address()
158 const struct in6_addr *ipaddr6 = &sa6->sin6_addr; in Curl_printable_address()
159 (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr6, buf, bufsize); in Curl_printable_address()
180 if(len > (buflen - 7)) in create_hostcache_id()
181 len = buflen - 7; in create_hostcache_id()
183 while(len--) { in create_hostcache_id()
200 * Returning non-zero means remove the entry, return 0 to keep it in the
210 return (0 != c->timestamp) in hostcache_timestamp_remove()
211 && (data->now - c->timestamp >= data->cache_timeout); in hostcache_timestamp_remove()
231 * Library-wide function for pruning the DNS cache. This function takes and
238 if((data->set.dns_cache_timeout == -1) || !data->dns.hostcache) in Curl_hostcache_prune()
243 if(data->share) in Curl_hostcache_prune()
249 hostcache_prune(data->dns.hostcache, in Curl_hostcache_prune()
250 data->set.dns_cache_timeout, in Curl_hostcache_prune()
253 if(data->share) in Curl_hostcache_prune()
260 is not thread-safe stuff. */
277 dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1); in fetch_addr()
280 if(!dns && data->state.wildcard_resolve) { in fetch_addr()
284 dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1); in fetch_addr()
287 if(dns && (data->set.dns_cache_timeout != -1)) { in fetch_addr()
292 user.cache_timeout = data->set.dns_cache_timeout; in fetch_addr()
297 Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1); in fetch_addr()
302 if(dns && data->conn->ip_version != CURL_IPRESOLVE_WHATEVER) { in fetch_addr()
305 struct Curl_addrinfo *addr = dns->addr; in fetch_addr()
308 if(data->conn->ip_version == CURL_IPRESOLVE_V6) in fetch_addr()
313 if(addr->ai_family == pf) { in fetch_addr()
317 addr = addr->ai_next; in fetch_addr()
323 Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1); in fetch_addr()
350 if(data->share) in Curl_fetch_addr()
356 dns->inuse++; /* we use it! */ in Curl_fetch_addr()
358 if(data->share) in Curl_fetch_addr()
369 * struct by re-linking its linked list.
398 nodes[i] = nodes[i-1]->ai_next; in Curl_shuffle_addr()
403 /* Fisher-Yates shuffle */ in Curl_shuffle_addr()
406 for(i = num_addrs - 1; i > 0; i--) { in Curl_shuffle_addr()
414 nodes[i-1]->ai_next = nodes[i]; in Curl_shuffle_addr()
417 nodes[num_addrs-1]->ai_next = NULL; in Curl_shuffle_addr()
456 if(data->set.dns_shuffle_addresses) { in Curl_cache_addr()
473 dns->inuse = 1; /* the cache has the first reference */ in Curl_cache_addr()
474 dns->addr = addr; /* this is the address(es) */ in Curl_cache_addr()
475 time(&dns->timestamp); in Curl_cache_addr()
476 if(dns->timestamp == 0) in Curl_cache_addr()
477 dns->timestamp = 1; /* zero indicates permanent CURLOPT_RESOLVE entry */ in Curl_cache_addr()
480 dns2 = Curl_hash_add(data->dns.hostcache, entry_id, entry_len + 1, in Curl_cache_addr()
488 dns->inuse++; /* mark entry as in-use */ in Curl_cache_addr()
493 /* return a static IPv6 ::1 for the name */
500 unsigned char ipv6[16]; in get_localhost6() local
510 if(Curl_inet_pton(AF_INET6, "::1", ipv6) < 1) in get_localhost6()
512 memcpy(&sa6.sin6_addr, ipv6, sizeof(ipv6)); in get_localhost6()
514 ca->ai_flags = 0; in get_localhost6()
515 ca->ai_family = AF_INET6; in get_localhost6()
516 ca->ai_socktype = SOCK_STREAM; in get_localhost6()
517 ca->ai_protocol = IPPROTO_TCP; in get_localhost6()
518 ca->ai_addrlen = (curl_socklen_t)ss_size; in get_localhost6()
519 ca->ai_next = NULL; in get_localhost6()
520 ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo)); in get_localhost6()
521 memcpy(ca->ai_addr, &sa6, ss_size); in get_localhost6()
522 ca->ai_canonname = (char *)ca->ai_addr + ss_size; in get_localhost6()
523 strcpy(ca->ai_canonname, name); in get_localhost6()
551 ca->ai_flags = 0; in get_localhost()
552 ca->ai_family = AF_INET; in get_localhost()
553 ca->ai_socktype = SOCK_STREAM; in get_localhost()
554 ca->ai_protocol = IPPROTO_TCP; in get_localhost()
555 ca->ai_addrlen = (curl_socklen_t)ss_size; in get_localhost()
556 ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo)); in get_localhost()
557 memcpy(ca->ai_addr, &sa, ss_size); in get_localhost()
558 ca->ai_canonname = (char *)ca->ai_addr + ss_size; in get_localhost()
559 strcpy(ca->ai_canonname, name); in get_localhost()
560 ca->ai_next = get_localhost6(port, name); in get_localhost()
566 * Curl_ipv6works() returns TRUE if IPv6 seems to work.
571 /* the nature of most system is that IPv6 status doesn't come and go in Curl_ipv6works()
573 have the info kept for fast re-use */ in Curl_ipv6works()
575 DEBUGASSERT(data->multi); in Curl_ipv6works()
576 if(data->multi->ipv6_up == IPV6_UNKNOWN) { in Curl_ipv6works()
578 data->multi->ipv6_up = works ? IPV6_WORKS : IPV6_DEAD; in Curl_ipv6works()
580 return data->multi->ipv6_up == IPV6_WORKS; in Curl_ipv6works()
583 int ipv6_works = -1; in Curl_ipv6works()
584 /* probe to see if we have a working IPv6 stack */ in Curl_ipv6works()
587 /* an IPv6 address was requested but we can't get/use one */ in Curl_ipv6works()
600 * (or IPv6 if supported) address.
625 return strncasecompare(part, &full[flen - plen], plen); in tailmatch()
640 * CURLRESOLV_ERROR (-1) = error, no pointer
654 struct connectdata *conn = data->conn; in Curl_resolv()
657 conn->bits.doh = FALSE; /* default is not */ in Curl_resolv()
662 if(data->share) in Curl_resolv()
669 dns->inuse++; /* we use it! */ in Curl_resolv()
673 if(data->share) in Curl_resolv()
692 if(data->set.resolver_start) { in Curl_resolv()
695 st = data->set.resolver_start( in Curl_resolv()
697 data->state.async.resolver, in Curl_resolv()
702 data->set.resolver_start_client); in Curl_resolv()
711 * The automagic conversion from IPv4 literals to IPv6 literals only in Curl_resolv()
713 * first. As Curl currently doesn't support system-wide HTTP proxies, we in Curl_resolv()
717 * IPv4-only builds, hence the conditions above. in Curl_resolv()
728 /* This is a dotted IP address 123.123.123.123-style */ in Curl_resolv()
733 /* check if this is an IPv6 address string */ in Curl_resolv()
735 /* This is an IPv6 address literal */ in Curl_resolv()
744 /* This is a dotted IP address 123.123.123.123-style */ in Curl_resolv()
749 /* check if this is an IPv6 address string */ in Curl_resolv()
751 /* This is an IPv6 address literal */ in Curl_resolv()
760 if(conn->ip_version == CURL_IPRESOLVE_V6 && !Curl_ipv6works(data)) in Curl_resolv()
767 else if(allowDOH && data->set.doh && !ipnum) in Curl_resolv()
776 non-zero value indicating that we need to wait for the response to in Curl_resolv()
796 if(data->share) in Curl_resolv()
802 if(data->share) in Curl_resolv()
827 /* this is for "-ansi -Wall -pedantic" to stop complaining! (rabe) */ in alarmfunc()
849 * CURLRESOLV_TIMEDOUT(-2) = warning, time too short or previous alarm expired
850 * CURLRESOLV_ERROR (-1) = error, no pointer
883 if(data->set.no_signal) in Curl_resolv_timeout()
901 /* This allows us to time-out from the name resolver, as the timeout in Curl_resolv_timeout()
980 data->conn->created) / 1000; in Curl_resolv_timeout()
983 unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs); in Curl_resolv_timeout()
987 /* if the alarm time-left reached zero or turned "negative" (counted in Curl_resolv_timeout()
1012 if(data && data->share) in Curl_resolv_unlock()
1017 if(data && data->share) in Curl_resolv_unlock()
1022 * File-internal: release cache dns entry reference, free if inuse drops to 0
1027 DEBUGASSERT(dns && (dns->inuse>0)); in freednsentry()
1029 dns->inuse--; in freednsentry()
1030 if(dns->inuse == 0) { in freednsentry()
1031 Curl_freeaddrinfo(dns->addr); in freednsentry()
1055 if(data && data->share) in Curl_hostcache_clean()
1060 if(data && data->share) in Curl_hostcache_clean()
1071 data->state.wildcard_resolve = false; in Curl_loadhostpairs()
1073 for(hostp = data->state.resolve; hostp; hostp = hostp->next) { in Curl_loadhostpairs()
1075 if(!hostp->data) in Curl_loadhostpairs()
1077 if(hostp->data[0] == '-') { in Curl_loadhostpairs()
1081 host_end = strchr(&hostp->data[1], ':'); in Curl_loadhostpairs()
1084 hlen = host_end - &hostp->data[1]; in Curl_loadhostpairs()
1091 hostp->data); in Curl_loadhostpairs()
1095 entry_len = create_hostcache_id(&hostp->data[1], hlen, (int)num, in Curl_loadhostpairs()
1097 if(data->share) in Curl_loadhostpairs()
1101 Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1); in Curl_loadhostpairs()
1103 if(data->share) in Curl_loadhostpairs()
1122 char *host_begin = hostp->data; in Curl_loadhostpairs()
1132 hlen = host_end - host_begin; in Curl_loadhostpairs()
1156 if(addr_end == addr_begin || *(addr_end - 1) != ']') in Curl_loadhostpairs()
1159 --addr_end; in Curl_loadhostpairs()
1162 alen = addr_end - addr_begin; in Curl_loadhostpairs()
1174 infof(data, "Ignoring resolve address '%s', missing IPv6 support.", in Curl_loadhostpairs()
1187 tail->ai_next = ai; in Curl_loadhostpairs()
1188 tail = tail->ai_next; in Curl_loadhostpairs()
1202 hostp->data); in Curl_loadhostpairs()
1211 if(data->share) in Curl_loadhostpairs()
1215 dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1); in Curl_loadhostpairs()
1218 infof(data, "RESOLVE %.*s:%d is - old addresses discarded", in Curl_loadhostpairs()
1226 3. when adding a non-permanent entry, we want it to remove and in Curl_loadhostpairs()
1228 4. when adding a non-permanent entry, we want it to get a "fresh" in Curl_loadhostpairs()
1231 Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1); in Curl_loadhostpairs()
1238 dns->timestamp = 0; /* mark as permanent */ in Curl_loadhostpairs()
1241 dns->inuse--; in Curl_loadhostpairs()
1244 if(data->share) in Curl_loadhostpairs()
1253 permanent ? "" : " (non-permanent)"); in Curl_loadhostpairs()
1258 data->state.wildcard_resolve = true; in Curl_loadhostpairs()
1262 data->state.resolve = NULL; /* dealt with now */ in Curl_loadhostpairs()
1275 if(data->conn->bits.doh) in Curl_resolv_check()
1286 if(data->conn->bits.doh) in Curl_resolv_getsock()
1307 struct connectdata *conn = data->conn; in Curl_once_resolved()
1310 if(data->state.async.dns) { in Curl_once_resolved()
1311 conn->dns_entry = data->state.async.dns; in Curl_once_resolved()
1312 data->state.async.dns = NULL; in Curl_once_resolved()
1338 struct connectdata *conn = data->conn; in Curl_resolver_error()
1339 if(conn->bits.httpproxy) { in Curl_resolver_error()
1351 data->state.async.hostname); in Curl_resolver_error()