/* * This module implements decoding of OpenFlow protocol version 1.0 (wire * protocol 0x01). The decoder implements terse (default), detailed (-v) and * full (-vv) output formats and, as much as each format implies, detects and * tries to work around sizing anomalies inside the messages. The decoder marks * up bogus values of selected message fields and decodes partially captured * messages up to the snapshot end. It is based on the specification below: * * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf * * Most functions in this file take 3 arguments into account: * * cp -- the pointer to the first octet to decode * * len -- the length of the current structure as declared on the wire * * ep -- the pointer to the end of the captured frame * They return either the pointer to the next not-yet-decoded part of the frame * or the value of ep, which means the current frame processing is over as it * has been fully decoded or is invalid or truncated. This way it is possible * to chain and nest such functions uniformly to decode an OF1.0 message, which * consists of several layers of nested structures. * * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT * messages is done only when the verbosity level set by command-line argument * is "-vvv" or higher. In that case the verbosity level is temporarily * decremented by 3 during the nested frame decoding. For example, running * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of * the nested frames. * * Partial decoding of Big Switch Networks vendor extensions is done after the * oftest (OpenFlow Testing Framework) and Loxigen (library generator) source * code. * * * Copyright (c) 2013 The TCPDUMP project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "ether.h" #include "ethertype.h" #include "ipproto.h" #include "oui.h" #include "openflow.h" static const char tstr[] = " [|openflow]"; static const char istr[] = " (invalid)"; #define OFPT_HELLO 0x00 #define OFPT_ERROR 0x01 #define OFPT_ECHO_REQUEST 0x02 #define OFPT_ECHO_REPLY 0x03 #define OFPT_VENDOR 0x04 #define OFPT_FEATURES_REQUEST 0x05 #define OFPT_FEATURES_REPLY 0x06 #define OFPT_GET_CONFIG_REQUEST 0x07 #define OFPT_GET_CONFIG_REPLY 0x08 #define OFPT_SET_CONFIG 0x09 #define OFPT_PACKET_IN 0x0a #define OFPT_FLOW_REMOVED 0x0b #define OFPT_PORT_STATUS 0x0c #define OFPT_PACKET_OUT 0x0d #de