-struct openflow_packet {
- uint8_t type;
- const char *name;
- size_t min_size;
- void (*printer)(struct ds *, const void *, size_t len, int verbosity);
-};
-
-static const struct openflow_packet packets[] = {
- {
- OFPT_HELLO,
- "hello",
- sizeof (struct ofp_header),
- NULL,
- },
- {
- OFPT_FEATURES_REQUEST,
- "features_request",
- sizeof (struct ofp_header),
- NULL,
- },
- {
- OFPT_FEATURES_REPLY,
- "features_reply",
- sizeof (struct ofp_switch_features),
- ofp_print_switch_features,
- },
- {
- OFPT_GET_CONFIG_REQUEST,
- "get_config_request",
- sizeof (struct ofp_header),
- NULL,
- },
- {
- OFPT_GET_CONFIG_REPLY,
- "get_config_reply",
- sizeof (struct ofp_switch_config),
- ofp_print_switch_config,
- },
- {
- OFPT_SET_CONFIG,
- "set_config",
- sizeof (struct ofp_switch_config),
- ofp_print_switch_config,
- },
- {
- OFPT_PACKET_IN,
- "packet_in",
- offsetof(struct ofp_packet_in, data),
- ofp_packet_in,
- },
- {
- OFPT_PACKET_OUT,
- "packet_out",
- sizeof (struct ofp_packet_out),
- ofp_packet_out,
- },
- {
- OFPT_FLOW_MOD,
- "flow_mod",
- sizeof (struct ofp_flow_mod),
- ofp_print_flow_mod,
- },
- {
- OFPT_FLOW_REMOVED,
- "flow_removed",
- sizeof (struct ofp_flow_removed),
- ofp_print_flow_removed,
- },
- {
- OFPT_PORT_MOD,
- "port_mod",
- sizeof (struct ofp_port_mod),
- ofp_print_port_mod,
- },
- {
- OFPT_PORT_STATUS,
- "port_status",
- sizeof (struct ofp_port_status),
- ofp_print_port_status
- },
- {
- OFPT_ERROR,
- "error_msg",
- sizeof (struct ofp_error_msg),
- ofp_print_error_msg,
- },
- {
- OFPT_STATS_REQUEST,
- "stats_request",
- sizeof (struct ofp_stats_request),
- ofp_stats_request,
- },
- {
- OFPT_STATS_REPLY,
- "stats_reply",
- sizeof (struct ofp_stats_reply),
- ofp_stats_reply,
- },
- {
- OFPT_ECHO_REQUEST,
- "echo_request",
- sizeof (struct ofp_header),
- ofp_echo,
- },
- {
- OFPT_ECHO_REPLY,
- "echo_reply",
- sizeof (struct ofp_header),
- ofp_echo,
- },
- {
- OFPT_VENDOR,
- "vendor",
- sizeof (struct ofp_vendor_header),
- NULL,
- },
- {
- OFPT_BARRIER_REQUEST,
- "barrier_request",
- sizeof (struct ofp_header),
- NULL,
- },
- {
- OFPT_BARRIER_REPLY,
- "barrier_reply",
- sizeof (struct ofp_header),
- NULL,
- }
-};
+static void
+ofp_print_nxt_role_message(struct ds *string,
+ const struct nx_role_request *nrr)
+{
+ unsigned int role = ntohl(nrr->role);
+
+ ds_put_cstr(string, " role=");
+ if (role == NX_ROLE_OTHER) {
+ ds_put_cstr(string, "other");
+ } else if (role == NX_ROLE_MASTER) {
+ ds_put_cstr(string, "master");
+ } else if (role == NX_ROLE_SLAVE) {
+ ds_put_cstr(string, "slave");
+ } else {
+ ds_put_format(string, "%u", role);
+ }
+}
+
+static void
+ofp_print_nxt_flow_mod_table_id(struct ds *string,
+ const struct nxt_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 nxt_set_flow_format *nsff)
+{
+ uint32_t format = ntohl(nsff->format);
+
+ ds_put_cstr(string, " format=");
+ if (ofputil_flow_format_is_valid(format)) {
+ ds_put_cstr(string, ofputil_flow_format_to_string(format));
+ } else {
+ ds_put_format(string, "%"PRIu32, format);
+ }
+}
+
+static void
+ofp_to_string__(const struct ofp_header *oh,
+ const struct ofputil_msg_type *type, struct ds *string,
+ int verbosity)
+{
+ enum ofputil_msg_code code;
+ const void *msg = oh;
+
+ ds_put_format(string, "%s (xid=0x%"PRIx32"):",
+ ofputil_msg_type_name(type), ntohl(oh->xid));
+
+ code = ofputil_msg_type_code(type);
+ switch (code) {
+ case OFPUTIL_INVALID:
+ break;
+
+ case OFPUTIL_OFPT_HELLO:
+ ds_put_char(string, '\n');
+ ds_put_hex_dump(string, oh + 1, ntohs(oh->length) - sizeof *oh,
+ 0, true);
+ break;
+
+ case OFPUTIL_OFPT_ERROR:
+ ofp_print_error_msg(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_ECHO_REQUEST:
+ case OFPUTIL_OFPT_ECHO_REPLY:
+ ofp_print_echo(string, oh, verbosity);
+ break;
+
+ case OFPUTIL_OFPT_FEATURES_REQUEST:
+ break;
+
+ case OFPUTIL_OFPT_FEATURES_REPLY:
+ ofp_print_switch_features(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_GET_CONFIG_REQUEST:
+ break;
+
+ case OFPUTIL_OFPT_GET_CONFIG_REPLY:
+ case OFPUTIL_OFPT_SET_CONFIG:
+ ofp_print_switch_config(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_PACKET_IN:
+ ofp_print_packet_in(string, msg, verbosity);
+ break;
+
+ case OFPUTIL_OFPT_FLOW_REMOVED:
+ case OFPUTIL_NXT_FLOW_REMOVED:
+ ofp_print_flow_removed(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_PORT_STATUS:
+ ofp_print_port_status(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_PACKET_OUT:
+ ofp_print_packet_out(string, msg, verbosity);
+ break;
+
+ case OFPUTIL_OFPT_FLOW_MOD:
+ ofp_print_flow_mod(string, msg, code, verbosity);
+ break;
+
+ case OFPUTIL_OFPT_PORT_MOD:
+ ofp_print_port_mod(string, msg);
+ break;
+
+ case OFPUTIL_OFPT_BARRIER_REQUEST:
+ case OFPUTIL_OFPT_BARRIER_REPLY:
+ break;
+
+ case OFPUTIL_OFPT_QUEUE_GET_CONFIG_REQUEST:
+ case OFPUTIL_OFPT_QUEUE_GET_CONFIG_REPLY:
+ /* XXX */
+ break;
+
+ case OFPUTIL_OFPST_DESC_REQUEST:
+ ofp_print_stats_request(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_FLOW_REQUEST:
+ case OFPUTIL_NXST_FLOW_REQUEST:
+ case OFPUTIL_OFPST_AGGREGATE_REQUEST:
+ case OFPUTIL_NXST_AGGREGATE_REQUEST:
+ ofp_print_stats_request(string, oh);
+ ofp_print_flow_stats_request(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_TABLE_REQUEST:
+ ofp_print_stats_request(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_PORT_REQUEST:
+ ofp_print_stats_request(string, oh);
+ ofp_print_ofpst_port_request(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_QUEUE_REQUEST:
+ ofp_print_stats_request(string, oh);
+ ofp_print_ofpst_queue_request(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_DESC_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_ofpst_desc_reply(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_FLOW_REPLY:
+ case OFPUTIL_NXST_FLOW_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_flow_stats_reply(string, oh);
+ break;
+
+ case OFPUTIL_OFPST_QUEUE_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_ofpst_queue_reply(string, oh, verbosity);
+ break;
+
+ case OFPUTIL_OFPST_PORT_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_ofpst_port_reply(string, oh, verbosity);
+ break;
+
+ case OFPUTIL_OFPST_TABLE_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_ofpst_table_reply(string, oh, verbosity);
+ break;
+
+ case OFPUTIL_OFPST_AGGREGATE_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_ofpst_aggregate_reply(string, oh);
+ break;
+
+ case OFPUTIL_NXT_ROLE_REQUEST:
+ case OFPUTIL_NXT_ROLE_REPLY:
+ ofp_print_nxt_role_message(string, msg);
+ break;
+
+ case OFPUTIL_NXT_FLOW_MOD_TABLE_ID:
+ ofp_print_nxt_flow_mod_table_id(string, msg);
+ break;
+
+ case OFPUTIL_NXT_SET_FLOW_FORMAT:
+ ofp_print_nxt_set_flow_format(string, msg);
+ break;
+
+ case OFPUTIL_NXT_FLOW_MOD:
+ ofp_print_flow_mod(string, msg, code, verbosity);
+ break;
+
+ case OFPUTIL_NXST_AGGREGATE_REPLY:
+ ofp_print_stats_reply(string, oh);
+ ofp_print_nxst_aggregate_reply(string, msg);
+ break;
+ }
+}