Changeset 37195b4 for lib/trace.c


Ignore:
Timestamp:
02/10/06 10:52:41 (16 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:
7f32bb5
Parents:
56ef532
Message:

Split out legacy from erf
Added config_input, start_input, and start_output hooks for formats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    rbb09ce4 r37195b4  
    154154
    155155void register_format(struct libtrace_format_t *f) {
    156 //      fprintf(stderr,"Registering input format %s\n",f->name);
    157156        if (format_list == 0) {
    158157                format_size = 10;
     
    311310        assert( libtrace->fifo);
    312311        free(scan);
     312        libtrace->started=false;
    313313        return libtrace;
    314314}
     
    430430}
    431431
     432/* Start a trace
     433 * @param libtrace      the input trace to start
     434 * @returns 0 on success
     435 *
     436 * This does the work associated with actually starting up
     437 * the trace.  it may fail.
     438 */
     439int trace_start(struct libtrace_t *libtrace)
     440{
     441        if (libtrace->format->start_input) {
     442                int ret=libtrace->format->start_input(libtrace);
     443                if (!ret) {
     444                        return ret;
     445                }
     446        }
     447
     448        libtrace->started=true;
     449        return 0;
     450}
     451
    432452/* Parses an output options string and calls the appropriate function to deal with output options.
    433453 *
     
    520540int trace_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) {
    521541
    522         if (!libtrace) {
    523                 fprintf(stderr,"You called trace_read_packet() with a NULL libtrace parameter!\n");
    524         }
    525         assert(libtrace);
    526         assert(packet);
     542        assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n");
     543        assert(libtrace->started && "BUG: You must call libtrace_start() before trace_read_packet()\n");
     544        assert(packet);
    527545     
    528546        /* Store the trace we are reading from into the packet opaque
Note: See TracChangeset for help on using the changeset viewer.