diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 20:34:10 +0000 |
commit | e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch) | |
tree | 68cb5ef9081156392f1dd62a00c6ccc1451b93df /wsutil/crc7.h | |
parent | Initial commit. (diff) | |
download | wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip |
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | wsutil/crc7.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/wsutil/crc7.h b/wsutil/crc7.h new file mode 100644 index 00000000..7364d043 --- /dev/null +++ b/wsutil/crc7.h @@ -0,0 +1,76 @@ +/** @file + * + * Functions and types for CRC checks. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Generated on Wed Jul 11 17:24:57 2012, + * by pycrc v0.7.10, http://www.tty1.net/pycrc/ + * using the configuration: + * Width = 7 + * Poly = 0x45 + * XorIn = 0x00 + * ReflectIn = False + * XorOut = 0x00 + * ReflectOut = False + * Algorithm = table-driven + **************************************************************************** + */ +#ifndef __CRC7__H__ +#define __CRC7__H__ + +#include <wireshark.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * The definition of the used algorithm. + *****************************************************************************/ +#define CRC_ALGO_TABLE_DRIVEN 1 + +/** + * Calculate the initial crc value. + * + * \return The initial crc value. + *****************************************************************************/ +static inline uint8_t crc7init(void) +{ + return 0x00 << 1; +} + + +/** + * Update the crc value with new data. + * + * \param crc The current crc value. + * \param data Pointer to a buffer of \a data_len bytes. + * \param data_len Number of bytes in the \a data buffer. + * \return The updated crc value. + *****************************************************************************/ +WS_DLL_PUBLIC uint8_t crc7update(uint8_t crc, const unsigned char *data, int data_len); + + +/** + * Calculate the final crc value. + * + * \param crc The current crc value. + * \return The final crc value. + *****************************************************************************/ +static inline uint8_t crc7finalize(uint8_t crc) +{ + return (crc >> 1) ^ 0x00; +} + + +#ifdef __cplusplus +} /* closing brace for extern "C" */ +#endif + +#endif /* __CRC7__H__ */ |