From be9fc3dc6d8c579f43016ce27e0ec67f9695e9fc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 20 May 2012 10:42:14 +0900 Subject: [PATCH] Add Switch to Controller Nicira extension message support Signed-off-by: FUJITA Tomonori --- ryu/ofproto/ofproto_v1_0_parser.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index 9517e4f5..9270ce4a 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -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):