diff --git a/TODO b/TODO index c315e2d..616d9dc 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ Things to do for iftop $Id$ -* Turn off services resolution. - * IP types other than v4? * Which average to use for the bar graph? Show several and peaks? Colours? diff --git a/options.c b/options.c index c9f8a43..00f3c67 100644 --- a/options.c +++ b/options.c @@ -71,6 +71,7 @@ static void set_defaults() { options.aggregate_src = 0; options.aggregate_dest = 0; options.paused = 0; + options.showhelp = 0; } static void die(char *msg) { diff --git a/options.h b/options.h index 329e494..9fbd0d9 100644 --- a/options.h +++ b/options.h @@ -42,6 +42,7 @@ typedef struct { int aggregate_src; int aggregate_dest; int paused; + int showhelp; } options_t; diff --git a/ui.c b/ui.c index 1cb268b..6d1ae9b 100644 --- a/ui.c +++ b/ui.c @@ -24,6 +24,25 @@ #define HISTORY_DIVISIONS 3 #define BARGRAPH_INTERVAL 1 /* which division used for bars. */ +#define HELP_MESSAGE \ +"Host display:\n"\ +" r - toggle DNS host resolution \n"\ +" s - toggle show source host\n"\ +" d - toggle show destination host\n"\ +"\nPort display:\n"\ +" R - toggle service resolution \n"\ +" S - toggle show source port \n"\ +" D - toggle show destination port\n"\ +" p - toggle port display\n"\ +"\nGeneral:\n"\ +" P - pause display\n"\ +" h - toggle this help display\n"\ +" b - toggle bar graph display\n"\ +" q - quit\n"\ +"\niftop, version " IFTOP_VERSION + + + /* 1, 15 and 60 seconds */ int history_divs[HISTORY_DIVISIONS] = {1, 5, 20}; @@ -384,52 +403,57 @@ void ui_print() { attron(A_REVERSE); addstr(" s "); attroff(A_REVERSE); - addstr(options.aggregate_src ? " aggregate off " - : " aggregate src "); + addstr(options.aggregate_src ? " show src " + : " hide src "); attron(A_REVERSE); addstr(" d "); attroff(A_REVERSE); - addstr(options.aggregate_dest ? " aggregate off " - : " aggregate dest "); + addstr(options.aggregate_dest ? " show dest " + : " hide dest "); draw_bar_scale(&y); + if(options.showhelp) { + mvaddstr(y,0,HELP_MESSAGE); + } + else { - /* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history - * items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two - * host names. */ + /* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history + * items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two + * host names. */ - while((nn = sorted_list_next_item(&screen_list, nn)) != NULL) { - int x = 0, L; - host_pair_line* screen_line = (host_pair_line*)nn->data; + while((nn = sorted_list_next_item(&screen_list, nn)) != NULL) { + int x = 0, L; + host_pair_line* screen_line = (host_pair_line*)nn->data; - if(y < LINES - 4) { - L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2; - if(L > sizeof hostname) { - L = sizeof hostname; - } + if(y < LINES - 4) { + L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2; + if(L > sizeof hostname) { + L = sizeof hostname; + } - sprint_host(line, &(screen_line->ap.src), screen_line->ap.src_port, screen_line->ap.protocol, L); + sprint_host(line, &(screen_line->ap.src), screen_line->ap.src_port, screen_line->ap.protocol, L); - //sprintf(line, "%-*s", L, hostname); - mvaddstr(y, x, line); - x += L; + //sprintf(line, "%-*s", L, hostname); + mvaddstr(y, x, line); + x += L; - mvaddstr(y, x, " => "); - mvaddstr(y+1, x, " <= "); + mvaddstr(y, x, " => "); + mvaddstr(y+1, x, " <= "); - x += 4; + x += 4; - sprint_host(line, &(screen_line->ap.dst), screen_line->ap.dst_port, screen_line->ap.protocol, L); + sprint_host(line, &(screen_line->ap.dst), screen_line->ap.dst_port, screen_line->ap.protocol, L); - mvaddstr(y, x, line); - - draw_line_totals(y, screen_line); + mvaddstr(y, x, line); + + draw_line_totals(y, screen_line); - } - y += 2; + } + y += 2; + } } @@ -518,6 +542,11 @@ void ui_loop() { tick(1); break; + case 'h': + options.showhelp = !options.showhelp; + tick(1); + break; + case 'b': options.showbars = !options.showbars; tick(1);