Changeset 73dd29f for lib/format_pcap.c


Ignore:
Timestamp:
04/02/07 21:44:53 (14 years ago)
Author:
Perry Lorier <perry@…>
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:
11f2df7
Parents:
02bd77e
Message:

Sooo, pcap has two types of DLT's "pure" DLT's that are platform dependant,
and "linktype" DLT's that are portable and are what are written to pcap files.

Instead of fudging the two concepts together so much, attempt to disintangle
this mess without exposing too much of the god awful mess to the end user.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    rf0c639b r73dd29f  
    264264        assert(libtrace->format_data);
    265265        linktype = pcap_datalink(DATA(libtrace)->input.pcap);
    266         packet->type = pcap_dlt_to_rt(linktype);
     266        packet->type = pcap_linktype_to_rt(linktype);
    267267
    268268        packet->buf_control = TRACE_CTRL_PACKET;
     
    314314         * pop off the top header until it can be converted
    315315         */
    316         while (libtrace_to_pcap_dlt(trace_get_link_type(packet))==~0U) {
     316        while (libtrace_to_pcap_linktype(trace_get_link_type(packet))==~0U) {
    317317                if (!demote_packet(packet)) {
    318318                        trace_set_err_out(libtrace,
     
    323323        }
    324324
     325
    325326        if (!OUTPUT.trace.pcap) {
    326                 OUTPUT.trace.pcap = pcap_open_dead(
    327                         libtrace_to_pcap_dlt(trace_get_link_type(packet)),
    328                         65536);
     327                int linktype=libtrace_to_pcap_dlt(trace_get_link_type(packet));
     328                OUTPUT.trace.pcap = pcap_open_dead(linktype,65536);
    329329                if (!OUTPUT.trace.pcap) {
    330                         trace_set_err_out(libtrace,TRACE_ERR_INIT_FAILED,"Failed to open dead trace: %s\n",
     330                        trace_set_err_out(libtrace,TRACE_ERR_INIT_FAILED,
     331                                        "Failed to open dead trace: %s\n",
    331332                                        pcap_geterr(OUTPUT.trace.pcap));
    332333                }
     
    409410
    410411static libtrace_linktype_t pcap_get_link_type(const libtrace_packet_t *packet) {
    411         /* pcap doesn't store dlt in the framing header so we need
     412        /* pcap doesn't store linktype in the framing header so we need
    412413         * rt to do it for us
    413414         */
    414         int linktype = rt_to_pcap_dlt(packet->type);
    415         return pcap_dlt_to_libtrace(linktype);
     415        int linktype = rt_to_pcap_linktype(packet->type);
     416        return pcap_linktype_to_libtrace(linktype);
    416417}
    417418
     
    511512        struct pcap_pkthdr *pcapptr = 0;
    512513        pcapptr = (struct pcap_pkthdr *)packet->header;
    513         if (packet->type==pcap_dlt_to_rt(TRACE_DLT_EN10MB))
     514        if (packet->type==pcap_linktype_to_rt(TRACE_DLT_EN10MB))
    514515                return pcapptr->len+4; /* Include the missing FCS */
    515         else if (packet->type==pcap_dlt_to_rt(TRACE_DLT_IEEE802_11_RADIO)) {
     516        else if (packet->type==pcap_linktype_to_rt(TRACE_DLT_IEEE802_11_RADIO)) {
    516517                /* If the packet is Radiotap and the flags field indicates
    517518                 * that the FCS is not included in the 802.11 frame, then
    518519                 * we need to add 4 to the wire-length to account for it.
    519520                 */
    520                 uint16_t flags;
    521                 trace_get_wireless_flags(trace_get_link(packet), trace_get_link_type(packet), &flags);
     521                uint8_t flags;
     522                trace_get_wireless_flags(trace_get_link(packet),
     523                                trace_get_link_type(packet), &flags);
    522524                if ((flags & TRACE_RADIOTAP_F_FCS) == 0)
    523525                        return pcapptr->len + 4;
Note: See TracChangeset for help on using the changeset viewer.