|
Lines 2403-2438
getaddrinfo (const char *name, const char *service,
|
Link Here
|
|---|
|
| 2403 |
bool seen_ipv6 = false; |
2403 |
bool seen_ipv6 = false; |
| 2404 |
bool check_pf_called = false; |
2404 |
bool check_pf_called = false; |
| 2405 |
|
2405 |
|
| 2406 |
if (hints->ai_flags & AI_ADDRCONFIG) |
|
|
| 2407 |
{ |
| 2408 |
/* We might need information about what interfaces are available. |
| 2409 |
Also determine whether we have IPv4 or IPv6 interfaces or both. We |
| 2410 |
cannot cache the results since new interfaces could be added at |
| 2411 |
any time. */ |
| 2412 |
__check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen); |
| 2413 |
check_pf_called = true; |
| 2414 |
|
| 2415 |
/* Now make a decision on what we return, if anything. */ |
| 2416 |
if (hints->ai_family == PF_UNSPEC && (seen_ipv4 || seen_ipv6)) |
| 2417 |
{ |
| 2418 |
/* If we haven't seen both IPv4 and IPv6 interfaces we can |
| 2419 |
narrow down the search. */ |
| 2420 |
if ((! seen_ipv4 || ! seen_ipv6) && (seen_ipv4 || seen_ipv6)) |
| 2421 |
{ |
| 2422 |
local_hints = *hints; |
| 2423 |
local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6; |
| 2424 |
hints = &local_hints; |
| 2425 |
} |
| 2426 |
} |
| 2427 |
else if ((hints->ai_family == PF_INET && ! seen_ipv4) |
| 2428 |
|| (hints->ai_family == PF_INET6 && ! seen_ipv6)) |
| 2429 |
{ |
| 2430 |
/* We cannot possibly return a valid answer. */ |
| 2431 |
__free_in6ai (in6ai); |
| 2432 |
return EAI_NONAME; |
| 2433 |
} |
| 2434 |
} |
| 2435 |
|
| 2436 |
if (service && service[0]) |
2406 |
if (service && service[0]) |
| 2437 |
{ |
2407 |
{ |
| 2438 |
char *c; |
2408 |
char *c; |