]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.26 v0.26
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Sat, 31 Oct 1998 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:36 +0000 (20:45 +0000)
 - Added "-n" flag for numeric output.
 - Fixed IP numbers displaying backwards.
 - GTK mainloop now runs at 10 packets per second.
 -- That's too much if there are only 3 hosts
 -- that's too little if there are 20 hosts.
 -- Someone tell me how to change the "ping-timeout" callback time in
    gtk. Can't find it in the docs.
 - The default for "hostname" is now "localhost" so that you can start
   mtr without any arguments and later fill in the host you want to
   trace to.

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

AUTHORS
NEWS
TODO
configure.in
dns.c
dns.h
gtk.c
mtr.8
mtr.c
net.c
select.c

diff --git a/AUTHORS b/AUTHORS
index a52bb4c036a2953806b97fc6b61f793e57cb3a77..d8dd1ea0a836174783f2c681d73dac82b3118c31 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,9 +9,10 @@
 
   Thanks to everyone who has provided feedback on mtr.  
 
-  Thanks especially to those of you who have sent me code:
+  Thanks especially to those of you who have sent code:
 
        Brian Casey, Mircea Damian, Christophe Kalt, Simon Kirby,
-        Anand Kumria, Charles Levert, Russell Nelson, 
-        Aaron Scarisbrick, Andrew Stesin, Juha Takala, Rogier Wolff
+        Anand Kumria, Bertrand Leconte, Charles Levert, Alexander 
+        V. Lukyanov, Russell Nelson, Aaron Scarisbrick, Andrew 
+        Stesin, Juha Takala.
         and anyone who has slipped through the cracks of my mail file.
diff --git a/NEWS b/NEWS
index 8d938db0e32d470908d9e30930a5d6e446d575bb..f28612b7534abfacd4c87df95b9795b835a6b5fe 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,16 @@
 WHAT'S NEW?
 
+  v0.26
+        Added "-n" flag for numeric output. 
+        fixed IP numbers displaying backwards.
+        GTK mainloop now runs at 10 packets per second. 
+          - That's too much if there are only 3 hosts
+          - that's too little if there are 20 hosts.
+        -> Someone tell me how to change the "ping-timeout" 
+           callback time in gtk. Can't find it in the docs.
+        The default for "hostname" is now "localhost" so that
+        you can start mtr without any arguments and later 
+        fill in the host you want to trace to. 
 
   v0.25
         Included two "raw" formats. One for separating GUI from
diff --git a/TODO b/TODO
index 1277e768696077a64e4dd456cc41b2b0e5a0c2ab..0d406815cdd799a9b88ef0bf35dc436b876bb1b9 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@
 - Stuff to implement:
 
   - Allow mtr to log the return packets, for later analysis.
+    Done: 0.25 . Todo: allow the userinterface(s) to work while
+    still logging to a file. 
 
   - Request timestamping at the remote site.
        Andreas Fasbender has an algorithm that will allow us to 
index 8f9c701e765d55fcdda7340a00e7d726356b0c54..1fcb9b359b6e2b33720b724ae609d025f35cc927 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.25)
+AM_INIT_AUTOMAKE(mtr, 0.26)
 
 AC_SUBST(GTK_OBJ)
 AC_SUBST(CURSES_OBJ)
diff --git a/dns.c b/dns.c
index e41ad4ad3f58a85cd7631cede3626d7645ddce30..11143c44108c7c73536218d75a5fab7b56f8df42 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -51,6 +51,9 @@ extern char *sys_errlist[];
 /*  Hmm, it seems Irix requires this  */
 extern int errno;
 
+/* Defined in mtr.c */
+extern int dns;
+
 /* Defines */
 
 #undef Debug
