some compilers dont like unnamed unions and structs
[obnox/wireshark/wip.git] / epan / crc16.h
1 /* crc16.h
2  * Declaration of CRC-16 routines and table
3  *
4  * 2004 Richard van der Hoff <richardv@mxtelecom.com>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@xxxxxxxxxxxx>
10  * Copyright 1998 Gerald Combs
11  *
12  * Copied from README.developer
13  *
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.
18  *
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.
23  *
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.
27 */
28
29 /* Calculate the CCITT/ITU/CRC-16 16-bit CRC
30
31    (parameters for this CRC are:
32        Polynomial: x^16 + x^12 + x^5 + 1  (0x1021);
33        Start value 0xFFFF;
34        XOR result with 0xFFFF;
35        First bit is LSB)
36 */
37
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);
43
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);
52
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);
58
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);
65
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);
74
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);
85
86