-
- /* [OF10] Section 5.1 */
- ND_PRINT("\n\tversion 1.0, type %s, length %u, xid 0x%08x",
- tok2str(ofpt_str, "invalid (0x%02x)", type),
- OF_HEADER_FIXLEN + len, xid);
- switch (type) {
- /* OpenFlow header only. */
- case OFPT_FEATURES_REQUEST: /* [OF10] Section 5.3.1 */
- case OFPT_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.2 */
- case OFPT_BARRIER_REQUEST: /* [OF10] Section 5.3.7 */
- case OFPT_BARRIER_REPLY: /* ibid */
- if (len)
- goto invalid;
- return;
-
- /* OpenFlow header and fixed-size message body. */
- case OFPT_SET_CONFIG: /* [OF10] Section 5.3.2 */
- case OFPT_GET_CONFIG_REPLY: /* ibid */
- if (len != OF_SWITCH_CONFIG_FIXLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- /* flags */
- ND_PRINT("\n\t flags %s",
- tok2str(ofp_config_str, "invalid (0x%04x)",
- GET_BE_U_2(cp)));
- OF_FWD(2);
- /* miss_send_len */
- ND_PRINT(", miss_send_len %u", GET_BE_U_2(cp));
- return;
- case OFPT_PORT_MOD:
- if (len != OF_PORT_MOD_FIXLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_port_mod_print(ndo, cp);
- return;
- case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */
- if (len != OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- /* port */
- ND_PRINT("\n\t port %s",
- tok2str(ofpp_str, "%u", GET_BE_U_2(cp)));
- OF_FWD(2);
- /* pad */
- /* Always the last field, check bounds. */
- ND_TCHECK_2(cp);
- return;
- case OFPT_FLOW_REMOVED:
- if (len != OF_FLOW_REMOVED_FIXLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_flow_removed_print(ndo, cp);
- return;
- case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */
- if (len != OF_PORT_STATUS_FIXLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- /* reason */
- ND_PRINT("\n\t reason %s",
- tok2str(ofppr_str, "invalid (0x%02x)", GET_U_1(cp)));
- OF_FWD(1);
- /* pad */
- /* No need to check bounds, more data follows. */
- OF_FWD(7);
- /* desc */
- of10_phy_ports_print(ndo, cp, len);
- return;
-
- /* OpenFlow header, fixed-size message body and n * fixed-size data units. */
- case OFPT_FEATURES_REPLY:
- if (len < OF_FEATURES_REPLY_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_features_reply_print(ndo, cp, len);
- return;
-
- /* OpenFlow header and variable-size data. */
- case OFPT_HELLO: /* [OF10] Section 5.5.1 */
- case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */
- case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */
- if (ndo->ndo_vflag < 1)
- break;
- of10_data_print(ndo, cp, len);
- return;
-
- /* OpenFlow header, fixed-size message body and variable-size data. */
- case OFPT_ERROR:
- if (len < OF_ERROR_MSG_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_error_print(ndo, cp, len);
- return;
- case OFPT_VENDOR:
- /* [OF10] Section 5.5.4 */
- if (len < OF_VENDOR_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_vendor_message_print(ndo, cp, len);
- return;
- case OFPT_PACKET_IN:
- /* 2 mock octets count in OF_PACKET_IN_MINLEN but not in len */
- if (len < OF_PACKET_IN_MINLEN - 2 - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_packet_in_print(ndo, cp, len);
- return;
-
- /* a. OpenFlow header. */
- /* b. OpenFlow header and one of the fixed-size message bodies. */
- /* c. OpenFlow header, fixed-size message body and variable-size data. */
- case OFPT_STATS_REQUEST:
- if (len < OF_STATS_REQUEST_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_stats_request_print(ndo, cp, len);
- return;
-
- /* a. OpenFlow header and fixed-size message body. */
- /* b. OpenFlow header and n * fixed-size data units. */
- /* c. OpenFlow header and n * variable-size data units. */
- /* d. OpenFlow header, fixed-size message body and variable-size data. */
- case OFPT_STATS_REPLY:
- if (len < OF_STATS_REPLY_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_stats_reply_print(ndo, cp, len);
- return;
-
- /* OpenFlow header and n * variable-size data units and variable-size data. */
- case OFPT_PACKET_OUT:
- if (len < OF_PACKET_OUT_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_packet_out_print(ndo, cp, len);
- return;
-
- /* OpenFlow header, fixed-size message body and n * variable-size data units. */
- case OFPT_FLOW_MOD:
- if (len < OF_FLOW_MOD_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- of10_flow_mod_print(ndo, cp, len);
- return;
-
- /* OpenFlow header, fixed-size message body and n * variable-size data units. */
- case OFPT_QUEUE_GET_CONFIG_REPLY: /* [OF10] Section 5.3.4 */
- if (len < OF_QUEUE_GET_CONFIG_REPLY_MINLEN - OF_HEADER_FIXLEN)
- goto invalid;
- if (ndo->ndo_vflag < 1)
- break;
- /* port */
- ND_PRINT("\n\t port %s",
- tok2str(ofpp_str, "%u", GET_BE_U_2(cp)));
- OF_FWD(2);
- /* pad */
- /* Sometimes the last field, check bounds. */
- OF_CHK_FWD(6);
- /* queues */
- of10_queues_print(ndo, cp, len);
- return;
- } /* switch (type) */