]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.36 v0.36
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Sun, 11 Apr 1999 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:37 +0000 (20:45 +0000)
 - 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.

source: ftp://ftp.bitwizard.nl/mtr/mtr-0.36.tar.gz

AUTHORS
NEWS
configure.in
gtk.c
net.c
net.h
select.c

diff --git a/AUTHORS b/AUTHORS
index ba732715b7210659045c183b998f40656d0ffb0f..f5076abbb225b5689012223ff55bbe322ab19439 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -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 --git a/NEWS b/NEWS
index 9a4e63750b0587f5954c3fe32b8af7c6fce2ba8b..873e5c2bba3a401930e87c31adb04f9cb0d07569 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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 
index a7f745d80a04185ebd54a4c8bed8db318d516c90..c68563d1505a8c67a7ea1a4549b97f4b68e730f0 100644 (file)
@@ -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 --git a/gtk.c b/gtk.c
index dff4d6213200fdff0db9347de1b6578375d3e2a5..bc9fcd3d54716659dc14d0e496d71cc174b687b6 100644 (file)
--- a/gtk.c
+++ b/gtk.c
 #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 @@ int gtk_detect(int *argc, char ***argv) {
     /* 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 @@ gint Restart_clicked(GtkWidget *Button, gpointer data) {
   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 @@ gint Pause_clicked(GtkWidget *Button, gpointer data) {
   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 @@ void Toolbar_fill(GtkWidget *Toolbar) {
   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 @@ void Toolbar_fill(GtkWidget *Toolbar) {
                     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 @@ gint gtk_ping(gpointer data) {
   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_dns_data(gpointer data, gint fd, GdkInputCondition cond) {
 
 
 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 --git a/net.c b/net.c
index aebda4112a2e56de42485060a0e7b9c57bb125b2..2d6137ce71882f2ff8f0d8c2e698ad80e4b61117 100644 (file)
--- a/net.c
+++ b/net.c
@@ -36,8 +36,6 @@
 #include "net.h"
 
 
-extern float WaitTime, DeltaTime;
-int timestamp;
 
 #define MaxTransit 4
 
@@ -107,12 +105,25 @@ static struct nethost host[MaxHost];
 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 @@ int net_send_batch() {
 
   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 @@ void net_reset() {
   int i;
 
   batch_at = 0;
+  numhosts = 10;
 
   for(at = 0; at < MaxHost; at++) {
     host[at].xmit = 0;
diff --git a/net.h b/net.h
index 929a7a667f21456c5df1dcc5fbfe3758df886a71..2038ab41a6516963832c928e147716a73e0e2840 100644 (file)
--- a/net.h
+++ b/net.h
@@ -35,6 +35,9 @@ int net_avg(int at);
 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);
index 39eaa3a144d6d2388be1a3768ac3382d5ec23820..6517cfa79bd8fde2fc64e66dd6298b1bf01e9de5 100644 (file)
--- a/select.c
+++ b/select.c
 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 @@ void select_loop() {
   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);