Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Aug 2019 16:22:43 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350993 - head/sbin/ping6
Message-ID:  <201908131622.x7DGMhUL047226@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Tue Aug 13 16:22:43 2019
New Revision: 350993
URL: https://svnweb.freebsd.org/changeset/base/350993

Log:
  Consistently use the byteorder functions in the correct direction
  
  Though ntohs and htons are functionally identical, they have different meanings.Using the correct one helps to document the code.
  
  Submitted by:	Ján Sučan <sucanjan@gmail.com>
  MFC after:	2 weeks
  Sponsored by:	Google, inc. (Google Summer of Code 2019)
  Differential Revision:	https://reviews.freebsd.org/D21219

Modified:
  head/sbin/ping6/ping6.c

Modified: head/sbin/ping6/ping6.c
==============================================================================
--- head/sbin/ping6/ping6.c	Tue Aug 13 15:52:28 2019	(r350992)
+++ head/sbin/ping6/ping6.c	Tue Aug 13 16:22:43 2019	(r350993)
@@ -1324,7 +1324,7 @@ pinger(void)
 
 		memcpy(nip->icmp6_ni_nonce, nonce,
 		    sizeof(nip->icmp6_ni_nonce));
-		*(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq);
+		*(u_int16_t *)nip->icmp6_ni_nonce = htons(seq);
 
 		memcpy(&outpack[ICMP6_NIQLEN], &dst.sin6_addr,
 		    sizeof(dst.sin6_addr));
@@ -1339,7 +1339,7 @@ pinger(void)
 
 		memcpy(nip->icmp6_ni_nonce, nonce,
 		    sizeof(nip->icmp6_ni_nonce));
-		*(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq);
+		*(u_int16_t *)nip->icmp6_ni_nonce = htons(seq);
 
 		cc = ICMP6_NIQLEN;
 		datalen = 0;
@@ -1351,7 +1351,7 @@ pinger(void)
 
 		memcpy(nip->icmp6_ni_nonce, nonce,
 		    sizeof(nip->icmp6_ni_nonce));
-		*(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq);
+		*(u_int16_t *)nip->icmp6_ni_nonce = htons(seq);
 
 		memcpy(&outpack[ICMP6_NIQLEN], &dst.sin6_addr,
 		    sizeof(dst.sin6_addr));
@@ -1366,14 +1366,14 @@ pinger(void)
 
 		memcpy(nip->icmp6_ni_nonce, nonce,
 		    sizeof(nip->icmp6_ni_nonce));
-		*(u_int16_t *)nip->icmp6_ni_nonce = ntohs(seq);
+		*(u_int16_t *)nip->icmp6_ni_nonce = htons(seq);
 		cc = ICMP6_NIQLEN;
 		datalen = 0;
 	} else {
 		icp->icmp6_type = ICMP6_ECHO_REQUEST;
 		icp->icmp6_code = 0;
 		icp->icmp6_id = htons(ident);
-		icp->icmp6_seq = ntohs(seq);
+		icp->icmp6_seq = htons(seq);
 		if (timing) {
 			struct timeval tv;
 			struct tv32 *tv32;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908131622.x7DGMhUL047226>