[an error occurred while processing this directive]
|
static u16_t
chksum(u16_t *sdata, u16_t len)
{
u16_t acc;
for(acc = 0; len > 1; len -= 2) {
acc += *sdata;
if(acc < *sdata) {
/* Overflow, so we add the carry to acc (i.e., increase by
one). */
++acc;
}
++sdata;
}
/* add up any odd byte */
if(len == 1) {
acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
++acc;
}
}
return acc;
}
E-mail: info@telesys.ru