Coverage Report

Created: 2025-04-03 08:45

/src/wireshark/wsutil/crc16-plain.h
Line
Count
Source (jump to first uncovered line)
1
/** @file
2
 * http://www.tty1.net/pycrc/faq_en.html#code-ownership
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
/**
12
 * \file crc16-plain.h
13
 * Functions and types for CRC checks.
14
 *
15
 * Generated on Wed Mar 18 14:12:15 2009,
16
 * by pycrc v0.7, http://www.tty1.net/pycrc/
17
 * using the configuration:
18
 *    Width        = 16
19
 *    Poly         = 0x8005
20
 *    XorIn        = 0x0000
21
 *    ReflectIn    = True
22
 *    XorOut       = 0x0000
23
 *    ReflectOut   = True
24
 *    Algorithm    = table-driven
25
 *    Direct       = True
26
 *
27
 * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
28
 * appears not to have it; we're using GLib types, instead.
29
 *****************************************************************************/
30
#ifndef __CRC____PLAIN_H__
31
#define __CRC____PLAIN_H__
32
33
#include <stddef.h>
34
#include <stdint.h>
35
36
#include "ws_symbol_export.h"
37
38
#ifdef __cplusplus
39
extern "C" {
40
#endif
41
42
/**
43
 * The definition of the used algorithm.
44
 *****************************************************************************/
45
#define CRC_ALGO_TABLE_DRIVEN 1
46
47
/**
48
 * The type of the CRC values.
49
 *
50
 * This type must be big enough to contain at least 16 bits.
51
 *****************************************************************************/
52
typedef uint16_t crc16_plain_t;
53
54
/**
55
 * Reflect all bits of a \a data word of \a data_len bytes.
56
 *
57
 * \param data         The data word to be reflected.
58
 * \param data_len     The width of \a data expressed in number of bits.
59
 * \return     The reflected data.
60
 *****************************************************************************/
61
long crc16_plain_reflect(long data, size_t data_len);
62
63
/**
64
 * Calculate the initial crc value.
65
 *
66
 * \return     The initial crc value.
67
 *****************************************************************************/
68
static inline crc16_plain_t crc16_plain_init(void)
69
0
{
70
0
    return 0x0000;
71
0
}
Unexecuted instantiation: packet-solaredge.c:crc16_plain_init
Unexecuted instantiation: packet-umts_fp.c:crc16_plain_init
Unexecuted instantiation: crc16-tvb.c:crc16_plain_init
Unexecuted instantiation: crc16-plain.c:crc16_plain_init
72
73
/**
74
 * Update the crc value with new data.
75
 *
76
 * \param crc      The current crc value.
77
 * \param data     Pointer to a buffer of \a data_len bytes.
78
 * \param data_len Number of bytes in the \a data buffer.
79
 * \return         The updated crc value.
80
 *****************************************************************************/
81
WS_DLL_PUBLIC
82
crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len);
83
84
/**
85
 * Calculate the final crc value.
86
 *
87
 * \param crc  The current crc value.
88
 * \return     The final crc value.
89
 *****************************************************************************/
90
static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc)
91
0
{
92
0
    return crc ^ 0x0000;
93
0
}
Unexecuted instantiation: packet-solaredge.c:crc16_plain_finalize
Unexecuted instantiation: packet-umts_fp.c:crc16_plain_finalize
Unexecuted instantiation: crc16-tvb.c:crc16_plain_finalize
Unexecuted instantiation: crc16-plain.c:crc16_plain_finalize
94
95
/* Generated on Tue Jul 24 09:08:46 2012,
96
 * by pycrc v0.7.10, http://www.tty1.net/pycrc/
97
 * using the configuration:
98
 *    Width        = 16
99
 *    Poly         = 0x8005
100
 *    XorIn        = 0x0000
101
 *    ReflectIn    = False
102
 *    XorOut       = 0x0000
103
 *    ReflectOut   = False
104
 *    Algorithm    = table-driven
105
 *
106
 * Calculate the crc-16 (x^16 + x^15 + x^2 + 1) value for data. Note that this
107
 * CRC is not equal to crc16_plain.
108
 *
109
 * \param data     Pointer to a buffer of \a data_len bytes.
110
 * \param data_len Number of bytes in the \a data buffer.
111
 * \return         The crc value.
112
 *****************************************************************************/
113
WS_DLL_PUBLIC
114
uint16_t crc16_8005_noreflect_noxor(const uint8_t *data, uint64_t data_len);
115
116
117
#ifdef __cplusplus
118
}           /* closing brace for extern "C" */
119
#endif
120
121
#endif      /* __CRC____PLAIN_H__ */