1 /* GSM 04.08 System Information (SI) encoding and decoding
2 * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
4 /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <netinet/in.h>
28 #include <osmocom/core/bitvec.h>
29 #include <osmocom/core/utils.h>
30 #include <osmocom/gsm/sysinfo.h>
31 #include <osmocom/gsm/protocol/gsm_04_08.h>
32 #include <osmocom/gsm/protocol/gsm_08_58.h>
34 /* verify the sizes of the system information type structs */
36 /* rest octets are not part of the struct */
37 osmo_static_assert(sizeof(struct gsm48_system_information_type_header) == 3, _si_header_size);
38 osmo_static_assert(sizeof(struct gsm48_rach_control) == 3, _si_rach_control);
39 osmo_static_assert(sizeof(struct gsm48_system_information_type_1) == 22, _si1_size);
40 osmo_static_assert(sizeof(struct gsm48_system_information_type_2) == 23, _si2_size);
41 osmo_static_assert(sizeof(struct gsm48_system_information_type_3) == 19, _si3_size);
42 osmo_static_assert(sizeof(struct gsm48_system_information_type_4) == 13, _si4_size);
44 /* bs11 forgot the l2 len, 0-6 rest octets */
45 osmo_static_assert(sizeof(struct gsm48_system_information_type_5) == 18, _si5_size);
46 osmo_static_assert(sizeof(struct gsm48_system_information_type_6) == 11, _si6_size);
48 osmo_static_assert(sizeof(struct gsm48_system_information_type_13) == 3, _si13_size);
50 static const uint8_t sitype2rsl[_MAX_SYSINFO_TYPE] = {
51 [SYSINFO_TYPE_1] = RSL_SYSTEM_INFO_1,
52 [SYSINFO_TYPE_2] = RSL_SYSTEM_INFO_2,
53 [SYSINFO_TYPE_3] = RSL_SYSTEM_INFO_3,
54 [SYSINFO_TYPE_4] = RSL_SYSTEM_INFO_4,
55 [SYSINFO_TYPE_5] = RSL_SYSTEM_INFO_5,
56 [SYSINFO_TYPE_6] = RSL_SYSTEM_INFO_6,
57 [SYSINFO_TYPE_7] = RSL_SYSTEM_INFO_7,
58 [SYSINFO_TYPE_8] = RSL_SYSTEM_INFO_8,
59 [SYSINFO_TYPE_9] = RSL_SYSTEM_INFO_9,
60 [SYSINFO_TYPE_10] = RSL_SYSTEM_INFO_10,
61 [SYSINFO_TYPE_13] = RSL_SYSTEM_INFO_13,
62 [SYSINFO_TYPE_16] = RSL_SYSTEM_INFO_16,
63 [SYSINFO_TYPE_17] = RSL_SYSTEM_INFO_17,
64 [SYSINFO_TYPE_18] = RSL_SYSTEM_INFO_18,
65 [SYSINFO_TYPE_19] = RSL_SYSTEM_INFO_19,
66 [SYSINFO_TYPE_20] = RSL_SYSTEM_INFO_20,
67 [SYSINFO_TYPE_2bis] = RSL_SYSTEM_INFO_2bis,
68 [SYSINFO_TYPE_2ter] = RSL_SYSTEM_INFO_2ter,
69 [SYSINFO_TYPE_2quater] = RSL_SYSTEM_INFO_2quater,
70 [SYSINFO_TYPE_5bis] = RSL_SYSTEM_INFO_5bis,
71 [SYSINFO_TYPE_5ter] = RSL_SYSTEM_INFO_5ter,
74 static const uint8_t rsl2sitype[0xff] = {
75 [RSL_SYSTEM_INFO_1] = SYSINFO_TYPE_1,
76 [RSL_SYSTEM_INFO_2] = SYSINFO_TYPE_2,
77 [RSL_SYSTEM_INFO_3] = SYSINFO_TYPE_3,
78 [RSL_SYSTEM_INFO_4] = SYSINFO_TYPE_4,
79 [RSL_SYSTEM_INFO_5] = SYSINFO_TYPE_5,
80 [RSL_SYSTEM_INFO_6] = SYSINFO_TYPE_6,
81 [RSL_SYSTEM_INFO_7] = SYSINFO_TYPE_7,
82 [RSL_SYSTEM_INFO_8] = SYSINFO_TYPE_8,
83 [RSL_SYSTEM_INFO_9] = SYSINFO_TYPE_9,
84 [RSL_SYSTEM_INFO_10] = SYSINFO_TYPE_10,
85 [RSL_SYSTEM_INFO_13] = SYSINFO_TYPE_13,
86 [RSL_SYSTEM_INFO_16] = SYSINFO_TYPE_16,
87 [RSL_SYSTEM_INFO_17] = SYSINFO_TYPE_17,
88 [RSL_SYSTEM_INFO_18] = SYSINFO_TYPE_18,
89 [RSL_SYSTEM_INFO_19] = SYSINFO_TYPE_19,
90 [RSL_SYSTEM_INFO_20] = SYSINFO_TYPE_20,
91 [RSL_SYSTEM_INFO_2bis] = SYSINFO_TYPE_2bis,
92 [RSL_SYSTEM_INFO_2ter] = SYSINFO_TYPE_2ter,
93 [RSL_SYSTEM_INFO_2quater] = SYSINFO_TYPE_2quater,
94 [RSL_SYSTEM_INFO_5bis] = SYSINFO_TYPE_5bis,
95 [RSL_SYSTEM_INFO_5ter] = SYSINFO_TYPE_5ter,
98 const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = {
99 { SYSINFO_TYPE_1, "1" },
100 { SYSINFO_TYPE_2, "2" },
101 { SYSINFO_TYPE_3, "3" },
102 { SYSINFO_TYPE_4, "4" },
103 { SYSINFO_TYPE_5, "5" },
104 { SYSINFO_TYPE_6, "6" },
105 { SYSINFO_TYPE_7, "7" },
106 { SYSINFO_TYPE_8, "8" },
107 { SYSINFO_TYPE_9, "9" },
108 { SYSINFO_TYPE_10, "10" },
109 { SYSINFO_TYPE_13, "13" },
110 { SYSINFO_TYPE_16, "16" },
111 { SYSINFO_TYPE_17, "17" },
112 { SYSINFO_TYPE_18, "18" },
113 { SYSINFO_TYPE_19, "19" },
114 { SYSINFO_TYPE_20, "20" },
115 { SYSINFO_TYPE_2bis, "2bis" },
116 { SYSINFO_TYPE_2ter, "2ter" },
117 { SYSINFO_TYPE_2quater, "2quater" },
118 { SYSINFO_TYPE_5bis, "5bis" },
119 { SYSINFO_TYPE_5ter, "5ter" },
123 uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type)
125 return sitype2rsl[si_type];
128 enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si)
130 return rsl2sitype[rsl_si];