crc16_ccitt.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
32 #ifndef CHECKSUM_CRC16_CCITT_H
33 #define CHECKSUM_CRC16_CCITT_H
34 
35 #include <stdint.h>
36 #include <stdlib.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
54 uint16_t crc16_ccitt_kermit_update(uint16_t crc, const unsigned char *buf, size_t len);
55 
73 uint16_t crc16_ccitt_kermit_calc(const unsigned char *buf, size_t len);
74 
87 static inline uint16_t crc16_ccitt_mcrf4xx_update(uint16_t crc, const unsigned char *buf,
88  size_t len)
89 {
90  /* Since CCITT-KERMIT and CCITT-MCRF4XX only differ in the starting
91  * seed, we wrap around crc16_ccitt_kermit_update() for updating */
92  return crc16_ccitt_kermit_update(crc, buf, len);
93 }
94 
112 uint16_t crc16_ccitt_mcrf4xx_calc(const unsigned char *buf, size_t len);
113 
126 uint16_t crc16_ccitt_false_update(uint16_t crc, const unsigned char *buf, size_t len);
127 
145 uint16_t crc16_ccitt_false_calc(const unsigned char *buf, size_t len);
146 
159 static inline uint16_t crc16_ccitt_aug_update(uint16_t crc, const unsigned char *buf, size_t len)
160 {
161  /* Since CCITT-AUG and CCITT-FALSE only differ in the starting
162  * seed, we wrap around crc16_ccitt_false_update() for updating */
163  return crc16_ccitt_false_update(crc, buf, len);
164 }
165 
183 uint16_t crc16_ccitt_aug_calc(const unsigned char *buf, size_t len);
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* CHECKSUM_CRC16_CCITT_H */
190 
uint16_t crc16_ccitt_false_update(uint16_t crc, const unsigned char *buf, size_t len)
Update CRC16-CCITT-FALSE.
static uint16_t crc16_ccitt_mcrf4xx_update(uint16_t crc, const unsigned char *buf, size_t len)
Update CRC16-CCITT-MCRF4XX.
Definition: crc16_ccitt.h:87
uint16_t crc16_ccitt_mcrf4xx_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-MCRF4XX.
uint16_t crc16_ccitt_kermit_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-KERMIT.
uint16_t crc16_ccitt_aug_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-AUG.
uint16_t crc16_ccitt_kermit_update(uint16_t crc, const unsigned char *buf, size_t len)
Update CRC16-CCITT-KERMIT.
uint16_t crc16_ccitt_false_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-FALSE.
static uint16_t crc16_ccitt_aug_update(uint16_t crc, const unsigned char *buf, size_t len)
Update CRC16-CCITT-AUG.
Definition: crc16_ccitt.h:159