From 97c1aad368215fbd8825048fe9db1cd71bbeebd0 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Wed, 24 Apr 2013 12:19:53 +0900 Subject: of1.3: parser should return msg, not implicit None And OFPSetConfig should have serializer, not parser Because the message is sent by controller to OF switch. Cc: nitish nagesh Cc: Yoshihiro Kaneko Signed-off-by: Isaku Yamahata Signed-off-by: FUJITA Tomonori --- ryu/ofproto/ofproto_v1_3_parser.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py index d9a0ec3b..3213115b 100644 --- a/ryu/ofproto/ofproto_v1_3_parser.py +++ b/ryu/ofproto/ofproto_v1_3_parser.py @@ -1,5 +1,5 @@ # Copyright (C) 2012 Nippon Telegraph and Telephone Corporation. -# Copyright (C) 2012 Isaku Yamahata +# Copyright (C) 2012, 2013 Isaku Yamahata # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -2793,6 +2793,8 @@ class OFPRoleRequest(MsgBase): class OFPRoleReply(MsgBase): def __init__(self, datapath): super(OFPRoleReply, self).__init__(datapath) + self.role = None + self.generation_id = None @classmethod def parser(cls, datapath, version, msg_type, msg_len, xid, buf): @@ -2802,6 +2804,7 @@ class OFPRoleReply(MsgBase): (msg.role, msg.generation_id) = struct.unpack_from( ofproto_v1_3.OFP_ROLE_REQUEST_PACK_STR, msg.buf, ofproto_v1_3.OFP_HEADER_SIZE) + return msg @_set_msg_type(ofproto_v1_3.OFPT_GET_ASYNC_REQUEST) @@ -2815,6 +2818,9 @@ class OFPGetAsyncRequest(MsgBase): class OFPGetAsyncReply(MsgBase): def __init__(self, datapath): super(OFPGetAsyncReply, self).__init__(datapath) + self.packet_in_mask = None + self.port_status_mask = None + self.flow_removed_mask = None @classmethod def parser(cls, datapath, version, msg_type, msg_len, xid, buf): @@ -2825,20 +2831,20 @@ class OFPGetAsyncReply(MsgBase): msg.flow_removed_mask) = struct.unpack_from( ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf, ofproto_v1_3.OFP_HEADER_SIZE) + return msg -@_register_parser @_set_msg_type(ofproto_v1_3.OFPT_SET_ASYNC) class OFPSetAsync(MsgBase): - def __init__(self, datapath): + def __init__(self, datapath, + packet_in_mask, port_status_mask, flow_removed_mask): super(OFPSetAsync, self).__init__(datapath) + self.packet_in_mask = packet_in_mask + self.port_status_mask = port_status_mask + self.flow_removed_mask = flow_removed_mask - @classmethod - def parser(cls, datapath, version, msg_type, msg_len, xid, buf): - msg = super(OFPSetAsync, cls).parser(datapath, version, - msg_type, msg_len, - xid, buf) - (msg.packet_in_mask, msg.port_status_mask, - msg.flow_removed_mask) = struct.unpack_from( - ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, msg.buf, - ofproto_v1_3.OFP_HEADER_SIZE) + def _serialize_body(self): + msg_pack_into(ofproto_v1_3.OFP_ASYNC_CONFIG_PACK_STR, self.buf, + ofproto_v1_3.OFP_HEADER_SIZE, + self.packet_in_mask, self.port_status_mask, + self.flow_removed_mask) -- cgit v1.2.3