mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-01-24 18:11:24 +01:00
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>
This commit is contained in:
parent
29f7f1fa28
commit
d86df914c3
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user