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

Function DifferentialChecksum

freebsd/netinet/libalias/alias_util.c:153–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151#endif /* not _KERNEL */
152
153void
154DifferentialChecksum(u_short * cksum, void *newp, void *oldp, int n)
155{
156 int i;
157 int accumulate;
158 u_short *new = newp;
159 u_short *old = oldp;
160
161 accumulate = *cksum;
162 for (i = 0; i < n; i++) {
163 accumulate -= *new++;
164 accumulate += *old++;
165 }
166
167 if (accumulate < 0) {
168 accumulate = -accumulate;
169 accumulate = (accumulate >> 16) + (accumulate & 0xffff);
170 accumulate += accumulate >> 16;
171 *cksum = (u_short) ~ accumulate;
172 } else {
173 accumulate = (accumulate >> 16) + (accumulate & 0xffff);
174 accumulate += accumulate >> 16;
175 *cksum = (u_short) accumulate;
176 }
177}

Callers 15

NewFtpMessageFunction · 0.85
AliasHandlePptpGreOutFunction · 0.85
AliasHandlePptpGreInFunction · 0.85
AliasHandleIrcOutFunction · 0.85
alias_rtsp_outFunction · 0.85
SctpAliasFunction · 0.85
IcmpAliasIn1Function · 0.85
IcmpAliasIn2Function · 0.85
IcmpAliasOut1Function · 0.85
IcmpAliasOut2Function · 0.85
ProtoAliasInFunction · 0.85
ProtoAliasOutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected