From: Roger Wolff Date: Wed, 6 Mar 2002 00:00:00 +0000 (+0000) Subject: mtr v0.48 X-Git-Tag: v0.48^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a31591aa69c6de1423d9fea62c9e4a3ea9ea6fd3;p=thirdparty%2Fmtr.git mtr v0.48 - Draw names in red (GTK) or bold (Curses) if host doesn't respond. source: ftp://ftp.bitwizard.nl/mtr/mtr-0.48.tar.gz --- diff --git a/AUTHORS b/AUTHORS index 2a64c98..8284464 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,6 +36,7 @@ Steve Kann (stevek@spheara.horizonlive.com) Damian Gryski (dgryski@uwaterloo.ca) Mircea Damian + Cougar (cougar@random.ee) Brian Casey Andrew Brown (atatat@atatdot.net) Bill Bogstad (bogstad@pobox.com) diff --git a/ChangeLog b/ChangeLog index 0c91c59..21df52d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2002-03-06 Cougar + + If hop doesn't respond, draw its name in red (GTK) or bold (curses) + 2002-02-09 bodq * Added --address option to bind to given IP addess @@ -8,7 +11,3 @@ it does not work for GLIBC2 systems (e.g., RedHat 7+). * Fixed the subordinate CHECK_LIBS on the test for res_mkquery, so that they test for res_mkquery, not res_init. - - - - diff --git a/configure.in b/configure.in index f8706a5..5acab79 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.47) +AM_INIT_AUTOMAKE(mtr, 0.48) AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) diff --git a/curses.c b/curses.c index 0c8e2df..9129132 100644 --- a/curses.c +++ b/curses.c @@ -109,12 +109,15 @@ void mtr_curses_hosts(int startstat) { if(addr != 0) { name = dns_lookup(addr); + if (! net_up(at)) + attron(A_BOLD); if(name != NULL) { printw("%s", name); } else { printw("%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); } + attroff(A_BOLD); getyx(stdscr, y, x); move(y, startstat); @@ -224,12 +227,15 @@ void mtr_curses_graph(int startstat, int cols) { continue; } + if (! net_up(at)) + attron(A_BOLD); name = dns_lookup(addr); if (name) { printw("%s", name); } else { printw("%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) && 0xff, (addr >> 8) & 0xff, addr & 0xff); } + attroff(A_BOLD); getyx(stdscr, y, x); move(y, startstat); diff --git a/gtk.c b/gtk.c index 1d5e8db..a91bf33 100644 --- a/gtk.c +++ b/gtk.c @@ -283,6 +283,8 @@ void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, int num) { void gtk_update_row(GtkCList *List, int row) { int addr; char str[256], *name; + GdkColor color; + GdkColormap *cmap; addr = net_addr(row); name = "???"; @@ -294,6 +296,18 @@ void gtk_update_row(GtkCList *List, int row) { name = str; } } + + cmap = gtk_widget_get_colormap(ReportBody); + if (net_up(row)) { + gdk_color_black(cmap, &color); + } else { + color.red = 0xffffff; + color.green = 0; + color.blue = 0; + } + gdk_color_alloc (cmap, &color); + gtk_clist_set_foreground(List, row, &color); + gtk_set_field(List, row, 0, name); gtk_set_field_num(List, row, 1, "%d%%", net_percent(row)); diff --git a/mtr.c b/mtr.c index dd81332..fc5cd35 100644 --- a/mtr.c +++ b/mtr.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "mtr-curses.h" #include "getopt.h" diff --git a/net.c b/net.c index 7143e3f..2ab1bf4 100644 --- a/net.c +++ b/net.c @@ -85,6 +85,8 @@ struct nethost { uint32 addr; int xmit; int returned; + int sent; + int up; long long total; int last; int best; @@ -166,6 +168,9 @@ int new_sequence(int index) { memset(&sequence[seq].time, 0, sizeof(sequence[seq].time)); host[index].transit = 1; + if (host[index].sent) + host[index].up = 0; + host[index].sent = 1; net_save_xmit(index); return seq; @@ -254,6 +259,8 @@ void net_process_ping(int seq, uint32 addr, struct timeval now) { host[index].total += totusec; host[index].returned++; + host[index].sent = 0; + host[index].up = 1; host[index].transit = 0; net_save_return(index, sequence[seq].saved_seq, totusec); @@ -359,6 +366,10 @@ int net_transit(int at) { return host[at].transit; } +int net_up(int at) { + return host[at].up; +} + void net_end_transit() { int at; @@ -454,6 +465,8 @@ void net_reset() { host[at].xmit = 0; host[at].transit = 0; host[at].returned = 0; + host[at].sent = 0; + host[at].up = 0; host[at].total = 0; host[at].best = 0; host[at].worst = 0; diff --git a/net.h b/net.h index 12ea1ae..3607108 100644 --- a/net.h +++ b/net.h @@ -43,6 +43,8 @@ int net_returned(int at); int net_xmit(int at); int net_transit(int at); +int net_up(int at); + #define SAVED_PINGS 200 int* net_saved_pings(int at); void net_save_xmit(int at);