X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-print.c;h=38e228c9de78f4481342b75ca3233cd9112e0e69;hb=9620f50ccce53b75c45949f3984029fa67241afe;hp=f9fd4c5412b7ff32034a02ecf8403c5579d0285c;hpb=5deff5aa263a72a99141e95e50821f77bc687f15;p=sliver-openvswitch.git diff --git a/lib/ofp-print.c b/lib/ofp-print.c index f9fd4c541..38e228c9d 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -62,25 +62,24 @@ ofp_packet_to_string(const void *data, size_t len) const struct pkt_metadata md = PKT_METADATA_INITIALIZER(0); struct ofpbuf buf; struct flow flow; + size_t l4_size; ofpbuf_use_const(&buf, data, len); flow_extract(&buf, &md, &flow); flow_format(&ds, &flow); - if (buf.l7) { - if (flow.nw_proto == IPPROTO_TCP) { - struct tcp_header *th = buf.l4; - ds_put_format(&ds, " tcp_csum:%"PRIx16, - ntohs(th->tcp_csum)); - } else if (flow.nw_proto == IPPROTO_UDP) { - struct udp_header *uh = buf.l4; - ds_put_format(&ds, " udp_csum:%"PRIx16, - ntohs(uh->udp_csum)); - } else if (flow.nw_proto == IPPROTO_SCTP) { - struct sctp_header *sh = buf.l4; - ds_put_format(&ds, " sctp_csum:%"PRIx32, - ntohl(sh->sctp_csum)); - } + l4_size = ofpbuf_l4_size(&buf); + + if (flow.nw_proto == IPPROTO_TCP && l4_size >= TCP_HEADER_LEN) { + struct tcp_header *th = ofpbuf_l4(&buf); + ds_put_format(&ds, " tcp_csum:%"PRIx16, ntohs(th->tcp_csum)); + } else if (flow.nw_proto == IPPROTO_UDP && l4_size >= UDP_HEADER_LEN) { + struct udp_header *uh = ofpbuf_l4(&buf); + ds_put_format(&ds, " udp_csum:%"PRIx16, ntohs(uh->udp_csum)); + } else if (flow.nw_proto == IPPROTO_SCTP && l4_size >= SCTP_HEADER_LEN) { + struct sctp_header *sh = ofpbuf_l4(&buf); + ds_put_format(&ds, " sctp_csum:%"PRIx32, + ntohl(get_16aligned_be32(&sh->sctp_csum))); } ds_put_char(&ds, '\n'); @@ -744,6 +743,12 @@ ofp_print_flow_flags(struct ds *s, enum ofputil_flow_mod_flags flags) if (flags & OFPUTIL_FF_NO_BYT_COUNTS) { ds_put_cstr(s, "no_byte_counts "); } + if (flags & OFPUTIL_FF_HIDDEN_FIELDS) { + ds_put_cstr(s, "allow_hidden_fields "); + } + if (flags & OFPUTIL_FF_NO_READONLY) { + ds_put_cstr(s, "no_readonly_table "); + } } static void @@ -1363,12 +1368,13 @@ ofp_print_error_msg(struct ds *string, const struct ofp_header *oh) ds_put_format(string, " %s\n", ofperr_get_name(error)); if (error == OFPERR_OFPHFC_INCOMPATIBLE || error == OFPERR_OFPHFC_EPERM) { - ds_put_printable(string, payload.data, payload.size); + ds_put_printable(string, ofpbuf_data(&payload), ofpbuf_size(&payload)); } else { - s = ofp_to_string(payload.data, payload.size, 1); + s = ofp_to_string(ofpbuf_data(&payload), ofpbuf_size(&payload), 1); ds_put_cstr(string, s); free(s); } + ofpbuf_uninit(&payload); } static void @@ -1665,7 +1671,7 @@ ofp_print_ofpst_table_reply13(struct ds *string, const struct ofp_header *oh, ofpbuf_use_const(&b, oh, ntohs(oh->length)); ofpraw_pull_assert(&b); - n = b.size / sizeof *ts; + n = ofpbuf_size(&b) / sizeof *ts; ds_put_format(string, " %"PRIuSIZE" tables\n", n); if (verbosity < 1) { return; @@ -1695,7 +1701,7 @@ ofp_print_ofpst_table_reply12(struct ds *string, const struct ofp_header *oh, ofpbuf_use_const(&b, oh, ntohs(oh->length)); ofpraw_pull_assert(&b); - n = b.size / sizeof *ts; + n = ofpbuf_size(&b) / sizeof *ts; ds_put_format(string, " %"PRIuSIZE" tables\n", n); if (verbosity < 1) { return; @@ -1722,7 +1728,7 @@ ofp_print_ofpst_table_reply11(struct ds *string, const struct ofp_header *oh, ofpbuf_use_const(&b, oh, ntohs(oh->length)); ofpraw_pull_assert(&b); - n = b.size / sizeof *ts; + n = ofpbuf_size(&b) / sizeof *ts; ds_put_format(string, " %"PRIuSIZE" tables\n", n); if (verbosity < 1) { return; @@ -1762,7 +1768,7 @@ ofp_print_ofpst_table_reply10(struct ds *string, const struct ofp_header *oh, ofpbuf_use_const(&b, oh, ntohs(oh->length)); ofpraw_pull_assert(&b); - n = b.size / sizeof *ts; + n = ofpbuf_size(&b) / sizeof *ts; ds_put_format(string, " %"PRIuSIZE" tables\n", n); if (verbosity < 1) { return; @@ -2289,6 +2295,9 @@ ofp_print_version(const struct ofp_header *oh, case OFP13_VERSION: ds_put_cstr(string, " (OF1.3)"); break; + case OFP14_VERSION: + ds_put_cstr(string, " (OF1.4)"); + break; default: ds_put_format(string, " (OF 0x%02"PRIx8")", oh->version); break; @@ -2625,7 +2634,7 @@ ofp_print_table_features(struct ds *s, const struct ofp_header *oh) ds_put_format(s, "\n table %"PRIu8":\n", tf.table_id); ds_put_format(s, " name=\"%s\"\n", tf.name); ds_put_format(s, " metadata: match=%#"PRIx64" write=%#"PRIx64"\n", - tf.metadata_match, tf.metadata_write); + ntohll(tf.metadata_match), ntohll(tf.metadata_write)); ds_put_cstr(s, " config="); ofp_print_table_miss_config(s, tf.config);