Changeset b13caea for lib/format_erf.c


Ignore:
Timestamp:
08/06/15 17:41:06 (5 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:
c24de65
Parents:
fc0325e
Message:

Add support for ERF extension headers

At the moment, we don't actually look at them but we need to:

  • recognise that they are present so we can skip past them
  • not use the MSB of the type field when evaluating the type packet as this has now been re-purposed for indicating the presence of extension headers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    rc69aecb rb13caea  
    4949#include <string.h>
    5050#include <stdlib.h>
     51
    5152
    5253#ifdef WIN32
     
    135136        if (packet->trace->format->type==TRACE_FORMAT_ERF) {
    136137                dag_record_t *erfptr = (dag_record_t *)packet->header;
    137                 switch(erfptr->type) {
     138                switch((erfptr->type & 0x7f)) {
    138139                        case TYPE_ETH:         
    139140                        case TYPE_DSM_COLOR_ETH:
     
    152153int erf_get_framing_length(const libtrace_packet_t *packet)
    153154{
    154         return dag_record_size + erf_get_padding(packet);
     155        uint16_t extsize = 0;
     156        dag_record_t *erfptr = NULL;
     157        uint64_t *exthdr = NULL;
     158       
     159        erfptr = (dag_record_t *)packet->header;
     160        if ((erfptr->type & 0x80) == 0x80) {
     161                /* Extension headers are present */
     162                exthdr = (uint64_t *)((char *)packet->header + dag_record_size);
     163                extsize += 8;
     164
     165                while (*exthdr < (1UL << 31)) {
     166                        extsize += 8;
     167                        exthdr ++;
     168                        assert(extsize <= ntohs(erfptr->rlen));
     169                }
     170        }
     171       
     172
     173        return dag_record_size + extsize + erf_get_padding(packet);
    155174}
    156175
     
    186205        }
    187206        /* Is this a proper typed packet */
    188         if (erf->type > TYPE_AAL2) {
     207        if ((erf->type & 0x7f) > TYPE_AAL2) {
    189208                return 0;
    190209        }
     
    448467
    449468        /* Check for loss */
    450         if (erfptr->type == TYPE_DSM_COLOR_ETH) {
     469        if ((erfptr->type & 0x7f) == TYPE_DSM_COLOR_ETH) {
    451470                /* No idea how we get this yet */
    452471
     
    505524
    506525        /* Unknown/corrupt */
    507         if (((dag_record_t *)packet->buffer)->type >= TYPE_RAW_LINK) {
     526        if ((((dag_record_t *)packet->buffer)->type & 0x7f) >= TYPE_RAW_LINK) {
    508527                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
    509528                                "Corrupt or Unknown ERF type");
     
    684703        dag_record_t *erfptr = 0;
    685704        erfptr = (dag_record_t *)packet->header;
    686         if (erfptr->type != TYPE_LEGACY)
    687                 return erf_type_to_libtrace(erfptr->type);
     705        uint8_t type = (erfptr->type & 0x7f);
     706        if (type != TYPE_LEGACY) {
     707                /* The top-most bit is now used to indicate the presence of
     708                 * extension headers :/ */
     709                return erf_type_to_libtrace(type);
     710        }
    688711        else {
    689712                /* Sigh, lets start wildly guessing */
Note: See TracChangeset for help on using the changeset viewer.