From a2256e899b7c122169b9c50e8cb92ac6fc51e95b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 31 Jan 2009 20:17:41 +0000 Subject: - 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. --- ares/ares__get_hostent.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'ares/ares__get_hostent.c') 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. */ -- cgit v1.2.3