This is on the top of the patch that I sent last night.

I think that Ryu fully supports of1.2 now.

=
>From 086c66f23332a914b4a8dcc34542eba96e50f877 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Wed, 27 Jun 2012 08:52:22 +0900
Subject: [PATCH] of1.2: add OFPFlowStats support

Add PORT, QUEUE, GROUP, GROUP_DESC, and GROUP_FEATURES

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

diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index 5bc81f1..4f2d057 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -977,6 +977,184 @@ class OFPTableStats(
         return stats
 
 
+@_set_msg_type(ofproto_v1_2.OFPT_STATS_REQUEST)
+class OFPPortStatsRequest(OFPStatsRequest):
+    def __init__(self, datapath, port_no):
+        super(OFPPortStatsRequest, self).__init__(datapath,
+                                                  ofproto_v1_2.OFPST_PORT)
+        self.port_no = port_no
+
+    def _serialize_stats_body(self):
+        msg_pack_into(ofproto_v1_2.OFP_PORT_STATS_REQUEST_PACK_STR,
+                      self.buf, ofproto_v1_2.OFP_STATS_REQUEST_SIZE,
+                      self.port_no)
+
+
[email protected]_stats_reply_type(ofproto_v1_2.OFPST_PORT)
+class OFPPortStats(
+    collections.namedtuple('OFPPortStats',
+                           ('port_no', 'rx_packets', 'tx_packets',
+                            'rx_byptes', 'tx_bytes',
+                            'rx_dropped', 'tx_dropped',
+                            'rx_errors', 'tx_errors',
+                            'rx_frame_err', 'rx_over_err',
+                            'rx_crc_err', 'collisions'))):
+    @classmethod
+    def parser(cls, buf, offset):
+        port = struct.unpack_from(ofproto_v1_2.OFP_PORT_STATS_PACK_STR,
+                                  buf, offset)
+        stats = cls(*port)
+        stats.length = ofproto_v1_2.OFP_PORT_STATS_SIZE
+        return stats
+
+
+@_set_msg_type(ofproto_v1_2.OFPT_STATS_REQUEST)
+class OFPQueueStatsRequest(OFPStatsRequest):
+    def __init__(self, datapath, port_no, queue_id):
+        super(OFPQueueStatsRequest, self).__init__(datapath,
+                                                   ofproto_v1_2.OFPST_QUEUE)
+        self.port_no = port_no
+        self.queue_id = queue_id
+
+    def _serialize_stats_body(self):
+        msg_pack_into(ofproto_v1_2.OFP_QUEUE_STATS_REQUEST_PACK_STR,
+                      self.buf, ofproto_v1_2.OFP_STATS_REQUEST_SIZE,
+                      self.port_no, self.queue_id)
+
+
[email protected]_stats_reply_type(ofproto_v1_2.OFPST_QUEUE)
+class OFPQueueStats(
+    collections.namedtuple('OFPQueueStats',
+                           ('port_no', 'queue_id', 'tx_bytes',
+                            'tx_packets', 'tx_errors'))):
+    @classmethod
+    def parser(cls, buf, offset):
+        queue = struct.unpack_from(ofproto_v1_2.OFP_QUEUE_STATS_PACK_STR,
+                                   buf, offset)
+        stats = cls(*queue)
+        stats.length = ofproto_v1_2.OFP_QUEUE_STATS_SIZE
+        return stats
+
+
+class OFPBucketCounter(object):
+    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, byte = struct.unpack_from(
+            ofproto_v1_2.OFP_BUCKET_COUNTER_PACK_STR,
+            buf, offset)
+        return cls(packet, byte)
+
+
+@_set_msg_type(ofproto_v1_2.OFPT_STATS_REQUEST)
+class OFPGroupStatsRequest(OFPStatsRequest):
+    def __init__(self, datapath, group_id):
+        super(OFPGroupStatsRequest, self).__init__(datapath,
+                                                   ofproto_v1_2.OFPST_GROUP)
+        self.group_id = group_id
+
+    def _serialize_stats_body(self):
+        msg_pack_into(ofproto_v1_2.OFP_GROUP_STATS_REQUEST_PACK_STR,
+                      self.buf, ofproto_v1_2.OFP_STATS_REQUEST_SIZE,
+                      self.group_id)
+
+
[email protected]_stats_reply_type(ofproto_v1_2.OFPST_GROUP)
+class OFPGroupStats(object):
+    def __init__(self, length, group_id, ref_count, packet_count,
+                 byte_count, bucket_counters):
+        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.bucket_counters = bucket_counters
+
+    @classmethod
+    def parser(cls, buf, offset):
+        (length, group_id, ref_count, packet_count,
+                 byte_count) = struct.unpack_from(
+            ofproto_v1_2.OFP_GROUP_STATS_PACK_STR,
+            buf, offset)
+
+        bucket_len = length - ofproto_v1_2.OFP_GROUP_STATS_SIZE
+        offset += ofproto_v1_2.OFP_GROUP_STATS_SIZE
+        bucket_counters = []
+        while bucket_len > 0:
+            bucket_counters.append(OFPBucketCounter.parser(buf, offset))
+            offset += ofproto_v1_2.OFP_BUCKET_COUNTER_SIZE
+            bucket_len -= ofproto_v1_2.OFP_BUCKET_COUNTER_SIZE
+
+        return cls(length, group_id, ref_count, packet_count,
+                   byte_count, bucket_counters)
+
+
+@_set_msg_type(ofproto_v1_2.OFPT_STATS_REQUEST)
+class OFPGroupDescStatsRequest(OFPStatsRequest):
+    def __init__(self, datapath):
+        super(OFPGroupDescStatsRequest, self).__init__(
+            datapath,
+            ofproto_v1_2.OFPST_GROUP_DESC)
+
+
[email protected]_stats_reply_type(ofproto_v1_2.OFPST_GROUP_DESC)
+class OFPGroupDescStats(object):
+    def __init__(self, length, type_, group_id, buckets):
+        self.length = length
+        self.type = type_
+        self.group_id = group_id
+        self.buckets = buckets
+
+    @classmethod
+    def parser(cls, buf, offset):
+        (length, type_, group_id) = struct.unpack_from(
+            ofproto_v1_2.OFP_GROUP_DESC_STATS_PACK_STR,
+            buf, offset)
+
+        bucket_len = length - ofproto_v1_2.OFP_GROUP_DESC_STATS_SIZE
+        offset += ofproto_v1_2.OFP_GROUP_DESC_STATS_SIZE
+        buckets = []
+        while bucket_len > 0:
+            buckets.append(OFPBucket.parser(buf, offset))
+            offset += ofproto_v1_2.OFP_BUCKET_SIZE
+            bucket_len -= ofproto_v1_2.OFP_BUCKET_SIZE
+
+        return cls(length, type_, group_id, buckets)
+
+
+@_set_msg_type(ofproto_v1_2.OFPT_STATS_REQUEST)
+class OFPGroupFeaturesStatsRequest(OFPStatsRequest):
+    def __init__(self, datapath):
+        super(OFPGroupFeaturesStatsRequest, self).__init__(
+            datapath,
+            ofproto_v1_2.OFPST_GROUP_FEATURES)
+
+
[email protected]_stats_reply_type(ofproto_v1_2.OFPST_GROUP_FEATURES)
+class OFPGroupFeaturesStats(object):
+    def __init__(self, types, capabilities, max_groups, actions):
+        self.types = types
+        self.capabilities = capabilities
+        self.max_groups = max_groups
+        self.actions = acitons
+
+    @classmethod
+    def parser(cls, buf, offset):
+        stats = struct.unpack_from(
+            ofproto_v1_2.OFP_GROUP_FEATURES_STATS_PACK_STR, buf, offset)
+        types = stats[0]
+        capabilities = stats[1]
+        max_groups = stats[2:6]
+        acitons = stats[6:10]
+
+        return cls(types, capabilities, max_groups, actions)
+
+
 @_set_msg_type(ofproto_v1_2.OFPT_QUEUE_GET_CONFIG_REQUEST)
 class OFPQueueGetConfigRequest(MsgBase):
     def __init__(self, datapath, port):
-- 
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