diff options
author | Vladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com> | 2023-12-05 17:58:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 15:58:11 +0100 |
commit | 72601a69ffb97709136ad6b67ba720ca8109f898 (patch) | |
tree | 6965314cb82bba8836be18cd1181e9eebf5d2d4d /src/lib/protocols | |
parent | be50493f4480a17fbcd88a4ae9cc6b825bc5970d (diff) |
Add some fast CRC16 algorithms implementation (#2195)
* Add some fast CRC16 algorithms implementation
* Update ndpi_crc.c
* Move crc16 stuff to ndpi_analyze.c
* IEEE C37.118: use new fast CRC-16/CCITT-FALSE implementation
Diffstat (limited to 'src/lib/protocols')
-rw-r--r-- | src/lib/protocols/ieee-c37118.c | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/lib/protocols/ieee-c37118.c b/src/lib/protocols/ieee-c37118.c index c4576287f..e7b707c2a 100644 --- a/src/lib/protocols/ieee-c37118.c +++ b/src/lib/protocols/ieee-c37118.c @@ -31,20 +31,6 @@ #include "ndpi_api.h" #include "ndpi_private.h" -static u_int16_t crc16(const u_int8_t* data, size_t n_bytes) -{ - u_int16_t crc = 0xFFFF; - - while (n_bytes--) { - crc ^= *data++ << 8; - for (u_int8_t i = 0; i < 8; i++) { - crc = crc & 0x8000 ? (crc << 1) ^ 0x1021 : crc << 1; - } - } - - return crc & 0xFFFF; -} - static void ndpi_int_ieee_c37118_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { @@ -70,7 +56,7 @@ static void ndpi_search_ieee_c37118(struct ndpi_detection_module_struct *ndpi_st u_int16_t crc = ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len-2)); if ((frame_size == packet->payload_packet_len) && - (crc == crc16(packet->payload, packet->payload_packet_len-2))) + (crc == ndpi_crc16_ccit_false(packet->payload, packet->payload_packet_len-2))) { ndpi_int_ieee_c37118_add_connection(ndpi_struct, flow); return; |