2 * This module implements decoding of OpenFlow protocol version 1.3 (wire
3 * protocol 0x04). It is based on the implementation conventions explained in
4 * print-openflow-1.0.c.
6 * [OF13] https://www.opennetworking.org/wp-content/uploads/2014/10/openflow-switch-v1.3.4.pdf
8 * Copyright (c) 2020 The TCPDUMP project
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
34 /* \summary: OpenFlow protocol version 1.3 printer */
40 #include "netdissect-stdinc.h"
42 #define ND_LONGJMP_FROM_TCHECK
43 #include "netdissect.h"
45 #include "addrtoname.h"
50 #define OFPT_ECHO_REQUEST 2U
51 #define OFPT_ECHO_REPLY 3U
52 #define OFPT_EXPERIMENTER 4U
53 #define OFPT_FEATURES_REQUEST 5U
54 #define OFPT_FEATURES_REPLY 6U
55 #define OFPT_GET_CONFIG_REQUEST 7U
56 #define OFPT_GET_CONFIG_REPLY 8U
57 #define OFPT_SET_CONFIG 9U
58 #define OFPT_PACKET_IN 10U
59 #define OFPT_FLOW_REMOVED 11U
60 #define OFPT_PORT_STATUS 12U
61 #define OFPT_PACKET_OUT 13U
62 #define OFPT_FLOW_MOD 14U
63 #define OFPT_GROUP_MOD 15U
64 #define OFPT_PORT_MOD 16U
65 #define OFPT_TABLE_MOD 17U
66 #define OFPT_MULTIPART_REQUEST 18U
67 #define OFPT_MULTIPART_REPLY 19U
68 #define OFPT_BARRIER_REQUEST 20U
69 #define OFPT_BARRIER_REPLY 21U
70 #define OFPT_QUEUE_GET_CONFIG_REQUEST 22U
71 #define OFPT_QUEUE_GET_CONFIG_REPLY 23U
72 #define OFPT_ROLE_REQUEST 24U
73 #define OFPT_ROLE_REPLY 25U
74 #define OFPT_GET_ASYNC_REQUEST 26U
75 #define OFPT_GET_ASYNC_REPLY 27U
76 #define OFPT_SET_ASYNC 28U
77 #define OFPT_METER_MOD 29U
78 static const struct tok ofpt_str
[] = {
79 { OFPT_HELLO
, "HELLO" },
80 { OFPT_ERROR
, "ERROR" },
81 { OFPT_ECHO_REQUEST
, "ECHO_REQUEST" },
82 { OFPT_ECHO_REPLY
, "ECHO_REPLY" },
83 { OFPT_EXPERIMENTER
, "EXPERIMENTER" },
84 { OFPT_FEATURES_REQUEST
, "FEATURES_REQUEST" },
85 { OFPT_FEATURES_REPLY
, "FEATURES_REPLY" },
86 { OFPT_GET_CONFIG_REQUEST
, "GET_CONFIG_REQUEST" },
87 { OFPT_GET_CONFIG_REPLY
, "GET_CONFIG_REPLY" },
88 { OFPT_SET_CONFIG
, "SET_CONFIG" },
89 { OFPT_PACKET_IN
, "PACKET_IN" },
90 { OFPT_FLOW_REMOVED
, "FLOW_REMOVED" },
91 { OFPT_PORT_STATUS
, "PORT_STATUS" },
92 { OFPT_PACKET_OUT
, "PACKET_OUT" },
93 { OFPT_FLOW_MOD
, "FLOW_MOD" },
94 { OFPT_GROUP_MOD
, "GROUP_MOD" },
95 { OFPT_PORT_MOD
, "PORT_MOD" },
96 { OFPT_TABLE_MOD
, "TABLE_MOD" },
97 { OFPT_MULTIPART_REQUEST
, "MULTIPART_REQUEST" },
98 { OFPT_MULTIPART_REPLY
, "MULTIPART_REPLY" },
99 { OFPT_BARRIER_REQUEST
, "BARRIER_REQUEST" },
100 { OFPT_BARRIER_REPLY
, "BARRIER_REPLY" },
101 { OFPT_QUEUE_GET_CONFIG_REQUEST
, "QUEUE_GET_CONFIG_REQUEST" },
102 { OFPT_QUEUE_GET_CONFIG_REPLY
, "QUEUE_GET_CONFIG_REPLY" },
103 { OFPT_ROLE_REQUEST
, "ROLE_REQUEST" },
104 { OFPT_ROLE_REPLY
, "ROLE_REPLY" },
105 { OFPT_GET_ASYNC_REQUEST
, "GET_ASYNC_REQUEST" },
106 { OFPT_GET_ASYNC_REPLY
, "GET_ASYNC_REPLY" },
107 { OFPT_SET_ASYNC
, "SET_ASYNC" },
108 { OFPT_METER_MOD
, "METER_MOD" },
112 #define OFPC_FLOW_STATS (1U <<0)
113 #define OFPC_TABLE_STATS (1U <<1)
114 #define OFPC_PORT_STATS (1U <<2)
115 #define OFPC_GROUP_STATS (1U <<3)
116 #define OFPC_IP_REASM (1U <<5)
117 #define OFPC_QUEUE_STATS (1U <<6)
118 #define OFPC_PORT_BLOCKED (1U <<8)
119 static const struct tok ofp_capabilities_bm
[] = {
120 { OFPC_FLOW_STATS
, "FLOW_STATS" },
121 { OFPC_TABLE_STATS
, "TABLE_STATS" },
122 { OFPC_PORT_STATS
, "PORT_STATS" },
123 { OFPC_GROUP_STATS
, "GROUP_STATS" },
124 { OFPC_IP_REASM
, "IP_REASM" },
125 { OFPC_QUEUE_STATS
, "QUEUE_STATS" },
126 { OFPC_PORT_BLOCKED
, "PORT_BLOCKED" },
129 #define OFPCAP_U (~(OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | \
130 OFPC_GROUP_STATS | OFPC_IP_REASM | OFPC_QUEUE_STATS | \
133 #define OFPC_FRAG_NORMAL 0U
134 #define OFPC_FRAG_DROP 1U
135 #define OFPC_FRAG_REASM 2U
136 static const struct tok ofp_config_str
[] = {
137 { OFPC_FRAG_NORMAL
, "FRAG_NORMAL" },
138 { OFPC_FRAG_DROP
, "FRAG_DROP" },
139 { OFPC_FRAG_REASM
, "FRAG_REASM" },
143 #define OFPTT_MAX 0xfeU
144 #define OFPTT_ALL 0xffU
145 static const struct tok ofptt_str
[] = {
146 { OFPTT_MAX
, "MAX" },
147 { OFPTT_ALL
, "ALL" },
151 #define OFPCML_MAX 0xffe5U
152 #define OFPCML_NO_BUFFER 0xffffU
153 static const struct tok ofpcml_str
[] = {
154 { OFPCML_MAX
, "MAX" },
155 { OFPCML_NO_BUFFER
, "NO_BUFFER" },
159 #define OFPPC_PORT_DOWN (1U <<0)
160 #define OFPPC_NO_RECV (1U <<2)
161 #define OFPPC_NO_FWD (1U <<5)
162 #define OFPPC_NO_PACKET_IN (1U <<6)
163 static const struct tok ofppc_bm
[] = {
164 { OFPPC_PORT_DOWN
, "PORT_DOWN" },
165 { OFPPC_NO_RECV
, "NO_RECV" },
166 { OFPPC_NO_FWD
, "NO_FWD" },
167 { OFPPC_NO_PACKET_IN
, "NO_PACKET_IN" },
170 #define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_RECV | OFPPC_NO_FWD | \
173 #define OFPPS_LINK_DOWN (1U << 0)
174 #define OFPPS_BLOCKED (1U << 1)
175 #define OFPPS_LIVE (1U << 2)
176 static const struct tok ofpps_bm
[] = {
177 { OFPPS_LINK_DOWN
, "LINK_DOWN" },
178 { OFPPS_BLOCKED
, "BLOCKED" },
179 { OFPPS_LIVE
, "LIVE" },
182 #define OFPPS_U (~(OFPPS_LINK_DOWN | OFPPS_BLOCKED | OFPPS_LIVE))
184 #define OFPPF_10MB_HD (1U << 0)
185 #define OFPPF_10MB_FD (1U << 1)
186 #define OFPPF_100MB_HD (1U << 2)
187 #define OFPPF_100MB_FD (1U << 3)
188 #define OFPPF_1GB_HD (1U << 4)
189 #define OFPPF_1GB_FD (1U << 5)
190 #define OFPPF_10GB_FD (1U << 6)
191 #define OFPPF_40GB_FD (1U << 7)
192 #define OFPPF_100GB_FD (1U << 8)
193 #define OFPPF_1TB_FD (1U << 9)
194 #define OFPPF_OTHER (1U << 10)
195 #define OFPPF_COPPER (1U << 11)
196 #define OFPPF_FIBER (1U << 12)
197 #define OFPPF_AUTONEG (1U << 13)
198 #define OFPPF_PAUSE (1U << 14)
199 #define OFPPF_PAUSE_ASYM (1U << 15)
200 static const struct tok ofppf_bm
[] = {
201 { OFPPF_10MB_HD
, "10MB_HD" },
202 { OFPPF_10MB_FD
, "10MB_FD" },
203 { OFPPF_100MB_HD
, "100MB_HD" },
204 { OFPPF_100MB_FD
, "100MB_FD" },
205 { OFPPF_1GB_HD
, "1GB_HD" },
206 { OFPPF_1GB_FD
, "1GB_FD" },
207 { OFPPF_10GB_FD
, "10GB_FD" },
208 { OFPPF_40GB_FD
, "40GB_FD" },
209 { OFPPF_100GB_FD
, "100GB_FD" },
210 { OFPPF_1TB_FD
, "1TB_FD" },
211 { OFPPF_OTHER
, "OTHER" },
212 { OFPPF_COPPER
, "COPPER" },
213 { OFPPF_FIBER
, "FIBER" },
214 { OFPPF_AUTONEG
, "AUTONEG" },
215 { OFPPF_PAUSE
, "PAUSE" },
216 { OFPPF_PAUSE_ASYM
, "PAUSE_ASYM" },
219 #define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \
220 OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \
221 OFPPF_10GB_FD | OFPPF_40GB_FD | OFPPF_100GB_FD | \
222 OFPPF_1TB_FD | OFPPF_OTHER | OFPPF_COPPER | OFPPF_FIBER | \
223 OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM))
225 #define OFPHET_VERSIONBITMAP 1U
226 static const struct tok ofphet_str
[] = {
227 { OFPHET_VERSIONBITMAP
, "VERSIONBITMAP" },
231 #define OFPP_MAX 0xffffff00U
232 #define OFPP_IN_PORT 0xfffffff8U
233 #define OFPP_TABLE 0xfffffff9U
234 #define OFPP_NORMAL 0xfffffffaU
235 #define OFPP_FLOOD 0xfffffffbU
236 #define OFPP_ALL 0xfffffffcU
237 #define OFPP_CONTROLLER 0xfffffffdU
238 #define OFPP_LOCAL 0xfffffffeU
239 #define OFPP_ANY 0xffffffffU
240 static const struct tok ofpp_str
[] = {
242 { OFPP_IN_PORT
, "IN_PORT" },
243 { OFPP_TABLE
, "TABLE" },
244 { OFPP_NORMAL
, "NORMAL" },
245 { OFPP_FLOOD
, "FLOOD" },
247 { OFPP_CONTROLLER
, "CONTROLLER" },
248 { OFPP_LOCAL
, "LOCAL" },
253 #define OFPCR_ROLE_NOCHANGE 0U
254 #define OFPCR_ROLE_EQUAL 1U
255 #define OFPCR_ROLE_MASTER 2U
256 #define OFPCR_ROLE_SLAVE 3U
257 static const struct tok ofpcr_str
[] = {
258 { OFPCR_ROLE_NOCHANGE
, "NOCHANGE" },
259 { OFPCR_ROLE_EQUAL
, "EQUAL" },
260 { OFPCR_ROLE_MASTER
, "MASTER" },
261 { OFPCR_ROLE_SLAVE
, "SLAVE" },
265 #define OF_BIT_VER_1_0 (1U << (OF_VER_1_0 - 1))
266 #define OF_BIT_VER_1_1 (1U << (OF_VER_1_1 - 1))
267 #define OF_BIT_VER_1_2 (1U << (OF_VER_1_2 - 1))
268 #define OF_BIT_VER_1_3 (1U << (OF_VER_1_3 - 1))
269 #define OF_BIT_VER_1_4 (1U << (OF_VER_1_4 - 1))
270 #define OF_BIT_VER_1_5 (1U << (OF_VER_1_5 - 1))
271 static const struct tok ofverbm_str
[] = {
272 { OF_BIT_VER_1_0
, "1.0" },
273 { OF_BIT_VER_1_1
, "1.1" },
274 { OF_BIT_VER_1_2
, "1.2" },
275 { OF_BIT_VER_1_3
, "1.3" },
276 { OF_BIT_VER_1_4
, "1.4" },
277 { OF_BIT_VER_1_5
, "1.5" },
280 #define OF_BIT_VER_U (~(OF_BIT_VER_1_0 | OF_BIT_VER_1_1 | OF_BIT_VER_1_2 | \
281 OF_BIT_VER_1_3 | OF_BIT_VER_1_4 | OF_BIT_VER_1_5))
283 #define OFPR_NO_MATCH 0U
284 #define OFPR_ACTION 1U
285 #define OFPR_INVALID_TTL 2U
286 #if 0 /* for OFPT_PACKET_IN */
287 static const struct tok ofpr_str
[] = {
288 { OFPR_NO_MATCH
, "NO_MATCH" },
289 { OFPR_ACTION
, "ACTION" },
290 { OFPR_INVALID_TTL
, "OFPR_INVALID_TTL" },
295 #define ASYNC_OFPR_NO_MATCH (1U << OFPR_NO_MATCH )
296 #define ASYNC_OFPR_ACTION (1U << OFPR_ACTION )
297 #define ASYNC_OFPR_INVALID_TTL (1U << OFPR_INVALID_TTL)
298 static const struct tok async_ofpr_bm
[] = {
299 { ASYNC_OFPR_NO_MATCH
, "NO_MATCH" },
300 { ASYNC_OFPR_ACTION
, "ACTION" },
301 { ASYNC_OFPR_INVALID_TTL
, "INVALID_TTL" },
304 #define ASYNC_OFPR_U (~(ASYNC_OFPR_NO_MATCH | ASYNC_OFPR_ACTION | \
305 ASYNC_OFPR_INVALID_TTL))
308 #define OFPPR_DELETE 1U
309 #define OFPPR_MODIFY 2U
310 static const struct tok ofppr_str
[] = {
311 { OFPPR_ADD
, "ADD" },
312 { OFPPR_DELETE
, "DELETE" },
313 { OFPPR_MODIFY
, "MODIFY" },
317 #define ASYNC_OFPPR_ADD (1U << OFPPR_ADD )
318 #define ASYNC_OFPPR_DELETE (1U << OFPPR_DELETE)
319 #define ASYNC_OFPPR_MODIFY (1U << OFPPR_MODIFY)
320 static const struct tok async_ofppr_bm
[] = {
321 { ASYNC_OFPPR_ADD
, "ADD" },
322 { ASYNC_OFPPR_DELETE
, "DELETE" },
323 { ASYNC_OFPPR_MODIFY
, "MODIFY" },
326 #define ASYNC_OFPPR_U (~(ASYNC_OFPPR_ADD | ASYNC_OFPPR_DELETE | \
329 #define OFPET_HELLO_FAILED 0U
330 #define OFPET_BAD_REQUEST 1U
331 #define OFPET_BAD_ACTION 2U
332 #define OFPET_BAD_INSTRUCTION 3U
333 #define OFPET_BAD_MATCH 4U
334 #define OFPET_FLOW_MOD_FAILED 5U
335 #define OFPET_GROUP_MOD_FAILED 6U
336 #define OFPET_PORT_MOD_FAILED 7U
337 #define OFPET_TABLE_MOD_FAILED 8U
338 #define OFPET_QUEUE_OP_FAILED 9U
339 #define OFPET_SWITCH_CONFIG_FAILED 10U
340 #define OFPET_ROLE_REQUEST_FAILED 11U
341 #define OFPET_METER_MOD_FAILED 12U
342 #define OFPET_TABLE_FEATURES_FAILED 13U
343 #define OFPET_EXPERIMENTER 0xffffU /* a special case */
344 static const struct tok ofpet_str
[] = {
345 { OFPET_HELLO_FAILED
, "HELLO_FAILED" },
346 { OFPET_BAD_REQUEST
, "BAD_REQUEST" },
347 { OFPET_BAD_ACTION
, "BAD_ACTION" },
348 { OFPET_BAD_INSTRUCTION
, "BAD_INSTRUCTION" },
349 { OFPET_BAD_MATCH
, "BAD_MATCH" },
350 { OFPET_FLOW_MOD_FAILED
, "FLOW_MOD_FAILED" },
351 { OFPET_GROUP_MOD_FAILED
, "GROUP_MOD_FAILED" },
352 { OFPET_PORT_MOD_FAILED
, "PORT_MOD_FAILED" },
353 { OFPET_TABLE_MOD_FAILED
, "TABLE_MOD_FAILED" },
354 { OFPET_QUEUE_OP_FAILED
, "QUEUE_OP_FAILED" },
355 { OFPET_SWITCH_CONFIG_FAILED
, "SWITCH_CONFIG_FAILED" },
356 { OFPET_ROLE_REQUEST_FAILED
, "ROLE_REQUEST_FAILED" },
357 { OFPET_METER_MOD_FAILED
, "METER_MOD_FAILED" },
358 { OFPET_TABLE_FEATURES_FAILED
, "TABLE_FEATURES_FAILED" },
359 { OFPET_EXPERIMENTER
, "EXPERIMENTER" },
363 #define OFPHFC_INCOMPATIBLE 0U
364 #define OFPHFC_EPERM 1U
365 static const struct tok ofphfc_str
[] = {
366 { OFPHFC_INCOMPATIBLE
, "INCOMPATIBLE" },
367 { OFPHFC_EPERM
, "EPERM" },
371 #define OFPBRC_BAD_VERSION 0U
372 #define OFPBRC_BAD_TYPE 1U
373 #define OFPBRC_BAD_MULTIPART 2U
374 #define OFPBRC_BAD_EXPERIMENTER 3U
375 #define OFPBRC_BAD_EXP_TYPE 4U
376 #define OFPBRC_EPERM 5U
377 #define OFPBRC_BAD_LEN 6U
378 #define OFPBRC_BUFFER_EMPTY 7U
379 #define OFPBRC_BUFFER_UNKNOWN 8U
380 #define OFPBRC_BAD_TABLE_ID 9U
381 #define OFPBRC_IS_SLAVE 10U
382 #define OFPBRC_BAD_PORT 11U
383 #define OFPBRC_BAD_PACKET 12U
384 #define OFPBRC_MULTIPART_BUFFER_OVERFLOW 13U
385 static const struct tok ofpbrc_str
[] = {
386 { OFPBRC_BAD_VERSION
, "BAD_VERSION" },
387 { OFPBRC_BAD_TYPE
, "BAD_TYPE" },
388 { OFPBRC_BAD_MULTIPART
, "BAD_MULTIPART" },
389 { OFPBRC_BAD_EXPERIMENTER
, "BAD_EXPERIMENTER" },
390 { OFPBRC_BAD_EXP_TYPE
, "BAD_EXP_TYPE" },
391 { OFPBRC_EPERM
, "EPERM" },
392 { OFPBRC_BAD_LEN
, "BAD_LEN" },
393 { OFPBRC_BUFFER_EMPTY
, "BUFFER_EMPTY" },
394 { OFPBRC_BUFFER_UNKNOWN
, "BUFFER_UNKNOWN" },
395 { OFPBRC_BAD_TABLE_ID
, "BAD_TABLE_ID" },
396 { OFPBRC_IS_SLAVE
, "IS_SLAVE" },
397 { OFPBRC_BAD_PORT
, "BAD_PORT" },
398 { OFPBRC_BAD_PACKET
, "BAD_PACKET" },
399 { OFPBRC_MULTIPART_BUFFER_OVERFLOW
, "MULTIPART_BUFFER_OVERFLOW" },
403 #define OFPBAC_BAD_TYPE 0U
404 #define OFPBAC_BAD_LEN 1U
405 #define OFPBAC_BAD_EXPERIMENTER 2U
406 #define OFPBAC_BAD_EXP_TYPE 3U
407 #define OFPBAC_BAD_OUT_PORT 4U
408 #define OFPBAC_BAD_ARGUMENT 5U
409 #define OFPBAC_EPERM 6U
410 #define OFPBAC_TOO_MANY 7U
411 #define OFPBAC_BAD_QUEUE 8U
412 #define OFPBAC_BAD_OUT_GROUP 9U
413 #define OFPBAC_MATCH_INCONSISTENT 10U
414 #define OFPBAC_UNSUPPORTED_ORDER 11U
415 #define OFPBAC_BAD_TAG 12U
416 #define OFPBAC_BAD_SET_TYPE 13U
417 #define OFPBAC_BAD_SET_LEN 14U
418 #define OFPBAC_BAD_SET_ARGUMENT 15U
419 static const struct tok ofpbac_str
[] = {
420 { OFPBAC_BAD_TYPE
, "BAD_TYPE" },
421 { OFPBAC_BAD_LEN
, "BAD_LEN" },
422 { OFPBAC_BAD_EXPERIMENTER
, "BAD_EXPERIMENTER" },
423 { OFPBAC_BAD_EXP_TYPE
, "BAD_EXP_TYPE" },
424 { OFPBAC_BAD_OUT_PORT
, "BAD_OUT_PORT" },
425 { OFPBAC_BAD_ARGUMENT
, "BAD_ARGUMENT" },
426 { OFPBAC_EPERM
, "EPERM" },
427 { OFPBAC_TOO_MANY
, "TOO_MANY" },
428 { OFPBAC_BAD_QUEUE
, "BAD_QUEUE" },
429 { OFPBAC_BAD_OUT_GROUP
, "BAD_OUT_GROUP" },
430 { OFPBAC_MATCH_INCONSISTENT
, "MATCH_INCONSISTENT" },
431 { OFPBAC_UNSUPPORTED_ORDER
, "UNSUPPORTED_ORDER" },
432 { OFPBAC_BAD_TAG
, "BAD_TAG" },
433 { OFPBAC_BAD_SET_TYPE
, "BAD_SET_TYPE" },
434 { OFPBAC_BAD_SET_LEN
, "BAD_SET_LEN" },
435 { OFPBAC_BAD_SET_ARGUMENT
, "BAD_SET_ARGUMENT" },
439 #define OFPBIC_UNKNOWN_INST 0U
440 #define OFPBIC_UNSUP_INST 1U
441 #define OFPBIC_BAD_TABLE_ID 2U
442 #define OFPBIC_UNSUP_METADATA 3U
443 #define OFPBIC_UNSUP_METADATA_MASK 4U
444 #define OFPBIC_BAD_EXPERIMENTER 5U
445 #define OFPBIC_BAD_EXP_TYPE 6U
446 #define OFPBIC_BAD_LEN 7U
447 #define OFPBIC_EPERM 8U
448 static const struct tok ofpbic_str
[] = {
449 { OFPBIC_UNKNOWN_INST
, "UNKNOWN_INST" },
450 { OFPBIC_UNSUP_INST
, "UNSUP_INST" },
451 { OFPBIC_BAD_TABLE_ID
, "BAD_TABLE_ID" },
452 { OFPBIC_UNSUP_METADATA
, "UNSUP_METADATA" },
453 { OFPBIC_UNSUP_METADATA_MASK
, "UNSUP_METADATA_MASK" },
454 { OFPBIC_BAD_EXPERIMENTER
, "BAD_EXPERIMENTER" },
455 { OFPBIC_BAD_EXP_TYPE
, "BAD_EXP_TYPE" },
456 { OFPBIC_BAD_LEN
, "BAD_LEN" },
457 { OFPBIC_EPERM
, "EPERM" },
461 #define OFPBMC_BAD_TYPE 0U
462 #define OFPBMC_BAD_LEN 1U
463 #define OFPBMC_BAD_TAG 2U
464 #define OFPBMC_BAD_DL_ADDR_MASK 3U
465 #define OFPBMC_BAD_NW_ADDR_MASK 4U
466 #define OFPBMC_BAD_WILDCARDS 5U
467 #define OFPBMC_BAD_FIELD 6U
468 #define OFPBMC_BAD_VALUE 7U
469 #define OFPBMC_BAD_MASK 8U
470 #define OFPBMC_BAD_PREREQ 9U
471 #define OFPBMC_DUP_FIELD 10U
472 #define OFPBMC_EPERM 11U
473 static const struct tok ofpbmc_str
[] = {
474 { OFPBMC_BAD_TYPE
, "BAD_TYPE" },
475 { OFPBMC_BAD_LEN
, "BAD_LEN" },
476 { OFPBMC_BAD_TAG
, "BAD_TAG" },
477 { OFPBMC_BAD_DL_ADDR_MASK
, "BAD_DL_ADDR_MASK" },
478 { OFPBMC_BAD_NW_ADDR_MASK
, "BAD_NW_ADDR_MASK" },
479 { OFPBMC_BAD_WILDCARDS
, "BAD_WILDCARDS" },
480 { OFPBMC_BAD_FIELD
, "BAD_FIELD" },
481 { OFPBMC_BAD_VALUE
, "BAD_VALUE" },
482 { OFPBMC_BAD_MASK
, "BAD_MASK" },
483 { OFPBMC_BAD_PREREQ
, "BAD_PREREQ" },
484 { OFPBMC_DUP_FIELD
, "DUP_FIELD" },
485 { OFPBMC_EPERM
, "EPERM" },
489 #define OFPFMFC_UNKNOWN 0U
490 #define OFPFMFC_TABLE_FULL 1U
491 #define OFPFMFC_BAD_TABLE_ID 2U
492 #define OFPFMFC_OVERLAP 3U
493 #define OFPFMFC_EPERM 4U
494 #define OFPFMFC_BAD_TIMEOUT 5U
495 #define OFPFMFC_BAD_COMMAND 6U
496 #define OFPFMFC_BAD_FLAGS 7U
497 static const struct tok ofpfmfc_str
[] = {
498 { OFPFMFC_UNKNOWN
, "UNKNOWN" },
499 { OFPFMFC_TABLE_FULL
, "TABLE_FULL" },
500 { OFPFMFC_BAD_TABLE_ID
, "BAD_TABLE_ID" },
501 { OFPFMFC_OVERLAP
, "OVERLAP" },
502 { OFPFMFC_EPERM
, "EPERM" },
503 { OFPFMFC_BAD_TIMEOUT
, "BAD_TIMEOUT" },
504 { OFPFMFC_BAD_COMMAND
, "BAD_COMMAND" },
505 { OFPFMFC_BAD_FLAGS
, "BAD_FLAGS" },
509 #define OFPGMFC_GROUP_EXISTS 0U
510 #define OFPGMFC_INVALID_GROUP 1U
511 #define OFPGMFC_WEIGHT_UNSUPPORTED 2U
512 #define OFPGMFC_OUT_OF_GROUPS 3U
513 #define OFPGMFC_OUT_OF_BUCKETS 4U
514 #define OFPGMFC_CHAINING_UNSUPPORTED 5U
515 #define OFPGMFC_WATCH_UNSUPPORTED 6U
516 #define OFPGMFC_LOOP 7U
517 #define OFPGMFC_UNKNOWN_GROUP 8U
518 #define OFPGMFC_CHAINED_GROUP 9U
519 #define OFPGMFC_BAD_TYPE 10U
520 #define OFPGMFC_BAD_COMMAND 11U
521 #define OFPGMFC_BAD_BUCKET 12U
522 #define OFPGMFC_BAD_MATCH 13U
523 #define OFPGMFC_EPERM 14U
524 static const struct tok ofpgmfc_str
[] = {
525 { OFPGMFC_GROUP_EXISTS
, "GROUP_EXISTS" },
526 { OFPGMFC_INVALID_GROUP
, "INVALID_GROUP" },
527 { OFPGMFC_WEIGHT_UNSUPPORTED
, "WEIGHT_UNSUPPORTED" },
528 { OFPGMFC_OUT_OF_GROUPS
, "OUT_OF_GROUPS" },
529 { OFPGMFC_OUT_OF_BUCKETS
, "OUT_OF_BUCKETS" },
530 { OFPGMFC_CHAINING_UNSUPPORTED
, "CHAINING_UNSUPPORTED" },
531 { OFPGMFC_WATCH_UNSUPPORTED
, "WATCH_UNSUPPORTED" },
532 { OFPGMFC_LOOP
, "LOOP" },
533 { OFPGMFC_UNKNOWN_GROUP
, "UNKNOWN_GROUP" },
534 { OFPGMFC_CHAINED_GROUP
, "CHAINED_GROUP" },
535 { OFPGMFC_BAD_TYPE
, "BAD_TYPE" },
536 { OFPGMFC_BAD_COMMAND
, "BAD_COMMAND" },
537 { OFPGMFC_BAD_BUCKET
, "BAD_BUCKET" },
538 { OFPGMFC_BAD_MATCH
, "BAD_MATCH" },
539 { OFPGMFC_EPERM
, "EPERM" },
543 #define OFPPMFC_BAD_PORT 0U
544 #define OFPPMFC_BAD_HW_ADDR 1U
545 #define OFPPMFC_BAD_CONFIG 2U
546 #define OFPPMFC_BAD_ADVERTISE 3U
547 #define OFPPMFC_EPERM 4U
548 static const struct tok ofppmfc_str
[] = {
549 { OFPPMFC_BAD_PORT
, "BAD_PORT" },
550 { OFPPMFC_BAD_HW_ADDR
, "BAD_HW_ADDR" },
551 { OFPPMFC_BAD_CONFIG
, "BAD_CONFIG" },
552 { OFPPMFC_BAD_ADVERTISE
, "BAD_ADVERTISE" },
553 { OFPPMFC_EPERM
, "EPERM" },
557 #define OFPTMFC_BAD_TABLE 0U
558 #define OFPTMFC_BAD_CONFIG 1U
559 #define OFPTMFC_EPERM 2U
560 static const struct tok ofptmfc_str
[] = {
561 { OFPTMFC_BAD_TABLE
, "BAD_TABLE" },
562 { OFPTMFC_BAD_CONFIG
, "BAD_CONFIG" },
563 { OFPTMFC_EPERM
, "EPERM" },
567 #define OFPQOFC_BAD_PORT 0U
568 #define OFPQOFC_BAD_QUEUE 1U
569 #define OFPQOFC_EPERM 2U
570 static const struct tok ofpqofc_str
[] = {
571 { OFPQOFC_BAD_PORT
, "BAD_PORT" },
572 { OFPQOFC_BAD_QUEUE
, "BAD_QUEUE" },
573 { OFPQOFC_EPERM
, "EPERM" },
577 #define OFPSCFC_BAD_FLAGS 0U
578 #define OFPSCFC_BAD_LEN 1U
579 #define OFPSCFC_EPERM 2U
580 static const struct tok ofpscfc_str
[] = {
581 { OFPSCFC_BAD_FLAGS
, "BAD_FLAGS" },
582 { OFPSCFC_BAD_LEN
, "BAD_LEN" },
583 { OFPSCFC_EPERM
, "EPERM" },
587 #define OFPRRFC_STALE 0U
588 #define OFPRRFC_UNSUP 1U
589 #define OFPRRFC_BAD_ROLE 2U
590 static const struct tok ofprrfc_str
[] = {
591 { OFPRRFC_STALE
, "STALE" },
592 { OFPRRFC_UNSUP
, "UNSUP" },
593 { OFPRRFC_BAD_ROLE
, "BAD_ROLE" },
597 #define OFPMMFC_UNKNOWN 0U
598 #define OFPMMFC_METER_EXISTS 1U
599 #define OFPMMFC_INVALID_METER 2U
600 #define OFPMMFC_UNKNOWN_METER 3U
601 #define OFPMMFC_BAD_COMMAND 4U
602 #define OFPMMFC_BAD_FLAGS 5U
603 #define OFPMMFC_BAD_RATE 6U
604 #define OFPMMFC_BAD_BURST 7U
605 #define OFPMMFC_BAD_BAND 8U
606 #define OFPMMFC_BAD_BAND_VALUE 9U
607 #define OFPMMFC_OUT_OF_METERS 10U
608 #define OFPMMFC_OUT_OF_BANDS 11U
609 static const struct tok ofpmmfc_str
[] = {
610 { OFPMMFC_UNKNOWN
, "UNKNOWN" },
611 { OFPMMFC_METER_EXISTS
, "METER_EXISTS" },
612 { OFPMMFC_INVALID_METER
, "INVALID_METER" },
613 { OFPMMFC_UNKNOWN_METER
, "UNKNOWN_METER" },
614 { OFPMMFC_BAD_COMMAND
, "BAD_COMMAND" },
615 { OFPMMFC_BAD_FLAGS
, "BAD_FLAGS" },
616 { OFPMMFC_BAD_RATE
, "BAD_RATE" },
617 { OFPMMFC_BAD_BURST
, "BAD_BURST" },
618 { OFPMMFC_BAD_BAND
, "BAD_BAND" },
619 { OFPMMFC_BAD_BAND_VALUE
, "BAD_BAND_VALUE" },
620 { OFPMMFC_OUT_OF_METERS
, "OUT_OF_METERS" },
621 { OFPMMFC_OUT_OF_BANDS
, "OUT_OF_BANDS" },
625 #define OFPTFFC_BAD_TABLE 0U
626 #define OFPTFFC_BAD_METADATA 1U
627 #define OFPTFFC_BAD_TYPE 2U
628 #define OFPTFFC_BAD_LEN 3U
629 #define OFPTFFC_BAD_ARGUMENT 4U
630 #define OFPTFFC_EPERM 5U
631 static const struct tok ofptffc_str
[] = {
632 { OFPTFFC_BAD_TABLE
, "BAD_TABLE" },
633 { OFPTFFC_BAD_METADATA
, "BAD_METADATA" },
634 { OFPTFFC_BAD_TYPE
, "BAD_TYPE" },
635 { OFPTFFC_BAD_LEN
, "BAD_LEN" },
636 { OFPTFFC_BAD_ARGUMENT
, "BAD_ARGUMENT" },
637 { OFPTFFC_EPERM
, "EPERM" },
641 static const struct uint_tokary of13_ofpet2tokary
[] = {
642 { OFPET_HELLO_FAILED
, ofphfc_str
},
643 { OFPET_BAD_REQUEST
, ofpbrc_str
},
644 { OFPET_BAD_ACTION
, ofpbac_str
},
645 { OFPET_BAD_INSTRUCTION
, ofpbic_str
},
646 { OFPET_BAD_MATCH
, ofpbmc_str
},
647 { OFPET_FLOW_MOD_FAILED
, ofpfmfc_str
},
648 { OFPET_GROUP_MOD_FAILED
, ofpgmfc_str
},
649 { OFPET_PORT_MOD_FAILED
, ofppmfc_str
},
650 { OFPET_TABLE_MOD_FAILED
, ofptmfc_str
},
651 { OFPET_QUEUE_OP_FAILED
, ofpqofc_str
},
652 { OFPET_SWITCH_CONFIG_FAILED
, ofpscfc_str
},
653 { OFPET_ROLE_REQUEST_FAILED
, ofprrfc_str
},
654 { OFPET_METER_MOD_FAILED
, ofpmmfc_str
},
655 { OFPET_TABLE_FEATURES_FAILED
, ofptffc_str
},
656 { OFPET_EXPERIMENTER
, NULL
}, /* defines no codes */
657 /* uint2tokary() does not use array termination. */
660 /* lengths (fixed or minimal) of particular message types, where not 0 */
661 #define OF_ERROR_MSG_MINLEN (12U - OF_HEADER_FIXLEN)
662 #define OF_FEATURES_REPLY_FIXLEN (32U - OF_HEADER_FIXLEN)
663 #define OF_PORT_MOD_FIXLEN (40U - OF_HEADER_FIXLEN)
664 #define OF_SWITCH_CONFIG_MSG_FIXLEN (12U - OF_HEADER_FIXLEN)
665 #define OF_TABLE_MOD_FIXLEN (16U - OF_HEADER_FIXLEN)
666 #define OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN (16U - OF_HEADER_FIXLEN)
667 #define OF_ROLE_MSG_FIXLEN (24U - OF_HEADER_FIXLEN)
668 #define OF_ASYNC_MSG_FIXLEN (32U - OF_HEADER_FIXLEN)
669 #define OF_PORT_STATUS_FIXLEN (80U - OF_HEADER_FIXLEN)
670 #define OF_EXPERIMENTER_MSG_MINLEN (16U - OF_HEADER_FIXLEN)
672 /* lengths (fixed or minimal) of particular protocol structures */
673 #define OF_HELLO_ELEM_MINSIZE 4U
675 /* miscellaneous constants from [OF13] */
676 #define OFP_MAX_PORT_NAME_LEN 16U
678 /* [OF13] Section A.1 */
680 of13_msgtype_str(const uint8_t type
)
682 return tok2str(ofpt_str
, "invalid (0x%02x)", type
);
685 /* [OF13] Section 7.2.1 */
687 of13_port_print(netdissect_options
*ndo
,
691 ND_PRINT("\n\t port_no %s",
692 tok2str(ofpp_str
, "%u", GET_BE_U_4(cp
)));
697 ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp
));
702 ND_PRINT(", name '");
703 (void)nd_print(ndo
, cp
, cp
+ OFP_MAX_PORT_NAME_LEN
);
705 cp
+= OFP_MAX_PORT_NAME_LEN
;
707 if (ndo
->ndo_vflag
< 2) {
708 ND_TCHECK_LEN(cp
, 32);
713 ND_PRINT("\n\t config 0x%08x", GET_BE_U_4(cp
));
714 of_bitmap_print(ndo
, ofppc_bm
, GET_BE_U_4(cp
), OFPPC_U
);
717 ND_PRINT("\n\t state 0x%08x", GET_BE_U_4(cp
));
718 of_bitmap_print(ndo
, ofpps_bm
, GET_BE_U_4(cp
), OFPPS_U
);;
721 ND_PRINT("\n\t curr 0x%08x", GET_BE_U_4(cp
));
722 of_bitmap_print(ndo
, ofppf_bm
, GET_BE_U_4(cp
), OFPPF_U
);
725 ND_PRINT("\n\t advertised 0x%08x", GET_BE_U_4(cp
));
726 of_bitmap_print(ndo
, ofppf_bm
, GET_BE_U_4(cp
), OFPPF_U
);
729 ND_PRINT("\n\t supported 0x%08x", GET_BE_U_4(cp
));
730 of_bitmap_print(ndo
, ofppf_bm
, GET_BE_U_4(cp
), OFPPF_U
);
733 ND_PRINT("\n\t peer 0x%08x", GET_BE_U_4(cp
));
734 of_bitmap_print(ndo
, ofppf_bm
, GET_BE_U_4(cp
), OFPPF_U
);
737 ND_PRINT("\n\t curr_speed %ukbps", GET_BE_U_4(cp
));
740 ND_PRINT("\n\t max_speed %ukbps", GET_BE_U_4(cp
));
743 /* [OF13] Section 7.3.1 */
745 of13_features_reply_print(netdissect_options
*ndo
,
749 ND_PRINT("\n\t dpid 0x%016" PRIx64
, GET_BE_U_8(cp
));
752 ND_PRINT(", n_buffers %u", GET_BE_U_4(cp
));
755 ND_PRINT(", n_tables %u", GET_U_1(cp
));
758 ND_PRINT(", auxiliary_id %u", GET_U_1(cp
));
763 ND_PRINT("\n\t capabilities 0x%08x", GET_BE_U_4(cp
));
764 of_bitmap_print(ndo
, ofp_capabilities_bm
, GET_BE_U_4(cp
), OFPCAP_U
);
770 /* [OF13] Section 7.3.2 */
772 of13_switch_config_msg_print(netdissect_options
*ndo
,
776 ND_PRINT("\n\t flags %s",
777 tok2str(ofp_config_str
, "invalid (0x%04x)", GET_BE_U_2(cp
)));
780 ND_PRINT(", miss_send_len %s",
781 tok2str(ofpcml_str
, "%u", GET_BE_U_2(cp
)));
784 /* [OF13] Section 7.3.3 */
786 of13_table_mod_print(netdissect_options
*ndo
,
790 ND_PRINT("\n\t table_id %s", tok2str(ofptt_str
, "%u", GET_U_1(cp
)));
795 ND_PRINT(", config 0x%08x", GET_BE_U_4(cp
));
798 /* [OF13] Section 7.3.9 */
800 of13_role_msg_print(netdissect_options
*ndo
,
804 ND_PRINT("\n\t role %s",
805 tok2str(ofpcr_str
, "invalid (0x%08x)", GET_BE_U_4(cp
)));
810 ND_PRINT(", generation_id 0x%016" PRIx64
, GET_BE_U_8(cp
));
813 /* [OF13] Section 7.3.10 */
815 of13_async_msg_print(netdissect_options
*ndo
,
818 /* packet_in_mask[0] */
819 ND_PRINT("\n\t packet_in_mask[EM] 0x%08x", GET_BE_U_4(cp
));
820 of_bitmap_print(ndo
, async_ofpr_bm
, GET_BE_U_4(cp
), ASYNC_OFPR_U
);
822 /* packet_in_mask[1] */
823 ND_PRINT("\n\t packet_in_mask[S] 0x%08x", GET_BE_U_4(cp
));
824 of_bitmap_print(ndo
, async_ofpr_bm
, GET_BE_U_4(cp
), ASYNC_OFPR_U
);
826 /* port_status_mask[0] */
827 ND_PRINT("\n\t port_status_mask[EM] 0x%08x", GET_BE_U_4(cp
));
828 of_bitmap_print(ndo
, async_ofppr_bm
, GET_BE_U_4(cp
), ASYNC_OFPPR_U
);
830 /* port_status_mask[1] */
831 ND_PRINT("\n\t port_status_mask[S] 0x%08x", GET_BE_U_4(cp
));
832 of_bitmap_print(ndo
, async_ofppr_bm
, GET_BE_U_4(cp
), ASYNC_OFPPR_U
);
834 /* flow_removed_mask[0] */
835 ND_PRINT("\n\t flow_removed_mask[EM] 0x%08x", GET_BE_U_4(cp
));
836 of_bitmap_print(ndo
, async_ofppr_bm
, GET_BE_U_4(cp
), ASYNC_OFPPR_U
);
838 /* flow_removed_mask[1] */
839 ND_PRINT("\n\t flow_removed_mask[S] 0x%08x", GET_BE_U_4(cp
));
840 of_bitmap_print(ndo
, async_ofppr_bm
, GET_BE_U_4(cp
), ASYNC_OFPPR_U
);
843 /* [OF13] Section 7.3.4.3 */
845 of13_port_mod_print(netdissect_options
*ndo
,
849 ND_PRINT("\n\t port_no %s", tok2str(ofpp_str
, "%u", GET_BE_U_4(cp
)));
854 ND_PRINT(", hw_addr %s", GET_ETHERADDR_STRING(cp
));
859 ND_PRINT("\n\t config 0x%08x", GET_BE_U_4(cp
));
860 of_bitmap_print(ndo
, ofppc_bm
, GET_BE_U_4(cp
), OFPPC_U
);
863 ND_PRINT("\n\t mask 0x%08x", GET_BE_U_4(cp
));
864 of_bitmap_print(ndo
, ofppc_bm
, GET_BE_U_4(cp
), OFPPC_U
);
867 ND_PRINT("\n\t advertise 0x%08x", GET_BE_U_4(cp
));
868 of_bitmap_print(ndo
, ofppf_bm
, GET_BE_U_4(cp
), OFPPF_U
);
871 /* Always the last field, check bounds. */
875 /* [OF13] Section 7.4.3 */
877 of13_port_status_print(netdissect_options
*ndo
,
881 ND_PRINT("\n\t reason %s",
882 tok2str(ofppr_str
, "invalid (0x02x)", GET_U_1(cp
)));
887 of13_port_print(ndo
, cp
);
890 /* [OF13] Section 7.5.1 */
892 of13_hello_elements_print(netdissect_options
*ndo
,
893 const u_char
*cp
, u_int len
)
896 uint16_t type
, bmlen
;
898 if (len
< OF_HELLO_ELEM_MINSIZE
)
901 type
= GET_BE_U_2(cp
);
903 ND_PRINT("\n\t type %s",
904 tok2str(ofphet_str
, "unknown (0x%04x)", type
));
906 bmlen
= GET_BE_U_2(cp
);
908 ND_PRINT(", length %u", bmlen
);
909 /* cp is OF_HELLO_ELEM_MINSIZE bytes in */
910 if (bmlen
< OF_HELLO_ELEM_MINSIZE
||
911 bmlen
> OF_HELLO_ELEM_MINSIZE
+ len
)
914 case OFPHET_VERSIONBITMAP
:
916 * The specification obviously overprovisions the space
917 * for version bitmaps in this element ("ofp versions
918 * 32 to 63 are encoded in the second bitmap and so
919 * on"). Keep this code simple for now and recognize
920 * only a single bitmap with no padding.
922 if (bmlen
== OF_HELLO_ELEM_MINSIZE
+ 4) {
923 uint32_t bitmap
= GET_BE_U_4(cp
);
924 ND_PRINT(", bitmap 0x%08x", bitmap
);
925 of_bitmap_print(ndo
, ofverbm_str
, bitmap
,
928 ND_PRINT(" (bogus)");
929 ND_TCHECK_LEN(cp
, bmlen
- OF_HELLO_ELEM_MINSIZE
);
933 ND_TCHECK_LEN(cp
, bmlen
- OF_HELLO_ELEM_MINSIZE
);
935 OF_FWD(bmlen
- OF_HELLO_ELEM_MINSIZE
);
940 nd_print_invalid(ndo
);
941 ND_TCHECK_LEN(cp
, len
);
944 /* [OF13] Section 7.5.4 */
946 of13_experimenter_message_print(netdissect_options
*ndo
,
947 const u_char
*cp
, u_int len
)
949 uint32_t experimenter
;
952 experimenter
= GET_BE_U_4(cp
);
954 ND_PRINT("\n\t experimenter 0x%08x (%s)", experimenter
,
955 of_vendor_name(experimenter
));
957 ND_PRINT(", exp_type 0x%08x", GET_BE_U_4(cp
));
960 of_data_print(ndo
, cp
, len
);
963 /* [OF13] Section A.3.6 */
965 of13_queue_get_config_request_print(netdissect_options
*ndo
,
969 ND_PRINT("\n\t port %s", tok2str(ofpp_str
, "%u", GET_BE_U_4(cp
)));
972 /* Always the last field, check bounds. */
976 /* [OF13] Section A.4.4 */
978 of13_error_print(netdissect_options
*ndo
,
979 const u_char
*cp
, u_int len
)
982 const struct tok
*code_str
;
985 type
= GET_BE_U_2(cp
);
987 ND_PRINT("\n\t type %s", tok2str(ofpet_str
, "invalid (0x%04x)", type
));
989 code
= GET_BE_U_2(cp
);
991 code_str
= uint2tokary(of13_ofpet2tokary
, type
);
992 if (code_str
!= NULL
)
993 ND_PRINT(", code %s",
994 tok2str(code_str
, "invalid (0x%04x)", code
));
996 ND_PRINT(", code invalid (0x%04x)", code
);
998 of_data_print(ndo
, cp
, len
);
1002 of13_message_print(netdissect_options
*ndo
,
1003 const u_char
*cp
, uint16_t len
, const uint8_t type
)
1005 /* See the comment at the beginning of of10_message_print(). */
1007 /* OpenFlow header only. */
1008 case OFPT_FEATURES_REQUEST
: /* [OF13] Section A.3.1 */
1009 case OFPT_GET_CONFIG_REQUEST
: /* [OF13] Section A.3.2 */
1010 case OFPT_BARRIER_REQUEST
: /* [OF13] Section A.3.8 */
1011 case OFPT_BARRIER_REPLY
: /* ibid */
1012 case OFPT_GET_ASYNC_REQUEST
: /* [OF13] Section 7.3.10 */
1017 /* OpenFlow header and fixed-size message body. */
1018 case OFPT_FEATURES_REPLY
:
1019 if (len
!= OF_FEATURES_REPLY_FIXLEN
)
1021 if (ndo
->ndo_vflag
< 1)
1023 of13_features_reply_print(ndo
, cp
);
1025 case OFPT_QUEUE_GET_CONFIG_REQUEST
: /* [OF13] Section A.3.6 */
1026 if (len
!= OF_QUEUE_GET_CONFIG_REQUEST_FIXLEN
)
1028 if (ndo
->ndo_vflag
< 1)
1030 of13_queue_get_config_request_print(ndo
, cp
);
1032 case OFPT_GET_CONFIG_REPLY
: /* [OF13] Section 7.3.2 */
1033 case OFPT_SET_CONFIG
: /* ibid */
1034 if (len
!= OF_SWITCH_CONFIG_MSG_FIXLEN
)
1036 if (ndo
->ndo_vflag
< 1)
1038 of13_switch_config_msg_print(ndo
, cp
);
1040 case OFPT_PORT_MOD
: /* [OF13] Section 7.3.4.3 */
1041 if (len
!= OF_PORT_MOD_FIXLEN
)
1043 if (ndo
->ndo_vflag
< 1)
1045 of13_port_mod_print(ndo
, cp
);
1047 case OFPT_ROLE_REQUEST
: /* [OF13] Section 7.3.9 */
1048 case OFPT_ROLE_REPLY
: /* ibid */
1049 if (len
!= OF_ROLE_MSG_FIXLEN
)
1051 if (ndo
->ndo_vflag
< 1)
1053 of13_role_msg_print(ndo
, cp
);
1055 case OFPT_PORT_STATUS
: /* [OF13] Section 7.4.3 */
1056 if (len
!= OF_PORT_STATUS_FIXLEN
)
1058 if (ndo
->ndo_vflag
< 1)
1060 of13_port_status_print(ndo
, cp
);
1062 case OFPT_TABLE_MOD
: /* [OF13] Section 7.3.3 */
1063 if (len
!= OF_TABLE_MOD_FIXLEN
)
1065 if (ndo
->ndo_vflag
< 1)
1067 of13_table_mod_print(ndo
, cp
);
1069 case OFPT_SET_ASYNC
: /* [OF13] Section 7.3.10 */
1070 case OFPT_GET_ASYNC_REPLY
: /* ibid */
1071 if (len
!= OF_ASYNC_MSG_FIXLEN
)
1073 if (ndo
->ndo_vflag
< 1)
1075 of13_async_msg_print(ndo
, cp
);
1078 /* OpenFlow header and variable-size data. */
1079 case OFPT_ECHO_REQUEST
: /* [OF13] Section A.5.2 */
1080 case OFPT_ECHO_REPLY
: /* [OF13] Section A.5.3 */
1081 if (ndo
->ndo_vflag
< 1)
1083 of_data_print(ndo
, cp
, len
);
1086 /* OpenFlow header and n * variable-size data units. */
1087 case OFPT_HELLO
: /* [OF13] Section A.5.1 */
1088 if (ndo
->ndo_vflag
< 1)
1090 of13_hello_elements_print(ndo
, cp
, len
);
1093 /* OpenFlow header, fixed-size message body and variable-size data. */
1095 if (len
< OF_ERROR_MSG_MINLEN
)
1097 if (ndo
->ndo_vflag
< 1)
1099 of13_error_print(ndo
, cp
, len
);
1101 case OFPT_EXPERIMENTER
: /* [OF13] Section 7.5.4 */
1102 if (len
< OF_EXPERIMENTER_MSG_MINLEN
)
1104 if (ndo
->ndo_vflag
< 1)
1106 of13_experimenter_message_print(ndo
, cp
, len
);
1110 * Not a recognised type or did not print the details, fall back to
1113 ND_TCHECK_LEN(cp
, len
);
1116 invalid
: /* skip the message body */
1117 nd_print_invalid(ndo
);
1118 ND_TCHECK_LEN(cp
, len
);