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 * 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.
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.
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.
25 #ifndef __CRC16_TVB_H__
26 #define __CRC16_TVB_H__
28 #include "ws_symbol_export.h"
32 #endif /* __cplusplus */
34 /** Compute CRC16 CCITT checksum of a tv buffer.
35 @param tvb The tv buffer containing the data.
36 @param len The number of bytes to include in the computation.
37 @return The CRC16 CCITT checksum. */
38 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
40 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
41 @param tvb The tv buffer containing the data.
42 @param len The number of bytes to include in the computation.
43 @return The CRC16 X.25 CCITT checksum. */
44 WS_DLL_PUBLIC guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len);
46 /** Compute CRC16 ASSA R3 CCITT checksum of a tv buffer.
47 @param tvb The tv buffer containing the data.
48 @param offset The offset into tv buffer containing the data.
49 @param len The number of bytes to include in the computation.
50 @return The CRC16 X.25 CCITT checksum. */
51 WS_DLL_PUBLIC guint16 crc16_r3_ccitt_tvb(tvbuff_t *tvb, int offset, guint len);
53 /** Compute CRC16 CCITT checksum of a tv buffer.
54 @param tvb The tv buffer containing the data.
55 @param offset The offset into the tv buffer.
56 @param len The number of bytes to include in the computation.
57 @return The CRC16 CCITT checksum. */
58 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
60 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
61 * checksum over multiple tv buffers and you want to feed the partial CRC16
62 * back in, remember to take the 1's complement of the partial CRC16 first.
63 @param tvb The tv buffer containing the data.
64 @param len The number of bytes to include in the computation.
65 @param seed The seed to use.
66 @return The CRC16 CCITT checksum (using the given seed). */
67 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
69 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
70 * checksum over multiple tv buffers and you want to feed the partial CRC16
71 * back in, remember to take the 1's complement of the partial CRC16 first.
72 @param tvb The tv buffer containing the data.
73 @param offset The offset into the tv buffer.
74 @param len The number of bytes to include in the computation.
75 @param seed The seed to use.
76 @return The CRC16 CCITT checksum (using the given seed). */
77 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
78 guint len, guint16 seed);
80 /** Compute the 16bit CRC_A value of a tv buffer as defined in ISO14443-3.
81 @param tvb The tv buffer containing the data.
82 @param offset The offset into the tv buffer.
83 @param len The number of bytes to include in the computation.
84 @return The calculated CRC_A. */
85 WS_DLL_PUBLIC guint16 crc16_iso14443a_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
87 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
95 * Algorithm = table-driven
97 @param tvb The tv buffer containing the data.
98 @param offset The offset into the tv buffer.
99 @param len The number of bytes to include in the computation.
100 @return The CRC16 checksum. */
101 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
103 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
111 * 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 crc Starting CRC value
117 @return The CRC16 checksum. */
118 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 crc);
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_0x9949_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
132 /** Compute CRC16 checksum of a tv buffer using the parameters
136 * Algorithm = table-driven
137 @param tvb The tv buffer containing the data.
138 @param offset The offset into the tv buffer.
139 @param len The number of bytes to include in the computation.
140 @param seed The seed to use.
141 @return The CRC16 checksum. */
142 WS_DLL_PUBLIC guint16 crc16_0x3D65_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
146 #endif /* __cplusplus */
148 #endif /* crc16-tvb.h */