--------------------- PatchSet 4224 Date: 2007/04/11 13:23:21 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Rollout full to htcp.*, somewhat to net_db.cc and icmp.cc Members: NOTES-IPv6:1.1.2.14->1.1.2.15 include/IPAddress.h:1.1.2.13->1.1.2.14 lib/IPAddress.cc:1.1.2.25->1.1.2.26 src/htcp.cc:1.15.6.2->1.15.6.3 src/htcp.h:1.4.8.1->1.4.8.2 src/icmp.cc:1.8.8.4->1.8.8.5 src/net_db.cc:1.13.4.7->1.13.4.8 src/protos.h:1.48.4.11->1.48.4.12 Index: squid3/NOTES-IPv6 =================================================================== RCS file: /cvsroot/squid-sf//squid3/Attic/NOTES-IPv6,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -r1.1.2.14 -r1.1.2.15 --- squid3/NOTES-IPv6 10 Apr 2007 11:01:11 -0000 1.1.2.14 +++ squid3/NOTES-IPv6 11 Apr 2007 13:23:21 -0000 1.1.2.15 @@ -1,14 +1,18 @@ -$Id: NOTES-IPv6,v 1.1.2.14 2007/04/10 11:01:11 amosjeffries Exp $ +$Id: NOTES-IPv6,v 1.1.2.15 2007/04/11 13:23:21 amosjeffries Exp $ KNOWN BUGS: - PROBLEM: Attempts to connect to Port 20480 instead of 80 CAUSE: error with ntohs() or htons() in the wrong place or vice versa. _all_ locally stored port values should be HS in converted code. Solved for all known events now, but this may reccur at any time until conversion is completed. +PROBLEM: HTCP and Pinger Rollout is not complete. +CAUSE: My compile-testing is limited is present in these areas. + It compiles with the existign rollout and --enables-* present. + + TODO: 1.2 Migrate code to using IPAddress object over any other method of struct storage @@ -19,13 +23,13 @@ 3.2 first changes in include/ (submitted for approval) 3.3 first changes in lib/ (submitted for approval) -3.4 changes in src/ (blocked by step 3.2-3) +3.4 changes in src/ (blocked by step 3.2-3, Aim: Squid 3.1 ) 3.5 push new rfc3596 library (blocked by 4.1) 3.9 changes in / -4.0 Migrate dns_internal.cc code to using rfc3595 library (blocked by 3.4) +4.0 Migrate dns_internal.cc code to using rfc3595 library 4.1 Test new rfc3596 library at runtime. (blocked by 4.0) Index: squid3/include/IPAddress.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/Attic/IPAddress.h,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -u -r1.1.2.13 -r1.1.2.14 --- squid3/include/IPAddress.h 9 Apr 2007 12:06:03 -0000 1.1.2.13 +++ squid3/include/IPAddress.h 11 Apr 2007 13:23:22 -0000 1.1.2.14 @@ -1,6 +1,6 @@ /* - * $Id: IPAddress.h,v 1.1.2.13 2007/04/09 12:06:03 amosjeffries Exp $ + * $Id: IPAddress.h,v 1.1.2.14 2007/04/11 13:23:22 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -117,8 +117,11 @@ /** @name Boolean Operators */ /*@{*/ bool operator ==(IPAddress const &s) const; + bool operator !=(IPAddress const &s) const; bool operator >=(IPAddress const &rhs) const; bool operator <=(IPAddress const &rhs) const; + bool operator >(IPAddress const &rhs) const; + bool operator <(IPAddress const &rhs) const; public: /* methods */ Index: squid3/lib/IPAddress.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/Attic/IPAddress.cc,v retrieving revision 1.1.2.25 retrieving revision 1.1.2.26 diff -u -r1.1.2.25 -r1.1.2.26 --- squid3/lib/IPAddress.cc 7 Apr 2007 14:25:38 -0000 1.1.2.25 +++ squid3/lib/IPAddress.cc 11 Apr 2007 13:23:22 -0000 1.1.2.26 @@ -1,6 +1,6 @@ /* - * $Id: IPAddress.cc,v 1.1.2.25 2007/04/07 14:25:38 amosjeffries Exp $ + * $Id: IPAddress.cc,v 1.1.2.26 2007/04/11 13:23:22 amosjeffries Exp $ * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries @@ -634,7 +634,7 @@ return 1; } - return true; + return 0; } bool IPAddress::operator ==(const IPAddress &s) const @@ -645,6 +645,11 @@ return (0 == matchIPAddr(s)); } +bool IPAddress::operator !=(const IPAddress &s) const +{ + return ! ( operator==(s) ); +} + bool IPAddress::operator <=(const IPAddress &rhs) const { if(IsAnyAddr() && !rhs.IsAnyAddr()) @@ -661,6 +666,22 @@ return ( matchIPAddr(rhs) >= 0); } +bool IPAddress::operator >(const IPAddress &rhs) const +{ + if(IsNoAddr() && !rhs.IsNoAddr()) + return true; + + return ( matchIPAddr(rhs) > 0); +} + +bool IPAddress::operator <(const IPAddress &rhs) const +{ + if(IsNoAddr() && !rhs.IsNoAddr()) + return true; + + return ( matchIPAddr(rhs) < 0); +} + u_short IPAddress::GetPort() const { return ntohs( m_SocketAddr.sin6_port ); Index: squid3/src/htcp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/htcp.cc,v retrieving revision 1.15.6.2 retrieving revision 1.15.6.3 diff -u -r1.15.6.2 -r1.15.6.3 --- squid3/src/htcp.cc 5 Jan 2007 16:59:22 -0000 1.15.6.2 +++ squid3/src/htcp.cc 11 Apr 2007 13:23:22 -0000 1.15.6.3 @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.15.6.2 2007/01/05 16:59:22 hno Exp $ + * $Id: htcp.cc,v 1.15.6.3 2007/04/11 13:23:22 amosjeffries Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -182,7 +182,7 @@ void checkHit(); void checkedHit(StoreEntry *e); - void setFrom (struct SOCKADDR_IN *from); + void setFrom (IPAddress &from); void setDataHeader (htcpDataHeader *); char *method; char *uri; @@ -193,7 +193,7 @@ private: HttpRequest *checkHitRequest; - struct SOCKADDR_IN *from; + IPAddress from; // was a ptr. return to such IFF needed. otherwise copy should do. htcpDataHeader *dhdr; }; @@ -263,7 +263,7 @@ static u_int32_t queried_id[N_QUERIED_KEYS]; static cache_key queried_keys[N_QUERIED_KEYS][MD5_DIGEST_CHARS]; -static struct sockaddr_in queried_addr[N_QUERIED_KEYS]; +static IPAddress queried_addr[N_QUERIED_KEYS]; static MemAllocator *htcpDetailPool = NULL; static int old_squid_format = 0; @@ -282,26 +282,26 @@ static void htcpFreeSpecifier(htcpSpecifier * s); static void htcpFreeDetail(htcpDetail * s); -static void htcpHandle(char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandle(char *buf, int sz, IPAddress &from); -static void htcpHandleData(char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleData(char *buf, int sz, IPAddress &from); -static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, IPAddress &from); -static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, IPAddress &from); -static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, IPAddress &from); -static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, IPAddress &from); static void htcpRecv(int fd, void *data); -static void htcpSend(const char *buf, int len, struct SOCKADDR_IN *to); +static void htcpSend(const char *buf, int len, IPAddress &to); -static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, struct SOCKADDR_IN *); +static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, IPAddress &); -static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, struct SOCKADDR_IN *from); +static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, IPAddress &from); -static void htcpHandleTstResponse(htcpDataHeader *, char *, int, struct SOCKADDR_IN *); +static void htcpHandleTstResponse(htcpDataHeader *, char *, int, IPAddress &); static void htcpHexdump(const char *tag, const char *s, int sz) @@ -605,15 +605,18 @@ static void -htcpSend(const char *buf, int len, struct SOCKADDR_IN *to) +htcpSend(const char *buf, int len, IPAddress &to) { int x; - debugs(31, 3, "htcpSend: " << INET_NTOA(to->sin_addr) << "/" << ntohs(to->sin_port)); + char ntoabuf[MAX_IPSTRLEN]; + + debugs(31, 3, "htcpSend: " << to.ToURL(ntoabuf,MAX_IPSTRLEN) ); htcpHexdump("htcpSend", buf, len); - x = comm_udp_sendto(htcpOutSocket, - to, - sizeof(struct SOCKADDR_IN), +/* FIXME INET6 : drop temp conversion. */ sockaddr_in tmp_to; to.GetSockAddr(tmp_to); + x = comm_udp_sendto(htcpOutSocket, + &tmp_to, + sizeof(struct sockaddr_in), buf, len); @@ -629,7 +632,7 @@ void -htcpSpecifier::setFrom (struct SOCKADDR_IN *aSocket) +htcpSpecifier::setFrom (IPAddress &aSocket) { from = aSocket; } @@ -857,11 +860,11 @@ static int -htcpAccessCheck(acl_access * acl, htcpSpecifier * s, struct sockaddr_in *from) +htcpAccessCheck(acl_access * acl, htcpSpecifier * s, IPAddress &from) { ACLChecklist checklist; - checklist.src_addr = from->sin_addr; - checklist.my_addr = no_addr; + checklist.src_addr = from; + checklist.my_addr.SetNoAddr(); checklist.request = s->request; checklist.accessList = cbdataReference(acl); /* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */ @@ -871,7 +874,7 @@ static void -htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct SOCKADDR_IN *from) +htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, IPAddress &from) { htcpStuff stuff; static char pkt[8192]; @@ -960,7 +963,7 @@ static void -htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, struct sockaddr_in *from) +htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, IPAddress &from) { htcpStuff stuff; static char pkt[8192]; @@ -998,7 +1001,7 @@ static void -htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { debug(31, 3) ("htcpHandleNop: Unimplemented\n"); } @@ -1036,23 +1039,18 @@ if (e->isNull()) { debug(31, 3) ("htcpCheckHit: NO; public object not found\n"); - goto miss; } - - if (!storeEntryValidToSend(e)) { + else if (!storeEntryValidToSend(e)) { debug(31, 3) ("htcpCheckHit: NO; entry not valid to send\n"); - goto miss; } - - if (refreshCheckHTCP(e, checkHitRequest)) { + else if (refreshCheckHTCP(e, checkHitRequest)) { debug(31, 3) ("htcpCheckHit: NO; cached response is stale\n"); - goto miss; } - - debug(31, 3) ("htcpCheckHit: YES!?\n"); - hit = e; - -miss: + else + { + debug(31, 3) ("htcpCheckHit: YES!?\n"); + hit = e; + } checkedHit (hit); } @@ -1103,7 +1101,7 @@ static void -htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { debug(31, 3) ("htcpHandleTst: sz = %d\n", (int) sz); @@ -1118,19 +1116,19 @@ static void -htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { htcpReplyData htcpReply; cache_key *key = NULL; - struct sockaddr_in *peer; + IPAddress *peer; htcpDetail *d = NULL; char *t; - + char ntoabuf[MAX_IPSTRLEN]; if (queried_id[hdr->msg_id % N_QUERIED_KEYS] != hdr->msg_id) { - debug(31, 2) ("htcpHandleTstResponse: No matching query id '%d' (expected %d) from '%s'\n", hdr->msg_id, queried_id[hdr->msg_id % N_QUERIED_KEYS], inet_ntoa(from->sin_addr)); + debug(31, 2) ("htcpHandleTstResponse: No matching query id '%d' (expected %d) from '%s'\n", hdr->msg_id, queried_id[hdr->msg_id % N_QUERIED_KEYS], from.NtoA(ntoabuf,MAX_IPSTRLEN) ); return; } @@ -1138,15 +1136,15 @@ if (!key) { - debug(31, 1) ("htcpHandleTstResponse: No query key for response id '%d' from '%s'\n", hdr->msg_id, inet_ntoa(from->sin_addr)); + debug(31, 1) ("htcpHandleTstResponse: No query key for response id '%d' from '%s'\n", hdr->msg_id, from.NtoA(ntoabuf,MAX_IPSTRLEN) ); return; } peer = &queried_addr[hdr->msg_id % N_QUERIED_KEYS]; - if (peer->sin_addr.s_addr != from->sin_addr.s_addr || peer->sin_port != from->sin_port) + if ( *peer != from || peer->GetPort() != from.GetPort() ) { - debug(31, 1) ("htcpHandleTstResponse: Unexpected response source %s\n", inet_ntoa(from->sin_addr)); + debug(31, 1) ("htcpHandleTstResponse: Unexpected response source %s\n", from.NtoA(ntoabuf,MAX_IPSTRLEN)); return; } @@ -1193,7 +1191,7 @@ static void -htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, IPAddress &from) { /* buf should be a SPECIFIER */ htcpSpecifier *s; @@ -1257,21 +1255,21 @@ static void -htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { debug(31, 3) ("htcpHandleMon: Unimplemented\n"); } static void -htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { debug(31, 3) ("htcpHandleSet: Unimplemented\n"); } static void -htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) +htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, IPAddress &from) { htcpSpecifier *s; /* buf[0/1] is reserved and reason */ @@ -1333,9 +1331,10 @@ static void -htcpHandleData(char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandleData(char *buf, int sz, IPAddress &from) { htcpDataHeader hdr; + char ntoabuf[MAX_IPSTRLEN]; if ((size_t)sz < sizeof(htcpDataHeader)) { @@ -1367,7 +1366,7 @@ if (hdr.opcode >= HTCP_END) { debug(31, 1) ("htcpHandleData: client %s, opcode %d out of range\n", - INET_NTOA(from->sin_addr), + from.NtoA(ntoabuf,MAX_IPSTRLEN), (int) hdr.opcode); return; } @@ -1429,10 +1428,11 @@ static void -htcpHandle(char *buf, int sz, struct SOCKADDR_IN *from) +htcpHandle(char *buf, int sz, IPAddress &from) { htcpHeader htcpHdr; assert (sz >= 0); + char ntoabuf[MAX_IPSTRLEN]; if ((size_t)sz < sizeof(htcpHeader)) { @@ -1459,7 +1459,7 @@ { debug(31, 1) ("htcpHandle: sz/%d != htcpHdr.length/%d from %s:%d\n", sz, htcpHdr.length, - INET_NTOA(from->sin_addr), (int) ntohs(from->sin_port)); + from.NtoA(ntoabuf,MAX_IPSTRLEN), (int) from.GetPort() ); return; } @@ -1467,7 +1467,7 @@ { debug(31, 1) ("htcpHandle: Unknown major version %d from %s:%d\n", htcpHdr.major, - inet_ntoa(from->sin_addr), (int) ntohs(from->sin_port)); + from.NtoA(ntoabuf,MAX_IPSTRLEN), (int) from.GetPort() ); return; } @@ -1481,22 +1481,25 @@ { static char buf[8192]; int len; + static IPAddress from; + static char ntoabuf[MAX_IPSTRLEN]; - static struct SOCKADDR_IN from; - - socklen_t flen = sizeof(struct SOCKADDR_IN); - memset(&from, '\0', flen); + socklen_t flen = sizeof(struct sockaddr_in); /* Receive up to 8191 bytes, leaving room for a null */ - len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &flen); +/* FIXME INET6 : drop temp construction */ struct sockaddr_in tmp_from; from.GetSockAddr(tmp_from); + len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &tmp_from, &flen); + +/* FIXME INET6 : drop temp construction */ from = tmp_from; + debug(31, 3) ("htcpRecv: FD %d, %d bytes from %s:%d\n", - fd, len, INET_NTOA(from.sin_addr), ntohs(from.sin_port)); + fd, len, from.NtoA(ntoabuf,MAX_IPSTRLEN), from.GetPort() ); if (len) statCounter.htcp.pkts_recv++; - htcpHandle(buf, len, &from); + htcpHandle(buf, len, from); commSetSelect(fd, COMM_SELECT_READ, htcpRecv, NULL, 0); } @@ -1622,7 +1625,8 @@ return; } - htcpSend(pkt, (int) pktlen, &p->in_addr); +/* FIXME INET6 : drop temp conversion. */ IPAddress tmp(p->in_addr); + htcpSend(pkt, (int) pktlen, tmp); queried_id[stuff.msg_id % N_QUERIED_KEYS] = stuff.msg_id; save_key = queried_keys[stuff.msg_id % N_QUERIED_KEYS]; storeKeyCopy(save_key, (const cache_key *)e->key); Index: squid3/src/htcp.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/htcp.h,v retrieving revision 1.4.8.1 retrieving revision 1.4.8.2 diff -u -r1.4.8.1 -r1.4.8.2 --- squid3/src/htcp.h 25 Apr 2005 13:39:00 -0000 1.4.8.1 +++ squid3/src/htcp.h 11 Apr 2007 13:23:23 -0000 1.4.8.2 @@ -1,6 +1,6 @@ /* - * $Id: htcp.h,v 1.4.8.1 2005/04/25 13:39:00 rmartinez Exp $ + * $Id: htcp.h,v 1.4.8.2 2007/04/11 13:23:23 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -36,6 +36,7 @@ #if USE_HTCP #include "HttpHeader.h" +#include "IPAddress.h" class HtcpReplyData { @@ -60,7 +61,7 @@ typedef class HtcpReplyData htcpReplyData; -SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const struct SOCKADDR_IN *); +SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const IPAddress &); SQUIDCEXTERN void htcpInit(void); SQUIDCEXTERN void htcpQuery(StoreEntry * e, HttpRequest * req, peer * p); SQUIDCEXTERN void htcpSocketShutdown(void); Index: squid3/src/icmp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/icmp.cc,v retrieving revision 1.8.8.4 retrieving revision 1.8.8.5 diff -u -r1.8.8.4 -r1.8.8.5 --- squid3/src/icmp.cc 5 Jan 2007 16:59:22 -0000 1.8.8.4 +++ squid3/src/icmp.cc 11 Apr 2007 13:23:23 -0000 1.8.8.5 @@ -1,6 +1,6 @@ /* - * $Id: icmp.cc,v 1.8.8.4 2007/01/05 16:59:22 hno Exp $ + * $Id: icmp.cc,v 1.8.8.5 2007/04/11 13:23:23 amosjeffries Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -37,6 +37,7 @@ #include "squid.h" #include "comm.h" #include "SquidTime.h" +#include "IPAddress.h" #if USE_ICMP @@ -50,7 +51,7 @@ static void icmpSend(pingerEchoData * pkt, int len); #if ALLOW_SOURCE_PING -static void icmpHandleSourcePing(const struct SOCKADDR_IN *from, const char *buf); +static void icmpHandleSourcePing(const IPAddress &from, const char *buf); #endif static void * hIpc; @@ -58,7 +59,7 @@ static void -icmpSendEcho(struct IN_ADDR to, int opcode, const char *payload, int len) +icmpSendEcho(IPAddress &to, int opcode, const char *payload, int len) { static pingerEchoData pecho; @@ -67,7 +68,7 @@ assert(len <= PINGER_PAYLOAD_SZ); - pecho.to = to; + to.GetInAddr(pecho.to); pecho.opcode = (unsigned char) opcode; @@ -85,7 +86,7 @@ static int fail_count = 0; pingerReplyData preply; - static struct SOCKADDR_IN F; + static struct sockaddr_in F; commSetSelect(icmp_sock, COMM_SELECT_READ, icmpRecv, NULL, 0); memset(&preply, '\0', sizeof(pingerReplyData)); n = comm_udp_recv(icmp_sock, @@ -113,11 +114,11 @@ if (n == 0) /* test probe from pinger */ return; - FAMILY_FROM_SA(F) = AF_INET; + F.sin_family = AF_INET; - ADDR_FROM_SA(F) = preply.from; + F.sin_addr = preply.from; - PORT_FROM_SA(F) = 0; + F.sin_port = 0; switch (preply.opcode) { @@ -221,11 +222,15 @@ void -icmpDomainPing(struct IN_ADDR to, const char *domain) +icmpDomainPing(IPAddress &to, const char *domain) { #if USE_ICMP debug(37, 3) ("icmpDomainPing: '%s'\n", domain); - icmpSendEcho(to, S_ICMP_DOM, domain, 0); + if(to.IsIPv4()) + { +/* FIXME INET6 : drop temp conversion */ struct IN_ADDR tmp; to.GetInAddr(tmp); + icmpSendEcho(tmp, S_ICMP_DOM, domain, 0); + } #endif } Index: squid3/src/net_db.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/net_db.cc,v retrieving revision 1.13.4.7 retrieving revision 1.13.4.8 diff -u -r1.13.4.7 -r1.13.4.8 --- squid3/src/net_db.cc 10 Apr 2007 12:48:12 -0000 1.13.4.7 +++ squid3/src/net_db.cc 11 Apr 2007 13:23:24 -0000 1.13.4.8 @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.13.4.7 2007/04/10 12:48:12 amosjeffries Exp $ + * $Id: net_db.cc,v 1.13.4.8 2007/04/11 13:23:24 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -54,6 +54,7 @@ #include "forward.h" #include "SquidTime.h" #include "wordlist.h" +#include "IPAddress.h" #if USE_ICMP #include "StoreClient.h" @@ -84,10 +85,10 @@ static hash_table *addr_table = NULL; static hash_table *host_table = NULL; -static struct IN_ADDR networkFromInaddr(struct IN_ADDR a); +static IPAddress networkFromInaddr(IPAddress &a); static void netdbRelease(netdbEntry * n); -static void netdbHashInsert(netdbEntry * n, struct IN_ADDR addr); +static void netdbHashInsert(netdbEntry * n, IPAddress &addr); static void netdbHashDelete(const char *key); static void netdbHostInsert(netdbEntry * n, const char *hostname); static void netdbHostDelete(const net_db_name * x); @@ -113,7 +114,7 @@ static void -netdbHashInsert(netdbEntry * n, struct IN_ADDR addr) +netdbHashInsert(netdbEntry * n, IPAddress &addr) { networkFromInaddr(addr).NtoA(n->network, MAX_IPSTRLEN); n->hash.key = n->network; @@ -253,14 +254,14 @@ { netdbEntry *n; char *key = new char [MAX_IPSTRLEN]; + memset(key,0,MAX_IPSTRLEN); networkFromInaddr(addr).NtoA(key,MAX_IPSTRLEN); n = (netdbEntry *) hash_lookup(addr_table, key); return n; } static netdbEntry * - -netdbAdd(struct IN_ADDR addr) +netdbAdd(IPAddress &addr) { netdbEntry *n; @@ -279,8 +280,7 @@ static void netdbSendPing(const ipcache_addrs * ia, void *data) { - - struct IN_ADDR addr; + IPAddress addr; char *hostname; static_cast(data)->unwrap(&hostname); netdbEntry *n; @@ -546,7 +546,7 @@ netdbEntry *n; netdbEntry N; - struct IN_ADDR addr; + IPAddress addr; int count = 0; struct timeval start = current_time; @@ -588,7 +588,7 @@ if (NULL == q) continue; - if (!safe_inet_addr(q, &addr)) + if (! (addr = q) ) continue; if (netdbLookupAddr(addr) != NULL) /* no dups! */ @@ -691,7 +691,7 @@ int rec_sz = 0; off_t o; - struct IN_ADDR addr; + IPAddress addr; double rtt; double hops; char *p; @@ -783,7 +783,7 @@ while (size >= rec_sz) { debug(38, 5) ("netdbExchangeHandleReply: in parsing loop, size = %d\n", size); - addr.s_addr = any_addr.s_addr; + addr.SetAnyAddr(); hops = rtt = 0.0; for (o = 0; o < rec_sz;) { @@ -816,7 +816,7 @@ } } - if (addr.s_addr != any_addr.s_addr && rtt > 0) + if (!addr.IsAnyAddr() && rtt > 0) netdbExchangeUpdatePeer(addr, ex->p, rtt, hops); assert(o == rec_sz); @@ -994,7 +994,7 @@ int -netdbHops(struct IN_ADDR addr) +netdbHops(IPAddress &addr) { #if USE_ICMP netdbEntry *n = netdbLookupAddr(addr); @@ -1163,13 +1163,14 @@ void -netdbExchangeUpdatePeer(struct IN_ADDR addr, peer * e, double rtt, double hops) +netdbExchangeUpdatePeer(IPAddress &addr, peer * e, double rtt, double hops) { #if USE_ICMP + char buf[MAX_IPSTRLEN]; netdbEntry *n; net_db_peer *p; debug(38, 5) ("netdbExchangeUpdatePeer: '%s', %0.1f hops, %0.1f rtt\n", - inet_ntoa(addr), hops, rtt); + addr.NtoA(buf,MAX_IPSTRLEN), hops, rtt); n = netdbLookupAddr(addr); if (n == NULL) @@ -1199,7 +1200,7 @@ void -netdbDeleteAddrNetwork(IPAddress addr) +netdbDeleteAddrNetwork(IPAddress &addr) { #if USE_ICMP netdbEntry *n = netdbLookupAddr(addr); @@ -1226,7 +1227,7 @@ int rec_sz; char *buf; - struct IN_ADDR addr; + IPAddress addr; storeBuffer(s); HttpVersion version(1, 0); reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2); @@ -1246,7 +1247,7 @@ if (n->rtt > 60000) /* RTT > 1 MIN probably bogus */ continue; - if (!safe_inet_addr(n->network, &addr)) + if (! (addr = n->network) ) continue; buf[i++] = (char) NETDB_EX_NETWORK; Index: squid3/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/protos.h,v retrieving revision 1.48.4.11 retrieving revision 1.48.4.12 diff -u -r1.48.4.11 -r1.48.4.12 --- squid3/src/protos.h 5 Apr 2007 09:23:58 -0000 1.48.4.11 +++ squid3/src/protos.h 11 Apr 2007 13:23:24 -0000 1.48.4.12 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.48.4.11 2007/04/05 09:23:58 amosjeffries Exp $ + * $Id: protos.h,v 1.48.4.12 2007/04/11 13:23:24 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -269,7 +269,7 @@ SQUIDCEXTERN void icmpSourcePing(struct IN_ADDR to, const icp_common_t *, const char *url); -SQUIDCEXTERN void icmpDomainPing(struct IN_ADDR to, const char *domain); +SQUIDCEXTERN void icmpDomainPing(IPAddress &to, const char *domain); #ifdef SQUID_SNMP SQUIDCEXTERN PF snmpHandleUdp; @@ -406,11 +406,11 @@ SQUIDCEXTERN int netdbHostRtt(const char *host); SQUIDCEXTERN void netdbUpdatePeer(HttpRequest *, peer * e, int rtt, int hops); -SQUIDCEXTERN void netdbDeleteAddrNetwork(IPAddress addr); +SQUIDCEXTERN void netdbDeleteAddrNetwork(IPAddress &addr); SQUIDCEXTERN void netdbBinaryExchange(StoreEntry *); SQUIDCEXTERN void netdbExchangeStart(void *); -SQUIDCEXTERN void netdbExchangeUpdatePeer(struct IN_ADDR, peer *, double, double); +SQUIDCEXTERN void netdbExchangeUpdatePeer(IPAddress &, peer *, double, double); SQUIDCEXTERN peer *netdbClosestParent(HttpRequest *); SQUIDCEXTERN void netdbHostData(const char *host, int *samp, int *rtt, int *hops);