From: Roger Wolff Date: Sat, 23 Nov 2002 00:00:00 +0000 (+0000) Subject: mtr v0.52 X-Git-Tag: v0.52^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ad4e857466de7fba7b191d0cfdac538badc2c2d;p=thirdparty%2Fmtr.git mtr v0.52 - Mostly cleanups from Brett Johnson on MacOS X. It may clean up some compilation problems on MacOS X as well. source: ftp://ftp.bitwizard.nl/mtr/mtr-0.52.tar.gz --- diff --git a/AUTHORS b/AUTHORS index fdd5b58..746b50d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,6 +36,7 @@ Simon Kirby Christophe Kalt Steve Kann (stevek@spheara.horizonlive.com) + Brett Johnson (brett@jdacareers.com) Damian Gryski (dgryski@uwaterloo.ca) Mircea Damian Cougar (cougar@random.ee) diff --git a/Makefile.am b/Makefile.am index 59cd031..ac610ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = img sbin_PROGRAMS = mtr man_MANS = mtr.8 install-exec-am: - chmod u+s $(sbindir)/mtr + chmod u+s $(DESTDIR)$(sbindir)/mtr mtr_SOURCES = mtr.c \ net.c net.h \ diff --git a/NEWS b/NEWS index 4a45a5b..20d194d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ WHAT'S NEW? + v0.52 Mostly cleanups from Brett Johnson on MacOS X. It may + clean up some compilation problems on MacOS X as well. + v0.51 Fixed the bug introduced by the previous select loop fix... Thanks Evgeniy diff --git a/configure.in b/configure.in index 5b4ddab..e5ee5f6 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.51) +AM_INIT_AUTOMAKE(mtr, 0.52) AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) diff --git a/curses.c b/curses.c index 9129132..ab6cc39 100644 --- a/curses.c +++ b/curses.c @@ -22,6 +22,7 @@ #ifndef NO_CURSES #include #include +#include #if defined(HAVE_NCURSES_H) # include @@ -188,7 +189,6 @@ void mtr_print_scaled(int ms) { void mtr_fill_graph(int at, int cols) { int* saved; int i; - int val; saved = net_saved_pings(at); for (i = SAVED_PINGS-cols; i < SAVED_PINGS; i++) { diff --git a/display.c b/display.c index eea3269..a00ff10 100644 --- a/display.c +++ b/display.c @@ -18,11 +18,13 @@ */ #include +#include #include "display.h" #include "mtr-curses.h" #include "mtr-gtk.h" #include "report.h" #include "select.h" +#include "raw.h" extern int DisplayMode; @@ -32,14 +34,18 @@ extern int DisplayMode; #define mtr_curses_redraw() #define mtr_curses_keyaction() #define mtr_curses_clear() +#else +#include "mtr-curses.h" #endif #ifdef NO_GTK #define gtk_open() #define gtk_close() #define gtk_redraw() -#define gtk_keyaction() -#define gtk_loop() +#define gtk_keyaction() 0 +#define gtk_loop() {fprintf (stderr, "No GTK support. Sorry.\n"); exit (1); } +#else +#include "mtr-gtk.h" #endif #ifdef NO_SPLIT @@ -47,6 +53,8 @@ extern int DisplayMode; #define split_close() #define split_redraw() #define split_keyaction() 0 +#else +#include "split.h" #endif void display_detect(int *argc, char ***argv) { diff --git a/dns.c b/dns.c index fdcb069..c1237bc 100644 --- a/dns.c +++ b/dns.c @@ -314,8 +314,8 @@ void *statmalloc(size_t size){ mallocsize = size + TOT_SLACK * sizeof(dword); p = malloc(mallocsize); - if (!p){ - fprintf(stderr,"malloc() of %u bytes failed: %s\n",size,strerror(errno)); + if (!p) { + fprintf(stderr,"malloc() of %u bytes failed: %s\n", (unsigned int)size, strerror(errno)); exit(-1); } *((dword *)p) = (dword)size; @@ -515,11 +515,8 @@ void linkresolveid(struct resolve *addrp){ void unlinkresolveid(struct resolve *rp){ dword bashnum; bashnum = getidbash(rp->id); - if (idbash[bashnum] == rp) - if (rp->previousid) - idbash[bashnum] = rp->previousid; - else - idbash[bashnum] = rp->nextid; + if (idbash[bashnum] == rp) + idbash[bashnum] = (rp->previousid)? rp->previousid : rp->nextid; if (rp->nextid) rp->nextid->previousid = rp->previousid; if (rp->previousid) @@ -558,10 +555,7 @@ void unlinkresolvehost(struct resolve *rp){ dword bashnum; bashnum = gethostbash(rp->hostname); if (hostbash[bashnum] == rp) - if (rp->previoushost) - hostbash[bashnum] = rp->previoushost; - else - hostbash[bashnum] = rp->nexthost; + hostbash[bashnum] = (rp->previoushost)? rp->previoushost : rp->nexthost; if (rp->nexthost) rp->nexthost->previoushost = rp->previoushost; if (rp->previoushost) @@ -601,10 +595,7 @@ void unlinkresolveip(struct resolve *rp){ dword bashnum; bashnum = getipbash(rp->ip); if (ipbash[bashnum] == rp) - if (rp->previousip) - ipbash[bashnum] = rp->previousip; - else - ipbash[bashnum] = rp->nextip; + ipbash[bashnum] = (rp->previousip)? rp->previousip : rp->nextip; if (rp->nextip) rp->nextip->previousip = rp->previousip; if (rp->previousip) @@ -753,7 +744,7 @@ void dorequest(char *s,int type,word id){ packetheader *hp; int r,i; int buf[(MaxPacketsize/sizeof (int))+1]; - r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,buf,MaxPacketsize); + r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,(unsigned char*)buf,MaxPacketsize); if (r == -1){ restell("Resolver error: Query too large."); return; @@ -1107,13 +1098,14 @@ void dns_ack(){ } int istime(double x,double *sinterval){ - if (x) - if (x > sweeptime){ + if (x) { + if (x > sweeptime) { if (*sinterval > x - sweeptime) *sinterval = x - sweeptime; } else return 1; - return 0; + } + return 0; } void dns_events(double *sinterval){ diff --git a/getopt.c b/getopt.c index beb7450..3d43e26 100644 --- a/getopt.c +++ b/getopt.c @@ -39,6 +39,7 @@ #endif #include +#include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C @@ -486,7 +487,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) const struct option *pfound = NULL; int exact = 0; int ambig = 0; - int indfound; + int indfound = 0; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) @@ -538,7 +539,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) optarg = nameend + 1; else { - if (opterr) + if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, @@ -549,7 +550,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); - + } nextchar += strlen (nextchar); return '?'; } diff --git a/gtk.c b/gtk.c index a91bf33..64b13b0 100644 --- a/gtk.c +++ b/gtk.c @@ -301,7 +301,7 @@ void gtk_update_row(GtkCList *List, int row) { if (net_up(row)) { gdk_color_black(cmap, &color); } else { - color.red = 0xffffff; + color.red = 0xffff; color.green = 0; color.blue = 0; } diff --git a/mtr.8 b/mtr.8 index 91d87df..c56c1a4 100644 --- a/mtr.8 +++ b/mtr.8 @@ -65,11 +65,15 @@ starts, it investigates the network connection between the host .B mtr runs on and .BR HOSTNAME . -After it determines the address of each network hop between the -machines, it sends a sequence ICMP ECHO requests to each one to -determine the quality of the link to each machine. As it does this, -it prints running statistics about each machine. - +by sending packets with purposly low TTLs. It continues to send +packets with low TTL, noting the response time of the intervening +routers. This allows +.B mtr +to print the response percentage and response times of the internet +route to +.BR HOSTNAME . +A sudden increase in packetloss or response time is often an indication +of a bad (or simply overloaded) link. .SH OPTIONS diff --git a/mtr.c b/mtr.c index 467997d..462c411 100644 --- a/mtr.c +++ b/mtr.c @@ -17,6 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include "mtr-curses.h" #include "getopt.h" @@ -139,7 +141,6 @@ void parse_mtr_options (char *string) { int argc; char *argv[128], *p; - int i; if (!string) return; @@ -212,29 +213,28 @@ int main(int argc, char **argv) { if(InterfaceAddress) { /* Mostly borrowed from ping(1) code */ - struct sockaddr_in source; int i1, i2, i3, i4; char dummy; - extern int sendsock; /* from net.c:115 */ + extern int sendsock; /* from net.c:118 */ + extern struct sockaddr_in sourceaddress; /* from net.c:120 */ - bzero(&source, sizeof(source)); /* -- Evgeniy Tretyak */ - - source.sin_family = AF_INET; - source.sin_port = 0; + sourceaddress.sin_family = AF_INET; + sourceaddress.sin_port = 0; + sourceaddress.sin_addr.s_addr = 0; if(sscanf(InterfaceAddress, "%u.%u.%u.%u%c", &i1, &i2, &i3, &i4, &dummy) != 4) { printf("mtr: bad interface address: %s\n", InterfaceAddress); exit(1); } else { unsigned char*ptr; - ptr = (unsigned char*)&source.sin_addr; + ptr = (unsigned char*)&sourceaddress.sin_addr; ptr[0] = i1; ptr[1] = i2; ptr[2] = i3; ptr[3] = i4; } - if(bind(sendsock, (struct sockaddr*)&source, sizeof(source)) == -1) { + if(bind(sendsock, (struct sockaddr*)&sourceaddress, sizeof(sourceaddress)) == -1) { perror("mtr: failed to bind to interface"); exit(1); } diff --git a/net.c b/net.c index 2ab1bf4..2ac9ce0 100644 --- a/net.c +++ b/net.c @@ -37,7 +37,7 @@ #include #include "net.h" - +#include "display.h" #define MaxTransit 4 @@ -79,7 +79,7 @@ struct IPHeader { #define SOL_IP 0 #endif - +#define saddr_correction(addr) BSDfix ? addr : 0 struct nethost { uint32 addr; @@ -117,6 +117,7 @@ static struct timeval reset = { 0, 0 }; int timestamp; int sendsock; int recvsock; +struct sockaddr_in sourceaddress; struct sockaddr_in remoteaddress; static int batch_at = 0; @@ -201,7 +202,8 @@ void net_send_query(int index) { ip->frag = 0; ip->ttl = index + 1; ip->protocol = IPPROTO_ICMP; - ip->saddr = 0; + /* BSD needs the source address here, Linux & others do not... */ + ip->saddr = saddr_correction(sourceaddress.sin_addr.s_addr); ip->daddr = remoteaddress.sin_addr.s_addr; icmp->type = ICMP_ECHO; @@ -275,7 +277,6 @@ void net_process_return() { struct sockaddr_in fromaddr; int fromaddrsize; int num; - int at; struct ICMPHeader *header; struct timeval now; diff --git a/net.h b/net.h index 3607108..285e220 100644 --- a/net.h +++ b/net.h @@ -31,6 +31,7 @@ int net_addr(int at); int net_percent(int at); int net_best(int at); int net_worst(int at); +int net_last(int at); int net_avg(int at); int net_send_batch(); void net_end_transit(); diff --git a/select.c b/select.c index 7268699..04dad82 100644 --- a/select.c +++ b/select.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -47,7 +49,6 @@ void select_loop() { int NumPing; int paused; struct timeval lasttime, thistime, selecttime; - float wt; int dt; int rv; diff --git a/split.c b/split.c index 97fe5ae..388f581 100644 --- a/split.c +++ b/split.c @@ -24,13 +24,14 @@ #include #include #include +#include #include "display.h" #include "dns.h" -/* + #include "net.h" #include "split.h" -*/ + #include