GNU Radio's CCSDS Package
bch/libcrc-2.0/include/checksum.h
Go to the documentation of this file.
1 /*
2  * Library: libcrc
3  * File: include/checksum.h
4  * Author: Lammert Bies
5  *
6  * This file is licensed under the MIT License as stated below
7  *
8  * Copyright (c) 1999-2016 Lammert Bies
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to deal
12  * in the Software without restriction, including without limitation the rights
13  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14  * copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in all
18  * copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  *
28  * Description
29  * -----------
30  * The headerfile include/checksum.h contains the definitions and prototypes
31  * for routines that can be used to calculate several kinds of checksums.
32  */
33 
34 #ifndef DEF_LIBCRC_CHECKSUM_H
35 #define DEF_LIBCRC_CHECKSUM_H
36 
37 #include <stdint.h>
38 
39 /*
40  * #define CRC_POLY_xxxx
41  *
42  * The constants of the form CRC_POLY_xxxx define the polynomials for some well
43  * known CRC calculations.
44  */
45 
46 #define CRC_POLY_16 0xA001
47 #define CRC_POLY_32 0xEDB88320L
48 #define CRC_POLY_CCITT 0x1021
49 #define CRC_POLY_DNP 0xA6BC
50 #define CRC_POLY_KERMIT 0x8408
51 #define CRC_POLY_SICK 0x8005
52 
53 /*
54  * #define CRC_START_xxxx
55  *
56  * The constants of the form CRC_START_xxxx define the values that are used for
57  * initialization of a CRC value for common used calculation methods.
58  */
59 
60 #define CRC_START_8 0x00
61 #define CRC_START_16 0x0000
62 #define CRC_START_MODBUS 0xFFFF
63 #define CRC_START_XMODEM 0x0000
64 #define CRC_START_CCITT_1D0F 0x1D0F
65 #define CRC_START_CCITT_FFFF 0xFFFF
66 #define CRC_START_KERMIT 0x0000
67 #define CRC_START_SICK 0x0000
68 #define CRC_START_DNP 0x0000
69 #define CRC_START_32 0xFFFFFFFFL
70 
71 /*
72  * Prototype list of global functions
73  */
74 
75 unsigned char * checksum_NMEA( const unsigned char *input_str, unsigned char *result );
76 uint8_t crc_8( const unsigned char *input_str, size_t num_bytes );
77 uint16_t crc_16( const unsigned char *input_str, size_t num_bytes );
78 uint32_t crc_32( const unsigned char *input_str, size_t num_bytes );
79 uint16_t crc_ccitt_1d0f( const unsigned char *input_str, size_t num_bytes );
80 uint16_t crc_ccitt_ffff( const unsigned char *input_str, size_t num_bytes );
81 uint16_t crc_dnp( const unsigned char *input_str, size_t num_bytes );
82 uint16_t crc_kermit( const unsigned char *input_str, size_t num_bytes );
83 uint16_t crc_modbus( const unsigned char *input_str, size_t num_bytes );
84 uint16_t crc_sick( const unsigned char *input_str, size_t num_bytes );
85 uint16_t crc_xmodem( const unsigned char *input_str, size_t num_bytes );
86 uint8_t update_crc_8( uint8_t crc, unsigned char c );
87 uint16_t update_crc_16( uint16_t crc, unsigned char c );
88 uint32_t update_crc_32( uint32_t crc, unsigned char c );
89 uint16_t update_crc_ccitt( uint16_t crc, unsigned char c );
90 uint16_t update_crc_dnp( uint16_t crc, unsigned char c );
91 uint16_t update_crc_kermit( uint16_t crc, unsigned char c );
92 uint16_t update_crc_sick( uint16_t crc, unsigned char c, unsigned char prev_byte );
93 
94 #endif // DEF_LIBCRC_CHECKSUM_H
uint16_t update_crc_16(uint16_t crc, unsigned char c)
uint16_t crc_xmodem(const unsigned char *input_str, size_t num_bytes)
uint32_t update_crc_32(uint32_t crc, unsigned char c)
uint32_t crc_32(const unsigned char *input_str, size_t num_bytes)
uint16_t crc_kermit(const unsigned char *input_str, size_t num_bytes)
uint16_t crc_sick(const unsigned char *input_str, size_t num_bytes)
uint16_t update_crc_ccitt(uint16_t crc, unsigned char c)
unsigned char * checksum_NMEA(const unsigned char *input_str, unsigned char *result)
uint16_t crc_modbus(const unsigned char *input_str, size_t num_bytes)
uint16_t crc_16(const unsigned char *input_str, size_t num_bytes)
uint16_t update_crc_sick(uint16_t crc, unsigned char c, unsigned char prev_byte)
uint16_t crc_ccitt_1d0f(const unsigned char *input_str, size_t num_bytes)
uint16_t crc_ccitt_ffff(const unsigned char *input_str, size_t num_bytes)
uint16_t crc_dnp(const unsigned char *input_str, size_t num_bytes)
uint16_t update_crc_kermit(uint16_t crc, unsigned char c)
unsigned char crc
Definition: generateCLTU_impl.h:28
uint16_t update_crc_dnp(uint16_t crc, unsigned char c)
uint8_t crc_8(const unsigned char *input_str, size_t num_bytes)
unsigned char uint8_t
Definition: generateCLTU_impl.h:27
uint8_t update_crc_8(uint8_t crc, unsigned char c)