add a new match field parser which fills OFPMatch attributes used
by the new api.

the old parser which fills match.fields is kept for now but will be
removed later.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 ryu/ofproto/ofproto_v1_3_parser.py | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_3_parser.py 
b/ryu/ofproto/ofproto_v1_3_parser.py
index 734749f..163d955 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -675,14 +675,43 @@ class OFPMatch(StringifyMixin):
         # ofp_match adjustment
         offset += 4
         length -= 4
+
+        # XXXcompat
+        cls.parser_old(match, buf, offset, length)
+
+        fields = {}
+        while length > 0:
+            hdr_pack_str = '!I'
+            (header, ) = struct.unpack_from(hdr_pack_str, buf, offset)
+            hdr_len = struct.calcsize(hdr_pack_str)
+            oxm_type = header >> 9  # class|field
+            oxm_hasmask = ofproto_v1_3.oxm_tlv_header_extract_hasmask(header)
+            value_len = ofproto_v1_3.oxm_tlv_header_extract_length(header)
+            value_pack_str = '!%ds' % value_len
+            assert struct.calcsize(value_pack_str) == value_len
+            (value, ) = struct.unpack_from(value_pack_str, buf,
+                                           offset + hdr_len)
+            if oxm_hasmask:
+                (mask, ) = struct.unpack_from(value_pack_str, buf,
+                                              offset + hdr_len + value_len)
+            else:
+                mask = None
+            k, uv = oxm_fields.to_user(oxm_type, value, mask)
+            fields[k] = uv
+            field_len = hdr_len + (header & 0xff)
+            offset += field_len
+            length -= field_len
+        match._fields2 = fields
+        return match
+
+    @staticmethod
+    def parser_old(match, buf, offset, length):
         while length > 0:
             field = OFPMatchField.parser(buf, offset)
             offset += field.length
             length -= field.length
             match.fields.append(field)
 
-        return match
-
     def set_in_port(self, port):
         self._wc.ft_set(ofproto_v1_3.OFPXMT_OFB_IN_PORT)
         self._flow.in_port = port
-- 
1.8.1.5


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to