summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-07-05 02:39:39 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-07-06 01:06:05 +0900
commitf132d53fb12329c59a4400843437159344936341 (patch)
tree4a735e28cde4123ed099c39f2972a59e9ef309da
parent1d415b8b6c6bfd729686d5225b4abaa499fd5376 (diff)
of1.2: fix OFPActionSetField
Parse and serialize OXM TLV. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py
index 099c6ea0..8a19bc8c 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -716,20 +716,25 @@ class OFPActionPopMpls(OFPAction):
@OFPAction.register_action_type(ofproto_v1_2.OFPAT_SET_FIELD,
ofproto_v1_2.OFP_ACTION_SET_FIELD_SIZE)
class OFPActionSetField(OFPAction):
- def __init__(self):
+ def __init__(self, field):
super(OFPActionSetField, self).__init__()
+ self.field = field
@classmethod
def parser(cls, buf, offset):
- (type_, len_) = struct.unpack_from(
- ofproto_v1_2.OFP_ACTION_SET_FIELD_PACK_STR, buf, offset)
- action = cls()
- # TODO: parse OXM
- return action
+ (type_, len_) = struct.unpack_from('!HH', buf, offset)
+ action.len = len_
+ field = OFPMatchField.parse(buf, offset + 4)
+ return cls(field)
def serialize(self, buf, offset):
- msg_pack_into(ofproto_v1_2.OFP_ACTION_SET_FIELD_PACK_STR, buf, offset)
- # TODO: serialize OXM
+ self.field.serialize(buf, offset + 4)
+ oxm_len = self.field.length
+ pad_len = utils.round_up(oxm_len + 4, 8) - (oxm_len + 4)
+ ofproto_parser.msg_pack_into("%dx" % pad_len, buf,
+ offset + 8 + oxm_len)
+ self.len = ofproto_v1_2.OFP_ACTION_SET_FIELD_SIZE + oxm_len + pad_len
+ msg_pack_into('!HH', buf, offset, self.type, self.len)
@OFPAction.register_action_type(
@@ -1916,6 +1921,9 @@ class OFPMatchField(object):
if len(mask):
self._putv6(buf, offset + self.length, mask)
+ def length(self):
+ return self.header & 0xff
+
@OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IN_PORT])
class MTInPort(OFPMatchField):