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

Set UDP checksum to 0xffff if it's 0

This commit is contained in:
Matias Fontanini
2015-12-29 09:00:46 -08:00
parent c4a2fed112
commit 4ba9085eeb
2 changed files with 30 additions and 1 deletions

View File

@@ -146,6 +146,8 @@ void UDP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *par
checksum = (checksum & 0xffff)+(checksum >> 16);
}
_udp.check = ~checksum;
// If checksum is 0, it has to be set to 0xffff
_udp.check = (_udp.check == 0) ? 0xffff : _udp.check;
((udphdr*)buffer)->check = _udp.check;
}