2017-06-20 02:35:06 +00:00
|
|
|
/*! \file crcXXgen.h
|
|
|
|
* Osmocom generic CRC routines (for max XX bits poly) header. */
|
2011-09-16 20:59:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2014-06-16 08:13:40 +00:00
|
|
|
#pragma once
|
2011-09-16 20:59:18 +00:00
|
|
|
|
2017-10-16 12:29:26 +00:00
|
|
|
/*! \addtogroup crc
|
2011-09-16 20:59:18 +00:00
|
|
|
* @{
|
2017-06-20 02:35:06 +00:00
|
|
|
* \file crcXXgen.h.tpl */
|
2011-09-16 20:59:18 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <osmocom/core/bits.h>
|
|
|
|
|
|
|
|
|
2017-06-19 22:17:59 +00:00
|
|
|
/*! structure describing a given CRC code of max XX bits */
|
2011-09-16 20:59:18 +00:00
|
|
|
struct osmo_crcXXgen_code {
|
2017-06-19 22:17:59 +00:00
|
|
|
int bits; /*!< Actual number of bits of the CRC */
|
|
|
|
uintXX_t poly; /*!< Polynom (normal representation, MSB omitted */
|
|
|
|
uintXX_t init; /*!< Initialization value of the CRC state */
|
|
|
|
uintXX_t remainder; /*!< Remainder of the CRC (final XOR) */
|
2011-09-16 20:59:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
uintXX_t osmo_crcXXgen_compute_bits(const struct osmo_crcXXgen_code *code,
|
|
|
|
const ubit_t *in, int len);
|
|
|
|
int osmo_crcXXgen_check_bits(const struct osmo_crcXXgen_code *code,
|
|
|
|
const ubit_t *in, int len, const ubit_t *crc_bits);
|
|
|
|
void osmo_crcXXgen_set_bits(const struct osmo_crcXXgen_code *code,
|
|
|
|
const ubit_t *in, int len, ubit_t *crc_bits);
|
|
|
|
|
|
|
|
|
2012-04-18 19:53:23 +00:00
|
|
|
/*! @} */
|
2011-09-16 20:59:18 +00:00
|
|
|
|
|
|
|
/* vim: set syntax=c: */
|