summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2014-02-04 13:27:58 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-02-04 18:41:50 +0900
commitd86df914c3d1b8ea202ab710b2fac358423df8ed (patch)
tree360203f39be5e8a69ba6ba022588d83a3b83593e
parent29f7f1fa282900e8d5014575033fdb497c788c1c (diff)
of14: Add generic OFPropBase class
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 <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index 7a446133..4077f207 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,