]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ACL.h
Summary: Merge of ACL refactoring.
[thirdparty/squid.git] / src / ACL.h
1
2 /*
3 * $Id: ACL.h,v 1.3 2003/02/12 06:10:58 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 SQUIDCEXTERN void aclParseRegexList(void *curlist);
70 SQUIDCEXTERN wordlist *aclDumpGeneric(const acl *);
71 SQUIDCEXTERN int aclPurgeMethodInUse(acl_access *);
72 SQUIDCEXTERN void aclCacheMatchFlush(dlink_list * cache);
73 SQUIDCEXTERN int aclAuthenticated(ACLChecklist * checklist);
74 void dump_acl_access(StoreEntry * entry, const char *name, acl_access * head);
75
76 class ACL {
77 public:
78 void *operator new(size_t);
79 void operator delete(void *);
80 virtual void deleteSelf() const;
81
82 static ACL *Factory (char const *);
83 static void ParseAclLine(acl ** head);
84
85 ACL();
86 ACL (squid_acl const);
87 virtual ~ACL();
88 virtual ACL *clone()const;
89 virtual void parse();
90 virtual char const *typeString() const;
91 virtual squid_acl aclType() const { return type;}
92 virtual bool isProxyAuth() const;
93 virtual bool requiresRequest() const;
94 virtual int match(ACLChecklist * checklist);
95 virtual wordlist *dumpGeneric() const;
96 virtual wordlist *dump() const;
97 virtual bool valid () const;
98 virtual void startExternal(ACLChecklist *);
99 int checklistMatches(ACLChecklist *);
100
101 /* only relevant to METHOD acl's */
102 virtual bool containsPURGE() const;
103
104 /* only relecant to ASN acl's */
105 void startCache();
106
107
108 char name[ACL_NAME_SZ];
109 char *cfgline;
110 ACL *next;
111 private:
112 static MemPool *Pool;
113 squid_acl type;
114 protected:
115 void *data;
116 class Prototype {
117 public:
118 Prototype ();
119 Prototype (ACL const *, char const *);
120 ~Prototype();
121 static bool Registered(char const *);
122 static ACL *Factory (char const *);
123 private:
124 ACL const*prototype;
125 char const *typeString;
126 private:
127 static Vector<Prototype const *> * Registry;
128 static void *Initialized;
129 typedef Vector<Prototype const*>::iterator iterator;
130 typedef Vector<Prototype const*>::const_iterator const_iterator;
131 void registerMe();
132 };
133 };
134
135 class acl_access {
136 public:
137 void *operator new(size_t);
138 void operator delete(void *);
139 virtual void deleteSelf() const;
140 bool containsPURGE() const;
141 allow_t allow;
142 acl_list *aclList;
143 char *cfgline;
144 acl_access *next;
145 private:
146 CBDATA_CLASS(acl_access);
147 };
148
149 class ACLList {
150 public:
151 void *operator new(size_t);
152 void operator delete(void *);
153 virtual void deleteSelf() const;
154
155 ACLList();
156 void negated(bool isNegated);
157 bool matches (ACLChecklist *)const;
158 int op;
159 acl *_acl;
160 ACLList *next;
161 private:
162 static MemPool *Pool;
163 };
164
165 typedef ACLList acl_list;
166 #endif /* SQUID_ACL_H */