blob: 164f720136ab8ef9bde004fd5f584361e21b2578 [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
Sylvain Munaut12ba7782014-06-16 10:13:40 +020023#pragma once
Sylvain Munaut2749c0b2011-09-16 22:59:18 +020024
25/*! \addtogroup crcgen
26 * @{
27 */
28
29/*! \file crcXXgen.h
Katerina Barone-Adesic28c6a02013-02-15 13:27:59 +010030 * Osmocom generic CRC routines (for max XX bits poly) header
Sylvain Munaut2749c0b2011-09-16 22:59:18 +020031 */
32
33
34#include <stdint.h>
35#include <osmocom/core/bits.h>
36
37
38/*! \brief structure describing a given CRC code of max XX bits */
39struct osmo_crcXXgen_code {
40 int bits; /*!< \brief Actual number of bits of the CRC */
41 uintXX_t poly; /*!< \brief Polynom (normal representation, MSB omitted */
42 uintXX_t init; /*!< \brief Initialization value of the CRC state */
43 uintXX_t remainder; /*!< \brief Remainder of the CRC (final XOR) */
44};
45
46uintXX_t osmo_crcXXgen_compute_bits(const struct osmo_crcXXgen_code *code,
47 const ubit_t *in, int len);
48int osmo_crcXXgen_check_bits(const struct osmo_crcXXgen_code *code,
49 const ubit_t *in, int len, const ubit_t *crc_bits);
50void osmo_crcXXgen_set_bits(const struct osmo_crcXXgen_code *code,
51 const ubit_t *in, int len, ubit_t *crc_bits);
52
53
Sylvain Munautdca7d2c2012-04-18 21:53:23 +020054/*! @} */
Sylvain Munaut2749c0b2011-09-16 22:59:18 +020055
Sylvain Munaut2749c0b2011-09-16 22:59:18 +020056/* vim: set syntax=c: */