Changeset 56ef532 for lib/format_erf.c


Ignore:
Timestamp:
02/09/06 17:23:33 (16 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:
37195b4
Parents:
9e3902e
Message:

Added trace_event_dag to format_erf for checking dag events
Tidied up dag_read to be more sensible i.e no unused buffers
Added TRACE_TYPE_80211_PRISM which Perry forgot!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_erf.c

    r9e3902e r56ef532  
    419419 
    420420#if HAVE_DAG
    421 static int dag_read(struct libtrace_t *libtrace, void *buffer, size_t len, int block_flag) {
     421static int dag_read(struct libtrace_t *libtrace, int block_flag) {
    422422        int numbytes;
    423423        static short lctr = 0;
     
    425425        int rlen;
    426426
    427         if (buffer == 0)
    428                 buffer = malloc(len);
    429        
     427        if (DAG.diff != 0)
     428                return DAG.diff;
     429
    430430        DAG.bottom = DAG.top;
    431431        DAG.top = dag_offset(
     
    446446        int numbytes;
    447447        int size;
    448         char buf[RP_BUFSIZE];
    449448        dag_record_t *erfptr;
    450449        void *buffer = packet->buffer;
     
    458457        }
    459458   
    460         if (DAG.diff == 0) {
    461                 if ((numbytes = dag_read(libtrace,buf,RP_BUFSIZE, 0)) <= 0)
    462                         return numbytes;
    463         }
     459        if ((numbytes = dag_read(libtrace,0)) <= 0)
     460                return numbytes;
    464461
    465462        //DAG always gives us whole packets
     
    874871}
    875872
     873#ifdef HAVE_DAG
     874struct libtrace_eventobj_t trace_event_dag(struct libtrace_t *trace, struct libtrace_packet_t *packet) {
     875        struct libtrace_eventobj_t event = {0,0,0.0,0};
     876        int dag_fd;
     877        int data;
     878
     879        if (packet->trace->format->get_fd) {
     880                dag_fd = packet->trace->format->get_fd(packet);
     881        } else {
     882                dag_fd = 0;
     883        }
     884       
     885        data = dag_read(trace, DAGF_NONBLOCK);
     886
     887        if (data > 0) {
     888                event.size = trace_read_packet(trace,packet);
     889                event.type = TRACE_EVENT_PACKET;
     890                return event;
     891        }
     892        event.type = TRACE_EVENT_SLEEP;
     893        event.seconds = 0.0001;
     894        return event;
     895}
     896#endif
     897
    876898#if HAVE_DAG
    877899static void dag_help() {
     
    10981120        erf_set_capture_length,         /* set_capture_length */
    10991121        NULL,                           /* get_fd */
    1100         trace_event_device,             /* trace_event */
     1122        trace_event_dag,                /* trace_event */
    11011123        dag_help                        /* help */
    11021124};
Note: See TracChangeset for help on using the changeset viewer.