blob: a6f2905c11d9904dab6a5daa65752d2e259e3594 [file] [log] [blame]
Max51754b62019-03-13 17:14:13 +01001/* coding_scheme.c
2 *
3 * Copyright (C) 2019 by sysmocom s.f.m.c. GmbH
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <stdint.h>
21#include <stdbool.h>
22
23#include <osmocom/core/utils.h>
24
25#include "coding_scheme.h"
26
27static struct {
28 struct {
29 uint8_t data_header_bits;
30 } uplink, downlink;
31 uint8_t data_block_header_bits;
32 uint8_t num_blocks;
33 const char *name;
34} hdr_type_info[NUM_HEADER_TYPES] = {
35 { { 0 }, { 0 }, 0, 0, "INVALID" },
36 { { 1 * 8 + 0 }, { 1 * 8 + 0 }, 0, 0, "CONTROL" },
37 { { 3 * 8 + 0 }, { 3 * 8 + 0 }, 0, 1, "GPRS_DATA" },
38 { { 5 * 8 + 6 }, { 5 * 8 + 0 }, 2, 2, "EGPRS_DATA_TYPE1" },
39 { { 4 * 8 + 5 }, { 3 * 8 + 4 }, 2, 1, "EGPRS_DATA_TYPE2" },
40 { { 3 * 8 + 7 }, { 3 * 8 + 7 }, 2, 1, "EGPRS_DATA_TYPE3" },
41};
42
43uint8_t num_data_blocks(enum HeaderType ht)
44{
45 OSMO_ASSERT(ht < NUM_HEADER_TYPES);
46 return hdr_type_info[ht].num_blocks;
47}
48
49uint8_t num_data_header_bits_UL(enum HeaderType ht)
50{
51 OSMO_ASSERT(ht < NUM_HEADER_TYPES);
52 return hdr_type_info[ht].uplink.data_header_bits;
53}
54
55uint8_t num_data_header_bits_DL(enum HeaderType ht)
56{
57 OSMO_ASSERT(ht < NUM_HEADER_TYPES);
58 return hdr_type_info[ht].downlink.data_header_bits;
59}
60
61uint8_t num_data_block_header_bits(enum HeaderType ht)
62{
63 OSMO_ASSERT(ht < NUM_HEADER_TYPES);
64 return hdr_type_info[ht].data_block_header_bits;
65}