Changeset 2627439 for lib


Ignore:
Timestamp:
11/30/12 15:04:47 (9 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:
f00c146
Parents:
f240823
Message:
  • Created separate RT types for each combination of BPF + DLT - BPF doesn't store the linktype in the packet at all, so this has to be included in the RT type :/
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_bpf.c

    rb8cb571 r2627439  
    383383{
    384384        uint32_t flags = 0;
     385
     386        packet->type = bpf_linktype_to_rt(swapl(libtrace,
     387                        FORMATIN(libtrace)->linktype));
    385388       
    386389        /* Read from the BPF interface into our capture buffer */
     
    417420         * buffer */
    418421        if (bpf_prepare_packet(libtrace, packet, FORMATIN(libtrace)->bufptr,
    419                 TRACE_RT_DATA_BPF, flags)) {
     422                        packet->type, flags)) {
    420423                return -1;
    421424        }
     
    438441        /* Convert the linktype that we recorded when we started the trace
    439442         * into a suitable libtrace linktype */
    440         return pcap_linktype_to_libtrace(FORMATIN(packet->trace)->linktype);
     443        return pcap_linktype_to_libtrace(rt_to_pcap_linktype(packet->type));
    441444}
    442445
  • lib/libtrace.h.in

    rd500159 r2627439  
    345345        TRACE_RT_DATA_LINUX_NATIVE=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_LINUX_NATIVE,
    346346        /** RT is encapsulating a BSD native capture record */
    347         TRACE_RT_DATA_BPF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_BPF,
     347        //TRACE_RT_DATA_BPF       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_BPF,
    348348        /** RT is encapsulating a TSH capture record */
    349349        TRACE_RT_DATA_TSH       =TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_TSH,
     
    377377         * encapsulation */
    378378        TRACE_RT_DATA_DLT_END           = 2999,
     379        /** BPF does not store the linktype with the packet, so we need a
     380         * separate RT type for each supported DLT. This value represents the
     381         * starting point */
     382        TRACE_RT_DATA_BPF               = 3000,
     383
     384        TRACE_RT_BPF_NULL               = TRACE_RT_DATA_BPF+TRACE_DLT_NULL,
     385        TRACE_RT_BPF_EN10MB             = TRACE_RT_DATA_BPF+TRACE_DLT_EN10MB,
     386        TRACE_RT_BPF_IEEE802_11         = TRACE_RT_DATA_BPF+TRACE_DLT_IEEE802_11,
     387        TRACE_RT_BPF_PFLOG              =TRACE_RT_DATA_BPF+TRACE_DLT_PFLOG,
     388        TRACE_RT_BPF_ATM_RFC1483        =TRACE_RT_DATA_BPF+TRACE_DLT_ATM_RFC1483,
     389
     390        TRACE_RT_DATA_BPF_END           = 3999,
    379391        /** Unused value marking the end of the valid range for all RT packet
    380392         * types */
    381         TRACE_RT_LAST                   = 3000
     393        TRACE_RT_LAST                   = 4000
    382394} libtrace_rt_types_t;
    383395
  • lib/linktypes.c

    r64d4398 r2627439  
    164164                case TRACE_TYPE_ATM:    return TYPE_ATM;
    165165                case TRACE_TYPE_AAL5:   return TYPE_AAL5;
     166               
     167                /* Not technically correct! Could be IPv6 packet
     168                 *
     169                 * TODO: Maybe we want TRACE_TYPE_RAW_IPV4 and
     170                 * TRACE_TYPE_RAW_IPV6 to replace TRACE_TYPE_NONE.
     171                 * Still need a good way to figure out how to convert
     172                 * TRACE_DLT_LINKTYPE_RAW into the correct type for the
     173                 * IP version though :( */
    166174                case TRACE_TYPE_NONE:   return TYPE_IPV4;
    167175                /* Unsupported conversions */
     
    360368                                return false;
    361369
    362 #if 0
    363                         switch(ntohs(((libtrace_sll_header_t*)packet->payload)
    364                                         ->hatype)) {
    365                                 case ARPHRD_PPP:
    366                                         packet->type=pcap_linktype_to_rt(TRACE_DLT_RAW);
    367                                         break;
    368                                 case ARPHRD_ETHER:
    369                                         packet->type=pcap_linktype_to_rt(TRACE_DLT_EN10MB);
    370                                         break;
    371                                 default:
    372                                         /* Dunno how to demote this packet */
    373                                         return false;
    374                         }
    375 #endif
    376370                        /* Skip the Linux SLL header */
    377371                        packet->payload=(void*)((char*)packet->payload
Note: See TracChangeset for help on using the changeset viewer.