--------------------- PatchSet 6755 Date: 2008/02/10 11:10:14 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Add preliminary sockaddr* retrieval to IPAddress. Members: include/IPAddress.h:1.1.2.43->1.1.2.44 lib/IPAddress.cc:1.1.2.79->1.1.2.80 Index: squid3/include/IPAddress.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/IPAddress.h,v retrieving revision 1.1.2.43 retrieving revision 1.1.2.44 diff -u -r1.1.2.43 -r1.1.2.44 --- squid3/include/IPAddress.h 23 Nov 2007 00:28:35 -0000 1.1.2.43 +++ squid3/include/IPAddress.h 10 Feb 2008 11:10:14 -0000 1.1.2.44 @@ -1,5 +1,5 @@ /* - * $Id: IPAddress.h,v 1.1.2.43 2007/11/23 00:28:35 amosjeffries Exp $ + * $Id: IPAddress.h,v 1.1.2.44 2008/02/10 11:10:14 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -302,6 +302,15 @@ int matchIPAddr(const IPAddress &rhs) const; /** + * Get pointer to sockaddr_storage object and its size. + * As requried to pass to many system calls. + * This can be passed without any further alteration to any system call + * which does not alter the sockaddr* content + */ + const sockaddr *GetSockAddr(int &size); + + + /** * Get RFC 3493 addrinfo structure from the IPAddress data * for protocol-neutral socket operations. * Should be passed a NULL pointer of type struct addrinfo* it will Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/IPAddress.cc,v retrieving revision 1.1.2.79 retrieving revision 1.1.2.80 diff -u -r1.1.2.79 -r1.1.2.80 --- squid3/lib/IPAddress.cc 8 Jan 2008 21:56:26 -0000 1.1.2.79 +++ squid3/lib/IPAddress.cc 10 Feb 2008 11:10:16 -0000 1.1.2.80 @@ -1,5 +1,5 @@ /* - * $Id: IPAddress.cc,v 1.1.2.79 2008/01/08 21:56:26 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.80 2008/02/10 11:10:16 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -778,6 +778,22 @@ return true; } +const sockaddr* IPAddress::GetSockAddr(int &size) +{ + // check that the family details are correct!! + if(IsIPv4() && m_SocketAddr.sin6_family != AF_INET) + m_SocketAddr.sin6_family = AF_INET; + else if(IsIPv6() && m_SocketAddr.sin6_family != AF_INET6) + m_SocketAddr.sin6_family = AF_INET6; +#if 0 // INET6: do we need this? + else + m_SocketAddr.sin6_family = AF_UNSPEC; +#endif + + size = sizeof(m_SocketAddr); + return (const struct sockaddr*) &m_SocketAddr; +} + void IPAddress::GetAddrInfo(struct addrinfo *&dst, int force) const { if(dst == NULL)