Adrian Moreno <amore...@redhat.com> writes: > diff --git a/python/ovs/flows/decoders.py b/python/ovs/flows/decoders.py > index 73d5c0c60..2f8e5bd0a 100644 > --- a/python/ovs/flows/decoders.py > +++ b/python/ovs/flows/decoders.py > @@ -16,3 +25,392 @@ def decode_default(value): > return int(value, 0) > except ValueError: > return value > + > + > +def decode_flag(value): > + """Decode a flag. It's existance is just flagged by returning True."""
'existence' > + return True > + > + > +def decode_int(value): > + """Integer decoder. > + > + Both base10 and base16 integers are supported. Is this true? If `value` is a string, it isn't. int("0x4") throws an exception but int(0x4) doesn't. > + Used for fields such as: > + n_bytes=34 > + metadata=0x4 > + """ > + return int(value, 0) [...] > +class IntMask(Decoder): > + """Base class for Integer Mask decoder classes. > + > + It supports decoding a value/mask pair. The class has to be derived, > + and the size attribute must be set. > + """ > + > + size = None # Size in bits. > + > + def __init__(self, string): > + if not self.size: > + raise NotImplementedError( > + "IntMask should be derived and " "size should be fixed" > + ) Any reason not to join the strings here? > +class EthMask(Decoder): > + """EthMask represents an Ethernet address with optional mask. This is nitpicky, but the capitalisation of Ethernet is inconsistent throughout this function; it'd be nice to clean it up. [...] > + def __eq__(self, other): > + """Equality operator. > + > + Both the Ethernet address and the mask are compared. This can be used > + to implement filters where we expecte a specific mask to be present, 'expect' [...] > +class IPMask(Decoder): > + """IPMask stores an IPv6 or IPv4 and a mask. > + > + It uses netaddr.IPAddress. > + > + IPMasks can represent valid CIDRs or randomly maked IP Addresses. 'masked'? > + def __contains__(self, other): > + """Contains operator. > + > + Only comparing valid CIDRs is supported. > + > + Args: > + other (netaddr.IPAddres or IPMask): An IP address. 'netaddr.IPAddress' -- James _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev