Sylvain Munaut | 2749c0b | 2011-09-16 22:59:18 +0200 | [diff] [blame] | 1 | /* |
| 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 |
Katerina Barone-Adesi | c28c6a0 | 2013-02-15 13:27:59 +0100 | [diff] [blame] | 31 | * Osmocom generic CRC routines (for max XX bits poly) header |
Sylvain Munaut | 2749c0b | 2011-09-16 22:59:18 +0200 | [diff] [blame] | 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 */ |
| 40 | struct 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 | |
| 47 | uintXX_t osmo_crcXXgen_compute_bits(const struct osmo_crcXXgen_code *code, |
| 48 | const ubit_t *in, int len); |
| 49 | int osmo_crcXXgen_check_bits(const struct osmo_crcXXgen_code *code, |
| 50 | const ubit_t *in, int len, const ubit_t *crc_bits); |
| 51 | void osmo_crcXXgen_set_bits(const struct osmo_crcXXgen_code *code, |
| 52 | const ubit_t *in, int len, ubit_t *crc_bits); |
| 53 | |
| 54 | |
Sylvain Munaut | dca7d2c | 2012-04-18 21:53:23 +0200 | [diff] [blame] | 55 | /*! @} */ |
Sylvain Munaut | 2749c0b | 2011-09-16 22:59:18 +0200 | [diff] [blame] | 56 | |
| 57 | #endif /* __OSMO_CRCXXGEN_H__ */ |
| 58 | |
| 59 | /* vim: set syntax=c: */ |