diff options
author | fenner <fenner@FreeBSD.org> | 2002-02-27 22:37:22 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 2002-02-27 22:37:22 +0000 |
commit | 095aa99d6ea5f50a3a37b36a5193f47927ad19fb (patch) | |
tree | 977011f4cb0932a57a4bf19862ac93de63fa7ffd | |
parent | 445306ca92c2145ed4b4ac3b6bf853d17acfb76c (diff) | |
download | FreeBSD-src-095aa99d6ea5f50a3a37b36a5193f47927ad19fb.zip FreeBSD-src-095aa99d6ea5f50a3a37b36a5193f47927ad19fb.tar.gz |
Use network byte order for the ICMP sequence number. This is only
significant when monitoring packets on another system, since
otherwise the ICMP sequence number is only used by the ping client.
-rw-r--r-- | sbin/ping/ping.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 302ab98..064993d 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -755,10 +755,10 @@ pinger(void) icp->icmp_type = ICMP_ECHO; icp->icmp_code = 0; icp->icmp_cksum = 0; - icp->icmp_seq = ntransmitted; + icp->icmp_seq = htons(ntransmitted); icp->icmp_id = ident; /* ID */ - CLR(icp->icmp_seq % mx_dup_ck); + CLR(ntransmitted % mx_dup_ck); if (timing) (void)gettimeofday((struct timeval *)&outpack[8], @@ -812,7 +812,7 @@ pr_pack(buf, cc, from, tv) struct ip *ip; struct timeval *tp; double triptime; - int hlen, dupflag; + int hlen, dupflag, seq; /* Check the IP header */ ip = (struct ip *)buf; @@ -852,12 +852,14 @@ pr_pack(buf, cc, from, tv) tmax = triptime; } - if (TST(icp->icmp_seq % mx_dup_ck)) { + seq = ntohs(icp->icmp_seq); + + if (TST(seq % mx_dup_ck)) { ++nrepeats; --nreceived; dupflag = 1; } else { - SET(icp->icmp_seq % mx_dup_ck); + SET(seq % mx_dup_ck); dupflag = 0; } @@ -869,7 +871,7 @@ pr_pack(buf, cc, from, tv) else { (void)printf("%d bytes from %s: icmp_seq=%u", cc, inet_ntoa(*(struct in_addr *)&from->sin_addr.s_addr), - icp->icmp_seq); + seq); (void)printf(" ttl=%d", ip->ip_ttl); if (timing) (void)printf(" time=%.3f ms", triptime); |