crc16_ccitt.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
31 #include <stdint.h>
32 #include <stdlib.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
50 uint16_t crc16_ccitt_kermit_update(uint16_t crc, const unsigned char *buf, size_t len);
51 
69 uint16_t crc16_ccitt_kermit_calc(const unsigned char *buf, size_t len);
70 
80 uint16_t crc16_ccitt_fcs_start(const unsigned char *buf, size_t len);
81 
94 static inline uint16_t crc16_ccitt_fcs_update(uint16_t crc, const unsigned char *buf,
95  size_t len)
96 {
97  /* Since CCITT-KERMIT and CCITT-FCS only differ in the starting
98  * seed, we wrap around crc16_ccitt_kermit_update() for updating */
99  return crc16_ccitt_kermit_update(crc, buf, len);
100 }
101 
114 uint16_t crc16_ccitt_fcs_finish(uint16_t crc, const unsigned char *buf, size_t len);
115 
134 uint16_t crc16_ccitt_fcs_calc(const unsigned char *buf, size_t len);
135 
148 static inline uint16_t crc16_ccitt_mcrf4xx_update(uint16_t crc, const unsigned char *buf,
149  size_t len)
150 {
151  /* Since CCITT-KERMIT and CCITT-MCRF4XX only differ in the starting
152  * seed, we wrap around crc16_ccitt_kermit_update() for updating */
153  return crc16_ccitt_kermit_update(crc, buf, len);
154 }
155 
173 uint16_t crc16_ccitt_mcrf4xx_calc(const unsigned char *buf, size_t len);
174 
187 uint16_t crc16_ccitt_false_update(uint16_t crc, const unsigned char *buf, size_t len);
188 
206 uint16_t crc16_ccitt_false_calc(const unsigned char *buf, size_t len);
207 
220 static inline uint16_t crc16_ccitt_aug_update(uint16_t crc, const unsigned char *buf, size_t len)
221 {
222  /* Since CCITT-AUG and CCITT-FALSE only differ in the starting
223  * seed, we wrap around crc16_ccitt_false_update() for updating */
224  return crc16_ccitt_false_update(crc, buf, len);
225 }
226 
244 uint16_t crc16_ccitt_aug_calc(const unsigned char *buf, size_t len);
245 
246 #ifdef __cplusplus
247 }
248 #endif
249 
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:94
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:148
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:220