aboutsummaryrefslogtreecommitdiff
path: root/ares/ares__get_hostent.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2009-01-31 20:17:41 +0000
committerDaniel Stenberg <daniel@haxx.se>2009-01-31 20:17:41 +0000
commita2256e899b7c122169b9c50e8cb92ac6fc51e95b (patch)
tree0235ee52cb2d1054027f4a7c083b0665035b442e /ares/ares__get_hostent.c
parent8b6805572a5322bd4addbf45382f0041cc09c885 (diff)
- ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving
either AF_INET6 or AF_INET. It works by accepting any of the looksups in the hosts file, and it resolves the AAAA field with a fallback to A.
Diffstat (limited to 'ares/ares__get_hostent.c')
-rw-r--r--ares/ares__get_hostent.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/ares/ares__get_hostent.c b/ares/ares__get_hostent.c
index 40dad5d56..c14919a97 100644
--- a/ares/ares__get_hostent.c
+++ b/ares/ares__get_hostent.c
@@ -68,17 +68,21 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
*p = 0;
addr.s_addr = inet_addr(line);
if (addr.s_addr == INADDR_NONE)
- {
- if (ares_inet_pton(AF_INET6, line, &addr6) > 0)
- {
- if (family != AF_INET6)
- continue;
- addrlen = sizeof(struct in6_addr);
- }
- else
- continue;
- }
+ {
+ /* It wasn't an AF_INET dotted address, then AF_UNSPEC and AF_INET6
+ families are subject for this further check */
+ if ((family != AF_INET) &&
+ (ares_inet_pton(AF_INET6, line, &addr6) > 0)) {
+ addrlen = sizeof(struct in6_addr);
+ family = AF_INET6;
+ }
+ else
+ continue;
+ }
+ else if (family == AF_UNSPEC)
+ family = AF_INET; /* now confirmed! */
else if (family != AF_INET)
+ /* unknown, keep moving */
continue;
/* Get the canonical hostname. */