]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.72 v0.72
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Fri, 29 Sep 2006 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:38 +0000 (20:45 +0000)
 - Fix signed/unsigned bug in IPV6 part improved random packet size
   behaviour. --REW

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

configure.in
curses.c
dns.c
mtr.8
mtr.c
net.c
report.c

index b1563efe26972109980d95446478e2123c5f241b..9e3bd52034b37ab0c0184c3381960930e26fef9e 100644 (file)
@@ -1,5 +1,5 @@
 AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.71)
+AM_INIT_AUTOMAKE(mtr, 0.72)
 
 
 AC_SUBST(GTK_OBJ)
index a2c9272a945350afc4a0ebb22176ae47d46b48c5..03157a2962c6948fcce5e6f21a3cf803967915b0 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -70,7 +70,7 @@
 extern char LocalHostname[];
 extern int fstTTL;
 extern int maxTTL;
-extern int packetsize;
+extern int cpacketsize;
 extern int bitpattern;
 extern int tos;
 extern float WaitTime;
@@ -118,8 +118,8 @@ int mtr_curses_keyaction(void)
 
   /* more stuffs added by Min */
   if (tolower(c) == 's') {
-    mvprintw(2, 0, "Change Packet Size: %d\n", packetsize );
-    mvprintw(3, 0, "Size Range: %d-%d, <random.\n", MINPACKET, MAXPACKET);
+    mvprintw(2, 0, "Change Packet Size: %d\n", cpacketsize );
+    mvprintw(3, 0, "Size Range: %d-%d, < 0:random.\n", MINPACKET, MAXPACKET);
     move(2,20);
     refresh();
     while ( (c=getch ()) != '\n' && i < MAXFLD ) {
@@ -127,15 +127,7 @@ int mtr_curses_keyaction(void)
       buf[i++] = c;   /* need more checking on 'c' */
     }
     buf[i] = '\0';
-    packetsize = atoi ( buf );
-    if( packetsize >=0 ) {
-      if ( packetsize < MINPACKET ) packetsize = MINPACKET;
-      if ( packetsize > MAXPACKET ) packetsize = MAXPACKET;
-    } else {
-      packetsize =
-      - (int)(MINPACKET + (MAXPACKET-MINPACKET)*(rand()/(RAND_MAX+0.1)));
-    }
-
+    cpacketsize = atoi ( buf );
     return ActionNone;
   }
   if (tolower(c) == 'b') {
@@ -498,12 +490,12 @@ void mtr_curses_redraw(void)
   mvprintw(1, 0, "%s (%s)", LocalHostname, net_localaddr());
   /*
   printw("(tos=0x%X ", tos);
-  printw("psize=%d ", abs(packetsize) );
+  printw("psize=%d ", packetsize );
   printw("bitpattern=0x%02X)", (unsigned char)(abs(bitpattern)));
-  if( packetsize>0 ){
-    printw("psize=%d ", packetsize);
+  if( cpacketsize > 0 ){
+    printw("psize=%d ", cpacketsize);
   } else {
-    printw("psize=rand(%d,%d) ",MINPACKET, MAXPACKET);
+    printw("psize=rand(%d,%d) ",MINPACKET, -cpacketsize);
   }
   if( bitpattern>=0 ){
     printw("bitpattern=0x%02X)", (unsigned char)(bitpattern));
diff --git a/dns.c b/dns.c
index ada3ab2296fa69bc189de3affbc0c0784ba7e1dd..ef3e518a34ad4ac8430022c8eac852f63f2b5f86 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -1357,7 +1357,7 @@ char *dns_lookup(ip_t * ip)
 #ifdef ENABLE_IPV6
 /* Returns an ip6.arpa character string. */
 void addr2ip6arpa( ip_t * ip, char * buf ) {
-  char * p = (char *) ip;
+  unsigned char * p = (unsigned char *) ip;
   char * b = buf;
   int i;
 
diff --git a/mtr.8 b/mtr.8
index af67d7f644b2ab10087a42e7fe4f5604274dcfda..d7b297d3c0b59bb62940795ca3a1346a64805db3 100644 (file)
--- a/mtr.8
+++ b/mtr.8
@@ -132,6 +132,9 @@ those machines.  Each cycle lasts one second.
 These options or a trailing PACKETSIZE on the commandline sets 
 the packet size used for probing.
 It is in bytes inclusive IP and ICMP headers
+
+If set to a negative number, every iteration will use a different, random
+packetsize upto that number. 
 .TP
 .B \-t
 .TP
diff --git a/mtr.c b/mtr.c
index 4b32c163a6fc5bf0706123f88ed6789bba8c596f..40ae11bf6f3d5aa93054167cc4e5cbf39e51b304 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -61,7 +61,7 @@ char *Hostname = NULL;
 char *InterfaceAddress = NULL;
 char  LocalHostname[128];
 int   dns = 1;
-int   packetsize = 64;          /* default packet size */
+int   cpacketsize = 64;          /* default packet size */
 int   bitpattern = 0;
 int   tos = 0;
 int af = DEFAULT_AF;
@@ -188,11 +188,7 @@ void parse_arg (int argc, char **argv)
       ForceMaxPing = 1;
       break;
     case 's':
-      packetsize = atoi (optarg);
-      if (packetsize >=0) {
-        if (packetsize < MINPACKET) packetsize = MINPACKET;
-        if (packetsize > MAXPACKET) packetsize = MAXPACKET;
-      }
+      cpacketsize = atoi (optarg);
       break;
     case 'a':
       InterfaceAddress = optarg;
@@ -284,11 +280,7 @@ void parse_arg (int argc, char **argv)
   Hostname = argv[optind++];
 
   if (argc > optind) {
-    packetsize = atoi (argv[optind]);
-    if (packetsize >=0 ) {
-      if (packetsize < MINPACKET) packetsize = MINPACKET;
-      if (packetsize > MAXPACKET) packetsize = MAXPACKET;
-    }
+    cpacketsize = atoi (argv[optind]);
   }
 }
 
diff --git a/net.c b/net.c
index 2a4b4627709eaf0b976f7f8a1427c083a8312588..327f35d58b564391e4887ce94a8b94d428b0d002 100644 (file)
--- a/net.c
+++ b/net.c
@@ -170,7 +170,8 @@ static int numhosts = 10;
 
 extern int fstTTL;             /* initial hub(ttl) to ping byMin */
 extern int maxTTL;             /* last hub to ping byMin*/
-extern int packetsize;         /* packet size used by ping */
+extern int cpacketsize;                /* packet size used by ping */
+static int packetsize;         /* packet size used by ping */
 extern int bitpattern;         /* packet bit pattern used by ping */
 extern int tos;                        /* type of service set in ping packet*/
 extern int af;                 /* address family of remote target */
@@ -697,15 +698,27 @@ int net_send_batch(void)
      bitpattern<0.  abs(packetsize) and/or abs(bitpattern) will be used 
   */
   if( batch_at < fstTTL ) {
-    if( packetsize < 0 ) {
-      packetsize = 
-       - (int)(MINPACKET + (MAXPACKET-MINPACKET)*(rand()/(RAND_MAX+0.1)));
+    if( cpacketsize < 0 ) {
+       /* Someone used a formula here that tried to correct for the 
+           "end-error" in "rand()". By "end-error" I mean that if you 
+           have a range for "rand()" that runs to 32768, and the 
+           destination range is 10000, you end up with 4 out of 32768 
+           0-2768's and only 3 out of 32768 for results 2769 .. 9999. 
+           As our detination range (in the example 10000) is much 
+           smaller (reasonable packet sizes), and our rand() range much 
+           larger, this effect is insignificant. Oh! That other formula
+           didn't work. -- REW */
+      packetsize = MINPACKET + rand () % (-cpacketsize - MINPACKET);
+    } else {
+      packetsize = cpacketsize;
     }
     if( bitpattern < 0 ) {
       bitpattern = - (int)(256 + 255*(rand()/(RAND_MAX+0.1)));
     }
   }
 
+  /* printf ("cpacketsize = %d, packetsize = %d\n", cpacketsize, packetsize);  */
+
   net_send_query(batch_at);
 
   for (i=fstTTL-1;i<batch_at;i++) {
index 7a1847e9a3eceebf1b8f92e2c57634f3c21744a2..8b9fe60da9452be807b009a0b6307df9fd16b4e1 100644 (file)
--- a/report.c
+++ b/report.c
@@ -36,7 +36,7 @@ extern char LocalHostname[];
 extern char *Hostname;
 extern int fstTTL;
 extern int maxTTL;
-extern int packetsize;
+extern int cpacketsize;
 extern int bitpattern;
 extern int tos;
 extern int MaxPing;
@@ -134,10 +134,10 @@ void xml_close(void)
 
   printf("<MTR SRC=%s DST=%s", LocalHostname, Hostname);
   printf(" TOS=0x%X", tos);
-  if( packetsize>=0 ){
-    printf(" PSIZE=%d", packetsize);
+  if(cpacketsize >= 0) {
+    printf(" PSIZE=%d", cpacketsize);
   } else {
-    printf(" PSIZE=rand(%d-%d)",MINPACKET, MAXPACKET);
+    printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize);
   }
   if( bitpattern>=0 ) {
     printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern));
@@ -206,10 +206,10 @@ void csv_close(void)
   /* Caption */
   printf("<SRC=%s DST=%s", LocalHostname, Hostname);
   printf(" TOS=0x%X", tos);
-  if( packetsize>=0 ){
-    printf(" PSIZE=%d", packetsize);
+  if(cpacketsize >= 0) {
+    printf(" PSIZE=%d", cpacketsize);
   } else {
-    printf(" PSIZE=rand(%d-%d)",MINPACKET, MAXPACKET);
+    printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize);
   }
   if( bitpattern>=0 ) {
     printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern));