Ignore:
Timestamp:
02/02/15 16:59:34 (6 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/protocols_transport.c

    re0bea4e5 r3fc3267  
    553553        return csum_ptr;
    554554}
     555
     556DLLEXPORT void *trace_get_payload_from_gre(libtrace_gre_t *gre,
     557        uint32_t *remaining)
     558{
     559    uint32_t size = 4; /* GRE is 4 bytes long by default */
     560    if (remaining && *remaining < size) {
     561        *remaining = 0;
     562        return NULL;
     563    }
     564
     565    if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_CHECKSUM) != 0) {
     566        size += 4;  /* An extra 4 bytes. */
     567    }
     568
     569    if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_KEY) != 0) {
     570        size += 4;  /* An extra 4 bytes. */
     571    }
     572
     573    if ((ntohs(gre->flags) & LIBTRACE_GRE_FLAG_SEQ) != 0) {
     574        size += 4;  /* An extra 4 bytes. */
     575    }
     576
     577    if (remaining) {
     578        if (*remaining < size) {
     579            *remaining = 0;
     580            return NULL;
     581        }
     582        *remaining -= size;
     583    }
     584    return (char*)gre+size;
     585}
Note: See TracChangeset for help on using the changeset viewer.