X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fofp-print.c;h=3d3b919387958e22ad5ea7538c37b9069d51961f;hb=4b9f923273fb79079fcfa15350299b71a0062969;hp=48b8daa964570c52e3a0c3e894c1bdb9e727def7;hpb=2b07c8b182b76e4e3a162796d3ae273ef51d4131;p=openvswitch diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 48b8daa9..3d3b9193 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1519,6 +1519,14 @@ ofp_print_version(const struct ofp_header *oh, ds_put_format(string, " (xid=0x%"PRIx32"):", ntohl(oh->xid)); } +static void +ofp_header_to_string__(const struct ofp_header *oh, + const struct ofputil_msg_type *type, struct ds *string) +{ + ds_put_cstr(string, ofputil_msg_type_name(type)); + ofp_print_version(oh, string); +} + static void ofp_to_string__(const struct ofp_header *oh, const struct ofputil_msg_type *type, struct ds *string, @@ -1527,8 +1535,7 @@ ofp_to_string__(const struct ofp_header *oh, enum ofputil_msg_code code; const void *msg = oh; - ds_put_cstr(string, ofputil_msg_type_name(type)); - ofp_print_version(oh, string); + ofp_header_to_string__(oh, type, string); code = ofputil_msg_type_code(type); switch (code) { case OFPUTIL_MSG_INVALID: @@ -1730,6 +1737,15 @@ ofp_to_string(const void *oh_, size_t len, int verbosity) ds_put_format(&string, "OpenFlow packet too short (only %zu bytes):\n", len); } else if (ntohs(oh->length) > len) { + const struct ofputil_msg_type *type; + enum ofperr error; + + error = ofputil_decode_msg_type_partial(oh, len, &type); + if (!error) { + ofp_header_to_string__(oh, type, &string); + ds_put_char(&string, '\n'); + } + ds_put_format(&string, "(***truncated to %zu bytes from %"PRIu16"***)\n", len, ntohs(oh->length));