Ignore:
Timestamp:
08/17/18 17:21:48 (2 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
develop, master, ringdecrementfix, ringperformance
Children:
37ee856, 73a5b72
Parents:
54a76f2 (diff), 2044185 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'cachetimestamps' into develop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_etsilive.c

    r32ee9b2 r2044185  
    8383        etsithread_t *receivers;
    8484        int nextthreadid;
     85        wandder_etsispec_t *shareddec;
    8586} etsilive_format_data_t;
    8687
     
    227228        FORMAT_DATA->listenport = strdup(scan + 1);
    228229
     230        FORMAT_DATA->shareddec = wandder_create_etsili_decoder();
     231
    229232        return 0;
    230233}
     
    240243        if (FORMAT_DATA->listenport) {
    241244                free(FORMAT_DATA->listenport);
     245        }
     246        if (FORMAT_DATA->shareddec) {
     247                wandder_free_etsili_decoder(FORMAT_DATA->shareddec);
    242248        }
    243249        free(libtrace->format_data);
     
    522528        packet->wire_length = esock->cached.length;
    523529        packet->capture_length = esock->cached.length;
    524 
    525         /*
    526         for (j = 0; j < packet->wire_length; j++) {
    527                 printf("%02x ", *(((uint8_t *)packet->buffer) + j));
    528                 if ((j % 16) == 15) printf("\n");
    529         }
    530         printf("\n");
    531         */
    532530
    533531        /* Advance the read pointer for this buffer
     
    589587
    590588        /* Should never get here because cache is set when packet is read */
    591         wandder_etsispec_t *dec;
    592589        size_t reclen;
     590        libtrace_t *libtrace = packet->trace;
     591
     592        assert(libtrace);
     593        assert(FORMAT_DATA->shareddec);
    593594
    594595        /* 0 should be ok here for quickly evaluating the first length
    595596         * field... */
    596         dec = wandder_create_etsili_decoder();
    597         wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
    598         reclen = (size_t)wandder_etsili_get_pdu_length(dec);
    599         wandder_free_etsili_decoder(dec);
     597        wandder_attach_etsili_buffer(FORMAT_DATA->shareddec, packet->buffer,
     598                        0, false);
     599        reclen = (size_t)wandder_etsili_get_pdu_length(
     600                        FORMAT_DATA->shareddec);
    600601
    601602        return reclen;
     
    607608}
    608609
    609 static struct timeval etsilive_get_timeval(const libtrace_packet_t *packet) {
    610         /* TODO add cached timestamps to libtrace so we don't have to look
    611          * this up again. */
    612         struct timeval tv;
    613         wandder_etsispec_t *dec;
    614 
    615         tv.tv_sec = 0;
    616         tv.tv_usec = 0;
    617 
    618 
    619         dec = wandder_create_etsili_decoder();
    620         wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
    621         tv = wandder_etsili_get_header_timestamp(dec);
    622         wandder_free_etsili_decoder(dec);
    623         return tv;
     610static uint64_t etsilive_get_erf_timestamp(const libtrace_packet_t *packet) {
     611        return packet->order;
    624612}
    625613
     
    652640        NULL,                           /* get_direction */
    653641        NULL,                           /* set_direction */
    654         NULL,                           /* get_erf_timestamp */
    655         etsilive_get_timeval,           /* get_timeval */
     642        etsilive_get_erf_timestamp,     /* get_erf_timestamp */
     643        NULL,                           /* get_timeval */
    656644        NULL,                           /* get_timespec */
    657645        NULL,                           /* get_seconds */
Note: See TracChangeset for help on using the changeset viewer.