Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/traceroute6 make args u_long not to lose accuracy d...



details:   https://anonhg.NetBSD.org/src/rev/4f97cf112bc6
branches:  trunk
changeset: 538600:4f97cf112bc6
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Oct 23 03:48:07 2002 +0000

description:
make args u_long not to lose accuracy due to conversion/overflow.
from mark@openbsd

diffstat:

 usr.sbin/traceroute6/traceroute6.c |  32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diffs (120 lines):

diff -r 2bd312e565e8 -r 4f97cf112bc6 usr.sbin/traceroute6/traceroute6.c
--- a/usr.sbin/traceroute6/traceroute6.c        Wed Oct 23 03:28:34 2002 +0000
+++ b/usr.sbin/traceroute6/traceroute6.c        Wed Oct 23 03:48:07 2002 +0000
@@ -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 @@
 #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    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 @@
 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 @@
 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 @@
        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 @@
                        }
                        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 @@
                        }
                        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 @@
        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 @@
                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 @@
 
 void
 send_probe(seq, hops)
-       int seq, hops;
+       int seq;
+       u_long hops;
 {
        int i;
 
@@ -1020,7 +1022,7 @@
        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);
        }



Home | Main Index | Thread Index | Old Index