]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorMark Andrews <marka@isc.org>
Tue, 26 Feb 2002 03:15:00 +0000 (03:15 +0000)
committerMark Andrews <marka@isc.org>
Tue, 26 Feb 2002 03:15:00 +0000 (03:15 +0000)
1210.  [bug]           libbind: getnameinfo() failed to lookup IPv4 mapped /
                       compatible addresses. [RT #2461]

CHANGES
lib/bind/irs/getnameinfo.c
lib/bind/port_after.h.in

diff --git a/CHANGES b/CHANGES
index 303d892ce22e6f039348e044a64bac76b9c0eff9..48bcdab2a147b197b14d26b79a7eeaba9c7a96e8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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]
 
index 0e86cc1523043c04475d15af014a8919baffd4df..9b26c641ff675816d48d74fab00e816f105e6486 100644 (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) {
index f120779e59fb637a77baf03dcbee7b9ff8551ffc..fcbc99c9d37be2a85cb43c1518ea4c6e6bcb3923 100644 (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