--------------------- PatchSet 5275 Date: 2007/08/12 07:34:02 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Remove IPAddressType - Just one more piece of state that could be mucked up (and was) - API now using AF_* and Is*() if protocol-specifics ever needed - Fixes quite a few false asserts on address translation in some code Members: include/IPAddress.h:1.1.2.32->1.1.2.33 lib/IPAddress.cc:1.1.2.62->1.1.2.63 lib/tests/testIPAddress.cc:1.1.2.13->1.1.2.14 src/ACLIP.cc:1.8.2.37->1.8.2.38 src/ACLIP.h:1.6.2.5->1.6.2.6 src/asn.cc:1.16.6.21->1.16.6.22 src/comm.cc:1.47.2.44->1.47.2.45 src/net_db.cc:1.13.4.25->1.13.4.26 Index: squid3/include/IPAddress.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/Attic/IPAddress.h,v retrieving revision 1.1.2.32 retrieving revision 1.1.2.33 diff -u -r1.1.2.32 -r1.1.2.33 --- squid3/include/IPAddress.h 12 Aug 2007 04:14:36 -0000 1.1.2.32 +++ squid3/include/IPAddress.h 12 Aug 2007 07:34:02 -0000 1.1.2.33 @@ -1,6 +1,5 @@ - /* - * $Id: IPAddress.h,v 1.1.2.32 2007/08/12 04:14:36 amosjeffries Exp $ + * $Id: IPAddress.h,v 1.1.2.33 2007/08/12 07:34:02 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -64,34 +63,6 @@ #define s6_addr32 __u6_addr.__u6_addr32 #endif -/// Test to verify the build configure options are correct. -// COMMENT THE FOLLOWING LINE TO TEST: -/* -// the use of #warning and #error is intentional to stop the build process. -#if USE_IPV6 -# if USE_IPV6_SPLITSTACK -# warning --enable-ipv6 is ON and --with-ipv6-splitstack is ON -# else -# warning --enable-ipv6 is ON and --with-ipv6-splitstack is OFF -# endif -#else -# if USE_IPV6_SPLITSTACK -# error --enable-ipv6 is OFF but --with-ipv6-splitstack is ON! -# else -# warning --enable-ipv6 is OFF and --with-ipv6-splitstack is OFF -# endif -#endif -// */ - -/// Specify the type of Address being or to be handled. -enum IPAddressType { - None =0, ///< Nothing Special. Equates to default if used as a parameter. - SockAddr =1, ///< Full SocketAddr Details Stored. Port and Address can be used together or seperately. - IPv4 =2, ///< Pure IPv4 address stored (conversion up must be done explicitly) - IPv6 =4, ///< Pure IPv6 address Stored (no conversion to IPv4 possible) - IPv64 =6 ///< Dual-Address stored (can return either IPv6 OR IPv4) -}; - /// Length of buffer that needs to be allocated to old a null-terminated IP-string // Yuck. But there are still structures that need it to be an 'integer constant'. #define MAX_IPSTRLEN 75 @@ -163,7 +134,7 @@ * \retval true if content was received as an IPv4-Mapped address * \retval false if content was received as a non-mapped IPv6 native address. */ - inline bool IsIPv4() const { return (m_Type & IPv4); }; + bool IsIPv4() const; /** Test whether content can be used as an IPv6 address. * \retval true if --enable-ipv6 has been compiled. @@ -174,10 +145,10 @@ /** Test whether content can be used as a Socket address. * \retval true if address AND port are both set - * \retval true if content was received as a Socket address + * \retval true if content was received as a Socket address with port * \retval false if port in unset (zero) */ - inline bool IsSockAddr() const { return (m_Type & SockAddr); }; + bool IsSockAddr() const; /** Content-neutral test for whether the specific IP case ANY_ADDR is stored. * This is the default content of a new undefined IPAddress object. @@ -209,6 +180,7 @@ * \retval n Port associated with this address in host native -endian. */ u_short GetPort() const; + /** Set the Port value for an address. * Replaces any previously existing Port value. * \param port Port being assigned in host native -endian. @@ -246,9 +218,9 @@ /** Apply a mask to the stored address. * CIDR will be converted appropriate to map the stored content. * \param cidr CIDR Mask being applied. As an integer in host format. - * \param mtype Type of CIDR mask being applied (IPv4,IPv6, or None for default) + * \param mtype Type of CIDR mask being applied (AF_INET or AF_INET6) */ - bool ApplyMask(const unsigned int cidr, IPAddressType mtype = None); + bool ApplyMask(const unsigned int cidr, int mtype = AF_UNSPEC); /** Return the ASCII equivalent of the address @@ -289,10 +261,10 @@ * The buffer sent MUST be allocated large enough to hold the resulting string. * Name truncation will occur if buf does not have enough space. * The constant MAX_IPSTRLEN is defined to provide for sizing arrays correctly. - * \param show_format may be one of: IPv4,IPv6 for the format of rDNS string wanted. + * \param show_format may be one of: AF_INET, AF_INET6 for the format of rDNS string wanted. * \param buf buffer to receive the text string output. */ - bool GetReverseString(char buf[], IPAddressType show_format = None) const; + bool GetReverseString(char buf[], int show_format = AF_UNSPEC) const; /** Test how two IP relate to each other. * \retval 0 IP are equal @@ -392,7 +364,6 @@ bool LookupHostIP(const char *s, bool nodns); /* variables */ - IPAddressType m_Type; #if USE_IPV6 struct sockaddr_in6 m_SocketAddr; Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/Attic/IPAddress.cc,v retrieving revision 1.1.2.62 retrieving revision 1.1.2.63 diff -u -r1.1.2.62 -r1.1.2.63 --- squid3/lib/IPAddress.cc 12 Aug 2007 04:57:38 -0000 1.1.2.62 +++ squid3/lib/IPAddress.cc 12 Aug 2007 07:34:03 -0000 1.1.2.63 @@ -1,6 +1,5 @@ - /* - * $Id: IPAddress.cc,v 1.1.2.62 2007/08/12 04:57:38 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.63 2007/08/12 07:34:03 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -65,17 +64,6 @@ # include "../src/Debug.h" #endif -/* - enum IPAddressType { - NONE=0, - SockAddr =1, // Full SocketAddr Details Stored. - IPv4 =2, // Pure IPv4 address stored (conversion up must be done explicitly) - IPv6 =4, // Pure IPv6 Address Stored (no conversion to IPv4 possible) - IPv64 =6 // Dual-Address Stored (can return either IPv6 OR IPv4) - } m_Type; - struct sockaddr m_SocketAddr; -*/ - #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. @@ -93,6 +81,16 @@ static const unsigned int MAX_IP6_STRLEN = STRLEN_IP6R; +/* AYJ INET6 debugging only. Dump the address content when a fatal assert is encountered. */ +#define IASSERT(a,b) \ + do{ printf("assert \"%s\" at line %d\n", a, __LINE__); \ + printf("IPAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \ + printf("ADDRESS:"); \ + for(unsigned int i = 0; i < sizeof(m_SocketAddr.sin6_addr); i++) { \ + printf(" %x", m_SocketAddr.sin6_addr.s6_addr[i]); \ + } printf("\n"); assert(b); \ + }while(0) + IPAddress::IPAddress() { SetEmpty(); @@ -173,20 +171,20 @@ return changes; } -bool IPAddress::ApplyMask(const unsigned int cidr, IPAddressType mtype) +bool IPAddress::ApplyMask(const unsigned int cidr, int mtype) { uint8_t clearbits = 0; uint8_t* p = NULL; #if !USE_IPV6 - assert(mtype != IPv6); /* using IPv6 in IPv4 is invalid. */ + IASSERT("mtype != AF_INET6", mtype != AF_INET6); /* using IPv6 in IPv4 is invalid. */ - if(mtype == None) - mtype = IPv4; + if(mtype == AF_UNSPEC) + mtype = AF_INET; #else - if(mtype == None) - mtype = IPv6; + if(mtype == AF_UNSPEC) + mtype = AF_INET6; #endif @@ -194,10 +192,10 @@ if (cidr > 128) return false; - if (cidr > 32 && mtype == IPv4) + if (cidr > 32 && mtype == AF_INET) return false; - clearbits = (uint8_t)((mtype&IPv6?128:32)-cidr); + clearbits = (uint8_t)( (mtype==AF_INET6?128:32) -cidr); // short-cut if(clearbits == 0) @@ -223,16 +221,44 @@ } } - /* we have found a situation where mask forms or destroys a IPv4 map. */ - check4Mapped(); - return true; } +bool IPAddress::IsSockAddr() const +{ + return (m_SocketAddr.sin6_port != 0); +} + +bool IPAddress::IsIPv4() const +{ +#if USE_IPV6 + + return IsAnyAddr() || IsNoAddr() || +#if IPV6_SPECIAL_LOCALHOST + IsLocalhost() || +#endif + ( m_SocketAddr.sin6_addr.s6_addr32[0] == htonl(0x00000000) && + m_SocketAddr.sin6_addr.s6_addr32[1] == htonl(0x00000000) && + m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0x0000FFFF) + ); + +#else + return true; // enforce IPv4 in IPv4-only mode. +#endif +} + bool IPAddress::IsIPv6() const { #if USE_IPV6 - return IsAnyAddr() || IsNoAddr() || ((m_Type & IPv6) && !(m_Type & IPv4)); + + return IsAnyAddr() || IsNoAddr() || +#if IPV6_SPECIAL_LOCALHOST + IsLocalhost() || +#endif + !( m_SocketAddr.sin6_addr.s6_addr32[0] == htonl(0x00000000) && + m_SocketAddr.sin6_addr.s6_addr32[1] == htonl(0x00000000) && + m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0x0000FFFF) + ); #else return false; // enforce IPv4 in IPv4-only mode. #endif @@ -256,30 +282,12 @@ void IPAddress::SetAnyAddr() { memset(&m_SocketAddr.sin6_addr, 0, sizeof(m_SocketAddr.sin6_addr) ); -#if USE_IPV6 - - m_Type= (IPAddressType) (m_Type | IPv64); -#else - m_Type= (IPAddressType) (m_Type | IPv4); -#endif } /// NOTE: completely empties the IPAddres structure. Address, Port, Type, everything. void IPAddress::SetEmpty() { memset(&m_SocketAddr, 0, sizeof(m_SocketAddr) ); -#if USE_IPV6 - - m_Type = IPv64; - - assert( m_Type & IPv6 ); - assert( m_Type & IPv4 ); -#else - - m_Type = IPv4; - - assert( m_Type & IPv4 ); -#endif } bool IPAddress::IsLocalhost() const @@ -308,16 +316,11 @@ #if USE_IPV6 SetAnyAddr(); m_SocketAddr.sin6_addr.s6_addr[15] = 0x1; -#if IPV6_SPECIAL_LOCALHOST - m_Type = IPv64; -#else - m_Type = IPv6; -#endif + m_SocketAddr.sin6_family = AF_INET6; #else m_SocketAddr.sin_addr.s_addr = htonl(0x7F000001); - - m_Type=IPv4; + m_SocketAddr.sin_family = AF_INET; #endif } @@ -339,13 +342,7 @@ void IPAddress::SetNoAddr() { memset(&(m_SocketAddr.sin6_addr),0xFFFFFFFF,sizeof(m_SocketAddr.sin6_addr)); -#if USE_IPV6 - - m_Type = IPv64; -#else - - m_Type = IPv4; -#endif + m_SocketAddr.sin6_family = AF_INET6; } #if USE_IPV6 @@ -390,24 +387,22 @@ return true; } -bool IPAddress::GetReverseString(char buf[MAX_IPSTRLEN], IPAddressType show_type) const +bool IPAddress::GetReverseString(char buf[MAX_IPSTRLEN], int show_type) const { - if(m_Type == None) - return false; - if(show_type == None) { + if(show_type == AF_UNSPEC) { #if USE_IPV6 - show_type = IsIPv6() ? IPv6 : IPv4 ; + show_type = IsIPv6() ? AF_INET6 : AF_INET ; #else - show_type = IPv4 ; + show_type = AF_INET; #endif } - if (IsIPv4() && show_type == IPv4) { + if (show_type == AF_INET && IsIPv4()) { #if USE_IPV6 return GetReverseString4(buf, *(struct in_addr*)&m_SocketAddr.sin6_addr.s6_addr32[3] ); - } else if (IsIPv6() && show_type == IPv6) { + } else if ( show_type == AF_INET6 && IsIPv6() ) { return GetReverseString6(buf, m_SocketAddr.sin6_addr); #else return GetReverseString4(buf, m_SocketAddr.sin_addr); @@ -447,6 +442,8 @@ { int err = 0; + short port = 0; + struct addrinfo *res = NULL; struct addrinfo want; @@ -470,17 +467,12 @@ } /* - * NP: =(sockaddr_*) sets SockAddr flag. - * we MUST NOT set that flag from only an IPA assignment + * NP: =(sockaddr_*) may alter the port. we don't want that. + * all we have been given as input was an IPA. */ - if( IsSockAddr() ) { // does not matter. - operator=(*res); - } else { - // prevent SockAddr being set by the other operator. - operator=(*res); - // TODO FIX: really need to get a non-magic way of doing this mask. SockAddr == 0x01 -> 0xe in last bits. - m_Type = (IPAddressType)(m_Type & 0xFFFe ); - } + port = GetPort(); + operator=(*res); + SetPort(port); /* free the memory getaddrinfo dynamically allocated. */ freeaddrinfo(res); @@ -502,11 +494,9 @@ Map4to6((const in_addr)s.sin_addr, m_SocketAddr.sin6_addr); m_SocketAddr.sin6_port = s.sin_port; m_SocketAddr.sin6_family = AF_INET6; - m_Type=(IPAddressType)(IPv64 | SockAddr); #else memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in)); - m_Type=(IPAddressType)(IPv4 | SockAddr); #endif /* maintain stored family values properly */ @@ -517,47 +507,8 @@ void IPAddress::check4Mapped() { -#if USE_IPV6 - - /* check for ::ffff:x.x.x.x IPv4-mapped addresses */ - - if( m_SocketAddr.sin6_addr.s6_addr32[0] == htonl(0x00000000) && - m_SocketAddr.sin6_addr.s6_addr32[1] == htonl(0x00000000) && - m_SocketAddr.sin6_addr.s6_addr32[2] == htonl(0x0000FFFF) ) { - - if( m_Type & IPv6 ) // Pure IPv4-Mapped addresses are not actualy valid as IPv6-Native. - m_Type = (IPAddressType)( m_Type & (0xFFFF ^ IPv6)); - - m_Type = (IPAddressType)(m_Type | IPv4); - } - - /* check for special ANYADDR case. */ - else if( IsAnyAddr() ) { - m_Type = (IPAddressType)(m_Type | IPv64); - } - - /* check for special NOADDR case. */ - else if( IsNoAddr() ) { - m_Type = (IPAddressType)(m_Type | IPv64); - } - -#if IPV6_SPECIAL_LOCALHOST - /* check for ::ffff:x.x.x.x IPv4-mapped addresses */ - else if( IsLocalhost() ) { - m_Type = (IPAddressType)(m_Type | IPv64); // Localhost is stored as native version. - } -#endif - - /* FIXME : maybe other tests can apply if the IPA was mapped in other ways */ - /* I know of 2002:0.0.0.0:: mappings and possibly fe80::???? mappings */ - /* Special cases like LOOPBACK that can be converted inline need to be marked. */ - - else { - if( m_Type & IPv4) - m_Type = (IPAddressType)(m_Type & (0xFFFF ^ IPv4)); - } - -#endif + // obsolete. + // TODO use this NOW to set the sin6_family properly on exporting. not on import. } #if USE_IPV6 @@ -569,10 +520,9 @@ IPAddress& IPAddress::operator =(sockaddr_in6 const &s) { - memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6)); - m_Type = (IPAddressType)(SockAddr | IPv6); + /* maintain address family properly */ check4Mapped(); return *this; }; @@ -591,20 +541,10 @@ Map4to6((const in_addr)s, m_SocketAddr.sin6_addr); m_SocketAddr.sin6_family = AF_INET6; - if(m_SocketAddr.sin6_port > 0) - m_Type=(IPAddressType)(SockAddr | IPv64); - else - m_Type=IPv64; - #else memcpy(&m_SocketAddr.sin_addr, &s, sizeof(struct in_addr)); - if(m_SocketAddr.sin_port > 0) - m_Type=(IPAddressType)(SockAddr | IPv4); - else - m_Type=IPv4; - #endif /* maintain stored family type properly */ @@ -627,12 +567,7 @@ memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr)); m_SocketAddr.sin6_family = AF_INET6; - if(m_SocketAddr.sin6_port > 0) - m_Type = (IPAddressType)(SockAddr | IPv6); - else - m_Type = IPv6; - - /* maintain stored family type properly */ + /* maintain address family type properly */ check4Mapped(); return *this; @@ -690,6 +625,10 @@ #endif break; + + default: + IASSERT("false",false); + return false; } return true; @@ -757,18 +696,12 @@ #if USE_IPV6 if(s.ai_addrlen == sizeof(struct sockaddr_in6)) { operator=(*((struct sockaddr_in6*)s.ai_addr)); - assert(m_SocketAddr.sin6_family == AF_INET6); return true; } else #endif if(s.ai_addrlen == sizeof(struct sockaddr_in)) { operator=(*((struct sockaddr_in*)s.ai_addr)); -#if USE_IPV6 - assert(m_SocketAddr.sin6_family == AF_INET6); // now v4-mapped. -#else - assert(m_SocketAddr.sin6_family == AF_INET); -#endif return true; } } @@ -802,9 +735,8 @@ dst->ai_protocol = IPPROTO_UDP; #if USE_IPV6 - if( force==AF_INET6 || force == AF_UNSPEC && IsIPv6() ) + if( force == AF_INET6 || force == AF_UNSPEC && IsIPv6() ) { - dst->ai_addr = (struct sockaddr*)new sockaddr_in6; memset(dst->ai_addr,0,sizeof(struct sockaddr_in6)); @@ -831,7 +763,7 @@ dst->ai_family = ((struct sockaddr_in*)dst->ai_addr)->sin_family; } else { - assert(false); + IASSERT("false",false); } } @@ -894,9 +826,6 @@ bool IPAddress::operator ==(const IPAddress &s) const { - if( (m_Type & IPv64) != (s.m_Type & IPv64) ) - return false; - return (0 == matchIPAddr(s)); } @@ -946,8 +875,6 @@ { m_SocketAddr.sin6_port = htons(prt); - m_Type = (IPAddressType)(m_Type | SockAddr); - return prt; } @@ -1040,6 +967,9 @@ p++; } + /* terminate just in case. */ + *p = '\0'; + /* return size of buffer now used */ return (p - buf); } @@ -1058,7 +988,7 @@ if(m_SocketAddr.sin6_port > 0 && p < buf+blen-6) { /* 6 is max length of expected ':port' (short int) */ - snprintf(p,6,":%d", GetPort() ); + snprintf(p, 6,":%d", GetPort() ); } // force a null-terminated string @@ -1071,7 +1001,7 @@ { #if USE_IPV6 - if(m_Type & IPv4) + if( IsIPv4() ) { buf.sin_family = AF_INET; buf.sin_port = m_SocketAddr.sin6_port; @@ -1100,8 +1030,8 @@ void IPAddress::GetSockAddr(struct sockaddr_in6 &buf) const { - memcpy(&buf, &m_SocketAddr, sizeof(struct sockaddr_in6)); + /* maintain address family. It may have changed inside us. */ buf.sin6_family = AF_INET6; } @@ -1171,8 +1101,6 @@ #if USE_IPV6 void IPAddress::GetInAddr(in6_addr &buf) const { - assert(m_Type & IPv6); - memcpy(&buf, &m_SocketAddr.sin6_addr, sizeof(struct in6_addr)); } @@ -1180,30 +1108,25 @@ bool IPAddress::GetInAddr(struct in_addr &buf) const { - switch(m_Type & IPv64) - { -#if USE_IPV6 - - case IPv4: - case IPv64: // IPv4-Compatible IPv6 Address +#if USE_IPV6 + if( IsIPv4() ) { Map6to4((const in6_addr)m_SocketAddr.sin6_addr, buf); return true; + } #else - case IPv4: // Pure IPv4 Address. - - memcpy(&buf, &m_SocketAddr.sin_addr, sizeof(struct in_addr)); + if( IsIPv4() ) { + memcpy(&buf, &m_SocketAddr.sin_addr, sizeof(struct in_addr)); return true; + } #endif - case IPv6: // non-compatible IPv6 Pure Address + // default: + // non-compatible IPv6 Pure Address - default: - debugs(14,1, HERE << "IPAddress::GetInAddr : Cannot convert non-IPv4 to IPv4. IPA=" << *this); - - memset(&buf,0xFFFFFFFF,sizeof(struct in_addr)); - assert(false); - return false; - } + debugs(14,1, HERE << "IPAddress::GetInAddr : Cannot convert non-IPv4 to IPv4. IPA=" << *this); + memset(&buf,0xFFFFFFFF,sizeof(struct in_addr)); + assert(false); + return false; } Index: squid3/lib/tests/testIPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/tests/Attic/testIPAddress.cc,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid3/lib/tests/testIPAddress.cc 31 Jul 2007 04:02:54 -0000 1.1.2.13 +++ squid3/lib/tests/testIPAddress.cc 12 Aug 2007 07:34:04 -0000 1.1.2.14 @@ -442,10 +442,10 @@ v4IPA.GetReverseString(buf); CPPUNIT_ASSERT( memcmp("12.100.168.192.in-addr.arpa.",buf, 28) == 0 ); - v4IPA.GetReverseString(buf,IPv4); + v4IPA.GetReverseString(buf,AF_INET); CPPUNIT_ASSERT( memcmp("12.100.168.192.in-addr.arpa.",buf, 28) == 0 ); - v4IPA.GetReverseString(buf,IPv6); + v4IPA.GetReverseString(buf,AF_INET6); CPPUNIT_ASSERT( memcmp("",buf, 1) == 0 ); @@ -495,7 +495,7 @@ CPPUNIT_ASSERT_EQUAL( 31 , anIPA.GetCIDR() ); anIPA.SetNoAddr(); - anIPA.ApplyMask(31, IPv4); + anIPA.ApplyMask(31, AF_INET); #if USE_IPV6 CPPUNIT_ASSERT_EQUAL( 127 , anIPA.GetCIDR() ); #else @@ -504,7 +504,7 @@ #if USE_IPV6 anIPA.SetNoAddr(); - anIPA.ApplyMask(80,IPv6); + anIPA.ApplyMask(80,AF_INET6); CPPUNIT_ASSERT_EQUAL( 80 , anIPA.GetCIDR() ); /* BUG Check: test values by display. */ CPPUNIT_ASSERT( anIPA.NtoA(buf,MAX_IPSTRLEN) != NULL ); Index: squid3/src/ACLIP.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLIP.cc,v retrieving revision 1.8.2.37 retrieving revision 1.8.2.38 diff -u -r1.8.2.37 -r1.8.2.38 --- squid3/src/ACLIP.cc 12 Aug 2007 00:01:24 -0000 1.8.2.37 +++ squid3/src/ACLIP.cc 12 Aug 2007 07:34:05 -0000 1.8.2.38 @@ -1,5 +1,5 @@ /* - * $Id: ACLIP.cc,v 1.8.2.37 2007/08/12 00:01:24 amosjeffries Exp $ + * $Id: ACLIP.cc,v 1.8.2.38 2007/08/12 07:34:05 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -188,7 +188,7 @@ * This function should NOT be called if 'asc' is a hostname! */ bool -acl_ip_data::DecodeMask(const char *asc, IPAddress &mask, IPAddressType ctype) +acl_ip_data::DecodeMask(const char *asc, IPAddress &mask, int ctype) { char junk; int a1 = 0; @@ -240,7 +240,7 @@ char c; debugs(28, 5, "aclIpParseIpData: " << t); acl_ip_data *q = new acl_ip_data; - IPAddressType iptype = None; + int iptype = AF_UNSPEC; /* Special ACL RHS "all" matches entire Internet */ if (strcasecmp(t, "all") == 0) { @@ -260,30 +260,30 @@ // IPv4 if (sscanf(t, SCAN_ACL1_4, l_addr1, l_addr2, l_mask) == 3) { (void) 0; - iptype=IPv4; + iptype=AF_INET; } else if (sscanf(t, SCAN_ACL2_4,l_addr1, l_addr2, &c) >= 2) { l_mask[0] = '\0'; - iptype=IPv4; + iptype=AF_INET; } else if (sscanf(t, SCAN_ACL3_4, l_addr1, l_mask) == 2) { l_addr2[0] = '\0'; - iptype=IPv4; + iptype=AF_INET; } else if (sscanf(t, SCAN_ACL4_4, l_addr1,l_mask) == 2) { l_addr2[0] = '\0'; - iptype=IPv4; + iptype=AF_INET; // IPv6 } else if (sscanf(t, SCAN_ACL1_6, l_addr1, l_addr2, l_mask) == 3) { (void) 0; - iptype=IPv6; + iptype=AF_INET6; } else if (sscanf(t, SCAN_ACL2_6, l_addr1, l_addr2, &c) >= 2) { l_mask[0] = '\0'; - iptype=IPv6; + iptype=AF_INET6; } else if (sscanf(t, SCAN_ACL3_6, l_addr1, l_mask) == 2) { l_addr2[0] = '\0'; - iptype=IPv6; + iptype=AF_INET6; } else if (sscanf(t, SCAN_ACL4_6, l_addr1, l_mask) == 2) { l_addr2[0] = '\0'; - iptype=IPv6; + iptype=AF_INET6; // Neither } else if (sscanf(t, "%s", l_addr1) == 1) { @@ -312,7 +312,7 @@ memset(&hints, 0, sizeof(struct addrinfo)); - if( iptype != None ) + if( iptype != AF_UNSPEC ) hints.ai_flags |= AI_NUMERICHOST; #if 0 && USE_IPV6 && !USE_IPV6_SPLIT_STACK Index: squid3/src/ACLIP.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLIP.h,v retrieving revision 1.6.2.5 retrieving revision 1.6.2.6 diff -u -r1.6.2.5 -r1.6.2.6 --- squid3/src/ACLIP.h 9 Apr 2007 14:10:44 -0000 1.6.2.5 +++ squid3/src/ACLIP.h 12 Aug 2007 07:34:05 -0000 1.6.2.6 @@ -1,6 +1,6 @@ /* - * $Id: ACLIP.h,v 1.6.2.5 2007/04/09 14:10:44 amosjeffries Exp $ + * $Id: ACLIP.h,v 1.6.2.6 2007/08/12 07:34:05 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -62,7 +62,7 @@ private: - static bool DecodeMask(const char *asc, IPAddress &mask, IPAddressType string_format_type); + static bool DecodeMask(const char *asc, IPAddress &mask, int string_format_type); }; MEMPROXY_CLASS_INLINE(acl_ip_data) Index: squid3/src/asn.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/asn.cc,v retrieving revision 1.16.6.21 retrieving revision 1.16.6.22 diff -u -r1.16.6.21 -r1.16.6.22 --- squid3/src/asn.cc 11 Aug 2007 13:26:01 -0000 1.16.6.21 +++ squid3/src/asn.cc 12 Aug 2007 07:34:05 -0000 1.16.6.22 @@ -1,6 +1,6 @@ /* - * $Id: asn.cc,v 1.16.6.21 2007/08/11 13:26:01 amosjeffries Exp $ + * $Id: asn.cc,v 1.16.6.22 2007/08/12 07:34:05 amosjeffries Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -420,11 +420,12 @@ if (bitl < 0) bitl = 0; + // INET6 TODO : find a better way of identifying the base IPA family for mask than this. t = strchr(as_string, '.'); // generate Netbits Format Mask mask.SetNoAddr(); - mask.ApplyMask(bitl, (t!=NULL?IPv4:IPv6) ); + mask.ApplyMask(bitl, (t!=NULL?AF_INET:AF_INET6) ); debugs(53, 3, "asnAddNet: called for " << addr << "/" << mask ); Index: squid3/src/comm.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/comm.cc,v retrieving revision 1.47.2.44 retrieving revision 1.47.2.45 diff -u -r1.47.2.44 -r1.47.2.45 --- squid3/src/comm.cc 11 Aug 2007 02:37:57 -0000 1.47.2.44 +++ squid3/src/comm.cc 12 Aug 2007 07:34:06 -0000 1.47.2.45 @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.47.2.44 2007/08/11 02:37:57 amosjeffries Exp $ + * $Id: comm.cc,v 1.47.2.45 2007/08/12 07:34:06 amosjeffries Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1313,11 +1313,12 @@ struct addrinfo *AI = NULL; PROF_start(comm_connect_addr); - debugs(5, 9, "comm_connect_addr: connecting socket " << sock << " to " << address << " Old-State=" << fdc_table[sock].active); + assert(address.GetPort() != 0); - address.GetAddrInfo(AI, F->sock_family); + debugs(5, 9, "comm_connect_addr: connecting socket " << sock << " to " << address << " (want family: " << F->sock_family << + ") Old-State=" << fdc_table[sock].active); - assert(address.GetPort() != 0); + address.GetAddrInfo(AI); //, F->sock_family); /* Establish connection. */ errno = 0; Index: squid3/src/net_db.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/net_db.cc,v retrieving revision 1.13.4.25 retrieving revision 1.13.4.26 diff -u -r1.13.4.25 -r1.13.4.26 --- squid3/src/net_db.cc 11 Aug 2007 13:26:01 -0000 1.13.4.25 +++ squid3/src/net_db.cc 12 Aug 2007 07:34:06 -0000 1.13.4.26 @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.13.4.25 2007/08/11 13:26:01 amosjeffries Exp $ + * $Id: net_db.cc,v 1.13.4.26 2007/08/12 07:34:06 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -355,7 +355,7 @@ if( in.IsIPv6() ) { - out.ApplyMask(64, IPv6); + out.ApplyMask(64, AF_INET6); debugs(14, 5, "networkFromInaddr : Masked IPv6 Address to " << in << "/64 routing part."); return out; } @@ -380,7 +380,7 @@ debugs(14, 5, "networkFromInaddr : Masked IPv4 Address to " << out << "/24."); /* use /24 for everything under IPv4 */ - out.ApplyMask(24, IPv4); + out.ApplyMask(24, AF_INET); debugs(14, 5, "networkFromInaddr : Masked IPv4 Address to " << in << "/24."); return out;