Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #215 #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion 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 @@ -184,12 +185,12 @@ static void init_structures(void)
set_pointer(mitm, "ndp_poison_equal_mac", &EC_GBL_CONF->ndp_poison_equal_mac);
set_pointer(mitm, "icmp6_probe_delay", &EC_GBL_CONF->icmp6_probe_delay);
#endif

set_pointer(connections, "connection_timeout", &EC_GBL_CONF->connection_timeout);
set_pointer(connections, "connection_idle", &EC_GBL_CONF->connection_idle);
set_pointer(connections, "connection_buffer", &EC_GBL_CONF->connection_buffer);
set_pointer(connections, "connect_timeout", &EC_GBL_CONF->connect_timeout);
set_pointer(stats, "sampling_rate", &EC_GBL_CONF->sampling_rate);
set_pointer(stats, "packet_update_count", &EC_GBL_CONF->packet_update_count);
set_pointer(misc, "close_on_eof", &EC_GBL_CONF->close_on_eof);
set_pointer(misc, "store_profiles", &EC_GBL_CONF->store_profiles);
set_pointer(misc, "aggressive_dissectors", &EC_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 @@ -39,6 +39,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 @@ -86,9 +87,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(&EC_GBL_STATS->bh);

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

/* XXX -- remove this */
#if 0
if (!EC_GBL_OPTIONS->quiet)
Expand Down Expand Up @@ -233,10 +238,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(&EC_GBL_STATS->bh, pkthdr->caplen);

if(count == EC_GBL_CONF->packet_update_count)
{
/* calculate the stats */
stats_half_end(&EC_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(&EC_GBL_STATS->th);


count++;
if(count == 1)
{
/* start the counter for the TopHalf */
stats_half_start(&EC_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(&EC_GBL_STATS->th, pck_len);

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

return NULL;
Expand Down