13c602fabSXin LI /* 23c602fabSXin LI * Copyright (c) 2013 The TCPDUMP project 33c602fabSXin LI * All rights reserved. 43c602fabSXin LI * 53c602fabSXin LI * Redistribution and use in source and binary forms, with or without 63c602fabSXin LI * modification, are permitted provided that the following conditions 73c602fabSXin LI * are met: 83c602fabSXin LI * 1. Redistributions of source code must retain the above copyright 93c602fabSXin LI * notice, this list of conditions and the following disclaimer. 103c602fabSXin LI * 2. Redistributions in binary form must reproduce the above copyright 113c602fabSXin LI * notice, this list of conditions and the following disclaimer in the 123c602fabSXin LI * documentation and/or other materials provided with the distribution. 133c602fabSXin LI * 143c602fabSXin LI * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 153c602fabSXin LI * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 163c602fabSXin LI * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 173c602fabSXin LI * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 183c602fabSXin LI * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 193c602fabSXin LI * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 203c602fabSXin LI * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 213c602fabSXin LI * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 223c602fabSXin LI * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 233c602fabSXin LI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 243c602fabSXin LI * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 253c602fabSXin LI * POSSIBILITY OF SUCH DAMAGE. 263c602fabSXin LI */ 273c602fabSXin LI 283c602fabSXin LI /* OpenFlow: protocol between controller and datapath. */ 293c602fabSXin LI 303c602fabSXin LI /* for netdissect_options */ 313c602fabSXin LI #include "netdissect.h" 323c602fabSXin LI 33*ee67461eSJoseph Mingrone #define OF_FWD(n) { \ 34*ee67461eSJoseph Mingrone cp += (n); \ 35*ee67461eSJoseph Mingrone len -= (n); \ 36*ee67461eSJoseph Mingrone } 37*ee67461eSJoseph Mingrone 38*ee67461eSJoseph Mingrone #define OF_CHK_FWD(n) { \ 39*ee67461eSJoseph Mingrone ND_TCHECK_LEN(cp, (n)); \ 40*ee67461eSJoseph Mingrone cp += (n); \ 41*ee67461eSJoseph Mingrone len -= (n); \ 42*ee67461eSJoseph Mingrone } 43*ee67461eSJoseph Mingrone 44*ee67461eSJoseph Mingrone #define OF_VER_1_0 0x01U 45*ee67461eSJoseph Mingrone #define OF_VER_1_1 0x02U 46*ee67461eSJoseph Mingrone #define OF_VER_1_2 0x03U 47*ee67461eSJoseph Mingrone #define OF_VER_1_3 0x04U 48*ee67461eSJoseph Mingrone #define OF_VER_1_4 0x05U 49*ee67461eSJoseph Mingrone #define OF_VER_1_5 0x06U 50*ee67461eSJoseph Mingrone 51*ee67461eSJoseph Mingrone #define OF_HEADER_FIXLEN 8U 523c602fabSXin LI 538bdc5a62SPatrick Kelsey #define ONF_EXP_ONF 0x4f4e4600 548bdc5a62SPatrick Kelsey #define ONF_EXP_BUTE 0xff000001 558bdc5a62SPatrick Kelsey #define ONF_EXP_NOVIFLOW 0xff000002 568bdc5a62SPatrick Kelsey #define ONF_EXP_L3 0xff000003 578bdc5a62SPatrick Kelsey #define ONF_EXP_L4L7 0xff000004 588bdc5a62SPatrick Kelsey #define ONF_EXP_WMOB 0xff000005 598bdc5a62SPatrick Kelsey #define ONF_EXP_FABS 0xff000006 608bdc5a62SPatrick Kelsey #define ONF_EXP_OTRANS 0xff000007 61*ee67461eSJoseph Mingrone #define ONF_EXP_NBLNCTU 0xff000008 62*ee67461eSJoseph Mingrone #define ONF_EXP_MPCE 0xff000009 63*ee67461eSJoseph Mingrone #define ONF_EXP_MPLSTPSPTN 0xff00000a 648bdc5a62SPatrick Kelsey extern const struct tok onf_exp_str[]; 658bdc5a62SPatrick Kelsey 668bdc5a62SPatrick Kelsey extern const char * of_vendor_name(const uint32_t); 67*ee67461eSJoseph Mingrone extern void of_bitmap_print(netdissect_options *ndo, 68*ee67461eSJoseph Mingrone const struct tok *, const uint32_t, const uint32_t); 69*ee67461eSJoseph Mingrone extern void of_data_print(netdissect_options *ndo, 70*ee67461eSJoseph Mingrone const u_char *, const u_int); 71*ee67461eSJoseph Mingrone 72*ee67461eSJoseph Mingrone /* 73*ee67461eSJoseph Mingrone * Routines to handle various versions of OpenFlow. 74*ee67461eSJoseph Mingrone */ 75*ee67461eSJoseph Mingrone 76*ee67461eSJoseph Mingrone struct of_msgtypeinfo { 77*ee67461eSJoseph Mingrone /* Should not be NULL. */ 78*ee67461eSJoseph Mingrone const char *name; 79*ee67461eSJoseph Mingrone /* May be NULL to mean "message body printing is not implemented". */ 80*ee67461eSJoseph Mingrone void (*decoder)(netdissect_options *ndo, const u_char *, const u_int); 81*ee67461eSJoseph Mingrone enum { 82*ee67461eSJoseph Mingrone REQ_NONE, /* Message body length may be anything. */ 83*ee67461eSJoseph Mingrone REQ_FIXLEN, /* Message body length must be == req_value. */ 84*ee67461eSJoseph Mingrone REQ_MINLEN, /* Message body length must be >= req_value. */ 85*ee67461eSJoseph Mingrone } req_what; 86*ee67461eSJoseph Mingrone uint16_t req_value; 87*ee67461eSJoseph Mingrone }; 88*ee67461eSJoseph Mingrone 89*ee67461eSJoseph Mingrone extern const struct of_msgtypeinfo *of10_identify_msgtype(const uint8_t); 90*ee67461eSJoseph Mingrone extern const struct of_msgtypeinfo *of13_identify_msgtype(const uint8_t); 91