diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-05 15:02:09 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2012-07-06 01:06:32 +0900 |
commit | 8843a8d9cce49f9633b622e7133e70eefc117cb6 (patch) | |
tree | f549c7349d510e3d8288ff2301950198288d5353 | |
parent | 8de8d653cc9db576852e00265871f709dc98d995 (diff) |
of1.2: fix OFPBucket parser and serialize methods
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/ofproto/ofproto_v1_2_parser.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py index 228248e7..09cce743 100644 --- a/ryu/ofproto/ofproto_v1_2_parser.py +++ b/ryu/ofproto/ofproto_v1_2_parser.py @@ -769,20 +769,32 @@ class OFPBucket(object): @classmethod def parser(cls, buf, offset): - (msg.len, msg.weigth, msg.watch_port, - msg.watch_group) = struct.unpack_from( + (len_, weigth, watch_port, watch_group) = struct.unpack_from( ofproto_v1_2.OFP_BUCKET_PACK_STR, buf, offset) length = ofproto_v1_2.OFP_BUCKET_SIZE offset += ofproto_v1_2.OFP_BUCKET_SIZE - msg.actions = [] - while length < msg.len: + actions = [] + while length < len_: action = OFPAction.parser(buf, offset) - msg.actions.append(action) + actions.append(action) offset += action.len length += action.len - return msg + return cls(len_, weigth, watch_port, watch_group, actions) + + def serialize(self, buf, offset): + action_offset = offset + ofproto_v1_2.OFP_BUCKET_SIZE + action_len = 0 + for a in self.actions: + a.serialize(buf, action_offset) + action_offset += a.len + action_len += a.len + + self.len = utils.round_up(ofproto_v1_2.OFP_BUCKET_SIZE + action_len, + 8) + msg_pack_into(ofproto_v1_2.OFP_BUCKET_PACK_STR, buf, offset, + self.len, self.weight, self.watch_port, self.watch_group) @_set_msg_type(ofproto_v1_2.OFPT_GROUP_MOD) |