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');
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
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
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;
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;
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;
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;
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;
}
}
+static const char *
+bundle_flags_to_name(uint32_t bit)
+{
+ switch (bit) {
+ case OFPBF_ATOMIC:
+ return "atomic";
+ case OFPBF_ORDERED:
+ return "ordered";
+ default:
+ return NULL;
+ }
+}
+
+static void
+ofp_print_bundle_ctrl(struct ds *s, const struct ofp_header *oh)
+{
+ int error;
+ struct ofputil_bundle_ctrl_msg bctrl;
+
+ error = ofputil_decode_bundle_ctrl(oh, &bctrl);
+ if (error) {
+ ofp_print_error(s, error);
+ return;
+ }
+
+ ds_put_char(s, '\n');
+
+ ds_put_format(s, " bundle_id=%#"PRIx32" type=", bctrl.bundle_id);
+ switch (bctrl.type) {
+ case OFPBCT_OPEN_REQUEST:
+ ds_put_cstr(s, "OPEN_REQUEST");
+ break;
+ case OFPBCT_OPEN_REPLY:
+ ds_put_cstr(s, "OPEN_REPLY");
+ break;
+ case OFPBCT_CLOSE_REQUEST:
+ ds_put_cstr(s, "CLOSE_REQUEST");
+ break;
+ case OFPBCT_CLOSE_REPLY:
+ ds_put_cstr(s, "CLOSE_REPLY");
+ break;
+ case OFPBCT_COMMIT_REQUEST:
+ ds_put_cstr(s, "COMMIT_REQUEST");
+ break;
+ case OFPBCT_COMMIT_REPLY:
+ ds_put_cstr(s, "COMMIT_REPLY");
+ break;
+ case OFPBCT_DISCARD_REQUEST:
+ ds_put_cstr(s, "DISCARD_REQUEST");
+ break;
+ case OFPBCT_DISCARD_REPLY:
+ ds_put_cstr(s, "DISCARD_REPLY");
+ break;
+ }
+
+ ds_put_cstr(s, " flags=");
+ ofp_print_bit_names(s, bctrl.flags, bundle_flags_to_name, ' ');
+}
+
+static void
+ofp_print_bundle_add(struct ds *s, const struct ofp_header *oh, int verbosity)
+{
+ int error;
+ struct ofputil_bundle_add_msg badd;
+ char *msg;
+
+ error = ofputil_decode_bundle_add(oh, &badd);
+ if (error) {
+ ofp_print_error(s, error);
+ return;
+ }
+
+ ds_put_char(s, '\n');
+ ds_put_format(s, " bundle_id=%#"PRIx32, badd.bundle_id);
+ ds_put_cstr(s, " flags=");
+ ofp_print_bit_names(s, badd.flags, bundle_flags_to_name, ' ');
+
+ ds_put_char(s, '\n');
+ msg = ofp_to_string(badd.msg, ntohs(badd.msg->length), verbosity);
+ if (msg) {
+ ds_put_cstr(s, msg);
+ }
+}
+
static void
ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
struct ds *string, int verbosity)
case OFPTYPE_FLOW_MONITOR_STATS_REPLY:
ofp_print_nxst_flow_monitor_reply(string, msg);
break;
+
+ case OFPTYPE_BUNDLE_CONTROL:
+ ofp_print_bundle_ctrl(string, msg);
+ break;
+
+ case OFPTYPE_BUNDLE_ADD_MESSAGE:
+ ofp_print_bundle_add(string, msg, verbosity);
+ break;
}
}