2 * Declaration of CRC-16 routines and table
4 * 2004 Richard van der Hoff <richardv@mxtelecom.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@xxxxxxxxxxxx>
10 * Copyright 1998 Gerald Combs
12 * Copied from README.developer
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #endif /* __cplusplus */
36 /* Calculate the CCITT/ITU/CRC-16 16-bit CRC
38 (parameters for this CRC are:
39 Polynomial: x^16 + x^12 + x^5 + 1 (0x1021);
41 XOR result with 0xFFFF;
45 /** Compute CRC16 CCITT checksum of a buffer of data.
46 @param buf The buffer containing the data.
47 @param len The number of bytes to include in the computation.
48 @return The CRC16 CCITT checksum. */
49 extern guint16 crc16_ccitt(const guint8 *buf, guint len);
51 /** Compute CRC16 X.25 CCITT checksum of a buffer of data.
52 @param buf The buffer containing the data.
53 @param len The number of bytes to include in the computation.
54 @return The CRC16 X.25 CCITT checksum. */
55 extern guint16 crc16_x25_ccitt(const guint8 *buf, guint len);
57 /** Compute CRC16 CCITT checksum of a buffer of data. If computing the
58 * checksum over multiple 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 buf The buffer containing the data.
61 @param len The number of bytes to include in the computation.
62 @param seed The seed to use.
63 @return The CRC16 CCITT checksum (using the given seed). */
64 extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
66 /** Compute CRC16 CCITT checksum of a tv buffer.
67 @param tvb The tv buffer containing the data.
68 @param len The number of bytes to include in the computation.
69 @return The CRC16 CCITT checksum. */
70 extern guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
72 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
73 @param tvb The tv buffer containing the data.
74 @param len The number of bytes to include in the computation.
75 @return The CRC16 X.25 CCITT checksum. */
76 extern guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len);
78 /** Compute CRC16 CCITT checksum of a tv buffer.
79 @param tvb The tv buffer containing the data.
80 @param offset The offset into the tv buffer.
81 @param len The number of bytes to include in the computation.
82 @return The CRC16 CCITT checksum. */
83 extern guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
85 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
86 * checksum over multiple tv buffers and you want to feed the partial CRC16
87 * back in, remember to take the 1's complement of the partial CRC16 first.
88 @param tvb The tv buffer containing the data.
89 @param len The number of bytes to include in the computation.
90 @param seed The seed to use.
91 @return The CRC16 CCITT checksum (using the given seed). */
92 extern guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
94 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
95 * checksum over multiple tv buffers and you want to feed the partial CRC16
96 * back in, remember to take the 1's complement of the partial CRC16 first.
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 @param seed The seed to use.
101 @return The CRC16 CCITT checksum (using the given seed). */
102 extern guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
103 guint len, guint16 seed);
107 #endif /* __cplusplus */