8.3.1.11. Filter
This module contains the L23 port filter classes that deal with configuration of the filters on the received traffic of a port.
The filter command names all have the form PF_<xxx>
, and require both a module index id and a port index id, as well as a sub-index identifying a particular filter.
Each filter specifies a compound Boolean condition on these true/false values to determine if the filter as a whole is true/false.
While a filter is enabled, neither its condition nor the definition of each match term or length term used by the condition can be changed.
- class PF_COMMENT[source]
Bases:
object
The description of a filter.
- class GetDataAttr[source]
Bases:
ResponseBodyStruct
- comment
string, the description of the filter.
- class PF_CONDITION[source]
Bases:
object
The boolean condition on the terms specifying when the filter is satisfied. The condition uses a canonical and-or-not expression on the match terms and length terms. The condition is specified using a number of compound terms, each encoded as an integer value specifying an arbitrary set of the match terms and length terms defined for the port. Each match or length term has a specific power-of-two value, and the set is encoded as the sum of the values for the contained terms:
Value for match term
[match_term_xindex] = 2^match_term_xindex
Value for length term
[length_term_xindex] = 2^(length_term_xindex+16)
A compound term is true if all the match terms and length terms contained in it are true. This supports the and-part of the condition. If some compound term is satisfied, the condition as a whole is true.
This is the or-part of the condition. The first few compound terms at the even positions (second, fourth, …) are inverted, and all the contained match terms and length terms must be false at the same time that the those of the preceding compound term are true. This is the not-part of the condition.
At the top level, a condition is a bunch of things or-ed together.
<filter-condition> = <or-expr>
Two of the or-operands are general, two are ‘simple’.
<or-expr> = <general-and-expr> or <general-and-expr> or <simple-and-expr> or <simple-and-expr>
A ‘general’ and-expression can include negated terms.
<general-and-expr> = <term> and <term> and ... and not <term> and ... and not <term>
A ‘simple’ and-expression can only have non-negated terms.
<simple-and-expr> = <term> and <term> and ... and <term>
<term> = <match-term>
<term> = <length-term>
In practice, the simplest way to generate these encodings is to use the ValkyrieManager, which supports Boolean expressions using the operators
&, |, and ~
, and simply query the chassis for the resulting script-level definition.- class GetDataAttr[source]
Bases:
ResponseBodyStruct
- and_expression_0
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_1
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_2
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_3
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_not_expression_0
unsigned integer, encoding a compound term which is a set of the match NOT terms AND length NOT terms.
- and_not_expression_1
unsigned integer, encoding a compound term which is a set of the match NOT terms AND length NOT terms.
- class SetDataAttr[source]
Bases:
RequestBodyStruct
- and_expression_0
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_1
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_2
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_expression_3
unsigned integer, encoding a compound term which is a set of the match terms AND length terms.
- and_not_expression_0
unsigned integer, encoding a compound term which is a set of the match NOT terms AND length NOT terms.
- and_not_expression_1
unsigned integer, encoding a compound term which is a set of the match NOT terms AND length NOT terms.
- get()[source]
Get the condition on the terms specifying when the filter is satisfied.
- Returns:
and_expression_0, and_not_expression_0, and_expression_1, and_not_expression_1, and_expression_2, and and_expression_3.
- Return type:
- set(and_expression_0, and_not_expression_0, and_expression_1, and_not_expression_1, and_expression_2, and_expression_3)[source]
Set the condition on the terms specifying when the filter is satisfied.
- Parameters:
and_expression_0 (int) – encoding a compound term which is a set of the match terms AND length terms.
and_not_expression_0 (int) – encoding a compound term which is a set of the match NOT terms AND length NOT terms.
and_expression_1 (int) – encoding a compound term which is a set of the match terms AND length terms.
and_not_expression_1 (int) – encoding a compound term which is a set of the match NOT terms AND length NOT terms.
and_expression_2 (int) – encoding a compound term which is a set of the match terms AND length terms.
and_expression_3 (int) – encoding a compound term which is a set of the match terms AND length terms.
- class PF_CREATE[source]
Bases:
object
Creates an empty filter definition with the specified sub-index value.
- class PF_DELETE[source]
Bases:
object
Deletes the filter definition with the specified sub-index value.
- class PF_ENABLE[source]
Bases:
object
Whether a filter is currently active on a port. While a filter is enabled its condition cannot be changed, nor can any match term or length terms used by it.
- class GetDataAttr[source]
Bases:
ResponseBodyStruct
- on_off
coded byte, whether the filter is enabled.
- class SetDataAttr[source]
Bases:
RequestBodyStruct
- on_off
coded byte, whether the filter is enabled.
- get()[source]
Get whether a filter is currently active on the port.
- Returns:
whether the filter is enabled
- Return type:
- set(on_off)[source]
Set whether a filter is currently active on the port.
- Parameters:
on_off (OnOff) – whether the filter is enabled
- set_off()
Disable a filter on a port.
- set_on()
Enable a filter on a port.
- class PF_INDICES[source]
Bases:
object
The full list of which filters are defined for a port. These are the sub-index values that are used for the parameters defining the compound conditions on the match/length terms operating on the packets received for the port. Setting the value of this parameter creates a new empty filter for each value that is not already in use, and deletes each filter that is not mentioned in the list. The same can be accomplished one-filter-at-a-time using the PF_CREATE and PF_DELETE commands.
- class GetDataAttr[source]
Bases:
ResponseBodyStruct
- filter_xindices
list of integers, the list of indices of filters on a port.
- class SetDataAttr[source]
Bases:
RequestBodyStruct
- filter_xindices
list of integers, the list of indices of filters on a port.
- class PF_STRING[source]
Bases:
object
The string representation of a filter.
- class GetDataAttr[source]
Bases:
ResponseBodyStruct
- string_name
string, the string representation of the filter.
- class SetDataAttr[source]
Bases:
RequestBodyStruct
- string_name
string, the string representation of the filter.