mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-11 23:19:00 +08:00
Fix IP csum calculation on 8-bit platforms
This commit is contained in:
parent
85414cfec2
commit
49469840ab
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user