Changeset f00c146 for lib


Ignore:
Timestamp:
11/30/12 16:24:15 (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:
e1f3b6b
Parents:
2627439
Message:
  • Fix build errors with format_bpf.c
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_bpf.c

    r2627439 rf00c146  
    384384        uint32_t flags = 0;
    385385
    386         packet->type = bpf_linktype_to_rt(swapl(libtrace,
    387                         FORMATIN(libtrace)->linktype));
     386        packet->type = bpf_linktype_to_rt(ntohs(FORMATIN(libtrace)->linktype));
    388387       
    389388        /* Read from the BPF interface into our capture buffer */
  • lib/libtrace_int.h

    rf440dc0 rf00c146  
    790790libtrace_dlt_t rt_to_pcap_linktype(libtrace_rt_types_t rt_type);
    791791
     792/** Converts a PCAP DLT into an RT protocol type for the BPF format.
     793 *
     794 * @param linktype      The PCAP DLT to be converted
     795 * @return The RT type that is equivalent to the provided DLT for BPF
     796 */
     797libtrace_rt_types_t bpf_linktype_to_rt(libtrace_dlt_t linktype);
     798
    792799/** Converts an ERF type into a libtrace link type.
    793800 *
  • lib/linktypes.c

    r2627439 rf00c146  
    137137}
    138138
     139libtrace_rt_types_t bpf_linktype_to_rt(libtrace_dlt_t linktype) {
     140        return pcap_dlt_to_pcap_linktype(linktype) + TRACE_RT_DATA_BPF;
     141
     142}
     143
    139144libtrace_dlt_t rt_to_pcap_linktype(libtrace_rt_types_t rt_type)
    140145{
    141         assert(rt_type >= TRACE_RT_DATA_DLT);
    142         return rt_type - TRACE_RT_DATA_DLT;
     146       
     147        if (rt_type >= TRACE_RT_DATA_DLT && rt_type < TRACE_RT_DATA_DLT_END) {
     148                /* RT type is in the pcap range */
     149                return rt_type - TRACE_RT_DATA_DLT;
     150        }
     151        else if (rt_type >= TRACE_RT_DATA_BPF && rt_type < TRACE_RT_DATA_BPF_END) {
     152                return rt_type - TRACE_RT_DATA_BPF;
     153        }
     154       
     155        fprintf(stderr, "Error: RT type %u cannot be converted to a pcap DLT\n", rt_type);
     156
    143157}
    144158
Note: See TracChangeset for help on using the changeset viewer.