sbin/routed/rdisc.c
/* Compute the IP checksum
 *	This assumes the packet is less than 32K long.
 */
Compute the IP checksum
This assumes the packet is less than 32K long.
Compute the IP checksum This assumes the packet is less than 32K long .
static u_short
in_cksum(u_short *p,
	 u_int len)
{
	u_int sum = 0;
	int nwords = len >> 1;
	while (nwords-- != 0)
		sum += *p++;
	if (len & 1)
		sum += *(u_char *)p;
	sum = (sum >> 16) + (sum & 0xffff);
	sum += (sum >> 16);
	return (~sum);
}
static u_short in_cksum ( u_short * p , u_int len ) { u_int sum = 0 ; int nwords = len >> 1 ; while ( nwords -- != 0 ) sum += * p ++ ; if ( len & 1 ) sum += * ( u_char * ) p ; sum = ( sum >> 16 ) + ( sum & 0xffff ) ; sum += ( sum >> 16 ) ; return ( ~ sum ) ; }
Compute the IP checksum
      This assumes the packet is less than 32K long.
Compute the IP checksum This assumes the packet is less than 32K long .
/* end-around-carry */