This commit is contained in:
Christian Ulrich 2020-07-18 12:42:49 +02:00
parent 10f9ca135a
commit 974f324aec
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 1 additions and 1 deletions

View File

@ -118,7 +118,7 @@ proc tcpChecksum(buffer: string): uint16 =
checksum = checksum + ntohs(tcp[]) checksum = checksum + ntohs(tcp[])
tcp = cast[ptr uint16](cast[ByteAddress](tcp) + sizeof(uint16)) tcp = cast[ptr uint16](cast[ByteAddress](tcp) + sizeof(uint16))
tcpLen = tcpLen - sizeof(uint16).uint16 tcpLen = tcpLen - sizeof(uint16).uint16
# Add leftover single byte # Add leftover byte
if tcpLen != 0: if tcpLen != 0:
checksum = checksum + cast[ptr uint8](tcp)[] checksum = checksum + cast[ptr uint8](tcp)[]
# Fold 16-bit segments of the 32-bit checksum and add carry bit. Result is the # Fold 16-bit segments of the 32-bit checksum and add carry bit. Result is the