blob: 1d06aa191de3846ba723d47f3742b6287971a01a [file] [log] [blame]
Harald Welte56db5fd2017-07-14 18:25:59 +02001/* Encoding/Decoding routines for GSM System Information messages
2 * according to 3GPP TS 44.018 Version 12.3.0 Release 12 */
3
4/* (C) 2017 by Harald Welte <laforge@gnumonks.org> */
5
6module GSM_SystemInformation {
7
8 import from General_Types all;
Harald Weltea082a692017-07-15 15:58:13 +02009 import from GSM_Types all;
Harald Weltef9764922017-08-20 22:47:44 +020010 import from GSM_RR_Types all;
Harald Welte615bd542017-07-14 18:28:55 +020011 import from Osmocom_Types all;
Harald Welte56db5fd2017-07-14 18:25:59 +020012
Harald Welte56db5fd2017-07-14 18:25:59 +020013 type union ArfcnOrMaio {
14 uint12_t arfcn,
15 MaioHsn maio_hsn
16 } with { variant "" };
17
Harald Welte56db5fd2017-07-14 18:25:59 +020018 /* 24.008 10.5.1.1 */
Harald Welte484160b2017-07-28 13:30:24 +020019 type uint16_t SysinfoCellIdentity;
Harald Welte56db5fd2017-07-14 18:25:59 +020020
Harald Welte56db5fd2017-07-14 18:25:59 +020021 /* 44.018 10.5.2.1b */
22 type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
23
24 /* 44.018 10.5.2.3 */
Harald Welte82ccef72018-02-25 16:17:33 +010025 type enumerated CellOptions_DTX {
26 MS_MAY_USE_UL_DTX ('00'B),
27 MS_SHALL_USE_UL_DTX ('01'B),
28 MS_SHALL_NOT_USE_UL_DTX ('10'B)
29 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +020030 type record CellOptions {
31 boolean dn_ind,
32 boolean pwrc,
Harald Welte82ccef72018-02-25 16:17:33 +010033 CellOptions_DTX dtx,
34 uint4_t radio_link_tout_div4
Harald Welte56db5fd2017-07-14 18:25:59 +020035 } with { variant "" };
36
37 /* 44.018 10.5.2.3a */
38 type record CellOptionsSacch {
39 BIT1 dtx_ext,
40 boolean pwrc,
41 BIT2 dtx,
42 BIT4 radio_link_timeout
43 } with { variant "" };
44
45 /* 44.018 10.5.2.4 */
46 type record CellSelectionParameters {
Harald Welte82ccef72018-02-25 16:17:33 +010047 uint3_t cell_resel_hyst_2dB,
Harald Welte56db5fd2017-07-14 18:25:59 +020048 uint5_t ms_txpwr_max_cch,
Harald Welte82ccef72018-02-25 16:17:33 +010049 BIT1 acs,
Harald Welte56db5fd2017-07-14 18:25:59 +020050 boolean neci,
51 uint6_t rxlev_access_min
52 } with { variant "" };
53
Harald Welte56db5fd2017-07-14 18:25:59 +020054 /* 44.018 10.5.2.11 */
Harald Welte82ccef72018-02-25 16:17:33 +010055 type enumerated CtrlChanDesc_CC {
56 CCHAN_DESC_1CCCH_NOT_COMBINED ('000'B),
57 CCHAN_DESC_1CCCH_COMBINED ('001'B),
58 CCHAN_DESC_2CCCH_NOT_COMBINED ('010'B),
59 CCHAN_DESC_3CCCH_NOT_COMBINED ('100'B),
60 CCHAN_DESC_4CCCH_NOT_COMBINED ('110'B)
61 } with { variant "FIELDLENGTH(3)" };
62 type enumerated CBQ3 {
63 CBQ3_IU_MODE_NOT_SUPPORTED ('00'B),
64 CBQ3_IU_MODE_MS_BARRED ('01'B),
65 CBQ3_IU_MODE_NOT_BARRED ('10'B)
66 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +020067 type record ControlChannelDescription {
Harald Welte82ccef72018-02-25 16:17:33 +010068 boolean msc_r99,
Harald Welte56db5fd2017-07-14 18:25:59 +020069 boolean att,
70 uint3_t bs_ag_blks_res,
Harald Welte82ccef72018-02-25 16:17:33 +010071 CtrlChanDesc_CC ccch_conf,
Harald Welte56db5fd2017-07-14 18:25:59 +020072 boolean si22ind,
Harald Welte82ccef72018-02-25 16:17:33 +010073 CBQ3 cbq3,
Harald Welte56db5fd2017-07-14 18:25:59 +020074 BIT2 spare,
Harald Welte82ccef72018-02-25 16:17:33 +010075 uint3_t bs_pa_mfrms, /* off by 2 */
Harald Welte56db5fd2017-07-14 18:25:59 +020076 uint8_t t3212
77 } with { variant "" };
78
Harald Welte162b1602017-07-16 03:05:02 +020079 template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? };
80
Harald Welte56db5fd2017-07-14 18:25:59 +020081 /* 44.018 10.5.2.21 */
Harald Welted2e342f2017-07-16 07:34:13 +020082 type record MobileAllocationT {
Harald Welte56db5fd2017-07-14 18:25:59 +020083 OCT1 iei,
84 uint8_t len,
85 bitstring ma
86 } with { variant "" };
87
88 /* 44.018 10.5.2.22 */
89 type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
90
91 /* 44.018 10.5.2.22a */
92 type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
93
94 type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
95
96 /* 44.018 10.5.2.29 */
Harald Welte82ccef72018-02-25 16:17:33 +010097 type enumerated RachCtrlPar_MR {
98 RACH_MAX_RETRANS_1 ('00'B),
99 RACH_MAX_RETRANS_2 ('01'B),
100 RACH_MAX_RETRANS_4 ('10'B),
101 RACH_MAX_RETRANS_7 ('11'B)
102 } with { variant "FIELDLENGTH(2)" };
Harald Welte56db5fd2017-07-14 18:25:59 +0200103 type record RachControlParameters {
Harald Welte82ccef72018-02-25 16:17:33 +0100104 RachCtrlPar_MR max_retrans,
Harald Welte56db5fd2017-07-14 18:25:59 +0200105 BIT4 tx_integer,
106 boolean cell_barr_access,
Harald Welte82ccef72018-02-25 16:17:33 +0100107 boolean re_not_allowed,
108 AccessControlClass acc
109 } with { variant (acc) "FIELDLENGTH(16)" };
Harald Welte56db5fd2017-07-14 18:25:59 +0200110
111 /* 44.018 10.5.2.32 */
112 type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" };
113 type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" };
114
115 /* 44.018 9.1.31 */
116 type record SystemInformationType1 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200117 CellChannelDescription cell_chan_desc,
118 RachControlParameters rach_control,
119 Si1RestOctets rest_octets
120 } with { variant "" };
121
122 /* 44.018 9.1.32 */
123 type record SystemInformationType2 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200124 NeighbourCellDescription bcch_freq_list,
125 BIT8 ncc_permitted,
126 RachControlParameters rach_control
127 } with { variant "" };
128
129 /* 44.018 9.1.33 */
130 type record SystemInformationType2bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200131 NeighbourCellDescription extd_bcch_freq_list,
132 RachControlParameters rach_control,
133 OCT1 rest_octets
134 } with { variant "" };
135
136 /* 44.018 9.1.34 */
137 type record SystemInformationType2ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200138 NeighbourCellDescription2 extd_bcch_freq_list,
Harald Welte56db5fd2017-07-14 18:25:59 +0200139 OCT4 rest_octets
140 } with { variant "" };
141
142 /* 44.018 9.1.35 */
143 type record SystemInformationType3 {
Harald Welte484160b2017-07-28 13:30:24 +0200144 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200145 LocationAreaIdentification lai,
146 ControlChannelDescription ctrl_chan_desc,
147 CellOptions cell_options,
148 CellSelectionParameters cell_sel_par,
149 RachControlParameters rach_control,
150 Si3RestOctets rest_octets
151 } with { variant "" };
152
Harald Welte162b1602017-07-16 03:05:02 +0200153 template SystemInformationType3 t_SI3 := {
154 cell_id := ?,
155 lai := ?,
156 ctrl_chan_desc := t_ControlChannelDescription,
157 cell_options := ?,
158 cell_sel_par := ?,
159 rach_control := ?,
160 rest_octets := ?
161 };
162
163
Harald Welte56db5fd2017-07-14 18:25:59 +0200164 /* 44.018 9.1.36 */
165 type record SystemInformationType4 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200166 LocationAreaIdentification lai,
167 CellSelectionParameters cell_sel_par,
168 RachControlParameters rach_control,
Harald Weltead091b62017-07-16 21:03:17 +0200169 ChannelDescriptionTV cbch_chan_desc optional,
Harald Welted2e342f2017-07-16 07:34:13 +0200170 MobileAllocationT cbch_mobile_alloc optional,
Harald Welte56db5fd2017-07-14 18:25:59 +0200171 RestOctets rest_octets
172 } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
173
174 /* 44.018 9.1.37 */
175 type record SystemInformationType5 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200176 NeighbourCellDescription bcch_freq_list
177 } with { variant "" };
178
179 /* 44.018 9.1.38 */
180 type record SystemInformationType5bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200181 NeighbourCellDescription extd_bcch_freq_list
182 } with { variant "" };
183
184 /* 44.018 9.1.39 */
185 type record SystemInformationType5ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200186 NeighbourCellDescription2 extd_bcch_freq_list
187 } with { variant "" };
188
189 /* 44.018 9.1.40 */
190 type record SystemInformationType6 {
Harald Welte484160b2017-07-28 13:30:24 +0200191 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200192 LocationAreaIdentification lai,
193 CellOptionsSacch cell_options,
194 BIT8 ncc_permitted,
195 OCT7 rest_octets
196 } with { variant "" };
197
Harald Weltea4189182017-07-15 19:59:33 +0200198 type union SystemInformationUnion {
Harald Welte56db5fd2017-07-14 18:25:59 +0200199 SystemInformationType1 si1,
200 SystemInformationType2 si2,
201 SystemInformationType2bis si2bis,
202 SystemInformationType2ter si2ter,
203 SystemInformationType3 si3,
204 SystemInformationType4 si4,
205 SystemInformationType5 si5,
206 SystemInformationType5bis si5bis,
207 SystemInformationType5ter si5ter,
Harald Welte8c5b3252017-07-15 23:59:49 +0200208 SystemInformationType6 si6,
209 octetstring other
Harald Weltea4189182017-07-15 19:59:33 +0200210 } with { variant "" };
211
212 type record SystemInformation {
Harald Welted2e342f2017-07-16 07:34:13 +0200213 RrHeader header,
Harald Weltea4189182017-07-15 19:59:33 +0200214 SystemInformationUnion payload
215 } with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
Harald Weltea082a692017-07-15 15:58:13 +0200216 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
217 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
218 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
219 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
220 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
221 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
222 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
223 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
224 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
Harald Welte8c5b3252017-07-15 23:59:49 +0200225 other, OTHERWISE;
Harald Welte56db5fd2017-07-14 18:25:59 +0200226 )" };
227
228 external function enc_SystemInformation(in SystemInformation si) return octetstring
229 with { extension "prototype(convert) encode(RAW)" };
230 external function dec_SystemInformation(in octetstring stream) return SystemInformation
231 with { extension "prototype(convert) decode(RAW)" };
232
233} with { encode "RAW"; variant "FIELDORDER(msb)" }