From 7c14825c23d2fec7b14b4fdf6cf1a16ac416c812 Mon Sep 17 00:00:00 2001
From: Sriram Natarajan <natarajan.sriram@gmail.com>
Date: Wed, 17 Sep 2014 17:06:25 -0700
Subject: [PATCH] Add missing fields in OpenFlow statistics messages Update
 statistics structure to reflect OpenFlow specification

---
 ryu/lib/ofctl_v1_2.py |  7 +++----
 ryu/lib/ofctl_v1_3.py | 16 ++++++++++++----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index dec8c7e..da300f7 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -577,9 +577,7 @@ def get_queue_stats(dp, waiters):
     for msg in msgs:
         stats = msg.body
         for stat in stats:
-            s.append({'duration_nsec': stat.duration_nsec,
-                      'duration_sec': stat.duration_sec,
-                      'port_no': stat.port_no,
+            s.append({'port_no': stat.port_no,
                       'queue_id': stat.queue_id,
                       'tx_bytes': stat.tx_bytes,
                       'tx_errors': stat.tx_errors,
@@ -617,7 +615,8 @@ def get_flow_stats(dp, waiters, flow={}):
                  'duration_sec': stats.duration_sec,
                  'duration_nsec': stats.duration_nsec,
                  'packet_count': stats.packet_count,
-                 'table_id': stats.table_id}
+                 'table_id': stats.table_id,
+                 'length': stats.length}
             flows.append(s)
     flows = {str(dp.id): flows}
 
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 2369216..b60c4cc 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -648,7 +648,9 @@ def get_flow_stats(dp, waiters, flow={}):
                  'duration_sec': stats.duration_sec,
                  'duration_nsec': stats.duration_nsec,
                  'packet_count': stats.packet_count,
-                 'table_id': stats.table_id}
+                 'table_id': stats.table_id,
+                 'length': stats.length,
+                 'flags': stats.flags}
             flows.append(s)
     flows = {str(dp.id): flows}
 
@@ -676,7 +678,9 @@ def get_port_stats(dp, waiters):
                  'rx_frame_err': stats.rx_frame_err,
                  'rx_over_err': stats.rx_over_err,
                  'rx_crc_err': stats.rx_crc_err,
-                 'collisions': stats.collisions}
+                 'collisions': stats.collisions,
+                 'duration_sec': stats.duration_sec,
+                 'duration_nsec': stats.duration_nsec}
             ports.append(s)
     ports = {str(dp.id): ports}
     return ports
@@ -701,6 +705,8 @@ def get_meter_stats(dp, waiters):
                  'flow_count': stats.flow_count,
                  'packet_in_count': stats.packet_in_count,
                  'byte_in_count': stats.byte_in_count,
+                 'duration_sec': stats.duration_sec,
+                 'duration_nsec': stats.duration_nsec,
                  'band_stats': bands}
             meters.append(s)
     meters = {str(dp.id): meters}
@@ -726,7 +732,8 @@ def get_meter_features(dp, waiters):
                     band_types.append(v)
             f = {'max_meter': feature.max_meter,
                  'band_types': band_types,
-                 'max_band': feature.max_band,
+                 'capabilities': feature.capabilities,
+                 'max_bands': feature.max_bands,
                  'max_color': feature.max_color}
             features.append(f)
     features = {str(dp.id): features}
@@ -787,7 +794,8 @@ def get_group_stats(dp, waiters):
                 c = {'packet_count': bucket_stat.packet_count,
                      'byte_count': bucket_stat.byte_count}
                 bucket_stats.append(c)
-            g = {'group_id': stats.group_id,
+            g = {'length': stats.length,
+                 'group_id': stats.group_id,
                  'ref_count': stats.ref_count,
                  'packet_count': stats.packet_count,
                  'byte_count': stats.byte_count,
-- 
1.8.5.2 (Apple Git-48)

