]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-openflow-1.3.c
OpenFlow: Have a function for each message type.
[tcpdump] / print-openflow-1.3.c
index 9832373db8903805876aadeddf7eaf37a03f7d1d..08fe7ca4e602d51c8e5889c2b6643afaf5f49800 100644 (file)
@@ -42,6 +42,7 @@
 #define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
+#include "addrtoname.h"
 #include "openflow.h"
 
 #define OFPT_HELLO                     0U
@@ -108,6 +109,125 @@ static const struct tok ofpt_str[] = {
        { 0, NULL }
 };
 
+#define OFPC_FLOW_STATS   (1U <<0)
+#define OFPC_TABLE_STATS  (1U <<1)
+#define OFPC_PORT_STATS   (1U <<2)
+#define OFPC_GROUP_STATS  (1U <<3)
+#define OFPC_IP_REASM     (1U <<5)
+#define OFPC_QUEUE_STATS  (1U <<6)
+#define OFPC_PORT_BLOCKED (1U <<8)
+static const struct tok ofp_capabilities_bm[] = {
+       { OFPC_FLOW_STATS,   "FLOW_STATS"   },
+       { OFPC_TABLE_STATS,  "TABLE_STATS"  },
+       { OFPC_PORT_STATS,   "PORT_STATS"   },
+       { OFPC_GROUP_STATS,  "GROUP_STATS"  },
+       { OFPC_IP_REASM,     "IP_REASM"     },
+       { OFPC_QUEUE_STATS,  "QUEUE_STATS"  },
+       { OFPC_PORT_BLOCKED, "PORT_BLOCKED" },
+       { 0, NULL }
+};
+#define OFPCAP_U (~(OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | \
+                    OFPC_GROUP_STATS | OFPC_IP_REASM | OFPC_QUEUE_STATS | \
+                    OFPC_PORT_BLOCKED))
+
+#define OFPC_FRAG_NORMAL 0U
+#define OFPC_FRAG_DROP   1U
+#define OFPC_FRAG_REASM  2U
+static const struct tok ofp_config_str[] = {
+       { OFPC_FRAG_NORMAL, "FRAG_NORMAL" },
+       { OFPC_FRAG_DROP,   "FRAG_DROP"   },
+       { OFPC_FRAG_REASM,  "FRAG_REASM"  },
+       { 0, NULL }
+};
+
+#define OFPTT_MAX 0xfeU
+#define OFPTT_ALL 0xffU
+static const struct tok ofptt_str[] = {
+       { OFPTT_MAX, "MAX" },
+       { OFPTT_ALL, "ALL" },
+       { 0, NULL },
+};
+
+#define OFPCML_MAX       0xffe5U
+#define OFPCML_NO_BUFFER 0xffffU
+static const struct tok ofpcml_str[] = {
+       { OFPCML_MAX,       "MAX"       },
+       { OFPCML_NO_BUFFER, "NO_BUFFER" },
+       { 0, NULL }
+};
+
+#define OFPPC_PORT_DOWN    (1U <<0)
+#define OFPPC_NO_RECV      (1U <<2)
+#define OFPPC_NO_FWD       (1U <<5)
+#define OFPPC_NO_PACKET_IN (1U <<6)
+static const struct tok ofppc_bm[] = {
+       { OFPPC_PORT_DOWN,    "PORT_DOWN"    },
+       { OFPPC_NO_RECV,      "NO_RECV"      },
+       { OFPPC_NO_FWD,       "NO_FWD"       },
+       { OFPPC_NO_PACKET_IN, "NO_PACKET_IN" },
+       { 0, NULL }
+};
+#define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_RECV | OFPPC_NO_FWD | \
+                   OFPPC_NO_PACKET_IN))
+
+#define OFPPS_LINK_DOWN   (1U << 0)
+#define OFPPS_BLOCKED     (1U << 1)
+#define OFPPS_LIVE        (1U << 2)
+static const struct tok ofpps_bm[] = {
+       { OFPPS_LINK_DOWN, "LINK_DOWN" },
+       { OFPPS_BLOCKED,   "BLOCKED"   },
+       { OFPPS_LIVE,      "LIVE"      },
+       { 0, NULL }
+};
+#define OFPPS_U (~(OFPPS_LINK_DOWN | OFPPS_BLOCKED | OFPPS_LIVE))
+
+#define OFPPF_10MB_HD    (1U <<  0)
+#define OFPPF_10MB_FD    (1U <<  1)
+#define OFPPF_100MB_HD   (1U <<  2)
+#define OFPPF_100MB_FD   (1U <<  3)
+#define OFPPF_1GB_HD     (1U <<  4)
+#define OFPPF_1GB_FD     (1U <<  5)
+#define OFPPF_10GB_FD    (1U <<  6)
+#define OFPPF_40GB_FD    (1U <<  7)
+#define OFPPF_100GB_FD   (1U <<  8)
+#define OFPPF_1TB_FD     (1U <<  9)
+#define OFPPF_OTHER      (1U << 10)
+#define OFPPF_COPPER     (1U << 11)
+#define OFPPF_FIBER      (1U << 12)
+#define OFPPF_AUTONEG    (1U << 13)
+#define OFPPF_PAUSE      (1U << 14)
+#define OFPPF_PAUSE_ASYM (1U << 15)
+static const struct tok ofppf_bm[] = {
+       { OFPPF_10MB_HD,    "10MB_HD"    },
+       { OFPPF_10MB_FD,    "10MB_FD"    },
+       { OFPPF_100MB_HD,   "100MB_HD"   },
+       { OFPPF_100MB_FD,   "100MB_FD"   },
+       { OFPPF_1GB_HD,     "1GB_HD"     },
+       { OFPPF_1GB_FD,     "1GB_FD"     },
+       { OFPPF_10GB_FD,    "10GB_FD"    },
+       { OFPPF_40GB_FD,    "40GB_FD"    },
+       { OFPPF_100GB_FD,   "100GB_FD"   },
+       { OFPPF_1TB_FD,     "1TB_FD"     },
+       { OFPPF_OTHER,      "OTHER"      },
+       { OFPPF_COPPER,     "COPPER"     },
+       { OFPPF_FIBER,      "FIBER"      },
+       { OFPPF_AUTONEG,    "AUTONEG"    },
+       { OFPPF_PAUSE,      "PAUSE"      },
+       { OFPPF_PAUSE_ASYM, "PAUSE_ASYM" },
+       { 0, NULL }
+};
+#define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \
+                   OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \
+                   OFPPF_10GB_FD | OFPPF_40GB_FD | OFPPF_100GB_FD | \
+                   OFPPF_1TB_FD | OFPPF_OTHER | OFPPF_COPPER | OFPPF_FIBER | \
+                   OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM))
+
+#define OFPHET_VERSIONBITMAP 1U
+static const struct tok ofphet_str[] = {
+       { OFPHET_VERSIONBITMAP, "VERSIONBITMAP" },
+       { 0, NULL }
+};
+
 #define OFPP_MAX        0xffffff00U
 #define OFPP_IN_PORT    0xfffffff8U
 #define OFPP_TABLE      0xfffffff9U
