The unit test, "OFPST_TABLE reply - OF1.2" in ofp-print.at sends a very large hex string as an argument to 'ovs-ofctl ofp-print'. The length of the hex string exceeds the maximum command line length in Windows. With this commit, we can pass the same hex string by placing it inside a file.
Signed-off-by: Gurucharan Shetty <gshe...@nicira.com> --- tests/ofp-print.at | 2 +- utilities/ovs-ofctl.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/ofp-print.at b/tests/ofp-print.at index cfb604e..eea0f30 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -1442,7 +1442,7 @@ AT_KEYWORDS([ofp-print OFPT_STATS_REPLY]) printf "%02x $pad7" $x printf "%s$pad32" "table$x" | od -A n -t x1 -v -N 32 | tr '\n' ' ' echo -n "$mid 00 00 00 02 $tail") > in -AT_CHECK([ovs-ofctl ofp-print "$(cat in)"], [0], [expout]) +AT_CHECK([ovs-ofctl ofp-print - < in], [0], [expout]) AT_CLEANUP AT_SETUP([OFPST_TABLE reply - OF1.3]) diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 93f1382..c4034a0 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -3468,18 +3468,41 @@ ofctl_encode_error_reply(int argc OVS_UNUSED, char *argv[]) /* "ofp-print HEXSTRING [VERBOSITY]": Converts the hex digits in HEXSTRING into * binary data, interpreting them as an OpenFlow message, and prints the - * OpenFlow message on stdout, at VERBOSITY (level 2 by default). */ + * OpenFlow message on stdout, at VERBOSITY (level 2 by default). + * + * Alternative usage: "ofp-print [VERBOSITY] - < HEXSTRING_FILE", where + * HEXSTRING_FILE contains the HEXSTRING. */ static void ofctl_ofp_print(int argc, char *argv[]) { struct ofpbuf packet; + char *buffer; + int verbosity = 2; + struct ds line; + + ds_init(&line); + + if (!strcmp(argv[argc-1], "-")) { + if (ds_get_line(&line, stdin)) { + VLOG_FATAL("Failed to read stdin"); + } + + buffer = line.string; + verbosity = argc > 2 ? atoi(argv[1]) : verbosity; + } else if (argc > 2) { + buffer = argv[1]; + verbosity = atoi(argv[2]); + } else { + buffer = argv[1]; + } - ofpbuf_init(&packet, strlen(argv[1]) / 2); - if (ofpbuf_put_hex(&packet, argv[1], NULL)[0] != '\0') { + ofpbuf_init(&packet, strlen(buffer) / 2); + if (ofpbuf_put_hex(&packet, buffer, NULL)[0] != '\0') { ovs_fatal(0, "trailing garbage following hex bytes"); } - ofp_print(stdout, ofpbuf_data(&packet), ofpbuf_size(&packet), argc > 2 ? atoi(argv[2]) : 2); + ofp_print(stdout, ofpbuf_data(&packet), ofpbuf_size(&packet), verbosity); ofpbuf_uninit(&packet); + ds_destroy(&line); } /* "encode-hello BITMAP...": Encodes each BITMAP as an OpenFlow hello message -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev