ofp-print: Print OpenFlow version number of message, unless it's 1.0.
authorBen Pfaff <blp@nicira.com>
Wed, 15 Feb 2012 23:28:25 +0000 (15:28 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 7 Mar 2012 22:05:08 +0000 (14:05 -0800)
The version number is an important part of the OpenFlow message's
meaning, so include it.  Version 1.0 is grandfathered in so existing output
parsers don't have to change.

Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-print.c
tests/ofp-print.at

index b1f46df83fb7cacbeb15ffcfbc5a8ba4e079c4cc..c5312a38dbe87b774aed884b7a95a4701fcc86c1 100644 (file)
@@ -1424,8 +1424,18 @@ ofp_to_string__(const struct ofp_header *oh,
     enum ofputil_msg_code code;
     const void *msg = oh;
 
-    ds_put_format(string, "%s (xid=0x%"PRIx32"):",
-                  ofputil_msg_type_name(type), ntohl(oh->xid));
+    ds_put_cstr(string, ofputil_msg_type_name(type));
+    switch (oh->version) {
+    case OFP10_VERSION:
+        break;
+    case OFP11_VERSION:
+        ds_put_cstr(string, " (OF1.1)");
+        break;
+    default:
+        ds_put_format(string, " (OF 0x%02"PRIx8")", oh->version);
+        break;
+    }
+    ds_put_format(string, " (xid=0x%"PRIx32"):", ntohl(oh->xid));
 
     code = ofputil_msg_type_code(type);
     switch (code) {
index 6d17d01cc0476dc1402224164fbede6cd4de54a5..46b16175b8977fdc2d9ad4a2fb2c93087cf44b16 100644 (file)
@@ -68,7 +68,7 @@ AT_CLEANUP
 AT_SETUP([OFPT_ERROR with type OFPET_HELLO_FAILED - OF1.1])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print 020100170000000000000001657874726120646174610a], [0], [dnl
-OFPT_ERROR (xid=0x0): OFPHFC_EPERM
+OFPT_ERROR (OF1.1) (xid=0x0): OFPHFC_EPERM
 extra data\012
 ])
 AT_CLEANUP
@@ -93,7 +93,7 @@ AT_CLEANUP
 AT_SETUP([OFPT_ERROR with code NXBRC_NXM_BAD_PREREQ - OF1.1])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print '0201001c55555555 b0c20000 0000232000010104 0102000811111111'], [0], [dnl
-OFPT_ERROR (xid=0x55555555): NXBRC_NXM_BAD_PREREQ
+OFPT_ERROR (OF1.1) (xid=0x55555555): NXBRC_NXM_BAD_PREREQ
 OFPT_ECHO_REQUEST (xid=0x11111111): 0 bytes of payload
 ])
 AT_CLEANUP
@@ -111,7 +111,7 @@ AT_CLEANUP
 AT_SETUP([OFPT_ERROR with type OFPBIC_UNSUP_INST - OF1.1])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print 02010014000000000003000102bbccddeeff0011], [0], [dnl
-OFPT_ERROR (xid=0x0): OFPBIC_UNSUP_INST
+OFPT_ERROR (OF1.1) (xid=0x0): OFPBIC_UNSUP_INST
 (***truncated to 8 bytes from 52445***)
 00000000  02 bb cc dd ee ff 00 11-                        |........        |
 ])