]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ACL.h
Summary: Merge further ACL refactoring (including bugfixes)
[thirdparty/squid.git] / src / ACL.h
1
2 /*
3 * $Id: ACL.h,v 1.4 2003/02/13 08:07:46 robertc Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 *
33 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 */
35
36 #ifndef SQUID_ACL_H
37 #define SQUID_ACL_H
38 #include "splay.h"
39 #include "Array.h"
40
41 /* As ACL's get refactored, these probably need better homes */
42
43 #if USE_SSL
44 class acl_cert_data {
45 public:
46 void *operator new(size_t);
47 void operator delete(void *);
48 virtual void deleteSelf() const;
49 SplayNode<char*> *values;
50 char *attribute;
51 private:
52 static MemPool *Pool;
53 };
54 #endif
55
56 /* acl.c */
57 SQUIDCEXTERN int aclMatchAclList(const acl_list * list, ACLChecklist * checklist);
58 SQUIDCEXTERN void aclDestroyAccessList(acl_access **list);
59 SQUIDCEXTERN void aclDestroyAcls(acl **);
60 SQUIDCEXTERN void aclDestroyAclList(acl_list **);
61 SQUIDCEXTERN void aclParseAccessLine(acl_access **);
62 SQUIDCEXTERN void aclParseAclList(acl_list **);
63 SQUIDCEXTERN int aclIsProxyAuth(const char *name);
64 SQUIDCEXTERN err_type aclGetDenyInfoPage(acl_deny_info_list ** head, const char *name);
65 SQUIDCEXTERN void aclParseDenyInfoLine(struct _acl_deny_info_list **);
66 SQUIDCEXTERN void aclDestroyDenyInfoList(struct _acl_deny_info_list **);
67 SQUIDCEXTERN void aclDestroyRegexList(struct _relist *data);
68 SQUIDCEXTERN int aclMatchRegex(relist * data, const char *word);
69 wordlist *aclDumpRegexList(relist * data);
70 SQUIDCEXTERN void aclParseRegexList(void *curlist);
71 SQUIDCEXTERN wordlist *aclDumpGeneric(const acl *);
72 SQUIDCEXTERN int aclPurgeMethodInUse(acl_access *);
73 SQUIDCEXTERN void aclCacheMatchFlush(dlink_list * cache);
74 extern void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head);
75 IPH aclLookupDstIPforASNDone;
76 #if USE_IDENT
77 IDCB aclLookupIdentDone;
78 #endif
79 FQDNH aclLookupSrcFQDNDone;
80 FQDNH aclLookupDstFQDNDone;
81
82 class ACL {
83 public:
84 void *operator new(size_t);
85 void operator delete(void *);
86 virtual void deleteSelf() const;
87
88 static ACL *Factory (char const *);
89 static void ParseAclLine(acl ** head);
90 static ACL* FindByName(const char *name);
91
92 /* temporary until we subclass external acl's */
93 static void ExternalAclLookup(ACLChecklist * ch, ACL *, EAH * callback, void *callback_data);
94
95 ACL();
96 ACL (squid_acl const);
97 virtual ~ACL();
98 virtual ACL *clone()const;
99 virtual void parse();
100 virtual char const *typeString() const;
101 virtual squid_acl aclType() const { return type;}
102 virtual bool isProxyAuth() const;
103 virtual bool requiresRequest() const;
104 virtual int match(ACLChecklist * checklist);
105 virtual wordlist *dumpGeneric() const;
106 virtual wordlist *dump() const;
107 virtual bool valid () const;
108 int checklistMatches(ACLChecklist *);
109
110 /* only relevant to METHOD acl's */
111 virtual bool containsPURGE() const;
112
113 /* only relecant to ASN acl's */
114 void startCache();
115
116 int cacheMatchAcl(dlink_list * cache, ACLChecklist *);
117 virtual int matchForCache(ACLChecklist *checklist);
118
119 char name[ACL_NAME_SZ];
120 char *cfgline;
121 ACL *next;
122 private:
123 static MemPool *Pool;
124 squid_acl type;
125 protected:
126 void *data;
127 class Prototype {
128 public:
129 Prototype ();
130 Prototype (ACL const *, char const *);
131 ~Prototype();
132 static bool Registered(char const *);
133 static ACL *Factory (char const *);
134 private:
135 ACL const*prototype;
136 char const *typeString;
137 private:
138 static Vector<Prototype const *> * Registry;
139 static void *Initialized;
140 typedef Vector<Prototype const*>::iterator iterator;
141 typedef Vector<Prototype const*>::const_iterator const_iterator;
142 void registerMe();
143 };
144 };
145
146 class acl_access {
147 public:
148 void *operator new(size_t);
149 void operator delete(void *);
150 virtual void deleteSelf() const;
151 bool containsPURGE() const;
152 allow_t allow;
153 acl_list *aclList;
154 char *cfgline;
155 acl_access *next;
156 private:
157 CBDATA_CLASS(acl_access);
158 };
159
160 class ACLList {
161 public:
162 void *operator new(size_t);
163 void operator delete(void *);
164 virtual void deleteSelf() const;
165
166 ACLList();
167 void negated(bool isNegated);
168 bool matches (ACLChecklist *)const;
169 int op;
170 acl *_acl;
171 ACLList *next;
172 private:
173 static MemPool *Pool;
174 };
175
176 typedef ACLList acl_list;
177 #endif /* SQUID_ACL_H */