blob: b411276e2989f74c45da2e2a464fdf0734e3046d [file] [log] [blame]
Sylvain Munaut2749c0b2011-09-16 22:59:18 +02001/*
2 * crcXXgen.h
3 *
4 * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#ifndef __OSMO_CRCXXGEN_H__
24#define __OSMO_CRCXXGEN_H__
25
26/*! \addtogroup crcgen
27 * @{
28 */
29
30/*! \file crcXXgen.h
31 * \file Osmocom generic CRC routines (for max XX bits poly) header
32 */
33
34
35#include <stdint.h>
36#include <osmocom/core/bits.h>
37
38
39/*! \brief structure describing a given CRC code of max XX bits */
40struct osmo_crcXXgen_code {
41 int bits; /*!< \brief Actual number of bits of the CRC */
42 uintXX_t poly; /*!< \brief Polynom (normal representation, MSB omitted */
43 uintXX_t init; /*!< \brief Initialization value of the CRC state */
44 uintXX_t remainder; /*!< \brief Remainder of the CRC (final XOR) */
45};
46
47uintXX_t osmo_crcXXgen_compute_bits(const struct osmo_crcXXgen_code *code,
48 const ubit_t *in, int len);
49int osmo_crcXXgen_check_bits(const struct osmo_crcXXgen_code *code,
50 const ubit_t *in, int len, const ubit_t *crc_bits);
51void osmo_crcXXgen_set_bits(const struct osmo_crcXXgen_code *code,
52 const ubit_t *in, int len, ubit_t *crc_bits);
53
54
55/*! }@ */
56
57#endif /* __OSMO_CRCXXGEN_H__ */
58
59/* vim: set syntax=c: */