blob: 8413ee37ac2f215416df868131bcfac68fe11686 [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 Welte615bd542017-07-14 18:28:55 +020010 import from Osmocom_Types all;
Harald Welte56db5fd2017-07-14 18:25:59 +020011
12 type record L2PseudoLength {
13 uint6_t l2_plen,
14 BIT2 zero_one
15 } with { variant "" };
16
17 template L2PseudoLength t_L2Pseudolength(uint6_t len) := {
18 l2_plen := len,
19 zero_one := '01'B
20 };
21
22 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
23
24 type record MaioHsn {
25 } with { variant "" };
26
27 type union ArfcnOrMaio {
28 uint12_t arfcn,
29 MaioHsn maio_hsn
30 } with { variant "" };
31
32 type record SystemInformationHeader {
33 L2PseudoLength l2_plen,
34 uint4_t skip_indicator,
35 uint4_t rr_protocol_discriminator,
Harald Weltea082a692017-07-15 15:58:13 +020036 RrMessageType message_type
Harald Welte56db5fd2017-07-14 18:25:59 +020037 } with { variant "" };
38
Harald Weltea082a692017-07-15 15:58:13 +020039 template SystemInformationHeader t_SiHeader(RrMessageType msg_type, uint6_t len) := {
Harald Welte56db5fd2017-07-14 18:25:59 +020040 l2_plen := t_L2Pseudolength(len),
41 rr_protocol_discriminator := 6,
42 message_type := msg_type
43 };
44
45 external function enc_SystemInformationHeader(in SystemInformationHeader si) return octetstring
46 with { extension "prototype(convert) encode(RAW)" };
47 external function dec_SystemInformationHeader(in octetstring stream) return SystemInformationHeader
48 with { extension "prototype(convert) decode(RAW)" };
49
50 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
51 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
52
53 /* 24.008 10.5.1.1 */
54 type uint16_t CellIdentity;
55
56 /* 24.008 10.5.1.3 */
57 type record LocationAreaIdentification {
58 BcdMccMnc mcc_mnc,
59 uint16_t lac
60 } with { variant "" };
61
62 /* 44.018 10.5.2.1b */
63 type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
64
65 /* 44.018 10.5.2.3 */
66 type record CellOptions {
67 boolean dn_ind,
68 boolean pwrc,
69 BIT2 dtx,
70 BIT4 radio_link_timeout
71 } with { variant "" };
72
73 /* 44.018 10.5.2.3a */
74 type record CellOptionsSacch {
75 BIT1 dtx_ext,
76 boolean pwrc,
77 BIT2 dtx,
78 BIT4 radio_link_timeout
79 } with { variant "" };
80
81 /* 44.018 10.5.2.4 */
82 type record CellSelectionParameters {
83 uint3_t cell_resel_hyst,
84 uint5_t ms_txpwr_max_cch,
85 boolean acs,
86 boolean neci,
87 uint6_t rxlev_access_min
88 } with { variant "" };
89
90 /* 44.018 10.5.2.5 */
91 type record ChannelDescription {
92 OCT1 iei,
93 BIT5 chan_type_tdma_offset,
94 uint3_t tn,
95 uint3_t tsc,
96 boolean h,
97 uint12_t arfcn optional,
98 MaioHsn maio_hsn optional
99 } with { variant (arfcn) "PRESENCE(h = true)"
100 variant (maio_hsn) "PRESENCE(h = false)" };
101
102 /* 44.018 10.5.2.11 */
103 type record ControlChannelDescription {
104 boolean mscrr,
105 boolean att,
106 uint3_t bs_ag_blks_res,
107 uint3_t ccch_conf,
108 boolean si22ind,
109 uint2_t cbq3,
110 BIT2 spare,
111 uint3_t bs_pa_mfrms,
112 uint8_t t3212
113 } with { variant "" };
114
115 /* 44.018 10.5.2.21 */
116 type record MobileAllocation {
117 OCT1 iei,
118 uint8_t len,
119 bitstring ma
120 } with { variant "" };
121
122 /* 44.018 10.5.2.22 */
123 type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
124
125 /* 44.018 10.5.2.22a */
126 type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
127
128 type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
129
130 /* 44.018 10.5.2.29 */
131 type record RachControlParameters {
132 BIT2 max_retrans,
133 BIT4 tx_integer,
134 boolean cell_barr_access,
135 boolean re,
136 AccessControlClass ac
137 } with { variant (ac) "FIELDLENGTH(16)" };
138
139 /* 44.018 10.5.2.32 */
140 type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" };
141 type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" };
142
143 /* 44.018 9.1.31 */
144 type record SystemInformationType1 {
145 SystemInformationHeader header,
146 CellChannelDescription cell_chan_desc,
147 RachControlParameters rach_control,
148 Si1RestOctets rest_octets
149 } with { variant "" };
150
151 /* 44.018 9.1.32 */
152 type record SystemInformationType2 {
153 SystemInformationHeader header,
154 NeighbourCellDescription bcch_freq_list,
155 BIT8 ncc_permitted,
156 RachControlParameters rach_control
157 } with { variant "" };
158
159 /* 44.018 9.1.33 */
160 type record SystemInformationType2bis {
161 SystemInformationHeader header,
162 NeighbourCellDescription extd_bcch_freq_list,
163 RachControlParameters rach_control,
164 OCT1 rest_octets
165 } with { variant "" };
166
167 /* 44.018 9.1.34 */
168 type record SystemInformationType2ter {
169 SystemInformationHeader header,
170 NeighbourCellDescription2 extd_bcch_freq_list,
171 RachControlParameters rach_control,
172 OCT4 rest_octets
173 } with { variant "" };
174
175 /* 44.018 9.1.35 */
176 type record SystemInformationType3 {
177 SystemInformationHeader header,
178 CellIdentity cell_id,
179 LocationAreaIdentification lai,
180 ControlChannelDescription ctrl_chan_desc,
181 CellOptions cell_options,
182 CellSelectionParameters cell_sel_par,
183 RachControlParameters rach_control,
184 Si3RestOctets rest_octets
185 } with { variant "" };
186
187 /* 44.018 9.1.36 */
188 type record SystemInformationType4 {
189 SystemInformationHeader header,
190 LocationAreaIdentification lai,
191 CellSelectionParameters cell_sel_par,
192 RachControlParameters rach_control,
193 ChannelDescription cbch_chan_desc optional,
194 MobileAllocation cbch_mobile_alloc optional,
195 RestOctets rest_octets
196 } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
197
198 /* 44.018 9.1.37 */
199 type record SystemInformationType5 {
200 SystemInformationHeader header,
201 NeighbourCellDescription bcch_freq_list
202 } with { variant "" };
203
204 /* 44.018 9.1.38 */
205 type record SystemInformationType5bis {
206 SystemInformationHeader header,
207 NeighbourCellDescription extd_bcch_freq_list
208 } with { variant "" };
209
210 /* 44.018 9.1.39 */
211 type record SystemInformationType5ter {
212 SystemInformationHeader header,
213 NeighbourCellDescription2 extd_bcch_freq_list
214 } with { variant "" };
215
216 /* 44.018 9.1.40 */
217 type record SystemInformationType6 {
218 SystemInformationHeader header,
219 CellIdentity cell_id,
220 LocationAreaIdentification lai,
221 CellOptionsSacch cell_options,
222 BIT8 ncc_permitted,
223 OCT7 rest_octets
224 } with { variant "" };
225
226
227 type union SystemInformation {
228 SystemInformationType1 si1,
229 SystemInformationType2 si2,
230 SystemInformationType2bis si2bis,
231 SystemInformationType2ter si2ter,
232 SystemInformationType3 si3,
233 SystemInformationType4 si4,
234 SystemInformationType5 si5,
235 SystemInformationType5bis si5bis,
236 SystemInformationType5ter si5ter,
237 SystemInformationType6 si6
Harald Weltea082a692017-07-15 15:58:13 +0200238 } with { variant "TAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
239 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
240 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
241 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
242 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
243 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
244 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
245 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
246 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
247 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
Harald Welte56db5fd2017-07-14 18:25:59 +0200248 )" };
249
250 external function enc_SystemInformation(in SystemInformation si) return octetstring
251 with { extension "prototype(convert) encode(RAW)" };
252 external function dec_SystemInformation(in octetstring stream) return SystemInformation
253 with { extension "prototype(convert) decode(RAW)" };
254
255} with { encode "RAW"; variant "FIELDORDER(msb)" }