27 fatal (
"ACLIP::operator new: unused");
32ACLIP::operator
delete (
void *)
34 fatal (
"ACLIP::operator delete: unused");
69 snprintf(&(b3[1]), (len-rlen),
"%u", (
unsigned int)(cidr<0?0:cidr) );
78 static char tmpbuf[ bufsz ];
105 if (a->lastAddress() < b->firstAddress())
108 if (a->firstAddress() > b->lastAddress())
118 return b->firstAddress() <= a->firstAddress() && a->lastAddress() <= b->lastAddress();
125 const auto minLeft = std::min(a->firstAddress(), b->firstAddress());
126 const auto maxRight = std::max(a->lastAddress(), b->lastAddress());
154 debugs(28,9,
"aclIpAddrNetworkCompare: compare: " << p->
addr1 <<
"/" << q->
mask <<
" (" << A <<
") vs " <<
163 if ( (A >= q->
addr1) && (A <= q->addr2) )
189 if ((sscanf(asc,
"%d%c", &a1, &junk)==1) &&
190 (a1 <= 128) && (a1 >= 0)
199 debugs(28,
DBG_CRITICAL,
"WARNING: Netmasks are deprecated. Please use CIDR masks instead.");
205 debugs(28,
DBG_CRITICAL,
"WARNING: IPv4 netmasks are particularly nasty when used to compare IPv6 to IPv4 ranges.");
206 debugs(28,
DBG_CRITICAL,
"WARNING: For now we will assume you meant to write /" << m);
225 for (
const auto *i =
this; i && i->next; i = i->next) {
226 if (i->addr1 == needle)
233#define SCAN_ACL1_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]/%[0123456789]"
234#define SCAN_ACL2_6 "%[0123456789ABCDEFabcdef:]-%[0123456789ABCDEFabcdef:]%c"
235#define SCAN_ACL3_6 "%[0123456789ABCDEFabcdef:]/%[0123456789]"
236#define SCAN_ACL4_6 "%[0123456789ABCDEFabcdef:]/%c"
238#define SCAN_ACL1_4 "%[0123456789.]-%[0123456789.]/%[0123456789.]"
239#define SCAN_ACL2_4 "%[0123456789.]-%[0123456789.]%c"
240#define SCAN_ACL3_4 "%[0123456789.]/%[0123456789.]"
241#define SCAN_ACL4_4 "%[0123456789.]/%c"
253 unsigned int changed;
255 int iptype = AF_UNSPEC;
257 debugs(28, 5,
"aclIpParseIpData: " << t);
261 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN1-v4: " <<
SCAN_ACL1_4);
264 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN2-v4: " <<
SCAN_ACL2_4);
268 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN3-v4: " <<
SCAN_ACL3_4);
272 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN4-v4: " <<
SCAN_ACL4_4);
279 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN1-v6: " <<
SCAN_ACL1_6);
282 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN2-v6: " <<
SCAN_ACL2_6);
286 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN3-v6: " <<
SCAN_ACL3_6);
290 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: SCAN4-v6: " <<
SCAN_ACL4_6);
295 }
else if (sscanf(t,
"%[^/]/%s",
addr1,
mask) == 2) {
296 debugs(28, 9,
"aclIpParseIpData: '" << t <<
"' matched: non-IP pattern: %[^/]/%s");
298 }
else if (sscanf(t,
"%s",
addr1) == 1) {
305 debugs(28, 5,
"aclIpParseIpData: Lookup Host/IP " <<
addr1);
306 struct addrinfo *hp =
nullptr, *x =
nullptr;
307 struct addrinfo hints;
309 memset(&hints, 0,
sizeof(
struct addrinfo));
311 int errcode = getaddrinfo(
addr1,
nullptr,&hints,&hp);
314 if (strcmp(
addr1,
"::1") == 0) {
315 debugs(28,
DBG_IMPORTANT,
"aclIpParseIpData: IPv6 has not been enabled in host DNS resolver.");
318 "' in '" << t <<
"', flags=" << hints.ai_flags <<
319 " : (" << errcode <<
") " << gai_strerror(errcode) );
327 for (x = hp; x !=
nullptr;) {
328 if ((r = *Q) ==
nullptr)
335 debugs(28, 3,
"aclIpParseIpData: Duplicate host/IP: '" << r->
addr1 <<
"' dropped.");
341 debugs(28, 3,
"aclIpParseIpData: Located host/IP: '" << r->
addr1 <<
"'");
363 if ( iptype == AF_INET6 && !Ip::EnableIpv6) {
371 debugs(28,
DBG_CRITICAL,
"ERROR: aclIpParseIpData: unknown first address in '" << t <<
"'");
381 debugs(28,
DBG_CRITICAL,
"ERROR: aclIpParseIpData: unknown second address in '" << t <<
"'");
400 debugs(28,
DBG_CRITICAL,
"WARNING: aclIpParseIpData: Netmask masks away part of the specified IP in '" << t <<
"'");
429 if (strcmp(token,
"all") == 0) {
430 debugs(28, 8,
"found " << token);
438 if (strcmp(token,
"ipv4") == 0) {
439 debugs(28, 8,
"found " << token);
446 if (strcmp(token,
"ipv6") == 0) {
447 debugs(28, 8,
"found " << token);
455 if (strcmp(token,
"0/0") == 0 ||
456 strcmp(token,
"0.0.0.0/0") == 0 ||
457 strcmp(token,
"0.0.0.0/0.0.0.0") == 0 ||
458 strcmp(token,
"0.0.0.0-255.255.255.255") == 0 ||
459 strcmp(token,
"0.0.0.0-0.0.0.0/0") == 0) {
461 debugs(28,
DBG_CRITICAL,
"ERROR: '" << token <<
"' needs to be replaced by the term 'all'.");
462 debugs(28,
DBG_CRITICAL,
"SECURITY NOTICE: Overriding config setting. Using 'all' instead.");
483 while (q !=
nullptr) {
535 debugs(28, 3, clientip <<
" found, matched 'all'");
539 debugs(28, 3, clientip <<
" found, matched 'ipv4'");
545 debugs(28, 3, clientip <<
" found, matched 'ipv6'");
558 ClientAddress.
addr1 = clientip;
563 debugs(28, 3,
"aclIpMatchIp: '" << clientip <<
"' " << (result ?
"found" :
"NOT found"));
564 return (result !=
nullptr);
static std::ostream & operator<<(std::ostream &os, acl_ip_data *value)
reports acl_ip_data using squid.conf ACL value format
static int aclIpAddrNetworkCompare(acl_ip_data *const &p, acl_ip_data *const &q)
bool matchAnyIpv4
whether match() should return 1 for any IPv4 parameter
SBufList dump() const override
Splay< acl_ip_data * > IPSplay
bool parseGlobal(const char *)
void parse() override
parses node representation in squid.conf; dies on failures
bool matchAnyIpv6
whether match() should return 1 for any IPv6 parameter
bool empty() const override
int match(ACLChecklist *checklist) override=0
Matches the actual data in checklist against this Acl::Node.
static Value MakeCombinedValue(const Value &a, const Value &b)
static int Compare(const Value &a, const Value &b)
static bool IsSubset(const Value &a, const Value &b)
static void Merge(Splay< Value > &, Value &&)
static char * strtokFile()
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
static const Address & NoAddr()
int matchIPAddr(const Address &rhs) const
void turnMaskedBitsOn(const Address &mask)
int applyMask(const Address &mask)
void setAnyAddr()
NOTE: Does NOT clear the Port stored. Only the Address and Type.
Value const * find(FindValue const &, int(*compare)(FindValue const &a, Value const &b)) const
void visit(ValueVisitor &) const
left-to-right visit of all stored Values
void destroy(SPLAYFREE *=DefaultFree)
Ip::Address lastAddress() const
maximum (masked) address that matches this configured ACL value
Ip::Address firstAddress() const
minimum (masked) address that matches this configured ACL value
static bool DecodeMask(const char *asc, Ip::Address &mask, int string_format_type)
bool containsVetted(const Ip::Address &needle) const
whether we have parsed and vetted an item with an addr1 field that matches the needle
static acl_ip_data * FactoryParse(char const *)
void toStr(char *buf, int len) const
#define debugs(SECTION, LEVEL, CONTENT)
void fatal(const char *message)
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
std::list< SBuf > SBufList
#define LOCAL_ARRAY(type, name, size)
void operator()(acl_ip_data *const &ip)