]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Ip.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / acl / Ip.h
1 /*
2 * Copyright (C) 1996-2014 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_ACLIP_H
10 #define SQUID_ACLIP_H
11
12 #include "acl/Acl.h"
13 #include "acl/Data.h"
14 #include "ip/Address.h"
15 #include "splay.h"
16
17 /// \ingroup ACLAPI
18 class acl_ip_data
19 {
20
21 public:
22 MEMPROXY_CLASS(acl_ip_data);
23 static acl_ip_data *FactoryParse(char const *);
24 static int NetworkCompare(acl_ip_data * const & a, acl_ip_data * const &b);
25
26 acl_ip_data ();
27
28 acl_ip_data (Ip::Address const &, Ip::Address const &, Ip::Address const &, acl_ip_data *);
29 void toStr(char *buf, int len) const;
30 SBuf toSBuf() const;
31
32 Ip::Address addr1;
33
34 Ip::Address addr2;
35
36 Ip::Address mask; /**< \todo This should perhapse be stored as a CIDR range now instead of a full IP mask. */
37
38 acl_ip_data *next; /**< used for parsing, not for storing */
39
40 private:
41
42 static bool DecodeMask(const char *asc, Ip::Address &mask, int string_format_type);
43 };
44
45 MEMPROXY_CLASS_INLINE(acl_ip_data);
46
47 /// \ingroup ACLAPI
48 class ACLIP : public ACL
49 {
50
51 public:
52 void *operator new(size_t);
53 void operator delete(void *);
54
55 ACLIP() : data(NULL) {}
56 explicit ACLIP(const ACLFlag flgs[]) : ACL(flgs), data(NULL) {}
57
58 ~ACLIP();
59
60 typedef SplayNode<acl_ip_data *> IPSplay;
61
62 virtual char const *typeString() const = 0;
63 virtual void parse();
64 // virtual bool isProxyAuth() const {return true;}
65 virtual int match(ACLChecklist *checklist) = 0;
66 virtual SBufList dump() const;
67 virtual bool empty () const;
68
69 protected:
70
71 int match(Ip::Address &);
72 IPSplay *data;
73
74 private:
75 static void DumpIpListWalkee(acl_ip_data * const & ip, void *state);
76 };
77
78 #endif /* SQUID_ACLIP_H */