/* Mapping between known hosts and to lists of their addresses. */
static struct hash_table *host_name_addresses_map;
-
-#ifdef ENABLE_IPV6
-/* The IP family to request when connecting to remote hosts. This
- should be moved to an entry in struct options when we implement the
- --inet4/--inet6 flags. */
-static int requested_family = AF_UNSPEC;
-#endif
\f
/* Lists of addresses. This should eventually be extended to handle
IPv6. */
{
struct address_list *al = NULL;
- /* If we're not using getaddrinfo, first check if HOST names a
- numeric IPv4 address. This was necessary under old (e.g. Ultrix)
- implementations of gethostbyname that couldn't handle numeric
- addresses (!). This is not done under IPv6 because getaddrinfo
- always handles numeric addresses. */
#ifndef ENABLE_IPV6
+ /* If we're not using getaddrinfo, first check if HOST names a
+ numeric IPv4 address. gethostbyname is not required to accept
+ dotted-decimal IPv4 addresses, and some older implementations
+ (e.g. the Ultrix one) indeed didn't. */
{
uint32_t addr_ipv4 = (uint32_t)inet_addr (host);
if (addr_ipv4 != (uint32_t) -1)
xzero (hints);
hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = requested_family;
+ hints.ai_family = AF_UNSPEC; /* #### should look at opt.ipv4_only
+ and opt.ipv6_only */
hints.ai_flags = 0;
err = getaddrinfo_with_timeout (host, NULL, &hints, &res, opt.dns_timeout);
}
al = address_list_from_addrinfo (res);
freeaddrinfo (res);
+ if (!al)
+ {
+ logprintf (LOG_VERBOSE, _("failed: No IPv4/IPv6 addresses.\n"));
+ return NULL;
+ }
}
#else
{
xzero (hints);
hints.ai_socktype = SOCK_STREAM;
- hints.ai_family = requested_family;
+ hints.ai_family = AF_UNSPEC; /* #### should look at opt.ipv4_only
+ and opt.ipv6_only */
hints.ai_flags = AI_PASSIVE;
err = getaddrinfo (host, NULL, &hints, &res);