Updated Server Query Protocol (markdown)

fgsfds committed 2024-01-14 20:36:04 +01:00
1 parent ad5e3afeb8
commit 164b8eadd4
1 file changed
+7 -4
+7 -4
@@ -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;
}
```