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 guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint 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 guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint 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 guint16 crc16_r3_ccitt_tvb(tvbuff_t *tvb, int offset, guint 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 guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint 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 guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 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 guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
66 guint len, guint16 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 guint16 crc16_iso14443a_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
75 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
83 * Algorithm = table-driven
85 @param tvb The tv buffer containing the data.
86 @param offset The offset into the tv buffer.
87 @param len The number of bytes to include in the computation.
88 @return The CRC16 checksum. */
89 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
91 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
99 * Algorithm = table-driven
101 @param tvb The tv buffer containing the data.
102 @param offset The offset into the tv buffer.
103 @param len The number of bytes to include in the computation.
104 @param crc Starting CRC value
105 @return The CRC16 checksum. */
106 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 crc);
108 /** Compute CRC16 checksum of a tv buffer using the parameters
112 * Algorithm = table-driven
113 @param tvb The tv buffer containing the data.
114 @param offset The offset into the tv buffer.
115 @param len The number of bytes to include in the computation.
116 @param seed The seed to use.
117 @return The CRC16 checksum. */
118 WS_DLL_PUBLIC guint16 crc16_0x9949_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
120 /** Compute CRC16 checksum of a tv buffer using the parameters
124 * Algorithm = table-driven
125 @param tvb The tv buffer containing the data.
126 @param offset The offset into the tv buffer.
127 @param len The number of bytes to include in the computation.
128 @param seed The seed to use.
129 @return The CRC16 checksum. */
130 WS_DLL_PUBLIC guint16 crc16_0x3D65_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
134 #endif /* __cplusplus */
136 #endif /* crc16-tvb.h */