|
None | __init__ (self, dict protocol_data, dict device) |
|
Protocol | init_protocol (c, str protocol_name, dict protocol_data, dict device) |
|
str | format_list (self, list l, func=lambda x:x) |
|
None | add_field (self, str field, dict template_rules, bool is_backward=False, func=lambda x:x, backward_func=lambda x:x) |
|
dict | parse (self, bool is_backward=False, str initiator="src") |
|
Generic protocol, inherited by all concrete protocols.
None protocols.Protocol.Protocol.add_field |
( |
|
self, |
|
|
str |
field, |
|
|
dict |
template_rules, |
|
|
bool |
is_backward = False , |
|
|
|
func = lambda x: x , |
|
|
|
backward_func = lambda x: x |
|
) |
| |
Add a new nftables rule to the nftables rules accumulator.
:param field: Field to add the rule for.
:param template_rules: Dictionary containing the protocol-specific rules to add.
:param is_backward (optional): Whether the field to add is for a backward rule.
Optional, default is `False`.
:param func (optional): Function to apply to the field value before writing it.
Optional, default is the identity function.
:param backward_func (optional): a to apply to the field value in the case of a backwards rule.
Will be applied after the forward function.
Optional, default is the identity function.
Args:
field (str): Field to add the rule for.
rules (dict): Dictionary containing the protocol-specific rules to add.
is_backward (bool): Whether the field to add is for a backward rule.
Optional, default is `False`.
func (lambda): Function to apply to the field value before writing it.
Optional, default is the identity function.
backward_func (lambda): a to apply to the field value in the case of a backwards rule.
Will be applied after the forward function.
Optional, default is the identity function.
Reimplemented in protocols.Custom.Custom.
dict protocols.Protocol.Protocol.parse |
( |
|
self, |
|
|
bool |
is_backward = False , |
|
|
str |
initiator = "src" |
|
) |
| |
Default parsing method.
Must be updated in the children class.
:param is_backward (optional): Whether the protocol must be parsed for a backward rule.
Optional, default is `False`.
:param initiator (optional): Connection initiator (src or dst).
Optional, default is "src".
:return: Dictionary containing the (forward and backward) nftables and nfqueue rules for this policy.
Reimplemented in protocols.ssdp.ssdp, protocols.igmp.igmp, protocols.icmpv6.icmpv6, protocols.icmp.icmp, protocols.http.http, protocols.dns.dns, protocols.dhcp.dhcp, protocols.coap.coap, protocols.arp.arp, protocols.Transport.Transport, and protocols.ip.ip.