If gni_mapped worked for you then something is definitely different anyway.
Well, I did some more tracing of what's going on.
Darwin's getnameinfo() isn't handling the IPv6-IPv4 mapping, so it is sending the address to its DNS server to be reversed looked up without modification. Aren't DNS servers supposed to understand these IPv4-mapped addresses too? That is, must the client resolver detect and downgrade automatically? (Looking at glibc, that's exactly what it does in resolv/nss_dns/dns-host.c.)
Also, upon review of the manpages and RFC 2553, getipnodebyaddr is the only one expliclitly to handle IPv4-mapped addresses. So, adding that call to Jeff's gni_mapped.c yields:
look up via IPv4: 0,0/www.ibm.com look up via IPv6: 8,0/not found look up via IPv6: 0,0/www.ibm.com
where the code looks like:
struct hostent *hptr; hptr = getipnodebyaddr(&sin6.sin6_addr, sizeof sin6.sin6_addr, sin6.sin6_family, &rc); printf("look up via IPv6: %d,%d/%s\n", rc, errno, hptr->h_name); freehostent(hptr);
Also, the BUGS for the Darwin impl say:
The current implementation is not thread-safe.
So, yes, I guess we can step down for the resolver as your patch did. But, I'm wondering whether this is really a 'bug' in Darwin. -- justin