From 164b8eadd4e9dc72ed5740bbf375ff098d2477ff Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 14 Jan 2024 20:36:04 +0100 Subject: [PATCH] Updated Server Query Protocol (markdown) --- Server-Query-Protocol.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Server-Query-Protocol.md b/Server-Query-Protocol.md index 4fd1647..405157e 100644 --- a/Server-Query-Protocol.md +++ b/Server-Query-Protocol.md @@ -29,10 +29,13 @@ where `dstring` is u16 length; // including null terminator char data[length]; // null terminated ``` -The checksum function used is as follows: +The checksum function used is a variant of CRC16: ``` -u32 chk = 1; -for (u32 i = 0; i < datalen; ++i) { - chk = (chk + data[i]) % 65521; +u16 x; +u16 crc = 0xFFFF; +for (u32 i = 0; i < buf.wp; ++i) { + x = crc >> 8 ^ buf.data[i]; + x ^= x >> 4; + crc += (crc << 8) ^ (x << 12) ^ (x << 5) ^ x; } ``` \ No newline at end of file