summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2014-01-29 12:06:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-01-29 12:43:25 +0900
commitd2c7855c5446d133356f166b65d0fb1fa583ba9c (patch)
tree6535dd829aadedd54605bc72b1bce3d5ba948f2d
parente91473016b6187991cd82d80852f86877339dd93 (diff)
Add OF1.4 OFPBucket
This will be used by support for messages that have buckets Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_4_parser.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py b/ryu/ofproto/ofproto_v1_4_parser.py
index 2365f50f..e09b83ed 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -3258,6 +3258,45 @@ class OFPActionPopPbb(OFPAction):
return cls()
+class OFPBucket(StringifyMixin):
+ def __init__(self, weight, watch_port, watch_group, actions, len_=None):
+ super(OFPBucket, self).__init__()
+ self.weight = weight
+ self.watch_port = watch_port
+ self.watch_group = watch_group
+ self.actions = actions
+
+ @classmethod
+ def parser(cls, buf, offset):
+ (len_, weight, watch_port, watch_group) = struct.unpack_from(
+ ofproto.OFP_BUCKET_PACK_STR, buf, offset)
+ msg = cls(weight, watch_port, watch_group, [])
+ msg.len = len_
+
+ length = ofproto.OFP_BUCKET_SIZE
+ offset += ofproto.OFP_BUCKET_SIZE
+ while length < msg.len:
+ action = OFPAction.parser(buf, offset)
+ msg.actions.append(action)
+ offset += action.len
+ length += action.len
+
+ return msg
+
+ def serialize(self, buf, offset):
+ action_offset = offset + ofproto.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.OFP_BUCKET_SIZE + action_len, 8)
+ msg_pack_into(ofproto.OFP_BUCKET_PACK_STR, buf, offset,
+ self.len, self.weight, self.watch_port,
+ self.watch_group)
+
+
@_set_msg_type(ofproto.OFPT_ROLE_REQUEST)
class OFPRoleRequest(MsgBase):
"""