libosmocore
UNKNOWN
Osmocom core library
Toggle main menu visibility
Loading...
Searching...
No Matches
crc16.h
Go to the documentation of this file.
1
6
7
/*
8
* crc16.h - CRC-16 routine
9
*
10
* Implements the standard CRC-16:
11
* - Width 16
12
* - Poly 0x8005 (x^16 + x^15 + x^2 + 1)
13
* - Init 0
14
*
15
* Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
16
*
17
* This source code is licensed under the GNU General Public License,
18
* Version 2. See the file COPYING for more details.
19
*/
20
21
#pragma once
22
23
#include <stdint.h>
24
25
#include <sys/types.h>
26
27
extern
uint16_t
const
osmo_crc16_table
[256];
28
29
extern
uint16_t
osmo_crc16
(uint16_t crc,
const
uint8_t *
buffer
,
size_t
len
);
30
32
static
inline
uint16_t
osmo_crc16_byte
(uint16_t crc,
const
uint8_t
data
)
33
{
34
return
(crc >> 8) ^
osmo_crc16_table
[(crc ^
data
) & 0xff];
35
}
36
37
38
39
extern
uint16_t
const
osmo_crc16_ccitt_table
[256];
40
41
extern
uint16_t
osmo_crc16_ccitt
(uint16_t crc,
const
uint8_t *
buffer
,
size_t
len
);
42
44
static
inline
uint16_t
osmo_crc16_ccitt_byte
(uint16_t crc,
const
uint8_t
data
)
45
{
46
return
(crc >> 8) ^
osmo_crc16_ccitt_table
[(crc ^
data
) & 0xff];
47
}
48
osmo_crc16_byte
static uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data)
CRC-16 polynome 0x8005 (x^16 + x^15 + x^2 + 1).
Definition
crc16.h:32
osmo_crc16_table
uint16_t const osmo_crc16_table[256]
CRC table for the CRC-16.
Definition
crc16.c:18
osmo_crc16
uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len)
Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.
Definition
crc16.c:59
osmo_crc16_ccitt
uint16_t osmo_crc16_ccitt(uint16_t crc, const uint8_t *buffer, size_t len)
Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.
Definition
crc16.c:108
osmo_crc16_ccitt_table
uint16_t const osmo_crc16_ccitt_table[256]
CRC table for the CCITT CRC-6.
Definition
crc16.c:67
osmo_crc16_ccitt_byte
static uint16_t osmo_crc16_ccitt_byte(uint16_t crc, const uint8_t data)
CCITT polynome 0x8408 (x^0 + x^5 + x^12).
Definition
crc16.h:44
data
uint8_t data[0]
len
uint8_t len
buffer
include
osmocom
core
crc16.h
Generated by
1.17.0