blob: f1918c96b7cb365f6b87234536434a099ea6744a [file] [log] [blame]
Harald Welte56db5fd2017-07-14 18:25:59 +02001/* Encoding/Decoding routines for GSM System Information messages
Harald Welte34b5a952019-05-27 11:54:11 +02002 * according to 3GPP TS 44.018 Version 12.3.0 Release 12
3 *
4 * (C) 2018 Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
Harald Welte56db5fd2017-07-14 18:25:59 +020012
13module GSM_SystemInformation {
14
15 import from General_Types all;
Harald Weltea082a692017-07-15 15:58:13 +020016 import from GSM_Types all;
Harald Weltef9764922017-08-20 22:47:44 +020017 import from GSM_RR_Types all;
Harald Welte615bd542017-07-14 18:28:55 +020018 import from Osmocom_Types all;
Harald Welte56db5fd2017-07-14 18:25:59 +020019
Harald Welte56db5fd2017-07-14 18:25:59 +020020 type union ArfcnOrMaio {
21 uint12_t arfcn,
22 MaioHsn maio_hsn
23 } with { variant "" };
24
Harald Welte56db5fd2017-07-14 18:25:59 +020025 /* 24.008 10.5.1.1 */
Harald Welte484160b2017-07-28 13:30:24 +020026 type uint16_t SysinfoCellIdentity;
Harald Welte56db5fd2017-07-14 18:25:59 +020027
Harald Welte56db5fd2017-07-14 18:25:59 +020028 /* 44.018 10.5.2.1b */
29 type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
30
31 /* 44.018 10.5.2.3 */
Harald Welte82ccef72018-02-25 16:17:33 +010032 type enumerated CellOptions_DTX {
33 MS_MAY_USE_UL_DTX ('00'B),
34 MS_SHALL_USE_UL_DTX ('01'B),
35 MS_SHALL_NOT_USE_UL_DTX ('10'B)
36 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +020037 type record CellOptions {
38 boolean dn_ind,
39 boolean pwrc,
Harald Welte82ccef72018-02-25 16:17:33 +010040 CellOptions_DTX dtx,
41 uint4_t radio_link_tout_div4
Harald Welte56db5fd2017-07-14 18:25:59 +020042 } with { variant "" };
43
44 /* 44.018 10.5.2.3a */
45 type record CellOptionsSacch {
46 BIT1 dtx_ext,
47 boolean pwrc,
48 BIT2 dtx,
49 BIT4 radio_link_timeout
50 } with { variant "" };
51
52 /* 44.018 10.5.2.4 */
53 type record CellSelectionParameters {
Harald Welte82ccef72018-02-25 16:17:33 +010054 uint3_t cell_resel_hyst_2dB,
Harald Welte56db5fd2017-07-14 18:25:59 +020055 uint5_t ms_txpwr_max_cch,
Harald Welte82ccef72018-02-25 16:17:33 +010056 BIT1 acs,
Harald Welte56db5fd2017-07-14 18:25:59 +020057 boolean neci,
58 uint6_t rxlev_access_min
59 } with { variant "" };
60
Harald Welte56db5fd2017-07-14 18:25:59 +020061 /* 44.018 10.5.2.11 */
Harald Welte82ccef72018-02-25 16:17:33 +010062 type enumerated CtrlChanDesc_CC {
63 CCHAN_DESC_1CCCH_NOT_COMBINED ('000'B),
64 CCHAN_DESC_1CCCH_COMBINED ('001'B),
65 CCHAN_DESC_2CCCH_NOT_COMBINED ('010'B),
66 CCHAN_DESC_3CCCH_NOT_COMBINED ('100'B),
67 CCHAN_DESC_4CCCH_NOT_COMBINED ('110'B)
68 } with { variant "FIELDLENGTH(3)" };
69 type enumerated CBQ3 {
70 CBQ3_IU_MODE_NOT_SUPPORTED ('00'B),
71 CBQ3_IU_MODE_MS_BARRED ('01'B),
72 CBQ3_IU_MODE_NOT_BARRED ('10'B)
73 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +020074 type record ControlChannelDescription {
Harald Welte82ccef72018-02-25 16:17:33 +010075 boolean msc_r99,
Harald Welte56db5fd2017-07-14 18:25:59 +020076 boolean att,
77 uint3_t bs_ag_blks_res,
Harald Welte82ccef72018-02-25 16:17:33 +010078 CtrlChanDesc_CC ccch_conf,
Harald Welte56db5fd2017-07-14 18:25:59 +020079 boolean si22ind,
Harald Welte82ccef72018-02-25 16:17:33 +010080 CBQ3 cbq3,
Harald Welte56db5fd2017-07-14 18:25:59 +020081 BIT2 spare,
Harald Welte82ccef72018-02-25 16:17:33 +010082 uint3_t bs_pa_mfrms, /* off by 2 */
Harald Welte56db5fd2017-07-14 18:25:59 +020083 uint8_t t3212
84 } with { variant "" };
85
Harald Welte162b1602017-07-16 03:05:02 +020086 template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? };
87
Harald Welte56db5fd2017-07-14 18:25:59 +020088 /* 44.018 10.5.2.21 */
Harald Welted2e342f2017-07-16 07:34:13 +020089 type record MobileAllocationT {
Harald Welte56db5fd2017-07-14 18:25:59 +020090 OCT1 iei,
91 uint8_t len,
92 bitstring ma
93 } with { variant "" };
94
95 /* 44.018 10.5.2.22 */
96 type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
97
98 /* 44.018 10.5.2.22a */
99 type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
100
101 type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
102
103 /* 44.018 10.5.2.29 */
Harald Welte82ccef72018-02-25 16:17:33 +0100104 type enumerated RachCtrlPar_MR {
105 RACH_MAX_RETRANS_1 ('00'B),
106 RACH_MAX_RETRANS_2 ('01'B),
107 RACH_MAX_RETRANS_4 ('10'B),
108 RACH_MAX_RETRANS_7 ('11'B)
109 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +0200110 type record RachControlParameters {
Harald Welte82ccef72018-02-25 16:17:33 +0100111 RachCtrlPar_MR max_retrans,
Harald Welte56db5fd2017-07-14 18:25:59 +0200112 BIT4 tx_integer,
113 boolean cell_barr_access,
Harald Welte82ccef72018-02-25 16:17:33 +0100114 boolean re_not_allowed,
115 AccessControlClass acc
116 } with { variant (acc) "FIELDLENGTH(16)" };
Harald Welte56db5fd2017-07-14 18:25:59 +0200117
118 /* 44.018 10.5.2.32 */
119 type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" };
120 type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" };
121
122 /* 44.018 9.1.31 */
123 type record SystemInformationType1 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200124 CellChannelDescription cell_chan_desc,
125 RachControlParameters rach_control,
126 Si1RestOctets rest_octets
127 } with { variant "" };
128
129 /* 44.018 9.1.32 */
130 type record SystemInformationType2 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200131 NeighbourCellDescription bcch_freq_list,
132 BIT8 ncc_permitted,
133 RachControlParameters rach_control
134 } with { variant "" };
135
136 /* 44.018 9.1.33 */
137 type record SystemInformationType2bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200138 NeighbourCellDescription extd_bcch_freq_list,
139 RachControlParameters rach_control,
140 OCT1 rest_octets
141 } with { variant "" };
142
143 /* 44.018 9.1.34 */
144 type record SystemInformationType2ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200145 NeighbourCellDescription2 extd_bcch_freq_list,
Harald Welte56db5fd2017-07-14 18:25:59 +0200146 OCT4 rest_octets
147 } with { variant "" };
148
149 /* 44.018 9.1.35 */
150 type record SystemInformationType3 {
Harald Welte484160b2017-07-28 13:30:24 +0200151 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200152 LocationAreaIdentification lai,
153 ControlChannelDescription ctrl_chan_desc,
154 CellOptions cell_options,
155 CellSelectionParameters cell_sel_par,
156 RachControlParameters rach_control,
157 Si3RestOctets rest_octets
158 } with { variant "" };
159
Harald Welte162b1602017-07-16 03:05:02 +0200160 template SystemInformationType3 t_SI3 := {
161 cell_id := ?,
162 lai := ?,
163 ctrl_chan_desc := t_ControlChannelDescription,
164 cell_options := ?,
165 cell_sel_par := ?,
166 rach_control := ?,
167 rest_octets := ?
168 };
169
170
Harald Welte56db5fd2017-07-14 18:25:59 +0200171 /* 44.018 9.1.36 */
172 type record SystemInformationType4 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200173 LocationAreaIdentification lai,
174 CellSelectionParameters cell_sel_par,
175 RachControlParameters rach_control,
Harald Weltead091b62017-07-16 21:03:17 +0200176 ChannelDescriptionTV cbch_chan_desc optional,
Harald Welted2e342f2017-07-16 07:34:13 +0200177 MobileAllocationT cbch_mobile_alloc optional,
Harald Welte56db5fd2017-07-14 18:25:59 +0200178 RestOctets rest_octets
179 } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
180
181 /* 44.018 9.1.37 */
182 type record SystemInformationType5 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200183 NeighbourCellDescription bcch_freq_list
184 } with { variant "" };
185
186 /* 44.018 9.1.38 */
187 type record SystemInformationType5bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200188 NeighbourCellDescription extd_bcch_freq_list
189 } with { variant "" };
190
191 /* 44.018 9.1.39 */
192 type record SystemInformationType5ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200193 NeighbourCellDescription2 extd_bcch_freq_list
194 } with { variant "" };
195
196 /* 44.018 9.1.40 */
197 type record SystemInformationType6 {
Harald Welte484160b2017-07-28 13:30:24 +0200198 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200199 LocationAreaIdentification lai,
200 CellOptionsSacch cell_options,
201 BIT8 ncc_permitted,
202 OCT7 rest_octets
203 } with { variant "" };
204
Harald Weltea4189182017-07-15 19:59:33 +0200205 type union SystemInformationUnion {
Harald Welte56db5fd2017-07-14 18:25:59 +0200206 SystemInformationType1 si1,
207 SystemInformationType2 si2,
208 SystemInformationType2bis si2bis,
209 SystemInformationType2ter si2ter,
210 SystemInformationType3 si3,
211 SystemInformationType4 si4,
212 SystemInformationType5 si5,
213 SystemInformationType5bis si5bis,
214 SystemInformationType5ter si5ter,
Harald Welte8c5b3252017-07-15 23:59:49 +0200215 SystemInformationType6 si6,
216 octetstring other
Harald Weltea4189182017-07-15 19:59:33 +0200217 } with { variant "" };
218
219 type record SystemInformation {
Harald Welted2e342f2017-07-16 07:34:13 +0200220 RrHeader header,
Harald Weltea4189182017-07-15 19:59:33 +0200221 SystemInformationUnion payload
222 } with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
Harald Weltea082a692017-07-15 15:58:13 +0200223 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
224 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
225 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
226 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
227 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
228 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
229 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
230 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
231 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
Harald Welte8c5b3252017-07-15 23:59:49 +0200232 other, OTHERWISE;
Harald Welte56db5fd2017-07-14 18:25:59 +0200233 )" };
234
235 external function enc_SystemInformation(in SystemInformation si) return octetstring
236 with { extension "prototype(convert) encode(RAW)" };
237 external function dec_SystemInformation(in octetstring stream) return SystemInformation
238 with { extension "prototype(convert) decode(RAW)" };
239
240} with { encode "RAW"; variant "FIELDORDER(msb)" }