summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-09-02 15:05:56 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-09-02 19:41:37 +0900
commitdd10c22d5a36820883a43ad44e001f93f7ac0380 (patch)
tree2be00cb6c49c574598191397ddc087d6f0441a34
parentbed4bd1e02bab4e5e957697c2c9418a732608daf (diff)
of12: make OFPMatch "type" and "length" visible to users
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py
index a893b6a2..4ff7bc97 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -584,7 +584,7 @@ class OFPPacketIn(MsgBase):
msg.match = OFPMatch.parser(msg.buf, ofproto_v1_2.OFP_PACKET_IN_SIZE -
ofproto_v1_2.OFP_MATCH_SIZE)
- match_len = utils.round_up(msg.match._length, 8)
+ match_len = utils.round_up(msg.match.length, 8)
msg.data = msg.buf[(ofproto_v1_2.OFP_PACKET_IN_SIZE -
ofproto_v1_2.OFP_MATCH_SIZE + match_len + 2):]
@@ -2089,7 +2089,7 @@ class OFPFlowStats(StringifyMixin):
ofproto_v1_2.OFP_MATCH_SIZE)
match = OFPMatch.parser(buf, offset)
- match_length = utils.round_up(match._length, 8)
+ match_length = utils.round_up(match.length, 8)
inst_length = (length - (ofproto_v1_2.OFP_FLOW_STATS_SIZE -
ofproto_v1_2.OFP_MATCH_SIZE + match_length))
offset += match_length
@@ -3255,11 +3255,14 @@ class OFPMatch(StringifyMixin):
('2001:db8:bd05:1d2:288a:1fc0:1:10ee', 'ffff:ffff:ffff:ffff::')
"""
- def __init__(self, _ordered_fields=None, **kwargs):
+ def __init__(self, type_=None, length=None, _ordered_fields=None,
+ **kwargs):
super(OFPMatch, self).__init__()
self._wc = FlowWildcards()
self._flow = Flow()
self.fields = []
+ self.type = ofproto_v1_2.OFPMT_OXM
+ self.length = length
if not _ordered_fields is None:
assert not kwargs
@@ -3310,7 +3313,9 @@ class OFPMatch(StringifyMixin):
o = self
body = {"oxm_fields": [ofproto_v1_2.oxm_to_jsondict(k, uv) for k, uv
- in o._fields2]}
+ in o._fields2],
+ "length": o.length,
+ "type": o.type}
return {self.__class__.__name__: body}
@classmethod
@@ -3430,6 +3435,7 @@ class OFPMatch(StringifyMixin):
length = field_offset - offset
msg_pack_into(hdr_pack_str, buf, offset,
ofproto_v1_2.OFPMT_OXM, length)
+ self.length = length
pad_len = utils.round_up(length, 8) - length
ofproto_parser.msg_pack_into("%dx" % pad_len, buf, field_offset)
@@ -3646,7 +3652,7 @@ class OFPMatch(StringifyMixin):
type_, length = struct.unpack_from('!HH', buf, offset)
match.type = type_
- match._length = length
+ match.length = length
# ofp_match adjustment
offset += 4