43 #include "lwip/inet.h"
55 chksum(
void *dataptr,
u16_t len)
57 u16_t *sdataptr = dataptr;
61 for(acc = 0; len > 1; len -= 2) {
93 acc = (acc & 0xffff) + (acc >> 16);
95 if (q->
len % 2 != 0) {
96 swapped = 1 - swapped;
97 acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
102 acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
105 for(i = 0; i < 8; i++) {
107 acc += ((
u16_t *)dest->
addr)[i] & 0xffff;
109 acc = (acc & 0xffff) + (acc >> 16);
113 acc += ((
u16_t *)&proto_len)[0] & 0xffff;
114 acc += ((
u16_t *)&proto_len)[1] & 0xffff;
117 acc = (acc & 0xffff) + (acc >> 16);
119 return ~(acc & 0xffff);
133 acc = chksum(dataptr, len);
134 sum = (acc & 0xffff) + (acc >> 16);
136 return ~(sum & 0xffff);
148 for(q = p; q !=
NULL; q = q->
next) {
151 acc = (acc & 0xffff) + (acc >> 16);
153 if (q->
len % 2 != 0) {
154 swapped = 1 - swapped;
155 acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
160 acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
162 return ~(acc & 0xffff);