Export libwsutil symbols using WS_DLL_PUBLIC define
[metze/wireshark/wip.git] / wsutil / 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@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
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.
16  *
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.
21  *
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.
25 */
26
27 #ifndef __CRC16_H__
28 #define __CRC16_H__
29
30 #include "ws_symbol_export.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /* Calculate the CCITT/ITU/CRC-16 16-bit CRC
37
38    (parameters for this CRC are:
39        Polynomial: x^16 + x^12 + x^5 + 1  (0x1021);
40        Start value 0xFFFF;
41        XOR result with 0xFFFF;
42        First bit is LSB)
43 */
44
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 WS_DLL_PUBLIC
50 extern guint16 crc16_ccitt(const guint8 *buf, guint len);
51
52 /** Compute CRC16 X.25 CCITT checksum of a buffer of data.
53  @param buf The buffer containing the data.
54  @param len The number of bytes to include in the computation.
55  @return The CRC16 X.25 CCITT checksum. */
56 WS_DLL_PUBLIC
57 extern guint16 crc16_x25_ccitt(const guint8 *buf, guint len);
58
59 /** Compute CRC16 CCITT checksum of a buffer of data.  If computing the
60  *  checksum over multiple buffers and you want to feed the partial CRC16
61  *  back in, remember to take the 1's complement of the partial CRC16 first.
62  @param buf The buffer containing the data.
63  @param len The number of bytes to include in the computation.
64  @param seed The seed to use.
65  @return The CRC16 CCITT checksum (using the given seed). */
66 WS_DLL_PUBLIC
67 extern guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
68
69 /** Calculates a CRC16 checksum for the given buffer with the polynom
70  *  0x5935 using a precompiled CRC table
71  * @param pBuffer a pointer to a buffer of the given length
72  * @param len the length of the given buffer
73  * @param seed The seed to use.
74  * @return the CRC16 checksum for the buffer
75  */
76 WS_DLL_PUBLIC
77 extern guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed);
78
79 #ifdef __cplusplus
80 }
81 #endif /* __cplusplus */
82
83 #endif /* crc16.h */