September 2002
Intermediate to advanced
560 pages
13h 16m
English
From this point on, we will discuss the various components of file, vrrpd.c:
/********************************************************* NAME : in_csum *********************************************************/ static u_short in_csum( u_short *addr, int len, u_short csum) { register int nleft = len; const u_short *w = addr; register u_short answer; register int sum = csum; /* * Our algorithm is simple, using a 32 bit accumulator (sum), we add 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. */ while (nleft > 1) { sum += *w++; nleft -= 2; } /* mop up an odd octet, if necessary */ if (nleft == 1) sum += htons(*(u_char *)w << 8); /* * add back ...Read now
Unlock full access