libosmocore UNKNOWN
Osmocom core library
crc8gen.h
Go to the documentation of this file.
1/*
2 * crc8gen.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
19#ifndef __OSMO_CRC8GEN_H__
20#define __OSMO_CRC8GEN_H__
21
31#include <stdint.h>
32#include <osmocom/core/bits.h>
33
34
37 int bits;
38 uint8_t poly;
39 uint8_t init;
40 uint8_t remainder;
41};
42
43uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
44 const ubit_t *in, int len);
45int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
46 const ubit_t *in, int len, const ubit_t *crc_bits);
47void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
48 const ubit_t *in, int len, ubit_t *crc_bits);
49
50
53#endif /* __OSMO_CRC8GEN_H__ */
54
55/* vim: set syntax=c: */
uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc8gen.c:42
int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
Checks the CRC value of a given array of hard-bits.
Definition: crc8gen.c:77
void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
Computes and writes the CRC value of a given array of bits.
Definition: crc8gen.c:102
structure describing a given CRC code of max 8 bits
Definition: crc8gen.h:36
uint8_t poly
Polynom (normal representation, MSB omitted.
Definition: crc8gen.h:38
int bits
Actual number of bits of the CRC.
Definition: crc8gen.h:37
uint8_t init
Initialization value of the CRC state.
Definition: crc8gen.h:39
uint8_t remainder
Remainder of the CRC (final XOR)
Definition: crc8gen.h:40