From: Amos Jeffries Date: Wed, 7 Jan 2009 10:52:18 +0000 (+1300) Subject: Convert many IPAddress to IpAddress X-Git-Tag: SQUID_3_2_0_1~1269^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23f6a720b1ad4dbbf03370b342ab55616beffb43;p=thirdparty%2Fsquid.git Convert many IPAddress to IpAddress --- diff --git a/src/ACLIP.cc b/src/ACLIP.cc index d7fc8795b8..6ce3f27c08 100644 --- a/src/ACLIP.cc +++ b/src/ACLIP.cc @@ -462,4 +462,4 @@ ACLIP::match(IpAddress &clientip) acl_ip_data::acl_ip_data () :addr1(), addr2(), mask(), next (NULL) {} -acl_ip_data::acl_ip_data (IpAddress const &anAddress1, IPAddress const &anAddress2, IPAddress const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext) {} +acl_ip_data::acl_ip_data (IpAddress const &anAddress1, IpAddress const &anAddress2, IPAddress const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext) {} diff --git a/src/ACLIP.h b/src/ACLIP.h index 4d1b7a5614..8e53f4c0ba 100644 --- a/src/ACLIP.h +++ b/src/ACLIP.h @@ -50,7 +50,7 @@ public: acl_ip_data (); - acl_ip_data (IpAddress const &, IPAddress const &, IPAddress const &, acl_ip_data *); + acl_ip_data (IpAddress const &, IpAddress const &, IPAddress const &, acl_ip_data *); void toStr(char *buf, int len) const; IpAddress addr1; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 566902e5ee..c48cceaf2c 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -142,11 +142,11 @@ static void dump_denyinfo(StoreEntry * entry, const char *name, acl_deny_info_li static void free_denyinfo(acl_deny_info_list ** var); #if USE_WCCPv2 -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 **); +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_IpAddress_list(const IPAddress_list *); +static int check_null_IpAddress_list(const IpAddress_list *); #endif /* CURRENTLY_UNUSED */ #endif /* USE_WCCPv2 */ @@ -2750,7 +2750,7 @@ parseNeighborType(const char *s) #if USE_WCCPv2 void -parse_IpAddress_list_token(IPAddress_list ** head, char *token) +parse_IpAddress_list_token(IpAddress_list ** head, char *token) { char *t; char *host; @@ -2811,7 +2811,7 @@ parse_IpAddress_list_token(IPAddress_list ** head, char *token) } static void -parse_IpAddress_list(IPAddress_list ** head) +parse_IpAddress_list(IpAddress_list ** head) { char *token; @@ -2821,7 +2821,7 @@ parse_IpAddress_list(IPAddress_list ** head) } static void -dump_IpAddress_list(StoreEntry * e, const char *n, const IPAddress_list * s) +dump_IpAddress_list(StoreEntry * e, const char *n, const IpAddress_list * s) { char ntoabuf[MAX_IPSTRLEN]; @@ -2834,7 +2834,7 @@ dump_IpAddress_list(StoreEntry * e, const char *n, const IPAddress_list * s) } static void -free_IpAddress_list(IPAddress_list ** head) +free_IpAddress_list(IpAddress_list ** head) { if (*head) delete *head; *head = NULL; diff --git a/src/client_side.cc b/src/client_side.cc index 42ca7e027b..553435b9bb 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -166,7 +166,7 @@ static void connNoteUseOfBuffer(ConnStateData* conn, size_t byteCount); static int connKeepReadingIncompleteRequest(ConnStateData * conn); static void connCancelIncompleteRequests(ConnStateData * conn); -static ConnStateData *connStateCreate(const IpAddress &peer, const IPAddress &me, int fd, http_port_list *port); +static ConnStateData *connStateCreate(const IpAddress &peer, const IpAddress &me, int fd, http_port_list *port); int @@ -2765,7 +2765,7 @@ okToAccept() } ConnStateData * -connStateCreate(const IpAddress &peer, const IPAddress &me, int fd, http_port_list *port) +connStateCreate(const IpAddress &peer, const IpAddress &me, int fd, http_port_list *port) { ConnStateData *result = new ConnStateData; diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index 989f697413..ada63ca311 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -83,7 +83,7 @@ typedef struct { static hash_table *addr_table = NULL; static hash_table *host_table = NULL; -IpAddress networkFromInaddr(const IPAddress &a); +IpAddress networkFromInaddr(const IpAddress &a); static void netdbRelease(netdbEntry * n); static void netdbHashInsert(netdbEntry * n, IpAddress &addr); diff --git a/src/ident.cc b/src/ident.cc index 06dc2292bf..45624cc553 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -202,7 +202,7 @@ CBDATA_TYPE(IdentStateData); * start a TCP connection to the peer host on port 113 */ void -identStart(IpAddress &me, IPAddress &my_peer, IDCB * callback, void *data) +identStart(IpAddress &me, IpAddress &my_peer, IDCB * callback, void *data) { IdentStateData *state; int fd; diff --git a/src/ident.h b/src/ident.h index a0736dc64c..0c9f9bdcd1 100644 --- a/src/ident.h +++ b/src/ident.h @@ -19,7 +19,7 @@ class IpAddress; /// \ingroup IdentAPI -SQUIDCEXTERN void identStart(IpAddress &me, IPAddress &my_peer, IDCB * callback, void *cbdata); +SQUIDCEXTERN void identStart(IpAddress &me, IpAddress &my_peer, IDCB * callback, void *cbdata); /// \ingroup IdentAPI SQUIDCEXTERN void identInit(void); diff --git a/src/ip/IpAddress.cc b/src/ip/IpAddress.cc index ae8a018ea0..b5539ad10c 100644 --- a/src/ip/IpAddress.cc +++ b/src/ip/IpAddress.cc @@ -1,6 +1,4 @@ /* - * $Id: IpAddress.cc,v 1.4 2008/02/15 09:45:57 amosjeffries Exp $ - * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries * @@ -106,12 +104,12 @@ static const unsigned int MAX_IP6_STRLEN = STRLEN_IP6R; } #endif -IpAddress::IPAddress() +IpAddress::IpAddress() { SetEmpty(); } -IpAddress::~IPAddress() +IpAddress::~IpAddress() { memset(this,0,sizeof(IpAddress)); } @@ -166,7 +164,7 @@ IpAddress::GetCIDR() const return len; } -const int IpAddress::ApplyMask(IPAddress const &mask_addr) +const int IpAddress::ApplyMask(IpAddress const &mask_addr) { uint32_t *p1 = (uint32_t*)(&m_SocketAddr.sin6_addr); uint32_t const *p2 = (uint32_t const *)(&mask_addr.m_SocketAddr.sin6_addr); @@ -468,13 +466,13 @@ bool IpAddress::GetReverseString(char buf[MAX_IPSTRLEN], int show_type) const return false; } -IpAddress& IPAddress::operator =(const IPAddress &s) +IpAddress& IpAddress::operator =(const IPAddress &s) { memcpy(this, &s, sizeof(IpAddress)); return *this; }; -IpAddress::IPAddress(const char*s) +IpAddress::IpAddress(const char*s) { SetEmpty(); operator=(s); @@ -534,13 +532,13 @@ bool IpAddress::LookupHostIP(const char *s, bool nodns) return true; } -IpAddress::IPAddress(struct sockaddr_in const &s) +IpAddress::IpAddress(struct sockaddr_in const &s) { SetEmpty(); operator=(s); }; -IpAddress& IPAddress::operator =(struct sockaddr_in const &s) +IpAddress& IpAddress::operator =(struct sockaddr_in const &s) { #if USE_IPV6 Map4to6((const in_addr)s.sin_addr, m_SocketAddr.sin6_addr); @@ -557,7 +555,7 @@ IpAddress& IPAddress::operator =(struct sockaddr_in const &s) return *this; }; -IpAddress& IPAddress::operator =(const struct sockaddr_storage &s) +IpAddress& IpAddress::operator =(const struct sockaddr_storage &s) { #if USE_IPV6 /* some AF_* magic to tell socket types apart and what we need to do */ @@ -581,13 +579,13 @@ void IpAddress::check4Mapped() } #if USE_IPV6 -IpAddress::IPAddress(struct sockaddr_in6 const &s) +IpAddress::IpAddress(struct sockaddr_in6 const &s) { SetEmpty(); operator=(s); }; -IpAddress& IPAddress::operator =(struct sockaddr_in6 const &s) +IpAddress& IpAddress::operator =(struct sockaddr_in6 const &s) { memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6)); @@ -598,13 +596,13 @@ IpAddress& IPAddress::operator =(struct sockaddr_in6 const &s) #endif -IpAddress::IPAddress(struct in_addr const &s) +IpAddress::IpAddress(struct in_addr const &s) { SetEmpty(); operator=(s); }; -IpAddress& IPAddress::operator =(struct in_addr const &s) +IpAddress& IpAddress::operator =(struct in_addr const &s) { #if USE_IPV6 Map4to6((const in_addr)s, m_SocketAddr.sin6_addr); @@ -624,13 +622,13 @@ IpAddress& IPAddress::operator =(struct in_addr const &s) #if USE_IPV6 -IpAddress::IPAddress(struct in6_addr const &s) +IpAddress::IpAddress(struct in6_addr const &s) { SetEmpty(); operator=(s); }; -IpAddress& IPAddress::operator =(struct in6_addr const &s) +IpAddress& IpAddress::operator =(struct in6_addr const &s) { memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr)); @@ -644,19 +642,19 @@ IpAddress& IPAddress::operator =(struct in6_addr const &s) #endif -IpAddress::IPAddress(const IPAddress &s) +IpAddress::IpAddress(const IPAddress &s) { SetEmpty(); operator=(s); } -IpAddress::IPAddress(IPAddress *s) +IpAddress::IpAddress(IPAddress *s) { SetEmpty(); operator=(s); } -IpAddress& IPAddress::operator =(IPAddress *s) +IpAddress& IpAddress::operator =(IPAddress *s) { IpAddress *tmp = NULL; if (!s) return *this; @@ -665,7 +663,7 @@ IpAddress& IPAddress::operator =(IPAddress *s) return operator=(*tmp); } -IpAddress::IPAddress(const struct hostent &s) +IpAddress::IpAddress(const struct hostent &s) { SetEmpty(); operator=(s); @@ -717,7 +715,7 @@ bool IpAddress::operator =(const struct hostent &s) return true; } -IpAddress::IPAddress(const struct addrinfo &s) +IpAddress::IpAddress(const struct addrinfo &s) { SetEmpty(); operator=(s); @@ -891,7 +889,7 @@ void IpAddress::FreeAddrInfo(struct addrinfo *&ai) const ai = NULL; } -int IpAddress::matchIPAddr(const IPAddress &rhs) const +int IpAddress::matchIPAddr(const IpAddress &rhs) const { #if USE_IPV6 uint8_t *l = (uint8_t*)m_SocketAddr.sin6_addr.s6_addr; @@ -916,17 +914,17 @@ int IpAddress::matchIPAddr(const IPAddress &rhs) const return 0; } -bool IpAddress::operator ==(const IPAddress &s) const +bool IpAddress::operator ==(const IpAddress &s) const { return (0 == matchIPAddr(s)); } -bool IpAddress::operator !=(const IPAddress &s) const +bool IpAddress::operator !=(const IpAddress &s) const { return ! ( operator==(s) ); } -bool IpAddress::operator <=(const IPAddress &rhs) const +bool IpAddress::operator <=(const IpAddress &rhs) const { if (IsAnyAddr() && !rhs.IsAnyAddr()) return true; @@ -934,7 +932,7 @@ bool IpAddress::operator <=(const IPAddress &rhs) const return (matchIPAddr(rhs) <= 0); } -bool IpAddress::operator >=(const IPAddress &rhs) const +bool IpAddress::operator >=(const IpAddress &rhs) const { if (IsNoAddr() && !rhs.IsNoAddr()) return true; @@ -942,7 +940,7 @@ bool IpAddress::operator >=(const IPAddress &rhs) const return ( matchIPAddr(rhs) >= 0); } -bool IpAddress::operator >(const IPAddress &rhs) const +bool IpAddress::operator >(const IpAddress &rhs) const { if (IsNoAddr() && !rhs.IsNoAddr()) return true; @@ -950,7 +948,7 @@ bool IpAddress::operator >(const IPAddress &rhs) const return ( matchIPAddr(rhs) > 0); } -bool IpAddress::operator <(const IPAddress &rhs) const +bool IpAddress::operator <(const IpAddress &rhs) const { if (IsNoAddr() && !rhs.IsNoAddr()) return true; diff --git a/src/ip/IpAddress.h b/src/ip/IpAddress.h index e3d1503d66..4c40ac2b2e 100644 --- a/src/ip/IpAddress.h +++ b/src/ip/IpAddress.h @@ -1,6 +1,4 @@ /* - * $Id: IpAddress.h,v 1.3 2008/02/05 22:39:42 amosjeffries Exp $ - * * DEBUG: section 14 IP Storage and Handling * AUTHOR: Amos Jeffries * @@ -104,7 +102,7 @@ public: /** @name Constructors and Destructor */ /*@{*/ IpAddress(); - IpAddress(const IPAddress &); + IpAddress(const IpAddress &); /** * This constructor takes its own copy of the object pointed to for memory-safe usage later. @@ -113,7 +111,7 @@ public: \deprecated Use of pointers can be nasty. Consider this a last-resort. * Prefer the by-reference (&) version instead. */ - IpAddress(IPAddress *); + IpAddress(IpAddress *); IpAddress(const struct in_addr &); @@ -134,8 +132,8 @@ public: /** @name Assignment Operators */ /*@{*/ - IpAddress& operator =(const IPAddress &s); - IpAddress& operator =(IPAddress *s); + IpAddress& operator =(const IpAddress &s); + IpAddress& operator =(IpAddress *s); IpAddress& operator =(struct sockaddr_in const &s); IpAddress& operator =(struct sockaddr_storage const &s); IpAddress& operator =(struct in_addr const &s); @@ -321,7 +319,7 @@ public: * Some situations may also require an actual call to the system getaddrinfo() * to pull relevant OS details for the socket. \par - * IpAddress allocated objects MUST be destructed by IPAddress::FreeAddrInfo + * IpAddress allocated objects MUST be destructed by IpAddress::FreeAddrInfo * System getaddrinfo() allocated objects MUST be freed with system freeaddrinfo() \par * Some OS require that IPv4 addresses are pre-mapped by the client. diff --git a/src/ip/IpIntercept.cc b/src/ip/IpIntercept.cc index 4091c6f930..c37f74491a 100644 --- a/src/ip/IpIntercept.cc +++ b/src/ip/IpIntercept.cc @@ -118,7 +118,7 @@ IpIntercept::StopInterception(const char *str) } int -IpIntercept::NetfilterInterception(int fd, const IpAddress &me, IPAddress &dst, int silent) +IpIntercept::NetfilterInterception(int fd, const IpAddress &me, IpAddress &dst, int silent) { #if LINUX_NETFILTER struct addrinfo *lookup = NULL; @@ -149,7 +149,7 @@ IpIntercept::NetfilterInterception(int fd, const IpAddress &me, IPAddress &dst, } int -IpIntercept::NetfilterTransparent(int fd, const IpAddress &me, IPAddress &client, int silent) +IpIntercept::NetfilterTransparent(int fd, const IpAddress &me, IpAddress &client, int silent) { #if LINUX_NETFILTER @@ -165,7 +165,7 @@ IpIntercept::NetfilterTransparent(int fd, const IpAddress &me, IPAddress &client } int -IpIntercept::IpfwInterception(int fd, const IpAddress &me, IPAddress &dst, int silent) +IpIntercept::IpfwInterception(int fd, const IpAddress &me, IpAddress &dst, int silent) { #if IPFW_TRANSPARENT struct addrinfo *lookup = NULL; @@ -196,7 +196,7 @@ IpIntercept::IpfwInterception(int fd, const IpAddress &me, IPAddress &dst, int s } int -IpIntercept::NatLookup(int fd, const IpAddress &me, const IPAddress &peer, IPAddress &client, IPAddress &dst) +IpIntercept::NatLookup(int fd, const IpAddress &me, const IpAddress &peer, IPAddress &client, IPAddress &dst) { #if IPF_TRANSPARENT /* --enable-ipf-transparent */ client = me; diff --git a/src/ip/IpIntercept.h b/src/ip/IpIntercept.h index 747dd5490c..fe38eeb650 100644 --- a/src/ip/IpIntercept.h +++ b/src/ip/IpIntercept.h @@ -27,7 +27,7 @@ public: ~IpIntercept() {}; /** Perform NAT lookups */ - int NatLookup(int fd, const IpAddress &me, const IPAddress &peer, IPAddress &client, IPAddress &dst); + int NatLookup(int fd, const IpAddress &me, const IpAddress &peer, IPAddress &client, IPAddress &dst); #if LINUX_TPROXY2 // only relevant to TPROXY v2 connections. @@ -87,7 +87,7 @@ private: \retval 0 Successfuly located the new address. \retval -1 An error occured during NAT lookups. */ - int NetfilterInterception(int fd, const IpAddress &me, IPAddress &client, int silent); + int NetfilterInterception(int fd, const IpAddress &me, IpAddress &client, int silent); /** * perform Lookups on Netfilter fully-transparent interception targets (TPROXY). @@ -96,7 +96,7 @@ private: \retval 0 Successfuly located the new address. \retval -1 An error occured during NAT lookups. */ - int NetfilterTransparent(int fd, const IpAddress &me, IPAddress &dst, int silent); + int NetfilterTransparent(int fd, const IpAddress &me, IpAddress &dst, int silent); /** * perform Lookups on IPFW interception. @@ -105,7 +105,7 @@ private: \retval 0 Successfuly located the new address. \retval -1 An error occured during NAT lookups. */ - int IpfwInterception(int fd, const IpAddress &me, IPAddress &client, int silent); + int IpfwInterception(int fd, const IpAddress &me, IpAddress &client, int silent); int transparent_active; diff --git a/src/ipcache.cc b/src/ipcache.cc index c54cc1a5c4..eb47c967d7 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -420,7 +420,7 @@ ipcacheParse(ipcache_entry *i, const char *inbuf) if (ipcount > 0) { int j, k; - i->addrs.in_addrs = (IpAddress *)xcalloc(ipcount, sizeof(IPAddress)); + i->addrs.in_addrs = (IpAddress *)xcalloc(ipcount, sizeof(IpAddress)); for (int l = 0; l < ipcount; l++) i->addrs.in_addrs[l].SetEmpty(); // perform same init actions as constructor would. i->addrs.bad_mask = (unsigned char *)xcalloc(ipcount, sizeof(unsigned char)); @@ -555,7 +555,7 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m return 0; } - i->addrs.in_addrs = (IpAddress *)xcalloc(na, sizeof(IPAddress)); + i->addrs.in_addrs = (IpAddress *)xcalloc(na, sizeof(IpAddress)); for (int l = 0; l < na; l++) i->addrs.in_addrs[l].SetEmpty(); // perform same init actions as constructor would. i->addrs.bad_mask = (unsigned char *)xcalloc(na, sizeof(unsigned char)); @@ -780,7 +780,7 @@ ipcache_init(void) memset(&lru_list, '\0', sizeof(lru_list)); memset(&static_addrs, '\0', sizeof(ipcache_addrs)); - static_addrs.in_addrs = (IpAddress *)xcalloc(1, sizeof(IPAddress)); + static_addrs.in_addrs = (IpAddress *)xcalloc(1, sizeof(IpAddress)); static_addrs.in_addrs->SetEmpty(); // properly setup the IpAddress! static_addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char)); ipcache_high = (long) (((float) Config.ipcache.size * @@ -1039,7 +1039,7 @@ ipcacheMergeIPLists(const IpAddress *aaddrs, const int alen, debugs(14, 5, "ipcacheMergeIPLists: Merge " << alen << "+" << blen << " into " << fc << " unique IPs."); // copy the old IPs into the new list buffer. - (*out) = (IpAddress*)xcalloc(fc, sizeof(IPAddress)); + (*out) = (IpAddress*)xcalloc(fc, sizeof(IpAddress)); outlen=0; assert(out != NULL); @@ -1459,7 +1459,7 @@ ipcacheAddEntryFromHosts(const char *name, const char *ipaddr) i->addrs.cur = 0; i->addrs.badcount = 0; - i->addrs.in_addrs = (IpAddress *)xcalloc(1, sizeof(IPAddress)); + i->addrs.in_addrs = (IpAddress *)xcalloc(1, sizeof(IpAddress)); i->addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char)); i->addrs.in_addrs[0] = ip; i->addrs.bad_mask[0] = FALSE; diff --git a/src/protos.h b/src/protos.h index e688dbae2a..f5dec38608 100644 --- a/src/protos.h +++ b/src/protos.h @@ -76,7 +76,7 @@ SQUIDCEXTERN void parse_wordlist(wordlist ** list); SQUIDCEXTERN void requirePathnameExists(const char *name, const char *path); SQUIDCEXTERN void parse_time_t(time_t * var); -SQUIDCEXTERN void parse_IpAddress_list_token(IPAddress_list **, char *); +SQUIDCEXTERN void parse_IpAddress_list_token(IpAddress_list **, char *); /* client_side.c - FD related client side routines */ @@ -301,7 +301,7 @@ SQUIDCEXTERN void snmpDebugOid(int lvl, oid * Name, snint Len); SQUIDCEXTERN void addr2oid(IpAddress &addr, oid *Dest); SQUIDCEXTERN void oid2addr(oid *Dest, IpAddress &addr, u_int code); -SQUIDCEXTERN IpAddress *client_entry(IPAddress *current); +SQUIDCEXTERN IpAddress *client_entry(IpAddress *current); SQUIDCEXTERN variable_list *snmp_basicFn(variable_list *, snint *); SQUIDCEXTERN variable_list *snmp_confFn(variable_list *, snint *); SQUIDCEXTERN variable_list *snmp_sysFn(variable_list *, snint *);