MCPcopy Create free account
hub / github.com/F-Stack/f-stack / LibAliasInternetChecksum

Function LibAliasInternetChecksum

freebsd/netinet/libalias/alias_util.c:74–96  ·  view source on GitHub ↗

* Note: the checksum routines assume that the actual checksum word has * been zeroed out. If the checksum word is filled with the proper value, * then these routines will give a result of zero (useful for testing * purposes); */

Source from the content-addressed store, hash-verified

72 * purposes);
73 */
74u_short
75LibAliasInternetChecksum(struct libalias *la __unused, u_short * ptr,
76 int nbytes)
77{
78 int sum, oddbyte;
79
80 LIBALIAS_LOCK(la);
81 sum = 0;
82 while (nbytes > 1) {
83 sum += *ptr++;
84 nbytes -= 2;
85 }
86 if (nbytes == 1) {
87 oddbyte = 0;
88 ((u_char *) & oddbyte)[0] = *(u_char *) ptr;
89 ((u_char *) & oddbyte)[1] = 0;
90 sum += oddbyte;
91 }
92 sum = (sum >> 16) + (sum & 0xffff);
93 sum += (sum >> 16);
94 LIBALIAS_UNLOCK(la);
95 return (~sum);
96}
97
98#ifndef _KERNEL
99u_short

Callers 1

IpChecksumFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected