OFPStatsReply needs to handle variable-length bodys (flow stats) so
having two parsers (parser_stats_body_array and parser_stats_body)
doesn't make sense. Just kill parser_stats_body_array().

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/ofproto_v1_0_parser.py |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index f55e55f..322eca1 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -690,7 +690,9 @@ class OFPDescStats(collections.namedtuple('OFPDescStats',
     def parser(cls, buf, offset):
         desc = struct.unpack_from(ofproto_v1_0.OFP_DESC_STATS_PACK_STR,
                                   buf, offset)
-        return cls(*desc)
+        stats = cls(*desc)
+        stats.length = ofproto_v1_0.OFP_DESC_STATS_SIZE
+        return stats
 
 
 class OFPFlowStats(object):
@@ -1274,7 +1276,7 @@ class OFPStatsReply(MsgBase):
         self.body = None
 
     @classmethod
-    def parser_stats_body_array(cls, buf, msg_len, offset, entry_size):
+    def parser_stats_body(cls, buf, msg_len, offset):
         body_cls = cls.cls_stats_body_cls
         body = []
         while offset < msg_len:
@@ -1284,14 +1286,6 @@ class OFPStatsReply(MsgBase):
         return body
 
     @classmethod
-    def parser_stats_body(cls, buf, msg_len, offset):
-        if cls.cls_stats_body_cls_size == 0:
-            return cls.cls_stats_body_cls.parser(buf, offset)
-
-        return cls.parser_stats_body_array(buf, msg_len, offset,
-                                           cls.cls_stats_body_cls_size)
-
-    @classmethod
     def parser_stats(cls, datapath, version, msg_type, msg_len, xid, buf):
         # call MsgBase::parser, not OFPStatsReply::parser
         msg = MsgBase.parser.__func__(
-- 
1.7.4.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to