blob: 55548c6d4a4022e71c92bb801a6fd6dc47276a4f [file] [log] [blame]
Harald Weltea082a692017-07-15 15:58:13 +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_Types {
7
8 import from General_Types all;
9 import from Osmocom_Types all;
10
Harald Weltebdc5dbd2017-07-16 00:00:43 +020011 type integer GsmArfcn (0..1023);
12 type integer UmtsArfcn (0..16383);
13 type integer UmtsScramblingCode (0..511);
Harald Welted2e342f2017-07-16 07:34:13 +020014 const integer GsmMaxFrameNumber := 26*51*2048;
15 type integer GsmFrameNumber (0..GsmMaxFrameNumber);
16 type integer GsmRxLev (0..63);
17 type integer GsmTsc (0..7) with { variant "FIELDLENGTH(8)" };
18 type uint32_t GsmTmsi;
Harald Weltebdc5dbd2017-07-16 00:00:43 +020019
Harald Weltea082a692017-07-15 15:58:13 +020020 /* Table 10.4.1 of Section 10.4 / 3GPP TS 44.018 */
21 type enumerated RrMessageType {
22 ADDITIONAL_ASSIGNMENT ('00111011'B),
23 IMMEDIATE_ASSIGNMENT ('00111111'B),
24 IMMEDIATE_ASSIGNMENT_EXTENDED ('00111001'B),
25 IMMEDIATE_ASSIGNMENT_REJECT ('00111010'B),
26 IMMEDIATE_PACKET_ASSIGNMENT ('01101001'B),
27
28 CIPHERING_MODE_COMMAND ('00110101'B),
29 CIPHERING_MODE_COMPLETE ('00110010'B),
30
31 CONFIGURATION_CHANGE_COMMAND ('00110000'B),
32 CONFIGURATION_CHANGE_ACK ('00110001'B),
33 CONFIGURATION_CHANGE_REJECT ('00110011'B),
34
35 ASSIGNMENT_COMMAND ('00101110'B),
36 ASSIGNMENT_COMPLETE ('00101001'B),
37 ASSIGNMENT_FAILURE ('00101111'B),
38 HANDOVER_COMMAND ('00101011'B),
39 HANDOVER_COMPLETE ('00101100'B),
40 HANDOVER_FAILURE ('00101000'B),
41 PHYSICAL_INFORMATION ('00101101'B),
42
43 CHANNEL_RELEASE ('00001101'B),
44 PARTIAL_RELEASE ('00001010'B),
45 PARTIAL_RELEASE_COMPLETE ('00001111'B),
46
47 PAGING_REQUEST_TYPE_1 ('00100001'B),
48 PAGING_REQUEST_TYPE_2 ('00100010'B),
49 PAGING_REQUEST_TYPE_3 ('00100100'B),
50 PAGING_RESPONSE ('00100111'B),
51 NOTIFICATION_NCH ('00100000'B),
52 NOTIFICATION_RESPOSNE ('00100110'B),
53
54 SYSTEM_INFORMATION_TYPE_8 ('00011000'B),
55 SYSTEM_INFORMATION_TYPE_1 ('00011001'B),
56 SYSTEM_INFORMATION_TYPE_2 ('00011010'B),
57 SYSTEM_INFORMATION_TYPE_3 ('00011011'B),
58 SYSTEM_INFORMATION_TYPE_4 ('00011100'B),
59 SYSTEM_INFORMATION_TYPE_5 ('00011101'B),
60 SYSTEM_INFORMATION_TYPE_6 ('00011110'B),
61 SYSTEM_INFORMATION_TYPE_7 ('00011111'B),
62 SYSTEM_INFORMATION_TYPE_2bis ('00000010'B),
63 SYSTEM_INFORMATION_TYPE_2ter ('00000011'B),
64 SYSTEM_INFORMATION_TYPE_2quater ('00000111'B),
65 SYSTEM_INFORMATION_TYPE_5bis ('00000101'B),
66 SYSTEM_INFORMATION_TYPE_5ter ('00000110'B),
67 SYSTEM_INFORMATION_TYPE_9 ('00000100'B),
68 SYSTEM_INFORMATION_TYPE_13 ('00000000'B),
69
70 SYSTEM_INFORMATION_TYPE_16 ('00111101'B),
71 SYSTEM_INFORMATION_TYPE_17 ('00111110'B),
72
73 CHANNEL_MODE_MODIFY ('00010000'B),
74 RR_STATUS ('00010010'B),
75 CHANNEL_MODE_MODIFY_ACKNOWLEDGE ('00010111'B),
76 FREQUENCY_REDEFINITION ('00010100'B),
77 MEASUREMENT_REPORT ('00010101'B),
78 CLASSMARK_CHANGE ('00010110'B),
79 CLASSMARK_ENQUIRY ('00010011'B),
80 EXTENDED_MEASUREMENT_REPORT ('00110110'B),
81 EXTENDED_MEASUREMENT_ORDER ('00110111'B),
82 GPRS_SUSPENSION_REQUEST ('00110100'B),
83 //MBMS_ANNOUNCEMENT ('00010110'B), duplicate?
84 //SERVICE_INFORMATION ('00110110'B), duplicate?
85
86 APPLICATION_INFORMATION ('00111000'B),
87
88 SYSTEM_INFORMATION_TYPE_14 ('00000001'B),
89 SYSTEM_INFORMATION_TYPE_15 ('01000011'B),
90 SYSTEM_INFORMATION_TYPE_18 ('01000000'B),
91 SYSTEM_INFORMATION_TYPE_19 ('01000001'B),
92 SYSTEM_INFORMATION_TYPE_20 ('01000010'B),
93 SYSTEM_INFORMATION_TYPE_13alt ('01000100'B),
94 SYSTEM_INFORMATION_TYPE_2n ('01000101'B),
95 SYSTEM_INFORMATION_TYPE_21 ('01000110'B),
96 SYSTEM_INFORMATION_TYPE_22 ('01000111'B),
97 SYSTEM_INFORMATION_TYPE_23 ('01001111'B),
98
99 DTM_ASSIGNMENT_FAILURE ('01001000'B),
100 DTM_REJECT ('01001001'B),
101 DTM_REQUEST ('01001010'B),
102 PACKET_ASSIGNMENT ('01001011'B),
103 DTM_ASSIGNMENT_COMMAND ('01001100'B),
104 DTM_INFORMATION ('01001101'B),
105 PACKET_INFORMATION ('01001110'B),
106
107 UTRAN_CLASSMARK_CHANGE ('01100000'B),
108 CDMA2000_CLASSMARK_CHANGE ('01100010'B),
109 INTERSYS_TO_UTRAN_HO_CMD ('01100011'B),
110 INTERSYS_TO_CDMA2000_HO_CMD ('01100100'B),
111 GERAN_IU_MODE_CLASSMARK_CHG ('01100101'B),
112 INTERSYS_TO_EUTRAN_HO_CMD ('01100110'B)
113 } with { variant "FIELDLENGTH(8)" };
114
Harald Welted2e342f2017-07-16 07:34:13 +0200115 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
116 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
117 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
118
119 type record L2PseudoLength {
120 uint6_t l2_plen,
121 BIT2 zero_one
122 } with { variant "" };
123
124 template L2PseudoLength t_L2Pseudolength(template uint6_t len) := {
125 l2_plen := len,
126 zero_one := '01'B
127 };
128
129 type record RrHeader {
130 L2PseudoLength l2_plen,
131 uint4_t skip_indicator,
132 uint4_t rr_protocol_discriminator,
133 RrMessageType message_type
134 } with { variant "" };
135
136 template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := {
137 l2_plen := t_L2Pseudolength(len),
138 skip_indicator := 0,
139 rr_protocol_discriminator := 6,
140 message_type := msg_type
141 };
142
143 type record RrL3Header {
144 uint4_t skip_indicator,
145 uint4_t rr_protocol_discriminator,
146 RrMessageType message_type
147 } with { variant "" };
148
149 type record MaioHsn {
150 } with { variant "" };
151
152 /* TS 24.008 10.5.1.2 */
153 type uint4_t CipheringKeySeqNr (0..7);
154
155 /* 24.008 10.5.1.3 */
156 type record LocationAreaIdentification {
157 BcdMccMnc mcc_mnc,
158 uint16_t lac
159 } with { variant "" };
160
161 /* TS 24.008 10.5.1.4 */
162 type enumerated MobileIdentityType {
163 MI_TYPE_NONE (0),
164 MI_TYPE_IMSI,
165 MI_TYPE_IMEI,
166 MI_TYPE_IMEISV,
167 MI_TYPE_TMSI,
168 MI_TYPE_TMGI
169 } with { variant "FIELDLENGTH(3)" };
170
171 type record MobileIdentityBCD {
172 MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV),
173 boolean odd,
174 hexstring digits
175 } with { variant "" };
176
177 type record MobileIdentityTMSI {
178 MobileIdentityType mi_type (MI_TYPE_TMSI),
179 boolean odd (false),
180 BIT4 pad ('1111'B),
181 GsmTmsi tmsi
182 } with { variant "" };
183
184 type union MobileIdentity {
185 MobileIdentityBCD bcd,
186 MobileIdentityTMSI tmsi
187 } with { variant "TAG(bcd, mi_type = MI_TYPE_IMSI;
188 bcd, mi_type = MI_TYPE_IMEI;
189 bcd, mi_type = MI_TYPE_IMEISV;
190 tmsi, mi_type = MI_TYPE_TMSI)" };
191
192 type record MobileIdentityLV {
193 uint8_t len,
194 MobileIdentity mi
195 } with { variant (len) "LENGTHTO(mi)" };
196
197 type record MobileIdentityTLV {
198 uint8_t tag,
199 uint8_t len,
200 MobileIdentity mi
201 } with { variant (len) "LENGTHTO(mi)" };
202
203 /* TS 24.008 10.5.1.5 */
204 type record MsClassmark1 {
205 BIT1 spare,
206 uint2_t rev_level,
207 boolean es_ind,
208 boolean a51,
209 uint3_t rf_pwr_cap
210 } with { variant "" };
211
212 /* TS 24.008 10.5.1.6 */
213 type record MsClassmark2 {
214 BIT1 spare,
215 uint2_t rev_level,
216 boolean es_ind,
217 boolean a51,
218 uint3_t rf_pwr_cap,
219 BIT1 spare1,
220 boolean ps_cap,
221 uint2_t ss_screen_ind,
222 boolean sm_cap,
223 boolean vbs,
224 boolean vgcs,
225 boolean fc,
226 boolean cm3,
227 BIT1 spare2,
228 boolean lcsva_cap,
229 boolean ucs2,
230 boolean solsa,
231 boolean cmsp,
232 boolean a53,
233 boolean a52
234 } with { variant "" };
235 type record MsClassmark2LV {
236 uint8_t len,
237 MsClassmark2 cm2
238 } with { variant (len) "LENGTHTO(cm2)" };
239
240
241
242
243 /* 44.018 10.5.2.5 */
244 type record ChannelDescription {
245 OCT1 iei,
246 BIT5 chan_type_tdma_offset,
247 uint3_t tn,
248 uint3_t tsc,
249 boolean h,
250 uint12_t arfcn optional,
251 MaioHsn maio_hsn optional
252 } with { variant (arfcn) "PRESENCE(h = true)"
253 variant (maio_hsn) "PRESENCE(h = false)" };
254
255 /* 10.5.2.8 */
256 type enumerated ChannelNeeded {
257 CHAN_NEED_ANY (0),
258 CHAN_NEED_SDCCH (1),
259 CHAN_NEED_TCH_F (2),
260 CHAN_NEED_TCH_H (3)
261 } with { variant "FIELDLENGTH(2)" };
262 type record ChannelNeeded12 {
263 ChannelNeeded second,
264 ChannelNeeded first
265 } with { variant "" };
266
267 /* 10.5.2.21 */
268 type record MobileAllocation {
269 uint8_t len,
270 bitstring ma
271 } with { variant (len) "LENGTHTO(ma)" };
272
273 /* 10.5.2.25a */
274 type OCT3 PacketChannelDescription;
275
276 /* 10.5.2.25b */
277 type record DedicatedModeOrTbf {
278 BIT1 spare,
279 boolean tma,
280 boolean downlink,
281 boolean tbf
282 } with { variant "" };
283
284 /* 10.5.2.26 */
285 type enumerated PageMode {
286 PAGE_MODE_NORMAL,
287 PAGE_MODE_EXTENDED,
288 PAGE_MODE_REORGANIZATION,
289 PAGE_MODE_SAME_AS_BEFORE
290 } with { variant "FIELDLENGTH(4)" };
291
292 /* 10.5.2.30 */
293 type record RequestReference {
294 bitstring ra length(8),
295 uint5_t t1p,
296 uint6_t t3,
297 uint5_t t1
298 } with { variant "" };
299
300 /* 10.5.2.40 */
301 type integer TimingAdvance (0..219);
302
303 /* 10.5.2.43 */
304 type uint8_t WaitIndication;
305
306 /* 10.5.2.76 */
307 type record FeatureIndicator {
308 BIT2 spare,
309 boolean cs_ir,
310 boolean ps_ir
311 } with { variant "" };
312
313
314 /* 9.1.18 */
315 type record ImmediateAssignment {
316 DedicatedModeOrTbf ded_or_tbf,
317 PageMode page_mode,
318 ChannelDescription chan_desc optional,
319 PacketChannelDescription pkt_chan_desc optional,
320 RequestReference req_ref,
321 TimingAdvance timing_advance,
322 MobileAllocation mobile_allocation
323 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
324 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
325
326 /* 9.1.20 */
327 type record ReqRefWaitInd {
328 RequestReference req_ref,
329 WaitIndication wait_ind
330 } with { variant "" };
331 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
332 type record ImmediateAssignmentReject {
333 FeatureIndicator feature_ind,
334 PageMode page_mode,
335 ReqRefWaitInd4 payload
336 } with { variant "" };
337
338 /* 9.1.22 */
339 type record PagingRequestType1 {
340 ChannelNeeded12 chan_needed,
341 PageMode page_mode,
342 MobileIdentityLV mi1,
343 MobileIdentityTLV mi2 optional,
344 RestOctets rest_octets
345 } with { variant "TAG(mi2, tag = 23)" };
346
347 /* 9.1.23 */
348 type record PagingRequestType2 {
349 ChannelNeeded12 chan_needed,
350 PageMode page_mode,
351 GsmTmsi mi1,
352 GsmTmsi mi2,
353 MobileIdentityTLV mi3 optional,
354 RestOctets rest_octets
355 } with { variant "TAG(mi3, tag = 23)" };
356
357 /* 9.1.24 */
358 type record length(4) of GsmTmsi GsmTmsi4;
359 type record PagingRequestType3 {
360 ChannelNeeded12 chan_needed,
361 PageMode page_mode,
362 GsmTmsi4 mi,
363 RestOctets rest_octets
364 } with { variant "" };
365
366
367 type union RrUnion {
368/*
369 SystemInformationType1 si1,
370 SystemInformationType2 si2,
371 SystemInformationType2bis si2bis,
372 SystemInformationType2ter si2ter,
373 SystemInformationType3 si3,
374 SystemInformationType4 si4,
375 SystemInformationType5 si5,
376 SystemInformationType5bis si5bis,
377 SystemInformationType5ter si5ter,
378 SystemInformationType6 si6,
379*/
380 ImmediateAssignment imm_ass,
381 ImmediateAssignmentReject imm_ass_rej,
382 PagingRequestType1 pag_req_1,
383 PagingRequestType2 pag_req_2,
384 PagingRequestType3 pag_req_3,
385 octetstring other
386 } with { variant "" };
387
388 /* Special RR Message on BCCH / CCCH Dowlink */
389
390 type record GsmRrMessage {
391 RrHeader header,
392 RrUnion payload
393 } with { variant (payload) "CROSSTAG(
394/*
395 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
396 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
397 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
398 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
399 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
400 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
401 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
402 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
403 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
404 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
405*/
406 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
407 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
408 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
409 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
410 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
411 other, OTHERWISE;
412 )" };
413
414 /* Normal L3 Message on Dedicated Channel */
415
416 /* 9.1.25 Paging Response */
417 type record PagingResponse {
418 uint4_t spare_half_octet,
419 CipheringKeySeqNr cksn,
420 MsClassmark2LV cm2,
421 MobileIdentityLV mi,
422 uint8_t addl_upd_par optional
423 } with { variant "" };
424
425 type union RrL3Union {
426 PagingResponse paging_response,
427 octetstring other
428 };
429
430 type record GsmRrL3Message {
431 RrL3Header header,
432 RrL3Union payload
433 } with { variant (payload) "CROSSTAG(
434 paging_response, header.message_type = PAGING_RESPONSE;
435
436 other, OTHERWISE;
437 )" }
438
439
Harald Weltea082a692017-07-15 15:58:13 +0200440} with { encode "RAW"; variant "FIELDORDER(msb)" }