Add generic OFPropBase class and make OFPPortProp a subclass of it. This is to allow other properties classes to be implemented as subclasses of OFPPropBase, simplifying their implementation.
Signed-off-by: Simon Horman <[email protected]> --- ryu/ofproto/ofproto_v1_4_parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py index 7a44613..4077f20 100644 --- a/ryu/ofproto/ofproto_v1_4_parser.py +++ b/ryu/ofproto/ofproto_v1_4_parser.py @@ -749,7 +749,7 @@ class OFPMatch(StringifyMixin): return OFPMatch(_ordered_fields=fields) -class OFPPortPropUnknown(StringifyMixin): +class OFPPropUnknown(StringifyMixin): def __init__(self, type_=None, length=None, buf=None): self.buf = buf @@ -758,9 +758,9 @@ class OFPPortPropUnknown(StringifyMixin): return cls(buf=buf) -class OFPPortProp(StringifyMixin): +class OFPPropBase(StringifyMixin): _PACK_STR = '!HH' - _TYPES = {} + # _TYPES = {} must be an attribute of subclass def __init__(self, type_, length=None): self.type = type_ @@ -781,13 +781,17 @@ class OFPPortProp(StringifyMixin): try: subcls = cls._TYPES[type_] except KeyError: - subcls = OFPPortPropUnknown + subcls = OFPPropUnknown prop = subcls.parser(buf) prop.type = type_ prop.length = length return prop, rest +class OFPPortProp(OFPPropBase): + _TYPES = {} + + @OFPPortProp.register_type(ofproto.OFPPDPT_ETHERNET) class OFPPortDescPropEthernet(StringifyMixin): def __init__(self, type_=None, length=None, curr=None, advertised=None, -- 1.8.5.2 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
