PTLib
Version 2.14.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
40
class
PIpAccessControlEntry
:
public
PObject
41
{
42
PCLASSINFO
(
PIpAccessControlEntry
,
PObject
)
43
44
public
:
49
PIpAccessControlEntry
(
50
PIPSocket::Address
addr,
51
PIPSocket::Address
msk,
52
PBoolean
allow
53
);
54
PIpAccessControlEntry
(
55
const
PString
& description
56
);
57
62
PIpAccessControlEntry
&
operator=
(
63
const
PString
& pstr
64
);
65
PIpAccessControlEntry
&
operator=
(
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
(
140
PIPSocket::Address
&
address
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
:
164
PString
domain
;
165
PIPSocket::Address
address
;
166
PIPSocket::Address
mask
;
167
PBoolean
allowed
;
168
PBoolean
hidden
;
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
:
195
PIpAccessControlList
(
196
PBoolean
defaultAllowance
=
true
197
);
198
213
PBoolean
LoadHostsAccess
(
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
289
PBoolean
Remove
(
290
const
PString
& description
291
);
292
PBoolean
Remove
(
293
PIPSocket::Address
address,
294
PIPSocket::Address
mask
295
);
296
297
304
virtual
PIpAccessControlEntry
*
CreateControlEntry
(
305
const
PString
& description
306
);
307
310
PIpAccessControlEntry
*
Find
(
311
PIPSocket::Address
address
312
)
const
;
313
326
PBoolean
IsAllowed
(
327
PTCPSocket
& socket
328
)
const
;
329
PBoolean
IsAllowed
(
330
PIPSocket::Address
address
331
)
const
;
332
333
336
PBoolean
GetDefaultAllowance
()
const
{
return
defaultAllowance
; }
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
:
347
PBoolean
defaultAllowance
;
348
};
349
350
351
#endif // PTLIB_IPACL_H
352
353
354
// End of File ///////////////////////////////////////////////////////////////
include
ptclib
ipacl.h
Generated on Fri Oct 10 2014 21:15:13 for PTLib by
1.8.3.1