diff -ur mtr-0.25/AUTHORS mtr-0.26/AUTHORS --- mtr-0.25/AUTHORS Mon Oct 26 14:48:15 1998 +++ mtr-0.26/AUTHORS Sat Oct 31 16:15:54 1998 @@ -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 -ur mtr-0.25/Makefile.in mtr-0.26/Makefile.in --- mtr-0.25/Makefile.in Wed Oct 28 00:12:54 1998 +++ mtr-0.26/Makefile.in Sat Oct 31 13:56:42 1998 @@ -385,7 +385,7 @@ clean: clean-recursive clean-am distclean: distclean-recursive distclean-am - rm -f config.status *~ + rm -f config.status maintainer-clean: maintainer-clean-recursive maintainer-clean-am @echo "This command is intended for maintainers to use;" diff -ur mtr-0.25/NEWS mtr-0.26/NEWS --- mtr-0.25/NEWS Tue Oct 27 23:51:20 1998 +++ mtr-0.26/NEWS Sat Oct 31 16:22:48 1998 @@ -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 -ur mtr-0.25/TODO mtr-0.26/TODO --- mtr-0.25/TODO Tue Oct 27 18:12:34 1998 +++ mtr-0.26/TODO Sat Oct 31 13:52:20 1998 @@ -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 Only in mtr-0.25: bla diff -ur mtr-0.25/configure mtr-0.26/configure --- mtr-0.25/configure Tue Oct 27 19:34:21 1998 +++ mtr-0.26/configure Sat Oct 31 13:57:10 1998 @@ -609,7 +609,7 @@ PACKAGE=mtr -VERSION=0.25 +VERSION=0.26 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.25/configure.in mtr-0.26/configure.in --- mtr-0.25/configure.in Tue Oct 27 19:34:10 1998 +++ mtr-0.26/configure.in Sat Oct 31 13:56:35 1998 @@ -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 -ur mtr-0.25/dns.c mtr-0.26/dns.c --- mtr-0.25/dns.c Tue Oct 27 23:39:53 1998 +++ mtr-0.26/dns.c Sat Oct 31 14:54:11 1998 @@ -51,6 +51,9 @@ /* Hmm, it seems Irix requires this */ extern int errno; +/* Defined in mtr.c */ +extern int dns; + /* Defines */ #undef Debug @@ -387,7 +390,7 @@ 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_lookup(ip_t ip){ char *t; + if (!dns) return strlongip (ip); t = dns_lookup2 (ip); return t?t:strlongip(ip); } diff -ur mtr-0.25/dns.h mtr-0.26/dns.h --- mtr-0.25/dns.h Tue Oct 27 22:50:43 1998 +++ mtr-0.26/dns.h Sat Oct 31 15:16:58 1998 @@ -26,3 +26,4 @@ char *dns_lookup(int address); char *dns_lookup2(int address); int dns_forward(char *name); +char *strlongip (int address); diff -ur mtr-0.25/gtk.c mtr-0.26/gtk.c --- mtr-0.25/gtk.c Mon Oct 26 14:48:16 1998 +++ mtr-0.26/gtk.c Sat Oct 31 16:08:29 1998 @@ -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 +#include #ifndef NO_GTK #include @@ -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 @@ 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 @@ 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 @@ gint gtk_ping(gpointer data) { gtk_redraw(); net_send_batch(); - return TRUE; } @@ -316,8 +318,10 @@ 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 -ur mtr-0.25/mtr.8 mtr-0.26/mtr.8 --- mtr-0.25/mtr.8 Tue Oct 27 23:49:48 1998 +++ mtr-0.26/mtr.8 Sat Oct 31 14:57:07 1998 @@ -32,6 +32,9 @@ .B \-\-raw\c ] [\c +.B \-\-no-dns\c +] +[\c .B \-\-gtk\c ] [\c @@ -122,6 +125,16 @@ .B mtr 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 diff -ur mtr-0.25/mtr.c mtr-0.26/mtr.c --- mtr-0.25/mtr.c Wed Oct 28 00:24:46 1998 +++ mtr-0.26/mtr.c Sat Oct 31 16:18:00 1998 @@ -37,6 +37,7 @@ 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 @@ { "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 @@ 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 @@ 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 @@ 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 @@ 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 @@ #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 -ur mtr-0.25/net.c mtr-0.26/net.c --- mtr-0.25/net.c Wed Oct 28 00:03:09 1998 +++ mtr-0.26/net.c Sat Oct 31 16:00:33 1998 @@ -29,9 +29,14 @@ #include #include #include +#include +#include #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 @@ } -extern float WaitTime; -extern struct timeval intervaltime; -#include -#include int net_send_batch() { static int n_unknown = 10; @@ -359,10 +360,7 @@ 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 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 @@ #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 @@ remoteaddress.sin_family = AF_INET; remoteaddress.sin_addr.s_addr = addr; + net_reset (); net_send_batch(); } diff -ur mtr-0.25/select.c mtr-0.26/select.c --- mtr-0.25/select.c Mon Oct 26 14:48:16 1998 +++ mtr-0.26/select.c Sat Oct 31 16:07:54 1998 @@ -32,9 +32,10 @@ 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 @@ 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; .