@@ -130,6 +250,82 @@ static const struct tok ofpp_str[] = {
        { 0, NULL }
 };
 
+#define OFPCR_ROLE_NOCHANGE 0U
+#define OFPCR_ROLE_EQUAL    1U
+#define OFPCR_ROLE_MASTER   2U
+#define OFPCR_ROLE_SLAVE    3U
+static const struct tok ofpcr_str[] = {
+       { OFPCR_ROLE_NOCHANGE, "NOCHANGE" },
+       { OFPCR_ROLE_EQUAL,    "EQUAL"    },
+       { OFPCR_ROLE_MASTER,   "MASTER"   },
+       { OFPCR_ROLE_SLAVE,    "SLAVE"    },
+       { 0, NULL }
+};
+
+#define OF_BIT_VER_1_0 (1U << (OF_VER_1_0 - 1))
+#define OF_BIT_VER_1_1 (1U << (OF_VER_1_1 - 1))
+#define OF_BIT_VER_1_2 (1U << (OF_VER_1_2 - 1))
+#define OF_BIT_VER_1_3 (1U << (OF_VER_1_3 - 1))
+#define OF_BIT_VER_1_4 (1U << (OF_VER_1_4 - 1))
+#define OF_BIT_VER_1_5 (1U << (OF_VER_1_5 - 1))
+static const struct tok ofverbm_str[] = {
+       { OF_BIT_VER_1_0, "1.0" },
+       { OF_BIT_VER_1_1, "1.1" },
+       { OF_BIT_VER_1_2, "1.2" },
+       { OF_BIT_VER_1_3, "1.3" },
+       { OF_BIT_VER_1_4, "1.4" },
+       { OF_BIT_VER_1_5, "1.5" },
+       { 0, NULL }
+};
+#define OF_BIT_VER_U (~(OF_BIT_VER_1_0 | OF_BIT_VER_1_1 | OF_BIT_VER_1_2 | \
+                        OF_BIT_VER_1_3 | OF_BIT_VER_1_4 | OF_BIT_VER_1_5))
+
+#define OFPR_NO_MATCH    0U
+#define OFPR_ACTION      1U
+#define OFPR_INVALID_TTL 2U
+#if 0 /* for OFPT_PACKET_IN */
+static const struct tok ofpr_str[] = {
+       { OFPR_NO_MATCH,    "NO_MATCH"         },
+       { OFPR_ACTION,      "ACTION"           },
+       { OFPR_INVALID_TTL, "OFPR_INVALID_TTL" },
+       { 0, NULL }
+};
+#endif
+
+#define ASYNC_OFPR_NO_MATCH    (1U << OFPR_NO_MATCH   )
+#define ASYNC_OFPR_ACTION      (1U << OFPR_ACTION     )
+#define ASYNC_OFPR_INVALID_TTL (1U << OFPR_INVALID_TTL)
+static const struct tok async_ofpr_bm[] = {
+       { ASYNC_OFPR_NO_MATCH,    "NO_MATCH"    },
+       { ASYNC_OFPR_ACTION,      "ACTION"      },
+       { ASYNC_OFPR_INVALID_TTL, "INVALID_TTL" },
+       { 0, NULL }
+};
+#define ASYNC_OFPR_U (~(ASYNC_OFPR_NO_MATCH | ASYNC_OFPR_ACTION | \
+                        ASYNC_OFPR_INVALID_TTL))
+
+#define OFPPR_ADD    0U
+#define OFPPR_DELETE 1U
+#define OFPPR_MODIFY 2U
+static const struct tok ofppr_str[] = {
+       { OFPPR_ADD,    "ADD"    },
+       { OFPPR_DELETE, "DELETE" },
+       { OFPPR_MODIFY, "MODIFY" },
+       { 0, NULL }
+};
+
+#define ASYNC_OFPPR_ADD    (1U << OFPPR_ADD   )
+#define ASYNC_OFPPR_DELETE (1U << OFPPR_DELETE)
+#define ASYNC_OFPPR_MODIFY (1U << OFPPR_MODIFY)
+static const struct tok async_ofppr_bm[] = {
+       { ASYNC_OFPPR_ADD,    "ADD"    },
+       { ASYNC_OFPPR_DELETE, "DELETE" },
+       { ASYNC_OFPPR_MODIFY, "MODIFY" },
+       { 0, NULL }
+};
+#define ASYNC_OFPPR_U (~(ASYNC_OFPPR_ADD | ASYNC_OFPPR_DELETE | \
+                         ASYNC_OFPPR_MODIFY))
+
 #define OFPET_HELLO_FAILED           0U
 #define OFPET_BAD_REQUEST            1U
 #define OFPET_BAD_ACTION             2U
