nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * crc16-plain.h
3 * http://www.tty1.net/pycrc/faq_en.html#code-ownership
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23  
24 /**
25 * \file crc16-plain.h
26 * Functions and types for CRC checks.
27 *
28 * Generated on Wed Mar 18 14:12:15 2009,
29 * by pycrc v0.7, http://www.tty1.net/pycrc/
30 * using the configuration:
31 * Width = 16
32 * Poly = 0x8005
33 * XorIn = 0x0000
34 * ReflectIn = True
35 * XorOut = 0x0000
36 * ReflectOut = True
37 * Algorithm = table-driven
38 * Direct = True
39 *
40 * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
41 * appears not to have it; we're using GLib types, instead.
42 *****************************************************************************/
43 #ifndef __CRC____PLAIN_H__
44 #define __CRC____PLAIN_H__
45  
46 #include "ws_symbol_export.h"
47  
48 #include <glib.h>
49 #include <stdlib.h>
50  
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54  
55 /**
56 * The definition of the used algorithm.
57 *****************************************************************************/
58 #define CRC_ALGO_TABLE_DRIVEN 1
59  
60 /**
61 * The type of the CRC values.
62 *
63 * This type must be big enough to contain at least 16 bits.
64 *****************************************************************************/
65 typedef guint16 crc16_plain_t;
66  
67 /**
68 * Reflect all bits of a \a data word of \a data_len bytes.
69 *
70 * \param data The data word to be reflected.
71 * \param data_len The width of \a data expressed in number of bits.
72 * \return The reflected data.
73 *****************************************************************************/
74 long crc16_plain_reflect(long data, size_t data_len);
75  
76 /**
77 * Calculate the initial crc value.
78 *
79 * \return The initial crc value.
80 *****************************************************************************/
81 static inline crc16_plain_t crc16_plain_init(void)
82 {
83 return 0x0000;
84 }
85  
86 /**
87 * Update the crc value with new data.
88 *
89 * \param crc The current crc value.
90 * \param data Pointer to a buffer of \a data_len bytes.
91 * \param data_len Number of bytes in the \a data buffer.
92 * \return The updated crc value.
93 *****************************************************************************/
94 WS_DLL_PUBLIC
95 crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len);
96  
97 /**
98 * Calculate the final crc value.
99 *
100 * \param crc The current crc value.
101 * \return The final crc value.
102 *****************************************************************************/
103 static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc)
104 {
105 return crc ^ 0x0000;
106 }
107  
108 /* Generated on Tue Jul 24 09:08:46 2012,
109 * by pycrc v0.7.10, http://www.tty1.net/pycrc/
110 * using the configuration:
111 * Width = 16
112 * Poly = 0x8005
113 * XorIn = 0x0000
114 * ReflectIn = False
115 * XorOut = 0x0000
116 * ReflectOut = False
117 * Algorithm = table-driven
118 *
119 * Calculate the crc-16 (x^16 + x^15 + x^2 + 1) value for data. Note that this
120 * CRC is not equal to crc16_plain.
121 *
122 * \param data Pointer to a buffer of \a data_len bytes.
123 * \param data_len Number of bytes in the \a data buffer.
124 * \return The crc value.
125 *****************************************************************************/
126 WS_DLL_PUBLIC
127 guint16 crc16_8005_noreflect_noxor(const guint8 *data, guint64 data_len);
128  
129  
130 #ifdef __cplusplus
131 } /* closing brace for extern "C" */
132 #endif
133  
134 #endif /* __CRC____PLAIN_H__ */