Changeset 7428ab2 for lib/libtrace.h.in


Ignore:
Timestamp:
06/22/15 17:44:39 (7 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:
84d137d, d280f48
Parents:
8b12caf
Message:

Add trace_strip_packet to libtrace API

This function will allow callers to strip MPLS and VLAN headers from
libtrace packets. Some analysis tools (especially those written with
libpcap in the days before these technologies were popular) don't
work so well when these headers are present.

Stripping VLAN headers also makes BPF filtering easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    rc5ac872 r7428ab2  
    16031603void *trace_get_link(const libtrace_packet_t *packet);
    16041604
     1605/**
     1606 * Supported masks for stripping headers from packets.
     1607 */
     1608enum {
     1609        TRACE_STRIP_VLAN = 0x01, /**< Strip 802.1Q (VLAN tag) headers */
     1610        TRACE_STRIP_MPLS = 0x02  /**< Strip MPLS headers */
     1611};
     1612
     1613/** Strips certain headers from a given packet.
     1614 * @param packet        The packet to strip headers from.
     1615 * @param stripopts     A mask to indicate which headers should be stripped.
     1616 * If multiple header types are to be stripped, these should be ORed together
     1617 * to create the full mask. A mask of zero will strip all strippable headers.
     1618 *
     1619 * @return The packet with the requested headers removed (if they were
     1620 * present).
     1621 *
     1622 * This function is intended for removing those pesky layer 2.5 headers
     1623 * that are not supported by other packet analysis applications, e.g. VLAN
     1624 * and MPLS headers. If successful, the resulting packet will be a simple
     1625 * Ethernet-IP-Transport packet that just about anything should be able to
     1626 * parse without difficulty.
     1627 *
     1628 * If this function encounters a layer 2 or 2.5 header that it does not
     1629 * support, stripping will cease and the packet returning will be stripped
     1630 * up to but not including the unsupported header.
     1631 *
     1632 * New in libtrace 4.0.0
     1633 *
     1634 * @note This function only supports stripping headers from Ethernet packets
     1635 * for now. Passing in packets of other link types will simply result in
     1636 * the original packet being returned unmodified.
     1637 *
     1638 * @note Depending on the input source, this function may need to copy the
     1639 * original packet to be able to safely modify the contents. This may have
     1640 * a major impact on performance so avoid stripping packets unless absolutely
     1641 * necessary.
     1642 */
     1643DLLEXPORT libtrace_packet_t *trace_strip_packet(libtrace_packet_t *packet,
     1644                int stripopts);
     1645
    16051646/** Get a pointer to the IPv4 header (if any) for a given packet
    16061647 * @param packet        The packet to get the IPv4 header for
Note: See TracChangeset for help on using the changeset viewer.