1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

sys: net: crosslayer: fixed inet csum for 16bit platforms

Signed-off-by: malo <malo@25cmsquare.io>
This commit is contained in:
malo 2016-03-29 23:31:10 +02:00
parent f626ee5969
commit 06f0d4ea17

View File

@ -45,12 +45,12 @@ uint16_t inet_csum_slice(uint16_t sum, const uint8_t *buf, uint16_t len, size_t
}
for (int i = 0; i < (len >> 1); buf += 2, i++) {
csum += (*buf << 8) + *(buf + 1); /* group bytes by 16-byte words
* and add them*/
csum += (uint16_t)(*buf << 8) + *(buf + 1); /* group bytes by 16-byte words */
/* and add them */
}
if ((accum_len + len) & 1) /* if accumulated length is odd */
csum += (*buf << 8); /* add last byte as top half of 16-byte word */
if ((accum_len + len) & 1) /* if accumulated length is odd */
csum += (uint16_t)(*buf << 8); /* add last byte as top half of 16-byte word */
while (csum >> 16) {
uint16_t carry = csum >> 16;