xref: /dflybsd-src/contrib/tcpdump/openflow.h (revision 59c07fbdf8168fa08c76c515186d561b5a92690c)
1411677aeSAaron LI /*
2411677aeSAaron LI  * Copyright (c) 2013 The TCPDUMP project
3411677aeSAaron LI  * All rights reserved.
4411677aeSAaron LI  *
5411677aeSAaron LI  * Redistribution and use in source and binary forms, with or without
6411677aeSAaron LI  * modification, are permitted provided that the following conditions
7411677aeSAaron LI  * are met:
8411677aeSAaron LI  * 1. Redistributions of source code must retain the above copyright
9411677aeSAaron LI  *    notice, this list of conditions and the following disclaimer.
10411677aeSAaron LI  * 2. Redistributions in binary form must reproduce the above copyright
11411677aeSAaron LI  *    notice, this list of conditions and the following disclaimer in the
12411677aeSAaron LI  *    documentation and/or other materials provided with the distribution.
13411677aeSAaron LI  *
14411677aeSAaron LI  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15411677aeSAaron LI  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16411677aeSAaron LI  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17411677aeSAaron LI  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
18411677aeSAaron LI  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19411677aeSAaron LI  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20411677aeSAaron LI  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21411677aeSAaron LI  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22411677aeSAaron LI  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23411677aeSAaron LI  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24411677aeSAaron LI  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25411677aeSAaron LI  * POSSIBILITY OF SUCH DAMAGE.
26411677aeSAaron LI  */
27411677aeSAaron LI 
28411677aeSAaron LI /* OpenFlow: protocol between controller and datapath. */
29411677aeSAaron LI 
30411677aeSAaron LI /* for netdissect_options */
31411677aeSAaron LI #include "netdissect.h"
32411677aeSAaron LI 
33*ed775ee7SAntonio Huete Jimenez #define OF_FWD(n) { \
34*ed775ee7SAntonio Huete Jimenez 	cp += (n); \
35*ed775ee7SAntonio Huete Jimenez 	len -= (n); \
36*ed775ee7SAntonio Huete Jimenez }
37*ed775ee7SAntonio Huete Jimenez 
38*ed775ee7SAntonio Huete Jimenez #define OF_CHK_FWD(n) { \
39*ed775ee7SAntonio Huete Jimenez 	ND_TCHECK_LEN(cp, (n)); \
40*ed775ee7SAntonio Huete Jimenez 	cp += (n); \
41*ed775ee7SAntonio Huete Jimenez 	len -= (n); \
42*ed775ee7SAntonio Huete Jimenez }
43*ed775ee7SAntonio Huete Jimenez 
44*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_0 0x01U
45*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_1 0x02U
46*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_2 0x03U
47*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_3 0x04U
48*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_4 0x05U
49*ed775ee7SAntonio Huete Jimenez #define OF_VER_1_5 0x06U
50*ed775ee7SAntonio Huete Jimenez 
51*ed775ee7SAntonio Huete Jimenez #define OF_HEADER_FIXLEN 8U
52411677aeSAaron LI 
53411677aeSAaron LI #define ONF_EXP_ONF               0x4f4e4600
54411677aeSAaron LI #define ONF_EXP_BUTE              0xff000001
55411677aeSAaron LI #define ONF_EXP_NOVIFLOW          0xff000002
56411677aeSAaron LI #define ONF_EXP_L3                0xff000003
57411677aeSAaron LI #define ONF_EXP_L4L7              0xff000004
58411677aeSAaron LI #define ONF_EXP_WMOB              0xff000005
59411677aeSAaron LI #define ONF_EXP_FABS              0xff000006
60411677aeSAaron LI #define ONF_EXP_OTRANS            0xff000007
61*ed775ee7SAntonio Huete Jimenez #define ONF_EXP_NBLNCTU           0xff000008
62*ed775ee7SAntonio Huete Jimenez #define ONF_EXP_MPCE              0xff000009
63*ed775ee7SAntonio Huete Jimenez #define ONF_EXP_MPLSTPSPTN        0xff00000a
64411677aeSAaron LI extern const struct tok onf_exp_str[];
65411677aeSAaron LI 
66411677aeSAaron LI extern const char * of_vendor_name(const uint32_t);
67*ed775ee7SAntonio Huete Jimenez extern void of_bitmap_print(netdissect_options *ndo,
68*ed775ee7SAntonio Huete Jimenez 	const struct tok *, const uint32_t, const uint32_t);
69*ed775ee7SAntonio Huete Jimenez extern void of_data_print(netdissect_options *ndo,
70*ed775ee7SAntonio Huete Jimenez 	const u_char *, const u_int);
71*ed775ee7SAntonio Huete Jimenez 
72*ed775ee7SAntonio Huete Jimenez /*
73*ed775ee7SAntonio Huete Jimenez  * Routines to handle various versions of OpenFlow.
74*ed775ee7SAntonio Huete Jimenez  */
75*ed775ee7SAntonio Huete Jimenez 
76*ed775ee7SAntonio Huete Jimenez struct of_msgtypeinfo {
77*ed775ee7SAntonio Huete Jimenez 	/* Should not be NULL. */
78*ed775ee7SAntonio Huete Jimenez 	const char *name;
79*ed775ee7SAntonio Huete Jimenez 	/* May be NULL to mean "message body printing is not implemented". */
80*ed775ee7SAntonio Huete Jimenez 	void (*decoder)(netdissect_options *ndo, const u_char *, const u_int);
81*ed775ee7SAntonio Huete Jimenez 	enum {
82*ed775ee7SAntonio Huete Jimenez 		REQ_NONE,   /* Message body length may be anything. */
83*ed775ee7SAntonio Huete Jimenez 		REQ_FIXLEN, /* Message body length must be == req_value. */
84*ed775ee7SAntonio Huete Jimenez 		REQ_MINLEN, /* Message body length must be >= req_value. */
85*ed775ee7SAntonio Huete Jimenez 	} req_what;
86*ed775ee7SAntonio Huete Jimenez 	uint16_t req_value;
87*ed775ee7SAntonio Huete Jimenez };
88*ed775ee7SAntonio Huete Jimenez 
89*ed775ee7SAntonio Huete Jimenez extern const struct of_msgtypeinfo *of10_identify_msgtype(const uint8_t);
90*ed775ee7SAntonio Huete Jimenez extern const struct of_msgtypeinfo *of13_identify_msgtype(const uint8_t);
91