diff -ur mtr-0.35/AUTHORS mtr-0.36/AUTHORS --- mtr-0.35/AUTHORS Wed Apr 7 10:29:05 1999 +++ mtr-0.36/AUTHORS Sat Apr 10 10:26:58 1999 @@ -28,6 +28,7 @@ Steve Kann (stevek@spheara.horizonlive.com), Mircea Damian, Brian Casey, + Moritz Barsnick (barsnick@gmx.net) and anyone who has slipped through the cracks of my mail file. diff -ur mtr-0.35/NEWS mtr-0.36/NEWS --- mtr-0.35/NEWS Wed Apr 7 10:27:58 1999 +++ mtr-0.36/NEWS Sat Apr 10 10:33:58 1999 @@ -1,5 +1,10 @@ WHAT'S NEW? + v0.36 Added Craigs change-the-interval-on-the-fly patch. + Added Moritz Barsnick's "do something sensible if host not found" + patch. + Some cleanup of both Craigs and Moritz' patches. + v0.35 Added Craig Milo Rogers pause/resume for GTK patch. Added Craig Milo Rogers cleanup of "reset". (restart at the beginning) Net_open used to send a first packet. After that the display-driver diff -ur mtr-0.35/configure mtr-0.36/configure --- mtr-0.35/configure Wed Apr 7 09:32:37 1999 +++ mtr-0.36/configure Sat Apr 10 09:38:32 1999 @@ -700,7 +700,7 @@ PACKAGE=mtr -VERSION=0.35 +VERSION=0.36 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff -ur mtr-0.35/configure.in mtr-0.36/configure.in --- mtr-0.35/configure.in Wed Apr 7 09:30:44 1999 +++ mtr-0.36/configure.in Sat Apr 10 09:38:02 1999 @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.35) +AM_INIT_AUTOMAKE(mtr, 0.36) AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) diff -ur mtr-0.35/gtk.c mtr-0.36/gtk.c --- mtr-0.35/gtk.c Wed Apr 7 09:31:36 1999 +++ mtr-0.36/gtk.c Sat Apr 10 10:33:07 1999 @@ -32,11 +32,24 @@ #include "img/mtr_icon.xpm" #endif + +gint gtk_ping(gpointer data); + + extern char *Hostname; extern float WaitTime; -extern float DeltaTime; - static int tag; +static GtkWidget *Pause_Button; + + +void gtk_add_ping_timeout (void) +{ + int dt; + + dt = calc_deltatime (WaitTime); + tag = gtk_timeout_add(dt / 1000, gtk_ping, NULL); +} + void gtk_do_init(int *argc, char ***argv) { static int done = 0; @@ -53,7 +66,6 @@ /* If we do this here, gtk_init exits on an error. This happens BEFORE the user has had a chance to tell us not to use the display... */ - /* gtk_do_init(argc, argv); */ return TRUE; } else { return FALSE; @@ -73,13 +85,12 @@ return FALSE; } -gint gtk_ping(gpointer data); gint Pause_clicked(GtkWidget *Button, gpointer data) { static int paused = 0; if (paused) { - tag = gtk_timeout_add(DeltaTime*1000, gtk_ping, NULL); + gtk_add_ping_timeout (); } else { gtk_timeout_remove (tag); } @@ -89,12 +100,37 @@ return FALSE; } +/* + * There is a small problem with the following code: + * The timeout is canceled and removed in order to ensure that + * it takes effect (consider what happens if you set the timeout to 999, + * then try to undo the change); is a better approach possible? -- CMR + * + * What's the problem with this? (-> "I don't think so) -- REW + */ + +gint WaitTime_changed(GtkAdjustment *Adj, GtkWidget *Button) { + WaitTime = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(Button)); + gtk_timeout_remove (tag); + gtk_add_ping_timeout (); + gtk_redraw(); + + return FALSE; +} + gint Host_activate(GtkWidget *Entry, gpointer data) { int addr; addr = dns_forward(gtk_entry_get_text(GTK_ENTRY(Entry))); - if(addr) + if(addr) { net_reopen(addr); + /* If we are "Paused" at this point it is usually because someone + entered a non-existing host. Therefore do the go-ahead... --REW */ + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON( Pause_Button ) , 0); + } else { + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON( Pause_Button ) , 1); + gtk_entry_append_text( GTK_ENTRY(Entry), ": not found" ); + } return FALSE; } @@ -109,6 +145,7 @@ GtkWidget *Button; GtkWidget *Label; GtkWidget *Entry; + GtkAdjustment *Adjustment; Button = gtk_button_new_with_label("Quit"); gtk_box_pack_end(GTK_BOX(Toolbar), Button, FALSE, FALSE, 0); @@ -122,10 +159,24 @@ GTK_SIGNAL_FUNC(Restart_clicked), NULL); gtk_widget_show(Button); - Button = gtk_check_button_new_with_label("Pause"); - gtk_box_pack_end(GTK_BOX(Toolbar), Button, FALSE, FALSE, 0); - gtk_signal_connect(GTK_OBJECT(Button), "clicked", + Pause_Button = gtk_toggle_button_new_with_label("Pause"); + gtk_box_pack_end(GTK_BOX(Toolbar), Pause_Button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(Pause_Button), "clicked", GTK_SIGNAL_FUNC(Pause_clicked), NULL); + gtk_widget_show(Pause_Button); + + Adjustment = (GtkAdjustment *)gtk_adjustment_new(WaitTime, + 0.00, 999.99, + 1.0, 10.0, + 0.0); + Button = gtk_spin_button_new(Adjustment, 0.5, 2); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(Button), TRUE); + /* gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(Button), FALSE); */ + /* gtk_spin_button_set_set_update_policy(GTK_SPIN_BUTTON(Button), + GTK_UPDATE_IF_VALID); */ + gtk_box_pack_end(GTK_BOX(Toolbar), Button, FALSE, FALSE, 0); + gtk_signal_connect(GTK_OBJECT(Adjustment), "value_changed", + GTK_SIGNAL_FUNC(WaitTime_changed), Button); gtk_widget_show(Button); Label = gtk_label_new("Hostname"); @@ -338,7 +389,7 @@ gtk_redraw(); net_send_batch(); gtk_timeout_remove (tag); - tag = gtk_timeout_add(DeltaTime*1000, gtk_ping, NULL); + gtk_add_ping_timeout (); return TRUE; } @@ -354,8 +405,7 @@ void gtk_loop() { - DeltaTime = WaitTime/10; - tag = gtk_timeout_add(DeltaTime*1000, gtk_ping, NULL); + gtk_add_ping_timeout (); gdk_input_add(net_waitfd(), GDK_INPUT_READ, gtk_net_data, NULL); gdk_input_add(dns_waitfd(), GDK_INPUT_READ, gtk_dns_data, NULL); diff -ur mtr-0.35/net.c mtr-0.36/net.c --- mtr-0.35/net.c Wed Apr 7 10:18:20 1999 +++ mtr-0.36/net.c Sat Apr 10 09:50:51 1999 @@ -36,8 +36,6 @@ #include "net.h" -extern float WaitTime, DeltaTime; -int timestamp; #define MaxTransit 4 @@ -107,12 +105,25 @@ static struct sequence sequence[MaxSequence]; static struct timeval reset = { 0, 0 }; +int timestamp; int sendsock; int recvsock; struct sockaddr_in remoteaddress; static int batch_at = 0; + +static int numhosts = 10; + +/* return the number of microseconds to wait before sending the next + ping */ +int calc_deltatime (float waittime) +{ + waittime /= numhosts; + return 1000000 * waittime; +} + + /* This doesn't work for odd sz. I don't know enough about this to say that this is wrong. It doesn't seem to cripple mtr though. -- REW */ int checksum(void *data, int sz) { @@ -358,7 +369,7 @@ if ((host[batch_at].addr == remoteaddress.sin_addr.s_addr) || (n_unknown > MAX_UNKNOWN_HOSTS)) { - DeltaTime = WaitTime / (float) (batch_at+1); + numhosts = batch_at+1; batch_at = 0; return 1; } @@ -420,6 +431,7 @@ int i; batch_at = 0; + numhosts = 10; for(at = 0; at < MaxHost; at++) { host[at].xmit = 0; diff -ur mtr-0.35/net.h mtr-0.36/net.h --- mtr-0.35/net.h Wed Apr 7 09:29:57 1999 +++ mtr-0.36/net.h Sat Apr 10 09:50:41 1999 @@ -35,6 +35,9 @@ int net_send_batch(); void net_end_transit(); +int calc_deltatime (float WaitTime); + + /* Added by Brian Casey, December 1997 bcasey@imagiware.com*/ int net_returned(int at); int net_xmit(int at); diff -ur mtr-0.35/select.c mtr-0.36/select.c --- mtr-0.35/select.c Wed Apr 7 09:29:57 1999 +++ mtr-0.36/select.c Sat Apr 10 09:51:27 1999 @@ -32,11 +32,11 @@ extern int Interactive; extern int MaxPing; extern float WaitTime; -float DeltaTime; double dnsinterval; static struct timeval intervaltime; + void select_loop() { fd_set readfd; int anyset; @@ -46,16 +46,17 @@ int paused; struct timeval lasttime, thistime, selecttime; float wt; + int dt; NumPing = 0; anyset = 0; gettimeofday(&lasttime, NULL); - DeltaTime = WaitTime/10; paused=0; while(1) { - intervaltime.tv_sec = DeltaTime; - intervaltime.tv_usec = 1000000 *( DeltaTime - floor (DeltaTime)); + dt = calc_deltatime (WaitTime); + intervaltime.tv_sec = dt / 1000000; + intervaltime.tv_usec = dt % 1000000; FD_ZERO(&readfd); .