Smart Home firewall
Profile-based Smart Home firewall
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
protocols.ip.ip Class Reference
Inheritance diagram for protocols.ip.ip:
Inheritance graph
[legend]
Collaboration diagram for protocols.ip.ip:
Collaboration graph
[legend]

Public Member Functions

bool is_ip (self, Union[str, list] addr)
 
str explicit_address (self, Union[str, list] addr)
 
None add_addr_nfqueue (self, str addr_dir, bool is_backward=False)
 
None add_addr (self, str addr_dir, bool is_backward=False, str initiator="")
 
dict parse (self, bool is_backward=False, str initiator="")
 
- Public Member Functions inherited from protocols.Protocol.Protocol
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)
 

Static Public Member Functions

bool is_ip_static (Union[str, list] addr, str version="ipv4")
 
- Static Public Member Functions inherited from protocols.Protocol.Protocol
Union[str, int] convert_value (str value)
 

Static Public Attributes

int layer = 3
 
bool custom_parser = False
 
list supported_keys
 
dictionary addrs
 

Additional Inherited Members

- Public Attributes inherited from protocols.Protocol.Protocol
 protocol_data
 
 device
 
 rules
 

Member Function Documentation

◆ add_addr()

None protocols.ip.ip.add_addr (   self,
str  addr_dir,
bool   is_backward = False,
str   initiator = "" 
)
Add a new IP address match to the accumulator, in two possible ways:
    - If the address is a well-known alias or an explicit IP address, add an nftables match.
    - If the address is a domain name, add an nfqueue match.

:param addr_dir: Address direction to add the rule to (src or dst)
:param is_backward: Whether the field to add is for a backward rule.
:param initiator: Optional, initiator of the connection (src or dst).

◆ add_addr_nfqueue()

None protocols.ip.ip.add_addr_nfqueue (   self,
str  addr_dir,
bool   is_backward = False 
)
Add a new IP address match to the nfqueue accumulator.

:param addr_dir: Address direction to add the rule to (src or dst)
:param is_backward: Whether the field to add is for a backward rule.

◆ explicit_address()

str protocols.ip.ip.explicit_address (   self,
Union[str,list]  addr 
)
Return the explicit version of an IP address alias,
or a list of IP address aliases.
Example: "local" -> "192.168.0.0/16"

:param addr: IP address alias(es) to explicit.
:return: Explicit IP address(es).
:raises ValueError: If the address is not a well-known alias or an explicit address.

◆ is_ip()

bool protocols.ip.ip.is_ip (   self,
Union[str, list]  addr 
)
Check whether a (list of) string is a well-known IP alias or an explicit IP address.

:param addr: (list of) string to check.
:return: True if the (list of) string is an IP address, False otherwise.

◆ is_ip_static()

bool protocols.ip.ip.is_ip_static ( Union[str, list]  addr,
str   version = "ipv4" 
)
static
Check whether a (list of) string is a well-known IP alias or an explicit IP address.

:param addr: (list of) string to check.
:param version: IP version (ipv4 or ipv6). Default is "ipv4".
:return: True if the (list of) string is an IP address, False otherwise.

◆ parse()

dict protocols.ip.ip.parse (   self,
bool   is_backward = False,
str   initiator = "" 
)
Parse the IP (v4 or v6) protocol.

: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 from protocols.Protocol.Protocol.

Member Data Documentation

◆ addrs

dictionary protocols.ip.ip.addrs
static
Initial value:
= {
"ipv4": {
"local": "192.168.0.0/16",
"external": "!= 192.168.0.0/16",
"gateway": "192.168.1.1",
"phone": "192.168.1.222",
"broadcast": "255.255.255.255",
"udp-broadcast": "192.168.1.255",
"igmpv3": "224.0.0.22",
**igmp.groups
},
"ipv6": {
"default": "::",
"local": ["fe80::/10", "fc00::/7"],
"gateway": "fddd:ed18:f05b::1",
"gateway-local": "fe80::c256:27ff:fe73:460b",
"phone": "fe80::db22:fbec:a6b4:44fe",
}
}

◆ supported_keys

list protocols.ip.ip.supported_keys
static
Initial value:
= [
"src",
"dst"
]

The documentation for this class was generated from the following file: