Colm MacCarthaigh wrote:

- 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);

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 ?

urr, I didn't have the getnameinfo() call patched properly :( my apologies :(


with the patch properly applied the second getnameinfo() call works, which I suppose is intended to prove that when it didn't work we had the right data in the right place and it failed due to system library fubar

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;

Yeah, that looks reasonable :) I'm still curious about what was happening on Justin's system.






Reply via email to