make args u_long not to lose accuracy due to conversion/overflow.
from mark@openbsd
This commit is contained in:
parent
06ad574db3
commit
f062d0205a
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: traceroute6.c,v 1.28 2002/09/08 01:41:13 itojun Exp $ */
|
/* $NetBSD: traceroute6.c,v 1.29 2002/10/23 03:48:07 itojun Exp $ */
|
||||||
/* $KAME: traceroute6.c,v 1.61 2002/09/08 01:28:05 itojun Exp $ */
|
/* $KAME: traceroute6.c,v 1.61 2002/09/08 01:28:05 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,7 +79,7 @@ static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: traceroute6.c,v 1.28 2002/09/08 01:41:13 itojun Exp $");
|
__RCSID("$NetBSD: traceroute6.c,v 1.29 2002/10/23 03:48:07 itojun Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ int wait_for_reply __P((int, struct msghdr *));
|
||||||
int setpolicy __P((int so, char *policy));
|
int setpolicy __P((int so, char *policy));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
void send_probe __P((int, int));
|
void send_probe __P((int, u_long));
|
||||||
struct udphdr *get_udphdr __P((struct ip6_hdr *, u_char *));
|
struct udphdr *get_udphdr __P((struct ip6_hdr *, u_char *));
|
||||||
int get_hoplim __P((struct msghdr *));
|
int get_hoplim __P((struct msghdr *));
|
||||||
double deltaT __P((struct timeval *, struct timeval *));
|
double deltaT __P((struct timeval *, struct timeval *));
|
||||||
|
@ -338,7 +338,7 @@ int rcvhlim;
|
||||||
struct in6_pktinfo *rcvpktinfo;
|
struct in6_pktinfo *rcvpktinfo;
|
||||||
|
|
||||||
struct sockaddr_in6 Src, Dst, Rcv;
|
struct sockaddr_in6 Src, Dst, Rcv;
|
||||||
int datalen; /* How much data */
|
u_long datalen; /* How much data */
|
||||||
#define ICMP6ECHOLEN 8
|
#define ICMP6ECHOLEN 8
|
||||||
/* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */
|
/* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */
|
||||||
char rtbuf[2064];
|
char rtbuf[2064];
|
||||||
|
@ -350,9 +350,9 @@ struct cmsghdr *cmsg;
|
||||||
char *source = 0;
|
char *source = 0;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
|
|
||||||
int nprobes = 3;
|
u_long nprobes = 3;
|
||||||
int first_hop = 1;
|
u_long first_hop = 1;
|
||||||
int max_hops = 30;
|
u_long max_hops = 30;
|
||||||
u_int16_t srcport;
|
u_int16_t srcport;
|
||||||
u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
|
u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
|
||||||
u_int16_t ident;
|
u_int16_t ident;
|
||||||
|
@ -371,7 +371,8 @@ main(argc, argv)
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
int error;
|
int error;
|
||||||
struct addrinfo hints, *res;
|
struct addrinfo hints, *res;
|
||||||
int ch, i, on, probe, seq, hops, rcvcmsglen;
|
int ch, i, on, seq, rcvcmsglen;
|
||||||
|
u_long probe, hops;
|
||||||
static u_char *rcvcmsgbuf;
|
static u_char *rcvcmsgbuf;
|
||||||
char hbuf[NI_MAXHOST], src0[NI_MAXHOST];
|
char hbuf[NI_MAXHOST], src0[NI_MAXHOST];
|
||||||
char *ep;
|
char *ep;
|
||||||
|
@ -436,7 +437,7 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
if (first_hop > max_hops) {
|
if (first_hop > max_hops) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"traceroute6: min hoplimit must be <= %d.\n",
|
"traceroute6: min hoplimit must be <= %lu.\n",
|
||||||
max_hops);
|
max_hops);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -494,7 +495,7 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
if (max_hops < first_hop) {
|
if (max_hops < first_hop) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"traceroute6: max hoplimit must be >= %d.\n",
|
"traceroute6: max hoplimit must be >= %lu.\n",
|
||||||
first_hop);
|
first_hop);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -847,12 +848,12 @@ main(argc, argv)
|
||||||
fprintf(stderr, " to %s (%s)", hostname, hbuf);
|
fprintf(stderr, " to %s (%s)", hostname, hbuf);
|
||||||
if (source)
|
if (source)
|
||||||
fprintf(stderr, " from %s", source);
|
fprintf(stderr, " from %s", source);
|
||||||
fprintf(stderr, ", %d hops max, %d byte packets\n",
|
fprintf(stderr, ", %lu hops max, %lu byte packets\n",
|
||||||
max_hops, datalen);
|
max_hops, datalen);
|
||||||
(void) fflush(stderr);
|
(void) fflush(stderr);
|
||||||
|
|
||||||
if (first_hop > 1)
|
if (first_hop > 1)
|
||||||
printf("Skipping %d intermediate hops\n", first_hop - 1);
|
printf("Skipping %lu intermediate hops\n", first_hop - 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main loop
|
* Main loop
|
||||||
|
@ -862,7 +863,7 @@ main(argc, argv)
|
||||||
int got_there = 0;
|
int got_there = 0;
|
||||||
int unreachable = 0;
|
int unreachable = 0;
|
||||||
|
|
||||||
printf("%2d ", hops);
|
printf("%2lu ", hops);
|
||||||
bzero(&lastaddr, sizeof(lastaddr));
|
bzero(&lastaddr, sizeof(lastaddr));
|
||||||
for (probe = 0; probe < nprobes; ++probe) {
|
for (probe = 0; probe < nprobes; ++probe) {
|
||||||
int cc;
|
int cc;
|
||||||
|
@ -983,7 +984,8 @@ setpolicy(so, policy)
|
||||||
|
|
||||||
void
|
void
|
||||||
send_probe(seq, hops)
|
send_probe(seq, hops)
|
||||||
int seq, hops;
|
int seq;
|
||||||
|
u_long hops;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1020,7 +1022,7 @@ send_probe(seq, hops)
|
||||||
if (i < 0 || i != datalen) {
|
if (i < 0 || i != datalen) {
|
||||||
if (i<0)
|
if (i<0)
|
||||||
perror("sendto");
|
perror("sendto");
|
||||||
printf("traceroute6: wrote %s %d chars, ret=%d\n",
|
printf("traceroute6: wrote %s %lu chars, ret=%d\n",
|
||||||
hostname, datalen, i);
|
hostname, datalen, i);
|
||||||
(void) fflush(stdout);
|
(void) fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue