On Fri, 18 May 2012 10:29:53 +0900 (JST) FUJITA Tomonori <[email protected]> wrote:
> On Fri, 18 May 2012 10:02:33 +0900 > Isaku Yamahata <[email protected]> wrote: > >> Oops. The length value is class-wide constants. >> >> class OFPXXXStats(...) >> length = ..._SIZE >> def parser... > > I like to make the way all the OFPXXStats (include set the length > consistent. But either is fine. Applied the following patch. I added the discussion to the commit log. = >From 9a4bd6c976ff9818e99f412a06a97569e0bae26b Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori <[email protected]> Date: Sat, 19 May 2012 21:58:59 +0900 Subject: [PATCH] fix StatsReply parser OFPStatsReply parser_stats_body_array needs body classes to have length field. We could set length as class-wide constants for classes having a fixed length however we have two classes that need a variable length so let's set the length in the same way for all the stats classes. Signed-off-by: FUJITA Tomonori <[email protected]> --- ryu/ofproto/ofproto_v1_0_parser.py | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index c44117f..ad7a893 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): @@ -749,7 +751,9 @@ class OFPAggregateStats(collections.namedtuple('OFPAggregateStats', def parser(cls, buf, offset): agg = struct.unpack_from( ofproto_v1_0.OFP_AGGREGATE_STATS_REPLY_PACK_STR, buf, offset) - return cls(*agg) + stats = cls(*agg) + stats.length = ofproto_v1_0.OFP_AGGREGATE_STATS_REPLY_SIZE + return stats class OFPTableStats(collections.namedtuple('OFPTableStats', @@ -759,7 +763,9 @@ class OFPTableStats(collections.namedtuple('OFPTableStats', def parser(cls, buf, offset): tbl = struct.unpack_from(ofproto_v1_0.OFP_TABLE_STATS_PACK_STR, buf, offset) - return cls(*tbl) + stats = cls(*tbl) + stats.length = ofproto_v1_0.OFP_TABLE_STATS_SIZE + return stats class OFPPortStats(collections.namedtuple('OFPPortStats', @@ -770,7 +776,9 @@ class OFPPortStats(collections.namedtuple('OFPPortStats', def parser(cls, buf, offset): port = struct.unpack_from(ofproto_v1_0.OFP_PORT_STATS_PACK_STR, buf, offset) - return cls(*port) + stats = cls(*port) + stats.length = ofproto_v1_0.OFP_PORT_STATS_SIZE + return stats class OFPQueueStats(collections.namedtuple('OFPQueueStats', @@ -779,7 +787,9 @@ class OFPQueueStats(collections.namedtuple('OFPQueueStats', def parser(cls, buf, offset): queue = struct.unpack_from(ofproto_v1_0.OFP_QUEUE_STATS_PACK_STR, buf, offset) - return cls(*queue) + stats = cls(*queue) + stats.length = ofproto_v1_0.OFP_QUEUE_STATS_SIZE + return stats class OFPVendorStats(collections.namedtuple('OFPVendorStats', -- 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
