mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-25 22:20:49 +08:00
Merge pull request #2975 from cesanta/ipsum
Fix IP csum calculation on 8-bit platforms
This commit is contained in:
commit
74f77c9ded
@ -4216,7 +4216,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…
x
Reference in New Issue
Block a user