libosmocore  1.5.1
Osmocom core library
crc64gen.h
Go to the documentation of this file.
1 
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 #pragma once
24 
29 #include <stdint.h>
30 #include <osmocom/core/bits.h>
31 
32 
35  int bits;
36  uint64_t poly;
37  uint64_t init;
38  uint64_t remainder;
39 };
40 
41 uint64_t osmo_crc64gen_compute_bits(const struct osmo_crc64gen_code *code,
42  const ubit_t *in, int len);
43 int osmo_crc64gen_check_bits(const struct osmo_crc64gen_code *code,
44  const ubit_t *in, int len, const ubit_t *crc_bits);
45 void osmo_crc64gen_set_bits(const struct osmo_crc64gen_code *code,
46  const ubit_t *in, int len, ubit_t *crc_bits);
47 
48 
51 /* vim: set syntax=c: */
len
static size_t len(const char *str)
osmo_crc64gen_code
structure describing a given CRC code of max 64 bits
Definition: crc64gen.h:34
osmo_crc64gen_code::init
uint64_t init
Initialization value of the CRC state.
Definition: crc64gen.h:37
bits.h
osmo_crc64gen_code::poly
uint64_t poly
Polynom (normal representation, MSB omitted.
Definition: crc64gen.h:36
osmo_crc64gen_code::bits
int bits
Actual number of bits of the CRC.
Definition: crc64gen.h:35
ubit_t
uint8_t ubit_t
unpacked bit (0 or 1): 1 bit per byte
Definition: bits.h:24
osmo_crc64gen_set_bits
void osmo_crc64gen_set_bits(const struct osmo_crc64gen_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: crc64gen.c:104
osmo_crc64gen_code::remainder
uint64_t remainder
Remainder of the CRC (final XOR)
Definition: crc64gen.h:38
osmo_crc64gen_check_bits
int osmo_crc64gen_check_bits(const struct osmo_crc64gen_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: crc64gen.c:79
osmo_crc64gen_compute_bits
uint64_t osmo_crc64gen_compute_bits(const struct osmo_crc64gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc64gen.c:44