This enabls a vendor to register vendor's specific parser to handle Switch to Controller Vendor messages.
An object that vendor's parser returns is placed at msg.data. Signed-off-by: FUJITA Tomonori <[email protected]> --- ryu/ofproto/ofproto_v1_0_parser.py | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index b3a7cb4..efff7e5 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -966,6 +966,15 @@ class OFPEchoReply(MsgBase): @_register_parser @_set_msg_type(ofproto_v1_0.OFPT_VENDOR) class OFPVendor(MsgBase): + _VENDORS = {} + + @staticmethod + def register_vendor(_id): + def _register_vendor(cls): + OFPVendor._VENDORS[_id] = cls + return cls + return _register_vendor + def __init__(self, datapath): super(OFPVendor, self).__init__(datapath) self.data = None @@ -978,7 +987,13 @@ class OFPVendor(MsgBase): (msg.vendor,) = struct.unpack_from( ofproto_v1_0.OFP_VENDOR_HEADER_PACK_STR, msg.buf, ofproto_v1_0.OFP_HEADER_SIZE) - msg.data = msg.buf[ofproto_v1_0.OFP_VENDOR_HEADER_SIZE:] + + cls_ = cls._VENDORS.get(msg.vendor) + if cls_: + msg.data = cls_.parser(datapath, msg.buf, 0) + else: + msg.data = msg.buf[ofproto_v1_0.OFP_VENDOR_HEADER_SIZE:] + return msg def serialize_header(self): -- 1.7.4.4 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
