summaryrefslogtreecommitdiff
path: root/sbin/ping6/ping6.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-01 08:23:34 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-01 08:23:34 +0000
commit9dcaf3656438ee022f80bec8c3b7b7d5d3765802 (patch)
tree8ad768b6c24a6a7469f31e404f7bfc084e8d129f /sbin/ping6/ping6.c
parentd634269950d1398789a9d23213ec8e8acd8f7469 (diff)
fix 64 bit issues regarding timevals
Diffstat (limited to 'sbin/ping6/ping6.c')
-rw-r--r--sbin/ping6/ping6.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 2f348e878bb..b9254e07487 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.34 2001/10/26 05:09:35 mpech Exp $ */
+/* $OpenBSD: ping6.c,v 1.35 2001/11/01 08:23:33 deraadt Exp $ */
/* $KAME: ping6.c,v 1.129 2001/06/22 13:16:02 itojun Exp $ */
/*
@@ -249,6 +249,11 @@ volatile sig_atomic_t seenint;
volatile sig_atomic_t seeninfo;
#endif
+struct ping6_timeval {
+ int tv_sec;
+ int tv_usec;
+};
+
int main __P((int, char *[]));
void fill __P((char *, char *));
int get_hoplim __P((struct msghdr *));
@@ -626,7 +631,7 @@ main(argc, argv)
errx(1, "-f and -i incompatible options");
if ((options & F_NOUSERDATA) == 0) {
- if (datalen >= sizeof(struct timeval)) {
+ if (datalen >= sizeof(struct ping6_timeval)) {
/* we can time transfer */
timing = 1;
} else
@@ -1246,9 +1251,15 @@ pinger()
icp->icmp6_code = 0;
icp->icmp6_id = htons(ident);
icp->icmp6_seq = ntohs(seq);
- if (timing)
- (void)gettimeofday((struct timeval *)
- &outpack[ICMP6ECHOLEN], NULL);
+ if (timing) {
+ struct timeval tv;
+ struct ping6_timeval tv6;
+
+ (void)gettimeofday(&tv, NULL);
+ tv6.tv_sec = tv.tv_sec;
+ tv6.tv_usec = tv.tv_usec;
+ memcpy(&outpack[ICMP6ECHOLEN], &tv6, sizeof(tv6));
+ }
cc = ICMP6ECHOLEN + datalen;
}
@@ -1386,7 +1397,7 @@ pr_pack(buf, cc, mhdr)
int fromlen;
u_char *cp = NULL, *dp, *end = buf + cc;
struct in6_pktinfo *pktinfo = NULL;
- struct timeval tv, *tp;
+ struct timeval tv, tv2;
double triptime = 0;
int dupflag;
size_t off;
@@ -1428,8 +1439,12 @@ pr_pack(buf, cc, mhdr)
seq = ntohs(icp->icmp6_seq);
++nreceived;
if (timing) {
- tp = (struct timeval *)(icp + 1);
- tvsub(&tv, tp);
+ struct ping6_timeval tv6;
+
+ memcpy(&tv6, (void *)(icp + 1), sizeof(tv6));
+ tv2.tv_sec = tv6.tv_sec;
+ tv2.tv_usec = tv6.tv_usec;
+ tvsub(&tv, &tv2);
triptime = ((double)tv.tv_sec) * 1000.0 +
((double)tv.tv_usec) / 1000.0;
tsum += triptime;