Ignore:
Timestamp:
02/28/06 13:44:36 (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:
5b66921
Parents:
c26ca86
Message:

Add preliminary seek support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_helper.c

    r0ea3526 r0d57541  
    8080        struct timeval stv;
    8181
    82         if (!trace->event.packet.buffer) {
    83                 trace->event.packet.buffer = (void *)malloc(4096);
    84                 trace->event.packet.size=
    85                         trace_read_packet(trace,packet);
    86                 event.size = trace->event.packet.size = \
    87                              trace->event.packet.size;
    88                 if (trace->event.packet.size > 0 ) {
    89                         memcpy(trace->event.packet.buffer,
    90                                         packet->buffer,
    91                                         trace->event.packet.size);
    92                 } else {
     82        if (!trace->event.packet) {
     83                trace->event.packet = trace_create_packet();
     84                trace->event.psize=
     85                        trace_read_packet(trace,trace->event.packet);
     86                if (trace->event.psize<1) {
    9387                        /* return here, the test for
    9488                         * event.size will sort out the error
     
    9993        }
    10094
    101         ts=trace_get_seconds(packet);
     95        ts=trace_get_seconds(trace->event.packet);
    10296        if (trace->event.tdelta!=0) {
    10397                /* Get the adjusted current time */
     
    108102                now -= trace->event.tdelta;
    109103
    110                 /*if the trace timestamp is still in the
    111                 //future, return a SLEEP event,
    112                 //otherwise fire the packet
     104                /* if the trace timestamp is still in the
     105                 * future, return a SLEEP event,
     106                 * otherwise fire the packet
    113107                 */
    114108                if (ts > now) {
     
    121115                gettimeofday(&stv, NULL);
    122116                /* work out the difference between the
    123                 // start of trace replay, and the first
    124                 // packet in the trace
     117                 * start of trace replay, and the first
     118                 * packet in the trace
    125119                 */
    126120                trace->event.tdelta = stv.tv_sec +
     
    130124
    131125        /* This is the first packet, so just fire away. */
    132         memcpy(packet->buffer,
    133                         trace->event.packet.buffer,
    134                         trace->event.packet.size);
    135         free(trace->event.packet.buffer);
    136         trace->event.packet.buffer = 0;
     126        /* TODO: finalise packet */
     127        *packet = *trace->event.packet;
     128        trace->event.packet = NULL;
     129
    137130        event.type = TRACE_EVENT_PACKET;
    138131
     
    140133
    141134        return event;
    142        
    143135}
    144136
Note: See TracChangeset for help on using the changeset viewer.