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.
This commit is contained in:
parent
885a59f2e0
commit
5db89bc7e6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91432
@ -755,10 +755,10 @@ pinger(void)
|
|||||||
icp->icmp_type = ICMP_ECHO;
|
icp->icmp_type = ICMP_ECHO;
|
||||||
icp->icmp_code = 0;
|
icp->icmp_code = 0;
|
||||||
icp->icmp_cksum = 0;
|
icp->icmp_cksum = 0;
|
||||||
icp->icmp_seq = ntransmitted;
|
icp->icmp_seq = htons(ntransmitted);
|
||||||
icp->icmp_id = ident; /* ID */
|
icp->icmp_id = ident; /* ID */
|
||||||
|
|
||||||
CLR(icp->icmp_seq % mx_dup_ck);
|
CLR(ntransmitted % mx_dup_ck);
|
||||||
|
|
||||||
if (timing)
|
if (timing)
|
||||||
(void)gettimeofday((struct timeval *)&outpack[8],
|
(void)gettimeofday((struct timeval *)&outpack[8],
|
||||||
@ -812,7 +812,7 @@ pr_pack(buf, cc, from, tv)
|
|||||||
struct ip *ip;
|
struct ip *ip;
|
||||||
struct timeval *tp;
|
struct timeval *tp;
|
||||||
double triptime;
|
double triptime;
|
||||||
int hlen, dupflag;
|
int hlen, dupflag, seq;
|
||||||
|
|
||||||
/* Check the IP header */
|
/* Check the IP header */
|
||||||
ip = (struct ip *)buf;
|
ip = (struct ip *)buf;
|
||||||
@ -852,12 +852,14 @@ pr_pack(buf, cc, from, tv)
|
|||||||
tmax = triptime;
|
tmax = triptime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TST(icp->icmp_seq % mx_dup_ck)) {
|
seq = ntohs(icp->icmp_seq);
|
||||||
|
|
||||||
|
if (TST(seq % mx_dup_ck)) {
|
||||||
++nrepeats;
|
++nrepeats;
|
||||||
--nreceived;
|
--nreceived;
|
||||||
dupflag = 1;
|
dupflag = 1;
|
||||||
} else {
|
} else {
|
||||||
SET(icp->icmp_seq % mx_dup_ck);
|
SET(seq % mx_dup_ck);
|
||||||
dupflag = 0;
|
dupflag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,7 +871,7 @@ pr_pack(buf, cc, from, tv)
|
|||||||
else {
|
else {
|
||||||
(void)printf("%d bytes from %s: icmp_seq=%u", cc,
|
(void)printf("%d bytes from %s: icmp_seq=%u", cc,
|
||||||
inet_ntoa(*(struct in_addr *)&from->sin_addr.s_addr),
|
inet_ntoa(*(struct in_addr *)&from->sin_addr.s_addr),
|
||||||
icp->icmp_seq);
|
seq);
|
||||||
(void)printf(" ttl=%d", ip->ip_ttl);
|
(void)printf(" ttl=%d", ip->ip_ttl);
|
||||||
if (timing)
|
if (timing)
|
||||||
(void)printf(" time=%.3f ms", triptime);
|
(void)printf(" time=%.3f ms", triptime);
|
||||||
|
Loading…
Reference in New Issue
Block a user