view trau-decode/osmo_bits.h @ 14:98c0881c2af0

tfo/find-is-hdr: move here from freecalypso-reveng This little program was developed in freecalypso-reveng Hg repository in 2023-03, when we didn't have a separate repository for network-side reverse eng, but now that we do have separate repositories for FreeCalypso (mobile side) vs network side reverse eng, move TFO RE work to the proper place.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 24 May 2024 21:18:22 +0000
parents d9c095357c32
children
line wrap: on
line source

/*
 * This include file has been put together from Osmocom (specifically
 * libosmocore) header files, containing definitions for bit vector
 * manipulation and CRC functions.
 */

/* from bits.h */

/*! unpacked bit (0 or 1): 1 bit per byte */
typedef uint8_t ubit_t;

/* from crc8gen.h */

/*! structure describing a given CRC code of max 8 bits */
struct osmo_crc8gen_code {
	int bits;          /*!< Actual number of bits of the CRC */
	uint8_t poly;      /*!< Polynom (normal representation, MSB omitted */
	uint8_t init;      /*!< Initialization value of the CRC state */
	uint8_t remainder; /*!< Remainder of the CRC (final XOR) */
};

uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
                                  const ubit_t *in, int len);
int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
                            const ubit_t *in, int len, const ubit_t *crc_bits);
void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
                           const ubit_t *in, int len, ubit_t *crc_bits);