1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00
2000-05-27  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/posix/getaddrinfo.c (gaih_inet): If req->ai_family ==
	AF_UNSPEC don't allow the IPv6 lookup to return mapped IPv4 addresses.

	* nss/nss_files/files-hosts.c (LINE_PARSER): Simplify.  Correct
	handling of AI_V4MAPPED flag.

	* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): If lookup
	of IPv6 address failed and RES_USE_INET6 bit in _res.options is set,
	perform lookup for T_A type and tell getanswer_r to convert the
	result with new argument.
	(_nss_dns_gethostbyaddr_r): Pass zero as new argument to getanswer_r.
	Don't convert addresses from IPv4 to IPv6 here.
	(getanswer_r): Take new parameter indicating if mapping from IPv4 to
	IPv6 is wanted.  Allow qtype and type from reply to disagree if
	IPv4 mapping has to be done.  Perform mappings if required by the
	caller and not if RES_USE_INET6 bit in _res.options is set.
	Add several __builtin_expect.
This commit is contained in:
Ulrich Drepper
2000-05-27 08:17:05 +00:00
parent 9c42c64d30
commit b455972fda
3 changed files with 88 additions and 50 deletions

View File

@@ -53,31 +53,19 @@ LINE_PARSER
STRING_FIELD (addr, isspace, 1);
/* Parse address. */
if (af == AF_INET && inet_pton (AF_INET, addr, entdata->host_addr) > 0)
{
if (flags & AI_V4MAPPED)
{
map_v4v6_address ((char *) entdata->host_addr,
(char *) entdata->host_addr);
result->h_addrtype = AF_INET6;
result->h_length = IN6ADDRSZ;
}
else
{
result->h_addrtype = AF_INET;
result->h_length = INADDRSZ;
}
}
else if (af == AF_INET6
&& inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
{
result->h_addrtype = AF_INET6;
result->h_length = IN6ADDRSZ;
}
else
if (inet_pton (af, addr, entdata->host_addr) <= 0
&& (af != AF_INET6 || (flags & AI_V4MAPPED) == 0
|| inet_pton (AF_INET, addr, entdata->host_addr) <= 0
|| (map_v4v6_address ((char *) entdata->host_addr,
(char *) entdata->host_addr),
0)))
/* Illegal address: ignore line. */
return 0;
/* We always return entries of the requested form. */
result->h_addrtype = af;
result->h_length = af == AF_INET ? INADDRSZ : IN6ADDRSZ;
/* Store a pointer to the address in the expected form. */
entdata->h_addr_ptrs[0] = entdata->host_addr;
entdata->h_addr_ptrs[1] = NULL;
@@ -97,6 +85,8 @@ DB_LOOKUP (hostbyname, ,,
}, const char *name)
#undef EXTRA_ARGS_VALUE
/* XXX Is using _res to determine whether we want to convert IPv4 addresses
to IPv6 addresses really the right thing to do? */
#define EXTRA_ARGS_VALUE \
, af, ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)
DB_LOOKUP (hostbyname2, ,,