Changeset a181666 for lib/format_bpf.c


Ignore:
Timestamp:
03/08/13 17:03:29 (8 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
6e6577d
Parents:
19526f3
Message:

Possible fix for the BPF header contains a struct timeval bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_bpf.c

    rc909fad ra181666  
    7878        uint32_t bh_datalen;            /* wire length */
    7979        uint16_t bh_hdrlen;             /* header length (incl padding) */
     80};
     81
     82struct local_bpf_hdr {
     83        struct timeval bh_tstamp;
     84        uint32_t bh_caplen;
     85        uint32_t bh_datalen;
     86        uint16_t bh_hdrlen;
    8087};
    8188
     
    362369                void *buffer, libtrace_rt_types_t rt_type, uint32_t flags) {
    363370       
     371        struct local_bpf_hdr orig;
     372        struct local_bpf_hdr *ptr;
     373        struct libtrace_bpf_hdr *replace;
     374
    364375        /* If the packet previously owned a buffer that is not the buffer
    365376         * that contains the new packet data, we're going to need to free the
     
    380391        packet->header = buffer;
    381392        packet->type = rt_type;
     393
     394        /* FreeBSD is stupid and uses a timeval in the bpf header
     395         * structure. This means that sometimes our timestamp consumes
     396         * 8 bytes and sometimes it consumes 16 bytes.
     397         *
     398         * Let's try to standardise our header a bit, hopefully without
     399         * overwriting anything else important */
     400
     401        ptr = ((struct local_bpf_hdr *)(packet->header));
     402        replace = ((struct libtrace_bpf_hdr *)(packet->header));
     403        orig = *ptr;
     404       
     405        replace->bh_tstamp.tv_sec = (uint32_t) (orig.bh_tstamp.tv_sec & 0xffffffff);
     406        replace->bh_tstamp.tv_usec = (uint32_t) (orig.bh_tstamp.tv_usec & 0xffffffff);
     407        replace->bh_caplen = orig.bh_caplen;
     408        replace->bh_datalen = orig.bh_datalen;
     409        replace->bh_hdrlen = orig.bh_hdrlen;
     410               
    382411
    383412        /* Find the payload */
Note: See TracChangeset for help on using the changeset viewer.