Standard reflected IEEE CRC-32 (poly `0xEDB88320`, init/final `0xFFFFFFFF`) — equals the engine's `crc32(0, buf, len)`.
(data: &[u8])
| 17 | /// Standard reflected IEEE CRC-32 (poly `0xEDB88320`, init/final `0xFFFFFFFF`) — equals |
| 18 | /// the engine's `crc32(0, buf, len)`. |
| 19 | pub fn crc32(data: &[u8]) -> u32 { |
| 20 | let mut crc: u32 = 0xFFFF_FFFF; |
| 21 | for &byte in data { |
| 22 | crc ^= u32::from(byte); |
| 23 | for _ in 0..8 { |
| 24 | crc = if crc & 1 != 0 { |
| 25 | (crc >> 1) ^ 0xEDB8_8320 |
| 26 | } else { |
| 27 | crc >> 1 |
| 28 | }; |
| 29 | } |
| 30 | } |
| 31 | !crc |
| 32 | } |
| 33 | |
| 34 | /// Wrap a magic-packet body in a broadcast `MsgHeader` (flags `MAGIC | TO_BCAST`), filling |
| 35 | /// the length and CRC. `serial` is echoed back by the server; any value works for a probe. |
no outgoing calls
no test coverage detected