--------------------- PatchSet 4699 Date: 2007/06/08 13:29:10 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: FIX: netdb exchange bug, Protocol cannot handle non-IPv4 addresses. FIX: ACLIP bad initialisation error. Converted out globals any_addr, no_addr. IPAddress conversion slightly into WCCPv2. Members: include/IPAddress.h:1.1.2.22->1.1.2.23 src/ACLIP.cc:1.8.2.30->1.8.2.31 src/cache_cf.cc:1.40.2.30->1.40.2.31 src/client_side.cc:1.68.2.33->1.68.2.34 src/globals.h:1.17.2.8->1.17.2.9 src/ipc.cc:1.9.4.10->1.9.4.11 src/main.cc:1.42.4.12->1.42.4.13 src/neighbors.cc:1.23.4.22->1.23.4.23 src/net_db.cc:1.13.4.17->1.13.4.18 src/protos.h:1.48.4.25->1.48.4.26 src/structs.h:1.66.2.23->1.66.2.24 src/tools.cc:1.22.2.19->1.22.2.20 src/tunnel.cc:1.13.4.12->1.13.4.13 src/wccp2.cc:1.13.2.8->1.13.2.9 Index: squid3/include/IPAddress.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/Attic/IPAddress.h,v retrieving revision 1.1.2.22 retrieving revision 1.1.2.23 diff -u -r1.1.2.22 -r1.1.2.23 --- squid3/include/IPAddress.h 3 Jun 2007 12:58:32 -0000 1.1.2.22 +++ squid3/include/IPAddress.h 8 Jun 2007 13:29:10 -0000 1.1.2.23 @@ -1,6 +1,6 @@ /* - * $Id: IPAddress.h,v 1.1.2.22 2007/06/03 12:58:32 amosjeffries Exp $ + * $Id: IPAddress.h,v 1.1.2.23 2007/06/08 13:29:10 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -372,4 +372,22 @@ return os; } + +// Macros for Old IPv4-Only code that still needs to use IN_ADDR +#define ANY_ADDR (struct in_addr)0x00000000 +#define NO_ADDR (struct_in_addr)0xFFFFFFFF + +// WAS _sockaddr_in_list in an earlier incarnation +/* INET6 : this could possibly be an addrinfo structure now IFF it needs to be in a generic raw form. */ +class IPAddress_list +{ +public: + IPAddress_list() { next = NULL; }; + ~IPAddress_list() { if(next) delete next; next = NULL; }; + + IPAddress s; + IPAddress_list *next; +}; + + #endif /* _INC_IPADDRESS_H */ Index: squid3/src/ACLIP.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLIP.cc,v retrieving revision 1.8.2.30 retrieving revision 1.8.2.31 diff -u -r1.8.2.30 -r1.8.2.31 --- squid3/src/ACLIP.cc 4 Jun 2007 05:44:35 -0000 1.8.2.30 +++ squid3/src/ACLIP.cc 8 Jun 2007 13:29:10 -0000 1.8.2.31 @@ -1,5 +1,5 @@ /* - * $Id: ACLIP.cc,v 1.8.2.30 2007/06/04 05:44:35 amosjeffries Exp $ + * $Id: ACLIP.cc,v 1.8.2.31 2007/06/08 13:29:10 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -236,8 +236,8 @@ LOCAL_ARRAY(char, l_addr1, 256); LOCAL_ARRAY(char, l_addr2, 256); LOCAL_ARRAY(char, l_mask, 256); - acl_ip_data *r; - acl_ip_data **Q; + acl_ip_data *r = NULL; + acl_ip_data **Q = NULL; IPAddress temp; char c; debugs(28, 5, "aclParseIpData: " << t); @@ -301,11 +301,21 @@ debugs(28, 5, "aclParseIpData: Lookup Host/IP " << l_addr1); struct addrinfo *hp = NULL, *x = NULL, *y = NULL; + struct addrinfo hints; IPAddress *prev_addr = NULL; - getaddrinfo(l_addr1,NULL,NULL,&hp); + memset(&hints, 0, sizeof(struct addrinfo)); + + if( iptype != None ) + hints.ai_flags |= AI_NUMERICHOST; + +#if USE_IPV6 && !USE_IPV6_SPLIT_STACK + hints.ai_flags |= AI_V4MAPPED | AI_ALL; +#endif + + int errcode = getaddrinfo(l_addr1,NULL,&hints,&hp); if (hp == NULL) { - debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "'"); + debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "' : " << errcode << " " << gai_strerror(errcode) ); self_destruct(); } @@ -321,7 +331,7 @@ x = x->ai_next; y->ai_next = NULL; r->addr1 = *y; - freeaddrinfo(y); + y->ai_next = x; // re-link for clear later. /* getaddrinfo given a host has a nasty tendency to return duplicate addr's */ /* BUT sorted fortunately, so we can drop most of them easily */ @@ -357,6 +367,8 @@ self_destruct(); } + freeaddrinfo(hp); + return q; } @@ -437,7 +449,7 @@ int ACLIP::match(IPAddress &clientip) { - static acl_ip_data ClientAddress (any_addr, any_addr, no_addr, NULL); + static acl_ip_data ClientAddress; /* * aclIpAddrNetworkCompare() takes two acl_ip_data pointers as * arguments, so we must create a fake one for the client's IP @@ -447,6 +459,7 @@ ClientAddress.addr1 = clientip; ClientAddress.addr2.SetEmpty(); ClientAddress.mask.SetEmpty(); + acl_ip_data *ClientAddressPointer = &ClientAddress; data = data->splay(ClientAddressPointer, aclIpAddrNetworkCompare); debugs(28, 3, "aclMatchIp: '" << clientip << "' " << (splayLastResult ? "NOT found" : "found")); Index: squid3/src/cache_cf.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/cache_cf.cc,v retrieving revision 1.40.2.30 retrieving revision 1.40.2.31 diff -u -r1.40.2.30 -r1.40.2.31 --- squid3/src/cache_cf.cc 4 Jun 2007 06:54:25 -0000 1.40.2.30 +++ squid3/src/cache_cf.cc 8 Jun 2007 13:29:10 -0000 1.40.2.31 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.40.2.30 2007/06/04 06:54:25 amosjeffries Exp $ + * $Id: cache_cf.cc,v 1.40.2.31 2007/06/08 13:29:10 amosjeffries Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -124,17 +124,20 @@ static void parse_denyinfo(acl_deny_info_list ** var); static void dump_denyinfo(StoreEntry * entry, const char *name, acl_deny_info_list * var); static void free_denyinfo(acl_deny_info_list ** var); + #if USE_WCCPv2 -static void parse_sockaddr_in_list(sockaddr_in_list **); -static void dump_sockaddr_in_list(StoreEntry *, const char *, const sockaddr_in_list *); -static void free_sockaddr_in_list(sockaddr_in_list **); +static void parse_IPAddress_list(IPAddress_list **); +static void dump_IPAddress_list(StoreEntry *, const char *, const IPAddress_list *); +static void free_IPAddress_list(IPAddress_list **); #if CURRENTLY_UNUSED -static int check_null_sockaddr_in_list(const sockaddr_in_list *); +static int check_null_IPAddress_list(const IPAddress_list *); #endif /* CURRENTLY_UNUSED */ #endif + static void parse_http_port_list(http_port_list **); static void dump_http_port_list(StoreEntry *, const char *, const http_port_list *); static void free_http_port_list(http_port_list **); + #if USE_SSL static void parse_https_port_list(https_port_list **); static void dump_https_port_list(StoreEntry *, const char *, const https_port_list *); @@ -2506,7 +2509,7 @@ #if USE_WCCPv2 void -parse_sockaddr_in_list_token(sockaddr_in_list ** head, char *token) +parse_IPAddress_list_token(IPAddress_list ** head, char *token) { char *t; char *host; @@ -2515,7 +2518,7 @@ IPAddress ipa; const struct hostent *hp; unsigned short port; - sockaddr_in_list *s; + IPAddress_list *s; host = NULL; port = 0; @@ -2562,43 +2565,39 @@ while (*head) head = &(*head)->next; - s = static_cast(xcalloc(1, sizeof(*s))); - ipa.GetSockAddr(s->s); + s = static_cast(xcalloc(1, sizeof(*s))); + s->s = ipa; *head = s; } static void -parse_sockaddr_in_list(sockaddr_in_list ** head) +parse_IPAddress_list(IPAddress_list ** head) { char *token; while ((token = strtok(NULL, w_space))) { - parse_sockaddr_in_list_token(head, token); + parse_IPAddress_list_token(head, token); } } static void -dump_sockaddr_in_list(StoreEntry * e, const char *n, const sockaddr_in_list * s) +dump_IPAddress_list(StoreEntry * e, const char *n, const IPAddress_list * s) { + char ntoabuf[MAX_IPSTRLEN]; + while (s) { - storeAppendPrintf(e, "%s %s:%d\n", + storeAppendPrintf(e, "%s %s\n", n, - inet_ntoa(s->s.sin_addr), - ntohs(s->s.sin_port)); + s->s.NtoA(ntoabuf,MAX_IPSTRLEN)); s = s->next; } } static void -free_sockaddr_in_list(sockaddr_in_list ** head) +free_IPAddress_list(IPAddress_list ** head) { - sockaddr_in_list *s; - - while ((s = *head) != NULL) { - *head = s->next; - xfree(s); - } + if(*head) delete *head; *head = NULL; } #if CURRENTLY_UNUSED @@ -2606,7 +2605,7 @@ * be used by icp_port and htcp_port */ static int -check_null_sockaddr_in_list(const sockaddr_in_list * s) +check_null_IPAddress_list(const IPAdress_list * s) { return NULL == s; } Index: squid3/src/client_side.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v retrieving revision 1.68.2.33 retrieving revision 1.68.2.34 diff -u -r1.68.2.33 -r1.68.2.34 --- squid3/src/client_side.cc 3 Jun 2007 12:14:45 -0000 1.68.2.33 +++ squid3/src/client_side.cc 8 Jun 2007 13:29:10 -0000 1.68.2.34 @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.68.2.33 2007/06/03 12:14:45 amosjeffries Exp $ + * $Id: client_side.cc,v 1.68.2.34 2007/06/08 13:29:10 amosjeffries Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -492,7 +492,9 @@ if (loggingEntry() && loggingEntry()->mem_obj) al.cache.objectSize = loggingEntry()->contentLen(); - al.cache.caddr = getConn() != NULL ? getConn()->log_addr : no_addr; + al.cache.caddr.SetNoAddr(); + + if(getConn() != NULL) al.cache.caddr = getConn()->log_addr; al.cache.size = out.size; Index: squid3/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/globals.h,v retrieving revision 1.17.2.8 retrieving revision 1.17.2.9 diff -u -r1.17.2.8 -r1.17.2.9 --- squid3/src/globals.h 16 May 2007 16:04:57 -0000 1.17.2.8 +++ squid3/src/globals.h 8 Jun 2007 13:29:10 -0000 1.17.2.9 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.17.2.8 2007/05/16 16:04:57 amosjeffries Exp $ + * $Id: globals.h,v 1.17.2.9 2007/06/08 13:29:10 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -112,15 +112,11 @@ extern struct _acl_deny_info_list *DenyInfoList; /* NULL */ - extern struct IN_ADDR any_addr; - - extern struct IN_ADDR local_addr; - - extern struct IN_ADDR no_addr; + extern IPAddress local_addr; extern IPAddress theOutICPAddr; - extern struct IN_ADDR theOutSNMPAddr; + extern IPAddress theOutSNMPAddr; extern struct timeval current_time; Index: squid3/src/ipc.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipc.cc,v retrieving revision 1.9.4.10 retrieving revision 1.9.4.11 diff -u -r1.9.4.10 -r1.9.4.11 --- squid3/src/ipc.cc 29 Apr 2007 14:18:24 -0000 1.9.4.10 +++ squid3/src/ipc.cc 8 Jun 2007 13:29:10 -0000 1.9.4.11 @@ -1,6 +1,6 @@ /* - * $Id: ipc.cc,v 1.9.4.10 2007/04/29 14:18:24 amosjeffries Exp $ + * $Id: ipc.cc,v 1.9.4.11 2007/06/08 13:29:10 amosjeffries Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -105,28 +105,26 @@ if (hIpc) *hIpc = NULL; -/* FIXME INET6 : drop temp conversion boundary */ IPAddress tmp(local_addr); - if (type == IPC_TCP_SOCKET) { crfd = cwfd = comm_open(SOCK_STREAM, 0, - tmp, + local_addr, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_STREAM, 0, /* protocol */ - tmp, + local_addr, 0, /* blocking */ name); } else if (type == IPC_UDP_SOCKET) { crfd = cwfd = comm_open(SOCK_DGRAM, 0, - tmp, + local_addr, COMM_NOCLOEXEC, name); prfd = pwfd = comm_open(SOCK_DGRAM, 0, - tmp, + local_addr, 0, name); } else if (type == IPC_FIFO) { Index: squid3/src/main.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/main.cc,v retrieving revision 1.42.4.12 retrieving revision 1.42.4.13 diff -u -r1.42.4.12 -r1.42.4.13 --- squid3/src/main.cc 1 May 2007 08:32:31 -0000 1.42.4.12 +++ squid3/src/main.cc 8 Jun 2007 13:29:11 -0000 1.42.4.13 @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.42.4.12 2007/05/01 08:32:31 amosjeffries Exp $ + * $Id: main.cc,v 1.42.4.13 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -1123,12 +1123,7 @@ if (oldmask) umask(oldmask); - memset(&local_addr, '\0', sizeof(struct IN_ADDR)); - safe_inet_addr(localhost, &local_addr); - memset(&any_addr, '\0', sizeof(struct IN_ADDR)); - safe_inet_addr("0.0.0.0", &any_addr); - memset(&no_addr, '\0', sizeof(struct IN_ADDR)); - safe_inet_addr("255.255.255.255", &no_addr); + local_addr = localhost; squid_srandom(time(NULL)); Index: squid3/src/neighbors.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/neighbors.cc,v retrieving revision 1.23.4.22 retrieving revision 1.23.4.23 diff -u -r1.23.4.22 -r1.23.4.23 --- squid3/src/neighbors.cc 3 Jun 2007 12:58:32 -0000 1.23.4.22 +++ squid3/src/neighbors.cc 8 Jun 2007 13:29:11 -0000 1.23.4.23 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.23.4.22 2007/06/03 12:58:32 amosjeffries Exp $ + * $Id: neighbors.cc,v 1.23.4.23 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -490,8 +490,8 @@ struct addrinfo *AI = NULL; struct servent *sep = NULL; const char *me = getMyHostname(); - peer *thisPeer; - peer *next; + peer *thisPeer = NULL; + peer *next = NULL; int fd = theInIcpConnection; /* setup addrinfo for use */ @@ -503,7 +503,7 @@ debugs(15, 1, "getsockname(" << fd << "," << AI->ai_addr << "," << &AI->ai_addrlen << ") failed."); for (thisPeer = Config.peers; thisPeer; thisPeer = next) { - http_port_list *s; + http_port_list *s = NULL; next = thisPeer->next; if (0 != strcmp(thisPeer->host, me)) Index: squid3/src/net_db.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/net_db.cc,v retrieving revision 1.13.4.17 retrieving revision 1.13.4.18 diff -u -r1.13.4.17 -r1.13.4.18 --- squid3/src/net_db.cc 30 May 2007 05:06:08 -0000 1.13.4.17 +++ squid3/src/net_db.cc 8 Jun 2007 13:29:11 -0000 1.13.4.18 @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.13.4.17 2007/05/30 05:06:08 amosjeffries Exp $ + * $Id: net_db.cc,v 1.13.4.18 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -253,8 +253,7 @@ netdbLookupAddr(const IPAddress &addr) { netdbEntry *n; - char *key = new char [MAX_IPSTRLEN]; - memset(key,0,MAX_IPSTRLEN); + char *key = new char[MAX_IPSTRLEN]; networkFromInaddr(addr).NtoA(key,MAX_IPSTRLEN); n = (netdbEntry *) hash_lookup(addr_table, key); return n; @@ -692,11 +691,13 @@ static void netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) { + IPAddress addr; + netdbExchangeState *ex = (netdbExchangeState *)data; int rec_sz = 0; off_t o; - IPAddress addr; + struct in_addr line_addr; double rtt; double hops; char *p; @@ -708,7 +709,7 @@ int oldbufofs = ex->buf_ofs; rec_sz = 0; - rec_sz += 1 + sizeof(addr); + rec_sz += 1 + sizeof(struct in_addr); rec_sz += 1 + sizeof(int); rec_sz += 1 + sizeof(int); debugs(38, 3, "netdbExchangeHandleReply: " << recievedData.length << " read bytes"); @@ -793,8 +794,14 @@ case NETDB_EX_NETWORK: o++; - xmemcpy(&addr, p + o, sizeof(addr)); - o += sizeof(addr); +/* FIXME INET6 : So how do we cope with sending IPv6 addresses ?? */ +/* this transfer method allows for no address-type or size to be sent between caches */ +/* that is DEFINATELY going to cause problems with any cache built before the IPv6 release. */ +/* AYJ: for now we MUST assume the peer can handle IPv4 addresses only. */ + addr.GetInAddr(line_addr); + xmemcpy(&line_addr, p + o, sizeof(struct in_addr)); + addr = line_addr; + o += sizeof(struct in_addr); break; case NETDB_EX_RTT: @@ -1224,13 +1231,15 @@ HttpReply *reply = new HttpReply; #if USE_ICMP + IPAddress addr; + netdbEntry *n; int i; int j; int rec_sz; char *buf; - IPAddress addr; + struct in_addr line_addr; s->buffer(); HttpVersion version(1, 0); reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2); @@ -1255,9 +1264,13 @@ buf[i++] = (char) NETDB_EX_NETWORK; - xmemcpy(&buf[i], &addr, sizeof(addr)); +/* FIXME INET6 : netdb has no size or type info on teh address. */ +/* we are forced to be brain-damaged with peers and assume IPv4 */ + + addr.GetInAddr(line_addr); + xmemcpy(&buf[i], &line_addr, sizeof(struct in_addr)); - i += sizeof(addr); + i += sizeof(struct in_addr); buf[i++] = (char) NETDB_EX_RTT; Index: squid3/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/protos.h,v retrieving revision 1.48.4.25 retrieving revision 1.48.4.26 diff -u -r1.48.4.25 -r1.48.4.26 --- squid3/src/protos.h 3 Jun 2007 12:14:48 -0000 1.48.4.25 +++ squid3/src/protos.h 8 Jun 2007 13:29:11 -0000 1.48.4.26 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.48.4.25 2007/06/03 12:14:48 amosjeffries Exp $ + * $Id: protos.h,v 1.48.4.26 2007/06/08 13:29:11 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -77,7 +77,7 @@ SQUIDCEXTERN void requirePathnameExists(const char *name, const char *path); SQUIDCEXTERN void parse_time_t(time_t * var); -SQUIDCEXTERN void parse_sockaddr_in_list_token(sockaddr_in_list **, char *); +SQUIDCEXTERN void parse_IPAddress_list_token(IPAddress_list **, char *); /* client_side.c - FD related client side routines */ @@ -602,6 +602,9 @@ SQUIDCEXTERN pid_t readPidFile(void); SQUIDCEXTERN void keepCapabilities(void); +/* AYJ debugs function to show locations being reset with memset() */ +SQUIDCEXTERN void *xmemset(void *dst, int, size_t); + SQUIDCEXTERN int intAverage(int, int, int, int); SQUIDCEXTERN double doubleAverage(double, double, int, int); SQUIDCEXTERN void debug_trap(const char *); Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.66.2.23 retrieving revision 1.66.2.24 diff -u -r1.66.2.23 -r1.66.2.24 --- squid3/src/structs.h 4 Jun 2007 06:54:25 -0000 1.66.2.23 +++ squid3/src/structs.h 8 Jun 2007 13:29:11 -0000 1.66.2.24 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.66.2.23 2007/06/04 06:54:25 amosjeffries Exp $ + * $Id: structs.h,v 1.66.2.24 2007/06/08 13:29:11 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -123,12 +123,6 @@ relist *next; }; -struct _sockaddr_in_list -{ - struct sockaddr_in s; - sockaddr_in_list *next; -}; - struct _http_port_list { http_port_list *next; @@ -311,7 +305,7 @@ struct { - sockaddr_in_list *router; + IPAddress_list *router; IPAddress address; int forwarding_method; Index: squid3/src/tools.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tools.cc,v retrieving revision 1.22.2.19 retrieving revision 1.22.2.20 diff -u -r1.22.2.19 -r1.22.2.20 --- squid3/src/tools.cc 3 Jun 2007 12:14:48 -0000 1.22.2.19 +++ squid3/src/tools.cc 8 Jun 2007 13:29:11 -0000 1.22.2.20 @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.22.2.19 2007/06/03 12:14:48 amosjeffries Exp $ + * $Id: tools.cc,v 1.22.2.20 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -1333,3 +1333,13 @@ #endif } + +void * +xmemset(void *dst, int val, size_t sz) +{ + // do debugs output + debugs(63, 9, "memset: dst=" << dst << ", val=" << val << ", bytes=" << sz); + + // call the system one to do the actual work ~safely. + return memset(dst, val, sz); +} Index: squid3/src/tunnel.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tunnel.cc,v retrieving revision 1.13.4.12 retrieving revision 1.13.4.13 diff -u -r1.13.4.12 -r1.13.4.13 --- squid3/src/tunnel.cc 3 Jun 2007 03:57:12 -0000 1.13.4.12 +++ squid3/src/tunnel.cc 8 Jun 2007 13:29:11 -0000 1.13.4.13 @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.13.4.12 2007/06/03 03:57:12 amosjeffries Exp $ + * $Id: tunnel.cc,v 1.13.4.13 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -619,10 +619,10 @@ statCounter.server.all.requests++; statCounter.server.other.requests++; /* Create socket. */ -/* FIXME INET6 : drop temp conversion */ IPAddress tmp(getOutgoingAddr(request)); + IPAddress temp = getOutgoingAddr(request); sock = comm_openex(SOCK_STREAM, IPPROTO_TCP, - tmp, + temp, COMM_NONBLOCKING, getOutgoingTOS(request), url); Index: squid3/src/wccp2.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/wccp2.cc,v retrieving revision 1.13.2.8 retrieving revision 1.13.2.9 diff -u -r1.13.2.8 -r1.13.2.9 --- squid3/src/wccp2.cc 1 May 2007 08:32:32 -0000 1.13.2.8 +++ squid3/src/wccp2.cc 8 Jun 2007 13:29:11 -0000 1.13.2.9 @@ -1,6 +1,6 @@ /* - * $Id: wccp2.cc,v 1.13.2.8 2007/05/01 08:32:32 amosjeffries Exp $ + * $Id: wccp2.cc,v 1.13.2.9 2007/06/08 13:29:11 amosjeffries Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven Wilton @@ -127,6 +127,7 @@ /* WCCP v2 packet header */ +/// \interface WCCPv2 Protocol struct wccp2_here_i_am_header_t { uint32_t type; @@ -145,6 +146,7 @@ uint32_t security_option; }; +/// \interface WCCPv2 Protocol struct wccp2_security_md5_t { uint16_t security_type; @@ -155,6 +157,7 @@ /* Service info struct */ +/// \interface WCCPv2 Protocol struct wccp2_service_info_t { uint16_t service_type; @@ -174,10 +177,10 @@ uint16_t port7; }; +/// \interface WCCPv2 Protocol struct wccp2_cache_identity_info_t { - - struct IN_ADDR addr; + struct in_addr addr; uint16_t hash_revision; char bits[2]; char buckets[32]; @@ -187,6 +190,7 @@ /* Web Cache identity info */ +/// \interface WCCPv2 Protocol struct wccp2_identity_info_t { uint16_t cache_identity_type; @@ -197,10 +201,10 @@ static struct wccp2_identity_info_t wccp2_identity_info; +/// \interface WCCPv2 Protocol struct wccp2_cache_mask_identity_info_t { - - struct IN_ADDR addr; + struct in_addr addr; uint32_t num1; uint32_t num2; uint32_t source_ip_mask; @@ -213,6 +217,7 @@ /* Web Cache identity info */ +/// \interface WCCPv2 Protocol struct wccp2_mask_identity_info_t { uint16_t cache_identity_type; @@ -225,6 +230,7 @@ /* View header */ +/// \interface WCCPv2 Protocol struct wccp2_cache_view_header_t { uint16_t cache_view_type; @@ -236,6 +242,7 @@ /* View info */ +/// \interface WCCPv2 Protocol struct wccp2_cache_view_info_t { uint32_t num_routers; @@ -246,10 +253,10 @@ /* Router ID element */ +/// \interface WCCPv2 Protocol struct wccp2_router_id_element_t { - - struct IN_ADDR router_address; + struct in_addr router_address; uint32_t received_id; }; @@ -257,6 +264,7 @@ /* Capability info header */ +/// \interface WCCpv2 Protocol struct wccp2_capability_info_header_t { uint16_t capability_info_type; @@ -267,6 +275,7 @@ /* Capability element header */ +/// \interface WCCPv2 Protocol struct wccp2_capability_element_header_t { uint16_t capability_type; @@ -275,6 +284,7 @@ /* Capability element */ +/// \interface WCCPv2 Protocol struct wccp2_capability_element_t { uint16_t capability_type; @@ -286,6 +296,7 @@ /* Mask Element */ +/// \interface WCCPv2 Protocol struct wccp2_mask_element_t { uint32_t source_ip_mask; @@ -297,6 +308,7 @@ /* Value Element */ +/// \interface WCCPv2 Protocol struct wccp2_value_element_t { uint32_t source_ip_value; @@ -304,11 +316,12 @@ uint16_t source_port_value; uint16_t dest_port_value; - struct IN_ADDR cache_ip; + struct in_addr cache_ip; }; /* RECEIVED PACKET STRUCTURE */ +/// \interface WCCPv2 Protocol struct wccp2_i_see_you_t { uint32_t type; @@ -321,16 +334,17 @@ /* Router ID element */ +/// \interface WCCPv2 Protocol struct wccp2_router_assign_element_t { - - struct IN_ADDR router_address; + struct in_addr router_address; uint32_t received_id; uint32_t change_number; }; /* Generic header struct */ +/// \interface WCCPv2 Protocol struct wccp2_item_header_t { uint16_t type; @@ -339,6 +353,7 @@ /* Router identity struct */ +/// \interface WCCPv2 Protocol struct router_identity_info_t { @@ -352,10 +367,10 @@ /* The received packet for a mask assignment is unusual */ +/// \interface WCCPv2 Protocol struct cache_mask_info_t { - - struct IN_ADDR addr; + struct in_addr addr; uint32_t num1; uint32_t num2; uint32_t num3; @@ -363,15 +378,16 @@ /* assigment key */ +/// \interface WCCPv2 Protocol struct assignment_key_t { - - struct IN_ADDR master_ip; + struct in_addr master_ip; uint32_t master_number; }; /* Router view of WCCP */ +/// \interface WCCPv2 Protocol struct router_view_t { @@ -383,24 +399,26 @@ /* Lists used to keep track of caches, routers and services */ +/// \interface WCCPv2 Protocol struct wccp2_cache_list_t { - struct IN_ADDR cache_ip; + struct in_addr cache_ip; int weight; struct wccp2_cache_list_t *next; }; +/// \interface WCCPv2 Protocol struct wccp2_router_list_t { struct wccp2_router_id_element_t *info; - struct IN_ADDR local_ip; + struct in_addr local_ip; - struct IN_ADDR router_sendto_address; + struct in_addr router_sendto_address; uint32_t member_change; uint32_t num_caches; @@ -411,6 +429,7 @@ static int wccp2_numrouters; +/// \interface WCCPv2 Protocol struct wccp2_service_list_t { @@ -638,7 +657,7 @@ void wccp2Init(void) { - sockaddr_in_list *s; + IPAddress_list *s; char *ptr; uint32_t service_flags; @@ -657,7 +676,7 @@ /* Calculate the number of routers configured in the config file */ for (s = Config.Wccp2.router; s; s = s->next) { - if (s->s.sin_addr.s_addr != any_addr.s_addr) { + if (!s->s.IsAnyAddr()) { /* Increment the counter */ wccp2_numrouters++; } @@ -736,7 +755,7 @@ assert(wccp2_here_i_am_header.length <= WCCP_RESPONSE_SIZE); wccp2_identity_info.cache_identity_type = htons(WCCP2_WC_ID_INFO); wccp2_identity_info.cache_identity_length = htons(sizeof(wccp2_identity_info.cache_identity)); - memset(&wccp2_identity_info.cache_identity.addr, '\0', sizeof(wccp2_identity_info.cache_identity.addr)); + memset(&wccp2_identity_info.cache_identity.addr, '\0', sizeof(struct in_addr)); memset(&wccp2_identity_info.cache_identity.hash_revision, '\0', sizeof(wccp2_identity_info.cache_identity.hash_revision)); memset(&wccp2_identity_info.cache_identity.bits, '\0', sizeof(wccp2_identity_info.cache_identity.bits)); memset(&wccp2_identity_info.cache_identity.buckets, '\0', sizeof(wccp2_identity_info.cache_identity.buckets)); @@ -755,7 +774,7 @@ assert(wccp2_here_i_am_header.length <= WCCP_RESPONSE_SIZE); wccp2_mask_identity_info.cache_identity_type = htons(WCCP2_WC_ID_INFO); wccp2_mask_identity_info.cache_identity_length = htons(sizeof(wccp2_mask_identity_info.cache_identity)); - memset(&wccp2_mask_identity_info.cache_identity.addr, '\0', sizeof(wccp2_mask_identity_info.cache_identity.addr)); + memset(&wccp2_mask_identity_info.cache_identity.addr, '\0', sizeof(struct in_addr)); wccp2_mask_identity_info.cache_identity.num1 = htonl(2); wccp2_mask_identity_info.cache_identity.num2 = htonl(1); service_flags = ntohl(service_list_ptr->service_info->service_flags); @@ -826,7 +845,7 @@ /* Add each router. Keep this functionality here to make sure the received_id can be updated in the packet */ for (s = Config.Wccp2.router; s; s = s->next) { - if (s->s.sin_addr.s_addr != any_addr.s_addr) { + if (!s->s.IsAnyAddr()) { wccp2_here_i_am_header.length += sizeof(struct wccp2_router_id_element_t); assert(wccp2_here_i_am_header.length <= WCCP_RESPONSE_SIZE); @@ -834,9 +853,9 @@ /* Add a pointer to the router list for this router */ router_list_ptr->info = (struct wccp2_router_id_element_t *) ptr; - router_list_ptr->info->router_address = s->s.sin_addr; + s->s.GetInAddr(router_list_ptr->info->router_address); router_list_ptr->info->received_id = htonl(0); - router_list_ptr->router_sendto_address = s->s.sin_addr; + s->s.GetInAddr(router_list_ptr->router_sendto_address); router_list_ptr->member_change = htonl(0); /* Build the next struct */ @@ -943,8 +962,6 @@ void wccp2ConnectionOpen(void) { - u_short port = WCCP_PORT; - struct sockaddr_in router, local, null; socklen_t local_len, router_len; @@ -959,10 +976,10 @@ return; } -/* FIXME INET6 : drop temp conversion */ IPAddress tmp(Config.Wccp2.address); tmp.SetPort(WCCP_PORT); + Config.Wccp2.address.SetPort(WCCP_PORT); theWccp2Connection = comm_open(SOCK_DGRAM, 0, - tmp, + Config.Wccp2.address, COMM_NONBLOCKING, "WCCPv2 Socket"); @@ -982,7 +999,7 @@ NULL, 0); - debugs(80, 1, "Accepting WCCPv2 messages on port " << port << ", FD " << theWccp2Connection << "."); + debugs(80, 1, "Accepting WCCPv2 messages on port " << WCCP_PORT << ", FD " << theWccp2Connection << "."); debugs(80, 1, "Initialising all WCCPv2 lists"); /* Initialise all routers on all services */ @@ -997,7 +1014,7 @@ router_len = sizeof(router); memset(&router, '\0', router_len); router.sin_family = AF_INET; - router.sin_port = htons(port); + router.sin_port = htons(WCCP_PORT); router.sin_addr = router_list_ptr->router_sendto_address; if (connect(theWccp2Connection, (struct sockaddr *) &router, router_len)) @@ -1016,7 +1033,6 @@ * but disconnects anyway so we have to just assume it worked */ if (wccp2_numrouters > 1) - connect(theWccp2Connection, (struct sockaddr *) &null, router_len); }