1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 20:01:35 +01:00

Fix overall checksum calculation

This commit is contained in:
Matias Fontanini
2015-12-29 09:57:42 -03:00
parent afe778d03c
commit 67d31fd62c
7 changed files with 148 additions and 72 deletions

View File

@@ -274,11 +274,11 @@ void ICMPv6::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *
ipv6->dst_addr(),
size(),
Constants::IP::PROTO_ICMPV6
) + Utils::do_checksum(buffer, buffer + total_sz);
) + Utils::sum_range(buffer, buffer + total_sz);
while (checksum >> 16) {
checksum = (checksum & 0xffff) + (checksum >> 16);
}
this->checksum(~checksum);
this->checksum(Endian::host_to_be<uint16_t>(~checksum));
memcpy(buffer + 2, &_header.cksum, sizeof(uint16_t));
}
}