{
uint16_t w = ntohs(om->wildcards);
- print_wild(f, "inport", w & OFPFW_IN_PORT, "%d", ntohs(om->in_port));
+ print_wild(f, " inport", w & OFPFW_IN_PORT, "%d", ntohs(om->in_port));
print_wild(f, ":vlan", w & OFPFW_DL_VLAN, "%04x", ntohs(om->dl_vlan));
print_wild(f, " mac[", w & OFPFW_DL_SRC,
ETH_ADDR_FMT, ETH_ADDR_ARGS(om->dl_src));
print_wild(f, "] proto", w & OFPFW_NW_PROTO, "%u", om->nw_proto);
print_wild(f, " tport[", w & OFPFW_TP_SRC, "%d", ntohs(om->tp_src));
print_wild(f, "->", w & OFPFW_TP_DST, "%d", ntohs(om->tp_dst));
- ds_put_cstr(f, "]\n");
+ ds_put_cstr(f, "]");
}
/* Pretty-print the OFPT_FLOW_MOD packet of 'len' bytes at 'oh' to 'string'
ofp_print_match(string, &ofe->match);
ds_put_format(string,
- " pri%d secs%d pkts%lld bytes%lld\n",
+ " pri%"PRIu16" secs%"PRIu32" pkts%"PRIu64" bytes%"PRIu64"n",
ofe->match.wildcards ? ntohs(ofe->priority) : (uint16_t)-1,
ntohl(ofe->duration), ntohll(ofe->packet_count),
ntohll(ofe->byte_count));
ds_put_format(string, " table_id=%"PRIu8", ", fsr->table_id);
}
- if (fsr->type == OFPFS_INDIV) {
- ds_put_cstr(string, " type=indiv, ");
- } else if (fsr->type == OFPFS_AGGREGATE) {
- ds_put_cstr(string, " type=aggregate, ");
- } else {
- ds_put_format(string, " ***type=%"PRIu8"***, ", fsr->type);
- }
ofp_print_match(string, &fsr->match);
}
static void
-ofp_flow_stats_reply(struct ds *string, const void *body, size_t len,
+ofp_flow_stats_reply(struct ds *string, const void *body_, size_t len,
int verbosity)
{
- const struct ofp_flow_stats *fs = body;
- size_t n = len / sizeof *fs;
- ds_put_format(string, " %zu flows\n", n);
- if (verbosity < 1) {
- return;
- }
+ const char *body = body_;
+ const char *pos = body;
+ for (;;) {
+ const struct ofp_flow_stats *fs;
+ ptrdiff_t bytes_left = body + len - pos;
+ size_t length;
+
+ if (bytes_left < sizeof *fs) {
+ if (bytes_left != 0) {
+ ds_put_format(string, " ***%td leftover bytes at end***",
+ bytes_left);
+ }
+ break;
+ }
+
+ fs = (const void *) pos;
+ length = ntohs(fs->length);
+ if (length < sizeof *fs) {
+ ds_put_format(string, " ***length=%zu shorter than minimum %zu***",
+ length, sizeof *fs);
+ break;
+ } else if (length > bytes_left) {
+ ds_put_format(string,
+ " ***length=%zu but only %td bytes left***",
+ length, bytes_left);
+ break;
+ } else if ((length - sizeof *fs) % sizeof fs->actions[0]) {
+ ds_put_format(string,
+ " ***length=%zu has %zu bytes leftover in "
+ "final action***",
+ length,
+ (length - sizeof *fs) % sizeof fs->actions[0]);
+ break;
+ }
- for (; n--; fs++) {
ds_put_format(string, " duration=%"PRIu32" s, ", ntohl(fs->duration));
ds_put_format(string, "table_id=%"PRIu8", ", fs->table_id);
ds_put_format(string, "priority=%"PRIu16", ",
ds_put_format(string, "n_bytes=%"PRIu64", ", ntohll(fs->byte_count));
ds_put_format(string, "max_idle=%"PRIu16", ", ntohs(fs->max_idle));
ofp_print_match(string, &fs->match);
+ ofp_print_actions(string, fs->actions, length - sizeof *fs);
+ ds_put_char(string, '\n');
+
+ pos += length;
}
}
+static void
+ofp_aggregate_stats_request(struct ds *string, const void *oh, size_t len,
+ int verbosity)
+{
+ const struct ofp_aggregate_stats_request *asr = oh;
+
+ if (asr->table_id == 0xff) {
+ ds_put_format(string, " table_id=any, ");
+ } else {
+ ds_put_format(string, " table_id=%"PRIu8", ", asr->table_id);
+ }
+
+ ofp_print_match(string, &asr->match);
+}
+
+static void
+ofp_aggregate_stats_reply(struct ds *string, const void *body_, size_t len,
+ int verbosity)
+{
+ const struct ofp_aggregate_stats_reply *asr = body_;
+
+ ds_put_format(string, " packet_count=%"PRIu64, ntohll(asr->packet_count));
+ ds_put_format(string, " byte_count=%"PRIu64, ntohll(asr->byte_count));
+ ds_put_format(string, " flow_count=%"PRIu32, ntohl(asr->flow_count));
+}
+
static void
ofp_port_stats_reply(struct ds *string, const void *body, size_t len,
int verbosity)
ofp_flow_stats_request },
{ 0, SIZE_MAX, ofp_flow_stats_reply },
},
+ [OFPST_AGGREGATE] = {
+ "aggregate",
+ { sizeof(struct ofp_aggregate_stats_request),
+ sizeof(struct ofp_aggregate_stats_request),
+ ofp_aggregate_stats_request },
+ { sizeof(struct ofp_aggregate_stats_reply),
+ sizeof(struct ofp_aggregate_stats_reply),
+ ofp_aggregate_stats_reply },
+ },
[OFPST_TABLE] = {
"table",
{ 0, 0, NULL },
return;
}
s = &stats_types[type];
- ds_put_format(string, " type=%d(%s)", type, s->name);
+ ds_put_format(string, " type=%d(%s)\n", type, s->name);
m = direction == REQUEST ? &s->request : &s->reply;
if (body_len < m->min_body || body_len > m->max_body) {
len, pkt->min_size);
} else if (!pkt->printer) {
if (len > sizeof *oh) {
- ds_put_format(&string, " length=%zu (decoder not implemented)\n",
+ ds_put_format(&string, " length=%"PRIu16" (decoder not implemented)\n",
ntohs(oh->length));
}
} else {