Ignore:
Timestamp:
06/27/14 13:42:59 (7 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, 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:
fb20640
Parents:
fa7faf3
Message:

Added trace_get_fragment_offset to API

New function performs all the bit-shifting, masking,
multiplying and (in the case of IPv6) header skipping necessary to
work out the fragment offset for a packet, in bytes.

Fixed trace_get_source_port and trace_get_destination_port so
that they do not try to lookup port numbers if the packet is
not the first fragment.

IPv6 fragment offsets probably need more testing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols_transport.c

    r10f924c r7baa948  
    382382        uint32_t remaining;
    383383        uint8_t proto;
    384         const struct ports_t *port =
    385                 (const struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
     384        struct ports_t *port;
     385        uint16_t fragoff;
     386        uint8_t more;
     387
     388        fragoff = trace_get_fragment_offset(packet, &more);
     389
     390        /* If we're not the first fragment, we're unlikely to be able
     391         * to get any useful port numbers from this packet.
     392         */
     393        if (fragoff != 0)
     394                return 0;
     395       
     396       
     397        port = (struct ports_t*)trace_get_transport(
     398                        (libtrace_packet_t*)packet,
    386399                        &proto, &remaining);
    387400
     
    405418        uint32_t remaining;
    406419        uint8_t proto;
    407         struct ports_t *port =
    408                 (struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
     420        struct ports_t *port;
     421        uint16_t fragoff;
     422        uint8_t more;
     423
     424        fragoff = trace_get_fragment_offset(packet, &more);
     425
     426        /* If we're not the first fragment, we're unlikely to be able
     427         * to get any useful port numbers from this packet.
     428         */
     429        if (fragoff != 0)
     430                return 0;
     431       
     432       
     433        port = (struct ports_t*)trace_get_transport(
     434                        (libtrace_packet_t*)packet,
    409435                        &proto, &remaining);
    410436        /* Snapped too early */
Note: See TracChangeset for help on using the changeset viewer.