Add a -l flag, which displays the ttl of the returned packet.

From D'Arcy J.M. Cain <darcy@druid.com>, PR #2773.
This commit is contained in:
thorpej 1996-09-27 01:34:51 +00:00
parent e9b92001e2
commit af1f12dc6e
2 changed files with 17 additions and 5 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: traceroute.8,v 1.6 1995/10/12 03:05:50 mycroft Exp $
.\" $NetBSD: traceroute.8,v 1.7 1996/09/27 01:34:53 thorpej Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -47,6 +47,7 @@
.Op Fl d
.Op Fl D
.Op Fl g Ar gateway_addr
.Op Fl l
.Op Fl m Ar max_ttl
.Op Fl n
.Op Fl p Ar port
@ -87,6 +88,9 @@ Add
.Ar gateway_addr
to the list of addresses in the IP Loose Source Record Route (LSRR)
option. If no gateways are specified, the LSRR option is omitted.
.It Fl l
Display the ttl value of the returned packet. This is useful for
checking for assymetric routing.
.It Fl m Ar max_ttl
Set the max time-to-live (max number of hops) used in outgoing probe
packets. The default is 30 hops (the same default used for

View File

@ -1,4 +1,4 @@
/* $NetBSD: traceroute.c,v 1.14 1996/09/11 23:53:38 explorer Exp $ */
/* $NetBSD: traceroute.c,v 1.15 1996/09/27 01:34:51 thorpej Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -46,7 +46,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";*/
#else
static char rcsid[] = "$NetBSD: traceroute.c,v 1.14 1996/09/11 23:53:38 explorer Exp $";
static char rcsid[] = "$NetBSD: traceroute.c,v 1.15 1996/09/27 01:34:51 thorpej Exp $";
#endif
#endif /* not lint */
@ -301,13 +301,14 @@ main(argc, argv)
struct hostent *hp;
struct protoent *pe;
struct sockaddr_in from, to;
int ch, i, lsrr, on, probe, seq, tos, ttl;
int ch, i, lsrr, on, probe, seq, tos, ttl, ttl_flag;
struct ip *ip;
lsrr = 0;
on = 1;
seq = tos = 0;
while ((ch = getopt(argc, argv, "dDg:m:np:q:rs:t:w:v")) != -1)
ttl_flag = 0;
while ((ch = getopt(argc, argv, "dDg:lm:np:q:rs:t:w:v")) != -1)
switch (ch) {
case 'd':
options |= SO_DEBUG;
@ -328,6 +329,9 @@ main(argc, argv)
lsrrlen = 4;
lsrrlen += 4;
break;
case 'l':
ttl_flag = 1;
break;
case 'm':
max_ttl = atoi(optarg);
if (max_ttl < 1 || max_ttl > MAXTTL)
@ -509,7 +513,11 @@ main(argc, argv)
print(packet, cc, &from);
lastaddr = from.sin_addr.s_addr;
}
ip = (struct ip *)packet;
Printf(" %g ms", deltaT(&t1, &t2));
if (ttl_flag)
Printf(" (ttl = %d)",
ip->ip_ttl);
switch(i - 1) {
case ICMP_UNREACH_PORT:
#ifndef ARCHAIC