Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!clyde!cbatt!cbosgd!soma!guy
From: guy@soma.UUCP
Newsgroups: mod.computers.masscomp
Subject: Re: ICMP network utility
Message-ID: <2678@soma.bcm.tmc.edu>
Date: Wed, 10-Dec-86 13:09:23 EST
Article-I.D.: soma.2678
Posted: Wed Dec 10 13:09:23 1986
Date-Received: Sun, 14-Dec-86 01:10:18 EST
Sender: masscomp@soma.bcm.tmc.edu
Organization: Sun Microsystems
Lines: 57
Approved: masscomp@soma.uucp

> It should run on VAX, Masscomp and Sun for sure. If you find otherwise...

I found otherwise - or, more correctly, Doug Kingston found otherwise.  This
"ping" is based on a version prior to the one that came out in 4.3, but it
that version has the same bug Doug found in the 4.3 one; it doesn't work
with odd packet sizes on big-endian machines (like Suns and Masscomps).
Here's a "diff -c" listing of the changes needed to make it work with odd
packet sizes; however, if somebody has the 4.3 source they might want to
look at that version (and apply this fix, the 4.3 version still has that
bug).

[thanks! -- sob]

*** ping.c.BAK	Tue Dec  9 09:24:42 1986
--- ping.c	Tue Dec  9 09:28:46 1986
***************
*** 309,314 ****
--- 309,315 ----
  	register int nleft = len;
  	register u_short *w = addr;
  	register u_short answer;
+ 	u_short odd_byte = 0;
  	register int sum = 0;
  
  	/*
***************
*** 323,335 ****
  	}
  
  	/* mop up an odd byte, if necessary */
! 	if( nleft == 1 )
! 		sum += *(u_char *)w;
  
  	/*
  	 * add back carry outs from top 16 bits to low 16 bits
  	 */
! 	sum += (sum >> 16);	/* add hi 16 to low 16 */
  	answer = ~sum;		/* truncate to 16 bits */
  	return (answer);
  }
--- 324,339 ----
  	}
  
  	/* mop up an odd byte, if necessary */
! 	if( nleft == 1 ) {
! 		*(u_char *)(&odd_byte) = *(u_char *)w;
! 		sum += odd_byte;
! 	}
  
  	/*
  	 * add back carry outs from top 16 bits to low 16 bits
  	 */
! 	sum = (sum >> 16) + (sum & 0xffff);	/* add hi 16 to low 16 */
! 	sum += (sum >> 16);			/* add carry */
  	answer = ~sum;		/* truncate to 16 bits */
  	return (answer);
  }