- int count; /* number of adrresses */
- ip_address *addresses; /* pointer to the string of addresses */
+ int count; /* number of adrresses */
+ ip_address *addresses; /* pointer to the string of addresses */
- int faulty; /* number of addresses known not to work. */
- bool connected; /* whether we were able to connect to
- one of the addresses in the list,
- at least once. */
+ int faulty; /* number of addresses known not to work. */
+ bool connected; /* whether we were able to connect to
+ one of the addresses in the list,
+ at least once. */
- int refcount; /* reference count; when it drops to
- 0, the entry is freed. */
+ int refcount; /* reference count; when it drops to
+ 0, the entry is freed. */
- {
- ip_address *cur = al->addresses + i;
- if (cur->family == AF_INET
- && (cur->data.d4.s_addr == ip->data.d4.s_addr))
- return true;
- }
+ {
+ ip_address *cur = al->addresses + i;
+ if (cur->family == AF_INET
+ && (cur->data.d4.s_addr == ip->data.d4.s_addr))
+ return true;
+ }
- const struct sockaddr_in6 *sin6 =
- (const struct sockaddr_in6 *)ptr->ai_addr;
- ip->family = AF_INET6;
- ip->data.d6 = sin6->sin6_addr;
+ const struct sockaddr_in6 *sin6 =
+ (const struct sockaddr_in6 *)ptr->ai_addr;
+ ip->family = AF_INET6;
+ ip->data.d6 = sin6->sin6_addr;
- const struct sockaddr_in *sin =
- (const struct sockaddr_in *)ptr->ai_addr;
- ip->family = AF_INET;
- ip->data.d4 = sin->sin_addr;
- ++ip;
+ const struct sockaddr_in *sin =
+ (const struct sockaddr_in *)ptr->ai_addr;
+ ip->family = AF_INET;
+ ip->data.d4 = sin->sin_addr;
+ ++ip;
int i;
debug_logprintf ("Caching %s =>", host);
for (i = 0; i < al->count; i++)
int i;
debug_logprintf ("Caching %s =>", host);
for (i = 0; i < al->count; i++)
LH_SILENT - don't print the "resolving ... done" messages.
LH_BIND - resolve addresses for use with bind, which under
IPv6 means to use AI_PASSIVE flag to getaddrinfo.
LH_SILENT - don't print the "resolving ... done" messages.
LH_BIND - resolve addresses for use with bind, which under
IPv6 means to use AI_PASSIVE flag to getaddrinfo.
- /* No need to cache host->addr relation, just return the
- address. */
- char *vec[2];
- vec[0] = (char *)&addr_ipv4;
- vec[1] = NULL;
- return address_list_from_ipv4_addresses (vec);
+ /* No need to cache host->addr relation, just return the
+ address. */
+ char *vec[2];
+ vec[0] = (char *)&addr_ipv4;
+ vec[1] = NULL;
+ return address_list_from_ipv4_addresses (vec);
hints.ai_family = AF_INET6;
else
/* We tried using AI_ADDRCONFIG, but removed it because: it
hints.ai_family = AF_INET6;
else
/* We tried using AI_ADDRCONFIG, but removed it because: it
- misinterprets IPv6 loopbacks, it is broken on AIX 5.1, and
- it's unneeded since we sort the addresses anyway. */
- hints.ai_family = AF_UNSPEC;
+ misinterprets IPv6 loopbacks, it is broken on AIX 5.1, and
+ it's unneeded since we sort the addresses anyway. */
+ hints.ai_family = AF_UNSPEC;
- /* Where available, the AI_NUMERICHOST hint can prevent costly
- access to DNS servers. */
- hints.ai_flags |= AI_NUMERICHOST;
- timeout = 0; /* no timeout needed when "resolving"
- numeric hosts -- avoid setting up
- signal handlers and such. */
+ /* Where available, the AI_NUMERICHOST hint can prevent costly
+ access to DNS servers. */
+ hints.ai_flags |= AI_NUMERICHOST;
+ timeout = 0; /* no timeout needed when "resolving"
+ numeric hosts -- avoid setting up
+ signal handlers and such. */
}
#endif
err = getaddrinfo_with_timeout (host, NULL, &hints, &res, timeout);
if (err != 0 || res == NULL)
{
}
#endif
err = getaddrinfo_with_timeout (host, NULL, &hints, &res, timeout);
if (err != 0 || res == NULL)
{
- if (!silent)
- logprintf (LOG_VERBOSE, _("failed: %s.\n"),
- err != EAI_SYSTEM ? gai_strerror (err) : strerror (errno));
- return NULL;
+ if (!silent)
+ logprintf (LOG_VERBOSE, _("failed: %s.\n"),
+ err != EAI_SYSTEM ? gai_strerror (err) : strerror (errno));
+ return NULL;
- logprintf (LOG_VERBOSE,
- _("failed: No IPv4/IPv6 addresses for host.\n"));
- return NULL;
+ logprintf (LOG_VERBOSE,
+ _("failed: No IPv4/IPv6 addresses for host.\n"));
+ return NULL;
the addresses with the same family is undisturbed. */
if (al->count > 1 && opt.prefer_family != prefer_none)
stable_sort (al->addresses, al->count, sizeof (ip_address),
the addresses with the same family is undisturbed. */
if (al->count > 1 && opt.prefer_family != prefer_none)
stable_sort (al->addresses, al->count, sizeof (ip_address),
}
#else /* not ENABLE_IPV6 */
{
struct hostent *hptr = gethostbyname_with_timeout (host, timeout);
if (!hptr)
{
}
#else /* not ENABLE_IPV6 */
{
struct hostent *hptr = gethostbyname_with_timeout (host, timeout);
if (!hptr)
{
- if (!silent)
- {
- if (errno != ETIMEDOUT)
- logprintf (LOG_VERBOSE, _("failed: %s.\n"),
- host_errstr (h_errno));
- else
- logputs (LOG_VERBOSE, _("failed: timed out.\n"));
- }
- return NULL;
+ if (!silent)
+ {
+ if (errno != ETIMEDOUT)
+ logprintf (LOG_VERBOSE, _("failed: %s.\n"),
+ host_errstr (h_errno));
+ else
+ logputs (LOG_VERBOSE, _("failed: timed out.\n"));
+ }
+ return NULL;
- {
- logputs (LOG_VERBOSE, print_address (al->addresses + i));
- if (i < printmax - 1)
- logputs (LOG_VERBOSE, ", ");
- }
+ {
+ logputs (LOG_VERBOSE, print_address (al->addresses + i));
+ if (i < printmax - 1)
+ logputs (LOG_VERBOSE, ", ");
+ }
for (i = 0; list[i]; i++)
{
for (j = strlen (list[i]), k = lw; j >= 0 && k >= 0; j--, k--)
for (i = 0; list[i]; i++)
{
for (j = strlen (list[i]), k = lw; j >= 0 && k >= 0; j--, k--)
{
hash_table_iterator iter;
for (hash_table_iterate (host_name_addresses_map, &iter);
{
hash_table_iterator iter;
for (hash_table_iterate (host_name_addresses_map, &iter);
- hash_table_iter_next (&iter);
- )
- {
- char *host = iter.key;
- struct address_list *al = iter.value;
- xfree (host);
- assert (al->refcount == 1);
- address_list_delete (al);
- }
+ hash_table_iter_next (&iter);
+ )
+ {
+ char *host = iter.key;
+ struct address_list *al = iter.value;
+ xfree (host);
+ assert (al->refcount == 1);
+ address_list_delete (al);
+ }