10 uint16_t ipv6_checksum(struct ipv6_pseudo_hdr
*p_pshdr
, uint8_t *buff
, int lenbuff
)
13 uint16_t *ptrw
= (uint16_t *) p_pshdr
;
17 // Size pseudo header 40 byte (20 word)
18 for (i
= 0; i
< (sizeof(*p_pshdr
)/2); i
++)
20 word16
= ntohs(*((uint16_t *)ptrw
));
25 ptrw
= (uint16_t *) buff
;
28 word16
= ntohs(*((uint16_t *) ptrw
));
36 word16
= ntohs(*((uint8_t *) ptrw
));
40 // take only 16 bits out of the 32 bit sum and add up the carries
42 sum
= (sum
& 0xFFFF) + (sum
>> 16);
44 // one's complement the result
47 return htons((uint16_t) sum
);