crc: use namespace prefix osmo_*
[osmocom-bb.git] / include / osmocom / core / crc16.h
1 /*
2  * This was copied from the linux kernel and adjusted for our types.
3  */
4 /*
5  *      crc16.h - CRC-16 routine
6  *
7  * Implements the standard CRC-16:
8  *   Width 16
9  *   Poly  0x8005 (x^16 + x^15 + x^2 + 1)
10  *   Init  0
11  *
12  * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
13  *
14  * This source code is licensed under the GNU General Public License,
15  * Version 2. See the file COPYING for more details.
16  */
17
18 #ifndef __CRC16_H
19 #define __CRC16_H
20
21 #include <stdint.h>
22
23 #include <sys/types.h>
24
25 extern uint16_t const osmo_crc16_table[256];
26
27 extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len);
28
29 static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data)
30 {
31         return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff];
32 }
33
34 #endif /* __CRC16_H */