MarkMatch¶
Example:
>>> from linuxnet.iptables import MarkMatch
>>> m = MarkMatch()
>>> m.mark().equals(0x20, 0xff)
<linuxnet.iptables.matches.markmatch.MarkMatch object at 0x7f42fa72b240>
>>> m.to_iptables_args()
['-m', 'mark', '--mark', '0x20/0xff']
>>> m.mark().get_value()
(32, 255)
- class MarkMatch[source]¶
Match against the fwmark
- mark() MarkCriterion[source]¶
Match against the packet’s fwmark.
MarkCriterion¶
- class MarkCriterion(match: Match)[source]¶
A criterion for a mark, used by
MarkMatchandConnmarkMatchsince the iptables(8) option used by the mark/connmark modules is the same.The comparison value is a tuple consisting of an (integer) mark value and an integer mask value (
Nonein case of no mask).- get_value() Tuple[int, Optional[int]][source]¶
Returns the value that the criterion is comparing against.
- Return type:
tuple of (int, int|None)
- equals(mark: int, mask: Optional[int] = None) Match[source]¶
Check for equality against
markand optionallymask- Parameters:
mark – the mark value
mask – the mask value
- any() Match¶
Match any value.
This method is used when creating a
Criterionin order to search an existing chain for rules that try to match against certain packet properties (e.g. input interface) without being particular about the specific property value (e.g.eth0).
- 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