From 070ab184dce4404f285f13a691902db0ff4413ef Mon Sep 17 00:00:00 2001
From: Sriram Natarajan <natarajan.sriram@gmail.com>
Date: Sun, 21 Sep 2014 19:27:40 -0700
Subject: [PATCH] Improve debug messages for unsupported request Log correct
 debug message

Signed-off-by: Sriram Natarajan <natarajan.sriram@gmail.com>
---
 ryu/app/ofctl_rest.py | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py
index 0dcdbaa..125554f 100644
--- a/ryu/app/ofctl_rest.py
+++ b/ryu/app/ofctl_rest.py
@@ -202,6 +202,10 @@ class StatsController(ControllerBase):
 
         if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             meters = ofctl_v1_3.get_meter_features(dp, self.waiters)
+        elif dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
+                dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -216,6 +220,10 @@ class StatsController(ControllerBase):
 
         if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             meters = ofctl_v1_3.get_meter_config(dp, self.waiters)
+        elif dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
+                dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -230,6 +238,10 @@ class StatsController(ControllerBase):
 
         if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             meters = ofctl_v1_3.get_meter_stats(dp, self.waiters)
+        elif dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
+                dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -246,6 +258,9 @@ class StatsController(ControllerBase):
             groups = ofctl_v1_2.get_group_features(dp, self.waiters)
         elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             groups = ofctl_v1_3.get_group_features(dp, self.waiters)
+        elif do.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -262,6 +277,9 @@ class StatsController(ControllerBase):
             groups = ofctl_v1_2.get_group_desc(dp, self.waiters)
         elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             groups = ofctl_v1_3.get_group_desc(dp, self.waiters)
+        elif do.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -278,6 +296,9 @@ class StatsController(ControllerBase):
             groups = ofctl_v1_2.get_group_stats(dp, self.waiters)
         elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             groups = ofctl_v1_3.get_group_stats(dp, self.waiters)
+        elif do.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -369,11 +390,6 @@ class StatsController(ControllerBase):
         if dp is None:
             return Response(status=404)
 
-        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
-                dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
-            LOG.debug('Unsupported OF protocol')
-            return Response(status=501)
-
         if cmd == 'add':
             cmd = dp.ofproto.OFPMC_ADD
         elif cmd == 'modify':
@@ -385,6 +401,10 @@ class StatsController(ControllerBase):
 
         if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             ofctl_v1_3.mod_meter_entry(dp, flow, cmd)
+        elif dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION or \
+                dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
@@ -404,7 +424,7 @@ class StatsController(ControllerBase):
             return Response(status=404)
 
         if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
-            LOG.debug('Unsupported OF protocol')
+            LOG.debug('Request not supported in this OF protocol version')
             return Response(status=501)
 
         if cmd == 'add':
@@ -482,6 +502,9 @@ class StatsController(ControllerBase):
             ofctl_v1_2.send_experimenter(dp, exp)
         elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
             ofctl_v1_3.send_experimenter(dp, exp)
+        elif do.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
+            LOG.debug('Request not supported in this OF protocol version')
+            return Response(status=501)
         else:
             LOG.debug('Unsupported OF protocol')
             return Response(status=501)
-- 
1.8.5.2 (Apple Git-48)

