From: Hasso Tepper Date: Thu, 25 Oct 2007 08:12:42 +0000 (+0000) Subject: If answer to the repeated probe (same TTL as in the previous probe) packet X-Git-Tag: v2.0.1~1982 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3472506ce9fea841c4dd59654ab2192a9962f82b If answer to the repeated probe (same TTL as in the previous probe) packet 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 --- diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 118a7ce94d..548e642049 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -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); diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index be63879f87..017df90f5c 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -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) {