ClearFoundation

Developer API Reference FirewallRule

ClearOS API

Class FirewallRule

Description

FirewallRule base class.

Located in /api/FirewallRule.class.php (line 91)

Engine
   |
   --FirewallRule
Class Constant Summary
 BANDWIDTH_BASIC = 0x00004000
 BANDWIDTH_PRIO = 0x00002000
 BANDWIDTH_RATE = 0x00001000
 CUSTOM = 0x20000000
 DMZ_INCOMING = 0x00000020
 DMZ_PINHOLE = 0x00000010
 ENABLED = 0x10000000
 EXTERNAL_ADDR = 0x00200000
 FORWARD = 0x00000008
 IFADDRESS = 0x04000000
 IFNETWORK = 0x08000000
 INCOMING_ALLOW = 0x00000001
 INCOMING_BLOCK = 0x00000002
 L7FILTER_BYPASS = 0x00800000
 LOCAL_NETWORK = 0x00100000
 MAC_FILTER = 0x00000200
 MAC_SOURCE = 0x01000000
 ONE_TO_ONE = 0x00000080
 OUTGOING_BLOCK = 0x00000004
 PPTP_FORWARD = 0x00000100
 PROTO_AH = 51
 PROTO_ESP = 50
 PROTO_GRE = 47
 PROTO_IP = 0
 PROTO_TCP = 6
 PROTO_UDP = 17
 PROXY_BYPASS = 0x00400000
 RESERVED_0 = 0x00000040
 RESERVED_1 = 0x00008000
 RESERVED_2 = 0x00010000
 RESERVED_3 = 0x00020000
 RESERVED_4 = 0x00040000
 RESERVED_5 = 0x00080000
 RESERVED_6 = 0x40000000
 RESERVED_7 = 0x80000000
 SBR_HOST = 0x00000800
 SBR_PORT = 0x00000400
 WIFI = 0x02000000
Variable Summary
mixed $addr
mixed $flags
mixed $group
mixed $name
mixed $param
mixed $port
mixed $proto
Method Summary
FirewallRule __construct ()
void __destruct ()
flag ConvertProtocolName (string $protocol)
boolean Disable ()
boolean Enable ()
void GetAddress ()
int GetFlags ()
string GetGroup ()
string GetName ()
mixed GetParameter ()
int GetPort ()
int GetProtocol ()
string GetRule ()
string GetTypeText ()
boolean IsEnabled ()
boolean IsEqual (object $val)
boolean IsValidFlags (int $flags)
boolean IsValidIp (string $ip)
boolean IsValidMac (string $mac)
boolean IsValidName (string $name)
boolean IsValidPort (integer $port)
boolean IsValidProtocol (int $proto)
boolean IsValidTarget (string $ip)
void Reset ()
void SetAddress (string $val)
void SetFlags (int $val)
void SetGroup (string $val)
void SetName (string $val)
void SetParameter (mixed $val)
void SetPort (int $port)
void SetPortRange (int $from, int $to)
void SetProtocol (int $val)
void SetRule (string $input)
Variables
mixed $addr = null (line 145)
  • access: protected
mixed $flags = null (line 143)
  • access: protected
mixed $group = null (line 142)
  • access: protected
mixed $name = null (line 141)
  • access: protected
mixed $param = null (line 147)
  • access: protected
mixed $port = null (line 146)
  • access: protected
mixed $proto = null (line 144)
  • access: protected

Inherited Variables

Inherited from Engine

Engine::$errors
Methods
Constructor __construct (line 153)
  • access: public
FirewallRule __construct ()

Redefinition of:
Engine::__construct()
Engine constructor.
Destructor __destruct (line 967)
  • access: public
void __destruct ()

Redefinition of:
Engine::__destruct()
ConvertProtocolName (line 648)

Returns protocol flag for given protocol name.

  • return: protocol flag
flag ConvertProtocolName (string $protocol)
  • string $protocol: protocol name
Disable (line 432)

Disable rule.

  • return: Previous rule state
boolean Disable ()
Enable (line 415)

Enable rule.

  • return: Previous rule state
boolean Enable ()
GetAddress (line 520)

Get rule address.

return string address Rule address

void GetAddress ()
GetFlags (line 449)

Get rule type and flags.

  • return: flags Rule flags
int GetFlags ()
GetGroup (line 306)

Get rule group name.

  • return: Firewall group name
string GetGroup ()
GetName (line 274)

Get rule name.

  • return: Rule name
string GetName ()
GetParameter (line 617)

Get rule parameter value.

  • return: param Rule parameter field
mixed GetParameter ()
GetPort (line 554)

Get rule port.

  • return: port Rule numeric port address
int GetPort ()
GetProtocol (line 483)

Get rule protocol.

  • return: protocol Rule numeric protocol
int GetProtocol ()
GetRule (line 194)

Return validated rule in packed format.

Rule format, 7 fields with a pipe '|' delimiter: name|group|flags|proto|addr|port|param

  • return: Valid rule in packed format
string GetRule ()
GetTypeText (line 341)

Returns type description.

  • return: a description of the type of rule
string GetTypeText ()
IsEnabled (line 400)

Is rule enabled?

  • return: True if rule is enabled, false otherwise
boolean IsEnabled ()
IsEqual (line 697)

Compare this object with another, return true if equal.

  • return: True if objects are equal
boolean IsEqual (object $val)
  • object $val: FirewallRule object to compare against
