mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #5191 from malosek/inet_csum_16bit_fix
sys: net: crosslayer: fixed inet csum for 16bit platforms
This commit is contained in:
commit
82696da9f1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user