Have GTPv2 pass its "instance ID" to "private extension" subdissectors rather than...
[metze/wireshark/wip.git] / epan / crc16-tvb.h
1 /* crc16-tvb.h
2  * Declaration of CRC-16 tvbuff routines
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_TVB_H__
28 #define __CRC16_TVB_H__
29
30 #include "ws_symbol_export.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36 /** Compute CRC16 CCITT checksum of a tv buffer.
37  @param tvb The tv buffer containing the data.
38  @param len The number of bytes to include in the computation.
39  @return The CRC16 CCITT checksum. */
40 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
41
42 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
43  @param tvb The tv buffer containing the data.
44  @param len The number of bytes to include in the computation.
45  @return The CRC16 X.25 CCITT checksum. */
46 WS_DLL_PUBLIC guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len);
47
48 /** Compute CRC16 CCITT checksum of a tv buffer.
49  @param tvb The tv buffer containing the data.
50  @param offset The offset into the tv buffer.
51  @param len The number of bytes to include in the computation.
52  @return The CRC16 CCITT checksum. */
53 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
54
55 /** Compute CRC16 CCITT checksum of a tv buffer.  If computing the
56  *  checksum over multiple tv buffers and you want to feed the partial CRC16
57  *  back in, remember to take the 1's complement of the partial CRC16 first.
58  @param tvb The tv buffer containing the data.
59  @param len The number of bytes to include in the computation.
60  @param seed The seed to use.
61  @return The CRC16 CCITT checksum (using the given seed). */
62 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
63
64 /** Compute CRC16 CCITT checksum of a tv buffer.  If computing the
65  *  checksum over multiple tv buffers and you want to feed the partial CRC16
66  *  back in, remember to take the 1's complement of the partial CRC16 first.
67  @param tvb The tv buffer containing the data.
68  @param offset The offset into the tv buffer.
69  @param len The number of bytes to include in the computation.
70  @param seed The seed to use.
71  @return The CRC16 CCITT checksum (using the given seed). */
72 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
73                                            guint len, guint16 seed);
74
75 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
76  * parameters:
77  *    Width        = 16
78  *    Poly         = 0x8005
79  *    XorIn        = 0x0000
80  *    ReflectIn    = True
81  *    XorOut       = 0x0000
82  *    ReflectOut   = True
83  *    Algorithm    = table-driven
84  *    Direct       = True
85  @param tvb The tv buffer containing the data.
86  @param offset The offset into the tv buffer.
87  @param len The number of bytes to include in the computation.
88  @return The CRC16 checksum. */
89 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
90
91 /** Compute the "plain" CRC16 checksum of a tv buffer using the following
92  * parameters:
93  *    Width        = 16
94  *    Poly         = 0x8005
95  *    XorIn        = 0x0000
96  *    ReflectIn    = True
97  *    XorOut       = 0x0000
98  *    ReflectOut   = True
99  *    Algorithm    = table-driven
100  *    Direct       = True
101  @param tvb The tv buffer containing the data.
102  @param offset The offset into the tv buffer.
103  @param len The number of bytes to include in the computation.
104  @param crc Starting CRC value
105  @return The CRC16 checksum. */
106 WS_DLL_PUBLIC guint16 crc16_plain_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 crc);
107
108 /** Compute CRC16 checksum of a tv buffer using the parameters
109  *    Width        = 16 bits
110  *    Poly         = 0x9949
111  *    Reflection   = true 
112  *    Algorithm    = table-driven       
113  @param tvb The tv buffer containing the data.
114  @param offset The offset into the tv buffer.
115  @param len The number of bytes to include in the computation.
116  @param seed The seed to use. 
117  @return The CRC16 checksum. */
118 WS_DLL_PUBLIC guint16 crc16_0x9949_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
119
120 #ifdef __cplusplus
121 }
122 #endif /* __cplusplus */
123
124 #endif /* crc16-tvb.h */