regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / wsutil / crc16-plain.h
blob0e1eab6f6e9422ffc05ff166b40cbd1684d57e82
1 /** @file
2 * http://www.tty1.net/pycrc/faq_en.html#code-ownership
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 /**
12 * \file crc16-plain.h
13 * Functions and types for CRC checks.
15 * Generated on Wed Mar 18 14:12:15 2009,
16 * by pycrc v0.7, http://www.tty1.net/pycrc/
17 * using the configuration:
18 * Width = 16
19 * Poly = 0x8005
20 * XorIn = 0x0000
21 * ReflectIn = True
22 * XorOut = 0x0000
23 * ReflectOut = True
24 * Algorithm = table-driven
25 * Direct = True
27 * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
28 * appears not to have it; we're using GLib types, instead.
29 *****************************************************************************/
30 #ifndef __CRC____PLAIN_H__
31 #define __CRC____PLAIN_H__
33 #include <stddef.h>
34 #include <stdint.h>
36 #include "ws_symbol_export.h"
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 /**
43 * The definition of the used algorithm.
44 *****************************************************************************/
45 #define CRC_ALGO_TABLE_DRIVEN 1
47 /**
48 * The type of the CRC values.
50 * This type must be big enough to contain at least 16 bits.
51 *****************************************************************************/
52 typedef uint16_t crc16_plain_t;
54 /**
55 * Reflect all bits of a \a data word of \a data_len bytes.
57 * \param data The data word to be reflected.
58 * \param data_len The width of \a data expressed in number of bits.
59 * \return The reflected data.
60 *****************************************************************************/
61 long crc16_plain_reflect(long data, size_t data_len);
63 /**
64 * Calculate the initial crc value.
66 * \return The initial crc value.
67 *****************************************************************************/
68 static inline crc16_plain_t crc16_plain_init(void)
70 return 0x0000;
73 /**
74 * Update the crc value with new data.
76 * \param crc The current crc value.
77 * \param data Pointer to a buffer of \a data_len bytes.
78 * \param data_len Number of bytes in the \a data buffer.
79 * \return The updated crc value.
80 *****************************************************************************/
81 WS_DLL_PUBLIC
82 crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len);
84 /**
85 * Calculate the final crc value.
87 * \param crc The current crc value.
88 * \return The final crc value.
89 *****************************************************************************/
90 static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc)
92 return crc ^ 0x0000;
95 /* Generated on Tue Jul 24 09:08:46 2012,
96 * by pycrc v0.7.10, http://www.tty1.net/pycrc/
97 * using the configuration:
98 * Width = 16
99 * Poly = 0x8005
100 * XorIn = 0x0000
101 * ReflectIn = False
102 * XorOut = 0x0000
103 * ReflectOut = False
104 * Algorithm = table-driven
106 * Calculate the crc-16 (x^16 + x^15 + x^2 + 1) value for data. Note that this
107 * CRC is not equal to crc16_plain.
109 * \param data Pointer to a buffer of \a data_len bytes.
110 * \param data_len Number of bytes in the \a data buffer.
111 * \return The crc value.
112 *****************************************************************************/
113 WS_DLL_PUBLIC
114 uint16_t crc16_8005_noreflect_noxor(const uint8_t *data, uint64_t data_len);
117 #ifdef __cplusplus
118 } /* closing brace for extern "C" */
119 #endif
121 #endif /* __CRC____PLAIN_H__ */