From 72601a69ffb97709136ad6b67ba720ca8109f898 Mon Sep 17 00:00:00 2001 From: Vladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:58:11 +0300 Subject: 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 --- src/lib/protocols/ieee-c37118.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/lib/protocols') 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; -- cgit v1.2.3