-/* Copyright 1998 by the Massachusetts Institute of Technology.
+/* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
#include "ares_setup.h"
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
# include <arpa/nameser_compat.h>
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "ares.h"
-#include "inet_net_pton.h"
+#include "ares_inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
+#include "ares_nowarn.h"
#include "ares_private.h"
#ifdef WATT32
else if (hquery->sent_family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
- if (status == ARES_ENODATA || status == ARES_EBADRESP) {
+ if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
+ hquery->want_family == AF_UNSPEC) {
/* The query returned something but either there were no AAAA
records (e.g. just CNAME) or the response was malformed. Try
- looking up A instead. We should possibly limit this
- attempt-next logic to AF_UNSPEC lookups only. */
+ looking up A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
end_hquery(hquery, status, host);
}
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
- status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
+ status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
+ hquery->want_family == AF_UNSPEC))
{
- /* The AAAA query yielded no useful result. Now look up an A instead.
- We should possibly limit this attempt-next logic to AF_UNSPEC lookups
- only. */
+ /* The AAAA query yielded no useful result. Now look up an A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);
/* Fill in the rest of the host structure and terminate the query. */
addrs[1] = NULL;
hostent.h_aliases = aliases;
- hostent.h_addrtype = family;
+ hostent.h_addrtype = aresx_sitoss(family);
hostent.h_addr_list = addrs;
callback(arg, ARES_SUCCESS, 0, &hostent);
PATH_HOSTS[0] = '\0';
- platform = getplatform();
+ platform = ares__getplatform();
if (platform == WIN_NT) {
char tmp[MAX_PATH];
}
else
{
- if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
- sortlist[i].mask.bits))
+ if (!ares__bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
+ sortlist[i].mask.bits))
break;
}
}
{
if (sortlist[i].family != AF_INET6)
continue;
- if (!ares_bitncmp(addr,
- &sortlist[i].addrV6,
- sortlist[i].mask.bits))
- break;
+ if (!ares__bitncmp(addr, &sortlist[i].addrV6, sortlist[i].mask.bits))
+ break;
}
return i;
}