Added "freeze order" option. Talk about feature creep :-)
This commit is contained in:
2
Makefile
2
Makefile
@@ -5,7 +5,7 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
|
||||||
VERSION = 0.10pre2
|
VERSION = 0.10pre3
|
||||||
|
|
||||||
# C compiler to use.
|
# C compiler to use.
|
||||||
#CC = gcc
|
#CC = gcc
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ static void set_defaults() {
|
|||||||
options.bandwidth_in_bytes = 0;
|
options.bandwidth_in_bytes = 0;
|
||||||
options.sort = OPTION_SORT_DIV2;
|
options.sort = OPTION_SORT_DIV2;
|
||||||
options.screenfilter = NULL;
|
options.screenfilter = NULL;
|
||||||
|
options.freezeorder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void die(char *msg) {
|
static void die(char *msg) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ typedef struct {
|
|||||||
option_sort_t sort;
|
option_sort_t sort;
|
||||||
|
|
||||||
char* screenfilter;
|
char* screenfilter;
|
||||||
|
int freezeorder;
|
||||||
|
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
|
|||||||
37
ui.c
37
ui.c
@@ -47,6 +47,7 @@
|
|||||||
" 1/2/3 - sort by 1st/2nd/3rd column\n"\
|
" 1/2/3 - sort by 1st/2nd/3rd column\n"\
|
||||||
" < - sort by source name\n"\
|
" < - sort by source name\n"\
|
||||||
" > - sort by dest name\n"\
|
" > - sort by dest name\n"\
|
||||||
|
" o - freeze current order\n"\
|
||||||
"\n"\
|
"\n"\
|
||||||
"iftop, version " IFTOP_VERSION
|
"iftop, version " IFTOP_VERSION
|
||||||
|
|
||||||
@@ -292,7 +293,7 @@ void screen_list_init() {
|
|||||||
sorted_list_initialise(&screen_list);
|
sorted_list_initialise(&screen_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_data_clear() {
|
void screen_list_clear() {
|
||||||
sorted_list_node* nn = NULL;
|
sorted_list_node* nn = NULL;
|
||||||
peaksent = peakrecv = peaktotal = 0;
|
peaksent = peakrecv = peaktotal = 0;
|
||||||
while((nn = sorted_list_next_item(&screen_list, nn)) != NULL) {
|
while((nn = sorted_list_next_item(&screen_list, nn)) != NULL) {
|
||||||
@@ -337,6 +338,18 @@ void make_screen_list() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Zeros all data in the screen hash, but does not remove items.
|
||||||
|
*/
|
||||||
|
void screen_hash_clear() {
|
||||||
|
hash_node_type* n = NULL;
|
||||||
|
while(hash_next_item(screen_hash, &n) == HASH_STATUS_OK) {
|
||||||
|
host_pair_line* hpl = (host_pair_line*)n->rec;
|
||||||
|
memset(hpl->recv, 0, sizeof(hpl->recv));
|
||||||
|
memset(hpl->sent, 0, sizeof(hpl->sent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void analyse_data() {
|
void analyse_data() {
|
||||||
hash_node_type* n = NULL;
|
hash_node_type* n = NULL;
|
||||||
|
|
||||||
@@ -346,7 +359,13 @@ void analyse_data() {
|
|||||||
|
|
||||||
memset(&totals, 0, sizeof totals);
|
memset(&totals, 0, sizeof totals);
|
||||||
|
|
||||||
screen_data_clear();
|
if(options.freezeorder) {
|
||||||
|
screen_hash_clear();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
screen_list_clear();
|
||||||
|
hash_delete_all(screen_hash);
|
||||||
|
}
|
||||||
|
|
||||||
while(hash_next_item(history, &n) == HASH_STATUS_OK) {
|
while(hash_next_item(history, &n) == HASH_STATUS_OK) {
|
||||||
history_type* d = (history_type*)n->rec;
|
history_type* d = (history_type*)n->rec;
|
||||||
@@ -356,6 +375,7 @@ void analyse_data() {
|
|||||||
int tsent, trecv;
|
int tsent, trecv;
|
||||||
tsent = trecv = 0;
|
tsent = trecv = 0;
|
||||||
|
|
||||||
|
|
||||||
ap = *(addr_pair*)n->key;
|
ap = *(addr_pair*)n->key;
|
||||||
|
|
||||||
/* Aggregate hosts, if required */
|
/* Aggregate hosts, if required */
|
||||||
@@ -399,9 +419,10 @@ void analyse_data() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!options.freezeorder) {
|
||||||
make_screen_list();
|
make_screen_list();
|
||||||
|
}
|
||||||
|
|
||||||
hash_delete_all(screen_hash);
|
|
||||||
|
|
||||||
calculate_totals();
|
calculate_totals();
|
||||||
|
|
||||||
@@ -750,6 +771,16 @@ void ui_loop() {
|
|||||||
case 'P':
|
case 'P':
|
||||||
options.paused = !options.paused;
|
options.paused = !options.paused;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
if(options.freezeorder) {
|
||||||
|
options.freezeorder = 0;
|
||||||
|
showhelp("Order unfrozen");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
options.freezeorder = 1;
|
||||||
|
showhelp("Order frozen");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
options.sort = OPTION_SORT_DIV1;
|
options.sort = OPTION_SORT_DIV1;
|
||||||
showhelp("Sort by col 1");
|
showhelp("Sort by col 1");
|
||||||
|
|||||||
Reference in New Issue
Block a user