IsValidFlags (line 754)

Do the rule flags make sense?

  • return: True if flags are valid
boolean IsValidFlags (int $flags)
  • int $flags: Rule flags to validate
IsValidIp (line 865)

Validation routine for IPs.

  • return: true if IP address is valid
boolean IsValidIp (string $ip)
  • string $ip: ip IP address
IsValidMac (line 928)

Is this (MAC/HW) address valid? (eg AA:BB:CC:DD:EE:FF)

  • return: True if hardware address is valid
boolean IsValidMac (string $mac)
  • string $mac: Hardware address to validate
IsValidName (line 739)

Is the rule name (or group name) valid?

  • return: True if rule name is valid
boolean IsValidName (string $name)
  • string $name: Firewall rule name
IsValidPort (line 944)

Validates TCP port.

  • return: true if port address is valid
boolean IsValidPort (integer $port)
  • integer $port: port address
IsValidProtocol (line 832)

Is the rule protocol valid/supported?

  • return: True if numeric port address is valid
boolean IsValidProtocol (int $proto)
  • int $proto: Numeric port address to validate
IsValidTarget (line 894)

Is this (hostname, IPv4, and soon IPv6) address valid? localhost || 192.168.0.1 || 192.168.0.1/24 || 192.168.0.1/255.255.255.0 || 192.168.0.1:192.168.1.1

TODO: hostname validation should be moved to IsValidHostname TODO: network validation should be moved to IsValidNetwork TODO: this class should extend Network() and use the standard validation

  • return: True if address is valid
boolean IsValidTarget (string $ip)
  • string $ip: hostname, IPv4 address to validate
Reset (line 171)

Reset class field members to default state.

void Reset ()
SetAddress (line 535)

Set rule address.

void SetAddress (string $val)
  • string $val: Rule address
SetFlags (line 464)

Set rule type and flags.

void SetFlags (int $val)
  • int $val: Rule flags
SetGroup (line 321)

Set rule group name.

void SetGroup (string $val)
  • string $val: Firewall group name
SetName (line 289)

Set rule name.

void SetName (string $val)
  • string $val: Firewall name value
SetParameter (line 632)

Set rule parameter value.

void SetParameter (mixed $val)
  • mixed $val: Rule parameter value
SetPort (line 570)

Set rule port.

void SetPort (int $port)
  • int $port: port address
SetPortRange (line 596)

Set rule port range.

void SetPortRange (int $from, int $to)
  • int $from: from port
  • int $to: to port
SetProtocol (line 498)

Set rule protocol.

void SetProtocol (int $val)
  • int $val: Rule numeric protocol
SetRule (line 222)

Set class members from packed format input.

Rule format, 7 fields seperated by a pipe '|' delimiter: name|group|flags|proto|addr|port|param

  • throws: FirewallInvalidRuleException
void SetRule (string $input)
  • string $input: Packed firewall rule

Inherited Methods

Inherited From Engine

Engine::__construct()
Engine::AddValidationError()
Engine::CheckValidationErrors()
Engine::CopyValidationErrors()
Engine::GetValidationErrors()
Engine::Log()
Engine::__destruct()
Class Constants
BANDWIDTH_BASIC = 0x00004000 (line 111)
BANDWIDTH_PRIO = 0x00002000 (line 110)
BANDWIDTH_RATE = 0x00001000 (line 109)
CUSTOM = 0x20000000 (line 126)
DMZ_INCOMING = 0x00000020 (line 102)
DMZ_PINHOLE = 0x00000010 (line 101)
ENABLED = 0x10000000 (line 125)
EXTERNAL_ADDR = 0x00200000 (line 118)
FORWARD = 0x00000008 (line 100)
IFADDRESS = 0x04000000 (line 123)
IFNETWORK = 0x08000000 (line 124)
INCOMING_ALLOW = 0x00000001 (line 97)
INCOMING_BLOCK = 0x00000002 (line 98)
L7FILTER_BYPASS = 0x00800000 (line 120)
LOCAL_NETWORK = 0x00100000 (line 117)
MAC_FILTER = 0x00000200 (line 106)
MAC_SOURCE = 0x01000000 (line 121)
ONE_TO_ONE = 0x00000080 (line 104)
OUTGOING_BLOCK = 0x00000004 (line 99)
PPTP_FORWARD = 0x00000100 (line 105)
PROTO_AH = 51 (line 135)
PROTO_ESP = 50 (line 134)
PROTO_GRE = 47 (line 133)
PROTO_IP = 0 (line 130)
PROTO_TCP = 6 (line 131)
PROTO_UDP = 17 (line 132)
PROXY_BYPASS = 0x00400000 (line 119)
RESERVED_0 = 0x00000040 (line 103)
RESERVED_1 = 0x00008000 (line 112)
RESERVED_2 = 0x00010000 (line 113)
RESERVED_3 = 0x00020000 (line 114)
RESERVED_4 = 0x00040000 (line 115)
RESERVED_5 = 0x00080000 (line 116)
RESERVED_6 = 0x40000000 (line 127)
RESERVED_7 = 0x80000000 (line 128)
SBR_HOST = 0x00000800 (line 108)
SBR_PORT = 0x00000400 (line 107)
WIFI = 0x02000000 (line 122)

Inherited Constants

Inherited from Engine

Engine::COMMAND_API

Documentation generated on Fri, 28 Aug 2009 20:32:09 -0400 by phpDocumentor 1.3.2