@@ -387,7 +390,7 @@ void clearset(fd_set *set){
 
 char *strlongip(ip_t ip){
    struct in_addr a;
-   a.s_addr = ip;
+   a.s_addr = htonl(ip);
    return inet_ntoa(a);
 }
 
@@ -1174,6 +1177,7 @@ char *dns_lookup2(ip_t ip){
 char *dns_lookup(ip_t ip){
   char *t;
 
+  if (!dns) return strlongip (ip);
   t = dns_lookup2 (ip);
   return t?t:strlongip(ip);
 }
diff --git a/dns.h b/dns.h
index 3af73e4d6217bdb74ca4ec32b0d7e8ca860ff188..63228402dcdc3952eb6c5a9637929ef6f4de8321 100644 (file)
--- a/dns.h
+++ b/dns.h
@@ -26,3 +26,4 @@ void dns_events(double *sinterval);
 char *dns_lookup(int address);
 char *dns_lookup2(int address);
 int dns_forward(char *name);
+char *strlongip (int address);
diff --git a/gtk.c b/gtk.c
index 8fd7fed433fabc73ebc1454c868c401532edf92f..ea266726338ed2a15e366cf2fab8bbd2321b8f8e 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -1,6 +1,7 @@
 /*
     mtr  --  a network diagnostic tool
     Copyright (C) 1997,1998  Matt Kimball
+    Changes/additions Copyright (C) 1998 R.E.Wolff@BitWizard.nl
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -18,6 +19,7 @@
 */
 
 #include <config.h>
+#include <sys/time.h>
 
 #ifndef NO_GTK
 #include <stdlib.h>
@@ -32,6 +34,7 @@
 
 extern char *Hostname;
 extern float WaitTime;
+extern float DeltaTime;
 
 void gtk_do_init(int *argc, char ***argv) {
   static int done = 0;
@@ -127,9 +130,9 @@ GtkWidget *GetRow(int index) {
   if(addr != 0) {
     name = dns_lookup(addr);
     if(!name) {
-      sprintf(str, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, 
-             (addr >> 8) & 0xff, addr & 0xff);
-      name = str;
+      /* Actually this is not neccesary: 
+        dns_lookup always returns a printable string */
+      name = strlongip (addr);
     }
   }
 
@@ -245,7 +248,7 @@ void Window_fill(GtkWidget *Window) {
   GtkWidget *Toolbar;
   GtkWidget *List;
 
-  gtk_window_set_title(GTK_WINDOW(Window), "Matt's traceroute  [v" VERSION "]");
+  gtk_window_set_title(GTK_WINDOW(Window), "My traceroute  [v" VERSION "]");
   gtk_widget_set_usize(Window, 540, 400); 
   gtk_container_border_width(GTK_CONTAINER(Window), 10);
   VBox = gtk_vbox_new(FALSE, 10);
@@ -302,7 +305,6 @@ int gtk_keyaction() {
 gint gtk_ping(gpointer data) {
   gtk_redraw();
   net_send_batch();
-  
   return TRUE;
 }
 
@@ -316,8 +318,10 @@ void gtk_dns_data(gpointer data, gint fd, GdkInputCondition cond) {
   gtk_redraw();
 }
 
+
 void gtk_loop() {
-  gtk_timeout_add((int)(1000.0 * WaitTime), gtk_ping, NULL);
+  DeltaTime = WaitTime/10;
+  gtk_timeout_add(DeltaTime*1000, gtk_ping, NULL);
   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/mtr.8 b/mtr.8
index 026129322fa5f866b91c3f84a9d9693b98cd99db..4f01de6df84fc57ec14e84d6e914a5af6118315a 100644 (file)
--- a/mtr.8
+++ b/mtr.8
@@ -32,6 +32,9 @@ mtr \- a network diagnostic tool
 .B \-\-raw\c
 ]
 [\c
+.B \-\-no-dns\c
+]
+[\c
 .B \-\-gtk\c
 ]
 [\c
@@ -123,6 +126,16 @@ Use this option to force
 to use the curses based terminal
 interface (if available).
 
+.TP
+.B \-n
+.TP
+.B \-\-no-dns
+.br
+Use this option to force 
+.B mtr 
+to display numeric IP numbers and not try to resolve the
+host names. 
+
 .TP
 .B \-g
 .TP
diff --git a/mtr.c b/mtr.c
index 1315f8ecae0a6afd7de1ac1dc9f0065d4b6b1d0e..8c1bb9f2be8a5ff913c91341e704aa67cb6d7792 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -37,6 +37,7 @@ int PrintHelp = 0;
 int MaxPing = 16;
 float WaitTime = 1.0;
 char *Hostname = NULL;
+int dns = 1;
 
 void parse_arg(int argc, char **argv) {
   int opt;
@@ -48,6 +49,7 @@ void parse_arg(int argc, char **argv) {
     { "curses", 0, 0, 't' },
     { "gtk", 0, 0, 'g' },
     { "interval", 1, 0, 'i' },
+    { "no-dns", 0, 0, 'n' },
     { "split", 0, 0, 's' },     /* BL */
     { "raw", 0, 0, 'l' },
     { 0, 0, 0, 0 }
@@ -55,7 +57,7 @@ void parse_arg(int argc, char **argv) {
 
   opt = 0;
   while(1) {
-    opt = getopt_long(argc, argv, "hvrc:tklsi:", long_options, NULL);
+    opt = getopt_long(argc, argv, "hvrc:tklnsi:", long_options, NULL);
     if(opt == -1)
       break;
 
@@ -84,11 +86,14 @@ void parse_arg(int argc, char **argv) {
     case 'l':
       DisplayMode = DisplayRaw;
       break;
+    case 'n':
+      dns = 0;
+      break;
     case 'i':
       WaitTime = atof(optarg);
       if (WaitTime <= 0.0) {
        fprintf (stderr, "mtr: wait time must be positive\n");
-       exit (-1);
+       exit (1);
       }
       break;
     }
@@ -107,23 +112,22 @@ void parse_arg(int argc, char **argv) {
 int main(int argc, char **argv) {
   int traddr;
   struct hostent *host;
+  int net_preopen_result;
 
   /*  Get the raw sockets first thing, so we can drop to user euid immediately  */
-  if(net_preopen() != 0) {
-    printf("mtr: Unable to get raw socket.  (Executable not suid?)\n");
-    exit(0);
-  }
+
+  net_preopen_result = net_preopen ();
 
   /*  Now drop to user permissions  */
   if(seteuid(getuid())) {
     printf("mtr: Unable to drop permissions.\n");
-    exit(0);
+    exit(1);
   }
 
   /*  Double check, just in case  */
   if(geteuid() != getuid()) {
     printf("mtr: Unable to drop permissions.\n");
-    exit(0);
+    exit(1);
   }
   
   display_detect(&argc, &argv);
@@ -134,13 +138,20 @@ int main(int argc, char **argv) {
     exit(0);
   }
 
-  if(Hostname == NULL || PrintHelp) {
+  if(PrintHelp) {
     printf("usage: %s [-hvrctlis] [--help] [--version] [--report]\n"
           "\t\t[--report-cycles=COUNT] [--curses] [--gtk]\n"
            "\t\t[--raw] [--split]\n"      /* BL */
           "\t\t[--interval=SECONDS] HOSTNAME\n", argv[0]);
     exit(0);
   }
+  if (Hostname == NULL) Hostname = "localhost";
+
+  if(net_preopen_result != 0) {
+    printf("mtr: Unable to get raw socket.  (Executable not suid?)\n");
+    exit(1);
+  }
+
 
   host = gethostbyname(Hostname);
   if(host == NULL) {
@@ -149,14 +160,14 @@ int main(int argc, char **argv) {
 #else
     printf("mtr: error looking up \"%s\"\n", Hostname);
 #endif
-    exit(0);
+    exit(1);
   }
 
   traddr = *(int *)host->h_addr;
 
   if(net_open(traddr) != 0) {
     printf("mtr: Unable to get raw socket.  (Executable not suid?)\n");
-    exit(0);
+    exit(1);
   }
 
   display_open();
diff --git a/net.c b/net.c
index 3d4c252ccdd62d7fccd7b00622e95bb4f8b51e49..fb4d80dae192d49dfd6ca9ef1de9f1d04a88c95c 100644 (file)
--- a/net.c
+++ b/net.c
 #include <netinet/in.h>
 #include <memory.h>
 #include <unistd.h>
+#include <stdio.h>
+#include <math.h>
 
 #include "net.h"
 
+
+extern float WaitTime, DeltaTime;
+
 #define MaxTransit 4
 
 /*  We can't rely on header files to provide this information, because
@@ -341,10 +346,6 @@ void net_end_transit() {
 }
 
 
-extern float WaitTime;
-extern struct timeval intervaltime;
-#include <stdio.h>
-#include <math.h>
 
 int net_send_batch() {
   static int n_unknown = 10;
@@ -359,10 +360,7 @@ int net_send_batch() {
   
   if ((host[at].addr == remoteaddress.sin_addr.s_addr) ||
       (n_unknown == 0)) {
-    float wt = WaitTime / (float) at;
-
-    intervaltime.tv_sec = (int)(wt);
-    intervaltime.tv_usec = 1000000.0 * (wt - floor(wt));
+    DeltaTime = WaitTime / (float) (at+1);
     at = 0;
     n_unknown = 10;
     return 1;
@@ -377,7 +375,7 @@ int net_preopen() {
   int trueopt = 1;
 
   sendsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
-  if(sendsock == -1)
+  if(sendsock < 0)
     return -1;
 
 #ifdef IP_HDRINCL
@@ -391,8 +389,8 @@ int net_preopen() {
 #endif
 
   recvsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
-  if(recvsock == -1)
-    return -1;  
+  if(recvsock < 0)
+    return -1;
 
   return 0;
 }
@@ -416,6 +414,7 @@ void net_reopen(int addr) {
   remoteaddress.sin_family = AF_INET;
   remoteaddress.sin_addr.s_addr = addr;
 
+  net_reset ();
   net_send_batch();
 }
 
index b79cfe6fbadf028297b2d29b4bfdbf0f3a212d91..193ecd602f028c260a76cc14d0f2f2653d8146e9 100644 (file)
--- a/select.c
+++ b/select.c
 extern int Interactive;
 extern int MaxPing;
 extern float WaitTime;
+float DeltaTime;
 double dnsinterval;
 
-struct timeval intervaltime;
+static struct timeval intervaltime;
 
 void select_loop() {
   fd_set readfd;
@@ -48,11 +49,12 @@ void select_loop() {
   NumPing = 0;
   anyset = 0;
   gettimeofday(&lasttime, NULL);
-  wt = WaitTime/10;
-  intervaltime.tv_sec = (int)wt;
-  intervaltime.tv_usec = 1000000.0 * (wt - floor(wt));
+  DeltaTime = WaitTime/10;
 
   while(1) {
+    intervaltime.tv_sec = DeltaTime;
+    intervaltime.tv_usec = 1000000 *( DeltaTime - floor (DeltaTime));
+
     FD_ZERO(&readfd);
 
     maxfd = 0;