]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.56 v0.56
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Mon, 5 Apr 2004 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:37 +0000 (20:45 +0000)
 - Fixed compile warnings. Now compiles with -Wall. If your compiler
   finds things mine didn't feel free to shout.

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

NEWS
configure.in
curses.c
dns.c
gtk.c
net.c
net.h
raw.c
select.c

diff --git a/NEWS b/NEWS
index 4e06bf204ab11fd64fc09221852c058870a14013..de4a1475cd8fda36943eb83db302ac1cdbbcab72 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,7 @@
 WHAT'S NEW?
+  v0.56 Fixed compile warnings. Now compiles with -Wall. If your
+       compiler finds things mine didn't feel free to shout. 
+
   v0.55 Cleanup patch. I'm going to do some maintenance on MTR, 
         but I want to be able to say: Can you see which version
        fixed/broke things for you, so you're going to see a 
index 707403ad77c65da58a924bcc1e7c61d1dcf29b85..59cba09f26f549c65a98fb6015ae30cbe7d7f78d 100644 (file)
@@ -1,5 +1,6 @@
 AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.55)
+AM_INIT_AUTOMAKE(mtr, 0.56)
+
 
 AC_SUBST(GTK_OBJ)
 AC_SUBST(CURSES_OBJ)
@@ -75,6 +76,49 @@ AC_CHECK_FUNC(res_mkquery, ,
 AC_CHECK_FUNC(herror, , AC_DEFINE(NO_HERROR))
 AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR))
 
+
+dnl Add C flags to display more warnings
+AC_MSG_CHECKING(for C flags to get more warnings)
+ac_save_CFLAGS="$CFLAGS"
+if test "x$ac_cv_prog_gcc" = "xyes" ; then
+  dnl gcc is the easiest C compiler
+  warning_CFLAGS="-Wall"
+else
+  dnl Vendor supplied C compilers are a bit tricky
+  case "$host_os" in
+    dnl SGI IRIX with the MipsPRO C compiler
+    irix*)
+      CFLAGS="$CFLAGS -fullwarn"
+      AC_TRY_COMPILE([#include <stdio.h>],[printf("test");],
+        warning_CFLAGS="-fullwarn",)
+      ;;
+
+    dnl SunOS 4.x with the SparcWorks(?) acc compiler
+    sunos*)
+        if "$CC" = "acc" ; then
+          CFLAGS="$CFLAGS -vc"
+          AC_TRY_COMPILE([#include <stdio.h>],[printf("test");],
+            warning_CFLAGS="-vc",)
+        fi
+      ;;
+
+    dnl Unknown, do nothing
+    *)
+      warning_CFLAGS="none"
+      ;;
+  esac
+fi
+CFLAGS="$ac_save_CFLAGS"
+if test "$warning_CFLAGS" = "none" ; then
+  AC_MSG_RESULT(none)
+else
+  CFLAGS="$CFLAGS $warning_CFLAGS"
+  AC_MSG_RESULT($warning_CFLAGS)
+fi
+
+
+
+
 AM_CONFIG_HEADER(config.h)
 AC_OUTPUT(Makefile img/Makefile)
 
index f7f63b215ecd57bab21d5924831019f9cd261b43..fb002e94e2b6bef9367f5672b8f04a1b519cd919 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -70,6 +70,36 @@ extern int tos;
 extern float WaitTime;
 
 
