]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Windows: fix various libip build issues
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jun 2014 04:19:19 +0000 (22:19 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jun 2014 04:19:19 +0000 (22:19 -0600)
* Missing include ws2tcpip.h for IPv6 definitions
* Alternative IN6_ARE_ADDR_EQUAL definition required
* 'byte' is a reserved / system defined type on Windows,
 resolve variable shadowing by renaming to ipbyte.

src/ip/Address.cc

index 3f7a72ea4c67924d88639d8c2e7d4f06fa7c7147..ba3cff5a2c04b8ff98fc8c790a28def046d48313 100644 (file)
 /* for inet_ntoa() */
 #include <arpa/inet.h>
 #endif
+#if HAVE_WS2TCPIP_H
+// Windows IPv6 definitions
+#include <ws2tcpip.h>
+#endif
+
+// some OS (ie WIndows) define IN6_ADDR_EQUAL instead
+#if !defined(IN6_ARE_ADDR_EQUAL) && _SQUID_WINDOWS_
+#define IN6_ARE_ADDR_EQUAL IN6_ADDR_EQUAL
+#endif
 
 /* Debugging only. Dump the address content when a fatal assert is encountered. */
 #define IASSERT(a,b)  \
@@ -35,7 +44,7 @@
 int
 Ip::Address::cidr() const
 {
-    uint8_t shift,byte;
+    uint8_t shift,ipbyte;
     uint8_t bit,caught;
     int len = 0;
     const uint8_t *ptr= mSocketAddr_.sin6_addr.s6_addr;
@@ -52,20 +61,20 @@ Ip::Address::cidr() const
     }
 
     for (; shift<sizeof(mSocketAddr_.sin6_addr) ; ++shift) {
-        byte= *(ptr+shift);
+        ipbyte= *(ptr+shift);
 
-        if (byte == 0xFF) {
+        if (ipbyte == 0xFF) {
             len += 8;
             continue ;  /* A short-cut */
         }
 
         for (caught = 0 , bit= 7 ; !caught && (bit <= 7); --bit) {
-            caught = ((byte & 0x80) == 0x00);  /* Found a '0' at 'bit' ? */
+            caught = ((ipbyte & 0x80) == 0x00);  /* Found a '0' at 'bit' ? */
 
             if (!caught)
                 ++len;
 
-            byte <<= 1;
+            ipbyte <<= 1;
         }
 
         if (caught)