2 * This module implements decoding of OpenFlow protocol version 1.0 (wire
3 * protocol 0x01). The decoder implements terse (default), detailed (-v) and
4 * full (-vv) output formats and, as much as each format implies, detects and
5 * tries to work around sizing anomalies inside the messages. The decoder marks
6 * up bogus values of selected message fields and decodes partially captured
7 * messages up to the snapshot end. It is based on the specification below:
9 * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
11 * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT
12 * messages is done only when the verbosity level set by command-line argument
13 * is "-vvv" or higher. In that case the verbosity level is temporarily
14 * decremented by 3 during the nested frame decoding. For example, running
15 * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of
19 * Copyright (c) 2013 The TCPDUMP project
20 * All rights reserved.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
25 * 1. Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
41 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGE.
45 #define NETDISSECT_REWORKED
50 #include <tcpdump-stdinc.h>
52 #include "interface.h"
54 #include "addrtoname.h"
56 #include "ethertype.h"
60 static const char tstr[] = " [|openflow]";
61 static const char cstr[] = " (corrupt)";
63 #define OFPT_HELLO 0x00
64 #define OFPT_ERROR 0x01
65 #define OFPT_ECHO_REQUEST 0x02
66 #define OFPT_ECHO_REPLY 0x03
67 #define OFPT_VENDOR 0x04
68 #define OFPT_FEATURES_REQUEST 0x05
69 #define OFPT_FEATURES_REPLY 0x06
70 #define OFPT_GET_CONFIG_REQUEST 0x07
71 #define OFPT_GET_CONFIG_REPLY 0x08
72 #define OFPT_SET_CONFIG 0x09
73 #define OFPT_PACKET_IN 0x0a
74 #define OFPT_FLOW_REMOVED 0x0b
75 #define OFPT_PORT_STATUS 0x0c
76 #define OFPT_PACKET_OUT 0x0d
77 #define OFPT_FLOW_MOD 0x0e
78 #define OFPT_PORT_MOD 0x0f
79 #define OFPT_STATS_REQUEST 0x10
80 #define OFPT_STATS_REPLY 0x11
81 #define OFPT_BARRIER_REQUEST 0x12
82 #define OFPT_BARRIER_REPLY 0x13
83 #define OFPT_QUEUE_GET_CONFIG_REQUEST 0x14
84 #define OFPT_QUEUE_GET_CONFIG_REPLY 0x15
85 static const struct tok ofpt_str[] = {
86 { OFPT_HELLO, "HELLO" },
87 { OFPT_ERROR, "ERROR" },
88 { OFPT_ECHO_REQUEST, "ECHO_REQUEST" },
89 { OFPT_ECHO_REPLY, "ECHO_REPLY" },
90 { OFPT_VENDOR, "VENDOR" },
91 { OFPT_FEATURES_REQUEST, "FEATURES_REQUEST" },
92 { OFPT_FEATURES_REPLY, "FEATURES_REPLY" },
93 { OFPT_GET_CONFIG_REQUEST, "GET_CONFIG_REQUEST" },
94 { OFPT_GET_CONFIG_REPLY, "GET_CONFIG_REPLY" },
95 { OFPT_SET_CONFIG, "SET_CONFIG" },
96 { OFPT_PACKET_IN, "PACKET_IN" },
97 { OFPT_FLOW_REMOVED, "FLOW_REMOVED" },
98 { OFPT_PORT_STATUS, "PORT_STATUS" },
99 { OFPT_PACKET_OUT, "PACKET_OUT" },
100 { OFPT_FLOW_MOD, "FLOW_MOD" },
101 { OFPT_PORT_MOD, "PORT_MOD" },
102 { OFPT_STATS_REQUEST, "STATS_REQUEST" },
103 { OFPT_STATS_REPLY, "STATS_REPLY" },
104 { OFPT_BARRIER_REQUEST, "BARRIER_REQUEST" },
105 { OFPT_BARRIER_REPLY, "BARRIER_REPLY" },
106 { OFPT_QUEUE_GET_CONFIG_REQUEST, "QUEUE_GET_CONFIG_REQUEST" },
107 { OFPT_QUEUE_GET_CONFIG_REPLY, "QUEUE_GET_CONFIG_REPLY" },
111 #define OFPPC_PORT_DOWN (1 << 0)
112 #define OFPPC_NO_STP (1 << 1)
113 #define OFPPC_NO_RECV (1 << 2)
114 #define OFPPC_NO_RECV_STP (1 << 3)
115 #define OFPPC_NO_FLOOD (1 << 4)
116 #define OFPPC_NO_FWD (1 << 5)
117 #define OFPPC_NO_PACKET_IN (1 << 6)
118 static const struct tok ofppc_bm[] = {
119 { OFPPC_PORT_DOWN, "PORT_DOWN" },
120 { OFPPC_NO_STP, "NO_STP" },
121 { OFPPC_NO_RECV, "NO_RECV" },
122 { OFPPC_NO_RECV_STP, "NO_RECV_STP" },
123 { OFPPC_NO_FLOOD, "NO_FLOOD" },
124 { OFPPC_NO_FWD, "NO_FWD" },
125 { OFPPC_NO_PACKET_IN, "NO_PACKET_IN" },
128 #define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_STP | OFPPC_NO_RECV | \
129 OFPPC_NO_RECV_STP | OFPPC_NO_FLOOD | OFPPC_NO_FWD | \
132 #define OFPPS_LINK_DOWN (1 << 0)
133 #define OFPPS_STP_LISTEN (0 << 8)
134 #define OFPPS_STP_LEARN (1 << 8)
135 #define OFPPS_STP_FORWARD (2 << 8)
136 #define OFPPS_STP_BLOCK (3 << 8)
137 #define OFPPS_STP_MASK (3 << 8)
138 static const struct tok ofpps_bm[] = {
139 { OFPPS_LINK_DOWN, "LINK_DOWN" },
140 { OFPPS_STP_LISTEN, "STP_LISTEN" },
141 { OFPPS_STP_LEARN, "STP_LEARN" },
142 { OFPPS_STP_FORWARD, "STP_FORWARD" },
143 { OFPPS_STP_BLOCK, "STP_BLOCK" },
146 #define OFPPS_U (~(OFPPS_LINK_DOWN | OFPPS_STP_LISTEN | OFPPS_STP_LEARN | \
147 OFPPS_STP_FORWARD | OFPPS_STP_BLOCK))
149 #define OFPP_MAX 0xff00
150 #define OFPP_IN_PORT 0xfff8
151 #define OFPP_TABLE 0xfff9
152 #define OFPP_NORMAL 0xfffa
153 #define OFPP_FLOOD 0xfffb
154 #define OFPP_ALL 0xfffc
155 #define OFPP_CONTROLLER 0xfffd
156 #define OFPP_LOCAL 0xfffe
157 #define OFPP_NONE 0xffff
158 static const struct tok ofpp_str[] = {
160 { OFPP_IN_PORT, "IN_PORT" },
161 { OFPP_TABLE, "TABLE" },
162 { OFPP_NORMAL, "NORMAL" },
163 { OFPP_FLOOD, "FLOOD" },
165 { OFPP_CONTROLLER, "CONTROLLER" },
166 { OFPP_LOCAL, "LOCAL" },
167 { OFPP_NONE, "NONE" },
171 #define OFPPF_10MB_HD (1 << 0)
172 #define OFPPF_10MB_FD (1 << 1)
173 #define OFPPF_100MB_HD (1 << 2)
174 #define OFPPF_100MB_FD (1 << 3)
175 #define OFPPF_1GB_HD (1 << 4)
176 #define OFPPF_1GB_FD (1 << 5)
177 #define OFPPF_10GB_FD (1 << 6)
178 #define OFPPF_COPPER (1 << 7)
179 #define OFPPF_FIBER (1 << 8)
180 #define OFPPF_AUTONEG (1 << 9)
181 #define OFPPF_PAUSE (1 << 10)
182 #define OFPPF_PAUSE_ASYM (1 << 11)
183 static const struct tok ofppf_bm[] = {
184 { OFPPF_10MB_HD, "10MB_HD" },
185 { OFPPF_10MB_FD, "10MB_FD" },
186 { OFPPF_100MB_HD, "100MB_HD" },
187 { OFPPF_100MB_FD, "100MB_FD" },
188 { OFPPF_1GB_HD, "1GB_HD" },
189 { OFPPF_1GB_FD, "1GB_FD" },
190 { OFPPF_10GB_FD, "10GB_FD" },
191 { OFPPF_COPPER, "COPPER" },
192 { OFPPF_FIBER, "FIBER" },
193 { OFPPF_AUTONEG, "AUTONEG" },
194 { OFPPF_PAUSE, "PAUSE" },
195 { OFPPF_PAUSE_ASYM, "PAUSE_ASYM" },
198 #define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \
199 OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \
200 OFPPF_10GB_FD | OFPPF_COPPER | OFPPF_FIBER | \
201 OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM))
203 #define OFPQT_NONE 0x0000
204 #define OFPQT_MIN_RATE 0x0001
205 static const struct tok ofpqt_str[] = {
206 { OFPQT_NONE, "NONE" },
207 { OFPQT_MIN_RATE, "MIN_RATE" },
211 #define OFPFW_IN_PORT (1 << 0)
212 #define OFPFW_DL_VLAN (1 << 1)
213 #define OFPFW_DL_SRC (1 << 2)
214 #define OFPFW_DL_DST (1 << 3)
215 #define OFPFW_DL_TYPE (1 << 4)
216 #define OFPFW_NW_PROTO (1 << 5)
217 #define OFPFW_TP_SRC (1 << 6)
218 #define OFPFW_TP_DST (1 << 7)
219 #define OFPFW_NW_SRC_SHIFT 8
220 #define OFPFW_NW_SRC_BITS 6
221 #define OFPFW_NW_SRC_MASK (((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT)
222 #define OFPFW_NW_DST_SHIFT 14
223 #define OFPFW_NW_DST_BITS 6
224 #define OFPFW_NW_DST_MASK (((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT)
225 #define OFPFW_DL_VLAN_PCP (1 << 20)
226 #define OFPFW_NW_TOS (1 << 21)
227 #define OFPFW_ALL ((1 << 22) - 1)
228 static const struct tok ofpfw_bm[] = {
229 { OFPFW_IN_PORT, "IN_PORT" },
230 { OFPFW_DL_VLAN, "DL_VLAN" },
231 { OFPFW_DL_SRC, "DL_SRC" },
232 { OFPFW_DL_DST, "DL_DST" },
233 { OFPFW_DL_TYPE, "DL_TYPE" },
234 { OFPFW_NW_PROTO, "NW_PROTO" },
235 { OFPFW_TP_SRC, "TP_SRC" },
236 { OFPFW_TP_DST, "TP_DST" },
237 { OFPFW_DL_VLAN_PCP, "DL_VLAN_PCP" },
238 { OFPFW_NW_TOS, "NW_TOS" },
241 /* The above array does not include bits 8~13 (OFPFW_NW_SRC_*) and 14~19
242 * (OFPFW_NW_DST_*), which are not a part of the bitmap and require decoding
243 * other than that of tok2str(). The macro below includes these bits such that
244 * they are not reported as bogus in the decoding. */
245 #define OFPFW_U (~(OFPFW_ALL))
247 #define OFPAT_OUTPUT 0x0000
248 #define OFPAT_SET_VLAN_VID 0x0001
249 #define OFPAT_SET_VLAN_PCP 0x0002
250 #define OFPAT_STRIP_VLAN 0x0003
251 #define OFPAT_SET_DL_SRC 0x0004
252 #define OFPAT_SET_DL_DST 0x0005
253 #define OFPAT_SET_NW_SRC 0x0006
254 #define OFPAT_SET_NW_DST 0x0007
255 #define OFPAT_SET_NW_TOS 0x0008
256 #define OFPAT_SET_TP_SRC 0x0009
257 #define OFPAT_SET_TP_DST 0x000a
258 #define OFPAT_ENQUEUE 0x000b
259 #define OFPAT_VENDOR 0xffff
260 static const struct tok ofpat_str[] = {
261 { OFPAT_OUTPUT, "OUTPUT" },
262 { OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
263 { OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
264 { OFPAT_STRIP_VLAN, "STRIP_VLAN" },
265 { OFPAT_SET_DL_SRC, "SET_DL_SRC" },
266 { OFPAT_SET_DL_DST, "SET_DL_DST" },
267 { OFPAT_SET_NW_SRC, "SET_NW_SRC" },
268 { OFPAT_SET_NW_DST, "SET_NW_DST" },
269 { OFPAT_SET_NW_TOS, "SET_NW_TOS" },
270 { OFPAT_SET_TP_SRC, "SET_TP_SRC" },
271 { OFPAT_SET_TP_DST, "SET_TP_DST" },
272 { OFPAT_ENQUEUE, "ENQUEUE" },
273 { OFPAT_VENDOR, "VENDOR" },
277 /* bit-shifted, w/o vendor action */
278 static const struct tok ofpat_bm[] = {
279 { 1 << OFPAT_OUTPUT, "OUTPUT" },
280 { 1 << OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
281 { 1 << OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
282 { 1 << OFPAT_STRIP_VLAN, "STRIP_VLAN" },
283 { 1 << OFPAT_SET_DL_SRC, "SET_DL_SRC" },
284 { 1 << OFPAT_SET_DL_DST, "SET_DL_DST" },
285 { 1 << OFPAT_SET_NW_SRC, "SET_NW_SRC" },
286 { 1 << OFPAT_SET_NW_DST, "SET_NW_DST" },
287 { 1 << OFPAT_SET_NW_TOS, "SET_NW_TOS" },
288 { 1 << OFPAT_SET_TP_SRC, "SET_TP_SRC" },
289 { 1 << OFPAT_SET_TP_DST, "SET_TP_DST" },
290 { 1 << OFPAT_ENQUEUE, "ENQUEUE" },
293 #define OFPAT_U (~(1 << OFPAT_OUTPUT | 1 << OFPAT_SET_VLAN_VID | \
294 1 << OFPAT_SET_VLAN_PCP | 1 << OFPAT_STRIP_VLAN | \
295 1 << OFPAT_SET_DL_SRC | 1 << OFPAT_SET_DL_DST | \
296 1 << OFPAT_SET_NW_SRC | 1 << OFPAT_SET_NW_DST | \
297 1 << OFPAT_SET_NW_TOS | 1 << OFPAT_SET_TP_SRC | \
298 1 << OFPAT_SET_TP_DST | 1 << OFPAT_ENQUEUE))
300 #define OFPC_FLOW_STATS (1 << 0)
301 #define OFPC_TABLE_STATS (1 << 1)
302 #define OFPC_PORT_STATS (1 << 2)
303 #define OFPC_STP (1 << 3)
304 #define OFPC_RESERVED (1 << 4)
305 #define OFPC_IP_REASM (1 << 5)
306 #define OFPC_QUEUE_STATS (1 << 6)
307 #define OFPC_ARP_MATCH_IP (1 << 7)
308 static const struct tok ofp_capabilities_bm[] = {
309 { OFPC_FLOW_STATS, "FLOW_STATS" },
310 { OFPC_TABLE_STATS, "TABLE_STATS" },
311 { OFPC_PORT_STATS, "PORT_STATS" },
313 { OFPC_RESERVED, "RESERVED" }, /* not in the mask below */
314 { OFPC_IP_REASM, "IP_REASM" },
315 { OFPC_QUEUE_STATS, "QUEUE_STATS" },
316 { OFPC_ARP_MATCH_IP, "ARP_MATCH_IP" },
319 #define OFPCAP_U (~(OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | \
320 OFPC_STP | OFPC_IP_REASM | OFPC_QUEUE_STATS | \
323 #define OFPC_FRAG_NORMAL 0x0000
324 #define OFPC_FRAG_DROP 0x0001
325 #define OFPC_FRAG_REASM 0x0002
326 #define OFPC_FRAG_MASK 0x0003
327 static const struct tok ofp_config_str[] = {
328 { OFPC_FRAG_NORMAL, "FRAG_NORMAL" },
329 { OFPC_FRAG_DROP, "FRAG_DROP" },
330 { OFPC_FRAG_REASM, "FRAG_REASM" },
334 #define OFPFC_ADD 0x0000
335 #define OFPFC_MODIFY 0x0001
336 #define OFPFC_MODIFY_STRICT 0x0002
337 #define OFPFC_DELETE 0x0003
338 #define OFPFC_DELETE_STRICT 0x0004
339 static const struct tok ofpfc_str[] = {
340 { OFPFC_ADD, "ADD" },
341 { OFPFC_MODIFY, "MODIFY" },
342 { OFPFC_MODIFY_STRICT, "MODIFY_STRICT" },
343 { OFPFC_DELETE, "DELETE" },
344 { OFPFC_DELETE_STRICT, "DELETE_STRICT" },
348 static const struct tok bufferid_str[] = {
349 { 0xffffffff, "NONE" },
353 #define OFPFF_SEND_FLOW_REM (1 << 0)
354 #define OFPFF_CHECK_OVERLAP (1 << 1)
355 #define OFPFF_EMERG (1 << 2)
356 static const struct tok ofpff_bm[] = {
357 { OFPFF_SEND_FLOW_REM, "SEND_FLOW_REM" },
358 { OFPFF_CHECK_OVERLAP, "CHECK_OVERLAP" },
359 { OFPFF_EMERG, "EMERG" },
362 #define OFPFF_U (~(OFPFF_SEND_FLOW_REM | OFPFF_CHECK_OVERLAP | OFPFF_EMERG))
364 #define OFPST_DESC 0x0000
365 #define OFPST_FLOW 0x0001
366 #define OFPST_AGGREGATE 0x0002
367 #define OFPST_TABLE 0x0003
368 #define OFPST_PORT 0x0004
369 #define OFPST_QUEUE 0x0005
370 #define OFPST_VENDOR 0xffff
371 static const struct tok ofpst_str[] = {
372 { OFPST_DESC, "DESC" },
373 { OFPST_FLOW, "FLOW" },
374 { OFPST_AGGREGATE, "AGGREGATE" },
375 { OFPST_TABLE, "TABLE" },
376 { OFPST_PORT, "PORT" },
377 { OFPST_QUEUE, "QUEUE" },
378 { OFPST_VENDOR, "VENDOR" },
382 static const struct tok tableid_str[] = {
388 #define OFPQ_ALL 0xffffffff
389 static const struct tok ofpq_str[] = {
394 #define OFPSF_REPLY_MORE 0x0001
395 static const struct tok ofpsf_reply_bm[] = {
396 { OFPSF_REPLY_MORE, "MORE" },
399 #define OFPSF_REPLY_U (~(OFPSF_REPLY_MORE))
401 #define OFPR_NO_MATCH 0x00
402 #define OFPR_ACTION 0x01
403 static const struct tok ofpr_str[] = {
404 { OFPR_NO_MATCH, "NO_MATCH" },
405 { OFPR_ACTION, "ACTION" },
409 #define OFPRR_IDLE_TIMEOUT 0x00
410 #define OFPRR_HARD_TIMEOUT 0x01
411 #define OFPRR_DELETE 0x02
412 static const struct tok ofprr_str[] = {
413 { OFPRR_IDLE_TIMEOUT, "IDLE_TIMEOUT" },
414 { OFPRR_HARD_TIMEOUT, "HARD_TIMEOUT" },
415 { OFPRR_DELETE, "DELETE" },
419 #define OFPPR_ADD 0x00
420 #define OFPPR_DELETE 0x01
421 #define OFPPR_MODIFY 0x02
422 static const struct tok ofppr_str[] = {
423 { OFPPR_ADD, "ADD" },
424 { OFPPR_DELETE, "DELETE" },
425 { OFPPR_MODIFY, "MODIFY" },
429 #define OFPET_HELLO_FAILED 0x0000
430 #define OFPET_BAD_REQUEST 0x0001
431 #define OFPET_BAD_ACTION 0x0002
432 #define OFPET_FLOW_MOD_FAILED 0x0003
433 #define OFPET_PORT_MOD_FAILED 0x0004
434 #define OFPET_QUEUE_OP_FAILED 0x0005
435 static const struct tok ofpet_str[] = {
436 { OFPET_HELLO_FAILED, "HELLO_FAILED" },
437 { OFPET_BAD_REQUEST, "BAD_REQUEST" },
438 { OFPET_BAD_ACTION, "BAD_ACTION" },
439 { OFPET_FLOW_MOD_FAILED, "FLOW_MOD_FAILED" },
440 { OFPET_PORT_MOD_FAILED, "PORT_MOD_FAILED" },
441 { OFPET_QUEUE_OP_FAILED, "QUEUE_OP_FAILED" },
445 #define OFPHFC_INCOMPATIBLE 0x0000
446 #define OFPHFC_EPERM 0x0001
447 static const struct tok ofphfc_str[] = {
448 { OFPHFC_INCOMPATIBLE, "INCOMPATIBLE" },
449 { OFPHFC_EPERM, "EPERM" },
453 #define OFPBRC_BAD_VERSION 0x0000
454 #define OFPBRC_BAD_TYPE 0x0001
455 #define OFPBRC_BAD_STAT 0x0002
456 #define OFPBRC_BAD_VENDOR 0x0003
457 #define OFPBRC_BAD_SUBTYPE 0x0004
458 #define OFPBRC_EPERM 0x0005
459 #define OFPBRC_BAD_LEN 0x0006
460 #define OFPBRC_BUFFER_EMPTY 0x0007
461 #define OFPBRC_BUFFER_UNKNOWN 0x0008
462 static const struct tok ofpbrc_str[] = {
463 { OFPBRC_BAD_VERSION, "BAD_VERSION" },
464 { OFPBRC_BAD_TYPE, "BAD_TYPE" },
465 { OFPBRC_BAD_STAT, "BAD_STAT" },
466 { OFPBRC_BAD_VENDOR, "BAD_VENDOR" },
467 { OFPBRC_BAD_SUBTYPE, "BAD_SUBTYPE" },
468 { OFPBRC_EPERM, "EPERM" },
469 { OFPBRC_BAD_LEN, "BAD_LEN" },
470 { OFPBRC_BUFFER_EMPTY, "BUFFER_EMPTY" },
471 { OFPBRC_BUFFER_UNKNOWN, "BUFFER_UNKNOWN" },
475 #define OFPBAC_BAD_TYPE 0x0000
476 #define OFPBAC_BAD_LEN 0x0001
477 #define OFPBAC_BAD_VENDOR 0x0002
478 #define OFPBAC_BAD_VENDOR_TYPE 0x0003
479 #define OFPBAC_BAD_OUT_PORT 0x0004
480 #define OFPBAC_BAD_ARGUMENT 0x0005
481 #define OFPBAC_EPERM 0x0006
482 #define OFPBAC_TOO_MANY 0x0007
483 #define OFPBAC_BAD_QUEUE 0x0008
484 static const struct tok ofpbac_str[] = {
485 { OFPBAC_BAD_TYPE, "BAD_TYPE" },
486 { OFPBAC_BAD_LEN, "BAD_LEN" },
487 { OFPBAC_BAD_VENDOR, "BAD_VENDOR" },
488 { OFPBAC_BAD_VENDOR_TYPE, "BAD_VENDOR_TYPE" },
489 { OFPBAC_BAD_OUT_PORT, "BAD_OUT_PORT" },
490 { OFPBAC_BAD_ARGUMENT, "BAD_ARGUMENT" },
491 { OFPBAC_EPERM, "EPERM" },
492 { OFPBAC_TOO_MANY, "TOO_MANY" },
493 { OFPBAC_BAD_QUEUE, "BAD_QUEUE" },
497 #define OFPFMFC_ALL_TABLES_FULL 0x0000
498 #define OFPFMFC_OVERLAP 0x0001
499 #define OFPFMFC_EPERM 0x0002
500 #define OFPFMFC_BAD_EMERG_TIMEOUT 0x0003
501 #define OFPFMFC_BAD_COMMAND 0x0004
502 #define OFPFMFC_UNSUPPORTED 0x0005
503 static const struct tok ofpfmfc_str[] = {
504 { OFPFMFC_ALL_TABLES_FULL, "ALL_TABLES_FULL" },
505 { OFPFMFC_OVERLAP, "OVERLAP" },
506 { OFPFMFC_EPERM, "EPERM" },
507 { OFPFMFC_BAD_EMERG_TIMEOUT, "BAD_EMERG_TIMEOUT" },
508 { OFPFMFC_BAD_COMMAND, "BAD_COMMAND" },
509 { OFPFMFC_UNSUPPORTED, "UNSUPPORTED" },
513 #define OFPPMFC_BAD_PORT 0x0000
514 #define OFPPMFC_BAD_HW_ADDR 0x0001
515 static const struct tok ofppmfc_str[] = {
516 { OFPPMFC_BAD_PORT, "BAD_PORT" },
517 { OFPPMFC_BAD_HW_ADDR, "BAD_HW_ADDR" },
521 #define OFPQOFC_BAD_PORT 0x0000
522 #define OFPQOFC_BAD_QUEUE 0x0001
523 #define OFPQOFC_EPERM 0x0002
524 static const struct tok ofpqofc_str[] = {
525 { OFPQOFC_BAD_PORT, "BAD_PORT" },
526 { OFPQOFC_BAD_QUEUE, "BAD_QUEUE" },
527 { OFPQOFC_EPERM, "EPERM" },
531 static const struct tok empty_str[] = {
535 /* lengths (fixed or minimal) of particular protocol structures */
536 #define OF_SWITCH_CONFIG_LEN 12
537 #define OF_PHY_PORT_LEN 48
538 #define OF_SWITCH_FEATURES_LEN 32
539 #define OF_PORT_STATUS_LEN 64
540 #define OF_PORT_MOD_LEN 32
541 #define OF_PACKET_IN_LEN 20
542 #define OF_ACTION_OUTPUT_LEN 8
543 #define OF_ACTION_VLAN_VID_LEN 8
544 #define OF_ACTION_VLAN_PCP_LEN 8
545 #define OF_ACTION_DL_ADDR_LEN 16
546 #define OF_ACTION_NW_ADDR_LEN 8
547 #define OF_ACTION_TP_PORT_LEN 8
548 #define OF_ACTION_NW_TOS_LEN 8
549 #define OF_ACTION_VENDOR_HEADER_LEN 8
550 #define OF_ACTION_HEADER_LEN 8
551 #define OF_PACKET_OUT_LEN 16
552 #define OF_MATCH_LEN 40
553 #define OF_FLOW_MOD_LEN 72
554 #define OF_FLOW_REMOVED_LEN 88
555 #define OF_ERROR_MSG_LEN 12
556 #define OF_STATS_REQUEST_LEN 12
557 #define OF_STATS_REPLY_LEN 12
558 #define OF_DESC_STATS_LEN 1056
559 #define OF_FLOW_STATS_REQUEST_LEN 44
560 #define OF_FLOW_STATS_LEN 88
561 #define OF_AGGREGATE_STATS_REQUEST_LEN 44
562 #define OF_AGGREGATE_STATS_REPLY_LEN 24
563 #define OF_TABLE_STATS_LEN 64
564 #define OF_PORT_STATS_REQUEST_LEN 8
565 #define OF_PORT_STATS_LEN 104
566 #define OF_VENDOR_HEADER_LEN 12
567 #define OF_QUEUE_PROP_HEADER_LEN 8
568 #define OF_QUEUE_PROP_MIN_RATE_LEN 16
569 #define OF_PACKET_QUEUE_LEN 8
570 #define OF_QUEUE_GET_CONFIG_REQUEST_LEN 12
571 #define OF_QUEUE_GET_CONFIG_REPLY_LEN 16
572 #define OF_ACTION_ENQUEUE_LEN 16
573 #define OF_QUEUE_STATS_REQUEST_LEN 8
574 #define OF_QUEUE_STATS_LEN 32
576 /* miscellaneous constants from [OF10] */
577 #define OFP_MAX_TABLE_NAME_LEN 32
578 #define OFP_MAX_PORT_NAME_LEN 16
579 #define DESC_STR_LEN 256
580 #define SERIAL_NUM_LEN 32
581 #define OFP_VLAN_NONE 0xffff
584 vlan_str(const uint16_t vid) {
585 static char buf[sizeof("65535 (bogus)")];
588 if (vid == OFP_VLAN_NONE)
590 fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
591 snprintf(buf, sizeof(buf), fmt, vid);
596 pcp_str(const uint8_t pcp) {
597 static char buf[sizeof("255 (bogus)")];
598 snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
603 of10_bitmap_print(netdissect_options *ndo,
604 const struct tok *t, const uint32_t v, const uint32_t u) {
605 const char *sep = " (";
610 for (; t->s != NULL; t++)
612 ND_PRINT((ndo, "%s%s", sep, t->s));
615 /* unassigned bits? */
616 ND_PRINT((ndo, v & u ? ") (bogus)" : ")"));
619 static const u_char *
620 of10_data_print(netdissect_options *ndo,
621 const u_char *cp, const u_char *ep, const u_int len) {
625 ND_PRINT((ndo, "\n\t data (%u octets)", len));
626 ND_TCHECK2(*cp, len);
627 if (ndo->ndo_vflag >= 2)
628 hex_and_ascii_print(ndo, "\n\t ", cp, len);
632 ND_PRINT((ndo, "%s", tstr));
636 /* Vendor ID is mandatory, data is optional. */
637 static const u_char *
638 of10_vendor_data_print(netdissect_options *ndo,
639 const u_char *cp, const u_char *ep, const u_int len) {
644 ND_PRINT((ndo, ", vendor 0x%08x", EXTRACT_32BITS(cp)));
647 return of10_data_print(ndo, cp, ep, len - 4);
649 corrupt: /* skip the undersized data */
650 ND_PRINT((ndo, "%s", cstr));
651 ND_TCHECK2(*cp, len);
654 ND_PRINT((ndo, "%s", tstr));
658 static const u_char *
659 of10_packet_data_print(netdissect_options *ndo,
660 const u_char *cp, const u_char *ep, const u_int len) {
664 ND_PRINT((ndo, "\n\t data (%u octets)", len));
665 if (ndo->ndo_vflag < 3)
667 ND_TCHECK2(*cp, len);
669 ND_PRINT((ndo, ", frame decoding below\n"));
670 ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL);
675 ND_PRINT((ndo, "%s", tstr));
679 /* [OF10] Section 5.2.1 */
680 static const u_char *
681 of10_phy_ports_print(netdissect_options *ndo,
682 const u_char *cp, const u_char *ep, u_int len) {
683 const u_char *cp0 = cp;
684 const u_int len0 = len;
687 if (len < OF_PHY_PORT_LEN)
691 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
694 ND_TCHECK2(*cp, ETHER_ADDR_LEN);
695 ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
696 cp += ETHER_ADDR_LEN;
698 ND_TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
699 ND_PRINT((ndo, ", name '"));
700 fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
701 ND_PRINT((ndo, "'"));
702 cp += OFP_MAX_PORT_NAME_LEN;
704 if (ndo->ndo_vflag < 2) {
711 ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
712 of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
716 ND_PRINT((ndo, "\n\t state 0x%08x", EXTRACT_32BITS(cp)));
717 of10_bitmap_print(ndo, ofpps_bm, EXTRACT_32BITS(cp), OFPPS_U);
721 ND_PRINT((ndo, "\n\t curr 0x%08x", EXTRACT_32BITS(cp)));
722 of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
726 ND_PRINT((ndo, "\n\t advertised 0x%08x", EXTRACT_32BITS(cp)));
727 of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
731 ND_PRINT((ndo, "\n\t supported 0x%08x", EXTRACT_32BITS(cp)));
732 of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
736 ND_PRINT((ndo, "\n\t peer 0x%08x", EXTRACT_32BITS(cp)));
737 of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
740 len -= OF_PHY_PORT_LEN;
744 corrupt: /* skip the undersized trailing data */
745 ND_PRINT((ndo, "%s", cstr));
746 ND_TCHECK2(*cp0, len0);
749 ND_PRINT((ndo, "%s", tstr));
753 /* [OF10] Section 5.2.2 */
754 static const u_char *
755 of10_queue_props_print(netdissect_options *ndo,
756 const u_char *cp, const u_char *ep, u_int len) {
757 const u_char *cp0 = cp;
758 const u_int len0 = len;
759 uint16_t property, plen, rate;
762 u_char plen_bogus = 0, skip = 0;
764 if (len < OF_QUEUE_PROP_HEADER_LEN)
768 property = EXTRACT_16BITS(cp);
770 ND_PRINT((ndo, "\n\t property %s", tok2str(ofpqt_str, "invalid (0x%04x)", property)));
773 plen = EXTRACT_16BITS(cp);
775 ND_PRINT((ndo, ", len %u", plen));
776 if (plen < OF_QUEUE_PROP_HEADER_LEN || plen > len)
781 /* property-specific constraints and decoding */
784 plen_bogus = plen != OF_QUEUE_PROP_HEADER_LEN;
787 plen_bogus = plen != OF_QUEUE_PROP_MIN_RATE_LEN;
793 ND_PRINT((ndo, " (bogus)"));
797 ND_TCHECK2(*cp, plen - 4);
801 if (property == OFPQT_MIN_RATE) { /* the only case of property decoding */
804 rate = EXTRACT_16BITS(cp);
807 ND_PRINT((ndo, ", rate disabled"));
809 ND_PRINT((ndo, ", rate %u.%u%%", rate / 10, rate % 10));
819 corrupt: /* skip the rest of queue properties */
820 ND_PRINT((ndo, "%s", cstr));
821 ND_TCHECK2(*cp0, len0);
824 ND_PRINT((ndo, "%s", tstr));
829 static const u_char *
830 of10_queues_print(netdissect_options *ndo,
831 const u_char *cp, const u_char *ep, u_int len) {
832 const u_char *cp0 = cp;
833 const u_int len0 = len;
837 if (len < OF_PACKET_QUEUE_LEN)
841 ND_PRINT((ndo, "\n\t queue_id %u", EXTRACT_32BITS(cp)));
845 desclen = EXTRACT_16BITS(cp);
847 ND_PRINT((ndo, ", len %u", desclen));
848 if (desclen < OF_PACKET_QUEUE_LEN || desclen > len)
854 if (ndo->ndo_vflag < 2) {
855 ND_TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
856 cp += desclen - OF_PACKET_QUEUE_LEN;
859 if (ep == (cp = of10_queue_props_print(ndo, cp, ep, desclen - OF_PACKET_QUEUE_LEN)))
860 return ep; /* end of snapshot */
866 corrupt: /* skip the rest of queues */
867 ND_PRINT((ndo, "%s", cstr));
868 ND_TCHECK2(*cp0, len0);
871 ND_PRINT((ndo, "%s", tstr));
875 /* [OF10] Section 5.2.3 */
876 static const u_char *
877 of10_match_print(netdissect_options *ndo,
878 const char *pfx, const u_char *cp, const u_char *ep) {
883 const char *field_name;
887 wildcards = EXTRACT_32BITS(cp);
888 if (wildcards & OFPFW_U)
889 ND_PRINT((ndo, "%swildcards 0x%08x (bogus)", pfx, wildcards));
893 if (! (wildcards & OFPFW_IN_PORT))
894 ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
897 ND_TCHECK2(*cp, ETHER_ADDR_LEN);
898 if (! (wildcards & OFPFW_DL_SRC))
899 ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
900 cp += ETHER_ADDR_LEN;
902 ND_TCHECK2(*cp, ETHER_ADDR_LEN);
903 if (! (wildcards & OFPFW_DL_DST))
904 ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
905 cp += ETHER_ADDR_LEN;
908 if (! (wildcards & OFPFW_DL_VLAN))
909 ND_PRINT((ndo, "%smatch dl_vlan %s", pfx, vlan_str(EXTRACT_16BITS(cp))));
913 if (! (wildcards & OFPFW_DL_VLAN_PCP))
914 ND_PRINT((ndo, "%smatch dl_vlan_pcp %s", pfx, pcp_str(*cp)));
921 dl_type = EXTRACT_16BITS(cp);
923 if (! (wildcards & OFPFW_DL_TYPE))
924 ND_PRINT((ndo, "%smatch dl_type 0x%04x", pfx, dl_type));
927 if (! (wildcards & OFPFW_NW_TOS))
928 ND_PRINT((ndo, "%smatch nw_tos 0x%02x", pfx, *cp));
934 if (! (wildcards & OFPFW_NW_PROTO)) {
935 field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_ARP
936 ? "arp_opcode" : "nw_proto";
937 ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, nw_proto));
944 nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT;
946 ND_PRINT((ndo, "%smatch nw_src %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
950 nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT;
952 ND_PRINT((ndo, "%smatch nw_dst %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
956 if (! (wildcards & OFPFW_TP_SRC)) {
957 field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
958 && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
959 ? "icmp_type" : "tp_src";
960 ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
965 if (! (wildcards & OFPFW_TP_DST)) {
966 field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
967 && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
968 ? "icmp_code" : "tp_dst";
969 ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
974 ND_PRINT((ndo, "%s", tstr));
978 /* [OF10] Section 5.2.4 */
979 static const u_char *
980 of10_actions_print(netdissect_options *ndo,
981 const char *pfx, const u_char *cp, const u_char *ep,
983 const u_char *cp0 = cp;
984 const u_int len0 = len;
985 uint16_t type, alen, output_port;
988 u_char alen_bogus = 0, skip = 0;
990 if (len < OF_ACTION_HEADER_LEN)
994 type = EXTRACT_16BITS(cp);
996 ND_PRINT((ndo, "%saction type %s", pfx, tok2str(ofpat_str, "invalid (0x%04x)", type)));
999 alen = EXTRACT_16BITS(cp);
1001 ND_PRINT((ndo, ", len %u", alen));
1002 /* On action size underrun/overrun skip the rest of the action list. */
1003 if (alen < OF_ACTION_HEADER_LEN || alen > len)
1005 /* On action size inappropriate for the given type or invalid type just skip
1006 * the current action, as the basic length constraint has been met. */
1009 case OFPAT_SET_VLAN_VID:
1010 case OFPAT_SET_VLAN_PCP:
1011 case OFPAT_STRIP_VLAN:
1012 case OFPAT_SET_NW_SRC:
1013 case OFPAT_SET_NW_DST:
1014 case OFPAT_SET_NW_TOS:
1015 case OFPAT_SET_TP_SRC:
1016 case OFPAT_SET_TP_DST:
1017 alen_bogus = alen != 8;
1019 case OFPAT_SET_DL_SRC:
1020 case OFPAT_SET_DL_DST:
1022 alen_bogus = alen != 16;
1025 alen_bogus = alen % 8 != 0; /* already >= 8 so far */
1031 ND_PRINT((ndo, " (bogus)"));
1035 ND_TCHECK2(*cp, alen - 4);
1039 /* OK to decode the rest of the action structure */
1044 output_port = EXTRACT_16BITS(cp);
1046 ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", output_port)));
1049 if (output_port == OFPP_CONTROLLER)
1050 ND_PRINT((ndo, ", max_len %u", EXTRACT_16BITS(cp)));
1053 case OFPAT_SET_VLAN_VID:
1056 ND_PRINT((ndo, ", vlan_vid %s", vlan_str(EXTRACT_16BITS(cp))));
1062 case OFPAT_SET_VLAN_PCP:
1065 ND_PRINT((ndo, ", vlan_pcp %s", pcp_str(*cp)));
1071 case OFPAT_SET_DL_SRC:
1072 case OFPAT_SET_DL_DST:
1074 ND_TCHECK2(*cp, ETHER_ADDR_LEN);
1075 ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
1076 cp += ETHER_ADDR_LEN;
1081 case OFPAT_SET_NW_SRC:
1082 case OFPAT_SET_NW_DST:
1085 ND_PRINT((ndo, ", nw_addr %s", ipaddr_string(ndo, cp)));
1088 case OFPAT_SET_NW_TOS:
1091 ND_PRINT((ndo, ", nw_tos 0x%02x", *cp));
1097 case OFPAT_SET_TP_SRC:
1098 case OFPAT_SET_TP_DST:
1101 ND_PRINT((ndo, ", tp_port %u", EXTRACT_16BITS(cp)));
1110 ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1117 ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
1121 if (ep == (cp = of10_vendor_data_print(ndo, cp, ep, alen - 4)))
1122 return ep; /* end of snapshot */
1124 case OFPAT_STRIP_VLAN:
1135 corrupt: /* skip the rest of actions */
1136 ND_PRINT((ndo, "%s", cstr));
1137 ND_TCHECK2(*cp0, len0);
1140 ND_PRINT((ndo, "%s", tstr));
1144 /* [OF10] Section 5.3.1 */
1145 static const u_char *
1146 of10_features_reply_print(netdissect_options *ndo,
1147 const u_char *cp, const u_char *ep, const u_int len) {
1150 ND_PRINT((ndo, "\n\t dpid 0x%016" PRIx64, EXTRACT_64BITS(cp)));
1154 ND_PRINT((ndo, ", n_buffers %u", EXTRACT_32BITS(cp)));
1158 ND_PRINT((ndo, ", n_tables %u", *cp));
1165 ND_PRINT((ndo, "\n\t capabilities 0x%08x", EXTRACT_32BITS(cp)));
1166 of10_bitmap_print(ndo, ofp_capabilities_bm, EXTRACT_32BITS(cp), OFPCAP_U);
1170 ND_PRINT((ndo, "\n\t actions 0x%08x", EXTRACT_32BITS(cp)));
1171 of10_bitmap_print(ndo, ofpat_bm, EXTRACT_32BITS(cp), OFPAT_U);
1174 return of10_phy_ports_print(ndo, cp, ep, len - OF_SWITCH_FEATURES_LEN);
1177 ND_PRINT((ndo, "%s", tstr));
1181 /* [OF10] Section 5.3.3 */
1182 static const u_char *
1183 of10_flow_mod_print(netdissect_options *ndo,
1184 const u_char *cp, const u_char *ep, const u_int len) {
1188 if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
1189 return ep; /* end of snapshot */
1192 ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
1196 command = EXTRACT_16BITS(cp);
1197 ND_PRINT((ndo, ", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command)));
1201 if (EXTRACT_16BITS(cp))
1202 ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
1206 if (EXTRACT_16BITS(cp))
1207 ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
1211 if (EXTRACT_16BITS(cp))
1212 ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
1216 if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
1217 command == OFPFC_MODIFY_STRICT)
1218 ND_PRINT((ndo, ", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
1222 if (command == OFPFC_DELETE || command == OFPFC_DELETE_STRICT)
1223 ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1227 ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
1228 of10_bitmap_print(ndo, ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
1231 return of10_actions_print(ndo, "\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
1234 ND_PRINT((ndo, "%s", tstr));
1239 static const u_char *
1240 of10_port_mod_print(netdissect_options *ndo,
1241 const u_char *cp, const u_char *ep) {
1244 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1247 ND_TCHECK2(*cp, ETHER_ADDR_LEN);
1248 ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
1249 cp += ETHER_ADDR_LEN;
1252 ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
1253 of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
1257 ND_PRINT((ndo, "\n\t mask 0x%08x", EXTRACT_32BITS(cp)));
1258 of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
1262 ND_PRINT((ndo, "\n\t advertise 0x%08x", EXTRACT_32BITS(cp)));
1263 of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
1270 ND_PRINT((ndo, "%s", tstr));
1274 /* [OF10] Section 5.3.5 */
1275 static const u_char *
1276 of10_stats_request_print(netdissect_options *ndo,
1277 const u_char *cp, const u_char *ep, u_int len) {
1278 const u_char *cp0 = cp;
1279 const u_int len0 = len;
1284 type = EXTRACT_16BITS(cp);
1286 ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
1289 ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
1290 if (EXTRACT_16BITS(cp))
1291 ND_PRINT((ndo, " (bogus)"));
1293 /* type-specific body of one of fixed lengths */
1294 len -= OF_STATS_REQUEST_LEN;
1302 case OFPST_AGGREGATE:
1303 if (len != OF_FLOW_STATS_REQUEST_LEN)
1306 if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
1307 return ep; /* end of snapshot */
1310 ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
1317 ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1320 if (len != OF_PORT_STATS_REQUEST_LEN)
1324 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1330 if (len != OF_QUEUE_STATS_REQUEST_LEN)
1334 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1341 ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
1344 return of10_vendor_data_print(ndo, cp, ep, len);
1348 corrupt: /* skip the message body */
1349 ND_PRINT((ndo, "%s", cstr));
1350 ND_TCHECK2(*cp0, len0);
1353 ND_PRINT((ndo, "%s", tstr));
1358 static const u_char *
1359 of10_desc_stats_reply_print(netdissect_options *ndo,
1360 const u_char *cp, const u_char *ep, const u_int len) {
1361 if (len != OF_DESC_STATS_LEN)
1364 ND_TCHECK2(*cp, DESC_STR_LEN);
1365 ND_PRINT((ndo, "\n\t mfr_desc '"));
1366 fn_print(ndo, cp, cp + DESC_STR_LEN);
1367 ND_PRINT((ndo, "'"));
1370 ND_TCHECK2(*cp, DESC_STR_LEN);
1371 ND_PRINT((ndo, "\n\t hw_desc '"));
1372 fn_print(ndo, cp, cp + DESC_STR_LEN);
1373 ND_PRINT((ndo, "'"));
1376 ND_TCHECK2(*cp, DESC_STR_LEN);
1377 ND_PRINT((ndo, "\n\t sw_desc '"));
1378 fn_print(ndo, cp, cp + DESC_STR_LEN);
1379 ND_PRINT((ndo, "'"));
1382 ND_TCHECK2(*cp, SERIAL_NUM_LEN);
1383 ND_PRINT((ndo, "\n\t serial_num '"));
1384 fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
1385 ND_PRINT((ndo, "'"));
1386 cp += SERIAL_NUM_LEN;
1388 ND_TCHECK2(*cp, DESC_STR_LEN);
1389 ND_PRINT((ndo, "\n\t dp_desc '"));
1390 fn_print(ndo, cp, cp + DESC_STR_LEN);
1391 ND_PRINT((ndo, "'"));
1392 return cp + DESC_STR_LEN;
1394 corrupt: /* skip the message body */
1395 ND_PRINT((ndo, "%s", cstr));
1396 ND_TCHECK2(*cp, len);
1399 ND_PRINT((ndo, "%s", tstr));
1404 static const u_char *
1405 of10_flow_stats_reply_print(netdissect_options *ndo,
1406 const u_char *cp, const u_char *ep, u_int len) {
1407 const u_char *cp0 = cp;
1408 const u_int len0 = len;
1412 if (len < OF_FLOW_STATS_LEN)
1416 entry_len = EXTRACT_16BITS(cp);
1417 ND_PRINT((ndo, "\n\t length %u", entry_len));
1418 if (entry_len < OF_FLOW_STATS_LEN || entry_len > len)
1423 ND_PRINT((ndo, ", table_id %s", tok2str(tableid_str, "%u", *cp)));
1429 if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
1430 return ep; /* end of snapshot */
1433 ND_PRINT((ndo, "\n\t duration_sec %u", EXTRACT_32BITS(cp)));
1437 ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
1441 ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
1445 ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
1449 ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
1456 ND_PRINT((ndo, ", cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
1460 ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
1464 ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
1467 if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, entry_len - OF_FLOW_STATS_LEN)))
1468 return ep; /* end of snapshot */
1474 corrupt: /* skip the rest of flow statistics entries */
1475 ND_PRINT((ndo, "%s", cstr));
1476 ND_TCHECK2(*cp0, len0);
1479 ND_PRINT((ndo, "%s", tstr));
1484 static const u_char *
1485 of10_aggregate_stats_reply_print(netdissect_options *ndo,
1486 const u_char *cp, const u_char *ep,
1488 if (len != OF_AGGREGATE_STATS_REPLY_LEN)
1492 ND_PRINT((ndo, "\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp)));
1496 ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
1500 ND_PRINT((ndo, ", flow_count %u", EXTRACT_32BITS(cp)));
1506 corrupt: /* skip the message body */
1507 ND_PRINT((ndo, "%s", cstr));
1508 ND_TCHECK2(*cp, len);
1511 ND_PRINT((ndo, "%s", tstr));
1516 static const u_char *
1517 of10_table_stats_reply_print(netdissect_options *ndo,
1518 const u_char *cp, const u_char *ep, u_int len) {
1519 const u_char *cp0 = cp;
1520 const u_int len0 = len;
1523 if (len < OF_TABLE_STATS_LEN)
1527 ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
1533 ND_TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
1534 ND_PRINT((ndo, ", name '"));
1535 fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
1536 ND_PRINT((ndo, "'"));
1537 cp += OFP_MAX_TABLE_NAME_LEN;
1540 ND_PRINT((ndo, "\n\t wildcards 0x%08x", EXTRACT_32BITS(cp)));
1541 of10_bitmap_print(ndo, ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
1545 ND_PRINT((ndo, "\n\t max_entries %u", EXTRACT_32BITS(cp)));
1549 ND_PRINT((ndo, ", active_count %u", EXTRACT_32BITS(cp)));
1553 ND_PRINT((ndo, ", lookup_count %" PRIu64, EXTRACT_64BITS(cp)));
1557 ND_PRINT((ndo, ", matched_count %" PRIu64, EXTRACT_64BITS(cp)));
1560 len -= OF_TABLE_STATS_LEN;
1564 corrupt: /* skip the undersized trailing data */
1565 ND_PRINT((ndo, "%s", cstr));
1566 ND_TCHECK2(*cp0, len0);
1569 ND_PRINT((ndo, "%s", tstr));
1574 static const u_char *
1575 of10_port_stats_reply_print(netdissect_options *ndo,
1576 const u_char *cp, const u_char *ep, u_int len) {
1577 const u_char *cp0 = cp;
1578 const u_int len0 = len;
1581 if (len < OF_PORT_STATS_LEN)
1585 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1587 if (ndo->ndo_vflag < 2) {
1588 ND_TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
1589 cp += OF_PORT_STATS_LEN - 2;
1597 ND_PRINT((ndo, ", rx_packets %" PRIu64, EXTRACT_64BITS(cp)));
1601 ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
1605 ND_PRINT((ndo, ", rx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
1609 ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
1613 ND_PRINT((ndo, ", rx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
1617 ND_PRINT((ndo, ", tx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
1621 ND_PRINT((ndo, ", rx_errors %" PRIu64, EXTRACT_64BITS(cp)));
1625 ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
1629 ND_PRINT((ndo, ", rx_frame_err %" PRIu64, EXTRACT_64BITS(cp)));
1633 ND_PRINT((ndo, ", rx_over_err %" PRIu64, EXTRACT_64BITS(cp)));
1637 ND_PRINT((ndo, ", rx_crc_err %" PRIu64, EXTRACT_64BITS(cp)));
1641 ND_PRINT((ndo, ", collisions %" PRIu64, EXTRACT_64BITS(cp)));
1644 len -= OF_PORT_STATS_LEN;
1648 corrupt: /* skip the undersized trailing data */
1649 ND_PRINT((ndo, "%s", cstr));
1650 ND_TCHECK2(*cp0, len0);
1653 ND_PRINT((ndo, "%s", tstr));
1658 static const u_char *
1659 of10_queue_stats_reply_print(netdissect_options *ndo,
1660 const u_char *cp, const u_char *ep, u_int len) {
1661 const u_char *cp0 = cp;
1662 const u_int len0 = len;
1665 if (len < OF_QUEUE_STATS_LEN)
1669 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1676 ND_PRINT((ndo, ", queue_id %u", EXTRACT_32BITS(cp)));
1680 ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
1684 ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
1688 ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
1691 len -= OF_QUEUE_STATS_LEN;
1695 corrupt: /* skip the undersized trailing data */
1696 ND_PRINT((ndo, "%s", cstr));
1697 ND_TCHECK2(*cp0, len0);
1700 ND_PRINT((ndo, "%s", tstr));
1705 static const u_char *
1706 of10_stats_reply_print(netdissect_options *ndo,
1707 const u_char *cp, const u_char *ep, const u_int len) {
1708 const u_char *cp0 = cp;
1713 type = EXTRACT_16BITS(cp);
1714 ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
1718 ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
1719 of10_bitmap_print(ndo, ofpsf_reply_bm, EXTRACT_16BITS(cp), OFPSF_REPLY_U);
1722 if (ndo->ndo_vflag > 0) {
1723 const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int) =
1724 type == OFPST_DESC ? of10_desc_stats_reply_print :
1725 type == OFPST_FLOW ? of10_flow_stats_reply_print :
1726 type == OFPST_AGGREGATE ? of10_aggregate_stats_reply_print :
1727 type == OFPST_TABLE ? of10_table_stats_reply_print :
1728 type == OFPST_PORT ? of10_port_stats_reply_print :
1729 type == OFPST_QUEUE ? of10_queue_stats_reply_print :
1730 type == OFPST_VENDOR ? of10_vendor_data_print :
1732 if (decoder != NULL)
1733 return decoder(ndo, cp, ep, len - OF_STATS_REPLY_LEN);
1735 ND_TCHECK2(*cp0, len);
1739 ND_PRINT((ndo, "%s", tstr));
1743 /* [OF10] Section 5.3.6 */
1744 static const u_char *
1745 of10_packet_out_print(netdissect_options *ndo,
1746 const u_char *cp, const u_char *ep, const u_int len) {
1747 const u_char *cp0 = cp;
1748 const u_int len0 = len;
1749 uint16_t actions_len;
1753 ND_PRINT((ndo, "\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp)));
1757 ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1761 actions_len = EXTRACT_16BITS(cp);
1763 if (actions_len > len - OF_PACKET_OUT_LEN)
1766 if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, actions_len)))
1767 return ep; /* end of snapshot */
1769 return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
1771 corrupt: /* skip the rest of the message body */
1772 ND_PRINT((ndo, "%s", cstr));
1773 ND_TCHECK2(*cp0, len0);
1776 ND_PRINT((ndo, "%s", tstr));
1780 /* [OF10] Section 5.4.1 */
1781 static const u_char *
1782 of10_packet_in_print(netdissect_options *ndo,
1783 const u_char *cp, const u_char *ep, const u_int len) {
1786 ND_PRINT((ndo, "\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
1790 ND_PRINT((ndo, ", total_len %u", EXTRACT_16BITS(cp)));
1794 ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1798 ND_PRINT((ndo, ", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp)));
1804 /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
1805 return of10_packet_data_print(ndo, cp, ep, len - (OF_PACKET_IN_LEN - 2));
1808 ND_PRINT((ndo, "%s", tstr));
1812 /* [OF10] Section 5.4.2 */
1813 static const u_char *
1814 of10_flow_removed_print(netdissect_options *ndo,
1815 const u_char *cp, const u_char *ep) {
1817 if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
1818 return ep; /* end of snapshot */
1821 ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
1825 if (EXTRACT_16BITS(cp))
1826 ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
1830 ND_PRINT((ndo, ", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp)));
1837 ND_PRINT((ndo, ", duration_sec %u", EXTRACT_32BITS(cp)));
1841 ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
1845 if (EXTRACT_16BITS(cp))
1846 ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
1853 ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
1857 ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
1861 ND_PRINT((ndo, "%s", tstr));
1865 /* [OF10] Section 5.4.4 */
1866 static const u_char *
1867 of10_error_print(netdissect_options *ndo,
1868 const u_char *cp, const u_char *ep, const u_int len) {
1870 const struct tok *code_str;
1874 type = EXTRACT_16BITS(cp);
1876 ND_PRINT((ndo, "\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type)));
1880 type == OFPET_HELLO_FAILED ? ofphfc_str :
1881 type == OFPET_BAD_REQUEST ? ofpbrc_str :
1882 type == OFPET_BAD_ACTION ? ofpbac_str :
1883 type == OFPET_FLOW_MOD_FAILED ? ofpfmfc_str :
1884 type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
1885 type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
1887 ND_PRINT((ndo, ", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
1890 return of10_data_print(ndo, cp, ep, len - OF_ERROR_MSG_LEN);
1893 ND_PRINT((ndo, "%s", tstr));
1898 of10_header_body_print(netdissect_options *ndo,
1899 const u_char *cp, const u_char *ep, const uint8_t type,
1900 const uint16_t len, const uint32_t xid) {
1901 const u_char *cp0 = cp;
1902 const u_int len0 = len;
1903 /* Thus far message length is not less than the basic header size, but most
1904 * message types have additional assorted constraints on the length. Wherever
1905 * possible, check that message length meets the constraint, in remaining
1906 * cases check that the length is OK to begin decoding and leave any final
1907 * verification up to a lower-layer function. When the current message is
1908 * corrupt, proceed to the next message. */
1910 /* [OF10] Section 5.1 */
1911 ND_PRINT((ndo, "\n\tversion 1.0, type %s, length %u, xid 0x%08x",
1912 tok2str(ofpt_str, "invalid (0x%02x)", type), len, xid));
1914 /* OpenFlow header only. */
1915 case OFPT_FEATURES_REQUEST: /* [OF10] Section 5.3.1 */
1916 case OFPT_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.2 */
1917 case OFPT_BARRIER_REQUEST: /* [OF10] Section 5.3.7 */
1918 case OFPT_BARRIER_REPLY: /* ibid */
1919 if (len != OF_HEADER_LEN)
1923 /* OpenFlow header and fixed-size message body. */
1924 case OFPT_SET_CONFIG: /* [OF10] Section 5.3.2 */
1925 case OFPT_GET_CONFIG_REPLY: /* ibid */
1926 if (len != OF_SWITCH_CONFIG_LEN)
1928 if (ndo->ndo_vflag < 1)
1932 ND_PRINT((ndo, "\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
1936 ND_PRINT((ndo, ", miss_send_len %u", EXTRACT_16BITS(cp)));
1939 if (len != OF_PORT_MOD_LEN)
1941 if (ndo->ndo_vflag < 1)
1943 return of10_port_mod_print(ndo, cp, ep);
1944 case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */
1945 if (len != OF_QUEUE_GET_CONFIG_REQUEST_LEN)
1947 if (ndo->ndo_vflag < 1)
1951 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
1956 case OFPT_FLOW_REMOVED:
1957 if (len != OF_FLOW_REMOVED_LEN)
1959 if (ndo->ndo_vflag < 1)
1961 return of10_flow_removed_print(ndo, cp, ep);
1962 case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */
1963 if (len != OF_PORT_STATUS_LEN)
1965 if (ndo->ndo_vflag < 1)
1969 ND_PRINT((ndo, "\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", *cp)));
1975 return of10_phy_ports_print(ndo, cp, ep, OF_PHY_PORT_LEN);
1977 /* OpenFlow header, fixed-size message body and n * fixed-size data units. */
1978 case OFPT_FEATURES_REPLY:
1979 if (len < OF_SWITCH_FEATURES_LEN)
1981 if (ndo->ndo_vflag < 1)
1983 return of10_features_reply_print(ndo, cp, ep, len);
1985 /* OpenFlow header and variable-size data. */
1986 case OFPT_HELLO: /* [OF10] Section 5.5.1 */
1987 case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */
1988 case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */
1989 if (ndo->ndo_vflag < 1)
1991 return of10_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
1993 /* OpenFlow header, fixed-size message body and variable-size data. */
1995 if (len < OF_ERROR_MSG_LEN)
1997 if (ndo->ndo_vflag < 1)
1999 return of10_error_print(ndo, cp, ep, len);
2001 /* [OF10] Section 5.5.4 */
2002 if (len < OF_VENDOR_HEADER_LEN)
2004 if (ndo->ndo_vflag < 1)
2006 return of10_vendor_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
2007 case OFPT_PACKET_IN:
2008 /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
2009 if (len < OF_PACKET_IN_LEN - 2)
2011 if (ndo->ndo_vflag < 1)
2013 return of10_packet_in_print(ndo, cp, ep, len);
2015 /* a. OpenFlow header. */
2016 /* b. OpenFlow header and one of the fixed-size message bodies. */
2017 /* c. OpenFlow header, fixed-size message body and variable-size data. */
2018 case OFPT_STATS_REQUEST:
2019 if (len < OF_STATS_REQUEST_LEN)
2021 if (ndo->ndo_vflag < 1)
2023 return of10_stats_request_print(ndo, cp, ep, len);
2025 /* a. OpenFlow header and fixed-size message body. */
2026 /* b. OpenFlow header and n * fixed-size data units. */
2027 /* c. OpenFlow header and n * variable-size data units. */
2028 /* d. OpenFlow header, fixed-size message body and variable-size data. */
2029 case OFPT_STATS_REPLY:
2030 if (len < OF_STATS_REPLY_LEN)
2032 if (ndo->ndo_vflag < 1)
2034 return of10_stats_reply_print(ndo, cp, ep, len);
2036 /* OpenFlow header and n * variable-size data units and variable-size data. */
2037 case OFPT_PACKET_OUT:
2038 if (len < OF_PACKET_OUT_LEN)
2040 if (ndo->ndo_vflag < 1)
2042 return of10_packet_out_print(ndo, cp, ep, len);
2044 /* OpenFlow header, fixed-size message body and n * variable-size data units. */
2046 if (len < OF_FLOW_MOD_LEN)
2048 if (ndo->ndo_vflag < 1)
2050 return of10_flow_mod_print(ndo, cp, ep, len);
2052 /* OpenFlow header, fixed-size message body and n * variable-size data units. */
2053 case OFPT_QUEUE_GET_CONFIG_REPLY: /* [OF10] Section 5.3.4 */
2054 if (len < OF_QUEUE_GET_CONFIG_REPLY_LEN)
2056 if (ndo->ndo_vflag < 1)
2060 ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
2066 return of10_queues_print(ndo, cp, ep, len - OF_QUEUE_GET_CONFIG_REPLY_LEN);
2067 } /* switch (type) */
2070 corrupt: /* skip the message body */
2071 ND_PRINT((ndo, "%s", cstr));
2073 ND_TCHECK2(*cp0, len0 - OF_HEADER_LEN);
2074 return cp0 + len0 - OF_HEADER_LEN;
2076 ND_PRINT((ndo, "%s", tstr));