Changeset 00365c6


Ignore:
Timestamp:
05/18/18 11:39:59 (2 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.

Files:
3 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
  • libpacketdump/link_21.c

    rb663d33 r00365c6  
    66DLLEXPORT void decode(int link_type UNUSED, const char *packet, unsigned len) {
    77
    8         wandder_decoder_t dec;
    9         wandder_etsi_stack_t *stack = NULL;
    108        char linespace[4096];
    119        int i;
    1210        uint8_t *cchdr = NULL;
    1311        uint32_t rem = len;
     12        wandder_etsispec_t *dec;
     13        wandder_decoder_t *basedec = NULL;
    1414
    15         init_wandder_decoder(&dec, (uint8_t *)packet, len, false);
    16         while (wandder_etsili_get_next_fieldstr(&dec, linespace, 4096, &stack)) {
     15        dec = wandder_create_etsili_decoder();
     16        wandder_attach_etsili_buffer(dec, (uint8_t *)packet, len, false);
     17
     18        basedec = wandder_get_etsili_base_decoder(dec);
     19        while (wandder_etsili_get_next_fieldstr(dec, linespace, 4096)) {
    1720                printf(" ETSILI: ");
    18                 for (i = 0; i < wandder_get_level(&dec); i++) {
     21                for (i = 0; i < wandder_get_level(basedec); i++) {
    1922                        printf("  ");
    2023                }
     
    2225        }
    2326
    24         wandder_reset_decoder(&dec);
    25         cchdr = wandder_etsili_get_cc_contents(&dec, &rem);
     27        cchdr = wandder_etsili_get_cc_contents(dec, &rem);
    2628
    27         wandder_etsili_free_stack(stack);
    28         free_wandder_decoder(&dec);
     29        wandder_free_etsili_decoder(dec);
    2930
    3031        if (cchdr) {
Note: See TracChangeset for help on using the changeset viewer.