Ignore:
Timestamp:
02/27/13 14:02:17 (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:
954577b9
Parents:
0801187
Message:
  • Added API functions for getting the ICMPv6 header and the subsequent payload
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols_transport.c

    rdc6072d r05f2718  
    294294}
    295295
     296DLLEXPORT libtrace_icmp6_t *trace_get_icmp6(libtrace_packet_t *packet) {
     297        uint8_t proto;
     298        uint32_t rem = 0;
     299        libtrace_icmp6_t *icmp;
     300
     301        icmp=(libtrace_icmp6_t*)trace_get_transport(packet,&proto,&rem);
     302
     303        if (!icmp || proto != TRACE_IPPROTO_ICMPV6)
     304                return NULL;
     305
     306        /* Make sure we return a full ICMP header as the caller has no way of
     307         * telling how much of the packet is remaining */
     308        if (rem < sizeof(libtrace_icmp6_t))
     309                return NULL;
     310
     311        return icmp;
     312}
     313
    296314DLLEXPORT libtrace_icmp_t *trace_get_icmp_from_ip(libtrace_ip_t *ip, uint32_t *remaining)
    297315{
     
    343361}
    344362
     363DLLEXPORT void *trace_get_payload_from_icmp6(libtrace_icmp6_t *icmp, uint32_t *remaining)
     364{
     365        if (remaining) {
     366                if (*remaining < sizeof(libtrace_icmp6_t)) {
     367                        *remaining = 0;
     368                        return NULL;
     369                }
     370                *remaining-=sizeof(libtrace_icmp6_t);
     371        }
     372        return (char*)icmp+sizeof(libtrace_icmp6_t);
     373}
     374
    345375/* Return the source port
    346376 */
Note: See TracChangeset for help on using the changeset viewer.