aboutsummaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-11-09 10:00:22 -0800
committerBen Pfaff <blp@nicira.com>2012-11-09 10:01:43 -0800
commit681ea7a0e98edf156aab79b062425d7ac638e415 (patch)
treec534998a597bdee252d523c9127c6bc0cec95c61 /utilities
parent1804d25a21dcdec83437ab1ebf9daf683d7e50da (diff)
tests: Add tests for encoding and decoding OpenFlow hello messages.
These tests helped me find the problems that I fixed in previous commits. Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 900c3d8d..0c146a42 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -2718,6 +2718,20 @@ ofctl_ofp_print(int argc, char *argv[])
ofpbuf_uninit(&packet);
}
+/* "encode-hello BITMAP...": Encodes each BITMAP as an OpenFlow hello message
+ * and dumps each message in hex. */
+static void
+ofctl_encode_hello(int argc OVS_UNUSED, char *argv[])
+{
+ uint32_t bitmap = strtol(argv[1], NULL, 0);
+ struct ofpbuf *hello;
+
+ hello = ofputil_encode_hello(bitmap);
+ ovs_hex_dump(stdout, hello->data, hello->size, 0, false);
+ ofp_print(stdout, hello->data, hello->size, verbosity);
+ ofpbuf_delete(hello);
+}
+
static const struct command all_commands[] = {
{ "show", 1, 1, ofctl_show },
{ "monitor", 1, 3, ofctl_monitor },
@@ -2758,6 +2772,7 @@ static const struct command all_commands[] = {
{ "check-vlan", 2, 2, ofctl_check_vlan },
{ "print-error", 1, 1, ofctl_print_error },
{ "ofp-print", 1, 2, ofctl_ofp_print },
+ { "encode-hello", 1, 1, ofctl_encode_hello },
{ NULL, 0, 0, NULL },
};