1210.  [bug]           libbind: getnameinfo() failed to lookup IPv4 mapped /
                       compatible addresses. [RT #2461]
This commit is contained in:
Mark Andrews
2002-02-26 03:15:00 +00:00
parent f9f2e770a9
commit 84ef147b1f
3 changed files with 42 additions and 4 deletions
+3
View File
@@ -1,3 +1,6 @@
1210. [bug] libbind: getnameinfo() failed to lookup IPv4 mapped /
compatible addresses. [RT #2461]
1209. [bug] Dig, host, nslookup were not checking the message ids
on the responses. [RT #2454]
+18 -4
View File
@@ -105,9 +105,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
int family, i;
const char *addr;
char *p;
u_char pfx;
char numserv[512];
char numaddr[512];
const struct sockaddr_in6 *sin6;
if (sa == NULL)
return EAI_FAIL;
@@ -157,9 +157,23 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
flags |= NI_NUMERICHOST;
break;
case AF_INET6:
pfx = *addr;
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
flags |= NI_NUMERICHOST;
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
break;
}
if (host == NULL || hostlen == 0) {
+21
View File
@@ -156,11 +156,32 @@ extern const struct in6_addr in6addr_any;
IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
#endif
#ifndef IN6_IS_ADDR_LOOPBACK
extern const struct in6_addr isc_in6addr_loopback;
#define IN6_IS_ADDR_LOOPBACK(a) \
IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
#endif
#ifndef IN6_IS_ADDR_V4MAPPED
#define IN6_IS_ADDR_V4MAPPED(a) \
((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
(a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
(a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
(a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
(a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
(a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
#endif
#ifndef IN6_IS_ADDR_SITELOCAL
#define IN6_IS_ADDR_SITELOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
#endif
#ifndef IN6_IS_ADDR_LINKLOCAL
#define IN6_IS_ADDR_LINKLOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
#endif
#ifndef IN6_IS_ADDR_MULTICAST
#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
#endif