Commit dad3733c authored by David Johnson's avatar David Johnson

Add an ipvXaddr expr helper/wrapper for nftables.

parent 97c9a18f
......@@ -139,3 +139,12 @@ def ipv6addr(src=None, dst=None):
kwarg['data'] = {'attrs': [('NFTA_DATA_VALUE', packed)]}
ret.append(genex('cmp', kwarg))
return ret
def ipvXaddr(family=socket.AF_INET, src=None, dst=None):
if family == socket.AF_INET:
return ipv4addr(src=src, dst=dst)
elif family == socket.AF_INET6:
return ipv6addr(src=src, dst=dst)
else:
raise ValueError("family must be AF_INET or AF_INET6")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment