From d765d023e5efaee38cb6b64c35a0b974e59da084 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 26 May 2002 13:24:55 +0000 Subject: use sysctl to get ttl from the kernel; itojun ok --- usr.sbin/traceroute/traceroute.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'usr.sbin/traceroute') diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 14c37e55bde..6c136ef168f 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.42 2002/05/21 00:46:44 deraadt Exp $ */ +/* $OpenBSD: traceroute.c,v 1.43 2002/05/26 13:24:54 deraadt Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";*/ #else -static char rcsid[] = "$OpenBSD: traceroute.c,v 1.42 2002/05/21 00:46:44 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: traceroute.c,v 1.43 2002/05/26 13:24:54 deraadt Exp $"; #endif #endif /* not lint */ @@ -227,6 +227,7 @@ static char rcsid[] = "$OpenBSD: traceroute.c,v 1.42 2002/05/21 00:46:44 deraadt #include #include #include +#include #include #include @@ -309,6 +310,8 @@ main(argc, argv) struct ip *ip; u_int32_t tmprnd; int sump = 0; + int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL }; + size_t size = sizeof(max_ttl); if ((pe = getprotobyname("icmp")) == NULL) { fprintf(stderr, "icmp: unknown protocol\n"); @@ -323,6 +326,9 @@ main(argc, argv) seteuid(getuid()); setuid(getuid()); + (void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_ttl, &size, + NULL, 0); + ttl_flag = 0; lsrr = 0; on = 1; -- cgit v1.2.3