Ignore:
Timestamp:
07/20/07 15:26:04 (14 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:
708f9ae
Parents:
a43a2bd
Message:
  • Added a new config option for input traces which will specify whether the event framework should retain the time gaps between packets or not.
  • Updated erf and pcapfile to support the new option, other formats can be updated as required.
  • Renamed the TRACE_META_FREQ option to match the option naming scheme
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcapfile.c

    rce0bf2c r646aca1  
    4545#define DATA(x) ((struct pcapfile_format_data_t*)((x)->format_data))
    4646#define DATAOUT(x) ((struct pcapfile_format_data_out_t*)((x)->format_data))
     47#define IN_OPTIONS DATA(libtrace)->options
    4748
    4849typedef struct pcapfile_header_t {
     
    5859struct pcapfile_format_data_t {
    5960        libtrace_io_t *file;
     61        struct {
     62                int real_time;
     63        } options;
    6064        pcapfile_header_t header;
    6165};
     
    7781
    7882        DATA(libtrace)->file=NULL;
    79 
     83        IN_OPTIONS.real_time = 0;
    8084        return 0;
    8185}
     
    163167static int pcapfile_config_input(libtrace_t *libtrace,
    164168                trace_option_t option,
    165                 void *data UNUSED)
    166 {
     169                void *data)
     170{
     171        switch(option) {
     172                case TRACE_OPTION_EVENT_REALTIME:
     173                        IN_OPTIONS.real_time = *(int *)data;
     174                        return 0;
     175                case TRACE_OPTION_META_FREQ:
     176                case TRACE_OPTION_SNAPLEN:
     177                case TRACE_OPTION_PROMISC:
     178                case TRACE_OPTION_FILTER:
     179                        /* all these are either unsupported or handled
     180                         * by trace_config */
     181                        break;
     182        }
     183       
    167184        trace_set_err(libtrace,TRACE_ERR_UNKNOWN_OPTION,
    168185                        "Unknown option %i", option);
     
    460477        pcapptr->caplen = swapl(packet->trace,(uint32_t)size);
    461478        return trace_get_capture_length(packet);
     479}
     480
     481static struct libtrace_eventobj_t pcapfile_event(libtrace_t *libtrace, libtrace_packet_t *packet) {
     482       
     483        libtrace_eventobj_t event = {0,0,0.0,0};
     484       
     485        if (IN_OPTIONS.real_time) {
     486                event.size = pcapfile_read_packet(libtrace, packet);
     487                if (event.size < 1)
     488                        event.type = TRACE_EVENT_TERMINATE;
     489                else
     490                        event.type = TRACE_EVENT_PACKET;
     491                return event;
     492        } else {
     493                return trace_event_trace(libtrace, packet);
     494        }
    462495}
    463496
Note: See TracChangeset for help on using the changeset viewer.