Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping/utils.c
Context not available. | |||||
* Checksum routine for Internet Protocol family headers (C Version) | * Checksum routine for Internet Protocol family headers (C Version) | ||||
*/ | */ | ||||
u_short | u_short | ||||
in_cksum(u_char *addr, int len) | in_cksum(u_char *addr, size_t ipstructsize, int ip_maxpacket, int len) | ||||
{ | { | ||||
int nleft, sum; | int nleft, sum; | ||||
u_char *w; | u_char *w; | ||||
Context not available. | |||||
* sequential 16 bit words to it, and at the end, fold back all the | * sequential 16 bit words to it, and at the end, fold back all the | ||||
* carry bits from the top 16 bits into the lower 16 bits. | * carry bits from the top 16 bits into the lower 16 bits. | ||||
*/ | */ | ||||
while (nleft > 1) { | while ((nleft > 1) && (w < &addr[ip_maxpacket - ipstructsize - sizeof(u_short)])) { | ||||
u_short data; | u_short data; | ||||
memcpy(&data, w, sizeof(data)); | memcpy(&data, w, sizeof(data)); | ||||
Context not available. |