2 * Declaration of CRC-32 routine and table
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "ws_symbol_export.h"
32 #endif /* __cplusplus */
34 #define CRC32_CCITT_SEED 0xFFFFFFFF
35 #define CRC32C_PRELOAD 0xffffffff
36 #define CRC32_MPEG2_SEED 0xFFFFFFFF
39 * Byte swap fix contributed by Dave Wysochanski <davidw@netapp.com>.
41 #define CRC32C_SWAP(crc32c_value) \
42 (((crc32c_value & 0xff000000) >> 24) | \
43 ((crc32c_value & 0x00ff0000) >> 8) | \
44 ((crc32c_value & 0x0000ff00) << 8) | \
45 ((crc32c_value & 0x000000ff) << 24))
47 /** Lookup the crc value in the crc32_ccitt_table
48 @param pos Position in the table. */
49 WS_DLL_PUBLIC guint32 crc32_ccitt_table_lookup (guchar pos);
51 /** Lookup the crc value in the crc32c_table
52 @param pos Position in the table. */
53 WS_DLL_PUBLIC guint32 crc32c_table_lookup (guchar pos);
55 /** Compute CRC32C checksum of a buffer of data.
56 @param buf The buffer containing the data.
57 @param len The number of bytes to include in the computation.
58 @param crc The preload value for the CRC32C computation.
59 @return The CRC32C checksum. */
60 WS_DLL_PUBLIC guint32 crc32c_calculate(const void *buf, int len, guint32 crc);
62 /** Compute CRC32C checksum of a buffer of data without swapping seed crc
64 @param buf The buffer containing the data.
65 @param len The number of bytes to include in the computation.
66 @param crc The preload value for the CRC32C computation.
67 @return The CRC32C checksum. */
68 WS_DLL_PUBLIC guint32 crc32c_calculate_no_swap(const void *buf, int len, guint32 crc);
70 /** Compute CRC32 CCITT checksum of a buffer of data.
71 @param buf The buffer containing the data.
72 @param len The number of bytes to include in the computation.
73 @return The CRC32 CCITT checksum. */
74 WS_DLL_PUBLIC guint32 crc32_ccitt(const guint8 *buf, guint len);
76 /** Compute CRC32 CCITT checksum of a buffer of data. If computing the
77 * checksum over multiple buffers and you want to feed the partial CRC32
78 * back in, remember to take the 1's complement of the partial CRC32 first.
79 @param buf The buffer containing the data.
80 @param len The number of bytes to include in the computation.
81 @param seed The seed to use.
82 @return The CRC32 CCITT checksum (using the given seed). */
83 WS_DLL_PUBLIC guint32 crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed);
85 /** Compute MPEG-2 CRC32 checksum of a buffer of data.
86 @param buf The buffer containing the data.
87 @param len The number of bytes to include in the computation.
88 @param seed The seed to use.
89 @return The CRC32 MPEG-2 checksum (using the given seed). */
90 WS_DLL_PUBLIC guint32 crc32_mpeg2_seed(const guint8 *buf, guint len, guint32 seed);
92 /** Computes CRC32 checksum for the given data with the polynom 0x0AA725CF using
93 * precompiled CRC table
94 * @param buf a pointer to a buffer of the given length
95 * @param len the length of the given buffer
96 * @param seed The seed to use.
97 * @return the CRC32 checksum for the buffer
99 WS_DLL_PUBLIC guint32 crc32_0x0AA725CF_seed(const guint8 *buf, guint len, guint32 seed);
101 WS_DLL_PUBLIC int AirPDcapWepDecrypt(
103 const size_t seed_len,
105 const size_t data_len);
109 #endif /* __cplusplus */