Changeset 3fc3267 for lib/libtrace.h.in


Ignore:
Timestamp:
02/02/15 16:59:34 (7 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
3440627
Parents:
68d3308
Message:

Add protocol decoder functions for GRE and VXLAN

Many thanks to Perry Lorier for providing this patch.

Includes a test-case for VXLAN parsing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    ra2ce0a6 r3fc3267  
    810810} PACKED libtrace_pppoe_t;
    811811
     812/** Libtrace local definition of GRE (Generalised Routing Protocol) header
     813 * RFC2890
     814 */
     815typedef struct libtrace_gre_t
     816{
     817    uint16_t flags;         /**< Flags and version */
     818    uint16_t ethertype;     /**< Payload ethertype */
     819    uint16_t checksum;      /**< Optional checksum */
     820    uint16_t reserved1;     /**< Optional reserved */
     821    uint16_t key;           /**< Optional key (or Tenant Network ID) */
     822    uint16_t seq;           /**< Optional sequence number */
     823} PACKED libtrace_gre_t;
     824
     825#define LIBTRACE_GRE_FLAG_CHECKSUM 0x8000
     826#define LIBTRACE_GRE_FLAG_KEY      0x2000
     827#define LIBTRACE_GRE_FLAG_SEQ      0x1000
     828#define LIBTRACE_GRE_FLAG_VERMASK  0x0007
     829
     830/** Libtrace local definition of VXLAN Header
     831 * (draft-mahalingam-dutt-dcops-vxlan)
     832 */
     833typedef struct libtrace_vxlan_t
     834{
     835    uint8_t flags;          /**< Flags */
     836    uint8_t reserved1[3];   /**< Reserved */
     837    uint8_t vni[3];         /**< VXLAN Network Identifier (VNI) */
     838    uint8_t reserved2;
     839} PACKED libtrace_vxlan_t;
     840
    812841/** 802.11 header */
    813842typedef struct libtrace_80211_t {
     
    20732102                uint32_t *remaining);
    20742103
     2104/** Gets a pointer to the payload following a GRE header
     2105 * @param         gre       A pointer to the beginning of the GRE header.
     2106 * @param[in,out] remaining Updated with the number of captured bytes remaining.
     2107 *
     2108 * @return A pointer to the GRE payload, or NULL if the GRE header is truncated.
     2109 *
     2110 * When calling this function, remaining must contain the number of captured
     2111 * bytes remaining in the packet starting from the GRE header (including the
     2112 * GRE header itself). remaining will be updated to contain the number of
     2113 * bytes remaining after the GRE header has been skipped.
     2114 *
     2115 * If the GRE header is complete but there are zero bytes of payload after
     2116 * the header, a pointer to where the payload would be is returned and
     2117 * remaining will be set to 0.  If the GRE header is incomplete, NULL will be
     2118 * returned and remaining will be set to 0. Therefore, it is important to check
     2119 * the value of remaining after calling this function.
     2120 */
     2121DLLEXPORT void *trace_get_payload_from_gre(libtrace_gre_t *gre,
     2122                uint32_t *remaining);
     2123
     2124/** Gets a pointer to the payload following a VXLAN header
     2125 * @param         udp       A pointer to the beginning of the UDP header.
     2126 * @param[in,out] remaining Updated with the number of captured bytes remaining.
     2127 *
     2128 * @return A pointer to the beginning of the VXLAN header, or NULL if the UDP
     2129 * header is truncated, or this is not a VXLAN packet.
     2130 *
     2131 */
     2132DLLEXPORT libtrace_vxlan_t *trace_get_vxlan_from_udp(libtrace_udp_t *udp,
     2133                uint32_t *remaining);
     2134
     2135/** Gets a pointer to the payload following a VXLAN header
     2136 * @param         vxlan       A pointer to the beginning of the VXLAN header.
     2137 * @param[in,out] remaining Updated with the number of captured bytes remaining.
     2138 *
     2139 * @return A pointer to the VXLAN payload, or NULL if the VXLAN header is
     2140 * truncated.
     2141 *
     2142 * When calling this function, remaining must contain the number of captured
     2143 * bytes remaining in the packet starting from the VXLAN header (including the
     2144 * VXLAN header itself). remaining will be updated to contain the number of
     2145 * bytes remaining after the VXLAN header has been skipped.
     2146 *
     2147 * If the VXLAN header is complete but there are zero bytes of payload after
     2148 * the header, a pointer to where the payload would be is returned and
     2149 * remaining will be set to 0.  If the VXLAN header is incomplete, NULL will be
     2150 * returned and remaining will be set to 0. Therefore, it is important to check
     2151 * the value of remaining after calling this function.
     2152 */
     2153DLLEXPORT void *trace_get_payload_from_vxlan(libtrace_vxlan_t *vxlan,
     2154                uint32_t *remaining);
     2155
    20752156/** Get a pointer to the TCP header (if present)
    20762157 * @param packet        The packet to get the TCP header from
Note: See TracChangeset for help on using the changeset viewer.