@@ -163,11 +359,6 @@ static const struct tok ofpet_str[] = {
        { OFPET_EXPERIMENTER,          "EXPERIMENTER"          },
        { 0, NULL }
 };
-/*
- * As far as of13_error_print() is concerned, OFPET_EXPERIMENTER is too large
- * and defines no codes anyway.
- */
-#define OFPET_MAX OFPET_TABLE_FEATURES_FAILED
 
 #define OFPHFC_INCOMPATIBLE 0U
 #define OFPHFC_EPERM        1U
@@ -447,9 +638,40 @@ static const struct tok ofptffc_str[] = {
        { 0, NULL }
 };
 
+static const struct uint_tokary of13_ofpet2tokary[] = {
+       { OFPET_HELLO_FAILED,          ofphfc_str  },
+       { OFPET_BAD_REQUEST,           ofpbrc_str  },
+       { OFPET_BAD_ACTION,            ofpbac_str  },
+       { OFPET_BAD_INSTRUCTION,       ofpbic_str  },
+       { OFPET_BAD_MATCH,             ofpbmc_str  },
+       { OFPET_FLOW_MOD_FAILED,       ofpfmfc_str },
+       { OFPET_GROUP_MOD_FAILED,      ofpgmfc_str },
+       { OFPET_PORT_MOD_FAILED,       ofppmfc_str },
+       { OFPET_TABLE_MOD_FAILED,      ofptmfc_str },
+       { OFPET_QUEUE_OP_FAILED,       ofpqofc_str },
+       { OFPET_SWITCH_CONFIG_FAILED,  ofpscfc_str },
+       { OFPET_ROLE_REQUEST_FAILED,   ofprrfc_str },
+       { OFPET_METER_MOD_FAILED,      ofpmmfc_str },
+       { OFPET_TABLE_FEATURES_FAILED, ofptffc_str },
+       { OFPET_EXPERIMENTER,          NULL        }, /* defines no codes */
+       /* uint2tokary() does not use array termination. */
+};
+
 /* lengths (fixed or minimal) of particular protocol structures */
