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 $ */
|
||||
|
||||
/*
|
||||
|
@ -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.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
|
||||
|
||||
|
@ -318,7 +318,7 @@ int wait_for_reply __P((int, struct msghdr *));
|
|||
int setpolicy __P((int so, char *policy));
|
||||
#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 *));
|
||||
int get_hoplim __P((struct msghdr *));
|
||||
double deltaT __P((struct timeval *, struct timeval *));
|
||||
|
@ -338,7 +338,7 @@ int rcvhlim;
|
|||
struct in6_pktinfo *rcvpktinfo;
|
||||
|
||||
struct sockaddr_in6 Src, Dst, Rcv;
|
||||
int datalen; /* How much data */
|
||||
u_long datalen; /* How much data */
|
||||
#define ICMP6ECHOLEN 8
|
||||
/* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */
|
||||
char rtbuf[2064];
|
||||
|
@ -350,9 +350,9 @@ struct cmsghdr *cmsg;
|
|||
char *source = 0;
|
||||
char *hostname;
|
||||
|
||||
int nprobes = 3;
|
||||
int first_hop = 1;
|
||||
int max_hops = 30;
|
||||
u_long nprobes = 3;
|
||||
u_long first_hop = 1;
|
||||
u_long max_hops = 30;
|
||||
u_int16_t srcport;
|
||||
u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
|
||||
u_int16_t ident;
|
||||
|
@ -371,7 +371,8 @@ main(argc, argv)
|
|||
struct hostent *hp;
|
||||
int error;
|
||||
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;
|
||||
char hbuf[NI_MAXHOST], src0[NI_MAXHOST];
|
||||
char *ep;
|
||||
|
@ -436,7 +437,7 @@ main(argc, argv)
|
|||
}
|
||||
if (first_hop > max_hops) {
|
||||
fprintf(stderr,
|
||||
"traceroute6: min hoplimit must be <= %d.\n",
|
||||
"traceroute6: min hoplimit must be <= %lu.\n",
|
||||
max_hops);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -494,7 +495,7 @@ main(argc, argv)
|
|||
}
|
||||
if (max_hops < first_hop) {
|
||||
fprintf(stderr,
|
||||
"traceroute6: max hoplimit must be >= %d.\n",
|
||||
"traceroute6: max hoplimit must be >= %lu.\n",
|
||||
first_hop);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -847,12 +848,12 @@ main(argc, argv)
|
|||
fprintf(stderr, " to %s (%s)", hostname, hbuf);
|
||||
if (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);
|
||||
(void) fflush(stderr);
|
||||
|
||||
if (first_hop > 1)
|
||||
printf("Skipping %d intermediate hops\n", first_hop - 1);
|
||||
printf("Skipping %lu intermediate hops\n", first_hop - 1);
|
||||
|
||||
/*
|
||||
* Main loop
|
||||
|
@ -862,7 +863,7 @@ main(argc, argv)
|
|||
int got_there = 0;
|
||||
int unreachable = 0;
|
||||
|
||||
printf("%2d ", hops);
|
||||
printf("%2lu ", hops);
|
||||
bzero(&lastaddr, sizeof(lastaddr));
|
||||
for (probe = 0; probe < nprobes; ++probe) {
|
||||
int cc;
|
||||
|
@ -983,7 +984,8 @@ setpolicy(so, policy)
|
|||
|
||||
void
|
||||
send_probe(seq, hops)
|
||||
int seq, hops;
|
||||
int seq;
|
||||
u_long hops;
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1020,7 +1022,7 @@ send_probe(seq, hops)
|
|||
if (i < 0 || i != datalen) {
|
||||
if (i<0)
|
||||
perror("sendto");
|
||||
printf("traceroute6: wrote %s %d chars, ret=%d\n",
|
||||
printf("traceroute6: wrote %s %lu chars, ret=%d\n",
|
||||
hostname, datalen, i);
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue