Signed-off-by: Simon Horman <[email protected]>
---
 ryu/ofproto/ofproto_v1_4.py        |  5 +++
 ryu/ofproto/ofproto_v1_4_parser.py | 85 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)

diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 48526bf..70f7b45 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -1128,6 +1128,11 @@ OFP_BUCKET_COUNTER_PACK_STR = '!QQ'
 OFP_BUCKET_COUNTER_SIZE = 16
 assert calcsize(OFP_BUCKET_COUNTER_PACK_STR) == OFP_BUCKET_COUNTER_SIZE
 
+# struct ofp_group_desc_stats
+OFP_GROUP_DESC_STATS_PACK_STR = '!HBxI'
+OFP_GROUP_DESC_STATS_SIZE = 8
+assert calcsize(OFP_GROUP_DESC_STATS_PACK_STR) == OFP_GROUP_DESC_STATS_SIZE
+
 # struct ofp_group_stats
 OFP_GROUP_STATS_PACK_STR = '!H2xII4xQQII'
 OFP_GROUP_STATS_SIZE = 40
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py 
b/ryu/ofproto/ofproto_v1_4_parser.py
index e09b83e..b5716c9 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -1838,6 +1838,91 @@ class OFPGroupStatsReply(OFPMultipartReply):
         super(OFPGroupStatsReply, self).__init__(datapath, **kwargs)
 
 
+class OFPGroupDescStats(StringifyMixin):
+    def __init__(self, type_=None, group_id=None, buckets=None, length=None):
+        super(OFPGroupDescStats, self).__init__()
+        self.type = type_
+        self.group_id = group_id
+        self.buckets = buckets
+
+    @classmethod
+    def parser(cls, buf, offset):
+        stats = cls()
+
+        (stats.length, stats.type, stats.group_id) = struct.unpack_from(
+            ofproto.OFP_GROUP_DESC_STATS_PACK_STR, buf, offset)
+        offset += ofproto.OFP_GROUP_DESC_STATS_SIZE
+
+        stats.buckets = []
+        length = ofproto.OFP_GROUP_DESC_STATS_SIZE
+        while length < stats.length:
+            bucket = OFPBucket.parser(buf, offset)
+            stats.buckets.append(bucket)
+
+            offset += bucket.len
+            length += bucket.len
+
+        return stats
+
+
+@_set_stats_type(ofproto.OFPMP_GROUP_DESC, OFPGroupDescStats)
+@_set_msg_type(ofproto.OFPT_MULTIPART_REQUEST)
+class OFPGroupDescStatsRequest(OFPMultipartRequest):
+    """
+    Group description request message
+
+    The controller uses this message to list the set of groups on a switch.
+
+    ================ ======================================================
+    Attribute        Description
+    ================ ======================================================
+    flags            Zero or ``OFPMPF_REQ_MORE``
+    ================ ======================================================
+
+    Example::
+
+        def send_group_desc_stats_request(self, datapath):
+            ofp = datapath.ofproto
+            ofp_parser = datapath.ofproto_parser
+
+            req = ofp_parser.OFPGroupDescStatsRequest(datapath, 0)
+            datapath.send_msg(req)
+    """
+    def __init__(self, datapath, flags, type_=None):
+        super(OFPGroupDescStatsRequest, self).__init__(datapath, flags)
+
+
[email protected]_stats_type()
+@_set_stats_type(ofproto.OFPMP_GROUP_DESC, OFPGroupDescStats)
+@_set_msg_type(ofproto.OFPT_MULTIPART_REPLY)
+class OFPGroupDescStatsReply(OFPMultipartReply):
+    """
+    Group description reply message
+
+    The switch responds with this message to a group description request.
+
+    ================ ======================================================
+    Attribute        Description
+    ================ ======================================================
+    body             List of ``OFPGroupDescStats`` instance
+    ================ ======================================================
+
+    Example::
+
+        @set_ev_cls(ofp_event.EventOFPGroupDescStatsReply, MAIN_DISPATCHER)
+        def group_desc_stats_reply_handler(self, ev):
+            descs = []
+            for stat in ev.msg.body:
+                descs.append('length=%d type=%d group_id=%d '
+                             'buckets=%s' %
+                             (stat.length, stat.type, stat.group_id,
+                              stat.bucket))
+            self.logger.debug('GroupDescStats: %s', groups)
+    """
+    def __init__(self, datapath, type_=None, **kwargs):
+        super(OFPGroupDescStatsReply, self).__init__(datapath, **kwargs)
+
+
 class OFPGroupFeaturesStats(ofproto_parser.namedtuple('OFPGroupFeaturesStats',
                             ('types', 'capabilities', 'max_groups',
                              'actions'))):
-- 
1.8.5.2


------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to