httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject [PATCH] get mod_unique_id to work on IPv6-only boxes
Date Thu, 25 Apr 2002 14:30:48 GMT
In this context, "IPv6-only boxes" means "boxes with an IPv6 address
but no IPv4 address corresponding to their hostname".

This is an easy change to use the low-order four bytes of the IPv6
address for part of the id when no IPv4 address is available.  This
should resolve the most problematic aspect for the person who wrote PR
7642.

The big picture is probably that mod_unique_id should be reworked to
use APR uuid support.  That is beyond the scope of what I can do at
this time.

Index: mod_unique_id.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_unique_id.c,v
retrieving revision 1.35
diff -u -r1.35 mod_unique_id.c
--- mod_unique_id.c	13 Mar 2002 20:47:53 -0000	1.35
+++ mod_unique_id.c	25 Apr 2002 14:23:13 -0000
@@ -213,16 +213,25 @@
         return HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    /* XXX theoretically there are boxes out there which want to use
-     *     mod_unique_id but which have no IPv4 address...  send in a patch :)
-     */
-    if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) != APR_SUCCESS)
{
+    if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) == APR_SUCCESS)
{
+        global_in_addr = sockaddr->sa.sin.sin_addr.s_addr;
+    }
+    else {
         ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
                     "mod_unique_id: unable to find IPv4 address of \"%s\"", str);
+#if APR_HAVE_IPV6
+        if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET6, 0, 0, p)) == APR_SUCCESS)
{
+            memcpy(&global_in_addr,
+                   sockaddr->ipaddr_ptr + sockaddr->ipaddr_len - sizeof(global_in_addr),
+                   sizeof(global_in_addr));
+            ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
+                         "mod_unique_id: using low-order bits of IPv6 address "
+                         "as if they were unique");
+        }
+        else
+#endif
         return HTTP_INTERNAL_SERVER_ERROR;
     }
-
-    global_in_addr = sockaddr->sa.sin.sin_addr.s_addr;
 
     apr_sockaddr_ip_get(&ipaddrstr, sockaddr);
     ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server,

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message