If answer to the repeated probe (same TTL as in the previous probe) packet
authorHasso Tepper <hasso@dragonflybsd.org>
Thu, 25 Oct 2007 08:12:42 +0000 (08:12 +0000)
committerHasso Tepper <hasso@dragonflybsd.org>
Thu, 25 Oct 2007 08:12:42 +0000 (08:12 +0000)
comes from different host (common in case of multipath routes), output it
to the new line - much better to read.

Obtained-from: FreeBSD with modifications

usr.sbin/traceroute/traceroute.c
usr.sbin/traceroute6/traceroute6.c

index 118a7ce..548e642 100644 (file)
@@ -32,7 +32,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/usr.sbin/traceroute/traceroute.c,v 1.8 2007/08/03 09:50:05 hasso Exp $
+ * $DragonFly: src/usr.sbin/traceroute/traceroute.c,v 1.9 2007/10/25 08:12:42 hasso Exp $
  * @(#)traceroute.c    8.1 (Berkeley) 6/6/93
  */
 
@@ -600,6 +600,7 @@ main(int argc, char *argv[])
 
        for (ttl = first_ttl; ttl <= max_ttl; ++ttl) {
                int got_there = 0, unreachable = 0, timeout = 0, loss;
+               int gotlastaddr = 0;
                in_addr_t lastaddr = 0;
                quad_t dt;
 
@@ -621,9 +622,13 @@ main(int argc, char *argv[])
                                /* Skip short packet */
                                if (i == 0)
                                        continue;
-                               if (from.sin_addr.s_addr != lastaddr) {
+                               if (!gotlastaddr ||
+                                   from.sin_addr.s_addr != lastaddr) {
+                                       if (gotlastaddr)
+                                               printf("\n   ");
                                        print(packet, cc, &from);
                                        lastaddr = from.sin_addr.s_addr;
+                                       ++gotlastaddr;
                                }
                                dt = (quad_t)(t2.tv_sec - t1.tv_sec) * 1000000 +
                                    (quad_t)(t2.tv_usec - t1.tv_usec);
index be63879..017df90 100644 (file)
@@ -31,7 +31,7 @@
  * @(#) Copyright (c) 1990, 1993 The Regents of the University of California.  All rights reserved.
  * @(#)traceroute.c    8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.sbin/traceroute6/traceroute6.c,v 1.4.2.4 2001/07/03 11:02:18 ume Exp $
- * $DragonFly: src/usr.sbin/traceroute6/traceroute6.c,v 1.6 2004/12/18 22:48:14 swildner Exp $
+ * $DragonFly: src/usr.sbin/traceroute6/traceroute6.c,v 1.7 2007/10/25 08:12:42 hasso Exp $
  */
 
 /*-
@@ -836,6 +836,7 @@ main(int argc, char **argv)
                struct in6_addr lastaddr;
                int got_there = 0;
                int unreachable = 0;
+               int gotlastaddr = 0;
 
                Printf("%2d ", hops);
                bzero(&lastaddr, sizeof(lastaddr));
@@ -849,10 +850,14 @@ main(int argc, char **argv)
                        while ((cc = wait_for_reply(rcvsock, &rcvmhdr))) {
                                gettimeofday(&t2, &tz);
                                if ((i = packet_ok(&rcvmhdr, cc, seq))) {
-                                       if (! IN6_ARE_ADDR_EQUAL(&Rcv.sin6_addr,
+                                       if (!gotlastaddr ||
+                                           !IN6_ARE_ADDR_EQUAL(&Rcv.sin6_addr,
                                                            &lastaddr)) {
+                                               if (gotlastaddr)
+                                                       printf("\n   ");
                                                print(&rcvmhdr, cc);
                                                lastaddr = Rcv.sin6_addr;
+                                               ++gotlastaddr;
                                        }
                                        Printf("  %g ms", deltaT(&t1, &t2));
                                        switch(i - 1) {