C.2. Computing fhe VRRP Checksum

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 ...

Get VRRP: Increasing Reliability and Failover with the Virtual Router Redundance Protocol now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.