summaryrefslogtreecommitdiff
path: root/sbin/ping6
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2016-09-11 11:19:28 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2016-09-11 11:19:28 +0000
commit4b7e4ab86bf93f312772cae233f78030b594e2dc (patch)
tree9e03ecc6119f125a6375895220d94c074634a02a /sbin/ping6
parentcd9daecd206965402a8776f731dfca3820cfab7e (diff)
normalize seq handling in pinger; little step to make this AF
independent
Diffstat (limited to 'sbin/ping6')
-rw-r--r--sbin/ping6/ping6.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 9b55c0983dd..9db91c8e20f 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.165 2016/09/11 11:17:15 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.166 2016/09/11 11:19:27 florian Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
@@ -802,7 +802,7 @@ pinger(void)
{
struct icmp6_hdr *icp;
int i, cc;
- int seq;
+ u_int16_t seq;
if (npackets && ntransmitted >= npackets)
return(-1); /* no more transmission */
@@ -810,13 +810,13 @@ pinger(void)
icp = (struct icmp6_hdr *)outpack;
memset(icp, 0, sizeof(*icp));
icp->icmp6_cksum = 0;
- seq = ntransmitted++;
- CLR(seq % mx_dup_ck);
+ seq = htons(ntransmitted++);
+ CLR(ntohs(seq) % mx_dup_ck);
icp->icmp6_type = ICMP6_ECHO_REQUEST;
icp->icmp6_code = 0;
icp->icmp6_id = htons(ident);
- icp->icmp6_seq = ntohs(seq);
+ icp->icmp6_seq = seq;
if (timing) {
SIPHASH_CTX ctx;
struct timespec ts;
@@ -833,8 +833,7 @@ pinger(void)
SipHash24_Init(&ctx, &mac_key);
SipHash24_Update(&ctx, tv64, sizeof(*tv64));
SipHash24_Update(&ctx, &ident, sizeof(ident));
- SipHash24_Update(&ctx,
- &icp->icmp6_seq, sizeof(icp->icmp6_seq));
+ SipHash24_Update(&ctx, &seq, sizeof(seq));
SipHash24_Update(&ctx, &dst.sin6_addr, sizeof(dst.sin6_addr));
SipHash24_Final(&payload.mac, &ctx);