Add Switch to Controller Nicira extension message support

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2012-05-20 10:42:14 +09:00
parent 0c74a7755c
commit be9fc3dc6d

View File

@ -1089,6 +1089,16 @@ class OFPVendor(MsgBase):
class NiciraHeader(OFPVendor):
_NX_SUBTYPES = {}
@staticmethod
def register_nx_subtype(subtype):
def _register_nx_subtype(cls):
cls.cls_subtype = subtype
NiciraHeader._NX_SUBTYPES[cls.cls_subtype] = cls
return cls
return _register_nx_subtype
def __init__(self, datapath, subtype):
super(NiciraHeader, self).__init__(datapath)
self.vendor = ofproto_v1_0.NX_VENDOR_ID
@ -1100,6 +1110,15 @@ class NiciraHeader(OFPVendor):
self.buf, ofproto_v1_0.OFP_HEADER_SIZE,
self.vendor, self.subtype)
@classmethod
def parser(cls, datapath, buf, offset):
vendor, subtype = struct.unpack_from(
ofproto_v1_0.NICIRA_HEADER_PACK_STR, buf,
offset + ofproto_v1_0.OFP_HEADER_SIZE)
cls_ = cls._NX_SUBTYPES.get(subtype)
return cls_.parser(datapath, buf,
offset + ofproto_v1_0.NICIRA_HEADER_SIZE)
class NXTSetFlowFormat(NiciraHeader):
def __init__(self, datapath, flow_format):