88 ((u_char *)&oddbyte)[0] = *(u_char *)ptr;
89 ((u_char *)&oddbyte)[1] = 0;
92 sum = (sum >> 16) + (sum & 0xffff);
100IpChecksum(
struct ip *pip)
108TcpChecksum(
struct ip *pip)
112 int nhdr, ntcp, nbytes;
115 nhdr = pip->
ip_hl << 2;
116 ntcp = ntohs(pip->
ip_len) - nhdr;
118 tc = (
struct tcphdr *)ip_next(pip);
130 ((u_char *)&oddbyte)[0] = *(u_char *)ptr;
131 ((u_char *)&oddbyte)[1] = 0;
135 ptr = (
void *)&pip->
ip_dst;
138 ptr = (
void *)&pip->ip_src;
141 sum += htons((u_short)ntcp);
142 sum += htons((u_short)pip->
ip_p);
145 sum = (sum >> 16) + (sum & 0xffff);
149 return ((u_short)~sum);
162 for (i = 0; i < n; i++) {
163 accumulate -= *
new++;
164 accumulate += *old++;
167 if (accumulate < 0) {
168 accumulate = -accumulate;
169 accumulate = (accumulate >> 16) + (accumulate & 0xffff);
170 accumulate += accumulate >> 16;
171 *cksum = (u_short)~accumulate;
173 accumulate = (accumulate >> 16) + (accumulate & 0xffff);
174 accumulate += accumulate >> 16;
175 *cksum = (u_short)accumulate;
#define LIBALIAS_UNLOCK(l)
u_short LibAliasInternetChecksum(struct libalias *la __unused, u_short *ptr, int nbytes)
void DifferentialChecksum(u_short *cksum, void *newp, void *oldp, int n)
struct in_addr ip_src ip_dst