summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-12-13 16:27:20 -0800
committerBen Pfaff <blp@nicira.com>2010-12-15 09:48:18 -0800
commit49ad0403a79ed166fad156dd649f8f9d63fc9dc3 (patch)
treead73a09bb6b954ac74af550bf78bd16a9b8c5b8a
parentf904747bf8131f8065d88496efa548760e45a4c3 (diff)
downloadopenvswitch-49ad0403a79ed166fad156dd649f8f9d63fc9dc3.tar.gz
ofp-print: Improve formatting for bad OpenFlow messages.
-rw-r--r--lib/ofp-print.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index e56556978..63edb79c4 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -1036,7 +1036,7 @@ ofp_print_error(struct ds *string, int error)
if (string->length) {
ds_put_char(string, ' ');
}
- ds_put_format(string, " ***decode error type:%d(%s) code:%d(%s)***",
+ ds_put_format(string, " ***decode error type:%d(%s) code:%d(%s)***\n",
type, lookup_error_type(type),
code, lookup_error_code(type, code));
}
@@ -1720,14 +1720,17 @@ ofp_to_string(const void *oh_, size_t len, int verbosity)
struct ds string = DS_EMPTY_INITIALIZER;
const struct ofp_header *oh = oh_;
- if (len < sizeof(struct ofp_header)) {
- ds_put_cstr(&string, "OpenFlow packet too short:\n");
+ if (!len) {
+ ds_put_cstr(&string, "OpenFlow message is empty\n");
+ } else if (len < sizeof(struct ofp_header)) {
+ ds_put_format(&string, "OpenFlow packet too short (only %zu bytes):\n",
+ len);
} else if (oh->version != OFP_VERSION) {
ds_put_format(&string, "Bad OpenFlow version %"PRIu8":\n",
oh->version);
} else if (ntohs(oh->length) > len) {
ds_put_format(&string,
- "(***truncated to %zu bytes from %"PRIu16"***)",
+ "(***truncated to %zu bytes from %"PRIu16"***)\n",
len, ntohs(oh->length));
} else if (ntohs(oh->length) < len) {
ds_put_format(&string,