]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Undo revno 9911. Not quite doable yet.
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 17 Aug 2009 03:11:44 +0000 (15:11 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 17 Aug 2009 03:11:44 +0000 (15:11 +1200)
src/ip/IpAddress.cc
src/ip/IpAddress.h

index bfb0a11c78b85fe06c83e5ccd39eb02f202152f2..997e49b4e672f8de1315094de3d981586a37c6d3 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "config.h"
 #include "ip/IpAddress.h"
-#include "Debug.h"
 #include "util.h"
 
 
 #error "INET6 defined but has been deprecated! Try running bootstrap and configure again."
 #endif
 
+/* We want to use the debug routines when running as module of squid. */
+/* otherwise fallback to printf if those are not available. */
+#ifndef SQUID_DEBUG
+#    define debugs(a,b,c)        //  drop.
+#else
+#warning "IpAddress built with Debugs!!"
+#    include "../src/Debug.h"
+#endif
+
 #if !USE_IPV6
 //  So there are some places where I will drop to using Macros too.
 //  At least I can restrict them to this file so they don't corrupt the app with C code.
@@ -170,6 +178,9 @@ const int IpAddress::ApplyMask(IpAddress const &mask_addr)
         p1[i] &= p2[i];
     }
 
+    /* we have found a situation where mask forms or destroys a IPv4 map. */
+    check4Mapped();
+
     return changes;
 }
 
@@ -533,6 +544,9 @@ IpAddress& IpAddress::operator =(struct sockaddr_in const &s)
     memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in));
 #endif
 
+    /* maintain stored family values properly */
+    check4Mapped();
+
     return *this;
 };
 
@@ -553,6 +567,12 @@ IpAddress& IpAddress::operator =(const struct sockaddr_storage &s)
     return *this;
 };
 
+void IpAddress::check4Mapped()
+{
+    // obsolete.
+    // TODO use this NOW to set the sin6_family properly on exporting. not on import.
+}
+
 #if USE_IPV6
 IpAddress::IpAddress(struct sockaddr_in6 const &s)
 {
@@ -563,6 +583,9 @@ IpAddress::IpAddress(struct sockaddr_in6 const &s)
 IpAddress& IpAddress::operator =(struct sockaddr_in6 const &s)
 {
     memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6));
+
+    /* maintain address family properly */
+    check4Mapped();
     return *this;
 };
 
@@ -579,9 +602,16 @@ IpAddress& IpAddress::operator =(struct in_addr const &s)
 #if USE_IPV6
     Map4to6((const in_addr)s, m_SocketAddr.sin6_addr);
     m_SocketAddr.sin6_family = AF_INET6;
+
 #else
+
     memcpy(&m_SocketAddr.sin_addr, &s, sizeof(struct in_addr));
+
 #endif
+
+    /* maintain stored family type properly */
+    check4Mapped();
+
     return *this;
 };
 
@@ -595,8 +625,13 @@ IpAddress::IpAddress(struct in6_addr const &s)
 
 IpAddress& IpAddress::operator =(struct in6_addr const &s)
 {
+
     memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr));
     m_SocketAddr.sin6_family = AF_INET6;
+
+    /* maintain address family type properly */
+    check4Mapped();
+
     return *this;
 };
 
index df6ee8dd564d759ee24b1d934d302f82a5bfceed..635cdad4020d624134cf291fa5276e2146452095 100644 (file)
@@ -390,6 +390,8 @@ private:
 
     bool GetReverseString4(char buf[MAX_IPSTRLEN], const struct in_addr &dat) const;
 
+    void check4Mapped();
+
 #if USE_IPV6
 
     bool GetReverseString6(char buf[MAX_IPSTRLEN], const struct in6_addr &dat) const;