Qt: Add copy from another profile in UAT dialogs
[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  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13 #ifndef __CRC16_TVB_H__
14 #define __CRC16_TVB_H__
15
16 #include "ws_symbol_export.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 /** Compute CRC16 CCITT checksum of a tv buffer.
23  @param tvb The tv buffer containing the data.
24  @param len The number of bytes to include in the computation.
25  @return The CRC16 CCITT checksum. */
26 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb(tvbuff_t *tvb, guint len);
27
28 /** Compute CRC16 X.25 CCITT checksum of a tv buffer.
29  @param tvb The tv buffer containing the data.
30  @param len The number of bytes to include in the computation.
31  @return The CRC16 X.25 CCITT checksum. */
32 WS_DLL_PUBLIC guint16 crc16_x25_ccitt_tvb(tvbuff_t *tvb, guint len);
33
34 /** Compute CRC16 ASSA R3 CCITT checksum of a tv buffer.
35  @param tvb The tv buffer containing the data.
36  @param offset The offset into tv buffer containing the data.
37  @param len The number of bytes to include in the computation.
38  @return The CRC16 X.25 CCITT checksum. */
39 WS_DLL_PUBLIC guint16 crc16_r3_ccitt_tvb(tvbuff_t *tvb, int offset, guint len);
40
41 /** Compute CRC16 CCITT checksum of a tv buffer.
42  @param tvb The tv buffer containing the data.
43  @param offset The offset into the tv buffer.
44  @param len The number of bytes to include in the computation.
45  @return The CRC16 CCITT checksum. */
46 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
47
48 /** Compute CRC16 CCITT checksum of a tv buffer.  If computing the
49  *  checksum over multiple tv buffers and you want to feed the partial CRC16
50  *  back in, remember to take the 1's complement of the partial CRC16 first.
51  @param tvb The tv buffer containing the data.
52  @param len The number of bytes to include in the computation.
53  @param seed The seed to use.
54  @return The CRC16 CCITT checksum (using the given seed). */
55 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint16 seed);
56
57 /** Compute CRC16 CCITT checksum of a tv buffer.  If computing the
58  *  checksum over multiple tv 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 tvb The tv buffer containing the data.
61  @param offset The offset into the tv buffer.
62  @param len The number of bytes to include in the computation.
63  @param seed The seed to use.
64  @return The CRC16 CCITT checksum (using the given seed). */
65 WS_DLL_PUBLIC guint16 crc16_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset,
66                                            guint len, guint16 seed);
67
68 /** Compute the 16bit CRC_A value of a tv buffer as defined in ISO14443-3.
69  @param tvb The tv buffer containing the data.
70  @param offset The offset into the tv buffer.
71  @param len The number of bytes to include in the computation.
72  @return The calculated CRC_A. */
73 WS_DLL_PUBLIC guint16 crc16_iso14443a_tvb_offset(tvbuff_t *tvb, guint offset, guint len);
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 /** Compute CRC16 checksum of a tv buffer using the parameters
121  *    Width        = 16 bits
122  *    Poly         = 0x3D65
123  *    Reflection   = true
124  *    Algorithm    = table-driven
125  @param tvb The tv buffer containing the data.
126  @param offset The offset into the tv buffer.
127  @param len The number of bytes to include in the computation.
128  @param seed The seed to use.
129  @return The CRC16 checksum. */
130 WS_DLL_PUBLIC guint16 crc16_0x3D65_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint16 seed);
131
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135
136 #endif /* crc16-tvb.h */