--------------------- PatchSet 4077 Date: 2007/03/04 04:58:50 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Updated class to suit inet_ntoa style access to strings. Members: src/IPAddress.cc:1.1.2.2->1.1.2.3 src/IPAddress.h:1.1.2.2->1.1.2.3 Index: squid3/src/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/IPAddress.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/IPAddress.cc 3 Mar 2007 14:44:05 -0000 1.1.2.2 +++ squid3/src/IPAddress.cc 4 Mar 2007 04:58:50 -0000 1.1.2.3 @@ -1,5 +1,5 @@ /* - * $Id: IPAddress.cc,v 1.1.2.2 2007/03/03 14:44:05 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.3 2007/03/04 04:58:50 amosjeffries Exp $ */ #include "squid.h" #include "IPAddress.h" @@ -25,6 +25,32 @@ return (INADDR_ANY == m_SocketAddr.sin_addr.s_addr); #endif } +void IPAddress::SetAnyAddr() +{ +#if INET6 + memcpy(&(m_SocketAddr.sin6_addr), &in6addr_any, sizeof(in6addr_any)); +#else + m_SocketAddr.sin_addr.s_addr = INADDR_ANY; +#endif +} + +bool IPAddress::IsNoAddr() +{ +// IFF the address = 0xffffffffff...fffff (all ones) +#if INET6 + return (0 == memcmp(&(m_SocketAddr.sin6_addr), &in6addr_none, sizeof(in6addr_any)) ); +#else + return (0xFFFFFFFF == m_SocketAddr.sin_addr.s_addr); +#endif +} +void IPAddress::SetNoAddr() +{ +#if INET6 + memset(&(m_SocketAddr.sin6_addr),255, sizeof(in6_addr)); +#else + m_SocketAddr.sin_addr.s_addr = 0xFFFFFFFF; +#endif +} #if INET6 bool IPAddress::GetReverseString6(char buf[MAX_IPSTRLEN], struct in_addr &dat) @@ -251,7 +277,7 @@ xstrncpy(m_cacheStringValue, inet_ntoa(m_SocketAddr.sin_addr), MAX_IPSTRLEN); #endif } -const char* IPAddress::GetString() +const char* IPAddress::NtoA() { RebuildStringCache(); return m_cacheStringValue; Index: squid3/src/IPAddress.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/IPAddress.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/IPAddress.h 3 Mar 2007 14:44:05 -0000 1.1.2.2 +++ squid3/src/IPAddress.h 4 Mar 2007 04:58:50 -0000 1.1.2.3 @@ -6,7 +6,7 @@ * * Intended for use by the DNS, ACLs, and Client-Server connection parts of Squid3. * - * $Id: IPAddress.h,v 1.1.2.2 2007/03/03 14:44:05 amosjeffries Exp $ + * $Id: IPAddress.h,v 1.1.2.3 2007/03/04 04:58:50 amosjeffries Exp $ */ #ifndef _INC_IPADDRESS_H #define _INC_IPADDRESS_H @@ -68,12 +68,15 @@ u_short GetPort(); u_short SetPort(u_short port); bool IsAnyAddr(); + void SetAnyAddr(); + bool IsNoAddr(); + void SetNoAddr(); bool GetString(char *buf, unsigned int len); std::ostream& operator<<(std::ostream& os); // After reading Debug.h and debug.cc I thought '<<' was all that was needed now. -// Apparently not, so here is 'char* GetString()' - const char* GetString(); +// Apparently not, so here is 'char* NtoA()' + const char* NtoA(); /* variables */