Changeset 92a37b0


Ignore:
Timestamp:
12/15/06 10:13:09 (15 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:
eb27e8e
Parents:
fab1d42
Message:

DAG 2.5 includes a function for getting the next record so let's use that instead of doing a lot of arithmetic with various offsets.
Fixed bug where trace_event_dag was returning an incorrect event type in certain situations.
We now only call one of dag_detach_stream and dag_stop_stream to prevent memory corruption.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r8d1e551 r92a37b0  
    408408                return -1;
    409409        }
     410        /*
    410411        if (dag_detach_stream(INPUT.fd, DAG.dagstream) < 0) {
    411412                trace_set_err(libtrace, errno, "Could not detach DAG stream");
    412413                return -1;
    413414        }
     415        */
    414416#endif
    415417        return 0; /* success */
     
    543545        struct timeval tv;
    544546        dag_record_t *erfptr;
     547        char *next_record = NULL;       
    545548
    546549        if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq &&
     
    562565       
    563566        packet->type = TRACE_RT_DATA_ERF;
    564        
     567#ifdef DAG_VERSION_2_4
    565568        if ((numbytes = dag_read(libtrace,0)) < 0)
    566569                return numbytes;
     
    570573        erfptr = (dag_record_t *) ((char *)DAG.buf +
    571574                        (DAG.bottom + DAG.offset));
     575#else
     576        next_record = (char *)dag_rx_stream_next_record(INPUT.fd, 0);
     577        erfptr = (dag_record_t *)next_record;
     578#endif
    572579        size = ntohs(erfptr->rlen);
    573 
    574580        assert( size >= dag_record_size );
    575581        assert( size < LIBTRACE_PACKET_BUFSIZE);
     
    587593        }
    588594
     595#ifdef DAG_VERSION_2_4
    589596        DAG.offset += size;
    590597        DAG.diff -= size;
    591 
     598#endif
    592599        tv = trace_get_timeval(packet);
    593600        DUCK.last_pkt = tv.tv_sec;
     
    595602        return packet->payload ? size : erf_get_framing_length(packet);
    596603}
    597 
     604       
    598605static int dag_start_input(libtrace_t *libtrace) {
    599606#ifdef DAG_VERSION_2_4
     
    617624         * happen.  flush the memory hole
    618625         */
    619         while(dag_read(libtrace,1)!=0)
     626        while(dag_read(libtrace,DAGF_NONBLOCK)!=0)
    620627                DAG.diff=0;
    621628        return 0;
     
    900907        if (data > 0) {
    901908                event.size = dag_read_packet(trace,packet);
     909                DATA(trace)->dag.diff -= event.size;
    902910                if (trace->filter) {
    903911                        if (trace_apply_filter(trace->filter, packet)) {
     
    908916                                return event;
    909917                        }
    910                 }       
     918                } else {
     919                        event.type = TRACE_EVENT_PACKET;
     920                }
    911921                if (trace->snaplen > 0) {
    912922                        trace_set_capture_length(packet, trace->snaplen);
Note: See TracChangeset for help on using the changeset viewer.