Package onep :: Package policy :: Module L3Ace :: Class L3Ace
[frames] | no frames]

Class L3Ace


L3 Access Control Element (ACE) Class.

It defines a set of attributes for matching a packet. One or more ACEs may be added to an Access Control List (ACL).

Instance Methods
 
__init__(self, sequence, permit)
Instantiate a new Access Control Element.
 
set_src_prefix_any(self)
Set source prefix to any.
 
set_dst_prefix_any(self)
Set destination prefix to any.
 
set_src_port_range(self, port1, port2)
Set TCP/UDP source port range.
(int,int)
get_src_port_range(self)
Get TCP/UDP source port lower,upper bound.
 
set_dst_port_range(self, port1, port2)
Set TCP/UDP destination port range.
(int,int)
get_dst_port_range(self)
Get TCP/UDP destination port lower,upper bound.
 
set_tcp_flags(self, value, mask, match)
Set TCP flags.
 
set_dscp(self, dscp)
Set the value of the DSCP field.
 
set_log_flag(self, log_flag)
Set Log Flag.
str
__str__(self)
Returns a string representation of the L2 Access Control Element(ACE) instance.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables
  AceFlag = enum(IP_ACE_PREC_PRESENT= 0x0001, IP_ACE_TOS_PRESENT...
Enum PortOperator = enum('ONEP_OPER_ANY', 'ONEP_OPER_LT', 'ONEP_OPE...
Enumeration of L3 Ace Port Operator.
Enum TcpFlags = enum(ONEP_TCP_FIN= 1, ONEP_TCP_SYN= 2, ONEP_TCP_RST...
Enumeration of TCP Flags.
Enum TcpFlagMatch = enum(ONEP_MATCH_ANY= 1, ONEP_MATCH_ALL= 2)
Enumeration of TCP Flag match.
Enum log_flag = enum(ONEP_ACL_LOG_UNUSED= 0, ONEP_ACL_LOG_NORMAL= 1...
Enumeration of Ace Log Flags.
  permit = property(_get_permit, _set_permit, None, _doc)
  src_prefix = property(_get_src_prefix, _set_src_prefix, None, ...
  src_prefix_len = property(_get_src_prefix_len, _set_src_prefix...
  dst_prefix = property(_get_dst_prefix, _set_dst_prefix, None, ...
  dst_prefix_len = property(_get_dst_prefix_len, _set_dst_prefix...
  protocol = property(_get_protocol, _set_protocol, None, _doc)
  src_port_oper = property(_get_src_port_oper, _set_src_port_ope...
  src_port1 = property(_get_src_port1, _set_src_port1, None, _doc)
  dst_port_oper = property(_get_dst_port_oper, _set_dst_port_ope...
  dst_port1 = property(_get_dst_port1, _set_dst_port1, None, _doc)
Properties

Inherited from object: __class__

Method Details

__init__(self, sequence, permit)
(Constructor)

 

Instantiate a new Access Control Element.

It initialises L3 Access Control Element(ACE) properties as follows:

   src_port_oper: PortOperator.ONEP_OPER_ANY
   dst_port_oper: PortOperator.ONEP_OPER_ANY
   protocol: 256 
   ttl: 0
Parameters:
  • sequence (int) - Position of L3 ACE in the L3 Access Control List(ACL).
  • permit (bool) - pass TRUE for permit, pass FALSE for deny.
Raises:
Overrides: object.__init__

set_src_prefix_any(self)

 

Set source prefix to any.

It sets following two properties:

src_prefix: "0.0.0.0"

src_prefix_len: 0

set_dst_prefix_any(self)

 

Set destination prefix to any.

It sets following two properties:

dst_prefix: "0.0.0.0"

dst_prefix_len: 0

set_src_port_range(self, port1, port2)

 

Set TCP/UDP source port range.

Parameters:
  • port1 (int) - Source port range lower bound.
  • port2 (int) - Source port range upper bound.
Raises:

get_src_port_range(self)

 

Get TCP/UDP source port lower,upper bound.

Returns: (int,int)
Returns source port lower,upper bound.

set_dst_port_range(self, port1, port2)

 

Set TCP/UDP destination port range.

Parameters:
  • port1 (int) - Destination port range lower bound.
  • port2 (int) - Destination port range upper bound.
Raises:

get_dst_port_range(self)

 

Get TCP/UDP destination port lower,upper bound.

Returns: (int,int)
Returns destination port lower,upper bound.

set_tcp_flags(self, value, mask, match)

 

Set TCP flags. A match bit field value, mask and a match type are used to set up the matching of TCP flags.

The mask field selects which flags are to be used in the match.

The match type determines the combination of selected TCP flags that will cause a match, i.e., either all TCP flags must match the selected flag values, or any one of the TCP flags must match the selected flag values.

For example to match on all TCP flag bits being FIN = 1, SYN = 1, PSH = 0, ACK = 0 :

   value = [TcpFlags.ONEP_TCP_FIN, TcpFlags.ONEP_TCP_SYN]
   mask  = [TcpFlags.ONEP_TCP_FIN, TcpFlags.ONEP_TCP_SYN, TcpFlags.ONEP_TCP_PSH, TcpFlags.ONEP_TCP_ACK]
   match = [TcpFlagMatch.ONEP_MATCH_ALL]
   Note: PSH and ACK are not passed in 'value' as all tcp flags have 0 bit value by default.
Parameters:
  • value (list) - pass list of tcp flags for which bit value 1 is to be matched.
  • mask (list) - list of tcp flags are to be used in the match.
  • match (list) - all or any one of the tcp flags must match selected flag values.
Raises:

set_dscp(self, dscp)

 

Set the value of the DSCP field.

Parameters:
  • dscp (int) - dscp value.
Raises:

set_log_flag(self, log_flag)

 

Set Log Flag.

Set the value of the Log flags.

Parameters:
  • log_flag (log_flag) - normal=1, input=2, or unused=0
Raises:

__str__(self)
(Informal representation operator)

 

Returns a string representation of the L2 Access Control Element(ACE) instance.

Returns: str
String representation of the L2 ACE object.
Overrides: object.__str__

Class Variable Details

AceFlag

Value:
enum(IP_ACE_PREC_PRESENT= 0x0001, IP_ACE_TOS_PRESENT= 0x0002, IP_ACE_D\
SCP_PRESENT= 0x0004, IP_ACE_FRAG_PRESENT= 0x0008, IP_ACE_LOG_PRESENT= \
0x0010, IP_ACE_LOG_INPUT_PRESENT= 0x0020, IP_ACE_COPY_ACTION= 0x0040, \
IP_ACE_DIVERT_ACTION= 0x0080, IP_ACE_ETHERTYPE_PRESENT= 0x0100, IP_ACE\
_VLAN_PRESENT= 0x0200, IP_ACE_IN_INTF_PRESENT= 0x0400, IP_ACE_L2COS_PR\
ESENT= 0x0800, IP_ACE_REDIRECT_ACTION= 0x1000, IP_ACE_SET_VLAN_ACTION=\
 0x2000, IP_ACE_STRIP_VLAN_ACTION= 0x4000, IP_ACE_MAC_REWRITE_ACTION= \
0x8000, IP_ACE_MATCHMAC_PRESENT= 0x10000, IP_ACE_TTL_PRESENT= 0x20000)

PortOperator

Enumeration of L3 Ace Port Operator.

ONEP_OPER_ANY ONEP_OPER_LT ONEP_OPER_GT ONEP_OPER_EQ ONEP_OPER_NEQ ONEP_OPER_RANGE ONEP_OPER_ONEBYTE ONEP_OPER_TWOBYTE

Type:
Enum
Value:
enum('ONEP_OPER_ANY', 'ONEP_OPER_LT', 'ONEP_OPER_GT', 'ONEP_OPER_EQ', \
'ONEP_OPER_NEQ', 'ONEP_OPER_RANGE', 'ONEP_OPER_ONEBYTE', 'ONEP_OPER_TW\
OBYTE')

TcpFlags

Enumeration of TCP Flags.

ONEP_TCP_FIN: Finish ONEP_TCP_SYN: Sync ONEP_TCP_RST: Reset ONEP_TCP_PSH: Push ONEP_TCP_ACK: Acknowledgement ONEP_TCP_URG: Urgent

Type:
Enum
Value:
enum(ONEP_TCP_FIN= 1, ONEP_TCP_SYN= 2, ONEP_TCP_RST= 4, ONEP_TCP_PSH= \
8, ONEP_TCP_ACK= 16, ONEP_TCP_URG= 32)

TcpFlagMatch

Enumeration of TCP Flag match.

ONEP_MATCH_ANY: All TCP flags must match the selected flag values. ONEP_MATCH_ALL: Any one of the TCP flags must match the selected flag values.

Type:
Enum
Value:
enum(ONEP_MATCH_ANY= 1, ONEP_MATCH_ALL= 2)

log_flag

Enumeration of Ace Log Flags.

ONEP_ACL_LOG_UNUSED ONEP_ACL_LOG_NORMAL ONEP_ACL_LOG_INPUT

Type:
Enum
Value:
enum(ONEP_ACL_LOG_UNUSED= 0, ONEP_ACL_LOG_NORMAL= 1, ONEP_ACL_LOG_INPU\
T= 2)

src_prefix

Value:
property(_get_src_prefix, _set_src_prefix, None, _doc)

src_prefix_len

Value:
property(_get_src_prefix_len, _set_src_prefix_len, None, _doc)

dst_prefix

Value:
property(_get_dst_prefix, _set_dst_prefix, None, _doc)

dst_prefix_len

Value:
property(_get_dst_prefix_len, _set_dst_prefix_len, None, _doc)

src_port_oper

Value:
property(_get_src_port_oper, _set_src_port_oper, None, _doc)

dst_port_oper

Value:
property(_get_dst_port_oper, _set_dst_port_oper, None, _doc)