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.
29 /* Calculate the CCITT/ITU/CRC-16 16-bit CRC
31 (parameters for this CRC are:
32 Polynomial: x^16 + x^12 + x^5 + 1 (0x1021);
34 XOR result with 0xFFFF;
38 /** Compute CRC16 CCITT checksum of a buffer of data.
39 @param buf The buffer containing the data.
40 @param len The number of bytes to include in the computation.
41 @return The CRC16 CCITT checksum. */
42 extern guint16 crc16_ccitt(const guint8 *buf, guint len);
44 /** Compute CRC16 CCITT checksum of a buffer of data. If computing the
45 * checksum over multiple buffers and you want to feed the partial CRC16
46 * back in, remember to take the 1's complement of the partial CRC16 first.
47 @param buf The buffer containing the data.
48 @param len The number of bytes to include in the computation.
49 @param seed The seed to use.
50 @return The CRC16 CCITT checksum (using the given seed). */
51 extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
53 /** Compute CRC16 CCITT checksum of a tv buffer.
54 @param tvb The tv buffer containing the data.
55 @param len The number of bytes to include in the computation.
56 @return The CRC16 CCITT checksum. */
57 extern guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
59 /** Compute CRC16 CCITT checksum of a tv buffer.
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 @return The CRC16 CCITT checksum. */
64 extern guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
66 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
67 * checksum over multiple tv buffers and you want to feed the partial CRC16
68 * back in, remember to take the 1's complement of the partial CRC16 first.
69 @param tvb The tv buffer containing the data.
70 @param len The number of bytes to include in the computation.
71 @param seed The seed to use.
72 @return The CRC16 CCITT checksum (using the given seed). */
73 extern guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
75 /** Compute CRC16 CCITT checksum of a tv buffer. If computing the
76 * checksum over multiple tv buffers and you want to feed the partial CRC16
77 * back in, remember to take the 1's complement of the partial CRC16 first.
78 @param tvb The tv buffer containing the data.
79 @param offset The offset into the tv buffer.
80 @param len The number of bytes to include in the computation.
81 @param seed The seed to use.
82 @return The CRC16 CCITT checksum (using the given seed). */
83 extern guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
84 guint len, guint16 seed);