diff options
Diffstat (limited to 'source/LCM/Hash.cpp')
-rw-r--r-- | source/LCM/Hash.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/source/LCM/Hash.cpp b/source/LCM/Hash.cpp index 4f5962c..7836604 100644 --- a/source/LCM/Hash.cpp +++ b/source/LCM/Hash.cpp @@ -23,21 +23,21 @@ **********************************************************************/ const uint32 red[16] = { 0, - (0x1 << 16) ^(0x1021 << 0), \ - (0x2 << 16) ^(0x1021 << 1), \ - (0x3 << 16) ^(0x1021 << 1) ^(0x1021 << 0), \ - (0x4 << 16) ^(0x1021 << 2), \ - (0x5 << 16) ^(0x1021 << 2) ^(0x1021 << 0), \ - (0x6 << 16) ^(0x1021 << 2) ^(0x1021 << 1), \ - (0x7 << 16) ^(0x1021 << 2) ^(0x1021 << 1) ^(0x1021 << 0), \ - (0x8 << 16) ^(0x1021 << 3), \ - (0x9 << 16) ^(0x1021 << 3) ^(0x1021 << 0), \ - (0xa << 16) ^(0x1021 << 3) ^(0x1021 << 1), \ - (0xb << 16) ^(0x1021 << 3) ^(0x1021 << 1) ^(0x1021 << 0), \ - (0xc << 16) ^(0x1021 << 3) ^(0x1021 << 2), \ - (0xd << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 0), \ - (0xe << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 1), \ - (0xf << 16) ^(0x1021 << 3) ^(0x1021 << 2) ^(0x1021 << 1) ^(0x1021 << 0) + (0x1 << 16) ^ (0x1021 << 0), \ + (0x2 << 16) ^ (0x1021 << 1), \ + (0x3 << 16) ^ (0x1021 << 1) ^ (0x1021 << 0), \ + (0x4 << 16) ^ (0x1021 << 2), \ + (0x5 << 16) ^ (0x1021 << 2) ^ (0x1021 << 0), \ + (0x6 << 16) ^ (0x1021 << 2) ^ (0x1021 << 1), \ + (0x7 << 16) ^ (0x1021 << 2) ^ (0x1021 << 1) ^ (0x1021 << 0), \ + (0x8 << 16) ^ (0x1021 << 3), \ + (0x9 << 16) ^ (0x1021 << 3) ^ (0x1021 << 0), \ + (0xa << 16) ^ (0x1021 << 3) ^ (0x1021 << 1), \ + (0xb << 16) ^ (0x1021 << 3) ^ (0x1021 << 1) ^ (0x1021 << 0), \ + (0xc << 16) ^ (0x1021 << 3) ^ (0x1021 << 2), \ + (0xd << 16) ^ (0x1021 << 3) ^ (0x1021 << 2) ^ (0x1021 << 0), \ + (0xe << 16) ^ (0x1021 << 3) ^ (0x1021 << 2) ^ (0x1021 << 1), \ + (0xf << 16) ^ (0x1021 << 3) ^ (0x1021 << 2) ^ (0x1021 << 1) ^ (0x1021 << 0) }; Hash::Hash() @@ -93,6 +93,7 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_CRC16: memset(request->Hash_p, 0, CRC16_LENGTH); @@ -102,6 +103,7 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_SIMPLE_XOR: request->Hash_p[0] = 0; @@ -110,8 +112,10 @@ void *Hash::WorkerThread(void *arg) } break; + case HASH_NONE: break; + default: // unsupported hash type, nothing to do delete request; @@ -184,12 +188,12 @@ uint16 Hash::crc16(const uint8 *p, int count, uint16 crc_in) register uint32 crc = crc_in; while (--count >= 0) { - crc = crc ^(uint8) * p++ << 8; - crc ^= red[crc>>16]; + crc = crc ^ (uint8) * p++ << 8; + crc ^= red[crc >> 16]; crc = (crc << 4); - crc ^= red[crc>>16]; + crc ^= red[crc >> 16]; crc = (crc << 4); - crc ^= red[crc>>16]; + crc ^= red[crc >> 16]; } |