]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
switch to runtime inaddr_none instead of #defined INADDR_NONE
authorwessels <>
Sat, 21 Dec 1996 06:45:35 +0000 (06:45 +0000)
committerwessels <>
Sat, 21 Dec 1996 06:45:35 +0000 (06:45 +0000)
src/acl.cc
src/cache_cf.cc
src/cachemgr.cc
src/comm.cc
src/dnsserver.cc
src/fqdncache.cc
src/ftp.cc
src/ipcache.cc
src/main.cc
src/squid.h

index 5bfbd71080c8b8c0d12a5ece61765f8aa7592483..503551cbe4a2f399360efaa1ef8147757cda38c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: acl.cc,v 1.70 1996/12/18 00:02:59 wessels Exp $
+ * $Id: acl.cc,v 1.71 1996/12/20 23:45:35 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -213,7 +213,7 @@ decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask)
 
     switch (sscanf(asc, "%d.%d.%d.%d", &a1, &a2, &a3, &a4)) {
     case 4:                    /* a dotted quad */
-       if ((a = (u_num32) inet_addr(asc)) != INADDR_NONE ||
+       if ((a = (u_num32) inet_addr(asc)) != inaddr_none ||
            !strcmp(asc, "255.255.255.255")) {
            addr->s_addr = a;
            /* inet_addr() outputs in network byte order */
index 94f57a3a3291692d6583c299348bc5956a3c87fc..3f9078e6af60e78d2521e16ff9d1942b6fadb9a8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.159 1996/12/20 16:21:30 wessels Exp $
+ * $Id: cache_cf.cc,v 1.160 1996/12/20 23:45:36 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -182,9 +182,9 @@ struct SquidConfig Config;
 #define DefaultAnnounceRate    0       /* Default off */
 #define DefaultTcpRcvBufsz     0       /* use system default */
 #define DefaultTcpIncomingAddr INADDR_ANY
-#define DefaultTcpOutgoingAddr INADDR_NONE
+#define DefaultTcpOutgoingAddr inaddr_none
 #define DefaultUdpIncomingAddr INADDR_ANY
-#define DefaultUdpOutgoingAddr INADDR_NONE
+#define DefaultUdpOutgoingAddr inaddr_none
 #define DefaultClientNetmask    0xFFFFFFFFul
 #define DefaultSslProxyPort    0
 #define DefaultSslProxyHost    (char *)NULL
@@ -787,7 +787,7 @@ parseAddressLine(struct in_addr *addr)
     token = strtok(NULL, w_space);
     if (token == NULL)
        self_destruct();
-    if (inet_addr(token) != INADDR_NONE)
+    if (inet_addr(token) != inaddr_none)
        (*addr).s_addr = inet_addr(token);
     else if ((hp = gethostbyname(token)))      /* dont use ipcache */
        *addr = inaddrFromHostent(hp);
@@ -942,7 +942,7 @@ parseVizHackLine(void)
     token = strtok(NULL, w_space);
     if (token == NULL)
        self_destruct();
-    if (inet_addr(token) != INADDR_NONE)
+    if (inet_addr(token) != inaddr_none)
        Config.vizHack.addr.s_addr = inet_addr(token);
     else if ((hp = gethostbyname(token)))      /* dont use ipcache */
        Config.vizHack.addr = inaddrFromHostent(hp);
index bce9e017b0e243ca3294cdf04fa7edc6340f6d2d..251fc38d60ca893ac6da7893d88f658548819433 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cachemgr.cc,v 1.48 1996/12/14 18:54:58 wessels Exp $
+ * $Id: cachemgr.cc,v 1.49 1996/12/20 23:45:37 wessels Exp $
  *
  * DEBUG: section 0     CGI Cache Manager
  * AUTHOR: Harvest Derived
 #define CR 13
 #endif
 
-#ifndef INADDR_NONE
-#define INADDR_NONE -1
-#endif
-
 typedef enum {
     INFO,
     CACHED,
@@ -302,6 +298,7 @@ static const char *script_name = "/cgi-bin/cachemgr.cgi";
 static const char *const w_space = " \t\n\r";
 static const char *progname = NULL;
 static time_t now;
+static unsigned int inaddr_none;
 
 static char x2c _PARAMS((char *));
 static int client_comm_connect _PARAMS((int sock, char *dest_host, u_short dest_port));
@@ -629,6 +626,7 @@ main(int argc, char *argv[])
     int single = TRUE;
     float f1;
 
+    inaddr_none = inet_addr("X");
     now = time(NULL);
     if ((s = strrchr(argv[0], '/')))
        progname = xstrdup(s + 1);
@@ -1002,7 +1000,7 @@ client_comm_connect(int sock, char *dest_host, u_short dest_port)
 
     if ((hp = gethostbyname(dest_host)) != NULL)
        xmemcpy(&to_addr.sin_addr, hp->h_addr, hp->h_length);
-    else if ((haddr = inet_addr(dest_host)) != INADDR_NONE)
+    else if ((haddr = inet_addr(dest_host)) != inaddr_none)
        xmemcpy(&to_addr.sin_addr, &haddr, sizeof(haddr));
     else
        return (-1);
index dfd9959911d50d5c8c2683ecc4c39d1ca5f41940..2f63d60f0f8193466af605903012f3b0e7989298 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.123 1996/12/18 18:35:32 wessels Exp $
+ * $Id: comm.cc,v 1.124 1996/12/20 23:45:38 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -280,7 +280,7 @@ comm_open(int sock_type,
        if (do_reuse)
            commSetReuseAddr(new_socket);
     }
-    if (addr.s_addr != INADDR_NONE)
+    if (addr.s_addr != inaddr_none)
        if (commBind(new_socket, addr, port) != COMM_OK)
            return COMM_ERROR;
     conn->local_port = port;
index 21a55035b225f1bfc87417b97be72ab99db7cc16..769c1154ace1b41edd06b95bb7b0ec5e87d8edac 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dnsserver.cc,v 1.29 1996/11/12 18:21:21 wessels Exp $
+ * $Id: dnsserver.cc,v 1.30 1996/12/20 23:45:38 wessels Exp $
  *
  * DEBUG: section 0     DNS Resolver
  * AUTHOR: Harvest Derived
 #include <resolv.h>
 #endif
 
-#ifndef INADDR_NONE
-#define INADDR_NONE -1
-#endif
-
 #include "ansiproto.h"
 #include "util.h"
 
@@ -231,6 +227,7 @@ struct hostent *_res_gethostbyname(char *name);
 #endif /* _SQUID_NEXT_ */
 
 static int do_debug = 0;
+static unsigned int inaddr_none;
 
 /* error messages from gethostbyname() */
 static char *
@@ -264,6 +261,8 @@ main(int argc, char *argv[])
     int i;
     int c;
 
+    inaddr_none = inet_addr("X");
+
 #if HAVE_RES_INIT
     res_init();
 #ifdef RES_DEFNAMES
@@ -319,7 +318,7 @@ main(int argc, char *argv[])
        result = NULL;
        start = time(NULL);
        /* check if it's already an IP address in text form. */
-       if (inet_addr(request) != INADDR_NONE) {
+       if (inet_addr(request) != inaddr_none) {
 #if NO_REVERSE_LOOKUP
            printf("$name %s\n", request);
            printf("$h_name %s\n", request);
index 62c115ee21be4ea2f25071292b52449637a65e4a..35c90675bec4e61d86da059ff07fe11aebd26ddc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.42 1996/11/25 06:15:30 wessels Exp $
+ * $Id: fqdncache.cc,v 1.43 1996/12/20 23:45:39 wessels Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -758,7 +758,7 @@ fqdncache_gethostbyaddr(struct in_addr addr, int flags)
     }
     FqdncacheStats.misses++;
     /* check if it's already a FQDN address in text form. */
-    if (inet_addr(name) == INADDR_NONE) {
+    if (inet_addr(name) == inaddr_none) {
        return name;
     }
     if (flags & FQDN_BLOCKING_LOOKUP) {
index 26f7468b51097d33ea68ab48c6374cd3c3054b90..0fdb7235c219dc074672da8e114a0bbb6873bef7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.91 1996/12/03 23:30:47 wessels Exp $
+ * $Id: ftp.cc,v 1.92 1996/12/20 23:45:40 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -493,7 +493,7 @@ ftpSendRequest(int fd, FtpStateData * data)
     if (data->authenticated) {
        strcat(buf, "-a ");
     }
-    if (Config.Addrs.tcp_outgoing.s_addr != INADDR_NONE) {
+    if (Config.Addrs.tcp_outgoing.s_addr != inaddr_none) {
        sprintf(tbuf, "-o %s ", inet_ntoa(Config.Addrs.tcp_outgoing));
        strcat(buf, tbuf);
     }
index 813ce84d8f29fa69cd2ab2e2c6d82412ab17ff7e..a0be30a48b0c09da928e2ca7f275cfb8993a7e63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ipcache.cc,v 1.90 1996/12/18 00:03:00 wessels Exp $
+ * $Id: ipcache.cc,v 1.91 1996/12/20 23:45:42 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -970,7 +970,7 @@ ipcacheCheckNumeric(const char *name)
 {
     unsigned int ip;
     /* check if it's already a IP address in text form. */
-    if ((ip = inet_addr(name)) == INADDR_NONE)
+    if ((ip = inet_addr(name)) == inaddr_none)
        return NULL;
     static_addrs.count = 1;
     static_addrs.cur = 0;
index 9466814716a84d79d2246b061ba71d1761aee8db..af9c7302434e6c206a7bbf2decca423aadd923d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.cc,v 1.128 1996/12/06 22:12:49 wessels Exp $
+ * $Id: main.cc,v 1.129 1996/12/20 23:45:42 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -138,6 +138,7 @@ struct in_addr theOutICPAddr;
 const char *const dash_str = "-";
 const char *const null_string = "";
 char ThisCache[SQUIDHOSTNAMELEN << 1];
+unsigned int inaddr_none;
 
 /* for error reporting from xmalloc and friends */
 extern void (*failure_notify) _PARAMS((const char *));
@@ -371,7 +372,7 @@ serverConnectionsOpen(void)
            debug(1, 1, "Accepting ICP connections on FD %d.\n",
                theInIcpConnection);
 
-           if ((addr = Config.Addrs.udp_outgoing).s_addr != INADDR_NONE) {
+           if ((addr = Config.Addrs.udp_outgoing).s_addr != inaddr_none) {
                enter_suid();
                theOutIcpConnection = comm_open(SOCK_DGRAM,
                    0,
@@ -627,6 +628,7 @@ main(int argc, char **argv)
     any_addr.s_addr = inet_addr("0.0.0.0");
     memset(&no_addr, '\0', sizeof(struct in_addr));
     no_addr.s_addr = inet_addr("255.255.255.255");
+    inaddr_none = inet_addr("X");
 
     errorInitialize();
 
index 718d94bd0b34ed0b8f9d827b9367e28031df5bc2..738fd140d5b811dc60e2d2da8fada42e0299de93 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.86 1996/12/17 23:27:12 wessels Exp $
+ * $Id: squid.h,v 1.87 1996/12/20 23:45:44 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #define MAXPATHLEN SQUID_MAXPATHLEN
 #endif
 
-#ifndef INADDR_NONE
-#define INADDR_NONE ((unsigned long) -1)
-#endif
-
 #if !defined(HAVE_GETRUSAGE) && defined(_SQUID_HPUX_)
 #define HAVE_GETRUSAGE 1
 #define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
@@ -336,6 +332,7 @@ extern const char *const appname;   /* main.c */
 extern struct in_addr local_addr;      /* main.c */
 extern struct in_addr theOutICPAddr;   /* main.c */
 extern const char *const localhost;
+extern unsigned int inaddr_none;
 extern struct in_addr any_addr;        /* comm.c */
 extern struct in_addr no_addr; /* comm.c */
 extern int opt_udp_hit_obj;    /* main.c */