2 * Declaration of CRC-16 tvbuff routines
4 * 2004 Richard van der Hoff <richardv@mxtelecom.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __CRC16_TVB_H__
14 #define __CRC16_TVB_H__
16 #include "ws_symbol_export.h"
20 #endif /* __cplusplus */
22 /** Compute CRC16 CCITT checksum of a tv buffer.
23 @param tvb The tv buffer containing the data.
24 @param len The number of bytes to include in the computation.
25 @return The CRC16 CCITT checksum. */
26 WS_DLL_PUBLIC
uint16_t crc16_ccitt_tvb(tvbuff_t
*tvb
, unsigned len
);
28 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
29 @param tvb The tv buffer containing the data.
30 @param len The number of bytes to include in the computation.
31 @return The CRC16 X.25 CCITT checksum. */
32 WS_DLL_PUBLIC
uint16_t crc16_x25_ccitt_tvb(tvbuff_t
*tvb
, unsigned len
);
34 /** Compute CRC16 ASSA R3 CCITT checksum of a tv buffer.
35 @param tvb The tv buffer containing the data.
36 @param offset The offset into tv buffer containing the data.
37 @param len The number of bytes to include in the computation.
38 @return The CRC16 X.25 CCITT checksum. */
39 WS_DLL_PUBLIC
uint16_t crc16_r3_ccitt_tvb(tvbuff_t
*tvb
, int offset
, unsigned len
);
41 /** Compute CRC16 CCITT checksum of a tv buffer.
42 @param tvb The tv buffer containing the data.
43 @param offset The offset into the tv buffer.
44 @param len The number of bytes to include in the computation.
45 @return The CRC16 CCITT checksum. */
46 WS_DLL_PUBLIC
uint16_t crc16_ccitt_tvb_offset(tvbuff_t
*tvb
, unsigned offset
, unsigned len
);
48 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
49 * checksum over multiple tv buffers and you want to feed the partial CRC16
50 * back in, remember to take the 1's complement of the partial CRC16 first.
51 @param tvb The tv buffer containing the data.
52 @param len The number of bytes to include in the computation.
53 @param seed The seed to use.
54 @return The CRC16 CCITT checksum (using the given seed). */
55 WS_DLL_PUBLIC
uint16_t crc16_ccitt_tvb_seed(tvbuff_t
*tvb
, unsigned len
, uint16_t seed
);
57 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
58 * checksum over multiple tv buffers and you want to feed the partial CRC16
59 * back in, remember to take the 1's complement of the partial CRC16 first.
60 @param tvb The tv buffer containing the data.
61 @param offset The offset into the tv buffer.
62 @param len The number of bytes to include in the computation.
63 @param seed The seed to use.
64 @return The CRC16 CCITT checksum (using the given seed). */
65 WS_DLL_PUBLIC
uint16_t crc16_ccitt_tvb_offset_seed(tvbuff_t
*tvb
, unsigned offset
,
66 unsigned len
, uint16_t seed
);
68 /** Compute the 16bit CRC_A value of a tv buffer as defined in ISO14443-3.
69 @param tvb The tv buffer containing the data.
70 @param offset The offset into the tv buffer.
71 @param len The number of bytes to include in the computation.
72 @return The calculated CRC_A. */
73 WS_DLL_PUBLIC
uint16_t crc16_iso14443a_tvb_offset(tvbuff_t
*tvb
, unsigned offset
, unsigned len
);
75 /** Compute the 16bit CRC value of a tv buffer as defined in USB Standard.
76 @param tvb The tv buffer containing the data.
77 @param offset The offset into the tv buffer.
78 @param len The number of bytes to include in the computation.
79 @return The calculated CRC. */
80 WS_DLL_PUBLIC
uint16_t crc16_usb_tvb_offset(tvbuff_t
*tvb
, unsigned offset
, unsigned len
);
82 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
90 * Algorithm = table-driven
92 @param tvb The tv buffer containing the data.
93 @param offset The offset into the tv buffer.
94 @param len The number of bytes to include in the computation.
95 @return The CRC16 checksum. */
96 WS_DLL_PUBLIC
uint16_t crc16_plain_tvb_offset(tvbuff_t
*tvb
, unsigned offset
, unsigned len
);
98 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
106 * Algorithm = table-driven
108 @param tvb The tv buffer containing the data.
109 @param offset The offset into the tv buffer.
110 @param len The number of bytes to include in the computation.
111 @param crc Starting CRC value
112 @return The CRC16 checksum. */
113 WS_DLL_PUBLIC
uint16_t crc16_plain_tvb_offset_seed(tvbuff_t
*tvb
, unsigned offset
, unsigned len
, uint16_t crc
);
115 /** Compute CRC16 checksum of a tv buffer using the parameters
119 * Algorithm = table-driven
120 @param tvb The tv buffer containing the data.
121 @param offset The offset into the tv buffer.
122 @param len The number of bytes to include in the computation.
123 @param seed The seed to use.
124 @return The CRC16 checksum. */
125 WS_DLL_PUBLIC
uint16_t crc16_0x9949_tvb_offset_seed(tvbuff_t
*tvb
, unsigned offset
, unsigned len
, uint16_t seed
);
127 /** Compute CRC16 checksum of a tv buffer using the parameters
131 * Algorithm = table-driven
132 @param tvb The tv buffer containing the data.
133 @param offset The offset into the tv buffer.
134 @param len The number of bytes to include in the computation.
135 @param seed The seed to use.
136 @return The CRC16 checksum. */
137 WS_DLL_PUBLIC
uint16_t crc16_0x3D65_tvb_offset_seed(tvbuff_t
*tvb
, unsigned offset
, unsigned len
, uint16_t seed
);
141 #endif /* __cplusplus */
143 #endif /* crc16-tvb.h */