Hi!

I just noticed that the php function gethostbyaddr is not able to lookup
IPv6 mapped IPv4 or native IPv6 addresses.

Because I get such addresses from the apache 1.3.19 when it is patched
with the KAME IPv6 patch (that's the normal way to IPv6 enable apache
1.3) I noticed the problem.

Attached is a patch that enables php to lookup such addresses too.


Tot kijk
   Matthias
-- 
Fon: +49-(0)70 0770 07770               http://matthias-wimmer.de/
Fax: +49-(0)89 312 88 654               jabber:[EMAIL PROTECTED]

Der Euro, unser Geld - noch 105 Tage.
--- php-4.0.6/ext/standard/dns.c        Tue Sep 18 18:17:58 2001
+++ php-4.0.6-patched/ext/standard/dns.c        Tue Sep 18 18:17:34 2001
@@ -81,9 +81,22 @@
 
 char *php_gethostbyaddr(char *ip)
 {
+#if HAVE_IPV6
+       struct in6_addr addr6;
+#else
        struct in_addr addr;
+#endif
        struct hostent *hp;
 
+#if HAVE_IPV6
+       if (!inet_pton(AF_INET6, ip, &addr6)) {
+#if PHP_DEBUG
+               php_error(E_WARNING, "address is not a valid IPv4 or IPv6 address");
+#endif
+               return estrdup(ip);
+       }
+       hp = gethostbyaddr((char *) &addr6, sizeof(addr6), AF_INET6);
+#else
        addr.s_addr = inet_addr(ip);
        if (addr.s_addr == -1) {
 #if PHP_DEBUG
@@ -92,6 +105,7 @@
                return estrdup(ip);
        }
        hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
+#endif
        if (!hp) {
 #if PHP_DEBUG
                php_error(E_WARNING, "Unable to resolve %s\n", ip);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to