Changeset 9bc4689 for lib/format_pcap.c


Ignore:
Timestamp:
09/06/07 01:07:07 (15 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:
fbc4342
Parents:
180f095
Message:

Move everything over to using the newer API's

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    r708f9ae r9bc4689  
    313313{
    314314        struct pcap_pkthdr pcap_pkt_hdr;
     315        void *link;
     316        libtrace_linktype_t linktype;
     317        uint32_t remaining;
     318
     319        link = trace_get_packet_buffer(packet,&linktype,&remaining);
    315320
    316321        /* If this packet cannot be converted to a pcap linktype then
    317322         * pop off the top header until it can be converted
    318323         */
    319         while (libtrace_to_pcap_linktype(trace_get_link_type(packet))==~0U) {
     324        while (libtrace_to_pcap_linktype(linktype)==~0U) {
    320325                if (!demote_packet(packet)) {
    321326                        trace_set_err_out(libtrace,
     
    324329                        return -1;
    325330                }
     331
     332                link = trace_get_packet_buffer(packet,&linktype,&remaining);
    326333        }
    327334
     
    346353
    347354        /* Corrupt packet, or other "non data" packet, so skip it */
    348         if (trace_get_link(packet) == NULL) {
     355        if (link == NULL) {
    349356                /* Return "success", but nothing written */
    350357                return 0;
     
    363370                pcap_pkt_hdr.ts.tv_sec = ts.tv_sec;
    364371                pcap_pkt_hdr.ts.tv_usec = ts.tv_usec;
    365                 pcap_pkt_hdr.caplen = trace_get_capture_length(packet);
     372                pcap_pkt_hdr.caplen = remaining;
    366373                /* trace_get_wire_length includes FCS, while pcap doesn't */
    367374                if (trace_get_link_type(packet)==TRACE_TYPE_ETH)
     
    442449                {
    443450                        libtrace_sll_header_t *sll;
    444                         sll = trace_get_link(packet);
     451                        sll = trace_get_packet_buffer(packet, NULL, NULL);
     452                        /* TODO: should check remaining>=sizeof(*sll) */
    445453                        if (!sll) {
    446454                                trace_set_err(packet->trace,
     
    471479                {
    472480                        libtrace_pflog_header_t *pflog;
    473                         pflog = trace_get_link(packet);
     481                        pflog = trace_get_packet_buffer(packet, NULL, NULL);
     482                        /* TODO: should check remaining >= sizeof(*pflog) */
    474483                        if (!pflog) {
    475484                                trace_set_err(packet->trace,
     
    518527                return pcapptr->len+4; /* Include the missing FCS */
    519528        else if (packet->type==pcap_linktype_to_rt(TRACE_DLT_IEEE802_11_RADIO)) {
     529                libtrace_linktype_t linktype;
     530                void *link = trace_get_packet_buffer(packet,&linktype,NULL);
    520531                /* If the packet is Radiotap and the flags field indicates
    521532                 * that the FCS is not included in the 802.11 frame, then
     
    523534                 */
    524535                uint8_t flags;
    525                 trace_get_wireless_flags(trace_get_link(packet),
    526                                 trace_get_link_type(packet), &flags);
     536                trace_get_wireless_flags(link,
     537                                linktype, &flags);
    527538                if ((flags & TRACE_RADIOTAP_F_FCS) == 0)
    528539                        return pcapptr->len + 4;
Note: See TracChangeset for help on using the changeset viewer.