summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2016-11-18 17:37:04 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2016-11-18 17:37:04 +0000
commit8ed45f4e906485871116996d5a06a534ecd4a407 (patch)
tree7d38e06ee55a73a80232b0d9b3fcb0c97c69e433 /usr.sbin
parentc74a722c1723dbae187aeb75eff12c00de876e6d (diff)
Updates tcpdump's OpenFlow printer to use the string maps from switchd
(manually synced). Also make the output a bit more like other printers. OK rzalamena@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/tcpdump/Makefile4
-rw-r--r--usr.sbin/tcpdump/ofp_map.c381
-rw-r--r--usr.sbin/tcpdump/ofp_map.h74
-rw-r--r--usr.sbin/tcpdump/print-ofp.c215
4 files changed, 586 insertions, 88 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile
index 88eb66e8750..4c0392cff6b 100644
--- a/usr.sbin/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.60 2016/10/22 20:55:04 rzalamena Exp $
+# $OpenBSD: Makefile,v 1.61 2016/11/18 17:37:03 reyk Exp $
#
# Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
# The Regents of the University of California. All rights reserved.
@@ -47,7 +47,7 @@ SRCS= tcpdump.c addrtoname.c privsep.c privsep_fdpass.c privsep_pcap.c \
print-ip6.c print-ip6opts.c print-icmp6.c print-dhcp6.c print-frag6.c \
print-bgp.c print-ospf6.c print-ripng.c print-rt6.c print-stp.c \
print-etherip.c print-lwres.c print-lldp.c print-cdp.c print-pflog.c \
- print-pfsync.c pf_print_state.c print-ofp.c \
+ print-pfsync.c pf_print_state.c print-ofp.c ofp_map.c \
print-udpencap.c print-carp.c \
print-802_11.c print-iapp.c print-mpls.c print-slow.c \
gmt2local.c savestr.c setsignal.c in_cksum.c
diff --git a/usr.sbin/tcpdump/ofp_map.c b/usr.sbin/tcpdump/ofp_map.c
new file mode 100644
index 00000000000..91e307f38aa
--- /dev/null
+++ b/usr.sbin/tcpdump/ofp_map.c
@@ -0,0 +1,381 @@
+/* Automatically generated from ofp.h, do not edit */
+/* $OpenBSD: ofp_map.c,v 1.1 2016/11/18 17:37:03 reyk Exp $ */
+
+/*
+ * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
+ * Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <net/ofp.h>
+#include "ofp_map.h"
+
+struct constmap ofp_v_map[] = {
+ { OFP_V_0, "0" },
+ { OFP_V_1_0, "1_0" },
+ { OFP_V_1_1, "1_1" },
+ { OFP_V_1_2, "1_2" },
+ { OFP_V_1_3, "1_3" },
+ { OFP_V_1_4, "1_4" },
+ { OFP_V_1_5, "1_5" },
+ { 0 }
+};
+struct constmap ofp_t_map[] = {
+ { OFP_T_HELLO, "HELLO" },
+ { OFP_T_ERROR, "ERROR" },
+ { OFP_T_ECHO_REQUEST, "ECHO_REQUEST" },
+ { OFP_T_ECHO_REPLY, "ECHO_REPLY" },
+ { OFP_T_EXPERIMENTER, "EXPERIMENTER" },
+ { OFP_T_FEATURES_REQUEST, "FEATURES_REQUEST" },
+ { OFP_T_FEATURES_REPLY, "FEATURES_REPLY" },
+ { OFP_T_GET_CONFIG_REQUEST, "GET_CONFIG_REQUEST" },
+ { OFP_T_GET_CONFIG_REPLY, "GET_CONFIG_REPLY" },
+ { OFP_T_SET_CONFIG, "SET_CONFIG" },
+ { OFP_T_PACKET_IN, "PACKET_IN" },
+ { OFP_T_FLOW_REMOVED, "FLOW_REMOVED" },
+ { OFP_T_PORT_STATUS, "PORT_STATUS" },
+ { OFP_T_PACKET_OUT, "PACKET_OUT" },
+ { OFP_T_FLOW_MOD, "FLOW_MOD" },
+ { OFP_T_GROUP_MOD, "GROUP_MOD" },
+ { OFP_T_PORT_MOD, "PORT_MOD" },
+ { OFP_T_TABLE_MOD, "TABLE_MOD" },
+ { OFP_T_MULTIPART_REQUEST, "MULTIPART_REQUEST" },
+ { OFP_T_MULTIPART_REPLY, "MULTIPART_REPLY" },
+ { OFP_T_BARRIER_REQUEST, "BARRIER_REQUEST" },
+ { OFP_T_BARRIER_REPLY, "BARRIER_REPLY" },
+ { OFP_T_QUEUE_GET_CONFIG_REQUEST, "QUEUE_GET_CONFIG_REQUEST" },
+ { OFP_T_QUEUE_GET_CONFIG_REPLY, "QUEUE_GET_CONFIG_REPLY" },
+ { OFP_T_ROLE_REQUEST, "ROLE_REQUEST" },
+ { OFP_T_ROLE_REPLY, "ROLE_REPLY" },
+ { OFP_T_GET_ASYNC_REQUEST, "GET_ASYNC_REQUEST" },
+ { OFP_T_GET_ASYNC_REPLY, "GET_ASYNC_REPLY" },
+ { OFP_T_SET_ASYNC, "SET_ASYNC" },
+ { OFP_T_METER_MOD, "METER_MOD" },
+ { 0 }
+};
+struct constmap ofp_pktin_map[] = {
+ { OFP_PKTIN_REASON_NO_MATCH, "REASON_NO_MATCH" },
+ { OFP_PKTIN_REASON_ACTION, "REASON_ACTION" },
+ { OFP_PKTIN_REASON_TTL, "REASON_TTL" },
+ { 0 }
+};
+struct constmap ofp_port_map[] = {
+ { OFP_PORT_MAX, "MAX" },
+ { OFP_PORT_INPUT, "INPUT" },
+ { OFP_PORT_FLOWTABLE, "FLOWTABLE" },
+ { OFP_PORT_NORMAL, "NORMAL" },
+ { OFP_PORT_FLOOD, "FLOOD" },
+ { OFP_PORT_ALL, "ALL" },
+ { OFP_PORT_CONTROLLER, "CONTROLLER" },
+ { OFP_PORT_LOCAL, "LOCAL" },
+ { OFP_PORT_ANY, "ANY" },
+ { 0 }
+};
+struct constmap ofp_pktout_map[] = {
+ { OFP_PKTOUT_NO_BUFFER, "NO_BUFFER" },
+ { 0 }
+};
+struct constmap ofp_oxm_c_map[] = {
+ { OFP_OXM_C_NXM_0, "NXM_0" },
+ { OFP_OXM_C_NXM_1, "NXM_1" },
+ { OFP_OXM_C_OPENFLOW_BASIC, "OPENFLOW_BASIC" },
+ { OFP_OXM_C_OPENFLOW_EXPERIMENTER, "OPENFLOW_EXPERIMENTER" },
+ { 0 }
+};
+struct constmap ofp_xm_t_map[] = {
+ { OFP_XM_T_IN_PORT, "IN_PORT" },
+ { OFP_XM_T_IN_PHY_PORT, "IN_PHY_PORT" },
+ { OFP_XM_T_META, "META" },
+ { OFP_XM_T_ETH_DST, "ETH_DST" },
+ { OFP_XM_T_ETH_SRC, "ETH_SRC" },
+ { OFP_XM_T_ETH_TYPE, "ETH_TYPE" },
+ { OFP_XM_T_VLAN_VID, "VLAN_VID" },
+ { OFP_XM_T_VLAN_PCP, "VLAN_PCP" },
+ { OFP_XM_T_IP_DSCP, "IP_DSCP" },
+ { OFP_XM_T_IP_ECN, "IP_ECN" },
+ { OFP_XM_T_IP_PROTO, "IP_PROTO" },
+ { OFP_XM_T_IPV4_SRC, "IPV4_SRC" },
+ { OFP_XM_T_IPV4_DST, "IPV4_DST" },
+ { OFP_XM_T_TCP_SRC, "TCP_SRC" },
+ { OFP_XM_T_TCP_DST, "TCP_DST" },
+ { OFP_XM_T_UDP_SRC, "UDP_SRC" },
+ { OFP_XM_T_UDP_DST, "UDP_DST" },
+ { OFP_XM_T_SCTP_SRC, "SCTP_SRC" },
+ { OFP_XM_T_SCTP_DST, "SCTP_DST" },
+ { OFP_XM_T_ICMPV4_TYPE, "ICMPV4_TYPE" },
+ { OFP_XM_T_ICMPV4_CODE, "ICMPV4_CODE" },
+ { OFP_XM_T_ARP_OP, "ARP_OP" },
+ { OFP_XM_T_ARP_SPA, "ARP_SPA" },
+ { OFP_XM_T_ARP_TPA, "ARP_TPA" },
+ { OFP_XM_T_ARP_SHA, "ARP_SHA" },
+ { OFP_XM_T_ARP_THA, "ARP_THA" },
+ { OFP_XM_T_IPV6_SRC, "IPV6_SRC" },
+ { OFP_XM_T_IPV6_DST, "IPV6_DST" },
+ { OFP_XM_T_IPV6_FLABEL, "IPV6_FLABEL" },
+ { OFP_XM_T_ICMPV6_TYPE, "ICMPV6_TYPE" },
+ { OFP_XM_T_ICMPV6_CODE, "ICMPV6_CODE" },
+ { OFP_XM_T_IPV6_ND_TARGET, "IPV6_ND_TARGET" },
+ { OFP_XM_T_IPV6_ND_SLL, "IPV6_ND_SLL" },
+ { OFP_XM_T_IPV6_ND_TLL, "IPV6_ND_TLL" },
+ { OFP_XM_T_MPLS_LABEL, "MPLS_LABEL" },
+ { OFP_XM_T_MPLS_TC, "MPLS_TC" },
+ { OFP_XM_T_MPLS_BOS, "MPLS_BOS" },
+ { OFP_XM_T_PBB_ISID, "PBB_ISID" },
+ { OFP_XM_T_TUNNEL_ID, "TUNNEL_ID" },
+ { OFP_XM_T_IPV6_EXTHDR, "IPV6_EXTHDR" },
+ { 0 }
+};
+struct constmap ofp_config_map[] = {
+ { OFP_CONFIG_FRAG_NORMAL, "FRAG_NORMAL" },
+ { OFP_CONFIG_FRAG_DROP, "FRAG_DROP" },
+ { OFP_CONFIG_FRAG_REASM, "FRAG_REASM" },
+ { OFP_CONFIG_FRAG_MASK, "FRAG_MASK" },
+ { 0 }
+};
+struct constmap ofp_controller_maxlen_map[] = {
+ { OFP_CONTROLLER_MAXLEN_MAX, "MAX" },
+ { OFP_CONTROLLER_MAXLEN_NO_BUFFER, "NO_BUFFER" },
+ { 0 }
+};
+struct constmap ofp_instruction_t_map[] = {
+ { OFP_INSTRUCTION_T_GOTO_TABLE, "GOTO_TABLE" },
+ { OFP_INSTRUCTION_T_WRITE_META, "WRITE_META" },
+ { OFP_INSTRUCTION_T_WRITE_ACTIONS, "WRITE_ACTIONS" },
+ { OFP_INSTRUCTION_T_APPLY_ACTIONS, "APPLY_ACTIONS" },
+ { OFP_INSTRUCTION_T_CLEAR_ACTIONS, "CLEAR_ACTIONS" },
+ { OFP_INSTRUCTION_T_METER, "METER" },
+ { OFP_INSTRUCTION_T_EXPERIMENTER, "EXPERIMENTER" },
+ { 0 }
+};
+struct constmap ofp_portstate_map[] = {
+ { OFP_PORTSTATE_LINK_DOWN, "LINK_DOWN" },
+ { OFP_PORTSTATE_STP_LISTEN, "STP_LISTEN" },
+ { OFP_PORTSTATE_STP_LEARN, "STP_LEARN" },
+ { OFP_PORTSTATE_STP_FORWARD, "STP_FORWARD" },
+ { OFP_PORTSTATE_STP_BLOCK, "STP_BLOCK" },
+ { OFP_PORTSTATE_STP_MASK, "STP_MASK" },
+ { 0 }
+};
+struct constmap ofp_portconfig_map[] = {
+ { OFP_PORTCONFIG_PORT_DOWN, "PORT_DOWN" },
+ { OFP_PORTCONFIG_NO_STP, "NO_STP" },
+ { OFP_PORTCONFIG_NO_RECV, "NO_RECV" },
+ { OFP_PORTCONFIG_NO_RECV_STP, "NO_RECV_STP" },
+ { OFP_PORTCONFIG_NO_FLOOD, "NO_FLOOD" },
+ { OFP_PORTCONFIG_NO_FWD, "NO_FWD" },
+ { OFP_PORTCONFIG_NO_PACKET_IN, "NO_PACKET_IN" },
+ { 0 }
+};
+struct constmap ofp_portmedia_map[] = {
+ { OFP_PORTMEDIA_10MB_HD, "10MB_HD" },
+ { OFP_PORTMEDIA_10MB_FD, "10MB_FD" },
+ { OFP_PORTMEDIA_100MB_HD, "100MB_HD" },
+ { OFP_PORTMEDIA_100MB_FD, "100MB_FD" },
+ { OFP_PORTMEDIA_1GB_HD, "1GB_HD" },
+ { OFP_PORTMEDIA_1GB_FD, "1GB_FD" },
+ { OFP_PORTMEDIA_10GB_FD, "10GB_FD" },
+ { OFP_PORTMEDIA_COPPER, "COPPER" },
+ { OFP_PORTMEDIA_FIBER, "FIBER" },
+ { OFP_PORTMEDIA_AUTONEG, "AUTONEG" },
+ { OFP_PORTMEDIA_PAUSE, "PAUSE" },
+ { OFP_PORTMEDIA_PAUSE_ASYM, "PAUSE_ASYM" },
+ { 0 }
+};
+struct constmap ofp_pktin_reason_map[] = {
+ { OFP_PKTIN_REASON_NO_MATCH, "NO_MATCH" },
+ { OFP_PKTIN_REASON_ACTION, "ACTION" },
+ { OFP_PKTIN_REASON_TTL, "TTL" },
+ { 0 }
+};
+struct constmap ofp_swcap_map[] = {
+ { OFP_SWCAP_FLOW_STATS, "FLOW_STATS" },
+ { OFP_SWCAP_TABLE_STATS, "TABLE_STATS" },
+ { OFP_SWCAP_PORT_STATS, "PORT_STATS" },
+ { OFP_SWCAP_GROUP_STATS, "GROUP_STATS" },
+ { OFP_SWCAP_IP_REASM, "IP_REASM" },
+ { OFP_SWCAP_QUEUE_STATS, "QUEUE_STATS" },
+ { OFP_SWCAP_ARP_MATCH_IP, "ARP_MATCH_IP" },
+ { OFP_SWCAP_PORT_BLOCKED, "PORT_BLOCKED" },
+ { 0 }
+};
+struct constmap ofp_table_id_map[] = {
+ { OFP_TABLE_ID_MAX, "MAX" },
+ { OFP_TABLE_ID_ALL, "ALL" },
+ { 0 }
+};
+struct constmap ofp_match_map[] = {
+ { OFP_MATCH_STANDARD, "STANDARD" },
+ { OFP_MATCH_OXM, "OXM" },
+ { 0 }
+};
+struct constmap ofp_mp_t_map[] = {
+ { OFP_MP_T_DESC, "DESC" },
+ { OFP_MP_T_FLOW, "FLOW" },
+ { OFP_MP_T_AGGREGATE, "AGGREGATE" },
+ { OFP_MP_T_TABLE, "TABLE" },
+ { OFP_MP_T_PORT_STATS, "PORT_STATS" },
+ { OFP_MP_T_QUEUE, "QUEUE" },
+ { OFP_MP_T_GROUP, "GROUP" },
+ { OFP_MP_T_GROUP_DESC, "GROUP_DESC" },
+ { OFP_MP_T_GROUP_FEATURES, "GROUP_FEATURES" },
+ { OFP_MP_T_METER, "METER" },
+ { OFP_MP_T_METER_CONFIG, "METER_CONFIG" },
+ { OFP_MP_T_METER_FEATURES, "METER_FEATURES" },
+ { OFP_MP_T_TABLE_FEATURES, "TABLE_FEATURES" },
+ { OFP_MP_T_PORT_DESC, "PORT_DESC" },
+ { OFP_MP_T_EXPERIMENTER, "EXPERIMENTER" },
+ { 0 }
+};
+struct constmap ofp_action_map[] = {
+ { OFP_ACTION_OUTPUT, "OUTPUT" },
+ { OFP_ACTION_COPY_TTL_OUT, "COPY_TTL_OUT" },
+ { OFP_ACTION_COPY_TTL_IN, "COPY_TTL_IN" },
+ { OFP_ACTION_SET_MPLS_TTL, "SET_MPLS_TTL" },
+ { OFP_ACTION_DEC_MPLS_TTL, "DEC_MPLS_TTL" },
+ { OFP_ACTION_PUSH_VLAN, "PUSH_VLAN" },
+ { OFP_ACTION_POP_VLAN, "POP_VLAN" },
+ { OFP_ACTION_PUSH_MPLS, "PUSH_MPLS" },
+ { OFP_ACTION_POP_MPLS, "POP_MPLS" },
+ { OFP_ACTION_SET_QUEUE, "SET_QUEUE" },
+ { OFP_ACTION_GROUP, "GROUP" },
+ { OFP_ACTION_SET_NW_TTL, "SET_NW_TTL" },
+ { OFP_ACTION_DEC_NW_TTL, "DEC_NW_TTL" },
+ { OFP_ACTION_SET_FIELD, "SET_FIELD" },
+ { OFP_ACTION_PUSH_PBB, "PUSH_PBB" },
+ { OFP_ACTION_POP_PBB, "POP_PBB" },
+ { OFP_ACTION_EXPERIMENTER, "EXPERIMENTER" },
+ { 0 }
+};
+struct constmap ofp_flowcmd_map[] = {
+ { OFP_FLOWCMD_ADD, "ADD" },
+ { OFP_FLOWCMD_MODIFY, "MODIFY" },
+ { OFP_FLOWCMD_MODIFY_STRICT, "MODIFY_STRICT" },
+ { OFP_FLOWCMD_DELETE, "DELETE" },
+ { OFP_FLOWCMD_DELETE_STRICT, "DELETE_STRICT" },
+ { 0 }
+};
+struct constmap ofp_flowflag_map[] = {
+ { OFP_FLOWFLAG_SEND_FLOW_REMOVED, "SEND_FLOW_REMOVED" },
+ { OFP_FLOWFLAG_CHECK_OVERLAP, "CHECK_OVERLAP" },
+ { OFP_FLOWFLAG_RESET_COUNTS, "RESET_COUNTS" },
+ { OFP_FLOWFLAG_NO_PACKET_COUNTS, "NO_PACKET_COUNTS" },
+ { OFP_FLOWFLAG_NO_BYTE_COUNTS, "NO_BYTE_COUNTS" },
+ { 0 }
+};
+struct constmap ofp_flowrem_reason_map[] = {
+ { OFP_FLOWREM_REASON_IDLE_TIMEOUT, "IDLE_TIMEOUT" },
+ { OFP_FLOWREM_REASON_HARD_TIMEOUT, "HARD_TIMEOUT" },
+ { OFP_FLOWREM_REASON_DELETE, "DELETE" },
+ { OFP_FLOWREM_REASON_GROUP_DELETE, "GROUP_DELETE" },
+ { 0 }
+};
+struct constmap ofp_group_id_map[] = {
+ { OFP_GROUP_ID_MAX, "MAX" },
+ { OFP_GROUP_ID_ALL, "ALL" },
+ { OFP_GROUP_ID_ANY, "ANY" },
+ { 0 }
+};
+struct constmap ofp_errtype_map[] = {
+ { OFP_ERRTYPE_HELLO_FAILED, "HELLO_FAILED" },
+ { OFP_ERRTYPE_BAD_REQUEST, "BAD_REQUEST" },
+ { OFP_ERRTYPE_BAD_ACTION, "BAD_ACTION" },
+ { OFP_ERRTYPE_BAD_INSTRUCTION, "BAD_INSTRUCTION" },
+ { OFP_ERRTYPE_BAD_MATCH, "BAD_MATCH" },
+ { OFP_ERRTYPE_FLOW_MOD_FAILED, "FLOW_MOD_FAILED" },
+ { OFP_ERRTYPE_GROUP_MOD_FAILED, "GROUP_MOD_FAILED" },
+ { OFP_ERRTYPE_PORT_MOD_FAILED, "PORT_MOD_FAILED" },
+ { OFP_ERRTYPE_TABLE_MOD_FAILED, "TABLE_MOD_FAILED" },
+ { OFP_ERRTYPE_QUEUE_OP_FAILED, "QUEUE_OP_FAILED" },
+ { OFP_ERRTYPE_SWITCH_CFG_FAILED, "SWITCH_CFG_FAILED" },
+ { OFP_ERRTYPE_ROLE_REQUEST_FAILED, "ROLE_REQUEST_FAILED" },
+ { OFP_ERRTYPE_METER_MOD_FAILED, "METER_MOD_FAILED" },
+ { OFP_ERRTYPE_TABLE_FEATURES_FAILED, "TABLE_FEATURES_FAILED" },
+ { OFP_ERRTYPE_EXPERIMENTER, "EXPERIMENTER" },
+ { 0 }
+};
+struct constmap ofp_errflowmod_map[] = {
+ { OFP_ERRFLOWMOD_UNKNOWN, "UNKNOWN" },
+ { OFP_ERRFLOWMOD_ALL_TABLES_FULL, "ALL_TABLES_FULL" },
+ { OFP_ERRFLOWMOD_TABLE_ID, "TABLE_ID" },
+ { OFP_ERRFLOWMOD_OVERLAP, "OVERLAP" },
+ { OFP_ERRFLOWMOD_EPERM, "EPERM" },
+ { OFP_ERRFLOWMOD_BAD_TIMEOUT, "BAD_TIMEOUT" },
+ { OFP_ERRFLOWMOD_BAD_COMMAND, "BAD_COMMAND" },
+ { OFP_ERRFLOWMOD_BAD_FLAGS, "BAD_FLAGS" },
+ { 0 }
+};
+struct constmap ofp_errmatch_map[] = {
+ { OFP_ERRMATCH_BAD_TYPE, "BAD_TYPE" },
+ { OFP_ERRMATCH_BAD_LEN, "BAD_LEN" },
+ { OFP_ERRMATCH_BAD_TAG, "BAD_TAG" },
+ { OFP_ERRMATCH_BAD_DL_ADDR_MASK, "BAD_DL_ADDR_MASK" },
+ { OFP_ERRMATCH_BAD_NW_ADDR_MASK, "BAD_NW_ADDR_MASK" },
+ { OFP_ERRMATCH_BAD_WILDCARDS, "BAD_WILDCARDS" },
+ { OFP_ERRMATCH_BAD_FIELD, "BAD_FIELD" },
+ { OFP_ERRMATCH_BAD_VALUE, "BAD_VALUE" },
+ { OFP_ERRMATCH_BAD_MASK, "BAD_MASK" },
+ { OFP_ERRMATCH_BAD_PREREQ, "BAD_PREREQ" },
+ { OFP_ERRMATCH_DUP_FIELD, "DUP_FIELD" },
+ { OFP_ERRMATCH_EPERM, "EPERM" },
+ { 0 }
+};
+struct constmap ofp_errinst_map[] = {
+ { OFP_ERRINST_UNKNOWN_INST, "UNKNOWN_INST" },
+ { OFP_ERRINST_UNSUPPORTED_INST, "UNSUPPORTED_INST" },
+ { OFP_ERRINST_TABLE_ID, "TABLE_ID" },
+ { OFP_ERRINST_UNSUPP_META, "UNSUPP_META" },
+ { OFP_ERRINST_UNSUPP_META_MASK, "UNSUPP_META_MASK" },
+ { OFP_ERRINST_BAD_EXPERIMENTER, "BAD_EXPERIMENTER" },
+ { OFP_ERRINST_BAD_EXPERIMENTER_TYPE, "BAD_EXPERIMENTER_TYPE" },
+ { OFP_ERRINST_BAD_LEN, "BAD_LEN" },
+ { OFP_ERRINST_EPERM, "EPERM" },
+ { 0 }
+};
+struct constmap ofp_errreq_map[] = {
+ { OFP_ERRREQ_VERSION, "VERSION" },
+ { OFP_ERRREQ_TYPE, "TYPE" },
+ { OFP_ERRREQ_MULTIPART, "MULTIPART" },
+ { OFP_ERRREQ_EXPERIMENTER, "EXPERIMENTER" },
+ { OFP_ERRREQ_EXP_TYPE, "EXP_TYPE" },
+ { OFP_ERRREQ_EPERM, "EPERM" },
+ { OFP_ERRREQ_LEN, "LEN" },
+ { OFP_ERRREQ_BUFFER_EMPTY, "BUFFER_EMPTY" },
+ { OFP_ERRREQ_BUFFER_UNKNOWN, "BUFFER_UNKNOWN" },
+ { OFP_ERRREQ_TABLE_ID, "TABLE_ID" },
+ { OFP_ERRREQ_IS_SLAVE, "IS_SLAVE" },
+ { OFP_ERRREQ_PORT, "PORT" },
+ { OFP_ERRREQ_PACKET, "PACKET" },
+ { OFP_ERRREQ_MULTIPART_OVERFLOW, "MULTIPART_OVERFLOW" },
+ { 0 }
+};
+struct constmap ofp_table_featprop_map[] = {
+ { OFP_TABLE_FEATPROP_INSTRUCTION, "INSTRUCTION" },
+ { OFP_TABLE_FEATPROP_INSTRUCTION_MISS, "INSTRUCTION_MISS" },
+ { OFP_TABLE_FEATPROP_NEXT_TABLES, "NEXT_TABLES" },
+ { OFP_TABLE_FEATPROP_NEXT_TABLES_MISS, "NEXT_TABLES_MISS" },
+ { OFP_TABLE_FEATPROP_WRITE_ACTIONS, "WRITE_ACTIONS" },
+ { OFP_TABLE_FEATPROP_WRITE_ACTIONS_MISS, "WRITE_ACTIONS_MISS" },
+ { OFP_TABLE_FEATPROP_APPLY_ACTIONS, "APPLY_ACTIONS" },
+ { OFP_TABLE_FEATPROP_APPLY_ACTIONS_MISS, "APPLY_ACTIONS_MISS" },
+ { OFP_TABLE_FEATPROP_MATCH, "MATCH" },
+ { OFP_TABLE_FEATPROP_WILDCARDS, "WILDCARDS" },
+ { OFP_TABLE_FEATPROP_WRITE_SETFIELD, "WRITE_SETFIELD" },
+ { OFP_TABLE_FEATPROP_WRITE_SETFIELD_MISS, "WRITE_SETFIELD_MISS" },
+ { OFP_TABLE_FEATPROP_APPLY_SETFIELD, "APPLY_SETFIELD" },
+ { OFP_TABLE_FEATPROP_APPLY_SETFIELD_MISS, "APPLY_SETFIELD_MISS" },
+ { OFP_TABLE_FEATPROP_EXPERIMENTER, "EXPERIMENTER" },
+ { OFP_TABLE_FEATPROP_EXPERIMENTER_MISS, "EXPERIMENTER_MISS" },
+ { 0 }
+};
diff --git a/usr.sbin/tcpdump/ofp_map.h b/usr.sbin/tcpdump/ofp_map.h
new file mode 100644
index 00000000000..79469a785f6
--- /dev/null
+++ b/usr.sbin/tcpdump/ofp_map.h
@@ -0,0 +1,74 @@
+/* $OpenBSD: ofp_map.h,v 1.1 2016/11/18 17:37:03 reyk Exp $ */
+
+/*
+ * Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef OFP_MAP_H
+#define OFP_MAP_H
+
+struct constmap {
+ unsigned int cm_type;
+ const char *cm_name;
+ const char *cm_descr;
+};
+
+/*
+ * Each map is generated from lists of #define's in ofp.h, using the format:
+ * #define OFP_{MAPNAME}_FLAG {value} / * COMMENT * /
+ *
+ * Please make sure that the flags in ofp.h match this style (incl. comment)
+ */
+
+/* OpenFlow 1.0 maps */
+extern struct constmap ofp10_t_map[];
+extern struct constmap ofp10_port_map[];
+extern struct constmap ofp10_action_map[];
+extern struct constmap ofp10_wildcard_map[];
+extern struct constmap ofp10_errtype_map[];
+extern struct constmap ofp10_errflowmod_map[];
+
+/* OpenFlow 1.3+ maps */
+extern struct constmap ofp_v_map[];
+extern struct constmap ofp_t_map[];
+extern struct constmap ofp_pktin_map[];
+extern struct constmap ofp_port_map[];
+extern struct constmap ofp_pktout_map[];
+extern struct constmap ofp_oxm_c_map[];
+extern struct constmap ofp_xm_t_map[];
+extern struct constmap ofp_config_map[];
+extern struct constmap ofp_controller_maxlen_map[];
+extern struct constmap ofp_instruction_t_map[];
+extern struct constmap ofp_portstate_map[];
+extern struct constmap ofp_portconfig_map[];
+extern struct constmap ofp_portmedia_map[];
+extern struct constmap ofp_pktin_reason_map[];
+extern struct constmap ofp_swcap_map[];
+extern struct constmap ofp_table_id_map[];
+extern struct constmap ofp_match_map[];
+extern struct constmap ofp_mp_t_map[];
+extern struct constmap ofp_action_map[];
+extern struct constmap ofp_flowcmd_map[];
+extern struct constmap ofp_flowflag_map[];
+extern struct constmap ofp_flowrem_reason_map[];
+extern struct constmap ofp_group_id_map[];
+extern struct constmap ofp_errtype_map[];
+extern struct constmap ofp_errflowmod_map[];
+extern struct constmap ofp_errmatch_map[];
+extern struct constmap ofp_errinst_map[];
+extern struct constmap ofp_errreq_map[];
+extern struct constmap ofp_table_featprop_map[];
+
+#endif /* OFP_MAP_H */
diff --git a/usr.sbin/tcpdump/print-ofp.c b/usr.sbin/tcpdump/print-ofp.c
index ddb57c06d23..724f35767c2 100644
--- a/usr.sbin/tcpdump/print-ofp.c
+++ b/usr.sbin/tcpdump/print-ofp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-ofp.c,v 1.3 2016/11/16 13:47:27 reyk Exp $ */
+/* $OpenBSD: print-ofp.c,v 1.4 2016/11/18 17:37:03 reyk Exp $ */
/*
* Copyright (c) 2016 Rafael Zalamena <rzalamena@openbsd.org>
@@ -21,14 +21,19 @@
#include <endian.h>
#include <stddef.h>
#include <stdio.h>
+#include <string.h>
#include <pcap.h>
#include "extract.h"
#include "interface.h"
+#include "ofp_map.h"
/* Size of action header without the padding. */
#define AH_UNPADDED (offsetof(struct ofp_action_header, ah_pad))
+const char *
+ print_map(unsigned int, struct constmap *);
+
void ofp_print_hello(const u_char *, u_int, u_int);
void ofp_print_featuresreply(const u_char *, u_int);
void ofp_print_setconfig(const u_char *, u_int);
@@ -60,6 +65,36 @@ void instruction_print_meter(const char *, u_int);
void instruction_print_experimenter(const char *, u_int);
void ofp_print_instruction(struct ofp_instruction *, const char *, u_int);
+const char *
+print_map(unsigned int type, struct constmap *map)
+{
+ unsigned int i;
+#define CYCLE_BUFFERS 8
+ static char buf[CYCLE_BUFFERS][32];
+ static int idx = 0;
+ const char *name = NULL;
+
+ if (idx >= CYCLE_BUFFERS)
+ idx = 0;
+ memset(buf[idx], 0, sizeof(buf[idx]));
+
+ for (i = 0; map[i].cm_name != NULL; i++) {
+ if (map[i].cm_type == type) {
+ name = map[i].cm_name;
+ break;
+ }
+ }
+
+ if (name == NULL)
+ snprintf(buf[idx], sizeof(buf[idx]), "%u", type);
+ else if (vflag > 1)
+ snprintf(buf[idx], sizeof(buf[idx]), "%s[%u]", name, type);
+ else
+ strlcpy(buf[idx], name, sizeof(buf[idx]));
+
+ return (buf[idx++]);
+}
+
void
ofp_print_hello(const u_char *bp, u_int length, u_int ohlen)
{
@@ -72,12 +107,10 @@ ofp_print_hello(const u_char *bp, u_int length, u_int ohlen)
bp += sizeof(struct ofp_header);
length -= sizeof(struct ofp_header);
- printf(" HELLO");
-
/* Check for header truncation. */
if (ohlen > sizeof(struct ofp_header) &&
length < sizeof(*he)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -142,21 +175,21 @@ ofp_print_error(const u_char *bp, u_int length)
{
struct ofp_error *err;
- printf(" ERROR");
if (length < sizeof(*err)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
err = (struct ofp_error *)bp;
- printf(" <type %d code %d>", ntohs(err->err_type),
+ printf(" <type %s code %d>",
+ print_map(ntohs(err->err_type), ofp_errtype_map),
ntohs(err->err_code));
length -= min(sizeof(*err), length);
bp += sizeof(*err);
/* If there are still bytes left, print the optional error data. */
if (length) {
- printf(" error data:");
+ printf(" error data");
ofp_print(bp, length);
}
}
@@ -166,7 +199,6 @@ ofp_print_featuresreply(const u_char *bp, u_int length)
{
struct ofp_switch_features *swf;
- printf(" FEATURES REPLY");
if (length < sizeof(*swf)) {
printf(" [trucanted]");
return;
@@ -185,9 +217,8 @@ ofp_print_setconfig(const u_char *bp, u_int length)
{
struct ofp_switch_config *cfg;
- printf(" SET CONFIG");
if (length < sizeof(*cfg)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -205,20 +236,22 @@ ofp_print_packetin(const u_char *bp, u_int length)
int haspacket = 0;
const u_char *pktptr;
- printf(" PACKET-IN");
if (length < sizeof(*pin)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
pin = (struct ofp_packet_in *)bp;
omtype = ntohs(pin->pin_match.om_type);
omlen = ntohs(pin->pin_match.om_length);
- printf(" <buffer_id %u total_len %d reason %d table_id %d "
- "cookie %#016llx match type %d length %d>",
- ntohl(pin->pin_buffer_id), ntohs(pin->pin_total_len),
- pin->pin_reason, pin->pin_table_id, be64toh(pin->pin_cookie),
- omtype, omlen);
+ printf(" <buffer_id %s total_len %d reason %s table_id %s "
+ "cookie %#016llx match type %s length %d>",
+ print_map(ntohl(pin->pin_buffer_id), ofp_pktout_map),
+ ntohs(pin->pin_total_len),
+ print_map(pin->pin_reason, ofp_pktin_reason_map),
+ print_map(pin->pin_table_id, ofp_table_id_map),
+ be64toh(pin->pin_cookie),
+ print_map(omtype, ofp_match_map), omlen);
if (pin->pin_buffer_id == OFP_PKTOUT_NO_BUFFER)
haspacket = 1;
@@ -241,7 +274,7 @@ ofp_print_packetin(const u_char *bp, u_int length)
parse_next_oxm:
if (length < sizeof(*oxm)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -249,7 +282,7 @@ ofp_print_packetin(const u_char *bp, u_int length)
bp += sizeof(*oxm);
length -= sizeof(*oxm);
if (length < oxm->oxm_length) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -288,23 +321,24 @@ ofp_print_flowremoved(const u_char *bp, u_int length)
struct ofp_ox_match *oxm;
int omtype, omlen;
- printf(" FLOW REMOVED");
if (length < sizeof(*fr)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
fr = (struct ofp_flow_removed *)bp;
omtype = ntohs(fr->fr_match.om_type);
omlen = ntohs(fr->fr_match.om_length);
- printf(" <cookie %#016llx priority %d reason %d table_id %d "
+ printf(" <cookie %#016llx priority %d reason %s table_id %s "
"duration sec %u nsec %u timeout idle %d hard %d "
- "packet count %llu byte count %llu match type %d length %d>",
- be64toh(fr->fr_cookie), ntohs(fr->fr_priority), fr->fr_reason,
- fr->fr_table_id, ntohl(fr->fr_duration_sec),
- ntohl(fr->fr_duration_nsec), ntohs(fr->fr_idle_timeout),
- ntohs(fr->fr_hard_timeout), be64toh(fr->fr_packet_count),
- be64toh(fr->fr_byte_count), omtype, omlen);
+ "packet count %llu byte count %llu match type %s length %d>",
+ be64toh(fr->fr_cookie), ntohs(fr->fr_priority),
+ print_map(fr->fr_reason, ofp_flowrem_reason_map),
+ print_map(fr->fr_table_id, ofp_table_id_map),
+ ntohl(fr->fr_duration_sec), ntohl(fr->fr_duration_nsec),
+ ntohs(fr->fr_idle_timeout), ntohs(fr->fr_hard_timeout),
+ be64toh(fr->fr_packet_count), be64toh(fr->fr_byte_count),
+ print_map(omtype, ofp_match_map), omlen);
/* We only support OXM. */
if (omtype != OFP_MATCH_OXM)
@@ -319,7 +353,7 @@ ofp_print_flowremoved(const u_char *bp, u_int length)
parse_next_oxm:
if (length < sizeof(*oxm)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -327,7 +361,7 @@ ofp_print_flowremoved(const u_char *bp, u_int length)
bp += sizeof(*oxm);
length -= sizeof(*oxm);
if (length < oxm->oxm_length) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -349,16 +383,16 @@ ofp_print_packetout(const u_char *bp, u_int length)
int actionslen, haspacket = 0;
int ahlen;
- printf(" PACKET-OUT");
if (length < sizeof(*pout)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
pout = (struct ofp_packet_out *)bp;
actionslen = ntohs(pout->pout_actions_len);
- printf(" <buffer_id %u in_port %u actions_len %d>",
- ntohl(pout->pout_buffer_id), ntohl(pout->pout_in_port),
+ printf(" <buffer_id %s in_port %s actions_len %d>",
+ print_map(ntohl(pout->pout_buffer_id), ofp_pktout_map),
+ print_map(ntohl(pout->pout_in_port), ofp_port_map),
actionslen);
if (pout->pout_buffer_id == OFP_PKTOUT_NO_BUFFER)
@@ -374,7 +408,7 @@ ofp_print_packetout(const u_char *bp, u_int length)
parse_next_action:
if (length < sizeof(*ah)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -384,7 +418,7 @@ ofp_print_packetout(const u_char *bp, u_int length)
actionslen -= AH_UNPADDED;
ahlen = ntohs(ah->ah_len) - AH_UNPADDED;
if (length < ahlen) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -420,23 +454,27 @@ ofp_print_flowmod(const u_char *bp, u_int length)
int omtype, omlen, ilen;
int instructionslen, padsize;
- printf(" FLOW-MOD");
if (length < sizeof(*fm)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
fm = (struct ofp_flow_mod *)bp;
omtype = ntohs(fm->fm_match.om_type);
omlen = ntohs(fm->fm_match.om_length);
- printf(" <cookie %llu cookie_mask %#016llx table_id %d command %d "
- "timeout idle %d hard %d priority %d buffer_id %u out_port %u "
- "out_group %u flags %#04x match type %d length %d>",
+ printf(" <cookie %llu cookie_mask %#016llx table_id %s command %s "
+ "timeout idle %d hard %d priority %d buffer_id %s out_port %s "
+ "out_group %s flags %#04x match type %s length %d>",
be64toh(fm->fm_cookie), be64toh(fm->fm_cookie_mask),
- fm->fm_table_id, fm->fm_command, ntohs(fm->fm_idle_timeout),
- ntohs(fm->fm_hard_timeout), fm->fm_priority,
- ntohl(fm->fm_buffer_id), ntohl(fm->fm_out_port),
- ntohl(fm->fm_out_group), ntohs(fm->fm_flags), omtype, omlen);
+ print_map(fm->fm_table_id, ofp_table_id_map),
+ print_map(fm->fm_command, ofp_flowcmd_map),
+ ntohs(fm->fm_idle_timeout), ntohs(fm->fm_hard_timeout),
+ fm->fm_priority,
+ print_map(ntohl(fm->fm_buffer_id), ofp_pktout_map),
+ print_map(ntohl(fm->fm_out_port), ofp_port_map),
+ print_map(ntohl(fm->fm_out_group), ofp_group_id_map),
+ ntohs(fm->fm_flags),
+ print_map(omtype, ofp_match_map), omlen);
bp += sizeof(*fm);
length -= sizeof(*fm);
@@ -458,7 +496,7 @@ ofp_print_flowmod(const u_char *bp, u_int length)
parse_next_oxm:
if (length < sizeof(*oxm)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -466,7 +504,7 @@ ofp_print_flowmod(const u_char *bp, u_int length)
bp += sizeof(*oxm);
length -= sizeof(*oxm);
if (length < oxm->oxm_length) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -486,7 +524,7 @@ ofp_print_flowmod(const u_char *bp, u_int length)
parse_next_instruction:
if (length < sizeof(*i)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -496,7 +534,7 @@ parse_next_instruction:
instructionslen -= sizeof(*i);
ilen = ntohs(i->i_len) - sizeof(*i);
if (length < ilen) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -558,8 +596,10 @@ ofp_print(const u_char *bp, u_int length)
oh = (struct ofp_header *)bp;
ohlen = ntohs(oh->oh_length);
- printf(": OpenFlow(ver %#02x type %d len %d xid %u)",
- oh->oh_version, oh->oh_type, ohlen, ntohl(oh->oh_xid));
+
+ printf(": OpenFlow %s type %u length %u xid %u",
+ print_map(oh->oh_version, ofp_v_map),
+ oh->oh_type, ntohs(oh->oh_length), ntohl(oh->oh_xid));
switch (oh->oh_version) {
case OFP_V_1_3:
@@ -569,6 +609,8 @@ ofp_print(const u_char *bp, u_int length)
return;
}
+ printf(": %s", print_map(oh->oh_type, ofp_t_map));
+
switch (oh->oh_type) {
case OFP_T_HELLO:
ofp_print_hello(bp, length, ohlen);
@@ -577,13 +619,9 @@ ofp_print(const u_char *bp, u_int length)
ofp_print_error(bp, length);
break;
case OFP_T_ECHO_REQUEST:
- printf(" ECHO REQUEST");
- break;
case OFP_T_ECHO_REPLY:
- printf(" ECHO REPLY");
break;
case OFP_T_FEATURES_REQUEST:
- printf(" FEATURES REQUEST");
break;
case OFP_T_FEATURES_REPLY:
ofp_print_featuresreply(bp, length);
@@ -612,7 +650,7 @@ oxm_print_byte(const u_char *bp, u_int length, int hasmask, int hex)
uint8_t *b;
if (length < sizeof(*b)) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -636,7 +674,7 @@ oxm_print_halfword(const u_char *bp, u_int length, int hasmask, int hex)
uint16_t *h;
if (length < sizeof(*h)) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -660,7 +698,7 @@ oxm_print_word(const u_char *bp, u_int length, int hasmask, int hex)
uint32_t *w;
if (length < sizeof(*w)) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -684,7 +722,7 @@ oxm_print_quad(const u_char *bp, u_int length, int hasmask, int hex)
uint64_t *q;
if (length < sizeof(*q)) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -710,7 +748,7 @@ oxm_print_ether(const u_char *bp, u_int length, int hasmask)
char hex[8];
if (length < ETHER_HDR_LEN) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -739,7 +777,7 @@ oxm_print_data(const u_char *bp, u_int length, int hasmask, size_t datalen)
char hex[8];
if (length < datalen) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
return;
}
@@ -767,8 +805,9 @@ ofp_print_oxm(struct ofp_ox_match *oxm, const u_char *bp, u_int length)
field = OFP_OXM_GET_FIELD(oxm);
mask = OFP_OXM_GET_HASMASK(oxm);
len = oxm->oxm_length;
- printf(" OXM <class %d field %d hasmask %d length %d",
- class, field, mask, len);
+ printf(" oxm <class %s field %s hasmask %d length %d",
+ print_map(class, ofp_oxm_c_map),
+ print_map(field, ofp_xm_t_map), mask, len);
switch (class) {
case OFP_OXM_C_OPENFLOW_BASIC:
@@ -815,7 +854,7 @@ ofp_print_oxm(struct ofp_ox_match *oxm, const u_char *bp, u_int length)
* the presence of the VLAN.
*/
if (length < sizeof(*vlan)) {
- printf("[truncated]");
+ printf("[|OpenFlow]");
break;
}
@@ -885,13 +924,14 @@ action_print_output(const u_char *bp, u_int length)
struct ofp_action_output *ao;
if (length < (sizeof(*ao) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
ao = (struct ofp_action_output *)(bp - AH_UNPADDED);
- printf(" port %u max_len %d",
- ntohl(ao->ao_port), ntohs(ao->ao_max_len));
+ printf(" port %s max_len %s",
+ print_map(ntohl(ao->ao_port), ofp_port_map),
+ print_map(ntohs(ao->ao_max_len), ofp_controller_maxlen_map));
}
void
@@ -900,12 +940,13 @@ action_print_group(const u_char *bp, u_int length)
struct ofp_action_group *ag;
if (length < (sizeof(*ag) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
ag = (struct ofp_action_group *)(bp - AH_UNPADDED);
- printf(" group_id %u", ntohl(ag->ag_group_id));
+ printf(" group_id %s",
+ print_map(ntohl(ag->ag_group_id), ofp_group_id_map));
}
void
@@ -914,7 +955,7 @@ action_print_setmplsttl(const u_char *bp, u_int length)
struct ofp_action_mpls_ttl *amt;
if (length < (sizeof(*amt) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -928,7 +969,7 @@ action_print_setnwttl(const u_char *bp, u_int length)
struct ofp_action_nw_ttl *ant;
if (length < (sizeof(*ant) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -942,7 +983,7 @@ action_print_push(const u_char *bp, u_int length)
struct ofp_action_push *ap;
if (length < (sizeof(*ap) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -956,7 +997,7 @@ action_print_popmpls(const u_char *bp, u_int length)
struct ofp_action_pop_mpls *apm;
if (length < (sizeof(*apm) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -972,7 +1013,7 @@ action_print_setfield(const u_char *bp, u_int length)
int omlen;
if (length < (sizeof(*asf) - AH_UNPADDED)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -983,7 +1024,7 @@ action_print_setfield(const u_char *bp, u_int length)
parse_next_oxm:
if (length < sizeof(*oxm)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -991,7 +1032,7 @@ action_print_setfield(const u_char *bp, u_int length)
bp += sizeof(*oxm);
length -= sizeof(*oxm);
if (length < oxm->oxm_length) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1010,7 +1051,8 @@ ofp_print_action(struct ofp_action_header *ah, const u_char *bp, u_int length)
int ahtype;
ahtype = ntohs(ah->ah_type);
- printf(" ACTION <type %d length %d", ahtype, ntohs(ah->ah_len));
+ printf(" action <type %s length %d",
+ print_map(ahtype, ofp_action_map), ntohs(ah->ah_len));
switch (ahtype) {
case OFP_ACTION_OUTPUT:
@@ -1067,7 +1109,7 @@ instruction_print_gototable(const char *bp, u_int length)
struct ofp_instruction_goto_table *igt;
if (length < (sizeof(*igt) - sizeof(struct ofp_instruction))) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1082,7 +1124,7 @@ instruction_print_meta(const char *bp, u_int length)
struct ofp_instruction_write_metadata *iwm;
if (length < (sizeof(*iwm) - sizeof(struct ofp_instruction))) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1101,7 +1143,7 @@ instruction_print_actions(const char *bp, u_int length)
unsigned int ahlen;
if (length < (sizeof(*ia) - sizeof(struct ofp_instruction))) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1117,7 +1159,7 @@ instruction_print_actions(const char *bp, u_int length)
parse_next_action:
if (length < sizeof(*ah)) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1127,7 +1169,7 @@ parse_next_action:
actionslen -= AH_UNPADDED;
ahlen = ntohs(ah->ah_len) - AH_UNPADDED;
if (length < ahlen) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1146,7 +1188,7 @@ instruction_print_meter(const char *bp, u_int length)
struct ofp_instruction_meter *im;
if (length < (sizeof(*im) - sizeof(struct ofp_instruction))) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1161,7 +1203,7 @@ instruction_print_experimenter(const char *bp, u_int length)
struct ofp_instruction_experimenter *ie;
if (length < (sizeof(*ie) - sizeof(struct ofp_instruction))) {
- printf(" [truncated]");
+ printf(" [|OpenFlow]");
return;
}
@@ -1176,7 +1218,8 @@ ofp_print_instruction(struct ofp_instruction *i, const char *bp, u_int length)
int itype;
itype = ntohs(i->i_type);
- printf(" INSTRUCTION <type %d length %d", itype, ntohs(i->i_len));
+ printf(" instruction <type %s length %d",
+ print_map(itype, ofp_instruction_t_map), ntohs(i->i_len));
switch (itype) {
case OFP_INSTRUCTION_T_GOTO_TABLE: