TcpMatch¶
- class TcpMatch[source]¶
Match against the fields of the TCP header
- syn() TcpFlagsCriterion[source]¶
Criterion for matching against a SYN packet
- tcp_flags() TcpFlagsCriterion[source]¶
Compare with TCP flags
- source_port() SourcePortCriterion[source]¶
Matching against the source port
- dest_port() DestPortCriterion[source]¶
Match against the destination port
- classmethod parse(parser: MatchParser) Match[source]¶
Parse the TCP criteria
TcpFlagsCriterion¶
- class TcpFlagsCriterion(match: Match, syn_only=False)[source]¶
A criterion for comparing against packets with an arbitrary set of TCP flags set, or for comparing against SYN packets. This is an either-or use, determined at the time of object instantiation.
The value is the tuple (flags-checked, flags-set); both flags-checked and flags-set are comma-separated lists of TCP flag names.
- get_value() Tuple[Set[TcpFlag], Set[TcpFlag]][source]¶
Returns the value that the criterion is comparing against
- is_syn_only()[source]¶
Returns
Trueif the criterion is only meant to check for the SYN flag (but note that it may not be set yet)
- bit_set() Match[source]¶
This method can be used if this criterion implements a SYN-only comparison to check if the packet flags include only the SYN bit.
- bit_not_set() Match[source]¶
This method can be used if this criterion implements a SYN-only comparison to check for the non-existence of the SYN bit
- equals(flags_checked: Optional[Set[TcpFlag]] = None, flags_set: Optional[List[TcpFlag]] = None) Match[source]¶
Perform flags comparison
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
SourcePortCriterion¶
- class SourcePortCriterion(match: Match)[source]¶
Compare with a source port or check for inclusion in port-range
The value is a the tuple (port, last_port) where last_port may be
None- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(port: int, last_port: Optional[int] = None) Match¶
Compare with a port (or inclusion in port-range if
last_postis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
DestPortCriterion¶
- class DestPortCriterion(match: Match)[source]¶
Compare against a destination port or check for inclusion in port-range
The value is a the tuple (port, last_port) where last_port may be
None- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(port: int, last_port: Optional[int] = None) Match¶
Compare with a port (or inclusion in port-range if
last_postis present)
- get_value() Tuple[int, Optional[int]]¶
Returns the value that the criterion is comparing against
- is_positive() bool¶
Returns the ‘polarity’ of the criterion;
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set