diff options
author | Daniel Stenberg <daniel@haxx.se> | 2009-01-31 20:17:41 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2009-01-31 20:17:41 +0000 |
commit | 1ce8e6583ebcdc448c3187d186a9ef219218bfdb (patch) | |
tree | 544bf377dbb9d8320556ec5ad0ba72f25fa77640 /ares__get_hostent.c | |
parent | 054aa0e11e3e71109bcb994146f2e641916ef115 (diff) | |
download | c-ares-1ce8e6583ebcdc448c3187d186a9ef219218bfdb.tar.gz c-ares-1ce8e6583ebcdc448c3187d186a9ef219218bfdb.tar.bz2 c-ares-1ce8e6583ebcdc448c3187d186a9ef219218bfdb.zip |
- 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__get_hostent.c')
-rw-r--r-- | ares__get_hostent.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/ares__get_hostent.c b/ares__get_hostent.c index 40dad5d..c14919a 100644 --- a/ares__get_hostent.c +++ b/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. */ |