PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ipacl.h
Go to the documentation of this file.
1 /*
2  * ipacl.h
3  *
4  * IP Access Control Lists
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 1998-2002 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 24177 $
27  * $Author: rjongbloed $
28  * $Date: 2010-04-05 21:52:04 +1000 (Mon, 05 Apr 2010) $
29  */
30 
31 #ifndef PTLIB_IPACL_H
32 #define PTLIB_IPACL_H
33 
34 
35 #include <ptlib/sockets.h>
36 
37 
41 {
43 
44  public:
50  PIPSocket::Address addr,
52  PBoolean allow
53  );
55  const PString & description
56  );
57 
63  const PString & pstr
64  );
66  const char * cstr
67  );
68 
75  virtual Comparison Compare(
76  const PObject & obj
77  ) const;
78 
82  virtual void PrintOn(
83  ostream &strm
84  ) const;
85 
90  virtual void ReadFrom(
91  istream &strm
92  );
93 
100  PString AsString() const;
101 
107  PBoolean IsValid();
108 
128  PBoolean Parse(
129  const PString & description
130  );
131 
132 
139  PBoolean Match(
141  );
142 
145  const PString & GetDomain() const { return domain; }
146 
149  const PIPSocket::Address & GetAddress() const { return address; }
150 
153  const PIPSocket::Address & GetMask() const { return mask; }
154 
157  PBoolean IsAllowed() const { return allowed; }
158 
161  PBoolean IsHidden() const { return hidden; }
162 
163  protected:
169 };
170 
171 PSORTED_LIST(PIpAccessControlList_base, PIpAccessControlEntry);
172 
173 
187 class PIpAccessControlList : public PIpAccessControlList_base
188 {
189 
190  PCLASSINFO(PIpAccessControlList, PIpAccessControlList_base)
191 
192  public:
197  );
198 
214  const char * daemonName = NULL
215  );
216 
217 #ifdef P_CONFIG_FILE
218 
226  PBoolean Load(
227  PConfig & cfg
228  );
229 
239  PBoolean Load(
240  PConfig & cfg,
241  const PString & baseName
242  );
243 
247  void Save(
248  PConfig & cfg
249  );
250 
256  void Save(
257  PConfig & cfg,
258  const PString & baseName
259  );
260 
261 #endif // P_CONFIG_FILE
262 
270  PBoolean Add(
271  PIpAccessControlEntry * entry
272  );
273  PBoolean Add(
274  const PString & description
275  );
276  PBoolean Add(
277  PIPSocket::Address address,
278  PIPSocket::Address mask,
279  PBoolean allow
280  );
281 
290  const PString & description
291  );
293  PIPSocket::Address address,
294  PIPSocket::Address mask
295  );
296 
297 
305  const PString & description
306  );
307 
311  PIPSocket::Address address
312  ) const;
313 
327  PTCPSocket & socket
328  ) const;
330  PIPSocket::Address address
331  ) const;
332 
333 
337 
340  void SetDefaultAllowance(PBoolean defAllow) { defaultAllowance = defAllow; }
341 
342  private:
343  PBoolean InternalLoadHostsAccess(const PString & daemon, const char * file, PBoolean allow);
344  PBoolean InternalRemoveEntry(PIpAccessControlEntry & entry);
345 
346  protected:
348 };
349 
350 
351 #endif // PTLIB_IPACL_H
352 
353 
354 // End of File ///////////////////////////////////////////////////////////////