Fix (-W)documentation error found by Clang
[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 guint16 crc16_ccitt(const guint8 *buf, guint len);
50
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 WS_DLL_PUBLIC guint16 crc16_x25_ccitt(const guint8 *buf, guint len);
56
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 WS_DLL_PUBLIC guint16 crc16_ccitt_seed(const guint8 *buf, guint len, guint16 seed);
65
66 /** Calculates a CRC16 checksum for the given buffer with the polynom
67  *  0x5935 using a precompiled CRC table
68  * @param buf a pointer to a buffer of the given length
69  * @param len the length of the given buffer
70  * @param seed The seed to use.
71  * @return the CRC16 checksum for the buffer
72  */
73 WS_DLL_PUBLIC guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed);
74
75 /** Calculates a CRC16 checksum for the given buffer with the polynom
76  *  0x755B using a precompiled CRC table
77  * @param buf a pointer to a buffer of the given length
78  * @param len the length of the given buffer
79  * @param seed The seed to use.
80  * @return the CRC16 checksum for the buffer
81  */
82 WS_DLL_PUBLIC guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed);
83
84 #ifdef __cplusplus
85 }
86 #endif /* __cplusplus */
87
88 #endif /* crc16.h */