Ip.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_ACL_IP_H
10 #define SQUID_SRC_ACL_IP_H
11 
12 #include "acl/Data.h"
13 #include "acl/Node.h"
14 #include "ip/Address.h"
15 #include "splay.h"
16 
18 {
20 
21 public:
22  static acl_ip_data *FactoryParse(char const *);
23 
24  acl_ip_data ();
25 
26  acl_ip_data (Ip::Address const &, Ip::Address const &, Ip::Address const &, acl_ip_data *);
27  void toStr(char *buf, int len) const;
28  SBuf toSBuf() const;
29 
31  Ip::Address firstAddress() const;
32 
34  Ip::Address lastAddress() const;
35 
37 
39 
40  Ip::Address mask; // TODO: should use a CIDR range
41 
44 private:
45 
46  static bool DecodeMask(const char *asc, Ip::Address &mask, int string_format_type);
47 
48  bool containsVetted(const Ip::Address &needle) const;
49 };
50 
51 class ACLIP : public Acl::Node
52 {
53 public:
54  void *operator new(size_t);
55  void operator delete(void *);
56 
57  ACLIP() : data(nullptr) {}
58  ~ACLIP() override;
59 
61 
62  char const *typeString() const override = 0;
63  void parse() override;
64  // virtual bool isProxyAuth() const {return true;}
65  int match(ACLChecklist *checklist) override = 0;
66  SBufList dump() const override;
67  bool empty () const override;
68 
69 protected:
70 
71  int match(const Ip::Address &);
73 
74 private:
75  bool parseGlobal(const char *);
76 
78  bool matchAnyIpv4 = false;
79 
81  bool matchAnyIpv6 = false;
82 };
83 
84 #endif /* SQUID_SRC_ACL_IP_H */
85 
IPSplay * data
Definition: Ip.h:72
SBuf toSBuf() const
Definition: Ip.cc:75
bool empty() const override
Definition: Ip.cc:525
bool parseGlobal(const char *)
Definition: Ip.cc:426
std::list< SBuf > SBufList
Definition: forward.h:22
const char * typeString() const override=0
Definition: SBuf.h:93
Ip::Address mask
Definition: Ip.h:40
Ip::Address addr2
Definition: Ip.h:38
int const char size_t
Definition: stub_liblog.cc:83
ACLIP()
Definition: Ip.h:57
void toStr(char *buf, int len) const
Definition: Ip.cc:44
Definition: splay.h:49
Definition: Ip.h:51
Ip::Address lastAddress() const
maximum (masked) address that matches this configured ACL value
Definition: Ip.cc:93
bool matchAnyIpv6
whether match() should return 1 for any IPv6 parameter
Definition: Ip.h:81
Ip::Address addr1
Definition: Ip.h:36
bool containsVetted(const Ip::Address &needle) const
whether we have parsed and vetted an item with an addr1 field that matches the needle
Definition: Ip.cc:219
Splay< acl_ip_data * > IPSplay
Definition: Ip.h:60
SBufList dump() const override
Definition: Ip.cc:509
int match(ACLChecklist *checklist) override=0
Matches the actual data in checklist against this Acl::Node.
static bool DecodeMask(const char *asc, Ip::Address &mask, int string_format_type)
Definition: Ip.cc:176
Definition: Node.h:25
~ACLIP() override
Definition: Ip.cc:493
Definition: Ip.h:17
Ip::Address firstAddress() const
minimum (masked) address that matches this configured ACL value
Definition: Ip.cc:84
bool matchAnyIpv4
whether match() should return 1 for any IPv4 parameter
Definition: Ip.h:78
acl_ip_data()
Definition: Ip.cc:567
acl_ip_data * next
Definition: Ip.h:42
static acl_ip_data * FactoryParse(char const *)
Definition: Ip.cc:244
void parse() override
parses node representation in squid.conf; dies on failures
Definition: Ip.cc:472
MEMPROXY_CLASS(acl_ip_data)

 

Introduction

Documentation

Support

Miscellaneous