Changeset a151dda for lib


Ignore:
Timestamp:
09/30/15 13:58:44 (6 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
348396b
Parents:
d391ce0
Message:

Blind attempt at adding buckets to bpf:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_bpf.c

    r10553bf ra151dda  
    117117        /* A boolean flag indicating whether the statistics are up-to-date */
    118118        int stats_valid;
     119        /* Bucket data structure for safely storing buffers of packets */
     120        libtrace_bucket_t *bucket;
    119121};
    120122
     
    139141        FORMATIN(libtrace)->snaplen = 65536;
    140142        FORMATIN(libtrace)->stats_valid = 0;
     143        FORMATIN(libtrace)->bucket = libtrace_bucket_init();
    141144
    142145        return 0;
     
    203206        }
    204207
    205         FORMATIN(libtrace)->buffer = malloc(FORMATIN(libtrace)->buffersize);
    206         FORMATIN(libtrace)->bufptr = FORMATIN(libtrace)->buffer;
     208        FORMATIN(libtrace)->buffer = NULL;
     209        FORMATIN(libtrace)->bufptr = NULL;
    207210        FORMATIN(libtrace)->remaining = 0;
    208211
     
    344347static int bpf_fin_input(libtrace_t *libtrace)
    345348{
    346         free(libtrace->format_data);
     349        libtrace_bucket_destroy(FORMATIN(libtrace)->bucket);
     350        free(libtrace->format_data);
    347351        return 0;
    348352}
     
    457461        packet->type = bpf_linktype_to_rt(FORMATIN(libtrace)->linktype);
    458462
     463        if (FORMATIN(libtrace)->remaining <= 0) {
     464                FORMATIN(libtrace)->buffer = malloc(FORMATIN(libtrace)->buffer_size);
     465                libtrace_create_new_bucket(FORMATIN(libtrace)->bucket, FORMATIN(libtrace)->buffer);
     466        }
     467
    459468        while (FORMATIN(libtrace)->remaining <= 0) {
     469
    460470                tout.tv_sec = 0;
    461471                tout.tv_usec = 500000;
     
    503513        flags |= TRACE_PREP_DO_NOT_OWN_BUFFER;
    504514
    505         if (packet->buf_control == TRACE_CTRL_PACKET)
     515        if (packet->buffer && packet->buf_control == TRACE_CTRL_PACKET)
    506516                free(packet->buffer);
    507517
     
    512522                return -1;
    513523        }
    514        
    515 
    516         /* Skip past the packet record we're going to return, making sure
     524
     525        packet->internalid = libtrace_push_into_bucket(FORMATIN(libtrace)->bucket);
     526        packet->srcbucket = FORMATIN(libtrace)->bucket;
     527
     528        /* Skip past the packet record we're going to return, making sure
    517529         * that we deal with padding correctly */
    518530        FORMATIN(libtrace)->bufptr+=
Note: See TracChangeset for help on using the changeset viewer.