annotate libutil/osmo_bits.h @ 247:c6a3fb913c53

top Makefile: mtctest changed to use libnumdb2
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 14 Aug 2023 22:39:28 -0800
parents 05d01e810217
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
194
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This include file has been put together from Osmocom (specifically
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * libosmocore) header files, containing definitions for bit vector
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * manipulation and CRC functions.
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 /* from bits.h */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 /*! unpacked bit (0 or 1): 1 bit per byte */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 typedef uint8_t ubit_t;
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 /* from crc8gen.h */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 /*! structure describing a given CRC code of max 8 bits */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct osmo_crc8gen_code {
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int bits; /*!< Actual number of bits of the CRC */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 uint8_t poly; /*!< Polynom (normal representation, MSB omitted */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 uint8_t init; /*!< Initialization value of the CRC state */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint8_t remainder; /*!< Remainder of the CRC (final XOR) */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 };
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code,
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 const ubit_t *in, int len);
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code,
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 const ubit_t *in, int len, const ubit_t *crc_bits);
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code,
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 const ubit_t *in, int len, ubit_t *crc_bits);
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /*
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 * Themyscira-added (not Osmocom-originating) functions
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * that use the ubit_t defined type that (to our knowledge)
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 * was invented by Osmocom.
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 */
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
05d01e810217 libutil: add TFO message gen function based on Osmocom crc8gen
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 void uint16_to_bits(uint16_t word, ubit_t *out, unsigned nbits);