diff options
author | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2003-08-31 16:28:55 +0000 |
---|---|---|
committer | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2003-08-31 16:28:55 +0000 |
commit | c0f3290ba99880087429e4f721fb58cb9393d432 (patch) | |
tree | 872eea38f72760265ba8cfe530f06325ce5a95d8 /network_io | |
parent | 295bf8dfdce0c440370f925cd52969dd0b189092 (diff) | |
download | libapr-c0f3290ba99880087429e4f721fb58cb9393d432.tar.gz |
Attempt to put this Darwin getnameinfo() sillyness behind us forever. If
future releases of Darwin get it 'right', then we'll detect that.
Take Jeff's gni_mapped and rewrite it as an autoconf macro, so we can do
configure-time detection of this brokenness and stop hardcoding Darwin's
inability to do the drop down.
Then, take Colm's patch and make it conditional on the autoconf macro above.
Submitted by: Colm MacCarthaigh <colm@stdlib.net> and Jeff Trawick
Reviewed by: Justin Erenkrantz
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/unix/sockaddr.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 7e111db18..765252b2e 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -632,10 +632,29 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, /* don't know if it is portable for getnameinfo() to set h_errno; * clear it then see if it was set */ SET_H_ERRNO(0); + /* default flags are NI_NAMREQD; otherwise, getnameinfo() will return * a numeric address string if it fails to resolve the host name; * that is *not* what we want here + * + * Additionally, if we know getnameinfo() doesn't handle IPv4-mapped + * IPv6 addresses correctly, drop down to IPv4 before calling + * getnameinfo(). */ +#ifdef GETNAMEINFO_IPV4_MAPPED_FAILS + 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); |