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 
9 #pragma once
10 
34 #include <stdint.h>
35 #include <stdlib.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
53 uint16_t crc16_ccitt_kermit_update(uint16_t crc, const unsigned char *buf, size_t len);
54 
72 uint16_t crc16_ccitt_kermit_calc(const unsigned char *buf, size_t len);
73 
83 uint16_t crc16_ccitt_fcs_start(const unsigned char *buf, size_t len);
84 
97 static inline uint16_t crc16_ccitt_fcs_update(uint16_t crc, const unsigned char *buf,
98  size_t len)
99 {
100  /* Since CCITT-KERMIT and CCITT-FCS only differ in the starting
101  * seed, we wrap around crc16_ccitt_kermit_update() for updating */
102  return crc16_ccitt_kermit_update(crc, buf, len);
103 }
104 
117 uint16_t crc16_ccitt_fcs_finish(uint16_t crc, const unsigned char *buf, size_t len);
118 
137 uint16_t crc16_ccitt_fcs_calc(const unsigned char *buf, size_t len);
138 
151 static inline uint16_t crc16_ccitt_mcrf4xx_update(uint16_t crc, const unsigned char *buf,
152  size_t len)
153 {
154  /* Since CCITT-KERMIT and CCITT-MCRF4XX only differ in the starting
155  * seed, we wrap around crc16_ccitt_kermit_update() for updating */
156  return crc16_ccitt_kermit_update(crc, buf, len);
157 }
158 
176 uint16_t crc16_ccitt_mcrf4xx_calc(const unsigned char *buf, size_t len);
177 
190 uint16_t crc16_ccitt_false_update(uint16_t crc, const unsigned char *buf, size_t len);
191 
209 uint16_t crc16_ccitt_false_calc(const unsigned char *buf, size_t len);
210 
223 static inline uint16_t crc16_ccitt_aug_update(uint16_t crc, const unsigned char *buf, size_t len)
224 {
225  /* Since CCITT-AUG and CCITT-FALSE only differ in the starting
226  * seed, we wrap around crc16_ccitt_false_update() for updating */
227  return crc16_ccitt_false_update(crc, buf, len);
228 }
229 
247 uint16_t crc16_ccitt_aug_calc(const unsigned char *buf, size_t len);
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
static uint16_t crc16_ccitt_fcs_update(uint16_t crc, const unsigned char *buf, size_t len)
Update CRC16-CCITT-FCS / IBM-SDLC.
Definition: crc16_ccitt.h:97
uint16_t crc16_ccitt_fcs_finish(uint16_t crc, const unsigned char *buf, size_t len)
Finalise CRC16-CCITT-FCS / IBM-SDLC.
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:151
uint16_t crc16_ccitt_mcrf4xx_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-MCRF4XX.
uint16_t crc16_ccitt_fcs_calc(const unsigned char *buf, size_t len)
Calculate CRC16-CCITT-FCS / IBM-SDLC in one pass.
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.
uint16_t crc16_ccitt_fcs_start(const unsigned char *buf, size_t len)
Start a CRC16-CCITT-FCS / IBM-SDLC calculation.
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:223