IpAddress is now Ip::Address, IpInterceptor is now Ip::Interceptor, etc.
* Also detaches QosConfig from the global config structures.
Clearing up several of the dependency chains to libip
{;
}
- IpAddress caddr;
+ Ip::Address caddr;
int64_t requestSize;
int64_t replySize;
int requestHeadersSize; ///< received, including request line
public:
IcapLogEntry():request(NULL),reply(NULL),outcome(Adaptation::Icap::xoUnknown),trTime(0),ioTime(0),resStatus(HTTP_STATUS_NONE) {}
- IpAddress hostAddr; ///< ICAP server IP address
+ Ip::Address hostAddr; ///< ICAP server IP address
String serviceName; ///< ICAP service name
String reqUri; ///< ICAP Request-URI
Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method
public:
hash_link hash; /* must be first */
- IpAddress addr;
+ Ip::Address addr;
struct {
int result_hist[LOG_TYPE_MAX];
public:
CompositeSelectionDetails() {}
- IpAddress src_addr;
+ Ip::Address src_addr;
AuthUserRequest *user;
String tag;
};
ConnectionDetail();
- IpAddress me;
+ Ip::Address me;
- IpAddress peer;
+ Ip::Address peer;
};
#endif
char skey1[32];
char skey2[32];
char skey3[32];
- IpAddress localhost;
+ Ip::Address localhost;
ikey = (getpid() << 10) + (instanceID << 2);
ikey &= 0x7fffffff;
#endif
public:
- IpAddress host_addr;
+ Ip::Address host_addr;
AuthUserRequest *auth_user_request;
int64_t max_forwards;
- IpAddress client_addr;
+ Ip::Address client_addr;
#if FOLLOW_X_FORWARDED_FOR
- IpAddress indirect_client_addr;
+ Ip::Address indirect_client_addr;
#endif /* FOLLOW_X_FORWARDED_FOR */
#if USE_SQUID_EUI
Eui::Eui64 client_eui64;
#endif
- IpAddress my_addr;
+ Ip::Address my_addr;
HierarchyLogEntry hier;
_icp_common_t();
_icp_common_t(char *buf, unsigned int len);
- void handleReply(char *buf, IpAddress &from);
+ void handleReply(char *buf, Ip::Address &from);
static _icp_common_t *createMessage(icp_opcode opcode, int flags, const char *url, int reqnum, int pad);
icp_opcode getOpCode() const;
#endif
HttpRequest *request;
int fd;
- IpAddress from;
+ Ip::Address from;
char *url;
};
/// \ingroup ServerProtocolICPAPI
struct icpUdpData {
- IpAddress address;
+ Ip::Address address;
void *msg;
size_t len;
icpUdpData *next;
};
/// \ingroup ServerProtocolICPAPI
-HttpRequest* icpGetRequest(char *url, int reqnum, int fd, IpAddress &from);
+HttpRequest* icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from);
/// \ingroup ServerProtocolICPAPI
-int icpAccessAllowed(IpAddress &from, HttpRequest * icp_request);
+int icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
/// \ingroup ServerProtocolICPAPI
-SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const IpAddress &from);
+SQUIDCEXTERN void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from);
/// \ingroup ServerProtocolICPAPI
extern icp_opcode icpGetCommonOpcode();
/// \ingroup ServerProtocolICPAPI
-SQUIDCEXTERN int icpUdpSend(int, const IpAddress &, icp_common_t *, log_type, int);
+SQUIDCEXTERN int icpUdpSend(int, const Ip::Address &, icp_common_t *, log_type, int);
/// \ingroup ServerProtocolICPAPI
SQUIDCEXTERN log_type icpLogFromICPCode(icp_opcode opcode);
/// \ingroup ServerProtocolICPAPI
-void icpDenyAccess(IpAddress &from, char *url, int reqnum, int fd);
+void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd);
/// \ingroup ServerProtocolICPAPI
SQUIDCEXTERN PF icpHandleUdp;
SQUIDCEXTERN PF icpUdpSendQueue;
/// \ingroup ServerProtocolICPAPI
-SQUIDCEXTERN void icpHandleIcpV3(int, IpAddress &, char *, int);
+SQUIDCEXTERN void icpHandleIcpV3(int, Ip::Address &, char *, int);
/// \ingroup ServerProtocolICPAPI
SQUIDCEXTERN int icpCheckUdpHit(StoreEntry *, HttpRequest * request);
}
bool
-GetHostWithPort(char *token, IpAddress *ipa)
+GetHostWithPort(char *token, Ip::Address *ipa)
{
char *t;
char *host;
extern bool StringToInt64(const char *str, int64_t &result, const char **p, int base);
/**
- * Parse a socket address (host:port), fill the given IpAddress object
+ * Parse a socket address (host:port), fill the given Ip::Address object
* \retval false Failure.
* \retval true Success.
* Destroys token during parse.
*/
-extern bool GetHostWithPort(char *token, IpAddress *ipa);
+extern bool GetHostWithPort(char *token, Ip::Address *ipa);
#endif /* SQUID_PARSING_H */
void *callback_data;
FwdServer *servers;
/*
- * Why are these IpAddress instead of peer *? Because a
+ * Why are these Ip::Address instead of peer *? Because a
* peer structure can become invalid during the peer selection
* phase, specifically after a reconfigure. Thus we need to lookup
* the peer * based on the address when we are finally ready to
* reference the peer structure.
*/
- IpAddress first_parent_miss;
+ Ip::Address first_parent_miss;
- IpAddress closest_parent_miss;
+ Ip::Address closest_parent_miss;
/*
* ->hit can be peer* because it should only be
* accessed during the thread when it is set
http_port_list *next;
- IpAddress s;
+ Ip::Address s;
char *protocol; /* protocol name */
char *name; /* visible name */
char *defaultsite; /* default web site */
#include "wordlist.h"
static void aclParseArpList(SplayNode<Eui::Eui48 *> **curlist);
-static int aclMatchArp(SplayNode<Eui::Eui48 *> **dataptr, IpAddress &c);
+static int aclMatchArp(SplayNode<Eui::Eui48 *> **dataptr, Ip::Address &c);
static SplayNode<Eui::Eui48 *>::SPLAYCMP aclArpCompare;
static SplayNode<Eui::Eui48 *>::SPLAYWALKEE aclDumpArpListWalkee;
/* aclMatchArp */
/***************/
int
-aclMatchArp(SplayNode<Eui::Eui48 *> **dataptr, IpAddress &c)
+aclMatchArp(SplayNode<Eui::Eui48 *> **dataptr, Ip::Address &c)
{
Eui::Eui48 result;
SplayNode<Eui::Eui48 *> **Top = dataptr;
{
public:
uint8_t len;
- IpAddress addr;
+ Ip::Address addr;
- m_ADDR() : len(sizeof(IpAddress)) {};
+ m_ADDR() : len(sizeof(Ip::Address)) {};
};
/* END of definitions for radix tree entries */
/* PUBLIC */
int
-asnMatchIp(CbDataList<int> *data, IpAddress &addr)
+asnMatchIp(CbDataList<int> *data, Ip::Address &addr)
{
struct squid_radix_node *rn;
as_info *e;
CbDataList<int> *q = NULL;
as_info *asinfo = NULL;
- IpAddress mask;
- IpAddress addr;
+ Ip::Address mask;
+ Ip::Address addr;
char *t;
int bitl;
CbDataList<int> *q;
as_info *asinfo;
char buf[MAX_IPSTRLEN];
- IpAddress addr;
- IpAddress mask;
+ Ip::Address addr;
+ Ip::Address mask;
assert(e);
assert(e->e_info);
bool
-ACLASN::match(IpAddress toMatch)
+ACLASN::match(Ip::Address toMatch)
{
return asnMatchIp(data, toMatch);
}
}
}
-ACLData<IpAddress> *
+ACLData<Ip::Address> *
ACLASN::clone() const
{
if (data)
/* explicit template instantiation required for some systems */
-template class ACLStrategised<IpAddress>;
+template class ACLStrategised<Ip::Address>;
ACL::Prototype ACLASN::SourceRegistryProtoype(&ACLASN::SourceRegistryEntry_, "src_as");
-ACLStrategised<IpAddress> ACLASN::SourceRegistryEntry_(new ACLASN, ACLSourceASNStrategy::Instance(), "src_as");
+ACLStrategised<Ip::Address> ACLASN::SourceRegistryEntry_(new ACLASN, ACLSourceASNStrategy::Instance(), "src_as");
ACL::Prototype ACLASN::DestinationRegistryProtoype(&ACLASN::DestinationRegistryEntry_, "dst_as");
-ACLStrategised<IpAddress> ACLASN::DestinationRegistryEntry_(new ACLASN, ACLDestinationASNStrategy::Instance(), "dst_as");
+ACLStrategised<Ip::Address> ACLASN::DestinationRegistryEntry_(new ACLASN, ACLDestinationASNStrategy::Instance(), "dst_as");
int
-ACLSourceASNStrategy::match (ACLData<IpAddress> * &data, ACLFilledChecklist *checklist)
+ACLSourceASNStrategy::match (ACLData<Ip::Address> * &data, ACLFilledChecklist *checklist)
{
return data->match(checklist->src_addr);
}
debugs(28, 3, "asnMatchAcl: Can't yet compare '" << "unknown" /*name*/ << "' ACL for '" << checklist->request->GetHost() << "'");
checklist->changeState (DestinationIPLookup::Instance());
} else {
- IpAddress noaddr;
+ Ip::Address noaddr;
noaddr.SetNoAddr();
return data->match(noaddr);
}
#include "acl/Checklist.h"
#include "ip/IpAddress.h"
-SQUIDCEXTERN int asnMatchIp(CbDataList<int> *, IpAddress &);
+SQUIDCEXTERN int asnMatchIp(CbDataList<int> *, Ip::Address &);
/// \ingroup ACLAPI
SQUIDCEXTERN void asnInit(void);
SQUIDCEXTERN void asnFreeMemory(void);
/// \ingroup ACLAPI
-class ACLASN : public ACLData<IpAddress>
+class ACLASN : public ACLData<Ip::Address>
{
public:
virtual ~ACLASN();
- virtual bool match(IpAddress);
+ virtual bool match(Ip::Address);
virtual wordlist *dump();
virtual void parse();
bool empty() const;
- virtual ACLData<IpAddress> *clone() const;
+ virtual ACLData<Ip::Address> *clone() const;
virtual void prepareForUse();
private:
static ACL::Prototype SourceRegistryProtoype;
- static ACLStrategised<IpAddress> SourceRegistryEntry_;
+ static ACLStrategised<Ip::Address> SourceRegistryEntry_;
static ACL::Prototype DestinationRegistryProtoype;
- static ACLStrategised<IpAddress> DestinationRegistryEntry_;
+ static ACLStrategised<Ip::Address> DestinationRegistryEntry_;
CbDataList<int> *data;
};
#include "ip/IpAddress.h"
/// \ingroup ACLAPI
-class ACLDestinationASNStrategy : public ACLStrategy<IpAddress>
+class ACLDestinationASNStrategy : public ACLStrategy<Ip::Address>
{
public:
#include "wordlist.h"
static void aclParseEuiList(SplayNode<Eui::Eui64 *> **curlist);
-static int aclMatchEui(SplayNode<Eui::Eui64 *> **dataptr, IpAddress &c);
+static int aclMatchEui(SplayNode<Eui::Eui64 *> **dataptr, Ip::Address &c);
static SplayNode<Eui::Eui64 *>::SPLAYCMP aclEui64Compare;
static SplayNode<Eui::Eui64 *>::SPLAYWALKEE aclDumpEuiListWalkee;
/* aclMatchEui */
/***************/
int
-aclMatchEui(SplayNode<Eui::Eui64 *> **dataptr, IpAddress &c)
+aclMatchEui(SplayNode<Eui::Eui64 *> **dataptr, Ip::Address &c)
{
Eui::Eui64 result;
SplayNode<Eui::Eui64 *> **Top = dataptr;
virtual bool hasReply() const { return reply != NULL; }
public:
- IpAddress src_addr;
- IpAddress dst_addr;
- IpAddress my_addr;
+ Ip::Address src_addr;
+ Ip::Address dst_addr;
+ Ip::Address my_addr;
struct peer *dst_peer;
char *dst_rdns;
int
aclIpAddrNetworkCompare(acl_ip_data * const &p, acl_ip_data * const &q)
{
- IpAddress A = p->addr1;
+ Ip::Address A = p->addr1;
/* apply netmask */
A.ApplyMask(q->mask);
* This function should NOT be called if 'asc' is a hostname!
*/
bool
-acl_ip_data::DecodeMask(const char *asc, IpAddress &mask, int ctype)
+acl_ip_data::DecodeMask(const char *asc, Ip::Address &mask, int ctype)
{
char junk;
int a1 = 0;
LOCAL_ARRAY(char, mask, 256);
acl_ip_data *r = NULL;
acl_ip_data **Q = NULL;
- IpAddress temp;
+ Ip::Address temp;
char c;
unsigned int changed;
acl_ip_data *q = new acl_ip_data;
/*
* Note, must use plain getaddrinfo() here because at startup
* ipcache hasn't been initialized
- * TODO: offload this to one of the IpAddress lookups.
+ * TODO: offload this to one of the Ip::Address lookups.
*/
debugs(28, 5, "aclIpParseIpData: Lookup Host/IP " << addr1);
struct addrinfo *hp = NULL, *x = NULL;
struct addrinfo hints;
- IpAddress *prev_addr = NULL;
+ Ip::Address *prev_addr = NULL;
memset(&hints, 0, sizeof(struct addrinfo));
}
int
-ACLIP::match(IpAddress &clientip)
+ACLIP::match(Ip::Address &clientip)
{
static acl_ip_data ClientAddress;
/*
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 (Ip::Address const &anAddress1, Ip::Address const &anAddress2, Ip::Address const &aMask, acl_ip_data *aNext) : addr1(anAddress1), addr2(anAddress2), mask(aMask), next(aNext) {}
acl_ip_data ();
- acl_ip_data (IpAddress const &, IpAddress const &, IpAddress const &, acl_ip_data *);
+ acl_ip_data (Ip::Address const &, Ip::Address const &, Ip::Address const &, acl_ip_data *);
void toStr(char *buf, int len) const;
- IpAddress addr1;
+ Ip::Address addr1;
- IpAddress addr2;
+ Ip::Address addr2;
- IpAddress mask; /**< \todo This should perhapse be stored as a CIDR range now instead of a full IP mask. */
+ Ip::Address mask; /**< \todo This should perhapse be stored as a CIDR range now instead of a full IP mask. */
acl_ip_data *next; /**< used for parsing, not for storing */
private:
- static bool DecodeMask(const char *asc, IpAddress &mask, int string_format_type);
+ static bool DecodeMask(const char *asc, Ip::Address &mask, int string_format_type);
};
MEMPROXY_CLASS_INLINE(acl_ip_data);
protected:
- int match(IpAddress &);
+ int match(Ip::Address &);
IPSplay *data;
private:
#include "acl/Strategy.h"
#include "ip/IpAddress.h"
-class ACLSourceASNStrategy : public ACLStrategy<IpAddress>
+class ACLSourceASNStrategy : public ACLStrategy<Ip::Address>
{
public:
}
if (TheConfig.send_client_ip && request) {
- IpAddress client_addr;
+ Ip::Address client_addr;
#if FOLLOW_X_FORWARDED_FOR
if (TheConfig.icap_uses_indirect_client) {
client_addr = request->indirect_client_addr;
// TODO: obey service-specific, OPTIONS-reported connection limit
void Adaptation::Icap::Xaction::openConnection()
{
- IpAddress client_addr;
+ Ip::Address client_addr;
Must(connection < 0);
disableRetries(); // we only retry pconn failures
- IpAddress outgoing;
+ Ip::Address outgoing;
connection = comm_open(SOCK_STREAM, 0, outgoing,
COMM_NONBLOCKING, s.cfg().uri.termedBuf());
}
if (reuseConnection) {
- IpAddress client_addr;
+ Ip::Address client_addr;
//status() adds leading spaces.
debugs(93,3, HERE << "pushing pconn" << status());
AsyncCall::Pointer call = NULL;
* 1 : Match
*/
int
-ACLMaxUserIP::match(AuthUserRequest * auth_user_request,
-
- IpAddress const &src_addr)
+ACLMaxUserIP::match(AuthUserRequest * auth_user_request, Ip::Address const &src_addr)
{
/*
* the logic for flush the ip list when the limit is hit vs keep
static Prototype RegistryProtoype;
static ACLMaxUserIP RegistryEntry_;
- int match(AuthUserRequest *, IpAddress const &);
+ int match(AuthUserRequest *, Ip::Address const &);
char const *class_;
int maximum;
}
void
-AuthUser::removeIp(IpAddress ipaddr)
+AuthUser::removeIp(Ip::Address ipaddr)
{
auth_user_ip_t *ipdata = (auth_user_ip_t *) ip_list.head;
}
void
-AuthUser::addIp(IpAddress ipaddr)
+AuthUser::addIp(Ip::Address ipaddr)
{
auth_user_ip_t *ipdata = (auth_user_ip_t *) ip_list.head;
int found = 0;
_SQUID_INLINE_ char const *username() const;
_SQUID_INLINE_ void username(char const *);
void clearIp();
- void removeIp(IpAddress);
- void addIp(IpAddress);
+ void removeIp(Ip::Address);
+ void addIp(Ip::Address);
_SQUID_INLINE_ void addRequest(AuthUserRequest *);
void lock();
}
static void
-authenticateAuthUserRequestSetIp(AuthUserRequest * auth_user_request, IpAddress &ipaddr)
+authenticateAuthUserRequestSetIp(AuthUserRequest * auth_user_request, Ip::Address &ipaddr)
{
AuthUser *auth_user = auth_user_request->user();
}
void
-authenticateAuthUserRequestRemoveIp(AuthUserRequest * auth_user_request, IpAddress const &ipaddr)
+authenticateAuthUserRequestRemoveIp(AuthUserRequest * auth_user_request, Ip::Address const &ipaddr)
{
AuthUser *auth_user = auth_user_request->user();
* Caller is responsible for locking and unlocking their *auth_user_request!
*/
auth_acl_t
-AuthUserRequest::authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, IpAddress &src_addr)
+AuthUserRequest::authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, Ip::Address &src_addr)
{
const char *proxy_auth;
assert(headertype != 0);
auth_acl_t
-AuthUserRequest::tryToAuthenticateAndSetAuthUser(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, IpAddress &src_addr)
+AuthUserRequest::tryToAuthenticateAndSetAuthUser(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, Ip::Address &src_addr)
{
/* If we have already been called, return the cached value */
AuthUserRequest *t = authTryGetUser (auth_user_request, conn, request);
dlink_node node;
/* IP addr this user authenticated from */
- IpAddress ipaddr;
+ Ip::Address ipaddr;
time_t ip_expiretime;
};
virtual void user(AuthUser *aUser) {_auth_user=aUser;}
- static auth_acl_t tryToAuthenticateAndSetAuthUser(AuthUserRequest **, http_hdr_type, HttpRequest *, ConnStateData *, IpAddress &);
+ static auth_acl_t tryToAuthenticateAndSetAuthUser(AuthUserRequest **, http_hdr_type, HttpRequest *, ConnStateData *, Ip::Address &);
static void addReplyAuthHeader(HttpReply * rep, AuthUserRequest * auth_user_request, HttpRequest * request, int accelerated, int internal);
AuthUserRequest();
private:
- static auth_acl_t authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, IpAddress &src_addr);
+ static auth_acl_t authenticate(AuthUserRequest ** auth_user_request, http_hdr_type headertype, HttpRequest * request, ConnStateData * conn, Ip::Address &src_addr);
/** return a message on the 407 error pages */
char *message;
extern void authenticateAddTrailer(HttpReply *, AuthUserRequest *, HttpRequest *, int);
/// \ingroup AuthAPI
-extern void authenticateAuthUserRequestRemoveIp(AuthUserRequest *, IpAddress const &);
+extern void authenticateAuthUserRequestRemoveIp(AuthUserRequest *, Ip::Address const &);
/// \ingroup AuthAPI
extern void authenticateAuthUserRequestClearIp(AuthUserRequest *);
/// \ingroup AuthAPI
} else {
const char *useragent = request->header.getStr(HDR_USER_AGENT);
- static IpAddress last_broken_addr;
+ static Ip::Address last_broken_addr;
static int seen_broken_client = 0;
if (!seen_broken_client) {
#include "HttpRequestMethod.h"
#include "ident/Config.h"
#include "ip/IpIntercept.h"
+#include "ip/QosConfig.h"
#include "log/Config.h"
#include "MemBuf.h"
#include "Parsing.h"
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(Ip::Address_list **);
+static void dump_IpAddress_list(StoreEntry *, const char *, const Ip::Address_list *);
+static void free_IpAddress_list(Ip::Address_list **);
#if CURRENTLY_UNUSED
-static int check_null_IpAddress_list(const IpAddress_list *);
+static int check_null_IpAddress_list(const Ip::Address_list *);
#endif /* CURRENTLY_UNUSED */
#endif /* USE_WCCPv2 */
}
static void
-dump_address(StoreEntry * entry, const char *name, IpAddress &addr)
+dump_address(StoreEntry * entry, const char *name, Ip::Address &addr)
{
char buf[MAX_IPSTRLEN];
storeAppendPrintf(entry, "%s %s\n", name, addr.NtoA(buf,MAX_IPSTRLEN) );
}
static void
-parse_address(IpAddress *addr)
+parse_address(Ip::Address *addr)
{
char *token = strtok(NULL, w_space);
}
static void
-free_address(IpAddress *addr)
+free_address(Ip::Address *addr)
{
addr->SetEmpty();
}
#if USE_WCCPv2
static void
-parse_IpAddress_list(IpAddress_list ** head)
+parse_IpAddress_list(Ip::Address_list ** head)
{
char *token;
- IpAddress_list *s;
- IpAddress ipa;
+ Ip::Address_list *s;
+ Ip::Address ipa;
while ((token = strtok(NULL, w_space))) {
if (GetHostWithPort(token, &ipa)) {
while (*head)
head = &(*head)->next;
- s = static_cast<IpAddress_list *>(xcalloc(1, sizeof(*s)));
+ s = static_cast<Ip::Address_list *>(xcalloc(1, sizeof(*s)));
s->s = ipa;
*head = s;
}
static void
-dump_IpAddress_list(StoreEntry * e, const char *n, const IpAddress_list * s)
+dump_IpAddress_list(StoreEntry * e, const char *n, const Ip::Address_list * s)
{
char ntoabuf[MAX_IPSTRLEN];
}
static void
-free_IpAddress_list(IpAddress_list ** head)
+free_IpAddress_list(Ip::Address_list ** head)
{
if (*head) delete *head;
*head = NULL;
* be used by icp_port and htcp_port
*/
static int
-check_null_IpAddress_list(const IpAddress_list * s)
+check_null_IpAddress_list(const Ip::Address_list * s)
{
return NULL == s;
}
} else if (strcmp(token, "transparent") == 0 || strcmp(token, "intercept") == 0) {
s->intercepted = 1;
- IpInterceptor.StartInterception();
+ Ip::Interceptor.StartInterception();
/* Log information regarding the port modes under interception. */
debugs(3, DBG_IMPORTANT, "Starting Authentication on port " << s->s);
debugs(3, DBG_IMPORTANT, "Disabling Authentication on port " << s->s << " (interception enabled)");
self_destruct();
}
s->spoof_client_ip = 1;
- IpInterceptor.StartTransparency();
+ Ip::Interceptor.StartTransparency();
/* Log information regarding the port modes under transparency. */
debugs(3, DBG_IMPORTANT, "Starting IP Spoofing on port " << s->s);
debugs(3, DBG_IMPORTANT, "Disabling Authentication on port " << s->s << " (IP spoofing enabled)");
- if (!IpInterceptor.ProbeForTproxy(s->s)) {
+ if (!Ip::Interceptor.ProbeForTproxy(s->s)) {
debugs(3, DBG_CRITICAL, "FATAL: http(s)_port: TPROXY support in the system does not work.");
self_destruct();
}
TYPE: QosConfig
IFDEF: USE_ZPH_QOS
DEFAULT: none
-LOC: Config.zph
+LOC: Ip::Qos::TheConfig
DOC_START
Allows you to select a TOS/DSCP value to mark outgoing
connections with, based on where the reply was sourced.
static hash_table *client_table = NULL;
-static ClientInfo *clientdbAdd(const IpAddress &addr);
+static ClientInfo *clientdbAdd(const Ip::Address &addr);
static FREE clientdbFreeItem;
static void clientdbStartGC(void);
static void clientdbScheduledGC(void *);
static ClientInfo *
-clientdbAdd(const IpAddress &addr)
+clientdbAdd(const Ip::Address &addr)
{
ClientInfo *c;
char *buf = new char[MAX_IPSTRLEN];
}
void
-clientdbUpdate(const IpAddress &addr, log_type ltype, protocol_t p, size_t size)
+clientdbUpdate(const Ip::Address &addr, log_type ltype, protocol_t p, size_t size)
{
char key[MAX_IPSTRLEN];
ClientInfo *c;
* -1. To get the current value, simply call with delta = 0.
*/
int
-clientdbEstablished(const IpAddress &addr, int delta)
+clientdbEstablished(const Ip::Address &addr, int delta)
{
char key[MAX_IPSTRLEN];
ClientInfo *c;
#define CUTOFF_SECONDS 3600
int
-clientdbCutoffDenied(const IpAddress &addr)
+clientdbCutoffDenied(const Ip::Address &addr)
{
char key[MAX_IPSTRLEN];
int NR;
#if SQUID_SNMP
-IpAddress *
-client_entry(IpAddress *current)
+Ip::Address *
+client_entry(Ip::Address *current)
{
ClientInfo *c = NULL;
char key[MAX_IPSTRLEN];
{
char key[MAX_IPSTRLEN];
ClientInfo *c = NULL;
- IpAddress keyIp;
+ Ip::Address keyIp;
*ErrP = SNMP_ERR_NOERROR;
MemBuf tmp;
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 Ip::Address &peer, const Ip::Address &me, int fd, http_port_list *port);
int
* If transparent or interception mode is working clone the transparent and interception flags
* from the port settings to the request.
*/
- if (IpInterceptor.InterceptActive()) {
+ if (Ip::Interceptor.InterceptActive()) {
request->flags.intercepted = http->flags.intercepted;
}
- if (IpInterceptor.TransparentActive()) {
+ if (Ip::Interceptor.TransparentActive()) {
request->flags.spoof_client_ip = conn->port->spoof_client_ip;
}
}
ConnStateData *
-connStateCreate(const IpAddress &peer, const IpAddress &me, int fd, http_port_list *port)
+connStateCreate(const Ip::Address &peer, const Ip::Address &me, int fd, http_port_list *port)
{
ConnStateData *result = new ConnStateData;
result->port = cbdataReference(port);
if (port->intercepted || port->spoof_client_ip) {
- IpAddress client, dst;
+ Ip::Address client, dst;
- if (IpInterceptor.NatLookup(fd, me, peer, client, dst) == 0) {
+ if (Ip::Interceptor.NatLookup(fd, me, peer, client, dst) == 0) {
result->me = client;
result->peer = dst;
result->transparent(true);
*/
ClientSocketContext::Pointer currentobject;
- IpAddress peer;
+ Ip::Address peer;
- IpAddress me;
+ Ip::Address me;
- IpAddress log_addr;
+ Ip::Address log_addr;
char rfc931[USER_IDENT_SZ];
int nrequests;
/* old includes without reasons given. */
#include "squid.h"
+#include "acl/FilledChecklist.h"
+#include "acl/Gadgets.h"
+#include "auth/UserRequest.h"
+#include "client_side.h"
#include "client_side_reply.h"
-#include "errorpage.h"
-#include "StoreClient.h"
-#include "Store.h"
-#include "HttpReply.h"
-#include "HttpRequest.h"
-#include "forward.h"
#include "clientStream.h"
-#include "auth/UserRequest.h"
+#if DELAY_POOLS
+#include "DelayPools.h"
+#endif
+#include "errorpage.h"
#if USE_SQUID_ESI
#include "esi/Esi.h"
#endif
-#include "MemObject.h"
#include "fde.h"
-#include "acl/FilledChecklist.h"
-#include "acl/Gadgets.h"
-#if DELAY_POOLS
-#include "DelayPools.h"
-#endif
-#include "client_side.h"
+#include "forward.h"
+#include "HttpReply.h"
+#include "HttpRequest.h"
+#include "ip/QosConfig.h"
+#include "MemObject.h"
#include "SquidTime.h"
+#include "StoreClient.h"
+#include "Store.h"
CBDATA_CLASS_INIT(clientReplyContext);
/* Local functions */
extern "C" CSS clientReplyStatus;
-extern ErrorState *clientBuildError(err_type, http_status, char const *, IpAddress &, HttpRequest *);
+extern ErrorState *clientBuildError(err_type, http_status, char const *, Ip::Address &, HttpRequest *);
/* privates */
void
clientReplyContext::setReplyToError(
err_type err, http_status status, const HttpRequestMethod& method, char const *uri,
- IpAddress &addr, HttpRequest * failedrequest, const char *unparsedrequest,
+ Ip::Address &addr, HttpRequest * failedrequest, const char *unparsedrequest,
AuthUserRequest * auth_user_request)
{
ErrorState *errstate =
assert(http->out.size == 0);
assert(http->out.offset == 0);
#if USE_ZPH_QOS
- if (Config.zph.tos_local_hit) {
- debugs(33, 2, "ZPH Local hit, TOS=" << Config.zph.tos_local_hit);
- comm_set_tos(http->getConn()->fd, Config.zph.tos_local_hit);
+ if (Ip::Qos::TheConfig.tos_local_hit) {
+ debugs(33, 2, "ZPH Local hit, TOS=" << Ip::Qos::TheConfig.tos_local_hit);
+ comm_set_tos(http->getConn()->fd, Ip::Qos::TheConfig.tos_local_hit);
}
#endif /* USE_ZPH_QOS */
localTempBuffer.offset = reqofs;
void
clientReplyContext::sendBodyTooLargeError()
{
- IpAddress tmp_noaddr;
+ Ip::Address tmp_noaddr;
tmp_noaddr.SetNoAddr(); // TODO: make a global const
http->logType = LOG_TCP_DENIED_REPLY;
ErrorState *err = clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL,
if (page_id == ERR_NONE)
page_id = ERR_ACCESS_DENIED;
- IpAddress tmp_noaddr;
+ Ip::Address tmp_noaddr;
tmp_noaddr.SetNoAddr();
err = clientBuildError(page_id, HTTP_FORBIDDEN, NULL,
http->getConn() != NULL ? http->getConn()->peer : tmp_noaddr,
if (reqofs==0 && !logTypeIsATcpHit(http->logType)) {
assert(fd >= 0); // the beginning of this method implies fd may be -1
int tos = 0;
- if (Config.zph.tos_sibling_hit && http->request->hier.code==SIBLING_HIT ) {
- tos = Config.zph.tos_sibling_hit;
+ if (Ip::Qos::TheConfig.tos_sibling_hit && http->request->hier.code==SIBLING_HIT ) {
+ tos = Ip::Qos::TheConfig.tos_sibling_hit;
debugs(33, 2, "ZPH: Sibling Peer hit with hier.code=" << http->request->hier.code << ", TOS=" << tos);
- } else if (Config.zph.tos_parent_hit && http->request->hier.code==PARENT_HIT) {
- tos = Config.zph.tos_parent_hit;
+ } else if (Ip::Qos::TheConfig.tos_parent_hit && http->request->hier.code==PARENT_HIT) {
+ tos = Ip::Qos::TheConfig.tos_parent_hit;
debugs(33, 2, "ZPH: Parent Peer hit with hier.code=" << http->request->hier.code << ", TOS=" << tos);
- } else if (Config.zph.preserve_miss_tos && Config.zph.preserve_miss_tos_mask) {
- tos = fd_table[fd].upstreamTOS & Config.zph.preserve_miss_tos_mask;
+ } else if (Ip::Qos::TheConfig.preserve_miss_tos && Ip::Qos::TheConfig.preserve_miss_tos_mask) {
+ tos = fd_table[fd].upstreamTOS & Ip::Qos::TheConfig.preserve_miss_tos_mask;
debugs(33, 2, "ZPH: Preserving TOS on miss, TOS="<<tos);
}
comm_set_tos(fd,tos);
ErrorState *
clientBuildError(err_type page_id, http_status status, char const *url,
- IpAddress &src_addr, HttpRequest * request)
+ Ip::Address &src_addr, HttpRequest * request)
{
ErrorState *err = errorCon(page_id, status, request);
err->src_addr = src_addr;
#include "client_side_request.h"
class ErrorState;
-class IpAddress;
+class Ip::Address;
/* XXX make static method */
int storeOKTransferDone() const;
int storeNotOKTransferDone() const;
- void setReplyToError(err_type, http_status, const HttpRequestMethod&, char const *, IpAddress &, HttpRequest *, const char *, AuthUserRequest *);
+ void setReplyToError(err_type, http_status, const HttpRequestMethod&, char const *, Ip::Address &, HttpRequest *, const char *, AuthUserRequest *);
void createStoreEntry(const HttpRequestMethod& m, request_flags flags);
void removeStoreReference(store_client ** scp, StoreEntry ** ep);
void removeClientStoreReference(store_client **scp, ClientHttpRequest *http);
const char *p;
const char *asciiaddr;
int l;
- IpAddress addr;
+ Ip::Address addr;
p = request->x_forwarded_for_iterator.termedBuf();
l = request->x_forwarded_for_iterator.size();
clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->prev->data;
clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
assert (repContext);
- IpAddress tmpnoaddr;
+ Ip::Address tmpnoaddr;
tmpnoaddr.SetNoAddr();
repContext->setReplyToError(page_id, status,
http->request->method, NULL,
// The original author of the code also wanted to pass an errno to
// setReplyToError, but it seems unlikely that the errno reflects the
// true cause of the error at this point, so I did not pass it.
- IpAddress noAddr;
+ Ip::Address noAddr;
noAddr.SetNoAddr();
ConnStateData * c = getConn();
repContext->setReplyToError(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR,
// defaults given by client
char *host;
u_short default_port;
- IpAddress default_addr;
+ Ip::Address default_addr;
// NP: CANNOT store the default addr:port together as it gets set/reset differently.
DnsLookupDetails dns; ///< host lookup details
- IpAddress S;
+ Ip::Address S;
AsyncCall::Pointer callback;
int fd;
* synchronous wrapper around udp socket functions
*/
int
-comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, IpAddress &from)
+comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from)
{
statCounter.syscalls.sock.recvfroms++;
int x = 0;
int
comm_udp_recv(int fd, void *buf, size_t len, int flags)
{
- IpAddress nul;
+ Ip::Address nul;
return comm_udp_recvfrom(fd, buf, len, flags, nul);
}
u_short
comm_local_port(int fd)
{
- IpAddress temp;
+ Ip::Address temp;
struct addrinfo *addr = NULL;
fde *F = &fd_table[fd];
int
comm_open(int sock_type,
int proto,
- IpAddress &addr,
+ Ip::Address &addr,
int flags,
const char *note)
{
int
comm_open_listener(int sock_type,
int proto,
- IpAddress &addr,
+ Ip::Address &addr,
int flags,
const char *note)
{
int
comm_openex(int sock_type,
int proto,
- IpAddress &addr,
+ Ip::Address &addr,
int flags,
unsigned char TOS,
const char *note)
ConnectStateData::commResetFD()
{
struct addrinfo *AI = NULL;
- IpAddress nul;
+ Ip::Address nul;
int new_family = AF_UNSPEC;
// XXX: do we have to check this?
}
int
-comm_connect_addr(int sock, const IpAddress &address)
+comm_connect_addr(int sock, const Ip::Address &address)
{
comm_err_t status = COMM_OK;
fde *F = &fd_table[sock];
/* Send a udp datagram to specified TO_ADDR. */
int
comm_udp_sendto(int fd,
- const IpAddress &to_addr,
+ const Ip::Address &to_addr,
const void *buf,
int len)
{
SQUIDCEXTERN void commConnectStart(int fd, const char *, u_short, CNCB *, void *);
void commConnectStart(int fd, const char *, u_short, AsyncCall::Pointer &cb);
-SQUIDCEXTERN int comm_connect_addr(int sock, const IpAddress &addr);
+SQUIDCEXTERN int comm_connect_addr(int sock, const Ip::Address &addr);
SQUIDCEXTERN void comm_init(void);
SQUIDCEXTERN void comm_exit(void);
-SQUIDCEXTERN int comm_open(int, int, IpAddress &, int, const char *note);
+SQUIDCEXTERN int comm_open(int, int, Ip::Address &, int, const char *note);
/**
* Open a port specially bound for listening or sending through a specific port.
* (in debugs or cachemgr) will occur in Native IPv4 format.
* A reconfigure is needed to reset the stored IP in most cases and attempt a port re-open.
*/
-SQUIDCEXTERN int comm_open_listener(int sock_type, int proto, IpAddress &addr, int flags, const char *note);
+SQUIDCEXTERN int comm_open_listener(int sock_type, int proto, Ip::Address &addr, int flags, const char *note);
-SQUIDCEXTERN int comm_openex(int, int, IpAddress &, int, unsigned char TOS, const char *);
+SQUIDCEXTERN int comm_openex(int, int, Ip::Address &, int, unsigned char TOS, const char *);
SQUIDCEXTERN u_short comm_local_port(int fd);
SQUIDCEXTERN int comm_set_tos(int fd, int tos);
SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
SQUIDCEXTERN void commResetSelect(int);
-SQUIDCEXTERN int comm_udp_sendto(int sock, const IpAddress &to, const void *buf, int buflen);
+SQUIDCEXTERN int comm_udp_sendto(int sock, const Ip::Address &to, const void *buf, int buflen);
extern void comm_write(int fd, const char *buf, int len, IOCB *callback, void *callback_data, FREE *func);
extern void comm_write(int fd, const char *buf, int size, AsyncCall::Pointer &callback, FREE * free_func = NULL);
SQUIDCEXTERN void comm_write_mbuf(int fd, MemBuf *mb, IOCB * handler, void *handler_data);
extern void comm_read(int fd, char *buf, int len, AsyncCall::Pointer &callback);
extern void comm_read_cancel(int fd, IOCB *callback, void *data);
extern void comm_read_cancel(int fd, AsyncCall::Pointer &callback);
-extern int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, IpAddress &from);
+extern int comm_udp_recvfrom(int fd, void *buf, size_t len, int flags, Ip::Address &from);
extern int comm_udp_recv(int fd, void *buf, size_t len, int flags);
extern ssize_t comm_udp_send(int s, const void *buf, size_t len, int flags);
extern bool comm_has_incomplete_write(int);
virtual char const *label() const = 0;
- virtual unsigned int makeKey(IpAddress &src_addr) const = 0;
+ virtual unsigned int makeKey(Ip::Address &src_addr) const = 0;
DelaySpec spec;
protected:
virtual char const *label() const {return "Individual";}
- virtual unsigned int makeKey(IpAddress &src_addr) const;
+ virtual unsigned int makeKey(Ip::Address &src_addr) const;
};
/// \ingroup DelayPoolsInternal
protected:
virtual char const *label() const {return "Network";}
- virtual unsigned int makeKey (IpAddress &src_addr) const;
+ virtual unsigned int makeKey (Ip::Address &src_addr) const;
};
/* don't use remote storage for these */
virtual char const *label() const {return "Individual";}
- virtual unsigned int makeKey (IpAddress &src_addr) const;
+ virtual unsigned int makeKey(Ip::Address &src_addr) const;
- unsigned char makeHostKey (IpAddress &src_addr) const;
+ unsigned char makeHostKey(Ip::Address &src_addr) const;
DelaySpec spec;
VectorMap<unsigned char, ClassCBucket> buckets;
}
unsigned int
-IndividualPool::makeKey (IpAddress &src_addr) const
+IndividualPool::makeKey(Ip::Address &src_addr) const
{
/* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
}
unsigned int
-ClassCNetPool::makeKey (IpAddress &src_addr) const
+ClassCNetPool::makeKey(Ip::Address &src_addr) const
{
/* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
}
unsigned char
-ClassCHostPool::makeHostKey (IpAddress &src_addr) const
+ClassCHostPool::makeHostKey(Ip::Address &src_addr) const
{
/* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
}
unsigned int
-ClassCHostPool::makeKey (IpAddress &src_addr) const
+ClassCHostPool::makeKey(Ip::Address &src_addr) const
{
/* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
};
struct _ns {
- IpAddress S;
+ Ip::Address S;
int nqueries;
int nreplies;
nsvc *vc;
static IOCB idnsReadVCHeader;
static void idnsDoSendQueryVC(nsvc *vc);
-static int idnsFromKnownNameserver(IpAddress const &from);
+static int idnsFromKnownNameserver(Ip::Address const &from);
static idns_query *idnsFindQuery(unsigned short id);
static void idnsGrokReply(const char *buf, size_t sz);
static PF idnsRead;
static void
idnsAddNameserver(const char *buf)
{
- IpAddress A;
+ Ip::Address A;
if (!(A = buf)) {
debugs(78, 0, "WARNING: rejecting '" << buf << "' as a name server, because it is not a numeric IP address");
nameservers[ns].vc = vc;
vc->ns = ns;
- IpAddress addr;
+ Ip::Address addr;
if (!Config.Addrs.udp_outgoing.IsNoAddr())
addr = Config.Addrs.udp_outgoing;
}
static int
-idnsFromKnownNameserver(IpAddress const &from)
+idnsFromKnownNameserver(Ip::Address const &from)
{
int i;
int max = INCOMING_DNS_MAX;
static char rbuf[SQUID_UDP_SO_RCVBUF];
int ns;
- IpAddress from;
+ Ip::Address from;
debugs(78, 3, "idnsRead: starting with FD " << fd);
* The cause of this is still unknown, however copying the data appears
* to allow it to be passed further without this erasure.
*/
- IpAddress bugbypass;
+ Ip::Address bugbypass;
while (max--) {
len = comm_udp_recvfrom(fd, rbuf, SQUID_UDP_SO_RCVBUF, 0, bugbypass);
if (DnsSocketA < 0 && DnsSocketB < 0) {
int port;
- IpAddress addr; // since we don't want to alter Config.Addrs.udp_* and dont have one of our own.
+ Ip::Address addr; // since we don't want to alter Config.Addrs.udp_* and dont have one of our own.
if (!Config.Addrs.udp_outgoing.IsNoAddr())
addr = Config.Addrs.udp_outgoing;
addr = Config.Addrs.udp_incoming;
#if IPV6_SPECIAL_SPLITSTACK
- IpAddress addr4 = addr;
+ Ip::Address addr4 = addr;
if ( addr.IsAnyAddr() || addr.IsIPv6() ) {
debugs(78, 2, "idnsInit: attempt open DNS socket to: " << addr);
}
void
-idnsPTRLookup(const IpAddress &addr, IDNSCB * callback, void *data)
+idnsPTRLookup(const Ip::Address &addr, IDNSCB * callback, void *data)
{
idns_query *q;
int ttl = 0;
int retry = 0;
unsigned int i = 0;
- IpAddress ipa;
+ Ip::Address ipa;
char ntoabuf[MAX_IPSTRLEN];
struct addrinfo hints;
struct addrinfo *AI = NULL;
int ns6count = 0;
#endif
#if HAVE_RES_INIT
- IpAddress ipa;
+ Ip::Address ipa;
#ifdef _SQUID_RES_NSADDR_LIST
extern char *optarg;
#endif
String dnsError; ///< DNS lookup error message
time_t ttl;
- IpAddress src_addr;
+ Ip::Address src_addr;
char *redirect_url;
ERCB *callback;
void *callback_data;
/* don't touch incoming, it's a pointer into buffered anyway */
}
-extern ErrorState *clientBuildError (err_type, http_status, char const *, IpAddress &, HttpRequest *);
+extern ErrorState *clientBuildError (err_type, http_status, char const *, Ip::Address &, HttpRequest *);
/* This can ONLY be used before we have sent *any* data to the client */
struct arpreq {
- IpAddress arp_pa; /* protocol address */
+ Ip::Address arp_pa; /* protocol address */
struct sockaddr arp_ha; /* hardware address */
int arp_flags; /* flags */
// return binary representation of the EUI
bool
-Eui::Eui48::lookup(IpAddress &c)
+Eui::Eui48::lookup(Ip::Address &c)
{
struct arpreq arpReq;
#if !defined(_SQUID_WIN32_)
struct sockaddr_in *sa = NULL;
#endif /* !_SQUID_WIN32_ */
- IpAddress ipAddr = c;
+ Ip::Address ipAddr = c;
ipAddr.SetPort(0);
#if defined(_SQUID_LINUX_)
/* EUI-48 is 6 bytes. */
#define SZ_EUI48_BUF 6
-class IpAddress;
+namespace Ip {
+ class Address;
+};
#if HAVE_CSTRING
#include <cstring>
bool encode(char *buf, const int len);
// lookup an EUI-48 / MAC address via ARP
- bool lookup(IpAddress &c);
+ bool lookup(Ip::Address &c);
private:
unsigned char eui[SZ_EUI48_BUF];
// return binary representation of the EUI
bool
-Eui::Eui64::lookup(IpAddress &c)
+Eui::Eui64::lookup(Ip::Address &c)
{
/* try to short-circuit slow OS lookups by using SLAAC data */
if (lookupSlaac(c)) return true;
}
bool
-Eui::Eui64::lookupSlaac(IpAddress &c)
+Eui::Eui64::lookupSlaac(Ip::Address &c)
{
#if USE_IPV6
/* RFC 4291 Link-Local unicast addresses which contain SLAAC - usually trustable. */
// return binary representation of the EUI
bool
-Eui::Eui64::lookupNdp(IpAddress &c)
+Eui::Eui64::lookupNdp(Ip::Address &c)
{
#if USE_IPV6
#if USE_SQUID_EUI
-class IpAddress;
+namespace Ip {
+ class Address;
+};
#if HAVE_CSTRING
#include <cstring>
bool encode(char *buf, const int len);
// lookup an EUI-64 address via IPv6 SLAAC or NDP
- bool lookup(IpAddress &c);
+ bool lookup(Ip::Address &c);
// lookup an EUI-64 address via IPv6 NDP
- bool lookupNdp(IpAddress &c);
+ bool lookupNdp(Ip::Address &c);
// lookup an EUI-64 address via decoding the IPv6 address SLAAC data
- bool lookupSlaac(IpAddress &c);
+ bool lookupSlaac(Ip::Address &c);
private:
unsigned char eui[SZ_EUI64_BUF];
QUOTE_METHOD_URL
} quote;
- IpAddress local_addr;
+ Ip::Address local_addr;
};
struct _external_acl_format {
unsigned int type;
u_short remote_port;
- IpAddress local_addr;
+ Ip::Address local_addr;
unsigned char tos;
int sock_family;
char ipaddr[MAX_IPSTRLEN]; /* dotted decimal address of peer */
halfClosedReader = NULL;
// XXX: the following memset may corrupt or leak new or changed members
memset(this, 0, sizeof(fde));
- local_addr.SetEmpty(); // IpAddress likes to be setup nicely.
+ local_addr.SetEmpty(); // Ip::Address likes to be setup nicely.
}
};
int ctimeout;
int ftimeout = Config.Timeout.forward - (squid_curtime - start_t);
- IpAddress outgoing;
+ Ip::Address outgoing;
unsigned short tos;
- IpAddress client_addr;
+ Ip::Address client_addr;
assert(fs);
assert(server_fd == -1);
debugs(17, 3, "fwdConnectStart: " << url);
if (!fs->_peer && request->flags.spoof_client_ip) {
// try to set the outgoing address using TPROXY v2
// if it fails we abort any further TPROXY actions on this connection
- if (IpInterceptor.SetTproxy2OutgoingAddr(fd, src) == -1) {
+ if (Ip::Interceptor.SetTproxy2OutgoingAddr(fd, src) == -1) {
request->flags.spoof_client_ip = 0;
}
}
* - address of the client for which we made the connection
*/
void
-FwdState::pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IpAddress &client_addr)
+FwdState::pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr)
{
if (_peer) {
fwdPconnPool->push(fd, _peer->name, _peer->http_port, domain, client_addr);
memFree(fs, MEM_FWD_SERVER);
}
-static IpAddress
+static Ip::Address
aclMapAddr(acl_address * head, ACLChecklist * ch)
{
acl_address *l;
- IpAddress addr;
+ Ip::Address addr;
for (l = head; l; l = l->next) {
if (!l->aclList || ch->matchAclListFast(l->aclList))
return 0;
}
-IpAddress
+Ip::Address
getOutgoingAddr(HttpRequest * request, struct peer *dst_peer)
{
if (request && request->flags.spoof_client_ip) {
}
if (!Config.accessList.outgoing_address) {
- return IpAddress(); // anything will do.
+ return Ip::Address(); // anything will do.
}
ACLFilledChecklist ch(NULL, request, NULL);
bool checkRetry();
bool checkRetriable();
void dispatch();
- void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IpAddress &client_addr);
+ void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr);
bool dontRetry() { return flags.dont_retry; }
unsigned int forward_completed:1;
} flags;
- IpAddress src; /* Client address for this connection. Needed for transparent operations. */
+ Ip::Address src; /* Client address for this connection. Needed for transparent operations. */
// NP: keep this last. It plays with private/public
CBDATA_CLASS2(FwdState);
* and does not affect the FQDN cache.
*/
void
-fqdncache_nbgethostbyaddr(IpAddress &addr, FQDNH * handler, void *handlerData)
+fqdncache_nbgethostbyaddr(const Ip::Address &addr, FQDNH * handler, void *handlerData)
{
fqdncache_entry *f = NULL;
char name[MAX_IPSTRLEN];
*
*/
const char *
-fqdncache_gethostbyaddr(IpAddress &addr, int flags)
+fqdncache_gethostbyaddr(const Ip::Address &addr, int flags)
{
char name[MAX_IPSTRLEN];
fqdncache_entry *f = NULL;
/// \ingroup FQDNCacheAPI
const char *
-fqdnFromAddr(IpAddress &addr)
+fqdnFromAddr(const Ip::Address &addr)
{
const char *n;
static char buf[MAX_IPSTRLEN];
char h1, h2, h3, h4;
int n;
u_short port;
- IpAddress ipa_remote;
+ Ip::Address ipa_remote;
int fd = ftpState->data.fd;
char *buf;
debugs(9, 3, HERE);
static void
ftpSendPassive(FtpStateData * ftpState)
{
- IpAddress addr;
+ Ip::Address addr;
struct addrinfo *AI = NULL;
/** Checks the server control channel is still available before running. */
int p1, p2;
int n;
u_short port;
- IpAddress ipa_remote;
+ Ip::Address ipa_remote;
int fd = ftpState->data.fd;
char *buf;
LOCAL_ARRAY(char, ipaddr, 1024);
ftpOpenListenSocket(FtpStateData * ftpState, int fallback)
{
int fd;
-
- IpAddress addr;
+ Ip::Address addr;
struct addrinfo *AI = NULL;
int on = 1;
int x = 0;
ftpSendPORT(FtpStateData * ftpState)
{
int fd;
-
- IpAddress ipa;
+ Ip::Address ipa;
struct addrinfo *AI = NULL;
unsigned char *addrptr;
unsigned char *portptr;
ftpSendEPRT(FtpStateData * ftpState)
{
int fd;
- IpAddress addr;
+ Ip::Address addr;
struct addrinfo *AI = NULL;
char buf[MAX_IPSTRLEN];
ftpState->flags.pasv_supported = 0;
fd = ftpOpenListenSocket(ftpState, 0);
- addr.InitAddrInfo(AI);
+ Ip::Address::InitAddrInfo(AI);
if (getsockname(fd, AI->ai_addr, &AI->ai_addrlen)) {
- addr.FreeAddrInfo(AI);
+ Ip::Address::FreeAddrInfo(AI);
debugs(9, DBG_CRITICAL, HERE << "getsockname(" << fd << ",..): " << xstrerror());
/* XXX Need to set error message */
ftpState->writeCommand(cbuf);
ftpState->state = SENT_EPRT;
- addr.FreeAddrInfo(AI);
+ Ip::Address::FreeAddrInfo(AI);
}
static void
extern struct acl_deny_info_list *DenyInfoList; /* NULL */
-//MOVED:icp_v2.cc extern IpAddress theOutICPAddr;
-//MOVED:snmp_core.cc extern IpAddress theOutSNMPAddr;
-
extern struct timeval squid_start;
extern int starting_up; /* 1 */
extern int shutting_down; /* 0 */
const char *id_name;
HelperChildConfig childs; ///< Configuration settings for number running.
int ipc_type;
- IpAddress addr;
+ Ip::Address addr;
time_t last_queue_warn;
time_t last_restart;
public:
int index;
int pid;
- IpAddress addr;
+ Ip::Address addr;
int rfd;
int wfd;
void *hIpc;
void checkHit();
void checkedHit(StoreEntry *e);
- void setFrom (IpAddress &from);
- void setDataHeader (htcpDataHeader *);
+ void setFrom(Ip::Address &from);
+ void setDataHeader(htcpDataHeader *);
char *method;
char *uri;
char *version;
private:
HttpRequest *checkHitRequest;
- IpAddress from; // was a ptr. return to such IFF needed. otherwise copy should do.
+ Ip::Address from; // was a ptr. return to such IFF needed. otherwise copy should do.
htcpDataHeader *dhdr;
};
static u_int32_t queried_id[N_QUERIED_KEYS];
static cache_key queried_keys[N_QUERIED_KEYS][SQUID_MD5_DIGEST_LENGTH];
-static IpAddress queried_addr[N_QUERIED_KEYS];
+static Ip::Address queried_addr[N_QUERIED_KEYS];
static MemAllocator *htcpDetailPool = NULL;
static int old_squid_format = 0;
static void htcpFreeSpecifier(htcpSpecifier * s);
static void htcpFreeDetail(htcpDetail * s);
-static void htcpHandleMsg(char *buf, int sz, IpAddress &from);
+static void htcpHandleMsg(char *buf, int sz, Ip::Address &from);
-static void htcpLogHtcp(IpAddress &, int, log_type, const char *);
-static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+static void htcpLogHtcp(Ip::Address &, int, log_type, const char *);
+static void htcpHandleMon(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
-static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+static void htcpHandleNop(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
-static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+static void htcpHandleSet(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
-static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+static void htcpHandleTst(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
static void htcpRecv(int fd, void *data);
-static void htcpSend(const char *buf, int len, IpAddress &to);
+static void htcpSend(const char *buf, int len, Ip::Address &to);
-static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, IpAddress &);
+static void htcpTstReply(htcpDataHeader *, StoreEntry *, htcpSpecifier *, Ip::Address &);
-static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, IpAddress &from);
+static void htcpHandleTstRequest(htcpDataHeader *, char *buf, int sz, Ip::Address &from);
-static void htcpHandleTstResponse(htcpDataHeader *, char *, int, IpAddress &);
+static void htcpHandleTstResponse(htcpDataHeader *, char *, int, Ip::Address &);
static void
htcpHexdump(const char *tag, const char *s, int sz)
static void
-htcpSend(const char *buf, int len, IpAddress &to)
+htcpSend(const char *buf, int len, Ip::Address &to)
{
int x;
void
-htcpSpecifier::setFrom (IpAddress &aSocket)
+htcpSpecifier::setFrom(Ip::Address &aSocket)
{
from = aSocket;
}
void
-htcpSpecifier::setDataHeader (htcpDataHeader *aDataHeader)
+htcpSpecifier::setDataHeader(htcpDataHeader *aDataHeader)
{
dhdr = aDataHeader;
}
}
static int
-htcpAccessCheck(acl_access * acl, htcpSpecifier * s, IpAddress &from)
+htcpAccessCheck(acl_access * acl, htcpSpecifier * s, Ip::Address &from)
{
/* default deny if no access list present */
if (!acl)
}
static void
-htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, IpAddress &from)
+htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, Ip::Address &from)
{
htcpStuff stuff;
static char pkt[8192];
static void
-htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, IpAddress &from)
+htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, Ip::Address &from)
{
htcpStuff stuff;
static char pkt[8192];
static void
-htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
debugs(31, 3, "htcpHandleNop: Unimplemented");
}
static void
-htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
debugs(31, 3, "htcpHandleTst: sz = " << sz);
static void
-htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
htcpReplyData htcpReply;
cache_key *key = NULL;
- IpAddress *peer;
+ Ip::Address *peer;
htcpDetail *d = NULL;
char *t;
static void
-htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, IpAddress &from)
+htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, Ip::Address &from)
{
/* buf should be a SPECIFIER */
htcpSpecifier *s;
static void
-htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
debugs(31, 3, "htcpHandleMon: Unimplemented");
}
static void
-htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
debugs(31, 3, "htcpHandleSet: Unimplemented");
}
static void
-htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, IpAddress &from)
+htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, Ip::Address &from)
{
htcpSpecifier *s;
/* buf[0/1] is reserved and reason */
* hands it off to other functions to break apart message-specific data.
*/
static void
-htcpHandleMsg(char *buf, int sz, IpAddress &from)
+htcpHandleMsg(char *buf, int sz, Ip::Address &from)
{
htcpHeader htcpHdr;
htcpDataHeader hdr;
{
static char buf[8192];
int len;
- static IpAddress from;
+ static Ip::Address from;
/* Receive up to 8191 bytes, leaving room for a null */
return;
}
- IpAddress incomingAddr = Config.Addrs.udp_incoming;
+ Ip::Address incomingAddr = Config.Addrs.udp_incoming;
incomingAddr.SetPort(Config.Port.htcp);
enter_suid();
debugs(31, 1, "Accepting HTCP messages on port " << Config.Port.htcp << ", FD " << htcpInSocket << ".");
if (!Config.Addrs.udp_outgoing.IsNoAddr()) {
- IpAddress outgoingAddr = Config.Addrs.udp_outgoing;
+ Ip::Address outgoingAddr = Config.Addrs.udp_outgoing;
outgoingAddr.SetPort(Config.Port.htcp);
enter_suid();
}
static void
-htcpLogHtcp(IpAddress &caddr, int opcode, log_type logcode, const char *url)
+htcpLogHtcp(Ip::Address &caddr, int opcode, log_type logcode, const char *url)
{
AccessLogEntry al;
if (LOG_TAG_NONE == logcode)
#include "HttpHeader.h"
-class IpAddress;
+class Ip::Address;
/// \ingroup ServerProtocolHTCP
class HtcpReplyData
typedef class HtcpReplyData htcpReplyData;
/// \ingroup ServerProtocolHTCP
-SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const IpAddress &);
+SQUIDCEXTERN void neighborsHtcpReply(const cache_key *, htcpReplyData *, const Ip::Address &);
/// \ingroup ServerProtocolHTCP
SQUIDCEXTERN void htcpInit(void);
HttpStateData::processReplyBody()
{
AsyncCall::Pointer call;
- IpAddress client_addr;
+ Ip::Address client_addr;
bool ispinned = false;
if (!flags.headers_parsed) {
}
void
-Icmp::Log(const IpAddress &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops)
+Icmp::Log(const Ip::Address &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops)
{
debugs(42, 2, "pingerLog: " << std::setw(9) << current_time.tv_sec <<
"." << std::setfill('0') << std::setw(6) <<
/* This is a line-data format struct. DO NOT alter. */
struct pingerEchoData {
- IpAddress to;
+ Ip::Address to;
unsigned char opcode;
int psize;
char payload[PINGER_PAYLOAD_SZ];
/* This is a line-data format struct. DO NOT alter. */
struct pingerReplyData {
- IpAddress from;
+ Ip::Address from;
unsigned char opcode;
int rtt;
int hops;
* Content longer than MAX_PAYLOAD will be truncated.
\param len Length of the payload in bytes if any is to be sent or 0.
*/
- virtual void SendEcho(IpAddress &to, int opcode, const char *payload=NULL, int len=0) =0;
+ virtual void SendEcho(Ip::Address &to, int opcode, const char *payload=NULL, int len=0) =0;
/// Handle ICMP responses.
virtual void Recv(void) =0;
int ipHops(int ttl);
/// Log the packet.
- void Log(const IpAddress &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops);
+ void Log(const Ip::Address &addr, const u_int8_t type, const char* pkt_str, const int rtt, const int hops);
/* no use wasting memory */
int icmp_sock;
}
void
-Icmp4::SendEcho(IpAddress &to, int opcode, const char *payload, int len)
+Icmp4::SendEcho(Ip::Address &to, int opcode, const char *payload, int len)
{
int x;
LOCAL_ARRAY(char, pkt, MAX_PKT4_SZ);
virtual int Open();
#if USE_ICMP
- virtual void SendEcho(IpAddress &, int, const char*, int);
+ virtual void SendEcho(Ip::Address &, int, const char*, int);
virtual void Recv(void);
#endif
};
* Generates an RFC 4443 Icmp6 ECHO Packet and sends into the network.
*/
void
-Icmp6::SendEcho(IpAddress &to, int opcode, const char *payload, int len)
+Icmp6::SendEcho(Ip::Address &to, int opcode, const char *payload, int len)
{
int x;
LOCAL_ARRAY(char, pkt, MAX_PKT6_SZ);
virtual int Open();
#if USE_ICMP
- virtual void SendEcho(IpAddress &, int, const char*, int);
+ virtual void SendEcho(Ip::Address &, int, const char*, int);
virtual void Recv(void);
#endif
};
private:
// unused in IcmpPinger
- virtual void SendEcho(IpAddress &to, int opcode, const char *payload, int len) {};
+ virtual void SendEcho(Ip::Address &to, int opcode, const char *payload, int len) {};
/**
* Control channel(s) to squid.
#if USE_ICMP
void
-IcmpSquid::SendEcho(IpAddress &to, int opcode, const char *payload, int len)
+IcmpSquid::SendEcho(Ip::Address &to, int opcode, const char *payload, int len)
{
static pingerEchoData pecho;
int x, slen;
int n;
static int fail_count = 0;
pingerReplyData preply;
- static IpAddress F;
+ static Ip::Address F;
commSetSelect(icmp_sock, COMM_SELECT_READ, icmpSquidRecv, NULL, 0);
memset(&preply, '\0', sizeof(pingerReplyData));
#endif /* USE_ICMP */
void
-IcmpSquid::DomainPing(IpAddress &to, const char *domain)
+IcmpSquid::DomainPing(Ip::Address &to, const char *domain)
{
#if USE_ICMP
debugs(37, 4, HERE << "'" << domain << "' (" << to << ")");
const char *args[2];
int rfd;
int wfd;
- IpAddress localhost;
+ Ip::Address localhost;
/* User configured disabled. */
if (!Config.pinger.enable) {
virtual int Open();
virtual void Close();
- void DomainPing(IpAddress &to, const char *domain);
+ void DomainPing(Ip::Address &to, const char *domain);
#if USE_ICMP
- virtual void SendEcho(IpAddress &to, int opcode, const char* payload=NULL, int len=0);
+ virtual void SendEcho(Ip::Address &to, int opcode, const char* payload=NULL, int len=0);
virtual void Recv(void);
#endif
};
static hash_table *addr_table = NULL;
static hash_table *host_table = NULL;
-IpAddress networkFromInaddr(const IpAddress &a);
+Ip::Address networkFromInaddr(const Ip::Address &a);
static void netdbRelease(netdbEntry * n);
-static void netdbHashInsert(netdbEntry * n, IpAddress &addr);
+static void netdbHashInsert(netdbEntry * n, Ip::Address &addr);
static void netdbHashDelete(const char *key);
static void netdbHostInsert(netdbEntry * n, const char *hostname);
static void netdbHostDelete(const net_db_name * x);
static wordlist *peer_names = NULL;
static void
-netdbHashInsert(netdbEntry * n, IpAddress &addr)
+netdbHashInsert(netdbEntry * n, Ip::Address &addr)
{
networkFromInaddr(addr).NtoA(n->network, MAX_IPSTRLEN);
n->hash.key = n->network;
}
static netdbEntry *
-netdbLookupAddr(const IpAddress &addr)
+netdbLookupAddr(const Ip::Address &addr)
{
netdbEntry *n;
char *key = new char[MAX_IPSTRLEN];
}
static netdbEntry *
-netdbAdd(IpAddress &addr)
+netdbAdd(Ip::Address &addr)
{
netdbEntry *n;
static void
netdbSendPing(const ipcache_addrs *ia, const DnsLookupDetails &, void *data)
{
- IpAddress addr;
+ Ip::Address addr;
char *hostname = NULL;
static_cast<generic_cbdata *>(data)->unwrap(&hostname);
netdbEntry *n;
xfree(hostname);
}
-IpAddress
-networkFromInaddr(const IpAddress &in)
+Ip::Address
+networkFromInaddr(const Ip::Address &in)
{
- IpAddress out;
+ Ip::Address out;
out = in;
#if USE_IPV6
netdbEntry *n;
netdbEntry N;
- IpAddress addr;
+ Ip::Address addr;
int count = 0;
struct timeval start = current_time;
static void
netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData)
{
- IpAddress addr;
+ Ip::Address addr;
netdbExchangeState *ex = (netdbExchangeState *)data;
int rec_sz = 0;
}
void
-netdbHandlePingReply(const IpAddress &from, int hops, int rtt)
+netdbHandlePingReply(const Ip::Address &from, int hops, int rtt)
{
#if USE_ICMP
netdbEntry *n;
#if 0 // AYJ: Looks to be unused code.
int
-netdbHops(IpAddress &addr)
+netdbHops(Ip::Address &addr)
{
#if USE_ICMP
netdbEntry *n = netdbLookupAddr(addr);
}
void
-netdbExchangeUpdatePeer(IpAddress &addr, peer * e, double rtt, double hops)
+netdbExchangeUpdatePeer(Ip::Address &addr, peer * e, double rtt, double hops)
{
#if USE_ICMP
netdbEntry *n;
}
void
-netdbDeleteAddrNetwork(IpAddress &addr)
+netdbDeleteAddrNetwork(Ip::Address &addr)
{
#if USE_ICMP
netdbEntry *n = netdbLookupAddr(addr);
HttpReply *reply = new HttpReply;
#if USE_ICMP
- IpAddress addr;
+ Ip::Address addr;
netdbEntry *n;
int i;
#include "config.h"
-class IpAddress;
+namespace Ip {
+ class Address;
+};
+
class StoreEntry;
class HttpRequest;
SQUIDCEXTERN void netdbInit(void);
-SQUIDCEXTERN void netdbHandlePingReply(const IpAddress &from, int hops, int rtt);
+SQUIDCEXTERN void netdbHandlePingReply(const Ip::Address &from, int hops, int rtt);
SQUIDCEXTERN void netdbPingSite(const char *hostname);
SQUIDCEXTERN void netdbDump(StoreEntry *);
-#if 0 // AYJ: Looks to be unused now.
-SQUIDCEXTERN int netdbHops(IpAddress &);
-#endif
-
SQUIDCEXTERN void netdbFreeMemory(void);
SQUIDCEXTERN int netdbHostHops(const char *host);
SQUIDCEXTERN int netdbHostRtt(const char *host);
SQUIDCEXTERN void netdbUpdatePeer(HttpRequest *, peer * e, int rtt, int hops);
-SQUIDCEXTERN void netdbDeleteAddrNetwork(IpAddress &addr);
+SQUIDCEXTERN void netdbDeleteAddrNetwork(Ip::Address &addr);
SQUIDCEXTERN void netdbBinaryExchange(StoreEntry *);
SQUIDCEXTERN void netdbExchangeStart(void *);
-SQUIDCEXTERN void netdbExchangeUpdatePeer(IpAddress &, peer *, double, double);
+SQUIDCEXTERN void netdbExchangeUpdatePeer(Ip::Address &, peer *, double, double);
SQUIDCEXTERN peer *netdbClosestParent(HttpRequest *);
SQUIDCEXTERN void netdbHostData(const char *host, int *samp, int *rtt, int *hops);
#ifndef SQUID_SRC_TEST_URL_H
#define SQUID_SRC_TEST_URL_H
+#define SQUID_UNIT_TEST 1
+
#include "Icmp.h"
#include <cppunit/extensions/HelperMacros.h>
virtual void Close() {};
/// Construct ECHO request
- virtual void SendEcho(IpAddress &to, int opcode, const char *payload, int len) {};
+ virtual void SendEcho(Ip::Address &to, int opcode, const char *payload, int len) {};
/// Handle ICMP responses.
virtual void Recv(void) {};
#include "rfc1738.h"
/// \ingroup ServerProtocolICPInternal2
-static void icpLogIcp(const IpAddress &, log_type, int, const char *, int);
+static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int);
/// \ingroup ServerProtocolICPInternal2
-static void icpHandleIcpV2(int, IpAddress &, char *, int);
+static void icpHandleIcpV2(int, Ip::Address &, char *, int);
/// \ingroup ServerProtocolICPInternal2
static void icpCount(void *, int, size_t, int);
static icpUdpData *IcpQueueTail = NULL;
/// \ingroup ServerProtocolICPInternal2
-IpAddress theOutICPAddr;
+Ip::Address theOutICPAddr;
/* icp_common_t */
_icp_common_t::_icp_common_t() : opcode(ICP_INVALID), version(0), length(0), reqnum(0), flags(0), pad(0), shostid(0)
/// \ingroup ServerProtocolICPInternal2
static void
-icpLogIcp(const IpAddress &caddr, log_type logcode, int len, const char *url, int delay)
+icpLogIcp(const Ip::Address &caddr, log_type logcode, int len, const char *url, int delay)
{
AccessLogEntry al;
int
icpUdpSend(int fd,
- const IpAddress &to,
+ const Ip::Address &to,
icp_common_t * msg,
log_type logcode,
int delay)
}
void
-icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const IpAddress &from)
+icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from)
{
icp_common_t *reply = _icp_common_t::createMessage(opcode, flags, url, reqnum, pad);
icpUdpSend(fd, from, reply, icpLogFromICPCode(opcode), 0);
}
void
-icpDenyAccess(IpAddress &from, char *url, int reqnum, int fd)
+icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd)
{
debugs(12, 2, "icpDenyAccess: Access Denied for " << from << " by " << AclMatchedName << ".");
}
int
-icpAccessAllowed(IpAddress &from, HttpRequest * icp_request)
+icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request)
{
/* absent an explicit allow, we deny all */
if (!Config.accessList.icp)
}
HttpRequest *
-icpGetRequest(char *url, int reqnum, int fd, IpAddress &from)
+icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from)
{
if (strpbrk(url, w_space)) {
url = rfc1738_escape(url);
}
static void
-doV2Query(int fd, IpAddress &from, char *buf, icp_common_t header)
+doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
{
int rtt = 0;
int src_rtt = 0;
}
void
-_icp_common_t::handleReply(char *buf, IpAddress &from)
+_icp_common_t::handleReply(char *buf, Ip::Address &from)
{
if (neighbors_do_private_keys && reqnum == 0) {
debugs(12, 0, "icpHandleIcpV2: Neighbor " << from << " returned reqnum = 0");
}
static void
-icpHandleIcpV2(int fd, IpAddress &from, char *buf, int len)
+icpHandleIcpV2(int fd, Ip::Address &from, char *buf, int len)
{
if (len <= 0) {
debugs(12, 3, "icpHandleIcpV2: ICP message is too small");
static void
icpPktDump(icp_common_t * pkt)
{
-
- IpAddress a;
+ Ip::Address a;
debugs(12, 9, "opcode: " << std::setw(3) << pkt->opcode << " " << icp_opcode_str[pkt->opcode]);
debugs(12, 9, "version: "<< std::left << std::setw(8) << pkt->version);
{
int *N = &incoming_sockets_accepted;
- IpAddress from;
+ Ip::Address from;
LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF);
int len;
int icp_version;
icpConnectionsOpen(void)
{
u_int16_t port;
-
- IpAddress addr;
+ Ip::Address addr;
struct addrinfo *xai = NULL;
int x;
/// \ingroup ServerProtocolICPInternal3
static void
-doV3Query(int fd, IpAddress &from, char *buf, icp_common_t header)
+doV3Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
{
/* We have a valid packet */
char *url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
/// \ingroup ServerProtocolICPInternal3
/* Currently Harvest cached-2.x uses ICP_VERSION_3 */
void
-icpHandleIcpV3(int fd, IpAddress&from, char *buf, int len)
+icpHandleIcpV3(int fd, Ip::Address &from, char *buf, int len)
{
if (len <= 0) {
debugs(12, 3, "icpHandleIcpV3: ICP message is too small");
hash_link hash; /* must be first */
int fd; /* IDENT fd */
- IpAddress me;
-
- IpAddress my_peer;
+ Ip::Address me;
+ Ip::Address my_peer;
IdentClient *clients;
char buf[4096];
} IdentStateData;
* start a TCP connection to the peer host on port 113
*/
void
-Ident::Start(IpAddress &me, IpAddress &my_peer, IDCB * callback, void *data)
+Ident::Start(Ip::Address &me, Ip::Address &my_peer, IDCB * callback, void *data)
{
IdentStateData *state;
int fd;
return;
}
- IpAddress addr = me;
+ Ip::Address addr = me;
addr.SetPort(0); // NP: use random port for secure outbound to IDENT_PORT
fd = comm_open_listener(SOCK_STREAM,
#include "cbdata.h"
-class IpAddress;
+class Ip::Address;
namespace Ident
{
* Self-registers with a global ident lookup manager,
* will call Ident::Init() itself if the manager has not been initialized already.
*/
-void Start(IpAddress &me, IpAddress &my_peer, IDCB * callback, void *cbdata);
+void Start(Ip::Address &me, Ip::Address &my_peer, IDCB * callback, void *cbdata);
/**
\ingroup IdentAPI
#if USE_IPV6
/* check for an IP address and format appropriately if found */
- IpAddress test = lc_host;
+ Ip::Address test = lc_host;
if ( !test.IsAnyAddr() ) {
test.ToHostname(lc_host,SQUIDHOSTNAMELEN);
}
* developed and/or copyrighted by other sources. Please see the
* CREDITS file for full details.
*
- * This IpAddress code is copyright (C) 2007 by Treehouse Networks Ltd
+ * This Ip::Address code is copyright (C) 2007 by Treehouse Networks Ltd
* of New Zealand. It is published and Lisenced as an extension of
* squid under the same conditions as the main squid application.
*
#if USE_IPV6
#define IASSERT(a,b) \
if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
- printf("IpAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
+ printf("Ip::Address invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
printf("ADDRESS:"); \
for(unsigned int i = 0; i < sizeof(m_SocketAddr.sin6_addr); i++) { \
printf(" %x", m_SocketAddr.sin6_addr.s6_addr[i]); \
#else
#define IASSERT(a,b) \
if(!(b)){ printf("assert \"%s\" at line %d\n", a, __LINE__); \
- printf("IpAddress invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
+ printf("Ip::Address invalid? with IsIPv4()=%c, IsIPv6()=%c\n",(IsIPv4()?'T':'F'),(IsIPv6()?'T':'F')); \
printf("ADDRESS: %x\n", (unsigned int)m_SocketAddr.sin_addr.s_addr); \
assert(b); \
}
#endif
-IpAddress::IpAddress()
+Ip::Address::Address()
{
SetEmpty();
}
-IpAddress::~IpAddress()
+Ip::Address::~Address()
{
- memset(this,0,sizeof(IpAddress));
+ memset(this,0,sizeof(Ip::Address));
}
int
-IpAddress::GetCIDR() const
+Ip::Address::GetCIDR() const
{
uint8_t shift,byte;
uint8_t bit,caught;
return len;
}
-const int IpAddress::ApplyMask(IpAddress const &mask_addr)
+const int
+Ip::Address::ApplyMask(Ip::Address 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);
return changes;
}
-bool IpAddress::ApplyMask(const unsigned int cidr, int mtype)
+bool
+Ip::Address::ApplyMask(const unsigned int cidr, int mtype)
{
uint8_t clearbits = 0;
uint8_t* p = NULL;
return true;
}
-bool IpAddress::IsSockAddr() const
+bool
+Ip::Address::IsSockAddr() const
{
return (m_SocketAddr.sin6_port != 0);
}
-bool IpAddress::IsIPv4() const
+bool
+Ip::Address::IsIPv4() const
{
#if USE_IPV6
return IsAnyAddr() || IsNoAddr() || IN6_IS_ADDR_V4MAPPED( &m_SocketAddr.sin6_addr );
#endif
}
-bool IpAddress::IsIPv6() const
+bool
+Ip::Address::IsIPv6() const
{
#if USE_IPV6
return IsAnyAddr() || IsNoAddr() || !IN6_IS_ADDR_V4MAPPED( &m_SocketAddr.sin6_addr );
#endif
}
-bool IpAddress::IsAnyAddr() const
+bool
+Ip::Address::IsAnyAddr() const
{
#if USE_IPV6
return IN6_IS_ADDR_UNSPECIFIED( &m_SocketAddr.sin6_addr );
}
/// NOTE: Does NOT clear the Port stored. Ony the Address and Type.
-void IpAddress::SetAnyAddr()
+void
+Ip::Address::SetAnyAddr()
{
#if USE_IPV6
memset(&m_SocketAddr.sin6_addr, 0, sizeof(struct in6_addr) );
#endif
}
-/// NOTE: completely empties the IpAddress structure. Address, Port, Type, everything.
-void IpAddress::SetEmpty()
+/// NOTE: completely empties the Ip::Address structure. Address, Port, Type, everything.
+void
+Ip::Address::SetEmpty()
{
memset(&m_SocketAddr, 0, sizeof(m_SocketAddr) );
}
#if USE_IPV6
-const struct in6_addr IpAddress::v4_localhost = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+const struct in6_addr Ip::Address::v4_localhost = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01 }}
};
-const struct in6_addr IpAddress::v4_anyaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+const struct in6_addr Ip::Address::v4_anyaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}
};
-const struct in6_addr IpAddress::v6_noaddr = {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+const struct in6_addr Ip::Address::v6_noaddr = {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}
};
#endif
-bool IpAddress::SetIPv4()
+bool
+Ip::Address::SetIPv4()
{
#if USE_IPV6
if ( IsLocalhost() ) {
#endif
}
-bool IpAddress::IsLocalhost() const
+bool
+Ip::Address::IsLocalhost() const
{
#if USE_IPV6
return IN6_IS_ADDR_LOOPBACK( &m_SocketAddr.sin6_addr ) || IN6_ARE_ADDR_EQUAL( &m_SocketAddr.sin6_addr, &v4_localhost );
#endif
}
-void IpAddress::SetLocalhost()
+void
+Ip::Address::SetLocalhost()
{
#if USE_IPV6
m_SocketAddr.sin6_addr = in6addr_loopback;
#endif
}
-bool IpAddress::IsSiteLocal6() const
+bool
+Ip::Address::IsSiteLocal6() const
{
#if USE_IPV6
return IN6_IS_ADDR_SITELOCAL( &m_SocketAddr.sin6_addr );
#endif
}
-bool IpAddress::IsSlaac() const
+bool
+Ip::Address::IsSlaac() const
{
#if USE_IPV6
return m_SocketAddr.sin6_addr.s6_addr[10] == htons(0xff) &&
#endif
}
-bool IpAddress::IsNoAddr() const
+bool
+Ip::Address::IsNoAddr() const
{
// IFF the address == 0xff..ff (all ones)
#if USE_IPV6
#endif
}
-void IpAddress::SetNoAddr()
+void
+Ip::Address::SetNoAddr()
{
#if USE_IPV6
memset(&m_SocketAddr.sin6_addr, 0xFF, sizeof(struct in6_addr) );
}
#if USE_IPV6
-
-bool IpAddress::GetReverseString6(char buf[MAX_IPSTRLEN], const struct in6_addr &dat) const
+bool
+Ip::Address::GetReverseString6(char buf[MAX_IPSTRLEN], const struct in6_addr &dat) const
{
char *p = buf;
unsigned char const *r = dat.s6_addr;
return true;
}
-
#endif
-bool IpAddress::GetReverseString4(char buf[MAX_IPSTRLEN], const struct in_addr &dat) const
+bool
+Ip::Address::GetReverseString4(char buf[MAX_IPSTRLEN], const struct in_addr &dat) const
{
unsigned int i = (unsigned int) ntohl(dat.s_addr);
snprintf(buf, 32, "%u.%u.%u.%u.in-addr.arpa.",
return true;
}
-bool IpAddress::GetReverseString(char buf[MAX_IPSTRLEN], int show_type) const
+bool
+Ip::Address::GetReverseString(char buf[MAX_IPSTRLEN], int show_type) const
{
if (show_type == AF_UNSPEC) {
return false;
}
-IpAddress& IpAddress::operator =(const IpAddress &s)
+Ip::Address&
+Ip::Address::operator =(const Ip::Address &s)
{
- memcpy(this, &s, sizeof(IpAddress));
+ memcpy(this, &s, sizeof(Ip::Address));
return *this;
};
-IpAddress::IpAddress(const char*s)
+Ip::Address::Address(const char*s)
{
SetEmpty();
operator=(s);
}
-bool IpAddress::operator =(const char* s)
+bool
+Ip::Address::operator =(const char* s)
{
return LookupHostIP(s, true);
}
-bool IpAddress::GetHostByName(const char* s)
+bool
+Ip::Address::GetHostByName(const char* s)
{
return LookupHostIP(s, false);
}
-bool IpAddress::LookupHostIP(const char *s, bool nodns)
+bool
+Ip::Address::LookupHostIP(const char *s, bool nodns)
{
int err = 0;
return true;
}
-IpAddress::IpAddress(struct sockaddr_in const &s)
+Ip::Address::Address(struct sockaddr_in const &s)
{
SetEmpty();
operator=(s);
};
-IpAddress& IpAddress::operator =(struct sockaddr_in const &s)
+Ip::Address &
+Ip::Address::operator =(struct sockaddr_in const &s)
{
#if USE_IPV6
Map4to6((const in_addr)s.sin_addr, m_SocketAddr.sin6_addr);
return *this;
};
-IpAddress& IpAddress::operator =(const struct sockaddr_storage &s)
+Ip::Address &
+Ip::Address::operator =(const struct sockaddr_storage &s)
{
#if USE_IPV6
/* some AF_* magic to tell socket types apart and what we need to do */
return *this;
};
-void IpAddress::check4Mapped()
+void
+Ip::Address::check4Mapped()
{
// obsolete.
// TODO use this NOW to set the sin6_family properly on exporting. not on import.
}
#if USE_IPV6
-IpAddress::IpAddress(struct sockaddr_in6 const &s)
+Ip::Address::Address(struct sockaddr_in6 const &s)
{
SetEmpty();
operator=(s);
};
-IpAddress& IpAddress::operator =(struct sockaddr_in6 const &s)
+Ip::Address &
+Ip::Address::operator =(struct sockaddr_in6 const &s)
{
memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6));
check4Mapped();
return *this;
};
-
#endif
-IpAddress::IpAddress(struct in_addr const &s)
+Ip::Address::Address(struct in_addr const &s)
{
SetEmpty();
operator=(s);
};
-IpAddress& IpAddress::operator =(struct in_addr const &s)
+Ip::Address &
+Ip::Address::operator =(struct in_addr const &s)
{
#if USE_IPV6
Map4to6((const in_addr)s, m_SocketAddr.sin6_addr);
};
#if USE_IPV6
-
-IpAddress::IpAddress(struct in6_addr const &s)
+Ip::Address::Address(struct in6_addr const &s)
{
SetEmpty();
operator=(s);
};
-IpAddress& IpAddress::operator =(struct in6_addr const &s)
+Ip::Address &
+Ip::Address::operator =(struct in6_addr const &s)
{
memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr));
return *this;
};
-
#endif
-IpAddress::IpAddress(const IpAddress &s)
+Ip::Address::Address(const Ip::Address &s)
{
SetEmpty();
operator=(s);
}
-IpAddress::IpAddress(IpAddress *s)
+Ip::Address::Address(Ip::Address *s)
{
SetEmpty();
if (s)
- memcpy(this, s, sizeof(IpAddress));
+ memcpy(this, s, sizeof(Ip::Address));
}
-IpAddress::IpAddress(const struct hostent &s)
+Ip::Address::Address(const struct hostent &s)
{
SetEmpty();
operator=(s);
}
-bool IpAddress::operator =(const struct hostent &s)
+bool
+Ip::Address::operator =(const struct hostent &s)
{
struct in_addr* ipv4 = NULL;
return true;
}
-IpAddress::IpAddress(const struct addrinfo &s)
+Ip::Address::Address(const struct addrinfo &s)
{
SetEmpty();
operator=(s);
}
-bool IpAddress::operator =(const struct addrinfo &s)
+bool
+Ip::Address::operator =(const struct addrinfo &s)
{
struct sockaddr_in* ipv4 = NULL;
return true;
}
-void IpAddress::GetAddrInfo(struct addrinfo *&dst, int force) const
+void
+Ip::Address::GetAddrInfo(struct addrinfo *&dst, int force) const
{
if (dst == NULL) {
dst = new addrinfo;
}
}
-void IpAddress::InitAddrInfo(struct addrinfo *&ai) const
+void
+Ip::Address::InitAddrInfo(struct addrinfo *&ai)
{
if (ai == NULL) {
ai = new addrinfo;
}
-void IpAddress::FreeAddrInfo(struct addrinfo *&ai) const
+void
+Ip::Address::FreeAddrInfo(struct addrinfo *&ai)
{
if (ai == NULL) return;
ai = NULL;
}
-int IpAddress::matchIPAddr(const IpAddress &rhs) const
+int
+Ip::Address::matchIPAddr(const Ip::Address &rhs) const
{
#if USE_IPV6
uint8_t *l = (uint8_t*)m_SocketAddr.sin6_addr.s6_addr;
return 0;
}
-bool IpAddress::operator ==(const IpAddress &s) const
+bool
+Ip::Address::operator ==(const Ip::Address &s) const
{
return (0 == matchIPAddr(s));
}
-bool IpAddress::operator !=(const IpAddress &s) const
+bool
+Ip::Address::operator !=(const Ip::Address &s) const
{
return ! ( operator==(s) );
}
-bool IpAddress::operator <=(const IpAddress &rhs) const
+bool
+Ip::Address::operator <=(const Ip::Address &rhs) const
{
if (IsAnyAddr() && !rhs.IsAnyAddr())
return true;
return (matchIPAddr(rhs) <= 0);
}
-bool IpAddress::operator >=(const IpAddress &rhs) const
+bool
+Ip::Address::operator >=(const Ip::Address &rhs) const
{
if (IsNoAddr() && !rhs.IsNoAddr())
return true;
return ( matchIPAddr(rhs) >= 0);
}
-bool IpAddress::operator >(const IpAddress &rhs) const
+bool
+Ip::Address::operator >(const Ip::Address &rhs) const
{
if (IsNoAddr() && !rhs.IsNoAddr())
return true;
return ( matchIPAddr(rhs) > 0);
}
-bool IpAddress::operator <(const IpAddress &rhs) const
+bool
+Ip::Address::operator <(const Ip::Address &rhs) const
{
if (IsNoAddr() && !rhs.IsNoAddr())
return true;
return ( matchIPAddr(rhs) < 0);
}
-u_short IpAddress::GetPort() const
+u_short
+Ip::Address::GetPort() const
{
return ntohs( m_SocketAddr.sin6_port );
}
-u_short IpAddress::SetPort(u_short prt)
+u_short
+Ip::Address::SetPort(u_short prt)
{
m_SocketAddr.sin6_port = htons(prt);
*
* A copy of the buffer is also returned for simple immediate display.
*/
-char* IpAddress::NtoA(char* buf, const unsigned int blen, int force) const
+char *
+Ip::Address::NtoA(char* buf, const unsigned int blen, int force) const
{
// Ensure we have a buffer.
if (buf == NULL) {
return buf;
}
-unsigned int IpAddress::ToHostname(char *buf, const unsigned int blen) const
+unsigned int
+Ip::Address::ToHostname(char *buf, const unsigned int blen) const
{
char *p = buf;
return (p - buf);
}
-char* IpAddress::ToURL(char* buf, unsigned int blen) const
+char *
+Ip::Address::ToURL(char* buf, unsigned int blen) const
{
char *p = buf;
return buf;
}
-void IpAddress::GetSockAddr(struct sockaddr_storage &addr, const int family) const
+void
+Ip::Address::GetSockAddr(struct sockaddr_storage &addr, const int family) const
{
struct sockaddr_in *sin = NULL;
if ( family == AF_INET && !IsIPv4()) {
// FIXME INET6: caller using the wrong socket type!
- debugs(14, DBG_CRITICAL, HERE << "IpAddress::GetSockAddr : Cannot convert non-IPv4 to IPv4. from " << *this);
+ debugs(14, DBG_CRITICAL, HERE << "Ip::Address::GetSockAddr : Cannot convert non-IPv4 to IPv4. from " << *this);
assert(false);
}
#endif /* USE_IPV6 */
}
-void IpAddress::GetSockAddr(struct sockaddr_in &buf) const
+void
+Ip::Address::GetSockAddr(struct sockaddr_in &buf) const
{
#if USE_IPV6
buf.sin_port = m_SocketAddr.sin6_port;
Map6to4( m_SocketAddr.sin6_addr, buf.sin_addr);
} else {
- debugs(14, DBG_CRITICAL, HERE << "IpAddress::GetSockAddr : Cannot convert non-IPv4 to IPv4. from " << *this );
+ debugs(14, DBG_CRITICAL, HERE << "Ip::Address::GetSockAddr : Cannot convert non-IPv4 to IPv4. from " << *this );
memset(&buf,0xFFFFFFFF,sizeof(struct sockaddr_in));
assert(false);
}
#if USE_IPV6
-
-void IpAddress::GetSockAddr(struct sockaddr_in6 &buf) const
+void
+Ip::Address::GetSockAddr(struct sockaddr_in6 &buf) const
{
memcpy(&buf, &m_SocketAddr, sizeof(struct sockaddr_in6));
/* maintain address family. It may have changed inside us. */
buf.sin6_len = sizeof(struct sockaddr_in6);
#endif
}
-
#endif
#if USE_IPV6
-
-void IpAddress::Map4to6(const struct in_addr &in, struct in6_addr &out) const
+void
+Ip::Address::Map4to6(const struct in_addr &in, struct in6_addr &out) const
{
/* check for special cases */
}
}
-void IpAddress::Map6to4(const struct in6_addr &in, struct in_addr &out) const
+void
+Ip::Address::Map6to4(const struct in6_addr &in, struct in_addr &out) const
{
/* ANYADDR */
/* NOADDR */
((uint8_t *)&out.s_addr)[3] = in.s6_addr[15];
}
-#endif
-
-#if USE_IPV6
-void IpAddress::GetInAddr(in6_addr &buf) const
+void
+Ip::Address::GetInAddr(in6_addr &buf) const
{
memcpy(&buf, &m_SocketAddr.sin6_addr, sizeof(struct in6_addr));
}
-
#endif
-bool IpAddress::GetInAddr(struct in_addr &buf) const
+bool
+Ip::Address::GetInAddr(struct in_addr &buf) const
{
#if USE_IPV6
// default:
// non-compatible IPv6 Pure Address
- debugs(14,1, HERE << "IpAddress::GetInAddr : Cannot convert non-IPv4 to IPv4. IPA=" << *this);
+ debugs(14,1, HERE << "Ip::Address::GetInAddr : Cannot convert non-IPv4 to IPv4. IPA=" << *this);
memset(&buf,0xFFFFFFFF,sizeof(struct in_addr));
assert(false);
return false;
* developed and/or copyrighted by other sources. Please see the
* CREDITS file for full details.
*
- * This IpAddress code is copyright (C) 2007 by Treehouse Networks Ltd
+ * This Ip::Address code is copyright (C) 2007 by Treehouse Networks Ltd
* of New Zealand. It is published and Lisenced as an extension of
* squid under the same conditions as the main squid application.
*
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
-#ifndef _INC_IPADDRESS_H
-#define _INC_IPADDRESS_H
+#ifndef _SQUID_IP_IPADDRESS_H
+#define _SQUID_IP_IPADDRESS_H
#include "config.h"
#include <ostream>
#endif
+namespace Ip {
+
/* FreeBSD hack:
* This OS has at least one version that defines these as private
* kernel macros commented as being 'non-standard'.
/**
* Holds and manipulates IPv4, IPv6, and Socket Addresses.
*/
-class IpAddress
+class Address
{
public:
/** @name Constructors and Destructor */
/*@{*/
- IpAddress();
- IpAddress(const IpAddress &);
+ Address();
+ Address(const Address &);
/**
* This constructor takes its own copy of the object pointed to for memory-safe usage later.
\deprecated Use of pointers can be nasty. Consider this a last-resort.
* Prefer the by-reference (&) version instead.
*/
- IpAddress(IpAddress *);
+ Address(Address *);
- IpAddress(const struct in_addr &);
+ Address(const struct in_addr &);
- IpAddress(const struct sockaddr_in &);
+ Address(const struct sockaddr_in &);
#if USE_IPV6
- IpAddress(const struct in6_addr &);
+ Address(const struct in6_addr &);
- IpAddress(const struct sockaddr_in6 &);
+ Address(const struct sockaddr_in6 &);
#endif
- IpAddress(const struct hostent &);
- IpAddress(const struct addrinfo &);
- IpAddress(const char*);
+ Address(const struct hostent &);
+ Address(const struct addrinfo &);
+ Address(const char*);
/// Default destructor.
- ~IpAddress();
+ ~Address();
/*@}*/
/** @name Assignment Operators */
/*@{*/
- IpAddress& operator =(const IpAddress &s);
- IpAddress& operator =(struct sockaddr_in const &s);
- IpAddress& operator =(struct sockaddr_storage const &s);
- IpAddress& operator =(struct in_addr const &s);
+ Address& operator =(const Address &s);
+ Address& operator =(struct sockaddr_in const &s);
+ Address& operator =(struct sockaddr_storage const &s);
+ Address& operator =(struct in_addr const &s);
#if USE_IPV6
- IpAddress& operator =(struct in6_addr const &s);
- IpAddress& operator =(struct sockaddr_in6 const &s);
+ Address& operator =(struct in6_addr const &s);
+ Address& operator =(struct sockaddr_in6 const &s);
#endif
bool operator =(const struct hostent &s);
bool operator =(const struct addrinfo &s);
/** @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;
+ bool operator ==(Address const &s) const;
+ bool operator !=(Address const &s) const;
+ bool operator >=(Address const &rhs) const;
+ bool operator <=(Address const &rhs) const;
+ bool operator >(Address const &rhs) const;
+ bool operator <(Address const &rhs) const;
public:
/* methods */
bool IsSockAddr() const;
/** Content-neutral test for whether the specific IP case ANY_ADDR is stored.
- * This is the default content of a new undefined IpAddress object.
+ * This is the default content of a new undefined Ip::Address object.
\retval true IPv4 0.0.0.0
\retval true IPv6 ::
\retval false anything else.
bool IsNoAddr() const;
/** Content-neutral test for whether the specific IP case LOCALHOST is stored.
- * This is the default content of a new undefined IpAddress object.
+ * This is the default content of a new undefined Ip::Address object.
\retval true IPv4 127.0.0.1
\retval true IPv6 ::1
\retval false anything else.
/** Apply a mask to the stored address.
\param mask Netmask format to be bit-mask-AND'd over the stored address.
*/
- const int ApplyMask(const IpAddress &mask);
+ const int ApplyMask(const Address &mask);
/** Apply a mask to the stored address.
* CIDR will be converted appropriate to map the stored content.
\retval 1 IP rhs is greater (numerically) than that stored.
\retval -1 IP rhs is less (numerically) than that stored.
*/
- int matchIPAddr(const IpAddress &rhs) const;
+ int matchIPAddr(const Address &rhs) const;
/**
- * Get RFC 3493 addrinfo structure from the IpAddress data
+ * Get RFC 3493 addrinfo structure from the Ip::Address data
* for protocol-neutral socket operations.
* Should be passed a NULL pointer of type struct addrinfo* it will
* allocate memory for the structures involved. (see FreeAddrInfo to clear).
* 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
+ * Ip::Address allocated objects MUST be destructed by Ip::Address::FreeAddrInfo
* System getaddrinfo() allocated objects MUST be freed with system freeaddrinfo()
\par
* Some OS require that IPv4 addresses are pre-mapped by the client.
#endif
/**
- * Equivalent to the sysem call freeaddrinfo() but for IpAddress allocated data
+ * Equivalent to the sysem call freeaddrinfo() but for Ip::Address allocated data
*/
- void FreeAddrInfo(struct addrinfo *&ai) const;
+ static void FreeAddrInfo(struct addrinfo *&ai);
/**
* Initializes an empty addrinfo properly for use.
* about to be changed and the stored details may not match the new ones coming.
\param ai addrinfo struct to be initialized as AF_UNSPEC with large address buffer
*/
- void InitAddrInfo(struct addrinfo *&ai) const;
+ static void InitAddrInfo(struct addrinfo *&ai);
/**
* Lookup a Host by Name. Equivalent to system call gethostbyname(char*)
*/
void GetSockAddr(struct sockaddr_storage &addr, const int family) const;
-
- /// \deprecated Deprecated for public use. Use IpAddress::GetAddrInfo()
void GetSockAddr(struct sockaddr_in &) const;
-
- /// \deprecated Deprecated for public use. Use IpAddress::GetAddrInfo()
bool GetInAddr(struct in_addr &) const; /* false if could not convert IPv6 down to IPv4 */
#if USE_IPV6
-
- /// \deprecated Deprecated for public use. Use IpAddress::GetAddrInfo()
void GetSockAddr(struct sockaddr_in6 &) const;
-
- /// \deprecated Deprecated for public use. Use IpAddress::GetAddrInfo()
void GetInAddr(struct in6_addr &) const;
#endif
/* variables */
#if USE_IPV6
-
struct sockaddr_in6 m_SocketAddr;
#else
-
struct sockaddr_in m_SocketAddr;
#endif
inline std::ostream &
-operator << (std::ostream &os, const IpAddress &ipa)
+operator << (std::ostream &os, const Address &ipa)
{
char buf[MAX_IPSTRLEN];
os << ipa.ToURL(buf,MAX_IPSTRLEN);
}
// WAS _sockaddr_in_list in an earlier incarnation
-class IpAddress_list
+class Address_list
{
public:
- IpAddress_list() { next = NULL; };
- ~IpAddress_list() { if (next) delete next; next = NULL; };
+ Address_list() { next = NULL; };
+ ~Address_list() { if (next) delete next; next = NULL; };
- IpAddress s;
- IpAddress_list *next;
+ Address s;
+ Address_list *next;
};
+}; // namespace Ip
+
+extern void parse_IpAddress_list_token(Ip::Address_list **, char *);
-#endif /* _INC_IPADDRESS_H */
+#endif /* _SQUID_IP_IPADDRESS_H */
// single global instance for access by other components.
-IpIntercept IpInterceptor;
+Ip::Intercept Ip::Interceptor;
void
-IpIntercept::StopTransparency(const char *str)
+Ip::Intercept::StopTransparency(const char *str)
{
if (transparent_active) {
debugs(89, DBG_IMPORTANT, "Stopping full transparency: " << str);
}
void
-IpIntercept::StopInterception(const char *str)
+Ip::Intercept::StopInterception(const char *str)
{
if (intercept_active) {
debugs(89, DBG_IMPORTANT, "Stopping IP interception: " << str);
}
int
-IpIntercept::NetfilterInterception(int fd, const IpAddress &me, IpAddress &dst, int silent)
+Ip::Intercept::NetfilterInterception(int fd, const Ip::Address &me, Ip::Address &dst, int silent)
{
#if LINUX_NETFILTER
struct addrinfo *lookup = NULL;
dst = *lookup;
}
- dst.FreeAddrInfo(lookup);
+ Address::FreeAddrInfo(lookup);
if (me != dst) {
debugs(89, 5, HERE << "address NAT: me= " << me << ", dst= " << dst);
}
int
-IpIntercept::NetfilterTransparent(int fd, const IpAddress &me, IpAddress &client, int silent)
+Ip::Intercept::NetfilterTransparent(int fd, const Ip::Address &me, Ip::Address &client, int silent)
{
#if LINUX_NETFILTER
}
int
-IpIntercept::IpfwInterception(int fd, const IpAddress &me, IpAddress &dst, int silent)
+Ip::Intercept::IpfwInterception(int fd, const Ip::Address &me, Ip::Address &dst, int silent)
{
#if IPFW_TRANSPARENT
struct addrinfo *lookup = NULL;
dst = *lookup;
}
- dst.FreeAddrInfo(lookup);
+ Address::FreeAddrInfo(lookup);
if (me != dst) {
debugs(89, 5, HERE << "address NAT: me= " << me << ", dst= " << dst);
}
int
-IpIntercept::IpfInterception(int fd, const IpAddress &me, IpAddress &client, IpAddress &dst, int silent)
+Ip::Intercept::IpfInterception(int fd, const Ip::Address &me, Ip::Address &client, Ip::Address &dst, int silent)
{
#if IPF_TRANSPARENT /* --enable-ipf-transparent */
}
int
-IpIntercept::PfInterception(int fd, const IpAddress &me, IpAddress &client, IpAddress &dst, int silent)
+Ip::Intercept::PfInterception(int fd, const Ip::Address &me, Ip::Address &client, Ip::Address &dst, int silent)
{
#if PF_TRANSPARENT /* --enable-pf-transparent */
int
-IpIntercept::NatLookup(int fd, const IpAddress &me, const IpAddress &peer, IpAddress &client, IpAddress &dst)
+Ip::Intercept::NatLookup(int fd, const Ip::Address &me, const Ip::Address &peer, Ip::Address &client, Ip::Address &dst)
{
/* --enable-linux-netfilter */
/* --enable-ipfw-transparent */
#if LINUX_TPROXY2
int
-IpIntercept::SetTproxy2OutgoingAddr(int fd, const IpAddress &src)
+Ip::Intercept::SetTproxy2OutgoingAddr(int fd, const Ip::Address &src)
{
- IpAddress addr;
+ Address addr;
struct in_tproxy itp;
src.GetInAddr(itp.v.addr.faddr);
#endif
bool
-IpIntercept::ProbeForTproxy(IpAddress &test)
+Ip::Intercept::ProbeForTproxy(Ip::Address &test)
{
debugs(3, 3, "Detect TPROXY support on port " << test);
#if LINUX_TPROXY2
debugs(3, 3, "...Probing for IPv6 TPROXY support.");
struct sockaddr_in6 tmp_ip6;
- IpAddress tmp = "::2";
+ Ip::Address tmp = "::2";
tmp.SetPort(0);
tmp.GetSockAddr(tmp_ip6);
debugs(3, 3, "...Probing for IPv4 TPROXY support.");
struct sockaddr_in tmp_ip4;
- IpAddress tmp = "127.0.0.2";
+ Ip::Address tmp = "127.0.0.2";
tmp.SetPort(0);
tmp.GetSockAddr(tmp_ip4);
* AUTHOR: Amos Jeffries
*
*/
-#ifndef SQUID_IPINTERCEPTION_H
-#define SQUID_IPINTERCEPTION_H
-
-class IpAddress;
+#ifndef SQUID_IP_IPINTERCEPT_H
+#define SQUID_IP_IPINTERCEPT_H
/* for time_t */
#include "SquidTime.h"
+namespace Ip {
+
+class Address;
+
/**
\defgroup IpInterceptAPI IP Interception and Transparent Proxy API
\ingroup SquidComponent
* instead there is this neutral API which other connection state machines
* and the comm layer use to co-ordinate their own state for transparency.
*/
-class IpIntercept
+class Intercept
{
public:
- IpIntercept() : transparent_active(0), intercept_active(0), last_reported(0) {};
- ~IpIntercept() {};
+ Intercept() : transparent_active(0), intercept_active(0), last_reported(0) {};
+ ~Intercept() {};
/** Perform NAT lookups */
- int NatLookup(int fd, const IpAddress &me, const IpAddress &peer, IpAddress &client, IpAddress &dst);
+ int NatLookup(int fd, const Address &me, const Address &peer, Address &client, Address &dst);
#if LINUX_TPROXY2
// only relevant to TPROXY v2 connections.
// which require the address be set specifically post-connect.
- int SetTproxy2OutgoingAddr(int fd, const IpAddress &src);
+ int SetTproxy2OutgoingAddr(int fd, const Address &src);
#endif
/**
* \retval true TPROXY is available.
* \retval false TPROXY is not available.
*/
- bool ProbeForTproxy(IpAddress &test);
+ bool ProbeForTproxy(Address &test);
/**
\retval 0 Full transparency is disabled.
\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 Address &me, Address &client, int silent);
/**
* perform Lookups on Netfilter fully-transparent interception targets (TPROXY).
\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 Address &me, Address &dst, int silent);
/**
* perform Lookups on IPFW interception.
\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 Address &me, Address &client, int silent);
/**
* perform Lookups on IPF interception.
\retval 0 Successfuly located the new address.
\retval -1 An error occured during NAT lookups.
*/
- int IpfInterception(int fd, const IpAddress &me, IpAddress &client, IpAddress &dst, int silent);
+ int IpfInterception(int fd, const Address &me, Address &client, Address &dst, int silent);
/**
* perform Lookups on PF interception.
\retval 0 Successfuly located the new address.
\retval -1 An error occured during NAT lookups.
*/
- int PfInterception(int fd, const IpAddress &me, IpAddress &client, IpAddress &dst, int silent);
+ int PfInterception(int fd, const Address &me, Address &client, Address &dst, int silent);
int transparent_active;
\ingroup IpInterceptAPI
* Globally available instance of the IP Interception manager.
*/
-extern IpIntercept IpInterceptor;
+extern Intercept Interceptor;
+
+}; // namespace Ip
-#endif /* SQUID_IPINTERCEPTION_H */
+#endif /* SQUID_IP_IPINTERCEPT_H */
#include "QosConfig.h"
-QosConfig::QosConfig() :
+Ip::Qos::QosConfig Ip::Qos::TheConfig;
+
+Ip::Qos::QosConfig::QosConfig() :
tos_local_hit(0),
tos_sibling_hit(0),
tos_parent_hit(0),
}
void
-QosConfig::parseConfigLine()
+Ip::Qos::QosConfig::parseConfigLine()
{
// %i honors 0 and 0x prefixes, which are important for things like umask
/* parse options ... */
* which means no StoreEntry refrences. Just a basic char* buffer.
*/
void
-QosConfig::dumpConfigLine(char *entry, const char *name) const
+Ip::Qos::QosConfig::dumpConfigLine(char *entry, const char *name) const
{
char *p = entry;
snprintf(p, 10, "%s", name); // strlen("qos_flows ");
#if USE_ZPH_QOS
+namespace Ip {
+
+namespace Qos {
+
class QosConfig
{
public:
void dumpConfigLine(char *entry, const char *name) const;
};
+extern QosConfig TheConfig;
+
/* legacy parser access wrappers */
#define parse_QosConfig(X) (X)->parseConfigLine()
#define free_QosConfig(X)
storeAppendPrintf(e, "%s", temp); \
} while(0);
+}; // namespace Qos
+}; // namespace Ip
+
#endif /* USE_ZPH_QOS */
#endif /* SQUID_QOSCONFIG_H */
void
testIpAddress::testDefaults()
{
- IpAddress anIPA;
+ Ip::Address anIPA;
/* test stored values */
CPPUNIT_ASSERT( anIPA.IsAnyAddr() );
inval.s_addr = htonl(0xC0A8640C);
outval.s_addr = htonl(0x00000000);
- IpAddress anIPA(inval);
+ Ip::Address anIPA(inval);
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
inval.s6_addr32[2] = htonl(0xFFFFFFFF);
inval.s6_addr32[3] = htonl(0xFFFFFFFF);
- IpAddress anIPA(inval);
+ Ip::Address anIPA(inval);
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
insock.sin_len = sizeof(struct sockaddr_in);
#endif
- IpAddress anIPA((const struct sockaddr_in)insock);
+ Ip::Address anIPA((const struct sockaddr_in)insock);
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
insock.sin6_len = sizeof(struct sockaddr_in6);
#endif
- IpAddress anIPA((const struct sockaddr_in6)insock);
+ Ip::Address anIPA((const struct sockaddr_in6)insock);
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
insock.sin_len = sizeof(struct sockaddr_in);
#endif
- IpAddress inIPA(insock);
- IpAddress outIPA(inIPA);
+ Ip::Address inIPA(insock);
+ Ip::Address outIPA(inIPA);
/* test stored values */
hp = gethostbyname("192.168.100.12");
CPPUNIT_ASSERT( hp != NULL /* gethostbyname failure.*/ );
- IpAddress anIPA(*hp);
+ Ip::Address anIPA(*hp);
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
expectval.s_addr = htonl(0xC0A8640C);
- IpAddress anIPA = "192.168.100.12";
+ Ip::Address anIPA = "192.168.100.12";
/* test stored values */
CPPUNIT_ASSERT( !anIPA.IsAnyAddr() );
expectv6.s6_addr32[2] = htonl(0x00000000);
expectv6.s6_addr32[3] = htonl(0x00000045);
- IpAddress bnIPA = "2000:800::45";
+ Ip::Address bnIPA = "2000:800::45";
/* test stored values */
CPPUNIT_ASSERT( !bnIPA.IsAnyAddr() );
CPPUNIT_ASSERT( memcmp( &expectv6, &outval6, sizeof(struct in6_addr)) == 0 );
/* test IPv6 as an old netmask format. This is invalid but sometimes use. */
- IpAddress cnIPA = "ffff:ffff:fff0::";
+ Ip::Address cnIPA = "ffff:ffff:fff0::";
expectv6.s6_addr32[0] = htonl(0xFFFFFFFF);
expectv6.s6_addr32[1] = htonl(0xFFF00000);
void
testIpAddress::testSetEmpty()
{
- IpAddress anIPA;
+ Ip::Address anIPA;
struct in_addr inval;
inval.s_addr = htonl(0xC0A8640C);
void
testIpAddress::testBooleans()
{
- IpAddress lhsIPA;
- IpAddress rhsIPA;
+ Ip::Address lhsIPA;
+ Ip::Address rhsIPA;
struct in_addr valLow;
struct in_addr valHigh;
{
struct in_addr inval;
char buf[MAX_IPSTRLEN];
- IpAddress anIPA;
+ Ip::Address anIPA;
anIPA.SetAnyAddr();
inval.s_addr = htonl(0xC0A8640C);
- IpAddress anIPA(inval);
+ Ip::Address anIPA(inval);
/* test values */
anIPA.ToURL(buf,MAX_IPSTRLEN);
ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
- IpAddress bnIPA(ip6val);
+ Ip::Address bnIPA(ip6val);
bnIPA.ToURL(buf,MAX_IPSTRLEN);
CPPUNIT_ASSERT( memcmp("[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]", buf, 41) == 0 );
sock.sin_len = sizeof(struct sockaddr_in);
#endif
- IpAddress anIPA(sock);
+ Ip::Address anIPA(sock);
char buf[MAX_IPSTRLEN];
/* test values */
ip6val.sin6_len = sizeof(struct sockaddr_in6);
#endif
- IpAddress bnIPA(ip6val);
+ Ip::Address bnIPA(ip6val);
bnIPA.ToURL(buf,MAX_IPSTRLEN);
CPPUNIT_ASSERT( memcmp("[c0a8:640c:ffff:ffff:ffff:ffff:ffff:ffff]:80", buf, 44) == 0 );
struct in_addr ipv4val;
ipv4val.s_addr = htonl(0xC0A8640C);
- IpAddress v4IPA(ipv4val);
+ Ip::Address v4IPA(ipv4val);
/* test IPv4 output */
v4IPA.GetReverseString(buf);
ip6val.s6_addr32[2] = htonl(0xFFFFFFFF);
ip6val.s6_addr32[3] = htonl(0xFFFFFFFF);
- IpAddress v6IPA(ip6val);
+ Ip::Address v6IPA(ip6val);
/* test IPv6 output */
v6IPA.GetReverseString(buf);
testIpAddress::testMasking()
{
char buf[MAX_IPSTRLEN];
- IpAddress anIPA;
- IpAddress maskIPA;
+ Ip::Address anIPA;
+ Ip::Address maskIPA;
/* Test Basic CIDR Routine */
anIPA.SetAnyAddr();
CPPUNIT_ASSERT( memcmp("ffff:ffff:ffff:ffff:ffff::", buf, 26) == 0 );
#endif
- /* Test Network Bitmask from IpAddress */
+ /* Test Network Bitmask from Ip::Address */
anIPA.SetNoAddr();
maskIPA = "255.255.240.0";
CPPUNIT_ASSERT_EQUAL( 20 , maskIPA.GetCIDR() );
hints.ai_flags = AI_NUMERICHOST;
- IpAddress anIP = "127.0.0.1";
+ Ip::Address anIP = "127.0.0.1";
/* assert this just to check that getaddrinfo is working properly */
CPPUNIT_ASSERT( getaddrinfo("127.0.0.1", NULL, &hints, &expect ) == 0 );
expectval.s_addr = htonl(0xC0A8640C);
- IpAddress anIPA = "192.168.100.12";
+ Ip::Address anIPA = "192.168.100.12";
/* test stored values */
}
pid_t
-ipcCreate(int type, const char *prog, const char *const args[], const char *name, IpAddress &local_addr, int *rfd, int *wfd, void **hIpc)
+ipcCreate(int type, const char *prog, const char *const args[], const char *name, Ip::Address &local_addr, int *rfd, int *wfd, void **hIpc)
{
pid_t pid;
- IpAddress ChS;
- IpAddress PaS;
+ Ip::Address ChS;
+ Ip::Address PaS;
struct addrinfo *AI = NULL;
int crfd = -1;
int prfd = -1;
int type;
int crfd;
int cwfd;
- IpAddress local_addr;
+ Ip::Address local_addr;
struct addrinfo PS;
const char *prog;
char **args;
}
pid_t
-ipcCreate(int type, const char *prog, const char *const args[], const char *name, IpAddress &local_addr, int *rfd, int *wfd, void **hIpc)
+ipcCreate(int type, const char *prog, const char *const args[], const char *name, Ip::Address &local_addr, int *rfd, int *wfd, void **hIpc)
{
unsigned long thread;
DWORD ecode = 0;
pid_t pid;
- IpAddress tmp_addr;
+ Ip::Address tmp_addr;
struct addrinfo *aiCS = NULL;
struct addrinfo *aiPS = NULL;
return ipcCloseAllFD(prfd, pwfd, crfd, cwfd);
}
- /* NP: tmp_addr was left with eiether empty or aiCS in IpAddress format */
+ /* NP: tmp_addr was left with eiether empty or aiCS in Ip::Address format */
if (comm_connect_addr(pwfd, tmp_addr) == COMM_ERROR) {
CloseHandle((HANDLE) thread);
return ipcCloseAllFD(prfd, pwfd, -1, -1);
int prfd_ipc = -1, pwfd_ipc = -1, crfd_ipc = -1, cwfd_ipc = -1;
char *prog = NULL, *buf1 = NULL;
- IpAddress PS_ipc;
- IpAddress CS_ipc;
+ Ip::Address PS_ipc;
+ Ip::Address CS_ipc;
struct addrinfo *aiPS_ipc = NULL;
struct addrinfo *aiCS_ipc = NULL;
int cwfd = params->cwfd;
char **args = params->args;
- IpAddress PS = params->PS;
- IpAddress local_addr = params->local_addr;
+ Ip::Address PS = params->PS;
+ Ip::Address local_addr = params->local_addr;
buf1 = (char *)xcalloc(1, 8192);
strcpy(buf1, params->prog);
if (ipcount > 0) {
int j, k;
- i->addrs.in_addrs = (IpAddress *)xcalloc(ipcount, sizeof(IpAddress));
+ i->addrs.in_addrs = static_cast<Ip::Address *>(xcalloc(ipcount, sizeof(Ip::Address)));
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));
return 0;
}
- i->addrs.in_addrs = (IpAddress *)xcalloc(na, sizeof(IpAddress));
+ i->addrs.in_addrs = static_cast<Ip::Address *>(xcalloc(na, sizeof(Ip::Address)));
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));
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->SetEmpty(); // properly setup the IpAddress!
+ static_addrs.in_addrs = static_cast<Ip::Address *>(xcalloc(1, sizeof(Ip::Address)));
+ static_addrs.in_addrs->SetEmpty(); // properly setup the Ip::Address!
static_addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char));
ipcache_high = (long) (((float) Config.ipcache.size *
(float) Config.ipcache.high) / (float) 100);
#if DNS_CNAME
/**
- * Takes two IpAddress arrays and merges them into a single array
+ * Takes two Ip::Address arrays and merges them into a single array
* which is allocated dynamically to fit the number of unique addresses
*
\param aaddrs One list to merge
\param outlen Size of list out
*/
void
-ipcacheMergeIPLists(const IpAddress *aaddrs, const int alen,
- const IpAddress *baddrs, const int blen,
- IpAddress **out, int &outlen )
+ipcacheMergeIPLists(const Ip::Address *aaddrs, const int alen,
+ const Ip::Address *baddrs, const int blen,
+ Ip::Address **out, int &outlen )
{
int fc=0, t=0, c=0;
- IpAddress const *ip4ptrs[255];
+ Ip::Address const *ip4ptrs[255];
#if USE_IPV6
- IpAddress const *ip6ptrs[255];
+ Ip::Address const *ip6ptrs[255];
#endif
int num_ip4 = 0;
int num_ip6 = 0;
- memset(ip4ptrs, 0, sizeof(IpAddress*)*255);
+ memset(ip4ptrs, 0, sizeof(Ip::Address*)*255);
#if USE_IPV6
- memset(ip6ptrs, 0, sizeof(IpAddress*)*255);
+ memset(ip6ptrs, 0, sizeof(Ip::Address*)*255);
#endif
// for each unique address in list A - grab ptr
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) = static_cast<Ip::Address*>(xcalloc(fc, sizeof(Ip::Address)));
outlen=0;
assert(out != NULL);
#if DNS_CNAME
ipcache_entry *i = NULL;
char *pname = NULL;
- IpAddress *tmpbuf = NULL;
+ Ip::Address *tmpbuf = NULL;
int fc = 0;
int ttl = 0;
generic_cbdata* gcb = (generic_cbdata*)cbdata;
ipcache_addrs *
ipcacheCheckNumeric(const char *name)
{
-
- IpAddress ip;
+ Ip::Address ip;
/* check if it's already a IP address in text form. */
/* it may be IPv6-wrapped */
\param addr specific addres to be marked bad
*/
void
-ipcacheMarkBadAddr(const char *name, IpAddress &addr)
+ipcacheMarkBadAddr(const char *name, const Ip::Address &addr)
{
ipcache_entry *i;
ipcache_addrs *ia;
/// \ingroup IPCacheAPI
void
-ipcacheMarkGoodAddr(const char *name, IpAddress &addr)
+ipcacheMarkGoodAddr(const char *name, const Ip::Address &addr)
{
ipcache_entry *i;
ipcache_addrs *ia;
{
ipcache_entry *i;
- IpAddress ip;
+ Ip::Address ip;
if (!(ip = ipaddr)) {
#if USE_IPV6
i->addrs.cur = 0;
i->addrs.badcount = 0;
- i->addrs.in_addrs = (IpAddress *)xcalloc(1, sizeof(IpAddress));
+ i->addrs.in_addrs = static_cast<Ip::Address *>(xcalloc(1, sizeof(Ip::Address)));
i->addrs.bad_mask = (unsigned char *)xcalloc(1, sizeof(unsigned char));
i->addrs.in_addrs[0] = ip;
i->addrs.bad_mask[0] = FALSE;
lf->data = ll;
ll->eol = 1;
{
- IpAddress localhost;
+ Ip::Address localhost;
args[0] = "(logfile-daemon)";
args[1] = path;
args[2] = NULL;
int
logfile_mod_udp_open(Logfile * lf, const char *path, size_t bufsz, int fatal_flag)
{
- IpAddress addr;
+ Ip::Address addr;
char *strAddr;
lf->f_close = logfile_mod_udp_close;
}
safe_free(strAddr);
- IpAddress any_addr;
+ Ip::Address any_addr;
any_addr.SetAnyAddr();
#if USE_IPV6
static void peerCountMcastPeersSchedule(peer * p, time_t when);
static IRCB peerCountHandleIcpReply;
-static void neighborIgnoreNonPeer(const IpAddress &, icp_opcode);
+static void neighborIgnoreNonPeer(const Ip::Address &, icp_opcode);
static OBJH neighborDumpPeers;
static OBJH neighborDumpNonPeers;
static void dump_peers(StoreEntry * sentry, peer * peers);
peer *
-whichPeer(const IpAddress &from)
+whichPeer(const Ip::Address &from)
{
int j;
void
neighbors_init(void)
{
- IpAddress nul;
+ Ip::Address nul;
struct addrinfo *AI = NULL;
struct servent *sep = NULL;
const char *me = getMyHostname();
static peer *non_peers = NULL;
static void
-neighborIgnoreNonPeer(const IpAddress &from, icp_opcode opcode)
+neighborIgnoreNonPeer(const Ip::Address &from, icp_opcode opcode)
{
peer *np;
* If a hit process is already started, then sobeit
*/
void
-neighborsUdpAck(const cache_key * key, icp_common_t * header, const IpAddress &from)
+neighborsUdpAck(const cache_key * key, icp_common_t * header, const Ip::Address &from)
{
peer *p = NULL;
StoreEntry *entry;
if (squid_curtime - p->stats.last_connect_probe == 0)
return ret;/* don't probe to often */
- IpAddress temp(getOutgoingAddr(NULL,p));
+ Ip::Address temp(getOutgoingAddr(NULL,p));
fd = comm_open(SOCK_STREAM, IPPROTO_TCP, temp, COMM_NONBLOCKING, p->host);
#if USE_HTCP
void
-neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const IpAddress &from)
+neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const Ip::Address &from)
{
StoreEntry *e = Store::Root().get(key);
MemObject *mem = NULL;
/* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
const char *
-PconnPool::key(const char *host, u_short port, const char *domain, IpAddress &client_address)
+PconnPool::key(const char *host, u_short port, const char *domain, Ip::Address &client_address)
{
LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 3 + 10);
char ntoabuf[MAX_IPSTRLEN];
}
void
-PconnPool::push(int fd, const char *host, u_short port, const char *domain, IpAddress &client_address)
+PconnPool::push(int fd, const char *host, u_short port, const char *domain, Ip::Address &client_address)
{
IdleConnList *list;
const char *aKey;
* transactions create persistent connections but are not retriable.
*/
int
-PconnPool::pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool isRetriable)
+PconnPool::pop(const char *host, u_short port, const char *domain, Ip::Address &client_address, bool isRetriable)
{
const char * aKey = key(host, port, domain, client_address);
};
-class IpAddress;
+class Ip::Address;
class StoreEntry;
class IdleConnLimit;
~PconnPool();
void moduleInit();
- void push(int fd, const char *host, u_short port, const char *domain, IpAddress &client_address);
- int pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool retriable);
+ void push(int fd, const char *host, u_short port, const char *domain, Ip::Address &client_address);
+ int pop(const char *host, u_short port, const char *domain, Ip::Address &client_address, bool retriable);
void count(int uses);
void dumpHist(StoreEntry *e);
void dumpHash(StoreEntry *e);
private:
- static const char *key(const char *host, u_short port, const char *domain, IpAddress &client_address);
+ static const char *key(const char *host, u_short port, const char *domain, Ip::Address &client_address);
int hist[PCONN_HIST_SZ];
hash_table *table;
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 *);
-
/* client_side.c - FD related client side routines */
SQUIDCEXTERN void clientdbInit(void);
-SQUIDCEXTERN void clientdbUpdate(const IpAddress &, log_type, protocol_t, size_t);
+SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, protocol_t, size_t);
-SQUIDCEXTERN int clientdbCutoffDenied(const IpAddress &);
+SQUIDCEXTERN int clientdbCutoffDenied(const Ip::Address &);
void clientdbDump(StoreEntry *);
SQUIDCEXTERN void clientdbFreeMemory(void);
-SQUIDCEXTERN int clientdbEstablished(const IpAddress &, int);
+SQUIDCEXTERN int clientdbEstablished(const Ip::Address &, int);
SQUIDCEXTERN void clientOpenListenSockets(void);
SQUIDCEXTERN void clientHttpConnectionsClose(void);
SQUIDCEXTERN void httpRequestFree(void *);
SQUIDCEXTERN void idnsShutdown(void);
SQUIDCEXTERN void idnsALookup(const char *, IDNSCB *, void *);
-SQUIDCEXTERN void idnsPTRLookup(const IpAddress &, IDNSCB *, void *);
+SQUIDCEXTERN void idnsPTRLookup(const Ip::Address &, IDNSCB *, void *);
SQUIDCEXTERN void fd_close(int fd);
SQUIDCEXTERN void fd_open(int fd, unsigned int type, const char *);
SQUIDCEXTERN void filemapFreeMemory(fileMap *);
-SQUIDCEXTERN void fqdncache_nbgethostbyaddr(IpAddress &, FQDNH *, void *);
+SQUIDCEXTERN void fqdncache_nbgethostbyaddr(const Ip::Address &, FQDNH *, void *);
-SQUIDCEXTERN const char *fqdncache_gethostbyaddr(IpAddress &, int flags);
+SQUIDCEXTERN const char *fqdncache_gethostbyaddr(const Ip::Address &, int flags);
SQUIDCEXTERN void fqdncache_init(void);
SQUIDCEXTERN void fqdnStats(StoreEntry *);
SQUIDCEXTERN void fqdncacheReleaseInvalid(const char *);
-SQUIDCEXTERN const char *fqdnFromAddr(IpAddress &);
+SQUIDCEXTERN const char *fqdnFromAddr(const Ip::Address &);
SQUIDCEXTERN int fqdncacheQueueDrain(void);
SQUIDCEXTERN void fqdncacheFreeMemory(void);
SQUIDCEXTERN void fqdncache_restart(void);
SQUIDCEXTERN void snmpConnectionClose(void);
SQUIDCEXTERN const char * snmpDebugOid(oid * Name, snint Len, MemBuf &outbuf);
-SQUIDCEXTERN void addr2oid(IpAddress &addr, oid *Dest);
-SQUIDCEXTERN void oid2addr(oid *Dest, IpAddress &addr, u_int code);
+SQUIDCEXTERN void addr2oid(Ip::Address &addr, oid *Dest);
+SQUIDCEXTERN void oid2addr(oid *Dest, Ip::Address &addr, u_int code);
-SQUIDCEXTERN IpAddress *client_entry(IpAddress *current);
+SQUIDCEXTERN Ip::Address *client_entry(Ip::Address *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 *);
SQUIDCEXTERN void ipcache_init(void);
SQUIDCEXTERN void stat_ipcache_get(StoreEntry *);
SQUIDCEXTERN void ipcacheCycleAddr(const char *name, ipcache_addrs *);
-
-SQUIDCEXTERN void ipcacheMarkBadAddr(const char *name, IpAddress &);
-
-SQUIDCEXTERN void ipcacheMarkGoodAddr(const char *name, IpAddress &);
+SQUIDCEXTERN void ipcacheMarkBadAddr(const char *name, const Ip::Address &);
+SQUIDCEXTERN void ipcacheMarkGoodAddr(const char *name, const Ip::Address &);
SQUIDCEXTERN void ipcacheFreeMemory(void);
SQUIDCEXTERN ipcache_addrs *ipcacheCheckNumeric(const char *name);
SQUIDCEXTERN void ipcache_restart(void);
int *timeout);
SQUIDCEXTERN void neighborAddAcl(const char *, const char *);
-SQUIDCEXTERN void neighborsUdpAck(const cache_key *, icp_common_t *, const IpAddress &);
+SQUIDCEXTERN void neighborsUdpAck(const cache_key *, icp_common_t *, const Ip::Address &);
SQUIDCEXTERN void neighborAdd(const char *, const char *, int, int, int, int, int);
SQUIDCEXTERN void neighbors_init(void);
#if USE_HTCP
SQUIDCEXTERN void dump_peer_options(StoreEntry *, peer *);
SQUIDCEXTERN int peerHTTPOkay(const peer *, HttpRequest *);
-SQUIDCEXTERN peer *whichPeer(const IpAddress &from);
+SQUIDCEXTERN peer *whichPeer(const Ip::Address &from);
SQUIDCEXTERN void peerSelect(HttpRequest *, StoreEntry *, PSC *, void *data);
SQUIDCEXTERN void peerSelectInit(void);
SQUIDCEXTERN void peerDigestNotePeerGone(PeerDigest * pd);
SQUIDCEXTERN void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
-extern IpAddress getOutgoingAddr(HttpRequest * request, struct peer *dst_peer);
+extern Ip::Address getOutgoingAddr(HttpRequest * request, struct peer *dst_peer);
unsigned long getOutgoingTOS(HttpRequest * request);
SQUIDCEXTERN void urnStart(HttpRequest *, StoreEntry *);
const char *prog,
const char *const args[],
const char *name,
- IpAddress &local_addr,
+ Ip::Address &local_addr,
int *rfd,
int *wfd,
void **hIpc);
void *data;
char *orig_url;
- IpAddress client_addr;
+ Ip::Address client_addr;
const char *client_ident;
const char *method_s;
RH *handler;
LOCAL_ARRAY(char, tbuf, 256);
LOCAL_ARRAY(char, sndbuf, BUFSIZ);
- IpAddress S;
+ Ip::Address S;
char *host = Config.Announce.host;
char *file = NULL;
u_short port = Config.Announce.port;
{
variable_list *Answer = NULL;
- IpAddress laddr;
+ Ip::Address laddr;
char *cp = NULL;
peer *p = NULL;
int cnt = 0;
#define SNMP_REQUEST_SIZE 4096
#define MAX_PROTOSTAT 5
-IpAddress theOutSNMPAddr;
+Ip::Address theOutSNMPAddr;
typedef struct _mib_tree_entry mib_tree_entry;
typedef oid *(instance_Fn) (oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn);
snmpHandleUdp(int sock, void *not_used)
{
LOCAL_ARRAY(char, buf, SNMP_REQUEST_SIZE);
- IpAddress from;
+ Ip::Address from;
snmp_request_t *snmp_rq;
int len;
client_Inst(oid * name, snint * len, mib_tree_entry * current, oid_ParseFn ** Fn)
{
oid *instance = NULL;
- IpAddress laddr;
- IpAddress *aux;
+ Ip::Address laddr;
+ Ip::Address *aux;
int size = 0;
int newshift = 0;
oid == 32.1.50.239.162.33.251.20.50.0.0.0.0.0.0.0.0.0.1
*/
void
-addr2oid(IpAddress &addr, oid * Dest)
+addr2oid(Ip::Address &addr, oid * Dest)
{
u_int i ;
u_char *cp = NULL;
IPv6 adress : 20:01:32:ef:a2:21:fb:32:00:00:00:00:00:00:00:00:OO:01
*/
void
-oid2addr(oid * id, IpAddress &addr, u_int size)
+oid2addr(oid * id, Ip::Address &addr, u_int size)
{
struct in_addr iaddr;
u_int i;
long reqid;
int outlen;
- IpAddress from;
+ Ip::Address from;
struct snmp_pdu *PDU;
ACLChecklist *acl_checklist;
acl_address *next;
ACLList *aclList;
- IpAddress addr;
+ Ip::Address addr;
};
struct acl_tos {
#include "icmp/IcmpConfig.h"
#endif
-#if USE_ZPH_QOS
-#include "ip/QosConfig.h"
-#endif
-
#include "HelperChildConfig.h"
/* forward decl for SquidConfig, see RemovalPolicy.h */
#if USE_WCCP
struct {
-
- IpAddress router;
-
- IpAddress address;
+ Ip::Address router;
+ Ip::Address address;
int version;
} Wccp;
#endif
#if USE_WCCPv2
struct {
- IpAddress_list *router;
-
- IpAddress address;
+ Ip::Address_list *router;
+ Ip::Address address;
int forwarding_method;
int return_method;
int assignment_method;
struct {
- IpAddress udp_incoming;
-
- IpAddress udp_outgoing;
+ Ip::Address udp_incoming;
+ Ip::Address udp_outgoing;
#if SQUID_SNMP
-
- IpAddress snmp_incoming;
-
- IpAddress snmp_outgoing;
+ Ip::Address snmp_incoming;
+ Ip::Address snmp_outgoing;
#endif
/* FIXME INET6 : this should really be a CIDR value */
- IpAddress client_netmask;
+ Ip::Address client_netmask;
} Addrs;
size_t tcpRcvBufsz;
size_t udpMaxHitObjsz;
struct {
- IpAddress addr;
+ Ip::Address addr;
int ttl;
unsigned short port;
char *encode_key;
time_t minimum_expiry_time; /* seconds */
external_acl *externalAclHelperList;
-#if USE_ZPH_QOS
- QosConfig zph;
-#endif
-
#if USE_SSL
struct {
};
struct _ipcache_addrs {
- IpAddress *in_addrs;
+ Ip::Address *in_addrs;
unsigned char *bad_mask;
unsigned char count;
unsigned char cur;
char *host;
peer_t type;
- IpAddress in_addr;
+ Ip::Address in_addr;
struct {
int pings_sent;
int tcp_up; /* 0 if a connect() fails */
- IpAddress addresses[10];
+ Ip::Address addresses[10];
int n_addresses;
int rr_count;
peer *next;
/* bah, cheating on stub count */
pid_t
-ipcCreate(int type, const char *prog, const char *const args[], const char *name, IpAddress &local_addr, int *rfd, int *wfd, void **hIpc)
+ipcCreate(int type, const char *prog, const char *const args[], const char *name, Ip::Address &local_addr, int *rfd, int *wfd, void **hIpc)
{
fatal ("Not implemented");
return -1;
LOCAL_ARRAY(char, host, SQUIDHOSTNAMELEN + 1);
static int present = 0;
struct addrinfo *AI = NULL;
- IpAddress sa;
+ Ip::Address sa;
if (Config.visibleHostname != NULL)
return Config.visibleHostname;
void
keepCapabilities(void)
{
-#if HAVE_PRCTL && defined(PR_SET_KEEPCAPS) && USE_LIBCAP
+#if USE_LIBCAP && HAVE_PRCTL && defined(PR_SET_KEEPCAPS)
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
- IpInterceptor.StopTransparency("capability setting has failed.");
+ Ip::Interceptor.StopTransparency("capability setting has failed.");
}
#endif
}
else
caps = cap_init();
if (!caps) {
- IpInterceptor.StopTransparency("Can't get current capabilities");
+ Ip::Interceptor.StopTransparency("Can't get current capabilities");
} else {
int ncaps = 0;
int rc = 0;
cap_value_t cap_list[10];
cap_list[ncaps++] = CAP_NET_BIND_SERVICE;
- if (IpInterceptor.TransparentActive()) {
+ if (Ip::Interceptor.TransparentActive()) {
cap_list[ncaps++] = CAP_NET_ADMIN;
#if LINUX_TPROXY2
cap_list[ncaps++] = CAP_NET_BROADCAST;
rc |= cap_set_flag(caps, CAP_PERMITTED, ncaps, cap_list, CAP_SET);
if (rc || cap_set_proc(caps) != 0) {
- IpInterceptor.StopTransparency("Error enabling needed capabilities.");
+ Ip::Interceptor.StopTransparency("Error enabling needed capabilities.");
}
cap_free(caps);
}
#elif defined(_SQUID_LINUX_)
- IpInterceptor.StopTransparency("Missing needed capability support.");
+ Ip::Interceptor.StopTransparency("Missing needed capability support.");
#endif /* HAVE_SYS_CAPABILITY_H */
}
statCounter.server.all.requests++;
statCounter.server.other.requests++;
/* Create socket. */
- IpAddress temp = getOutgoingAddr(request,NULL);
+ Ip::Address temp = getOutgoingAddr(request,NULL);
int flags = COMM_NONBLOCKING;
if (request->flags.spoof_client_ip) {
flags |= COMM_TRANSPARENT;
unlinkdInit(void)
{
const char *args[2];
- IpAddress localhost;
+ Ip::Address localhost;
args[0] = "(unlinkd)";
args[1] = NULL;
};
struct wccp_cache_entry_t {
- IpAddress ip_addr;
+ struct in_addr ip_addr; // WCCP on-the-wire in 32-bit IPv4-only.
int revision;
char hash[WCCP_HASH_SIZE];
int reserved;
};
struct wccp_i_see_you_t {
- int type;
- int version;
- int change;
- int id;
- int number;
+ int32_t type;
+ int32_t version;
+ int32_t change;
+ int32_t id;
+ int32_t number;
struct wccp_cache_entry_t wccp_cache_entry[WCCP_ACTIVE_CACHES];
};
static int last_assign_buckets_change;
static unsigned int number_caches;
-static IpAddress local_ip;
+static Ip::Address local_ip;
static PF wccpHandleUdp;
static int wccpLowestIP(void);
static void
wccpHandleUdp(int sock, void *not_used)
{
-
- IpAddress from;
+ Ip::Address from;
int len;
debugs(80, 6, "wccpHandleUdp: Called.");
for (loop = 0; loop < (unsigned) ntohl(wccp_i_see_you.number); loop++) {
assert(loop < WCCP_ACTIVE_CACHES);
- if (wccp_i_see_you.wccp_cache_entry[loop].ip_addr < local_ip)
+ if (local_ip >= wccp_i_see_you.wccp_cache_entry[loop].ip_addr)
return 0;
- if (wccp_i_see_you.wccp_cache_entry[loop].ip_addr == local_ip)
+ if (local_ip == wccp_i_see_you.wccp_cache_entry[loop].ip_addr)
found = 1;
}
void
wccp2Init(void)
{
- IpAddress_list *s;
+ Ip::Address_list *s;
char *ptr;
uint32_t service_flags;
commSetSelect(sock, COMM_SELECT_READ, wccp2HandleUdp, NULL, 0);
/* FIXME INET6 : drop conversion boundary */
- IpAddress from_tmp;
+ Ip::Address from_tmp;
len = comm_udp_recvfrom(sock,
&wccp2_i_see_you,
struct wccp2_mask_identity_info_t *wccp2_mask_identity_info_ptr;
- IpAddress router;
+ Ip::Address router;
debugs(80, 6, "wccp2HereIam: Called");
if (wccp2_numrouters > 1) {
/* FIXME INET6 : drop temp conversion */
- IpAddress tmp_rtr(router);
+ Ip::Address tmp_rtr(router);
comm_udp_sendto(theWccp2Connection,
tmp_rtr,
&wccp_packet,
int new_socket;
fde *F = NULL;
- IpAddress localhost;
- IpAddress handle0;
- IpAddress handle1;
+ Ip::Address localhost;
+ Ip::Address handle0;
+ Ip::Address handle1;
struct addrinfo *AI = NULL;
localhost.SetLocalhost();
char ipbuf[MAX_IPSTRLEN];
struct addrinfo *AI = NULL;
- IpAddress S;
+ Ip::Address S;
int s;
int l;
typedef void SIGHDLR(int sig);
/* Local functions */
-static int client_comm_bind(int, const IpAddress &);
+static int client_comm_bind(int, const Ip::Address &);
-static int client_comm_connect(int, const IpAddress &, struct timeval *);
+static int client_comm_connect(int, const Ip::Address &, struct timeval *);
static void usage(const char *progname);
static int Now(struct timeval *);
int opt_noaccept = 0;
int opt_verbose = 0;
const char *hostname, *localhost;
- IpAddress iaddr;
+ Ip::Address iaddr;
char url[BUFSIZ], msg[MESSAGELEN], buf[BUFSIZ];
char extra_hdrs[HEADERLEN];
const char *method = "GET";
}
static int
-client_comm_bind(int sock, const IpAddress &addr)
+client_comm_bind(int sock, const Ip::Address &addr)
{
int res;
}
static int
-client_comm_connect(int sock, const IpAddress &addr, struct timeval *tvp)
+client_comm_connect(int sock, const Ip::Address &addr, struct timeval *tvp)
{
int res;
static struct addrinfo *AI = NULL;