2 * Declaration of CRC-16 tvbuff routines
4 * 2004 Richard van der Hoff <richardv@mxtelecom.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef __CRC16_TVB_H__
28 #define __CRC16_TVB_H__
30 #include "ws_symbol_export.h"
34 #endif /* __cplusplus */
36 /** Compute CRC16 CCITT checksum of a tv buffer.
37 @param tvb The tv buffer containing the data.
38 @param len The number of bytes to include in the computation.
39 @return The CRC16 CCITT checksum. */
40 WS_DLL_PUBLIC guint16
crc16_ccitt_tvb(tvbuff_t
*tvb
, guint len
);
42 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
43 @param tvb The tv buffer containing the data.
44 @param len The number of bytes to include in the computation.
45 @return The CRC16 X.25 CCITT checksum. */
46 WS_DLL_PUBLIC guint16
crc16_x25_ccitt_tvb(tvbuff_t
*tvb
, guint len
);
48 /** Compute CRC16 CCITT checksum of a tv buffer.
49 @param tvb The tv buffer containing the data.
50 @param offset The offset into the tv buffer.
51 @param len The number of bytes to include in the computation.
52 @return The CRC16 CCITT checksum. */
53 WS_DLL_PUBLIC guint16
crc16_ccitt_tvb_offset(tvbuff_t
*tvb
, guint offset
, guint len
);
55 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
56 * checksum over multiple tv 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 tvb The tv 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_tvb_seed(tvbuff_t
*tvb
, guint len
, guint16 seed
);
64 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
65 * checksum over multiple tv buffers and you want to feed the partial CRC16
66 * back in, remember to take the 1's complement of the partial CRC16 first.
67 @param tvb The tv buffer containing the data.
68 @param offset The offset into the tv buffer.
69 @param len The number of bytes to include in the computation.
70 @param seed The seed to use.
71 @return The CRC16 CCITT checksum (using the given seed). */
72 WS_DLL_PUBLIC guint16
crc16_ccitt_tvb_offset_seed(tvbuff_t
*tvb
, guint offset
,
73 guint len
, guint16 seed
);
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
);
122 #endif /* __cplusplus */
124 #endif /* crc16-tvb.h */