inet_cksum: big-endian fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
9289935cfd
commit
0d0260fd1e
@ -21,8 +21,12 @@ uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mop up an odd byte, if necessary */
|
/* Mop up an odd byte, if necessary */
|
||||||
if (nleft)
|
if (nleft == 1) {
|
||||||
sum += *(uint8_t*)addr;
|
if (BB_LITTLE_ENDIAN)
|
||||||
|
sum += *(uint8_t*)addr;
|
||||||
|
else
|
||||||
|
sum += *(uint8_t*)addr << 8;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add back carry outs from top 16 bits to low 16 bits */
|
/* Add back carry outs from top 16 bits to low 16 bits */
|
||||||
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
|
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
|
||||||
|
Loading…
Reference in New Issue
Block a user