+struct fields data_fields[MAXFLD] = {
+  /* Remark, Header, Format, Width, CallBackFunc */
+  { "<sp>: Space between fields", " ",  " ",        1, &net_drop  },   /* 0 */
+  { "L: Loss Ratio",          "Loss%",  " %4.1f%%", 6, &net_loss  },   /* 1 */
+  { "D: Dropped Packets",     "Drop",   " %4d",     5, &net_drop  },   /* 2 */
+  { "R: Received Packets",    "Rcv",    " %5d",     6, &net_returned}, /* 3 */
+  { "S: Sent Packets",        "Snt",    " %5d",     6, &net_xmit  },   /* 4 */
+  { "N: Newest RTT(ms)",      "Last",   " %5.1f",   6, &net_last  },   /* 5 */
+  { "B: Min/Best RTT(ms)",    "Best",   " %5.1f",   6, &net_best  },   /* 6 */
+  { "A: Average RTT(ms)",     "Avg",    " %5.1f",   6, &net_avg   },   /* 7 */
+  { "W: Max/Worst RTT(ms)",   "Wrst",   " %5.1f",   6, &net_worst },   /* 8 */
+  { "V: Standard Deviation",  "StDev",  " %5.1f",   6, &net_stdev },   /* 9 */
+  { "G: Geometric Mean",      "Gmean",  " %5.1f",   6, &net_gmean },   /* 10 */
+  { "J: Current Jitter",      "Jttr",   " %4.1f",   5, &net_jitter},   /* 11 */
+  { "M: Jitter Mean/Avg.",    "Javg",   " %4.1f",   5, &net_javg  },   /* 12 */
+  { "X: Worst Jitter",        "Jmax",   " %4.1f",   5, &net_jworst},   /* 13 */
+  { "I: Interarrival Jitter", "Jint",   " %4.1f",   5, &net_jinta },   /* 14 */
+  { 0, 0, 0, 0, 0 }
+};
+
+
+/* keys: the value in the array is the index number in data_fields[] */
+int fld_index[] = {
+   0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,           /* ' ', 0,1..9 */
+   7,  6, -1,  2, -1, -1, 10, -1, 14, 11, -1,  1, 12,   /* A..M */
+   5, -1, -1, -1,  3,  4, -1, -1,  9,  8, 13, -1, -1,   /* N..Z */
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* a..m */
+  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* n..z */
+  -1
+};
 
 
 void pwcenter(char *str) {
@@ -116,7 +146,7 @@ int mtr_curses_keyaction() {
     move(2,20);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh ();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -137,7 +167,7 @@ int mtr_curses_keyaction() {
     move(2,18);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh ();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -151,7 +181,7 @@ int mtr_curses_keyaction() {
     move(2,22);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -166,7 +196,7 @@ int mtr_curses_keyaction() {
     move(2,11);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -182,7 +212,7 @@ int mtr_curses_keyaction() {
     move(2,11);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -198,7 +228,7 @@ int mtr_curses_keyaction() {
     move(2,9);
     refresh();
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh();
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
@@ -223,8 +253,8 @@ int mtr_curses_keyaction() {
 
     i = 0;
     while ( (c=getch ()) != '\n' && i<MAXFLD ) {
-      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh;
-      if( c>= 'A' && c<= 'Z' || c==' ') {
+      attron(A_BOLD); printw("%c", c); attroff(A_BOLD); refresh();
+      if( (c>= 'A' && c<= 'Z') || c==' ') {
         buf[i++] = c; /* only accept [ A-Z], can be extend to [a-z0-9] */
       }
     }
diff --git a/dns.c b/dns.c
index c1237bc0f3f8a89183ebbb7fa2a01a2e2b96046d..d9d5a1bac5ba3168c68dfa8c3ec196049cda2ff7 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -42,6 +42,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <time.h>
 
 #ifdef NO_STRERROR
 extern int sys_nerr;
@@ -1087,7 +1088,7 @@ void dns_ack(){
                break;
       if (i == _res.nscount){
          sprintf(tempstring,"Resolver error: Received reply from unknown source: %s",
-          strlongip(from.sin_addr.s_addr));
+         inet_ntoa(from.sin_addr));
          restell(tempstring);
       } else
          parserespacket((byte *)resrecvbuf,r);
diff --git a/gtk.c b/gtk.c
index c5f9cedc3327df553335f9939348f06218ccb2a8..52357a4e0b230ad91bc4551d810bdbb500571603 100644 (file)
--- a/gtk.c
+++ b/gtk.c
 */
 
 #include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include <sys/time.h>
+#include <sys/types.h>
 
 #ifndef NO_GTK
 #include <stdlib.h>
@@ -200,7 +205,7 @@ GtkWidget *ReportBody;
 
 GtkWidget *GetRow(int index) {
   int addr;
-  char str[256], *name;
+  char *name;
   GtkWidget *Row, *Label;
 
   Row = gtk_fixed_new();
diff --git a/net.c b/net.c
index f3d0ea9298b72044716f390d6e7515ccfdc3ce62..f7f5380fb7e169a9239062b7ddd62d60f8fccfad 100644 (file)
--- a/net.c
+++ b/net.c
@@ -516,10 +516,11 @@ int net_send_batch()
   for (i=fstTTL-1;i<batch_at;i++) {
     if (host[i].addr == 0)
       n_unknown++;
-    if (host[i].addr == remoteaddress.sin_addr.s_addr)
+
+    if ((host[i].addr == remoteaddress.sin_addr.s_addr) ||
+        (host[i].addr == host[batch_at].addr))
       n_unknown = MaxHost; /* Make sure we drop into "we should restart" */
   }
-
   if ( // success in reaching target
       (host[batch_at].addr == remoteaddress.sin_addr.s_addr) ||
       // fail in consecuitive MAX_UNKNOWN_HOSTS (firewall?)
diff --git a/net.h b/net.h
index 4e35062345e5f51cdead6e8e4ebf5368ec51f9c4..25740b9e497113c1a6b290b3c08e10d1356f6eab 100644 (file)
--- a/net.h
+++ b/net.h
@@ -43,6 +43,8 @@ int net_jitter(int at);
 int net_jworst(int at);
 int net_javg(int at);
 int net_jinta(int at);
+int net_addrs(int at, int i);
+
 
 int net_send_batch();
 void net_end_transit();
@@ -89,32 +91,8 @@ struct fields {
   int (*net_xxx)();
 };
 
-static struct fields data_fields[MAXFLD] = {
-  /* Remark, Header, Format, Width, CallBackFunc */
-  { "<sp>: Space between fields", " ",  " ",        1, &net_drop  },   /* 0 */
-  { "L: Loss Ratio",          "Loss%",  " %4.1f%%", 6, &net_loss  },   /* 1 */
-  { "D: Dropped Packets",     "Drop",   " %4d",     5, &net_drop  },   /* 2 */
-  { "R: Received Packets",    "Rcv",    " %5d",     6, &net_returned}, /* 3 */
-  { "S: Sent Packets",        "Snt",    " %5d",     6, &net_xmit  },   /* 4 */
-  { "N: Newest RTT(ms)",      "Last",   " %5.1f",   6, &net_last  },   /* 5 */
-  { "B: Min/Best RTT(ms)",    "Best",   " %5.1f",   6, &net_best  },   /* 6 */
-  { "A: Average RTT(ms)",     "Avg",    " %5.1f",   6, &net_avg   },   /* 7 */
-  { "W: Max/Worst RTT(ms)",   "Wrst",   " %5.1f",   6, &net_worst },   /* 8 */
-  { "V: Standard Deviation",  "StDev",  " %5.1f",   6, &net_stdev },   /* 9 */
-  { "G: Geometric Mean",      "Gmean",  " %5.1f",   6, &net_gmean },   /* 10 */
-  { "J: Current Jitter",      "Jttr",   " %4.1f",   5, &net_jitter},   /* 11 */
-  { "M: Jitter Mean/Avg.",    "Javg",   " %4.1f",   5, &net_javg  },   /* 12 */
-  { "X: Worst Jitter",        "Jmax",   " %4.1f",   5, &net_jworst},   /* 13 */
-  { "I: Interarrival Jitter", "Jint",   " %4.1f",   5, &net_jinta },   /* 14 */
-  { 0, 0, 0, 0, 0 }
-};
+extern struct fields data_fields[MAXFLD];
+
 
 /* keys: the value in the array is the index number in data_fields[] */
-static int fld_index[] = {
-   0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,           /* ' ', 0,1..9 */
-   7,  6, -1,  2, -1, -1, 10, -1, 14, 11, -1,  1, 12,   /* A..M */
-   5, -1, -1, -1,  3,  4, -1, -1,  9,  8, 13, -1, -1,   /* N..Z */
-  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* a..m */
-  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* n..z */
-  -1
-};
+extern  int fld_index[];
diff --git a/raw.c b/raw.c
index 42b3418dac0db5c2a8f81b0302b3a38bd643b665..d8b112d57e5f1f57183e0ed4545983c579d36659 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -22,6 +22,9 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 
 
 #include "raw.h"
@@ -30,6 +33,7 @@
 
 static int havename[MaxHost];
 
+#if 0
 static char *addr_to_str(int addr)
 {
   static char buf[20];
@@ -41,7 +45,7 @@ static char *addr_to_str(int addr)
           (addr >> 24) & 0xff);
   return buf;
 }
-
+#endif
 
 void raw_rawping (int host, int msec)
 {
@@ -55,12 +59,19 @@ void raw_rawping (int host, int msec)
     }
   }
   printf ("p %d %d\n", host, msec);
+  fflush (stdout); 
 }
 
 
 void raw_rawhost (int host, int ip_addr)
 {
-  printf ("h %d %s\n", host, addr_to_str (ip_addr));
+  struct in_addr in;
+
+  in.s_addr = ip_addr;
+
+  printf ("h %d %s\n", 
+         host, inet_ntoa(in));
+  fflush (stdout); 
 }
 
 
index c95b13a498e1c9dce390b1e3983f0f6b34d476ce..bd128110cf62eeec5552ae3bb81145fd6913f955 100644 (file)
--- a/select.c
+++ b/select.c
@@ -45,7 +45,6 @@ int display_offset = 0;
 
 void select_loop() {
   fd_set readfd;
-  int action;
   int anyset = 0;
   int maxfd = 0;
   int dnsfd, netfd;