Changeset 00365c6 for lib


Ignore:
Timestamp:
05/18/18 11:39:59 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, etsilive, master, rc-4.0.4, ringdecrementfix, ringperformance
Children:
991ff43
Parents:
b663d33
git-author:
Shane Alcock <salcock@…> (12/19/17 17:09:29)
git-committer:
Shane Alcock <salcock@…> (05/18/18 11:39:59)
Message:

Update to use new libwandder_etsili API

The new API should be more thread-safe than the original, at the
cost of being a bit more awkward to use.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/format_etsilive.c

    rb663d33 r00365c6  
    7373        uint16_t sourcecount;
    7474        int threadindex;
     75        wandder_etsispec_t *etsidec;
    7576} etsithread_t;
    7677
     
    263264                FORMAT_DATA->receivers[i].sourcecount = 0;
    264265                FORMAT_DATA->receivers[i].threadindex = i;
     266                FORMAT_DATA->receivers[i].etsidec =
     267                                wandder_create_etsili_decoder();
    265268
    266269        }
     
    291294                close(src.sock);
    292295        }
     296        wandder_free_etsili_decoder(receiver->etsidec);
    293297        free(receiver->sources);
    294298}
     
    425429                }
    426430
    427                 init_wandder_decoder(&dec, ptr, available, false);
     431                wandder_attach_etsili_buffer(et->etsidec, ptr, available, false);
    428432                if (et->sources[i].cached.length != 0) {
    429433                        reclen = et->sources[i].cached.length;
    430434                } else {
    431                         reclen = wandder_etsili_get_pdu_length(&dec);
     435                        reclen = wandder_etsili_get_pdu_length(et->etsidec);
    432436
    433437                        if (reclen == 0) {
    434                                 free_wandder_decoder(&dec);
    435438                                continue;
    436439                        }
     
    439442                if (available < reclen) {
    440443                        /* Don't have the whole PDU yet */
    441                         free_wandder_decoder(&dec);
    442444                        continue;
    443445                }
     
    445447                /* Get the timestamp */
    446448
    447                 tv = wandder_etsili_get_header_timestamp(&dec);
     449                tv = wandder_etsili_get_header_timestamp(et->etsidec);
    448450                if (tv.tv_sec == 0) {
    449                         free_wandder_decoder(&dec);
    450451                        continue;
    451452                }
     
    487488        packet->wire_length = esock->cached.length;
    488489        packet->capture_length = esock->cached.length;
     490
     491        /*
     492        for (j = 0; j < packet->wire_length; j++) {
     493                printf("%02x ", *(((uint8_t *)packet->buffer) + j));
     494                if ((j % 16) == 15) printf("\n");
     495        }
     496        printf("\n");
     497        */
    489498
    490499        /* Advance the read pointer for this buffer
     
    547556
    548557        /* Should never get here because cache is set when packet is read */
    549         wandder_decoder_t dec;
     558        wandder_etsispec_t *dec;
    550559        size_t reclen;
    551560
    552561        /* 0 should be ok here for quickly evaluating the first length
    553562         * field... */
    554         init_wandder_decoder(&dec, packet->buffer, 0, false);
    555         reclen = (size_t)wandder_etsili_get_pdu_length(&dec);
    556 
    557         free_wandder_decoder(&dec);
     563        dec = wandder_create_etsili_decoder();
     564        wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
     565        reclen = (size_t)wandder_etsili_get_pdu_length(dec);
     566        wandder_free_etsili_decoder(dec);
    558567
    559568        return reclen;
     
    569578         * this up again. */
    570579        struct timeval tv;
    571         wandder_decoder_t dec;
     580        wandder_etsispec_t *dec;
    572581
    573582        tv.tv_sec = 0;
    574583        tv.tv_usec = 0;
    575584
    576         init_wandder_decoder(&dec, packet->buffer, 0, false);
    577         tv = wandder_etsili_get_header_timestamp(&dec);
    578         free_wandder_decoder(&dec);
     585
     586        dec = wandder_create_etsili_decoder();
     587        wandder_attach_etsili_buffer(dec, packet->buffer, 0, false);
     588        tv = wandder_etsili_get_header_timestamp(dec);
     589        wandder_free_etsili_decoder(dec);
    579590        return tv;
    580591}
  • lib/protocols_pktmeta.c

    rb663d33 r00365c6  
    129129
    130130#ifdef HAVE_WANDDER
    131         wandder_decoder_t dec;
     131        wandder_etsispec_t *dec;
    132132        uint8_t *ccptr;
    133133
    134         init_wandder_decoder(&dec, (uint8_t *)link, *remaining, false);
    135         ccptr = wandder_etsili_get_cc_contents(&dec, remaining);
     134        /* XXX Bit annoying to be creating and freeing this every time */
     135        dec = wandder_create_etsili_decoder();
     136        wandder_attach_etsili_buffer(dec, (uint8_t *)link, *remaining, false);
     137        ccptr = wandder_etsili_get_cc_contents(dec, remaining);
    136138        /* Assuming all CCs are IP for now */
    137139        *type = TRACE_TYPE_NONE;
     140        wandder_free_etsili_decoder(dec);
    138141        return ccptr;
    139142
Note: See TracChangeset for help on using the changeset viewer.