From: Denis Ovsienko Date: Wed, 30 Sep 2020 13:49:38 +0000 (+0100) Subject: OpenFlow 1.3: Implement OFPT_FEATURES_REPLY. X-Git-Tag: tcpdump-4.99-bp~170 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/7c72cdb22c46f935e10ca3a1b015225a2fe828e3 OpenFlow 1.3: Implement OFPT_FEATURES_REPLY. --- diff --git a/print-openflow-1.3.c b/print-openflow-1.3.c index b4f7e354..34e4b873 100644 --- a/print-openflow-1.3.c +++ b/print-openflow-1.3.c @@ -108,6 +108,27 @@ 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 OFPHET_VERSIONBITMAP 1U static const struct tok ofphet_str[] = { { OFPHET_VERSIONBITMAP, "VERSIONBITMAP" }, @@ -474,6 +495,7 @@ static const struct tok ofptffc_str[] = { /* 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_QUEUE_GET_CONFIG_REQUEST_FIXLEN 16U /* [OF13] Section A.1 */ @@ -483,6 +505,33 @@ of13_msgtype_str(const uint8_t type) return tok2str(ofpt_str, "invalid (0x%02x)", type); } +/* [OF13] Section 7.3.1 */ +static void +of13_features_reply_print(netdissect_options *ndo, + const u_char *cp, u_int len) +{ + /* datapath_id */ + ND_PRINT("\n\t dpid 0x%016" PRIx64, GET_BE_U_8(cp)); + OF_FWD(8); + /* n_buffers */ + ND_PRINT(", n_buffers %u", GET_BE_U_4(cp)); + OF_FWD(4); + /* n_tables */ + ND_PRINT(", n_tables %u", GET_U_1(cp)); + OF_FWD(1); + /* auxiliary_id */ + ND_PRINT(", auxiliary_id %u", GET_U_1(cp)); + OF_FWD(1); + /* pad */ + OF_FWD(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); + OF_FWD(4); + /* reserved */ + ND_TCHECK_4(cp); +} + /* [OF13] Section 7.5.1 */ static void of13_hello_elements_print(netdissect_options *ndo, @@ -592,6 +641,13 @@ of13_message_print(netdissect_options *ndo, 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, len); + 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; diff --git a/tests/of13_ericsson-v.out b/tests/of13_ericsson-v.out index 27e70228..b022be4d 100644 --- a/tests/of13_ericsson-v.out +++ b/tests/of13_ericsson-v.out @@ -140,6 +140,8 @@ 51 15:47:18.962238 IP (tos 0x0, ttl 64, id 51478, offset 0, flags [DF], proto TCP (6), length 84) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe48 (incorrect -> 0xbbc3), seq 698:730, ack 657, win 86, options [nop,nop,TS val 267876 ecr 267876], length 32: OpenFlow version 1.3, type FEATURES_REPLY, length 32, xid 0x0000008e + dpid 0x000026a2b46fd9ba, n_buffers 256, n_tables 64, auxiliary_id 0 + capabilities 0x0000004f (FLOW_STATS, TABLE_STATS, PORT_STATS, GROUP_STATS, QUEUE_STATS) 52 15:47:18.962333 IP (tos 0x0, ttl 64, id 14609, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [.], cksum 0xfe28 (incorrect -> 0xb693), ack 730, win 94, options [nop,nop,TS val 267876 ecr 267876], length 0 53 16:32:34.623939 IP (tos 0x0, ttl 64, id 44797, offset 0, flags [DF], proto TCP (6), length 60) diff --git a/tests/of13_ericsson-vv.out b/tests/of13_ericsson-vv.out index 6bc54a93..ef6c4846 100644 --- a/tests/of13_ericsson-vv.out +++ b/tests/of13_ericsson-vv.out @@ -183,6 +183,8 @@ 51 15:47:18.962238 IP (tos 0x0, ttl 64, id 51478, offset 0, flags [DF], proto TCP (6), length 84) 127.0.0.1.58445 > 127.0.0.1.6633: Flags [P.], cksum 0xfe48 (incorrect -> 0xbbc3), seq 698:730, ack 657, win 86, options [nop,nop,TS val 267876 ecr 267876], length 32: OpenFlow version 1.3, type FEATURES_REPLY, length 32, xid 0x0000008e + dpid 0x000026a2b46fd9ba, n_buffers 256, n_tables 64, auxiliary_id 0 + capabilities 0x0000004f (FLOW_STATS, TABLE_STATS, PORT_STATS, GROUP_STATS, QUEUE_STATS) 52 15:47:18.962333 IP (tos 0x0, ttl 64, id 14609, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.6633 > 127.0.0.1.58445: Flags [.], cksum 0xfe28 (incorrect -> 0xb693), seq 657, ack 730, win 94, options [nop,nop,TS val 267876 ecr 267876], length 0 53 16:32:34.623939 IP (tos 0x0, ttl 64, id 44797, offset 0, flags [DF], proto TCP (6), length 60)