[ovs-dev] [PATCH 23/38] ofp-print: Allow printing of Open Flow 1.1 & 1.2 Port Status Request Messages

Simon Horman horms at verge.net.au
Thu Aug 9 08:49:44 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>

---

v11
* No change

v10
* No change

v9
* Manual Rebase
* Make use of enum ofp_version
* Change title from "ofp-print: Allow display of Open Flow 1.1 & 1.2 Port Status
  Request Messages" to "ofp-print: Allow printing of Open Flow 1.1 & 1.2 Port Status
  Request Messages"
* Add ofp-print test

v8
* Omitted

v7
* Omitted

v6
* No change

v5
* Initial Post
---
 lib/ofp-print.c    | 19 +++++++++++++++++--
 tests/ofp-print.at | 22 +++++++++++++++++++++-
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index c1bcbcf..20965a2 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1091,8 +1091,23 @@ static void print_port_stat(struct ds *string, const char *leader,
 static void
 ofp_print_ofpst_port_request(struct ds *string, const struct ofp_header *oh)
 {
-    const struct ofp10_port_stats_request *psr = ofpmsg_body(oh);
-    ds_put_format(string, " port_no=%"PRIu16, ntohs(psr->port_no));
+    switch ((enum ofp_version)oh->version) {
+    case OFP12_VERSION:
+    case OFP11_VERSION: {
+        const struct ofp11_port_stats_request *psr = ofpmsg_body(oh);
+        ds_put_format(string, " port_no=%"PRIu32, ntohl(psr->port_no));
+        break;
+    }
+
+    case OFP10_VERSION: {
+        const struct ofp10_port_stats_request *psr = ofpmsg_body(oh);
+        ds_put_format(string, " port_no=%"PRIu16, ntohs(psr->port_no));
+        break;
+    }
+
+    default:
+        NOT_REACHED();
+    }
 }
 
 static void
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 732a771..0871526 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -874,7 +874,7 @@ AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
 AT_CHECK([ovs-ofctl ofp-print "$(cat in)"], [0], [expout])
 AT_CLEANUP
 
-AT_SETUP([OFPST_PORT request])
+AT_SETUP([OFPST_PORT request - 1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "\
 01 10 00 14 00 00 00 01 00 04 00 00 ff ff 00 00 \
@@ -884,6 +884,26 @@ OFPST_PORT request (xid=0x1): port_no=65535
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPST_PORT request - 1.1])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+02 12 00 18 00 00 00 02 00 04 00 00 00 00 00 00 \
+ff ff 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_PORT request (OF1.1) (xid=0x2): port_no=4294901760
+])
+AT_CLEANUP
+
+AT_SETUP([OFPST_PORT request - 1.2])
+AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
+AT_CHECK([ovs-ofctl ofp-print "\
+03 12 00 18 00 00 00 02 00 04 00 00 00 00 00 00 \
+ff ff 00 00 00 00 00 00 \
+"], [0], [dnl
+OFPST_PORT request (OF1.2) (xid=0x2): port_no=4294901760
+])
+AT_CLEANUP
+
 AT_SETUP([OFPST_PORT reply - OF1.0])
 AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
 AT_CHECK([ovs-ofctl ofp-print "\
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list