Changeset f0fb38f for lib/trace.c


Ignore:
Timestamp:
03/26/08 10:45:36 (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:
f52bcdd
Parents:
e632f2f
Message:
  • Added prepare_packet functions to all formats, primarily to support translating RT packets into the appropriate format. These functions are all used internally as well, as most formats still need to "prepare" packets that have been read by setting pointers, updating loss counters etc.
  • Also added a trace_prepare_packet function, but this is not made available externally at this stage
  • Added init_format_data functions to some formats to initialise format data structures in cases where the init_trace function does more than just that
  • Refactored rt packet reading code to use the new trace_prepare_packet functionality - also did a lot of tidying of the code
  • Added missing RT type for BPF format
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    rf3f3558 rf0fb38f  
    622622DLLEXPORT void trace_destroy_dead(libtrace_t *libtrace) {
    623623        assert(libtrace);
     624        if (libtrace->format_data)
     625                free(libtrace->format_data);
    624626        free(libtrace);
    625627}
     
    761763}
    762764
     765int trace_prepare_packet(libtrace_t *trace, libtrace_packet_t *packet,
     766                void *buffer, libtrace_rt_types_t rt_type, uint32_t flags) {
     767
     768        assert(packet);
     769        assert(trace);
     770       
     771        /* XXX Proper error handling?? */
     772        if (buffer == NULL)
     773                return -1;
     774
     775        if (!(packet->buf_control==TRACE_CTRL_PACKET || packet->buf_control==TRACE_CTRL_EXTERNAL)) {
     776                trace_set_err(trace,TRACE_ERR_BAD_STATE,"Packet passed to trace_read_packet() is invalid\n");
     777                return -1;
     778        }
     779       
     780        packet->trace = trace;
     781       
     782        /* Clear packet cache */
     783        packet->capture_length = -1;
     784        packet->l3_header = NULL;
     785        packet->l3_ethertype = 0;
     786
     787        if (trace->format->prepare_packet) {
     788                return trace->format->prepare_packet(trace, packet,
     789                                buffer, rt_type, flags);
     790        }
     791        trace_set_err(trace, TRACE_ERR_UNSUPPORTED,
     792                        "This format does not support preparing packets\n");
     793        return -1;
     794
     795}
     796
    763797/* Writes a packet to the specified output
    764798 *
     
    15951629}
    15961630
     1631
    15971632uint64_t trace_get_received_packets(libtrace_t *trace)
    15981633{
Note: See TracChangeset for help on using the changeset viewer.