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

15 files changed:
AUTHORS
Makefile.am
NEWS
configure.in
curses.c
display.c
dns.c
getopt.c
gtk.c
mtr.8
mtr.c
net.c
net.h
select.c
split.c

diff --git a/AUTHORS b/AUTHORS
index fdd5b58b6c2fdd5d35e9e6ac97d447db7a08825a..746b50d74cf664f555b1263379d4d6b39dc179e0 100644 (file)
--- 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)
index 59cd0318700a788bb13e0c9c83ac1190d157a1b6..ac610ac42763d1d15c8c073ea3b4bc8fc2807dbf 100644 (file)
@@ -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 4a45a5bf8c87befbeccdf2185588847cf2c329af..20d194d006ca0814038a2c0616145ef27ab45e07 100644 (file)
--- 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
 
index 5b4ddabb42d6b1dfa1e0a95fb729d3f85a7cf0f6..e5ee5f6002faa3b0a15c33884ae37bf12463c65c 100644 (file)
@@ -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)
index 91291322990fd9d2d6909a09a1903f7a042e33bb..ab6cc3920e61f1ee6c0a89848ba3b411a9272d3b 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -22,6 +22,7 @@
 #ifndef NO_CURSES
 #include <ctype.h>
 #include <stdlib.h>
+#include <string.h>
 
 #if defined(HAVE_NCURSES_H)
 #  include <ncurses.h>
@@ -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++) {
index eea326999172b6162f79720cfd0f1300d60eae89..a00ff10c93945126c68e575dadc92c68151c350a 100644 (file)
--- a/display.c
+++ b/display.c
 */
 
 #include <config.h>
+#include <stdio.h>
 #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 fdcb0696395ad6640c3e3b6fbea101dc28375304..c1237bc0f3f8a89183ebbb7fa2a01a2e2b96046d 100644 (file)
--- 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){
index beb7450dd9cef766dc5c335013842a5f9801d476..3d43e26d950d35f06d545c65d5c90894b5e4fd1d 100644 (file)
--- a/getopt.c
+++ b/getopt.c
@@ -39,6 +39,7 @@
 #endif
 
 #include <stdio.h>
+#include <string.h>
 
 /* 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 a91bf338102b8fc7c357ecb54eacf4c517a6773f..64b13b074c2375f01787a1f608a381525bf25090 100644 (file)
--- 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 91d87df14eee0404cf52f1172213d8837f11c24b..c56c1a4b696798d11ae80f86f7846083ab97eb7d 100644 (file)
--- 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 467997d59a7477915f2ed47e6da71b6e52b51b6a..462c4115ad042288edb5b34d285b66b85a543c9e 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -17,6 +17,7 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <sys/types.h>
 #include <config.h>
 #include <netdb.h>
 #include <stdio.h>
@@ -24,6 +25,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <sys/socket.h> 
+#include <unistd.h>
 
 #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 2ab1bf473caff3f5e7a08b8783a20772320f4720..2ac9ce0075e8271a15e41f946c4720f055f28629 100644 (file)
--- a/net.c
+++ b/net.c
@@ -37,7 +37,7 @@
 #include <errno.h>
 
 #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 360710835fbe63f8d17230cb7b2841b4d47eb5e0..285e220511ca16c033d70866aec66f74fb587ccb 100644 (file)
--- 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();
index 72686990aa22c0be83e807ced073c1e3db8545b8..04dad82613c6f576b0834a18844393523ceb00e2 100644 (file)
--- a/select.c
+++ b/select.c
@@ -20,6 +20,8 @@
 #include <config.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <stdlib.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <time.h>
 #include <sys/select.h>
@@ -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 97fe5aedcd25cb6348d0c63c4792832ca66ff617..388f5810a337afdef15b184bd54e73197714c06a 100644 (file)
--- a/split.c
+++ b/split.c
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include "display.h"
 #include "dns.h"
-/*
+
 #include "net.h"
 #include "split.h"
-*/
+
 
 #include <config.h>