nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* crc16.h |
2 | * Declaration of CRC-16 routines and table |
||
3 | * |
||
4 | * 2004 Richard van der Hoff <richardv@mxtelecom.com> |
||
5 | * |
||
6 | * Wireshark - Network traffic analyzer |
||
7 | * By Gerald Combs <gerald@wireshark.org> |
||
8 | * Copyright 1998 Gerald Combs |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or |
||
11 | * modify it under the terms of the GNU General Public License |
||
12 | * as published by the Free Software Foundation; either version 2 |
||
13 | * of the License, or (at your option) any later version. |
||
14 | * |
||
15 | * This program is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | * GNU General Public License for more details. |
||
19 | * |
||
20 | * You should have received a copy of the GNU General Public License |
||
21 | * along with this program; if not, write to the Free Software |
||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
23 | */ |
||
24 | |||
25 | #ifndef __CRC16_H__ |
||
26 | #define __CRC16_H__ |
||
27 | |||
28 | #include "ws_symbol_export.h" |
||
29 | |||
30 | #ifdef __cplusplus |
||
31 | extern "C" { |
||
32 | #endif /* __cplusplus */ |
||
33 | |||
34 | /* Calculate the CCITT/ITU/CRC-16 16-bit CRC |
||
35 | |||
36 | (parameters for this CRC are: |
||
37 | Polynomial: x^16 + x^12 + x^5 + 1 (0x1021); |
||
38 | Start value 0xFFFF; |
||
39 | XOR result with 0xFFFF; |
||
40 | First bit is LSB) |
||
41 | */ |
||
42 | |||
43 | /** Compute CRC16 CCITT checksum of a buffer of data. |
||
44 | @param buf The buffer containing the data. |
||
45 | @param len The number of bytes to include in the computation. |
||
46 | @return The CRC16 CCITT checksum. */ |
||
47 | WS_DLL_PUBLIC guint16 crc16_ccitt(const guint8 *buf, guint len); |
||
48 | |||
49 | /** Compute CRC16 X.25 CCITT checksum of a buffer of data. |
||
50 | @param buf The buffer containing the data. |
||
51 | @param len The number of bytes to include in the computation. |
||
52 | @return The CRC16 X.25 CCITT checksum. */ |
||
53 | WS_DLL_PUBLIC guint16 crc16_x25_ccitt_seed(const guint8 *buf, guint len, guint16 seed); |
||
54 | |||
55 | /** Compute CRC16 CCITT checksum of a buffer of data. If computing the |
||
56 | * checksum over multiple buffers and you want to feed the partial CRC16 |
||
57 | * back in, remember to take the 1's complement of the partial CRC16 first. |
||
58 | @param buf The buffer containing the data. |
||
59 | @param len The number of bytes to include in the computation. |
||
60 | @param seed The seed to use. |
||
61 | @return The CRC16 CCITT checksum (using the given seed). */ |
||
62 | WS_DLL_PUBLIC guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed); |
||
63 | |||
64 | /** Compute the 16bit CRC_A value of a buffer as defined in ISO14443-3. |
||
65 | @param buf The buffer containing the data. |
||
66 | @param len The number of bytes to include in the computation. |
||
67 | @return the CRC16 checksum for the buffer */ |
||
68 | WS_DLL_PUBLIC guint16 crc16_iso14443a(const guint8 *buf, guint len); |
||
69 | |||
70 | /** Calculates a CRC16 checksum for the given buffer with the polynom |
||
71 | * 0x5935 using a precompiled CRC table |
||
72 | * @param buf a pointer to a buffer of the given length |
||
73 | * @param len the length of the given buffer |
||
74 | * @param seed The seed to use. |
||
75 | * @return the CRC16 checksum for the buffer |
||
76 | */ |
||
77 | WS_DLL_PUBLIC guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed); |
||
78 | |||
79 | /** Calculates a CRC16 checksum for the given buffer with the polynom |
||
80 | * 0x755B using a precompiled CRC table |
||
81 | * @param buf a pointer to a buffer of the given length |
||
82 | * @param len the length of the given buffer |
||
83 | * @param seed The seed to use. |
||
84 | * @return the CRC16 checksum for the buffer |
||
85 | */ |
||
86 | WS_DLL_PUBLIC guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed); |
||
87 | |||
88 | /** Computes CRC16 checksum for the given data with the polynom 0x9949 using |
||
89 | * precompiled CRC table |
||
90 | * @param buf a pointer to a buffer of the given length |
||
91 | * @param len the length of the given buffer |
||
92 | * @param seed The seed to use. |
||
93 | * @return the CRC16 checksum for the buffer |
||
94 | */ |
||
95 | WS_DLL_PUBLIC guint16 crc16_0x9949_seed(const guint8 *buf, guint len, guint16 seed); |
||
96 | |||
97 | /** Computes CRC16 checksum for the given data with the polynom 0x3D65 using |
||
98 | * precompiled CRC table |
||
99 | * @param buf a pointer to a buffer of the given length |
||
100 | * @param len the length of the given buffer |
||
101 | * @param seed The seed to use. |
||
102 | * @return the CRC16 checksum for the buffer |
||
103 | */ |
||
104 | WS_DLL_PUBLIC guint16 crc16_0x3D65_seed(const guint8 *buf, guint len, guint16 seed); |
||
105 | |||
106 | #ifdef __cplusplus |
||
107 | } |
||
108 | #endif /* __cplusplus */ |
||
109 | |||
110 | #endif /* crc16.h */ |