comparison libutil/tfo_msg_enc.c @ 0:35c0d9f03c0a

beginning with sipout-test-voice, a copy of sip-manual-out from themwi-system-sw
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Mar 2024 23:20:19 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:35c0d9f03c0a
1 /*
2 * The function implemented in this module encodes a GSM 08.62 Extension_Block.
3 */
4
5 #include <stdint.h>
6 #include "osmo_bits.h"
7
8 /*
9 * EFR TRAU parity
10 *
11 * g(x) = x^3 + x^1 + 1
12 */
13 static const struct osmo_crc8gen_code gsm0860_efr_crc3 = {
14 .bits = 3,
15 .poly = 0x3,
16 .init = 0x0,
17 .remainder = 0x7,
18 };
19
20 void
21 encode_tfo_ext_words(bits_2_10, bits_12_15, ex, out)
22 unsigned bits_2_10, bits_12_15, ex;
23 uint16_t *out;
24 {
25 ubit_t crc_in[13];
26 uint8_t crc;
27
28 uint16_to_bits(bits_2_10, crc_in, 9);
29 uint16_to_bits(bits_12_15, crc_in + 9, 4);
30 crc = osmo_crc8gen_compute_bits(&gsm0860_efr_crc3, crc_in, 13);
31 out[0] = bits_2_10;
32 out[1] = (bits_12_15 << 5) | (crc << 2) | ex;
33 }