+ ds_put_char(string, '?');
+ }
+ if (more) {
+ ds_put_cstr(string, ", ");
+ } else {
+ ds_put_cstr(string, "\n");
+ }
+}
+
+static void
+ofp_print_ofpst_port_request(struct ds *string, const struct ofp_header *oh)
+{
+ ofp_port_t ofp10_port;
+ enum ofperr error;
+
+ error = ofputil_decode_port_stats_request(oh, &ofp10_port);
+ if (error) {
+ ofp_print_error(string, error);
+ return;
+ }
+
+ ds_put_cstr(string, " port_no=");
+ ofputil_format_port(ofp10_port, string);
+}
+
+static void
+ofp_print_ofpst_port_reply(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofpbuf b;
+
+ ds_put_format(string, " %"PRIuSIZE" ports\n", ofputil_count_port_stats(oh));
+ if (verbosity < 1) {
+ return;
+ }
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ for (;;) {
+ struct ofputil_port_stats ps;
+ int retval;
+
+ retval = ofputil_decode_port_stats(&ps, &b);
+ if (retval) {
+ if (retval != EOF) {
+ ds_put_cstr(string, " ***parse error***");
+ }
+ return;
+ }
+
+ ds_put_cstr(string, " port ");
+ if (ofp_to_u16(ps.port_no) < 10) {
+ ds_put_char(string, ' ');
+ }
+ ofputil_format_port(ps.port_no, string);
+
+ ds_put_cstr(string, ": rx ");
+ print_port_stat(string, "pkts=", ps.stats.rx_packets, 1);
+ print_port_stat(string, "bytes=", ps.stats.rx_bytes, 1);
+ print_port_stat(string, "drop=", ps.stats.rx_dropped, 1);
+ print_port_stat(string, "errs=", ps.stats.rx_errors, 1);
+ print_port_stat(string, "frame=", ps.stats.rx_frame_errors, 1);
+ print_port_stat(string, "over=", ps.stats.rx_over_errors, 1);
+ print_port_stat(string, "crc=", ps.stats.rx_crc_errors, 0);
+
+ ds_put_cstr(string, " tx ");
+ print_port_stat(string, "pkts=", ps.stats.tx_packets, 1);
+ print_port_stat(string, "bytes=", ps.stats.tx_bytes, 1);
+ print_port_stat(string, "drop=", ps.stats.tx_dropped, 1);
+ print_port_stat(string, "errs=", ps.stats.tx_errors, 1);
+ print_port_stat(string, "coll=", ps.stats.collisions, 0);
+
+ if (ps.duration_sec != UINT32_MAX) {
+ ds_put_cstr(string, " duration=");
+ ofp_print_duration(string, ps.duration_sec, ps.duration_nsec);
+ ds_put_char(string, '\n');
+ }
+ }
+}
+
+static void
+ofp_print_one_ofpst_table_reply(struct ds *string, enum ofp_version ofp_version,
+ const char *name, struct ofp12_table_stats *ts)
+{
+ char name_[OFP_MAX_TABLE_NAME_LEN + 1];
+
+ /* ofp13_table_stats is different */
+ if (ofp_version > OFP12_VERSION) {
+ return;
+ }
+
+ ovs_strlcpy(name_, name, sizeof name_);
+
+ ds_put_format(string, " %d: %-8s: ", ts->table_id, name_);
+ ds_put_format(string, "wild=0x%05"PRIx64", ", ntohll(ts->wildcards));
+ ds_put_format(string, "max=%6"PRIu32", ", ntohl(ts->max_entries));
+ ds_put_format(string, "active=%"PRIu32"\n", ntohl(ts->active_count));
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "lookup=%"PRIu64", ", ntohll(ts->lookup_count));
+ ds_put_format(string, "matched=%"PRIu64"\n", ntohll(ts->matched_count));
+
+ if (ofp_version < OFP11_VERSION) {
+ return;
+ }
+
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "match=0x%08"PRIx64", ", ntohll(ts->match));
+ ds_put_format(string, "instructions=0x%08"PRIx32", ",
+ ntohl(ts->instructions));
+ ds_put_format(string, "config=0x%08"PRIx32"\n", ntohl(ts->config));
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "write_actions=0x%08"PRIx32", ",
+ ntohl(ts->write_actions));
+ ds_put_format(string, "apply_actions=0x%08"PRIx32"\n",
+ ntohl(ts->apply_actions));
+
+ if (ofp_version < OFP12_VERSION) {
+ return;
+ }
+
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "write_setfields=0x%016"PRIx64"\n",
+ ntohll(ts->write_setfields));
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "apply_setfields=0x%016"PRIx64"\n",
+ ntohll(ts->apply_setfields));
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "metadata_match=0x%016"PRIx64"\n",
+ ntohll(ts->metadata_match));
+ ds_put_cstr(string, " ");
+ ds_put_format(string, "metadata_write=0x%016"PRIx64"\n",
+ ntohll(ts->metadata_write));
+}
+
+static void
+ofp_print_ofpst_table_reply13(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofp13_table_stats *ts;
+ struct ofpbuf b;
+ size_t n;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpraw_pull_assert(&b);
+
+ n = ofpbuf_size(&b) / sizeof *ts;
+ ds_put_format(string, " %"PRIuSIZE" tables\n", n);
+ if (verbosity < 1) {
+ return;
+ }
+
+ for (;;) {
+ ts = ofpbuf_try_pull(&b, sizeof *ts);
+ if (!ts) {
+ return;
+ }
+ ds_put_format(string,
+ " %d: active=%"PRIu32", lookup=%"PRIu64 \
+ ", matched=%"PRIu64"\n",
+ ts->table_id, ntohl(ts->active_count),
+ ntohll(ts->lookup_count), ntohll(ts->matched_count));
+ }
+}
+
+static void
+ofp_print_ofpst_table_reply12(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofp12_table_stats *ts;
+ struct ofpbuf b;
+ size_t n;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpraw_pull_assert(&b);
+
+ n = ofpbuf_size(&b) / sizeof *ts;
+ ds_put_format(string, " %"PRIuSIZE" tables\n", n);
+ if (verbosity < 1) {
+ return;
+ }
+
+ for (;;) {
+ ts = ofpbuf_try_pull(&b, sizeof *ts);
+ if (!ts) {
+ return;
+ }
+
+ ofp_print_one_ofpst_table_reply(string, OFP12_VERSION, ts->name, ts);
+ }
+}
+
+static void
+ofp_print_ofpst_table_reply11(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofp11_table_stats *ts;
+ struct ofpbuf b;
+ size_t n;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpraw_pull_assert(&b);
+
+ n = ofpbuf_size(&b) / sizeof *ts;
+ ds_put_format(string, " %"PRIuSIZE" tables\n", n);
+ if (verbosity < 1) {
+ return;
+ }
+
+ for (;;) {
+ struct ofp12_table_stats ts12;
+
+ ts = ofpbuf_try_pull(&b, sizeof *ts);
+ if (!ts) {
+ return;
+ }
+
+ ts12.table_id = ts->table_id;
+ ts12.wildcards = htonll(ntohl(ts->wildcards));
+ ts12.max_entries = ts->max_entries;
+ ts12.active_count = ts->active_count;
+ ts12.lookup_count = ts->lookup_count;
+ ts12.matched_count = ts->matched_count;
+ ts12.match = htonll(ntohl(ts->match));
+ ts12.instructions = ts->instructions;
+ ts12.config = ts->config;
+ ts12.write_actions = ts->write_actions;
+ ts12.apply_actions = ts->apply_actions;
+ ofp_print_one_ofpst_table_reply(string, OFP11_VERSION, ts->name, &ts12);
+ }
+}
+
+static void
+ofp_print_ofpst_table_reply10(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofp10_table_stats *ts;
+ struct ofpbuf b;
+ size_t n;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpraw_pull_assert(&b);
+
+ n = ofpbuf_size(&b) / sizeof *ts;
+ ds_put_format(string, " %"PRIuSIZE" tables\n", n);
+ if (verbosity < 1) {
+ return;
+ }
+
+ for (;;) {
+ struct ofp12_table_stats ts12;
+
+ ts = ofpbuf_try_pull(&b, sizeof *ts);
+ if (!ts) {
+ return;
+ }
+
+ ts12.table_id = ts->table_id;
+ ts12.wildcards = htonll(ntohl(ts->wildcards));
+ ts12.max_entries = ts->max_entries;
+ ts12.active_count = ts->active_count;
+ ts12.lookup_count = get_32aligned_be64(&ts->lookup_count);
+ ts12.matched_count = get_32aligned_be64(&ts->matched_count);
+ ofp_print_one_ofpst_table_reply(string, OFP10_VERSION, ts->name, &ts12);
+ }
+}
+
+static void
+ofp_print_ofpst_table_reply(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ switch ((enum ofp_version)oh->version) {
+ case OFP14_VERSION:
+ case OFP13_VERSION:
+ ofp_print_ofpst_table_reply13(string, oh, verbosity);
+ break;
+
+ case OFP12_VERSION:
+ ofp_print_ofpst_table_reply12(string, oh, verbosity);
+ break;
+
+ case OFP11_VERSION:
+ ofp_print_ofpst_table_reply11(string, oh, verbosity);
+ break;
+
+ case OFP10_VERSION:
+ ofp_print_ofpst_table_reply10(string, oh, verbosity);
+ break;
+
+ default:
+ OVS_NOT_REACHED();
+ }
+}
+
+static void
+ofp_print_queue_name(struct ds *string, uint32_t queue_id)
+{
+ if (queue_id == OFPQ_ALL) {
+ ds_put_cstr(string, "ALL");
+ } else {
+ ds_put_format(string, "%"PRIu32, queue_id);
+ }
+}
+
+static void
+ofp_print_ofpst_queue_request(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_queue_stats_request oqsr;
+ enum ofperr error;
+
+ error = ofputil_decode_queue_stats_request(oh, &oqsr);
+ if (error) {
+ ds_put_format(string, "***decode error: %s***\n", ofperr_get_name(error));
+ return;
+ }
+
+ ds_put_cstr(string, "port=");
+ ofputil_format_port(oqsr.port_no, string);
+
+ ds_put_cstr(string, " queue=");
+ ofp_print_queue_name(string, oqsr.queue_id);
+}
+
+static void
+ofp_print_ofpst_queue_reply(struct ds *string, const struct ofp_header *oh,
+ int verbosity)
+{
+ struct ofpbuf b;
+
+ ds_put_format(string, " %"PRIuSIZE" queues\n", ofputil_count_queue_stats(oh));
+ if (verbosity < 1) {
+ return;
+ }
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ for (;;) {
+ struct ofputil_queue_stats qs;
+ int retval;
+
+ retval = ofputil_decode_queue_stats(&qs, &b);
+ if (retval) {
+ if (retval != EOF) {
+ ds_put_cstr(string, " ***parse error***");
+ }
+ return;
+ }
+
+ ds_put_cstr(string, " port ");
+ ofputil_format_port(qs.port_no, string);
+ ds_put_cstr(string, " queue ");
+ ofp_print_queue_name(string, qs.queue_id);
+ ds_put_cstr(string, ": ");
+
+ print_port_stat(string, "bytes=", qs.tx_bytes, 1);
+ print_port_stat(string, "pkts=", qs.tx_packets, 1);
+ print_port_stat(string, "errors=", qs.tx_errors, 1);
+
+ ds_put_cstr(string, "duration=");
+ if (qs.duration_sec != UINT32_MAX) {
+ ofp_print_duration(string, qs.duration_sec, qs.duration_nsec);
+ } else {
+ ds_put_char(string, '?');
+ }
+ ds_put_char(string, '\n');
+ }
+}
+
+static void
+ofp_print_ofpst_port_desc_reply(struct ds *string,
+ const struct ofp_header *oh)
+{
+ struct ofpbuf b;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpraw_pull_assert(&b);
+ ds_put_char(string, '\n');
+ ofp_print_phy_ports(string, oh->version, &b);
+}
+
+static void
+ofp_print_stats_request(struct ds *string, const struct ofp_header *oh)
+{
+ uint16_t flags = ofpmp_flags(oh);
+
+ if (flags) {
+ ds_put_format(string, " ***unknown flags 0x%04"PRIx16"***", flags);
+ }
+}
+
+static void
+ofp_print_stats_reply(struct ds *string, const struct ofp_header *oh)
+{
+ uint16_t flags = ofpmp_flags(oh);
+
+ if (flags) {
+ ds_put_cstr(string, " flags=");
+ if (flags & OFPSF_REPLY_MORE) {
+ ds_put_cstr(string, "[more]");
+ flags &= ~OFPSF_REPLY_MORE;
+ }
+ if (flags) {
+ ds_put_format(string, "[***unknown flags 0x%04"PRIx16"***]",
+ flags);
+ }
+ }
+}
+
+static void
+ofp_print_echo(struct ds *string, const struct ofp_header *oh, int verbosity)
+{
+ size_t len = ntohs(oh->length);
+
+ ds_put_format(string, " %"PRIuSIZE" bytes of payload\n", len - sizeof *oh);
+ if (verbosity > 1) {
+ ds_put_hex_dump(string, oh + 1, len - sizeof *oh, 0, true);
+ }
+}
+
+static void
+ofp_print_role_generic(struct ds *string, enum ofp12_controller_role role,
+ uint64_t generation_id)
+{
+ ds_put_cstr(string, " role=");
+
+ switch (role) {
+ case OFPCR12_ROLE_NOCHANGE:
+ ds_put_cstr(string, "nochange");
+ break;
+ case OFPCR12_ROLE_EQUAL:
+ ds_put_cstr(string, "equal"); /* OF 1.2 wording */
+ break;
+ case OFPCR12_ROLE_MASTER:
+ ds_put_cstr(string, "master");
+ break;
+ case OFPCR12_ROLE_SLAVE:
+ ds_put_cstr(string, "slave");
+ break;
+ default:
+ OVS_NOT_REACHED();
+ }
+
+ if (generation_id != UINT64_MAX) {
+ ds_put_format(string, " generation_id=%"PRIu64, generation_id);
+ }
+}
+
+static void
+ofp_print_role_message(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_role_request rr;
+ enum ofperr error;
+
+ error = ofputil_decode_role_message(oh, &rr);
+ if (error) {
+ ofp_print_error(string, error);
+ return;
+ }
+
+ ofp_print_role_generic(string, rr.role, rr.have_generation_id ? rr.generation_id : UINT64_MAX);
+}
+
+static void
+ofp_print_role_status_message(struct ds *string, const struct ofp_header *oh)
+{
+ struct ofputil_role_status rs;
+ enum ofperr error;
+
+ error = ofputil_decode_role_status(oh, &rs);
+ if (error) {
+ ofp_print_error(string, error);
+ return;
+ }
+
+ ofp_print_role_generic(string, rs.role, rs.generation_id);
+
+ ds_put_cstr(string, " reason=");
+
+ switch (rs.reason) {
+ case OFPCRR_MASTER_REQUEST:
+ ds_put_cstr(string, "master_request");
+ break;
+ case OFPCRR_CONFIG:
+ ds_put_cstr(string, "configuration_changed");
+ break;
+ case OFPCRR_EXPERIMENTER:
+ ds_put_cstr(string, "experimenter_data_changed");
+ break;
+ default:
+ OVS_NOT_REACHED();
+ }
+}
+
+static void
+ofp_print_nxt_flow_mod_table_id(struct ds *string,
+ const struct nx_flow_mod_table_id *nfmti)
+{
+ ds_put_format(string, " %s", nfmti->set ? "enable" : "disable");
+}
+
+static void
+ofp_print_nxt_set_flow_format(struct ds *string,
+ const struct nx_set_flow_format *nsff)
+{
+ uint32_t format = ntohl(nsff->format);
+
+ ds_put_cstr(string, " format=");
+ if (ofputil_nx_flow_format_is_valid(format)) {
+ ds_put_cstr(string, ofputil_nx_flow_format_to_string(format));
+ } else {
+ ds_put_format(string, "%"PRIu32, format);
+ }
+}
+
+static void
+ofp_print_nxt_set_packet_in_format(struct ds *string,
+ const struct nx_set_packet_in_format *nspf)
+{
+ uint32_t format = ntohl(nspf->format);
+
+ ds_put_cstr(string, " format=");
+ if (ofputil_packet_in_format_is_valid(format)) {
+ ds_put_cstr(string, ofputil_packet_in_format_to_string(format));
+ } else {
+ ds_put_format(string, "%"PRIu32, format);
+ }
+}
+
+/* Returns a string form of 'reason'. The return value is either a statically
+ * allocated constant string or the 'bufsize'-byte buffer 'reasonbuf'.
+ * 'bufsize' should be at least OFP_PORT_REASON_BUFSIZE. */
+#define OFP_PORT_REASON_BUFSIZE (INT_STRLEN(int) + 1)
+static const char *
+ofp_port_reason_to_string(enum ofp_port_reason reason,
+ char *reasonbuf, size_t bufsize)
+{
+ switch (reason) {
+ case OFPPR_ADD:
+ return "add";
+
+ case OFPPR_DELETE:
+ return "delete";
+
+ case OFPPR_MODIFY:
+ return "modify";
+
+ default:
+ snprintf(reasonbuf, bufsize, "%d", (int) reason);
+ return reasonbuf;
+ }
+}
+
+static void
+ofp_print_nxt_set_async_config(struct ds *string,
+ const struct nx_async_config *nac)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ int j;
+
+ ds_put_format(string, "\n %s:\n", i == 0 ? "master" : "slave");
+
+ ds_put_cstr(string, " PACKET_IN:");
+ for (j = 0; j < 32; j++) {
+ if (nac->packet_in_mask[i] & htonl(1u << j)) {
+ char reasonbuf[OFPUTIL_PACKET_IN_REASON_BUFSIZE];
+ const char *reason;
+
+ reason = ofputil_packet_in_reason_to_string(j, reasonbuf,
+ sizeof reasonbuf);
+ ds_put_format(string, " %s", reason);
+ }
+ }
+ if (!nac->packet_in_mask[i]) {
+ ds_put_cstr(string, " (off)");
+ }
+ ds_put_char(string, '\n');
+
+ ds_put_cstr(string, " PORT_STATUS:");
+ for (j = 0; j < 32; j++) {
+ if (nac->port_status_mask[i] & htonl(1u << j)) {
+ char reasonbuf[OFP_PORT_REASON_BUFSIZE];
+ const char *reason;
+
+ reason = ofp_port_reason_to_string(j, reasonbuf,
+ sizeof reasonbuf);
+ ds_put_format(string, " %s", reason);
+ }
+ }
+ if (!nac->port_status_mask[i]) {
+ ds_put_cstr(string, " (off)");
+ }
+ ds_put_char(string, '\n');
+
+ ds_put_cstr(string, " FLOW_REMOVED:");
+ for (j = 0; j < 32; j++) {
+ if (nac->flow_removed_mask[i] & htonl(1u << j)) {
+ char reasonbuf[OFP_FLOW_REMOVED_REASON_BUFSIZE];
+ const char *reason;
+
+ reason = ofp_flow_removed_reason_to_string(j, reasonbuf,
+ sizeof reasonbuf);
+ ds_put_format(string, " %s", reason);
+ }
+ }
+ if (!nac->flow_removed_mask[i]) {
+ ds_put_cstr(string, " (off)");
+ }
+ ds_put_char(string, '\n');
+ }
+}
+
+static void
+ofp_print_nxt_set_controller_id(struct ds *string,
+ const struct nx_controller_id *nci)
+{
+ ds_put_format(string, " id=%"PRIu16, ntohs(nci->controller_id));
+}
+
+static void
+ofp_print_nxt_flow_monitor_cancel(struct ds *string,
+ const struct ofp_header *oh)
+{
+ ds_put_format(string, " id=%"PRIu32,
+ ofputil_decode_flow_monitor_cancel(oh));
+}
+
+static const char *
+nx_flow_monitor_flags_to_name(uint32_t bit)
+{
+ enum nx_flow_monitor_flags fmf = bit;
+
+ switch (fmf) {
+ case NXFMF_INITIAL: return "initial";
+ case NXFMF_ADD: return "add";
+ case NXFMF_DELETE: return "delete";
+ case NXFMF_MODIFY: return "modify";
+ case NXFMF_ACTIONS: return "actions";
+ case NXFMF_OWN: return "own";
+ }
+
+ return NULL;
+}
+
+static void
+ofp_print_nxst_flow_monitor_request(struct ds *string,
+ const struct ofp_header *oh)
+{
+ struct ofpbuf b;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ for (;;) {
+ struct ofputil_flow_monitor_request request;
+ int retval;
+
+ retval = ofputil_decode_flow_monitor_request(&request, &b);
+ if (retval) {
+ if (retval != EOF) {
+ ofp_print_error(string, retval);
+ }
+ return;
+ }
+
+ ds_put_format(string, "\n id=%"PRIu32" flags=", request.id);
+ ofp_print_bit_names(string, request.flags,
+ nx_flow_monitor_flags_to_name, ',');
+
+ if (request.out_port != OFPP_NONE) {
+ ds_put_cstr(string, " out_port=");
+ ofputil_format_port(request.out_port, string);
+ }
+
+ if (request.table_id != 0xff) {
+ ds_put_format(string, " table=%"PRIu8, request.table_id);
+ }
+
+ ds_put_char(string, ' ');
+ match_format(&request.match, string, OFP_DEFAULT_PRIORITY);
+ ds_chomp(string, ' ');
+ }
+}
+
+static void
+ofp_print_nxst_flow_monitor_reply(struct ds *string,
+ const struct ofp_header *oh)
+{
+ uint64_t ofpacts_stub[1024 / 8];
+ struct ofpbuf ofpacts;
+ struct ofpbuf b;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub);
+ for (;;) {
+ char reasonbuf[OFP_FLOW_REMOVED_REASON_BUFSIZE];
+ struct ofputil_flow_update update;
+ struct match match;
+ int retval;
+
+ update.match = &match;
+ retval = ofputil_decode_flow_update(&update, &b, &ofpacts);
+ if (retval) {
+ if (retval != EOF) {
+ ofp_print_error(string, retval);
+ }
+ ofpbuf_uninit(&ofpacts);
+ return;
+ }
+
+ ds_put_cstr(string, "\n event=");
+ switch (update.event) {
+ case NXFME_ADDED:
+ ds_put_cstr(string, "ADDED");
+ break;
+
+ case NXFME_DELETED:
+ ds_put_format(string, "DELETED reason=%s",
+ ofp_flow_removed_reason_to_string(update.reason,
+ reasonbuf,
+ sizeof reasonbuf));
+ break;
+
+ case NXFME_MODIFIED:
+ ds_put_cstr(string, "MODIFIED");
+ break;
+
+ case NXFME_ABBREV:
+ ds_put_format(string, "ABBREV xid=0x%"PRIx32, ntohl(update.xid));
+ continue;
+ }
+
+ ds_put_format(string, " table=%"PRIu8, update.table_id);
+ if (update.idle_timeout != OFP_FLOW_PERMANENT) {
+ ds_put_format(string, " idle_timeout=%"PRIu16,
+ update.idle_timeout);
+ }
+ if (update.hard_timeout != OFP_FLOW_PERMANENT) {
+ ds_put_format(string, " hard_timeout=%"PRIu16,
+ update.hard_timeout);
+ }
+ ds_put_format(string, " cookie=%#"PRIx64, ntohll(update.cookie));
+
+ ds_put_char(string, ' ');
+ match_format(update.match, string, OFP_DEFAULT_PRIORITY);
+
+ if (update.ofpacts_len) {
+ if (string->string[string->length - 1] != ' ') {
+ ds_put_char(string, ' ');
+ }
+ ds_put_cstr(string, "actions=");
+ ofpacts_format(update.ofpacts, update.ofpacts_len, string);
+ }
+ }
+}
+
+void
+ofp_print_version(const struct ofp_header *oh,
+ struct ds *string)
+{
+ switch (oh->version) {
+ case OFP10_VERSION:
+ break;
+ case OFP11_VERSION:
+ ds_put_cstr(string, " (OF1.1)");
+ break;
+ case OFP12_VERSION:
+ ds_put_cstr(string, " (OF1.2)");
+ break;
+ case OFP13_VERSION:
+ ds_put_cstr(string, " (OF1.3)");
+ break;
+ default:
+ ds_put_format(string, " (OF 0x%02"PRIx8")", oh->version);
+ break;