Changeset a857389 for lib/format_erf.c


Ignore:
Timestamp:
02/15/18 17:59:50 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
5a70a80
Parents:
3004d6c
git-author:
Anthony Coddington <anthony.coddington@…> (02/14/18 16:03:04)
git-committer:
Shane Alcock <salcock@…> (02/15/18 17:59:50)
Message:

Initial support for ERF provenance records

Update erftypes.h with TYPE_META (27).
Check for ERF_TYPE_MAX rather than some arbitrary type in ERF sanity checks. In Wireshark we recently completely removed these checks as there are only a few types before TYPE_PAD/ERF_TYPE_MAX, but leave them in for now.
Add TRACE_TYPE_ERF_META for provenance record payload.
Continue to use TRACE_RT_DATA_ERF as provenance is a valid ERF record. Note: this means that LIBTRACE_IS_META_PACKET() will currently return FALSE which may confuse some tools. Other places in the code also tend to check for TRACE_TYPE_NONDATA which isn't true here either.
Return zero for wire length of provenance records.
Don't allow snapping them (just return the same value).
Skip provenance records in l2 parsers and trace_get_payload_from_meta().
Return provenance payload for trace_get_packet_meta().

Also add support for a couple of missing ERF_TYPE_ETH_COLOR variants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r7ff881a ra857389  
    120120} erf_index_t;
    121121
    122 
    123122/* Ethernet packets have a 2 byte padding before the packet
    124123 * so that the IP header is aligned on a 32 bit boundary.
     
    132131                dag_record_t *erfptr = (dag_record_t *)packet->header;
    133132                switch((erfptr->type & 0x7f)) {
    134                         case TYPE_ETH:         
     133                        case TYPE_ETH:
     134                        case TYPE_COLOR_ETH:
    135135                        case TYPE_DSM_COLOR_ETH:
     136                        case TYPE_COLOR_HASH_ETH:
    136137                                return 2;
    137138                        default:                return 0;
     
    144145                }
    145146        }
     147}
     148
     149int erf_is_color_type(uint8_t erf_type)
     150{
     151        switch(erf_type & 0x7f) {
     152                case TYPE_COLOR_HDLC_POS:
     153                case TYPE_DSM_COLOR_HDLC_POS:
     154                case TYPE_COLOR_ETH:
     155                case TYPE_DSM_COLOR_ETH:
     156                case TYPE_COLOR_HASH_POS:
     157                case TYPE_COLOR_HASH_ETH:
     158                        return 1;
     159        }
     160
     161        return 0;
    146162}
    147163
     
    200216        }
    201217        /* Is this a proper typed packet */
    202         if ((erf->type & 0x7f) > TYPE_AAL2) {
     218        if ((erf->type & 0x7f) > ERF_TYPE_MAX) {
    203219                return 0;
    204220        }
     
    464480
    465481        /* Check for loss */
    466         if ((erfptr->type & 0x7f) == TYPE_DSM_COLOR_ETH) {
     482        if (erf_is_color_type(erfptr->type)) {
    467483                /* No idea how we get this yet */
    468484
     
    521537
    522538        /* Unknown/corrupt */
    523         if ((((dag_record_t *)packet->buffer)->type & 0x7f) >= TYPE_RAW_LINK) {
     539        if ((((dag_record_t *)packet->buffer)->type & 0x7f) > ERF_TYPE_MAX) {
    524540                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
    525541                                "Corrupt or Unknown ERF type");
     
    758774        dag_record_t *erfptr = 0;
    759775        erfptr = (dag_record_t *)packet->header;
     776
     777        if ((erfptr->type & 0x7f) == TYPE_META)
     778                return 0;
     779
    760780        return ntohs(erfptr->wlen);
    761781}
     
    764784        dag_record_t *erfptr = 0;
    765785        assert(packet);
    766         if(size  > trace_get_capture_length(packet)) {
     786        erfptr = (dag_record_t *)packet->header;
     787
     788        if(size > trace_get_capture_length(packet) || (erfptr->type & 0x7f) == TYPE_META) {
    767789                /* Can't make a packet larger */
    768790                return trace_get_capture_length(packet);
    769791        }
     792
    770793        /* Reset cached capture length - otherwise we will both return the
    771794         * wrong value here and subsequent get_capture_length() calls will
    772795         * return the wrong value. */
    773796        packet->capture_length = -1;
    774         erfptr = (dag_record_t *)packet->header;
    775797        erfptr->rlen = htons(size + erf_get_framing_length(packet));
    776798        return trace_get_capture_length(packet);
Note: See TracChangeset for help on using the changeset viewer.