Policy Class Reference

#include <policy.h>

List of all members.

Public Types

enum  Action { Accept, Reject }
enum  SpecialPolicy { AcceptAll, RejectAll }

Public Member Functions

 Policy ()
 Policy (QString policy)
 Policy (QString action, QString address, QString ports)
 Policy (SpecialPolicy policy)
 Policy (Action action, QHostAddress addr, uchar mask, quint16 fromPort, quint16 toPort=0)
bool operator== (const Policy &policy) const
void fromString (QString policy)
QString toString ()
QString action ()
QString address ()
QString ports ()

Static Public Member Functions

static Action toAction (QString action)

Private Attributes

Action _action
QHostAddress _address
quint16 _fromPort
quint16 _toPort
uchar _mask


Detailed Description

Definition at line 36 of file policy.h.


Member Enumeration Documentation

enum Policy::Action

A set of possible actions for a policy

Enumerator:
Accept  Connections matching this policy will be accepted.
Reject  Connections matching this policy will be rejected.

Definition at line 42 of file policy.h.

enum Policy::SpecialPolicy

Special rule types.

Enumerator:
AcceptAll  Accepts all connections. Equivalent to "accept *:*".
RejectAll  Rejects all connections. Equivalent to "reject *:*".

Definition at line 47 of file policy.h.


Constructor & Destructor Documentation

Policy::Policy (  ) 

Default constructor. Creates an AcceptAll policy.

Definition at line 34 of file policy.cpp.

References _action, _address, _fromPort, _mask, _toPort, and Accept.

Policy::Policy ( QString  policy  ) 

Parses the given policy, represented as a string.

Definition at line 43 of file policy.cpp.

References _action, _address, _fromPort, _mask, _toPort, Accept, and fromString().

Policy::Policy ( QString  action,
QString  address,
QString  ports 
)

Parses the given portions of a policy string.

Definition at line 56 of file policy.cpp.

References _action, _address, _fromPort, _mask, _toPort, Accept, and fromString().

Policy::Policy ( SpecialPolicy  policy  ) 

Creates a policy of the given special type.

Definition at line 69 of file policy.cpp.

References _action, _address, _fromPort, _mask, _toPort, Accept, AcceptAll, and Reject.

Policy::Policy ( Action  action,
QHostAddress  addr,
uchar  mask,
quint16  fromPort,
quint16  toPort = 0 
)

Creates a policy using the specified information.

Definition at line 78 of file policy.cpp.

References _action, _address, _fromPort, _mask, and _toPort.


Member Function Documentation

bool Policy::operator== ( const Policy policy  )  const

Overloads the == operator.

Definition at line 90 of file policy.cpp.

References _action, _address, _fromPort, _mask, and _toPort.

void Policy::fromString ( QString  policy  ) 

Parses the given policy string.

Definition at line 101 of file policy.cpp.

References _action, _address, _fromPort, _mask, _toPort, ports(), and toAction().

Referenced by Policy().

QString Policy::toString (  ) 

Converts this policy to a format Tor understands.

Definition at line 136 of file policy.cpp.

References _action, Accept, address(), and ports().

Referenced by ExitPolicy::toString().

Policy::Action Policy::toAction ( QString  action  )  [static]

Converts a string action to an Action enum value.

Definition at line 145 of file policy.cpp.

References Accept, and Reject.

Referenced by ServerPage::addPolicy(), and fromString().

QString Policy::action (  ) 

Returns the action taken when this policy matches an address.

Definition at line 157 of file policy.cpp.

References _action, and Accept.

Referenced by ServerPage::addPolicyItem().

QString Policy::address (  ) 

Returns the host address (including mask, if set) for this policy.

Definition at line 164 of file policy.cpp.

References _address, and _mask.

Referenced by ServerPage::addPolicyItem(), and toString().

QString Policy::ports (  ) 

Returns the port or port range for this policy.

Definition at line 183 of file policy.cpp.

References _fromPort, and _toPort.

Referenced by ServerPage::addPolicyItem(), fromString(), and toString().


Member Data Documentation

Action Policy::_action [private]

The action to take for this policy.

Definition at line 82 of file policy.h.

Referenced by action(), fromString(), operator==(), Policy(), and toString().

QHostAddress Policy::_address [private]

Addresses to which this policy applies.

Definition at line 83 of file policy.h.

Referenced by address(), fromString(), operator==(), and Policy().

quint16 Policy::_fromPort [private]

Start of a port range.

Definition at line 84 of file policy.h.

Referenced by fromString(), operator==(), Policy(), and ports().

quint16 Policy::_toPort [private]

End of a port range.

Definition at line 85 of file policy.h.

Referenced by fromString(), operator==(), Policy(), and ports().

uchar Policy::_mask [private]

Address mask.

Definition at line 86 of file policy.h.

Referenced by address(), fromString(), operator==(), and Policy().


The documentation for this class was generated from the following files:
Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0