MSWSP: * add parse_lcid()
[wireshark-wip.git] / wsutil / crc16.h
blobe947af7b17f3e0cbc66429943c0c8193137841f5
1 /* crc16.h
2 * Declaration of CRC-16 routines and table
4 * 2004 Richard van der Hoff <richardv@mxtelecom.com>
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
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.
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.
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.
27 #ifndef __CRC16_H__
28 #define __CRC16_H__
30 #include "ws_symbol_export.h"
32 #ifdef __cplusplus
33 extern "C" {
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);
40 Start value 0xFFFF;
41 XOR result with 0xFFFF;
42 First bit is LSB)
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);
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);
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);
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
73 WS_DLL_PUBLIC guint16 crc16_0x5935(const guint8 *buf, guint32 len, guint16 seed);
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
82 WS_DLL_PUBLIC guint16 crc16_0x755B(const guint8 *buf, guint32 len, guint16 seed);
84 /** Computes CRC16 checksum for the given data with the polynom 0x9949 using
85 * precompiled CRC table
86 * @param buf a pointer to a buffer of the given length
87 * @param len the length of the given buffer
88 * @param seed The seed to use.
89 * @return the CRC16 checksum for the buffer
91 WS_DLL_PUBLIC guint16 crc16_0x9949_seed(const guint8 *buf, guint len, guint16 seed);
93 #ifdef __cplusplus
95 #endif /* __cplusplus */
97 #endif /* crc16.h */