Changeset 692bf9c for lib/libtrace.h.in


Ignore:
Timestamp:
02/05/19 09:41:34 (2 years ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
db919d5
Parents:
1668208
Message:

Add support to retrieve outermost vlan tag, outermost mpls label, and all layer2 headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    rd439067 r692bf9c  
    346346        /** NULL passed misc **/
    347347        TRACE_ERR_NULL = -31,
     348        /** ERR out of memory **/
     349        TRACE_ERR_OUT_OF_MEMORY = -33,
    348350};
    349351
     
    570572        TRACE_ETHERTYPE_RARP    = 0x8035,       /**< Reverse ARP */
    571573        TRACE_ETHERTYPE_8021Q   = 0x8100,       /**< 802.1q VLAN Extended Header */
     574        TRACE_ETHERTYPE_8021QS  = 0x88A8,       /**< 802.1q Service VLAN tag */
    572575        TRACE_ETHERTYPE_IPV6    = 0x86DD,       /**< IPv6 */
    573576        TRACE_ETHERTYPE_MPLS    = 0x8847,       /**< MPLS Unicast traffic */
     
    576579        TRACE_ETHERTYPE_PPP_SES = 0x8864        /**< PPPoE Session Messages */
    577580} libtrace_ethertype_t;
     581
     582/** constant to check if a vlan was found */
     583#define VLAN_NOT_FOUND 0xFF
     584
     585/** constant to check if a mpls label was found */
     586#define MPLS_NOT_FOUND 0xFFFF
     587
     588typedef struct libtrace_layer2_header {
     589        uint16_t ethertype;                     /**< Ethertype of the header */
     590        void *data;                             /**< Pointer to the header */
     591} libtrace_layer2_header_t;
     592typedef struct libtrace_layer2_headers {
     593        uint64_t bitmask;                       /**< Bitmask of found headers */
     594        int num;                                /**< The number of header */
     595        libtrace_layer2_header_t *header;       /**< Array of all found layer2 headers */
     596} libtrace_layer2_headers_t;
     597/** Enumeration of bitmask layer2 headers within libtrace_layer2_headers_t */
     598enum {
     599        TRACE_BITMASK_LOOPBACK  = 1,
     600        TRACE_BITMASK_IP        = 2,
     601        TRACE_BITMASK_ARP       = 4,
     602        TRACE_BITMASK_RARP      = 8,
     603        TRACE_BITMASK_8021Q     = 16,
     604        TRACE_BITMASK_IPV6      = 32,
     605        TRACE_BITMASK_8021QS    = 64,
     606        TRACE_BITMASK_MPLS      = 128,
     607        TRACE_BITMASK_MPLS_MC   = 256,
     608        TRACE_BITMASK_PPP_DISC  = 512,
     609        TRACE_BITMASK_PPP_SES   = 1024,
     610};
    578611
    579612typedef struct libtrace_packet_cache {
     
    24112444                void *vlan, uint16_t *type, uint32_t *remaining);
    24122445
     2446/** Get the outermost VLAN ID from a packet.
     2447 * @param packet                A pointer to the packet
     2448 * @param[out] vlanptr          A pointer to the VLAN header
     2449 * @param[out] remaining        Updated with the number of captured bytes remaining
     2450 *
     2451 * @return The outermost VLAN id if found or VLAN_NOT_FOUND
     2452 *
     2453 * vlanptr will be set to the start of the VLAN header found (or NULL if no
     2454 * VLAN tags are present).
     2455 *
     2456 * remaining will be set to the number of captured bytes in the packet,
     2457 * starting from the returned VLAN header.
     2458 */
     2459DLLEXPORT uint16_t trace_get_outermost_vlan(
     2460        libtrace_packet_t *packet, uint8_t **vlanptr, uint32_t *remaining);
     2461
     2462/** Get all layer2 headers from a packet.
     2463 * @param packet        A pointer to the packet
     2464 *
     2465 * @return A libtrace_layer2_headers_t structure containing all found layer2
     2466 * headers (or NULL if no layer2 headers are found). This structure must be
     2467 * destroyed with trace_destroy_layer2_headers().
     2468 */
     2469DLLEXPORT libtrace_layer2_headers_t *trace_get_layer2_headers(libtrace_packet_t *packet);
     2470
     2471/** Destroys a libtrace_layer2_headers_t structure.
     2472 * @param headers       A pointer to the libtrace_layer2_headers_t structure
     2473 *
     2474 * @returns 1 on successful deletion.
     2475 */
     2476DLLEXPORT int trace_destroy_layer2_headers(libtrace_layer2_headers_t *headers);
     2477
     2478/** Get the outermost MPLS label from a packet.
     2479 * @param packet                A pointer to the packet
     2480 * @param[out] mplsptr          A pointer to the mpls header
     2481 * @param[out] remaining        Updated with the number of captured bytes remaining
     2482 *
     2483 * @return The outmost MPLS label if found or MPLS_NOT_FOUND
     2484 *
     2485 * mplsptr will be set to the start of the MPLS header (or NULL if no
     2486 * MPLS header is found)
     2487 *
     2488 * remaining will be set to the number of captured bytes in the packet,
     2489 * starting from the MPLS header.
     2490 */
     2491DLLEXPORT uint32_t trace_get_outermost_mpls(
     2492        libtrace_packet_t *packet, uint8_t **mplsptr, uint32_t *remaining);
     2493
    24132494/** Gets a pointer to the payload following an MPLS header.
    24142495 * @param mpls      A pointer to the MPLS header
Note: See TracChangeset for help on using the changeset viewer.