diff --git a/options.c b/options.c index 7802a56..552c556 100644 --- a/options.c +++ b/options.c @@ -67,7 +67,8 @@ static void set_defaults() { options.promiscuous = 0; options.showbars = 1; options.showports = OPTION_PORTS_OFF; - options.aggregate = OPTION_AGGREGATE_OFF; + options.aggregate_src = 0; + options.aggregate_dest = 0; } static void die(char *msg) { diff --git a/options.h b/options.h index a78c67b..b7de6d5 100644 --- a/options.h +++ b/options.h @@ -38,7 +38,8 @@ typedef struct { int promiscuous; int showbars; option_port_t showports; - option_aggregate_t aggregate; + int aggregate_src; + int aggregate_dest; } options_t; diff --git a/ui.c b/ui.c index d57682d..0244884 100644 --- a/ui.c +++ b/ui.c @@ -209,12 +209,12 @@ void analyse_data() { ap = *(addr_pair*)n->key; /* Aggregate hosts, if required */ - if(options.aggregate == OPTION_AGGREGATE_SRC) { - ap.dst.s_addr = 0; - } - else if(options.aggregate == OPTION_AGGREGATE_DEST) { + if(options.aggregate_src) { ap.src.s_addr = 0; } + if(options.aggregate_dest) { + ap.dst.s_addr = 0; + } /* Aggregate ports, if required */ if(options.showports == OPTION_PORTS_DEST || options.showports == OPTION_PORTS_OFF) { @@ -362,13 +362,13 @@ void ui_print() { attron(A_REVERSE); addstr(" s "); attroff(A_REVERSE); - addstr(options.aggregate == OPTION_AGGREGATE_SRC ? " aggregate off " + addstr(options.aggregate_src ? " aggregate off " : " aggregate src "); attron(A_REVERSE); addstr(" d "); attroff(A_REVERSE); - addstr(options.aggregate == OPTION_AGGREGATE_DEST ? " aggregate off " + addstr(options.aggregate_dest ? " aggregate off " : " aggregate dest "); draw_bar_scale(&y); @@ -497,17 +497,11 @@ void ui_loop() { break; case 's': - options.aggregate = - (options.aggregate == OPTION_AGGREGATE_SRC) - ? OPTION_AGGREGATE_OFF - : OPTION_AGGREGATE_SRC; + options.aggregate_src = !options.aggregate_src; break; case 'd': - options.aggregate = - (options.aggregate == OPTION_AGGREGATE_DEST) - ? OPTION_AGGREGATE_OFF - : OPTION_AGGREGATE_DEST; + options.aggregate_dest = !options.aggregate_dest; break; case 'S': /* Show source ports */