grab max hlim/ttl from kernel via sysctl. sync w/openbsd

This commit is contained in:
itojun 2002-05-26 14:45:43 +00:00
parent 3fb28eec1f
commit c264025d4e
2 changed files with 16 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: traceroute.c,v 1.45 2002/01/12 02:42:58 yamt Exp $ */
/* $NetBSD: traceroute.c,v 1.46 2002/05/26 14:45:43 itojun Exp $ */
/*
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
@ -29,7 +29,7 @@ static const char rcsid[] =
#else
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n");
__RCSID("$NetBSD: traceroute.c,v 1.45 2002/01/12 02:42:58 yamt Exp $");
__RCSID("$NetBSD: traceroute.c,v 1.46 2002/05/26 14:45:43 itojun Exp $");
#endif
#endif
@ -212,6 +212,7 @@ __RCSID("$NetBSD: traceroute.c,v 1.45 2002/01/12 02:42:58 yamt Exp $");
#endif
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
@ -398,6 +399,11 @@ main(int argc, char **argv)
register u_short off = 0;
struct ifaddrlist *al, *al2;
char errbuf[132];
int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL };
size_t size = sizeof(max_ttl);
(void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_ttl, &size,
NULL, 0);
if ((cp = strrchr(argv[0], '/')) != NULL)
prog = cp + 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: traceroute6.c,v 1.20 2002/05/26 13:14:03 itojun Exp $ */
/* $NetBSD: traceroute6.c,v 1.21 2002/05/26 14:45:44 itojun Exp $ */
/* $KAME: traceroute6.c,v 1.50 2002/05/26 13:12:07 itojun Exp $ */
/*
@ -79,7 +79,7 @@ static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
#else
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: traceroute6.c,v 1.20 2002/05/26 13:14:03 itojun Exp $");
__RCSID("$NetBSD: traceroute6.c,v 1.21 2002/05/26 14:45:44 itojun Exp $");
#endif
#endif
@ -260,6 +260,7 @@ __RCSID("$NetBSD: traceroute6.c,v 1.20 2002/05/26 13:14:03 itojun Exp $");
#include <sys/uio.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#include <netinet/in.h>
@ -368,6 +369,8 @@ main(argc, argv)
static u_char *rcvcmsgbuf;
char hbuf[NI_MAXHOST], src0[NI_MAXHOST];
char *ep;
int mib[4] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DEFHLIM };
size_t size = sizeof(max_hops);
/*
* Receive ICMP
@ -381,6 +384,9 @@ main(argc, argv)
seteuid(getuid());
setuid(getuid());
(void) sysctl(mib, sizeof(mib)/sizeof(mib[0]), &max_hops, &size,
NULL, 0);
/* set a minimum set of socket options */
on = 1;
/* specify to tell receiving interface */