Fix IP csum calculation on 8-bit platforms

This commit is contained in:
Sergey Lyubka 2024-11-26 20:23:12 +00:00
parent 85414cfec2
commit 49469840ab
2 changed files with 2 additions and 2 deletions

View File

@ -4206,7 +4206,7 @@ static void mkpay(struct pkt *pkt, void *p) {
static uint32_t csumup(uint32_t sum, const void *buf, size_t len) {
size_t i;
const uint8_t *p = (const uint8_t *) buf;
for (i = 0; i < len; i++) sum += i & 1 ? p[i] : (uint32_t) (p[i] << 8);
for (i = 0; i < len; i++) sum += i & 1 ? p[i] : ((uint32_t) p[i]) << 8;
return sum;
}

View File

@ -152,7 +152,7 @@ static void mkpay(struct pkt *pkt, void *p) {
static uint32_t csumup(uint32_t sum, const void *buf, size_t len) {
size_t i;
const uint8_t *p = (const uint8_t *) buf;
for (i = 0; i < len; i++) sum += i & 1 ? p[i] : (uint32_t) (p[i] << 8);
for (i = 0; i < len; i++) sum += i & 1 ? p[i] : ((uint32_t) p[i]) << 8;
return sum;
}