Skip to content

Commit

Permalink
Fixing issue 215
Browse files Browse the repository at this point in the history
  • Loading branch information
LocutusOfBorg committed May 8, 2014
1 parent 01da194 commit 7454f9b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/ec_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct ec_conf {
int connection_buffer;
int connect_timeout;
int sampling_rate;
int packet_update_count;
int close_on_eof;
int aggressive_dissectors;
int skip_forwarded;
Expand Down
1 change: 1 addition & 0 deletions share/etter.conf.v4
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ connect_timeout = 5 # seconds

[stats]
sampling_rate = 50 # number of packets
packet_update_count = 50 # number of packets

[misc]
close_on_eof = 1 # boolean value
Expand Down
1 change: 1 addition & 0 deletions share/etter.conf.v6
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ connect_timeout = 5 # seconds

[stats]
sampling_rate = 50 # number of packets
packet_update_count = 50 # number of packets

[misc]
close_on_eof = 1 # boolean value
Expand Down
2 changes: 2 additions & 0 deletions src/ec_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static struct conf_entry connections[] = {

static struct conf_entry stats[] = {
{ "sampling_rate", NULL },
{ "packet_update_count", NULL },
{ NULL, NULL },
};

Expand Down Expand Up @@ -179,6 +180,7 @@ static void init_structures(void)
set_pointer((struct conf_entry *)&connections, "connection_buffer", &GBL_CONF->connection_buffer);
set_pointer((struct conf_entry *)&connections, "connect_timeout", &GBL_CONF->connect_timeout);
set_pointer((struct conf_entry *)&stats, "sampling_rate", &GBL_CONF->sampling_rate);
set_pointer((struct conf_entry *)&stats, "packet_update_count", &GBL_CONF->packet_update_count);
set_pointer((struct conf_entry *)&misc, "close_on_eof", &GBL_CONF->close_on_eof);
set_pointer((struct conf_entry *)&misc, "store_profiles", &GBL_CONF->store_profiles);
set_pointer((struct conf_entry *)&misc, "aggressive_dissectors", &GBL_CONF->aggressive_dissectors);
Expand Down
22 changes: 15 additions & 7 deletions src/ec_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

/* globals */

static int count = 0;
static struct dec_entry *protocols_table;
static unsigned protocols_num;
static bool table_sorted = false;
Expand Down Expand Up @@ -80,9 +81,13 @@ void ec_decode(u_char *param, const struct pcap_pkthdr *pkthdr, const u_char *pk

CANCELLATION_POINT();

/* start the timer for the stats */
stats_half_start(&GBL_STATS->bh);

count++;
if(count = 1)
{
/* start the timer for the stats */
stats_half_start(&GBL_STATS->bh);
}

/* XXX -- remove this */
#if 0
if (!GBL_OPTIONS->quiet)
Expand Down Expand Up @@ -227,10 +232,13 @@ void ec_decode(u_char *param, const struct pcap_pkthdr *pkthdr, const u_char *pk

/* free the structure */
packet_destroy_object(&po);

/* calculate the stats */
stats_half_end(&GBL_STATS->bh, pkthdr->caplen);

if(count == GBL_CONF->packet_update_count)
{
/* calculate the stats */
stats_half_end(&GBL_STATS->bh, pkthdr->caplen);
count = 0;
}

CANCELLATION_POINT();

return;
Expand Down
24 changes: 17 additions & 7 deletions src/ec_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <ec_stats.h>
#include <ec_sleep.h>

/* globals */
static int count = 0;

/* this is the PO queue from bottom to top half */
struct po_queue_entry {
Expand Down Expand Up @@ -97,10 +99,14 @@ EC_THREAD_FUNC(top_half)
ec_usleep(1); // 1µs
continue;
}

/* start the counter for the TopHalf */
stats_half_start(&GBL_STATS->th);


count++;
if(count = 1)
{
/* start the counter for the TopHalf */
stats_half_start(&GBL_STATS->th);
}

/* remove the packet form the queue */
STAILQ_REMOVE_HEAD(&po_queue, e, next);

Expand Down Expand Up @@ -140,9 +146,13 @@ EC_THREAD_FUNC(top_half)
packet_destroy_object(e->po);
SAFE_FREE(e->po);
SAFE_FREE(e);

/* start the counter for the TopHalf */
stats_half_end(&GBL_STATS->th, pck_len);

if(count == GBL_CONF->packet_update_count)
{
/* start the counter for the TopHalf */
stats_half_end(&GBL_STATS->th, pck_len);
count = 0;
}
}

return NULL;
Expand Down

0 comments on commit 7454f9b

Please sign in to comment.