Please cast your votes if you believe we need an IPv4 mapped IPv6
lookup of IPv4 addresses (by name or dotted IP).  The complete
APR_IPV6_V4MAPPED_OK patch is attached (and present on trunk,
unless/until voted down here on this thread.)

As Joe and I disagree on the usefulness of this API - we leave
it to all of you to chime in one way or the other.


Index: include/apr_network_io.h
===================================================================
--- include/apr_network_io.h	(revision 602175)
+++ include/apr_network_io.h	(revision 603435)
@@ -111,6 +111,7 @@
 
 #define APR_IPV4_ADDR_OK  0x01  /**< @see apr_sockaddr_info_get() */
 #define APR_IPV6_ADDR_OK  0x02  /**< @see apr_sockaddr_info_get() */
+#define APR_IPV6_V4MAPPED_OK 0x04 /**< @see apr_sockaddr_info_get() */
 
 #if (!APR_HAVE_IN_ADDR)
 /**
@@ -367,6 +368,9 @@
  *                                 only valid if family is APR_UNSPEC and hostname
  *                                 isn't NULL and APR_HAVE_IPV6; mutually exclusive
  *                                 with APR_IPV4_ADDR_OK
+ *       APR_IPV6_V4MAPPED_OK      Used with family APR_INET6, if no matching
+ *                                 IPv6 addresses could be matched, then 
+ *                                 accept IPv4 addresses as mapped matches.
  * </PRE>
  * @param p The pool for the apr_sockaddr_t and associated storage.
  */
Index: network_io/unix/sockaddr.c
===================================================================
--- network_io/unix/sockaddr.c	(revision 602175)
+++ network_io/unix/sockaddr.c	(revision 603435)
@@ -344,6 +344,11 @@
         servname = apr_itoa(p, port);
 #endif /* OSF1 */
     }
+#if APR_HAVE_IPV6 && defined(AI_V4MAPPED)
+    if (flags & APR_IPV6_V4MAPPED_OK && family == APR_INET6) {
+        hints.ai_flags |= AI_V4MAPPED;
+    }
+#endif
     error = getaddrinfo(hostname, servname, &hints, &ai_list);
 #ifdef HAVE_GAI_ADDRCONFIG
     if (error == EAI_BADFLAGS && family == APR_UNSPEC) {
@@ -414,6 +419,12 @@
                                    apr_port_t port, apr_int32_t flags, 
                                    apr_pool_t *p)
 {
+#if APR_HAVE_IPV6
+    if (flags & APR_IPV6_V4MAPPED_OK && family == APR_INET6) {
+        return call_resolver(sa, hostname, family, port, flags, p);
+    }
+#endif
+
     if (flags & APR_IPV4_ADDR_OK) {
         apr_status_t error = call_resolver(sa, hostname, AF_INET, port, flags, p);
 

Reply via email to