apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colm MacCarthaigh <c...@stdlib.net>
Subject Re: cvs commit: apr configure.in CHANGES
Date Mon, 25 Aug 2003 23:48:48 GMT
On Mon, Aug 25, 2003 at 01:54:19PM -0400, Jeff Trawick wrote:
> >--- gni_mapped.c	Sat Feb 15 00:18:30 2003
> >+++ gni_mapped2.c	Mon Aug 25 17:40:15 2003
> >@@ -37,8 +37,10 @@
> >     rc = getnameinfo((struct sockaddr *)&sin, sizeof sin, hostbuf, sizeof 
> >     hostbuf, NULL, 0, 0);
> >     printf("look up via IPv4: %d/%s\n", rc, hostbuf);
> >     
> >+    sin.sin_addr.s_addr = sin6.sin6_addr.s6_addr32[3];
> 
> the presence of this line doesn't make any difference on my box
> 
> compiling with -DKERNEL picks up the s6_addr32 macro on Jaguar
> 
> >+
> >     strcpy(hostbuf, "not found");
> >-    rc = getnameinfo((struct sockaddr *)&sin6, sizeof sin6, hostbuf, 
> >sizeof hostbuf, NULL, 0, NI_NAMEREQD);
> >+    rc = getnameinfo((struct sockaddr *)&sin, sizeof sin, hostbuf, sizeof 
> >hostbuf, NULL, 0, 0);
> >     printf("look up via IPv6: %d/%s\n", rc, hostbuf);
> 
> without the NI_NAMEREQD flag, with our without the line you added 
> previously, I get
> 
> look up via IPv6: 0/::ffff:812a:1263

Hmmm, that doesnt make much sense. At the very least the different sin
size should be making it print an IPv4 address. Did you make both
sin6 -> sin changes on that line ?

> >     return 0;
> >
> >
> >Where .s6_addr32 is the appropriate member of sin6_addr on darwin,
> >for BSDs it should be:
> >
> >sin6.sin6_addr.__u6_addr.__u6_addr32[3];
> >
> >That will tell if the patch would fix thigns (which it does for my
> >friends).
> 
> which patch are we talking about?

The one below, it fixes things for at least 3 Darwin using friends
of mine.

Index: network_io/unix/sockaddr.c
===================================================================
RCS file: /home/cvspublic/apr/network_io/unix/sockaddr.c,v
retrieving revision 1.41
diff -u -r1.41 sockaddr.c
--- network_io/unix/sockaddr.c	14 Aug 2003 17:36:17 -0000	1.41
+++ network_io/unix/sockaddr.c	14 Aug 2003 22:40:38 -0000
@@ -634,9 +634,29 @@
      * a numeric address string if it fails to resolve the host name;
      * that is *not* what we want here
      */
+#ifdef DARWIN && APR_HAVE_IPV6
+    /* Darwin's getnameinfo does not work for IPv4-mapped-IPv6 addresses,
+     * the workaround is to convert the last 32 bits of the IPv6 address 
+     * to a valid sockaddr_in structure. This is extremely hacky, avoid
+     * re-use. */
+    if (sockaddr->family == AF_INET6 && 
+        IN6_IS_ADDR_V4MAPPED(&sockaddr->sa.sin6.sin6_addr)) {
+        struct apr_sockaddr_t tmpsa;
+
+        tmpsa.sa.sin.sin_family = AF_INET;
+        tmpsa.sa.sin.sin_addr.s_addr = ((uint32_t *)sockaddr->ipaddr_ptr)[3]; 
+
+        rc = getnameinfo((const struct sockaddr *)&tmpsa.sa, 
+                         sizeof(struct sockaddr_in), tmphostname, 
+                         sizeof(tmphostname), NULL, 0,
+                         flags != 0 ? flags : NI_NAMEREQD);
+    }
+    else
+#endif
     rc = getnameinfo((const struct sockaddr *)&sockaddr->sa, sockaddr->salen,
                      tmphostname, sizeof(tmphostname), NULL, 0,
                      flags != 0 ? flags : NI_NAMEREQD);
+
     if (rc != 0) {
         *hostname = NULL;
 


-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net
colm@stdlib.net					  http://www.stdlib.net/

Mime
View raw message