]> granicus.if.org Git - apache/commitdiff
* server/listen.c (IS_INADDR_ANY, IS_IN6ADDR_ANY): New macros.
authorJoe Orton <jorton@apache.org>
Thu, 25 Aug 2005 15:37:39 +0000 (15:37 +0000)
committerJoe Orton <jorton@apache.org>
Thu, 25 Aug 2005 15:37:39 +0000 (15:37 +0000)
(open_listeners): Simplify using the new macros; no functional change.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@240092 13f79535-47bb-0310-9956-ffa450edef68

server/listen.c

index cf382f3cd6d9abc6ff561ef749bbf9b8b3869202..b322023f27aa10369893076ae03b8fed7089d6d7 100644 (file)
@@ -339,6 +339,15 @@ static const char *alloc_listener(process_rec *process, char *addr,
 
     return NULL;
 }
+/* Evaluates to true if the (apr_sockaddr_t *) addr argument is the
+ * IPv4 match-any-address, 0.0.0.0. */
+#define IS_INADDR_ANY(addr) ((addr)->family == APR_INET \
+                             && (addr)->sa.sin.sin_addr.s_addr == INADDR_ANY)
+
+/* Evaluates to true if the (apr_sockaddr_t *) addr argument is the
+ * IPv6 match-any-address, [::]. */
+#define IS_IN6ADDR_ANY(addr) ((addr)->family == APR_INET6 \
+                              && IN6_IS_ADDR_UNSPECIFIED(&(addr)->sa.sin6.sin6_addr))
 
 /**
  * Create, open, listen, and bind all sockets.
@@ -373,16 +382,13 @@ static int open_listeners(apr_pool_t *pool)
              * listen (which would generate an error). IPv4 will be handled
              * on the established IPv6 socket.
              */
-            if (previous != NULL &&
-                lr->bind_addr->family == APR_INET &&
-                lr->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY &&
-                lr->bind_addr->port == previous->bind_addr->port &&
-                previous->bind_addr->family == APR_INET6 &&
-                IN6_IS_ADDR_UNSPECIFIED(
-                    &previous->bind_addr->sa.sin6.sin6_addr) &&
-                apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY,
-                                   &v6only_setting) == APR_SUCCESS &&
-                v6only_setting == 0) {
+            if (previous != NULL
+                && IS_INADDR_ANY(lr->bind_addr)
+                && lr->bind_addr->port == previous->bind_addr->port
+                && IS_IN6ADDR_ANY(previous->bind_addr)
+                && apr_socket_opt_get(previous->sd, APR_IPV6_V6ONLY,
+                                      &v6only_setting) == APR_SUCCESS
+                && v6only_setting == 0) {
 
                 /* Remove the current listener from the list */
                 previous->next = lr->next;
@@ -400,12 +406,10 @@ static int open_listeners(apr_pool_t *pool)
                  * error. The user will still get a warning from make_sock
                  * though.
                  */
-                if (lr->next != NULL && lr->bind_addr->family == APR_INET6 &&
-                    IN6_IS_ADDR_UNSPECIFIED(
-                        &lr->bind_addr->sa.sin6.sin6_addr) &&
-                    lr->bind_addr->port == lr->next->bind_addr->port &&
-                    lr->next->bind_addr->family == APR_INET && 
-                    lr->next->bind_addr->sa.sin.sin_addr.s_addr == INADDR_ANY) {
+                if (lr->next != NULL
+                    && IS_IN6ADDR_ANY(lr->bind_addr)
+                    && lr->bind_addr->port == lr->next->bind_addr->port
+                    && IS_INADDR_ANY(lr->next->bind_addr)) {
 
                     /* Remove the current listener from the list */
                     if (previous) {