+#define OF_HELLO_ELEM_MINSIZE                 4U
 #define OF_ERROR_MSG_MINLEN                   12U
+#define OF_FEATURES_REPLY_FIXLEN              32U
+#define OF_PORT_MOD_FIXLEN                    40U
+#define OF_SWITCH_CONFIG_MSG_FIXLEN           12U
+#define OF_TABLE_MOD_FIXLEN                   16U
 #define OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN    16U
+#define OF_ROLE_MSG_FIXLEN                    24U
+#define OF_ASYNC_MSG_FIXLEN                   32U
+#define OF_PORT_STATUS_FIXLEN                 80U
+#define OF_EXPERIMENTER_MSG_MINLEN            16U
+
+/* miscellaneous constants from [OF13] */
+#define OFP_MAX_PORT_NAME_LEN                 16U
 
 /* [OF13] Section A.1 */
 const char *
@@ -458,28 +680,304 @@ of13_msgtype_str(const uint8_t type)
        return tok2str(ofpt_str, "invalid (0x%02x)", type);
 }
 
+/* [OF13] Section 7.2.1 */
+static void
+of13_port_print(netdissect_options *ndo,
+                const u_char *cp)
+{
+       /* port_no */
+       ND_PRINT("\n\t  port_no %s",
+                tok2str(ofpp_str, "%u", GET_BE_U_4(cp)));
+       cp += 4;
+       /* pad */
+       cp += 4;
+       /* hw_addr */
+       ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp));
+       cp += MAC_ADDR_LEN;
+       /* pad2 */
+       cp += 2;
+       /* name */
+       ND_PRINT(", name '");
+       (void)nd_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+       ND_PRINT("'");
+       cp += OFP_MAX_PORT_NAME_LEN;
+
+       if (ndo->ndo_vflag < 2) {
+               ND_TCHECK_LEN(cp, 32);
+               return;
+       }
+
+       /* config */
+       ND_PRINT("\n\t   config 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppc_bm, GET_BE_U_4(cp), OFPPC_U);
+       cp += 4;
+       /* state */
+       ND_PRINT("\n\t   state 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofpps_bm, GET_BE_U_4(cp), OFPPS_U);;
+       cp += 4;
+       /* curr */
+       ND_PRINT("\n\t   curr 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U);
+       cp += 4;
+       /* advertised */
+       ND_PRINT("\n\t   advertised 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U);
+       cp += 4;
+       /* supported */
+       ND_PRINT("\n\t   supported 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U);
+       cp += 4;
+       /* peer */
+       ND_PRINT("\n\t   peer 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U);
+       cp += 4;
+       /* curr_speed */
+       ND_PRINT("\n\t   curr_speed %ukbps", GET_BE_U_4(cp));
+       cp += 4;
+       /* max_speed */
+       ND_PRINT("\n\t   max_speed %ukbps", GET_BE_U_4(cp));
+}
+
+/* [OF13] Section 7.3.1 */
+static void
+of13_features_reply_print(netdissect_options *ndo,
+                          const u_char *cp)
+{
+       /* datapath_id */
+       ND_PRINT("\n\t dpid 0x%016" PRIx64, GET_BE_U_8(cp));
+       cp += 8;
+       /* n_buffers */
+       ND_PRINT(", n_buffers %u", GET_BE_U_4(cp));
+       cp += 4;
+       /* n_tables */
+       ND_PRINT(", n_tables %u", GET_U_1(cp));
+       cp += 1;
+       /* auxiliary_id */
+       ND_PRINT(", auxiliary_id %u", GET_U_1(cp));
+       cp += 1;
+       /* pad */
+       cp += 2;
+       /* capabilities */
+       ND_PRINT("\n\t capabilities 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofp_capabilities_bm, GET_BE_U_4(cp), OFPCAP_U);
+       cp += 4;
+       /* reserved */
+       ND_TCHECK_4(cp);
+}
+
+/* [OF13] Section 7.3.2 */
+static void
+of13_switch_config_msg_print(netdissect_options *ndo,
+                             const u_char *cp)
+{
+       /* flags */
+       ND_PRINT("\n\t flags %s",
+                tok2str(ofp_config_str, "invalid (0x%04x)", GET_BE_U_2(cp)));
+       cp += 2;
+       /* miss_send_len */
+       ND_PRINT(", miss_send_len %s",
+                tok2str(ofpcml_str, "%u", GET_BE_U_2(cp)));
+}
+
+/* [OF13] Section 7.3.3 */
+static void
+of13_table_mod_print(netdissect_options *ndo,
+                     const u_char *cp)
+{
+       /* table_id */
+       ND_PRINT("\n\t table_id %s", tok2str(ofptt_str, "%u", GET_U_1(cp)));
+       cp += 1;
+       /* pad */
+       cp += 3;
+       /* config */
+       ND_PRINT(", config 0x%08x", GET_BE_U_4(cp));
+}
+
+/* [OF13] Section 7.3.9 */
+static void
+of13_role_msg_print(netdissect_options *ndo,
+                    const u_char *cp)
+{
+       /* role */
+       ND_PRINT("\n\t role %s",
+                tok2str(ofpcr_str, "invalid (0x%08x)", GET_BE_U_4(cp)));
+       cp += 4;
+       /* pad */
+       cp += 4;
+       /* generation_id */
+       ND_PRINT(", generation_id 0x%016" PRIx64, GET_BE_U_8(cp));
+}
+
+/* [OF13] Section 7.3.10 */
+static void
+of13_async_msg_print(netdissect_options *ndo,
+                    const u_char *cp)
+{
+       /* packet_in_mask[0] */
+       ND_PRINT("\n\t packet_in_mask[EM] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofpr_bm, GET_BE_U_4(cp), ASYNC_OFPR_U);
+       cp += 4;
+       /* packet_in_mask[1] */
+       ND_PRINT("\n\t packet_in_mask[S] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofpr_bm, GET_BE_U_4(cp), ASYNC_OFPR_U);
+       cp += 4;
+       /* port_status_mask[0] */
+       ND_PRINT("\n\t port_status_mask[EM] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofppr_bm, GET_BE_U_4(cp), ASYNC_OFPPR_U);
+       cp += 4;
+       /* port_status_mask[1] */
+       ND_PRINT("\n\t port_status_mask[S] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofppr_bm, GET_BE_U_4(cp), ASYNC_OFPPR_U);
+       cp += 4;
+       /* flow_removed_mask[0] */
+       ND_PRINT("\n\t flow_removed_mask[EM] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofppr_bm, GET_BE_U_4(cp), ASYNC_OFPPR_U);
+       cp += 4;
+       /* flow_removed_mask[1] */
+       ND_PRINT("\n\t flow_removed_mask[S] 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, async_ofppr_bm, GET_BE_U_4(cp), ASYNC_OFPPR_U);
+}
+
+/* [OF13] Section 7.3.4.3 */
+static void
+of13_port_mod_print(netdissect_options *ndo,
+                    const u_char *cp)
+{
+       /* port_no */
+       ND_PRINT("\n\t port_no %s", tok2str(ofpp_str, "%u", GET_BE_U_4(cp)));
+       cp += 4;
+       /* pad */
+       cp += 4;
+       /* hw_addr */
+       ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp));
+       cp += MAC_ADDR_LEN;
+       /* pad2 */
+       cp += 2;
+       /* config */
+       ND_PRINT("\n\t  config 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppc_bm, GET_BE_U_4(cp), OFPPC_U);
+       cp += 4;
+       /* mask */
+       ND_PRINT("\n\t  mask 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppc_bm, GET_BE_U_4(cp), OFPPC_U);
+       cp += 4;
+       /* advertise */
+       ND_PRINT("\n\t  advertise 0x%08x", GET_BE_U_4(cp));
+       of_bitmap_print(ndo, ofppf_bm, GET_BE_U_4(cp), OFPPF_U);
+       cp += 4;
+       /* pad3 */
+       /* Always the last field, check bounds. */
+       ND_TCHECK_4(cp);
+}
+
+/* [OF13] Section 7.4.3 */
+static void
+of13_port_status_print(netdissect_options *ndo,
+                       const u_char *cp)
+{
+       /* reason */
+       ND_PRINT("\n\t reason %s",
+                tok2str(ofppr_str, "invalid (0x02x)", GET_U_1(cp)));
+       cp += 1;
+       /* pad */
+       cp += 7;
+       /* desc */
+       of13_port_print(ndo, cp);
+}
+
+/* [OF13] Section 7.5.1 */
+static void
+of13_hello_elements_print(netdissect_options *ndo,
+                          const u_char *cp, u_int len)
+{
+       while (len) {
+               uint16_t type, bmlen;
+
+               if (len < OF_HELLO_ELEM_MINSIZE)
+                       goto invalid;
+               /* type */
+               type = GET_BE_U_2(cp);
+               OF_FWD(2);
+               ND_PRINT("\n\t type %s",
+                        tok2str(ofphet_str, "unknown (0x%04x)", type));
+               /* length */
+               bmlen = GET_BE_U_2(cp);
+               OF_FWD(2);
+               ND_PRINT(", length %u", bmlen);
+               /* cp is OF_HELLO_ELEM_MINSIZE bytes in */
+               if (bmlen < OF_HELLO_ELEM_MINSIZE ||
+                   bmlen > OF_HELLO_ELEM_MINSIZE + len)
+                       goto invalid;
+               switch (type) {
+               case OFPHET_VERSIONBITMAP:
+                       /*
+                        * The specification obviously overprovisions the space
+                        * for version bitmaps in this element ("ofp versions
+                        * 32 to 63 are encoded in the second bitmap and so
+                        * on"). Keep this code simple for now and recognize
+                        * only a single bitmap with no padding.
+                        */
+                       if (bmlen == OF_HELLO_ELEM_MINSIZE + 4) {
+                               uint32_t bitmap = GET_BE_U_4(cp);
+                               ND_PRINT(", bitmap 0x%08x", bitmap);
+                               of_bitmap_print(ndo, ofverbm_str, bitmap,
+                                               OF_BIT_VER_U);
+                       } else {
+                               ND_PRINT(" (bogus)");
+                               ND_TCHECK_LEN(cp, bmlen - OF_HELLO_ELEM_MINSIZE);
+                       }
+                       break;
+               default:
+                       ND_TCHECK_LEN(cp, bmlen - OF_HELLO_ELEM_MINSIZE);
+               }
+               OF_FWD(bmlen - OF_HELLO_ELEM_MINSIZE);
+       }
+       return;
+
+invalid:
+       nd_print_invalid(ndo);
+       ND_TCHECK_LEN(cp, len);
+}
+
+/* [OF13] Section 7.5.4 */
+static void
+of13_experimenter_message_print(netdissect_options *ndo,
+                                const u_char *cp, u_int len)
+{
+       uint32_t experimenter;
+
+       /* experimenter */
+       experimenter = GET_BE_U_4(cp);
+       OF_FWD(4);
+       ND_PRINT("\n\t experimenter 0x%08x (%s)", experimenter,
+                of_vendor_name(experimenter));
+       /* exp_type */
+       ND_PRINT(", exp_type 0x%08x", GET_BE_U_4(cp));
+       OF_FWD(4);
+       /* data */
+       of_data_print(ndo, cp, len);
+}
+
+/* [OF13] Section A.3.6 */
+static void
+of13_queue_get_config_request_print(netdissect_options *ndo,
+                                    const u_char *cp)
+{
+       /* port */
+       ND_PRINT("\n\t port %s", tok2str(ofpp_str, "%u", GET_BE_U_4(cp)));
+       cp += 4;
+       /* pad */
+       /* Always the last field, check bounds. */
+       ND_TCHECK_4(cp);
+}
+
 /* [OF13] Section A.4.4 */
 static void
 of13_error_print(netdissect_options *ndo,
                  const u_char *cp, u_int len)
 {
        uint16_t type, code;
-       const struct tok *code_str[OFPET_MAX + 1] = {
-               /* [OFPET_HELLO_FAILED         ] = */ ofphfc_str,
-               /* [OFPET_BAD_REQUEST          ] = */ ofpbrc_str,
-               /* [OFPET_BAD_ACTION           ] = */ ofpbac_str,
-               /* [OFPET_BAD_INSTRUCTION      ] = */ ofpbic_str,
-               /* [OFPET_BAD_MATCH            ] = */ ofpbmc_str,
-               /* [OFPET_FLOW_MOD_FAILED      ] = */ ofpfmfc_str,
-               /* [OFPET_GROUP_MOD_FAILED     ] = */ ofpgmfc_str,
-               /* [OFPET_PORT_MOD_FAILED      ] = */ ofppmfc_str,
-               /* [OFPET_TABLE_MOD_FAILED     ] = */ ofptmfc_str,
-               /* [OFPET_QUEUE_OP_FAILED      ] = */ ofpqofc_str,
-               /* [OFPET_SWITCH_CONFIG_FAILED ] = */ ofpscfc_str,
-               /* [OFPET_ROLE_REQUEST_FAILED  ] = */ ofprrfc_str,
-               /* [OFPET_METER_MOD_FAILED     ] = */ ofpmmfc_str,
-               /* [OFPET_TABLE_FEATURES_FAILED] = */ ofptffc_str,
-       };
+       const struct tok *code_str;
 
        /* type */
        type = GET_BE_U_2(cp);
@@ -488,9 +986,10 @@ of13_error_print(netdissect_options *ndo,
        /* code */
        code = GET_BE_U_2(cp);
        OF_FWD(2);
-       if (type <= OFPET_MAX && code_str[type] != NULL)
+       code_str = uint2tokary(of13_ofpet2tokary, type);
+       if (code_str != NULL)
                ND_PRINT(", code %s",
-                        tok2str(code_str[type], "invalid (0x%04x)", code));
+                        tok2str(code_str, "invalid (0x%04x)", code));
        else
                ND_PRINT(", code invalid (0x%04x)", code);
        /* data */
@@ -508,27 +1007,73 @@ of13_message_print(netdissect_options *ndo,
        case OFPT_GET_CONFIG_REQUEST: /* [OF13] Section A.3.2 */
        case OFPT_BARRIER_REQUEST: /* [OF13] Section A.3.8 */
        case OFPT_BARRIER_REPLY: /* ibid */
+       case OFPT_GET_ASYNC_REQUEST: /* [OF13] Section 7.3.10 */
                if (len)
                        goto invalid;
                return;
 
        /* OpenFlow header and fixed-size message body. */
+       case OFPT_FEATURES_REPLY:
+               if (len != OF_FEATURES_REPLY_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_features_reply_print(ndo, cp);
+               return;
        case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF13] Section A.3.6 */
                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_4(cp)));
-               OF_FWD(4);
-               /* pad */
-               /* Always the last field, check bounds. */
-               ND_TCHECK_4(cp);
+               of13_queue_get_config_request_print(ndo, cp);
+               return;
+       case OFPT_GET_CONFIG_REPLY: /* [OF13] Section 7.3.2 */
+       case OFPT_SET_CONFIG: /* ibid */
+               if (len != OF_SWITCH_CONFIG_MSG_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_switch_config_msg_print(ndo, cp);
+               return;
+       case OFPT_PORT_MOD: /* [OF13] Section 7.3.4.3 */
+               if (len != OF_PORT_MOD_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_port_mod_print(ndo, cp);
+               return;
+       case OFPT_ROLE_REQUEST: /* [OF13] Section 7.3.9 */
+       case OFPT_ROLE_REPLY: /* ibid */
+               if (len != OF_ROLE_MSG_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_role_msg_print(ndo, cp);
+               return;
+       case OFPT_PORT_STATUS: /* [OF13] Section 7.4.3 */
+               if (len != OF_PORT_STATUS_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_port_status_print(ndo, cp);
+               return;
+       case OFPT_TABLE_MOD: /* [OF13] Section 7.3.3 */
+               if (len != OF_TABLE_MOD_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_table_mod_print(ndo, cp);
+               return;
+       case OFPT_SET_ASYNC: /* [OF13] Section 7.3.10 */
+       case OFPT_GET_ASYNC_REPLY: /* ibid */
+               if (len != OF_ASYNC_MSG_FIXLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_async_msg_print(ndo, cp);
                return;
 
        /* OpenFlow header and variable-size data. */
-       case OFPT_HELLO: /* [OF13] Section A.5.1 */
        case OFPT_ECHO_REQUEST: /* [OF13] Section A.5.2 */
        case OFPT_ECHO_REPLY: /* [OF13] Section A.5.3 */
                if (ndo->ndo_vflag < 1)
@@ -536,6 +1081,13 @@ of13_message_print(netdissect_options *ndo,
                of_data_print(ndo, cp, len);
                return;
 
+       /* OpenFlow header and n * variable-size data units. */
+       case OFPT_HELLO: /* [OF13] Section A.5.1 */
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_hello_elements_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)
@@ -544,6 +1096,13 @@ of13_message_print(netdissect_options *ndo,
                        break;
                of13_error_print(ndo, cp, len);
                return;
+       case OFPT_EXPERIMENTER: /* [OF13] Section 7.5.4 */
+               if (len < OF_EXPERIMENTER_MSG_MINLEN - OF_HEADER_FIXLEN)
+                       goto invalid;
+               if (ndo->ndo_vflag < 1)
+                       break;
+               of13_experimenter_message_print(ndo, cp, len);
+               return;
        }
        /*
         * Not a recognised type or did not print the details, fall back to