summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/ofproto/ofproto_v1_3_parser.py44
-rw-r--r--ryu/tests/unit/ofproto/json/of13/4-58-ofp_group_stats_reply.packet.json8
2 files changed, 46 insertions, 6 deletions
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index b12865e6..8d35db2d 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -3982,16 +3982,48 @@ class OFPQueueStatsReply(OFPMultipartReply):
super(OFPQueueStatsReply, self).__init__(datapath, **kwargs)
-class OFPGroupStats(ofproto_parser.namedtuple('OFPGroupStats', (
- 'length', 'group_id', 'ref_count', 'packet_count',
- 'byte_count', 'duration_sec', 'duration_nsec'))):
+class OFPBucketCounter(StringifyMixin):
+ def __init__(self, packet_count, byte_count):
+ super(OFPBucketCounter, self).__init__()
+ self.packet_count = packet_count
+ self.byte_count = byte_count
+
+ @classmethod
+ def parser(cls, buf, offset):
+ packet_count, byte_count = struct.unpack_from(
+ ofproto_v1_3.OFP_BUCKET_COUNTER_PACK_STR, buf, offset)
+ return cls(packet_count, byte_count)
+
+
+class OFPGroupStats(StringifyMixin):
+ def __init__(self, length=None, group_id=None, ref_count=None,
+ packet_count=None, byte_count=None, duration_sec=None,
+ duration_nsec=None, bucket_stats=None):
+ super(OFPGroupStats, self).__init__()
+ self.length = length
+ self.group_id = group_id
+ self.ref_count = ref_count
+ self.packet_count = packet_count
+ self.byte_count = byte_count
+ self.duration_sec = duration_sec
+ self.duration_nsec = duration_nsec
+ self.bucket_stats = bucket_stats
+
@classmethod
def parser(cls, buf, offset):
group = struct.unpack_from(ofproto_v1_3.OFP_GROUP_STATS_PACK_STR,
buf, offset)
- stats = cls(*group)
- stats.length = ofproto_v1_3.OFP_GROUP_STATS_SIZE
- return stats
+ group_stats = cls(*group)
+
+ group_stats.bucket_stats = []
+ total_len = group_stats.length + offset
+ offset += ofproto_v1_3.OFP_GROUP_STATS_SIZE
+ while total_len > offset:
+ b = OFPBucketCounter.parser(buf, offset)
+ group_stats.bucket_stats.append(b)
+ offset += ofproto_v1_3.OFP_BUCKET_COUNTER_SIZE
+
+ return group_stats
@_set_stats_type(ofproto_v1_3.OFPMP_GROUP, OFPGroupStats)
diff --git a/ryu/tests/unit/ofproto/json/of13/4-58-ofp_group_stats_reply.packet.json b/ryu/tests/unit/ofproto/json/of13/4-58-ofp_group_stats_reply.packet.json
index 012f174e..0caff1ce 100644
--- a/ryu/tests/unit/ofproto/json/of13/4-58-ofp_group_stats_reply.packet.json
+++ b/ryu/tests/unit/ofproto/json/of13/4-58-ofp_group_stats_reply.packet.json
@@ -3,6 +3,14 @@
"body": [
{
"OFPGroupStats": {
+ "bucket_stats": [
+ {
+ "OFPBucketCounter": {
+ "byte_count": 2345,
+ "packet_count": 234
+ }
+ }
+ ],
"byte_count": 12345,
"duration_nsec": 609036000,
"duration_sec": 9,