blob: 2ceb1f81ad27adabb14b802da8d9180d4f41bb93 [file] [log] [blame]
Harald Welte9419c8a2017-07-30 04:07:05 +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_RR_Types {
7
8 import from General_Types all;
9 import from Osmocom_Types all;
10 import from GSM_Types all;
11 import from RLCMAC_CSN1_Types all;
12
13 /* Table 10.4.1 of Section 10.4 / 3GPP TS 44.018 */
14 type enumerated RrMessageType {
15 ADDITIONAL_ASSIGNMENT ('00111011'B),
16 IMMEDIATE_ASSIGNMENT ('00111111'B),
17 IMMEDIATE_ASSIGNMENT_EXTENDED ('00111001'B),
18 IMMEDIATE_ASSIGNMENT_REJECT ('00111010'B),
19 IMMEDIATE_PACKET_ASSIGNMENT ('01101001'B),
20
21 CIPHERING_MODE_COMMAND ('00110101'B),
22 CIPHERING_MODE_COMPLETE ('00110010'B),
23
24 CONFIGURATION_CHANGE_COMMAND ('00110000'B),
25 CONFIGURATION_CHANGE_ACK ('00110001'B),
26 CONFIGURATION_CHANGE_REJECT ('00110011'B),
27
28 ASSIGNMENT_COMMAND ('00101110'B),
29 ASSIGNMENT_COMPLETE ('00101001'B),
30 ASSIGNMENT_FAILURE ('00101111'B),
31 HANDOVER_COMMAND ('00101011'B),
32 HANDOVER_COMPLETE ('00101100'B),
33 HANDOVER_FAILURE ('00101000'B),
34 PHYSICAL_INFORMATION ('00101101'B),
35
36 CHANNEL_RELEASE ('00001101'B),
37 PARTIAL_RELEASE ('00001010'B),
38 PARTIAL_RELEASE_COMPLETE ('00001111'B),
39
40 PAGING_REQUEST_TYPE_1 ('00100001'B),
41 PAGING_REQUEST_TYPE_2 ('00100010'B),
42 PAGING_REQUEST_TYPE_3 ('00100100'B),
43 PAGING_RESPONSE ('00100111'B),
44 NOTIFICATION_NCH ('00100000'B),
45 NOTIFICATION_RESPOSNE ('00100110'B),
46
47 SYSTEM_INFORMATION_TYPE_8 ('00011000'B),
48 SYSTEM_INFORMATION_TYPE_1 ('00011001'B),
49 SYSTEM_INFORMATION_TYPE_2 ('00011010'B),
50 SYSTEM_INFORMATION_TYPE_3 ('00011011'B),
51 SYSTEM_INFORMATION_TYPE_4 ('00011100'B),
52 SYSTEM_INFORMATION_TYPE_5 ('00011101'B),
53 SYSTEM_INFORMATION_TYPE_6 ('00011110'B),
54 SYSTEM_INFORMATION_TYPE_7 ('00011111'B),
55 SYSTEM_INFORMATION_TYPE_2bis ('00000010'B),
56 SYSTEM_INFORMATION_TYPE_2ter ('00000011'B),
57 SYSTEM_INFORMATION_TYPE_2quater ('00000111'B),
58 SYSTEM_INFORMATION_TYPE_5bis ('00000101'B),
59 SYSTEM_INFORMATION_TYPE_5ter ('00000110'B),
60 SYSTEM_INFORMATION_TYPE_9 ('00000100'B),
61 SYSTEM_INFORMATION_TYPE_13 ('00000000'B),
62
63 SYSTEM_INFORMATION_TYPE_16 ('00111101'B),
64 SYSTEM_INFORMATION_TYPE_17 ('00111110'B),
65
66 CHANNEL_MODE_MODIFY ('00010000'B),
67 RR_STATUS ('00010010'B),
68 CHANNEL_MODE_MODIFY_ACKNOWLEDGE ('00010111'B),
69 FREQUENCY_REDEFINITION ('00010100'B),
70 MEASUREMENT_REPORT ('00010101'B),
71 CLASSMARK_CHANGE ('00010110'B),
72 CLASSMARK_ENQUIRY ('00010011'B),
73 EXTENDED_MEASUREMENT_REPORT ('00110110'B),
74 EXTENDED_MEASUREMENT_ORDER ('00110111'B),
75 GPRS_SUSPENSION_REQUEST ('00110100'B),
76 //MBMS_ANNOUNCEMENT ('00010110'B), duplicate?
77 //SERVICE_INFORMATION ('00110110'B), duplicate?
78
79 APPLICATION_INFORMATION ('00111000'B),
80
81 SYSTEM_INFORMATION_TYPE_14 ('00000001'B),
82 SYSTEM_INFORMATION_TYPE_15 ('01000011'B),
83 SYSTEM_INFORMATION_TYPE_18 ('01000000'B),
84 SYSTEM_INFORMATION_TYPE_19 ('01000001'B),
85 SYSTEM_INFORMATION_TYPE_20 ('01000010'B),
86 SYSTEM_INFORMATION_TYPE_13alt ('01000100'B),
87 SYSTEM_INFORMATION_TYPE_2n ('01000101'B),
88 SYSTEM_INFORMATION_TYPE_21 ('01000110'B),
89 SYSTEM_INFORMATION_TYPE_22 ('01000111'B),
90 SYSTEM_INFORMATION_TYPE_23 ('01001111'B),
91
92 DTM_ASSIGNMENT_FAILURE ('01001000'B),
93 DTM_REJECT ('01001001'B),
94 DTM_REQUEST ('01001010'B),
95 PACKET_ASSIGNMENT ('01001011'B),
96 DTM_ASSIGNMENT_COMMAND ('01001100'B),
97 DTM_INFORMATION ('01001101'B),
98 PACKET_INFORMATION ('01001110'B),
99
100 UTRAN_CLASSMARK_CHANGE ('01100000'B),
101 CDMA2000_CLASSMARK_CHANGE ('01100010'B),
102 INTERSYS_TO_UTRAN_HO_CMD ('01100011'B),
103 INTERSYS_TO_CDMA2000_HO_CMD ('01100100'B),
104 GERAN_IU_MODE_CLASSMARK_CHG ('01100101'B),
105 INTERSYS_TO_EUTRAN_HO_CMD ('01100110'B)
106 } with { variant "FIELDLENGTH(8)" };
107
108 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
109 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
110 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
111
112 type record L2PseudoLength {
113 uint6_t l2_plen,
114 BIT2 zero_one
115 } with { variant "" };
116
Harald Weltef8df4cb2018-03-10 15:15:08 +0100117 template L2PseudoLength tr_L2Pseudolength(template uint6_t len) := {
118 l2_plen := len,
119 zero_one := '01'B
120 };
121
122 template (value) L2PseudoLength ts_L2Pseudolength(uint6_t len) := {
Harald Welte9419c8a2017-07-30 04:07:05 +0200123 l2_plen := len,
124 zero_one := '01'B
125 };
126
127 type record RrHeader {
128 L2PseudoLength l2_plen,
129 uint4_t skip_indicator,
130 uint4_t rr_protocol_discriminator,
131 RrMessageType message_type
132 } with { variant "" };
133
134 template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100135 l2_plen := tr_L2Pseudolength(len),
Harald Welte9419c8a2017-07-30 04:07:05 +0200136 skip_indicator := 0,
137 rr_protocol_discriminator := 6,
138 message_type := msg_type
139 };
140
Harald Weltef8df4cb2018-03-10 15:15:08 +0100141 template (value) RrHeader ts_RrHeader(RrMessageType msg_type, uint6_t len) := {
142 l2_plen := ts_L2Pseudolength(len),
143 skip_indicator := 0,
144 rr_protocol_discriminator := 6,
145 message_type := msg_type
146 };
147
148
Harald Welte9419c8a2017-07-30 04:07:05 +0200149 type record RrL3Header {
150 uint4_t skip_indicator,
151 uint4_t rr_protocol_discriminator,
152 RrMessageType message_type
153 } with { variant "" };
154
Harald Weltecbc947f2018-02-22 00:26:55 +0100155 template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
156 skip_indicator := 0,
157 rr_protocol_discriminator := 6,
158 message_type := msg_type
159 }
160
Harald Welte9419c8a2017-07-30 04:07:05 +0200161 type record MaioHsn {
162 } with { variant "" };
163
164 /* TS 24.008 10.5.1.1 */
165 type uint16_t CellIdentity;
166
167 /* TS 24.008 10.5.1.2 */
168 type uint4_t CipheringKeySeqNr (0..7);
169
170 /* 24.008 10.5.1.3 */
171 type record LocationAreaIdentification {
172 BcdMccMnc mcc_mnc,
173 uint16_t lac
174 } with { variant "" };
175
176 /* TS 24.008 10.5.1.4 */
177 type enumerated MobileIdentityType {
178 MI_TYPE_NONE (0),
179 MI_TYPE_IMSI,
180 MI_TYPE_IMEI,
181 MI_TYPE_IMEISV,
182 MI_TYPE_TMSI,
183 MI_TYPE_TMGI
184 } with { variant "FIELDLENGTH(3)" };
185
186 type record MobileIdentityBCD {
187 MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV),
188 boolean odd,
189 hexstring digits
190 } with { variant "FIELDORDER(lsb)" };
191
192 type record MobileIdentityTMSI {
193 BIT4 pad ('1111'B),
194 boolean odd (false),
195 MobileIdentityType mi_type (MI_TYPE_TMSI),
196 GsmTmsi tmsi
197 } with { variant "FIELDORDER(lsb)" };
198
199 type record MobileIdentityNone {
200 BIT4 pad ('1111'B),
201 boolean odd (false),
202 MobileIdentityType mi_type (MI_TYPE_NONE)
203 } with { variant "FIELDORDER(lsb)" };
204
205 type union MobileIdentity {
206 MobileIdentityBCD imsi,
207 MobileIdentityBCD imei,
208 MobileIdentityBCD imeisv,
209 MobileIdentityTMSI tmsi,
210 MobileIdentityNone unused
211 } with { variant "TAG(imsi, mi_type = MI_TYPE_IMSI;
212 imei, mi_type = MI_TYPE_IMEI;
213 imeisv, mi_type = MI_TYPE_IMEISV;
214 tmsi, mi_type = MI_TYPE_TMSI;
215 unused, mi_type = MI_TYPE_NONE)"
216 variant "FIELDORDER(lsb)"
217 };
218
219 type record MobileIdentityLV {
220 uint8_t len,
221 MobileIdentity mi
222 } with { variant (len) "LENGTHTO(mi)" };
223
224 type record MobileIdentityTLV {
225 uint8_t tag,
226 uint8_t len,
227 MobileIdentity mi
228 } with { variant (len) "LENGTHTO(mi)" };
229
230 /* TS 24.008 10.5.1.5 */
231 type record MsClassmark1 {
232 BIT1 spare,
233 uint2_t rev_level,
234 boolean es_ind,
235 boolean a51,
236 uint3_t rf_pwr_cap
237 } with { variant "" };
238
239 /* TS 24.008 10.5.1.6 */
240 type record MsClassmark2 {
241 BIT1 spare,
242 uint2_t rev_level,
243 boolean es_ind,
244 boolean a51,
245 uint3_t rf_pwr_cap,
246 BIT1 spare1,
247 boolean ps_cap,
248 uint2_t ss_screen_ind,
249 boolean sm_cap,
250 boolean vbs,
251 boolean vgcs,
252 boolean fc,
253 boolean cm3,
254 BIT1 spare2,
255 boolean lcsva_cap,
256 boolean ucs2,
257 boolean solsa,
258 boolean cmsp,
259 boolean a53,
260 boolean a52
261 } with { variant "" };
262 type record MsClassmark2LV {
263 uint8_t len,
264 MsClassmark2 cm2
265 } with { variant (len) "LENGTHTO(cm2)" };
266
267
268 /* 44.018 10.5.2.5 */
269 type record ChannelDescription {
270 RslChannelNr chan_nr,
271 uint3_t tsc,
272 boolean h,
273 uint12_t arfcn optional,
274 MaioHsn maio_hsn optional
275 } with { variant (arfcn) "PRESENCE(h = false)"
276 variant (maio_hsn) "PRESENCE(h = true)" };
277
278 type record ChannelDescriptionTV {
279 OCT1 iei,
280 ChannelDescription v
281 } with { variant "" };
282
283 /* 10.5.2.21 */
284 type record MobileAllocation {
285 uint8_t len,
286 bitstring ma
287 } with { variant (len) "LENGTHTO(ma)" };
288
289 /* 10.5.2.25a */
Harald Welte1b9b7702017-07-30 04:19:14 +0200290 type record PktChDesc0Ind {
291 uint6_t maio,
292 BIT1 ma_number_ind,
293 BIT1 change_mark1_valid,
294 BIT2 change_mark1
295 } with { variant "" };
296 type record PktChDesc0 {
297 BIT1 hopping,
298 BIT1 spare ('0'B),
299 uint10_t arfcn optional,
300 PktChDesc0Ind indirect optional
301 } with {
302 variant (arfcn) "PRESENCE(hopping = '0'B)"
303 variant (indirect) "PRESENCE(hopping = '1'B)"
304 };
305 type record PktChDesc1 {
306 uint6_t maio,
307 uint6_t hsn
308 } with { variant "" };
309 type record PacketChannelDescription {
310 uint5_t channel_Type_spare,
311 uint3_t tn,
312 uint3_t tsc,
313 BIT1 presence,
314 PktChDesc0 zero optional,
315 PktChDesc1 one optional
316 } with {
317 variant (zero) "PRESENCE(presence = '0'B)"
318 variant (one) "PRESENCE(presence = '1'B)"
319 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200320
321 /* 10.5.2.25b */
322 type record DedicatedModeOrTbf {
323 BIT1 spare,
324 boolean tma,
325 boolean downlink,
326 boolean tbf
327 } with { variant "" };
328
329 /* 10.5.2.26 */
330 type enumerated PageMode {
331 PAGE_MODE_NORMAL,
332 PAGE_MODE_EXTENDED,
333 PAGE_MODE_REORGANIZATION,
334 PAGE_MODE_SAME_AS_BEFORE
335 } with { variant "FIELDLENGTH(4)" };
336
337 /* 10.5.2.30 */
338 type record RequestReference {
339 bitstring ra length(8),
340 uint5_t t1p,
341 uint6_t t3,
342 uint5_t t2
343 } with { variant "" };
344
345 template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := {
346 ra := ra,
347 t1p := t1p,
348 t3 := t3,
349 t2 := t2
350 }
351
352 /* compute the expected request reference for given RA + FN */
353 function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference {
354 var RequestReference req_ref := { ra := int2bit(ra, 8) };
355 req_ref.t1p := (fn / 1326) mod 32;
356 req_ref.t2 := fn mod 26;
357 req_ref.t3 := fn mod 51;
358 return req_ref
359 }
360
361 /* 10.5.2.40 */
362 type integer TimingAdvance (0..219);
363
364 /* 10.5.2.43 */
365 type uint8_t WaitIndication;
366
367 /* 10.5.2.76 */
368 type record FeatureIndicator {
369 BIT2 spare,
370 boolean cs_ir,
371 boolean ps_ir
372 } with { variant "" };
373
374 /* 24.008 10.5.5.6 */
375 type record DrxParameter {
376 uint8_t split_pg_cycle_code,
377 uint4_t drx_cycle_len_coeff,
378 boolean split_on_ccch,
379 uint3_t non_drx_timer
380 } with { variant "" };
381
382 /* 24.008 10.5.5.15 */
383 type record RoutingAreaIdentification {
384 LocationAreaIdentification lai,
385 uint8_t rac
386 } with { variant "" };
387
388 /* 44.018 10.5.2.16 */
389 type record IaRestOctHL {
390 uint6_t freq_par_len,
391 BIT2 padding ('00'B) optional,
392 uint6_t maio optional,
393 octetstring mobile_allocation optional
394 } with {
395 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
396/*
397 variant (padding) "PRESENCE(freq_par_len != 0)"
398 variant (maio) "PRESENCE(freq_par_len != 0)"
399 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
400*/
401 };
402 type record IaRestOctHH {
403 BIT2 presence,
404 PacketUlAssign ul optional,
405 PacketDlAssign dl optional
406 } with {
407 variant (ul) "PRESENCE(presence = '00'B)"
408 variant (dl) "PRESENCE(presence = '01'B)"
409 };
410 type record PacketUlAssignDyn {
411 uint5_t tfi_assignment,
412 BIT1 polling,
413 BIT1 spare ('0'B),
414 uint3_t usf,
415 BIT1 usf_granularity,
416 BIT1 p0_present,
417 uint4_t p0 optional,
418 BIT1 pr_mode optional,
419 ChCodingCommand ch_coding_cmd,
420 BIT1 tlli_block_chan_coding,
421 BIT1 alpha_present,
422 uint4_t alpha optional,
423 uint5_t gamma,
424 BIT1 ta_index_present,
425 uint4_t ta_index optional,
426 BIT1 tbf_starting_time_present,
427 uint16_t tbf_starting_time optional
428 } with {
429 variant (p0) "PRESENCE(p0_present = '1'B)"
430 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
431 variant (alpha) "PRESENCE(alpha_present = '1'B)"
432 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
433 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
434 };
435 type record PacketUlAssignSgl {
436 BIT1 alpha_present,
437 uint4_t alpha optional,
438 uint5_t gamma,
439 BIT2 padding ('01'B),
440 uint16_t tbf_starting_time
441 /* TODO: P0 / PR_MODE */
442 } with {
443 variant (alpha) "PRESENCE(alpha_present = '1'B)"
444 };
445 type record PacketUlAssign {
446 BIT1 presence,
447 PacketUlAssignDyn dynamic optional,
448 PacketUlAssignSgl single optional
449 /* TODO: Estended RA, PFI */
450 } with {
451 variant (dynamic) "PRESENCE(presence = '1'B)"
452 variant (single) "PRESENCE(presence = '0'B)"
453 };
454 type record PacketDlAssG1 {
455 uint5_t tfi_assignment,
456 BIT1 rlc_mode,
457 BIT1 alpha_present,
458 uint4_t alpha optional,
459 uint5_t gamma,
460 BIT1 polling,
461 BIT1 ta_valid
462 } with { variant "" };
463 type record PacketDlAssign {
464 GprsTlli tlli,
465 BIT1 group1_present,
466 PacketDlAssG1 group1 optional,
467 BIT1 ta_index_present,
468 uint4_t ta_index optional,
469 BIT1 tbf_starting_time_present,
470 uint16_t tbf_starting_time optional,
471 BIT1 p0_present,
472 uint4_t p0 optional,
473 BIT1 pr_mode optional
474 /* TODO: EGPRS window size, etc. */
475 } with {
476 variant (group1) "PRESENCE(group1_present = '1'B)"
477 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
478 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
479 variant (p0) "PRESENCE(p0_present = '1'B)"
480 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
481 };
482 type record IaRestOctLL {
483 BIT1 compressed_irat_ho_info_ind
484 } with { variant "" };
485 type octetstring EgprsUlAss; /* TODO */
486 type octetstring MblkDlAss; /* TODO */
487 type record IaRestOctLH {
488 BIT2 presence,
489 EgprsUlAss egprs_ul optional,
490 MblkDlAss multiblock_dl_ass optional
491 } with {
492 variant (egprs_ul) "PRESENCE(presence = '00'B)"
493 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
494 };
495 type record IaRestOctets {
496 BIT2 presence,
497 IaRestOctLL ll optional,
498 IaRestOctLH lh optional,
499 IaRestOctHL hl optional,
500 IaRestOctHH hh optional
501 } with {
502 variant (ll) "PRESENCE(presence = '00'B)"
503 variant (lh) "PRESENCE(presence = '01'B)"
504 variant (hl) "PRESENCE(presence = '10'B)"
505 variant (hh) "PRESENCE(presence = '11'B)"
506 };
507
Harald Weltecbc947f2018-02-22 00:26:55 +0100508 type record MeasurementResults {
509 BIT1 ba_used,
510 BIT1 dtx_used,
511 uint6_t rxlev_full_srv_cell,
512 BIT1 threeg_ba_used,
513 BIT1 meas_valid,
514 uint6_t rxlev_sub_srv_cell,
515 BIT1 si23_ba_used,
516 uint3_t rxqual_full_srv_cell,
517 uint3_t rxqual_sub_srv_cell,
518 uint3_t no_ncell_m,
519 NcellReports ncell_reports optional
520 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
521 variant (no_ncell_m) "UNIT(elements)"
522 variant "PADDING(yes)"
523 variant "FIELDLENGTH(16)"
524 };
525
526 type record NcellReport {
527 uint6_t rxlev,
528 uint5_t bcch_freq,
529 uint6_t bsic
530 } with { variant ""};
531 type record of NcellReport NcellReports;
532
Harald Welte9419c8a2017-07-30 04:07:05 +0200533
534 /* 9.1.18 */
535 type record ImmediateAssignment {
536 DedicatedModeOrTbf ded_or_tbf,
537 PageMode page_mode,
538 ChannelDescription chan_desc optional,
539 PacketChannelDescription pkt_chan_desc optional,
540 RequestReference req_ref,
541 TimingAdvance timing_advance,
542 MobileAllocation mobile_allocation,
543 /* TODO: starting time TLV */
Harald Weltecbc947f2018-02-22 00:26:55 +0100544 IaRestOctets rest_octets optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200545 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
546 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
547
548 /* 9.1.20 */
549 type record ReqRefWaitInd {
550 RequestReference req_ref,
551 WaitIndication wait_ind
552 } with { variant "" };
553 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
554 type record ImmediateAssignmentReject {
555 FeatureIndicator feature_ind,
556 PageMode page_mode,
557 ReqRefWaitInd4 payload
558 } with { variant "" };
559
Harald Weltecbc947f2018-02-22 00:26:55 +0100560 /* 9.1.21 */
561 type record MeasurementReport {
562 MeasurementResults meas_res
563 } with { variant "" };
564
Harald Welte9419c8a2017-07-30 04:07:05 +0200565 /* 9.1.22 */
566 type record PagingRequestType1 {
567 ChannelNeeded12 chan_needed,
568 PageMode page_mode,
569 MobileIdentityLV mi1,
570 MobileIdentityTLV mi2 optional,
571 RestOctets rest_octets
572 } with { variant "TAG(mi2, tag = 23)" };
573
574 /* 9.1.23 */
575 type record PagingRequestType2 {
576 ChannelNeeded12 chan_needed,
577 PageMode page_mode,
578 GsmTmsi mi1,
579 GsmTmsi mi2,
580 MobileIdentityTLV mi3 optional,
581 RestOctets rest_octets
582 } with { variant "TAG(mi3, tag = 23)" };
583
584 /* 9.1.24 */
585 type record length(4) of GsmTmsi GsmTmsi4;
586 type record PagingRequestType3 {
587 ChannelNeeded12 chan_needed,
588 PageMode page_mode,
589 GsmTmsi4 mi,
590 RestOctets rest_octets
591 } with { variant "" };
592
Harald Welte9419c8a2017-07-30 04:07:05 +0200593 type union RrUnion {
594/*
595 SystemInformationType1 si1,
596 SystemInformationType2 si2,
597 SystemInformationType2bis si2bis,
598 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100599 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200600 SystemInformationType4 si4,
601 SystemInformationType5 si5,
602 SystemInformationType5bis si5bis,
603 SystemInformationType5ter si5ter,
604 SystemInformationType6 si6,
605*/
606 ImmediateAssignment imm_ass,
607 ImmediateAssignmentReject imm_ass_rej,
608 PagingRequestType1 pag_req_1,
609 PagingRequestType2 pag_req_2,
610 PagingRequestType3 pag_req_3,
611 octetstring other
612 } with { variant "" };
613
614 /* Special RR Message on BCCH / CCCH Dowlink */
615
616 type record GsmRrMessage {
617 RrHeader header,
618 RrUnion payload
619 } with { variant (payload) "CROSSTAG(
620/*
621 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
622 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
623 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
624 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
625 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
626 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
627 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
628 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
629 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
630 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
631*/
632 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
633 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
634 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
635 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
636 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
637 other, OTHERWISE;
638 )" };
639
640 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
641 with { extension "prototype(convert) encode(RAW)" };
642 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
643 with { extension "prototype(convert) decode(RAW)" };
644
645 /* Normal L3 Message on Dedicated Channel */
646
647 /* 9.1.25 Paging Response */
648 type record PagingResponse {
649 uint4_t spare_half_octet,
650 CipheringKeySeqNr cksn,
651 MsClassmark2LV cm2,
652 MobileIdentityLV mi,
653 uint8_t addl_upd_par optional
654 } with { variant "" };
655
656 type union RrL3Union {
657 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100658 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200659 octetstring other
660 };
661
662 type record GsmRrL3Message {
663 RrL3Header header,
664 RrL3Union payload
665 } with { variant (payload) "CROSSTAG(
666 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100667 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200668 other, OTHERWISE;
669 )" }
670
Harald Weltecbc947f2018-02-22 00:26:55 +0100671 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
672 with { extension "prototype(convert) encode(RAW)" };
673 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
674 with { extension "prototype(convert) decode(RAW)" };
675
676
677 template GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
678 ChannelDescription ch_desc, MobileAllocation ma) := {
679 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
680 payload := {
681 imm_ass := {
682 ded_or_tbf := {
683 spare := '0'B,
684 tma := false,
685 downlink := false,
686 tbf := false
687 },
688 page_mode := PAGE_MODE_NORMAL,
689 chan_desc := ch_desc,
690 pkt_chan_desc := omit,
691 req_ref := f_compute_ReqRef(ra, fn),
692 timing_advance := ta,
693 mobile_allocation := ma,
694 rest_octets := omit
695 }
696 }
697 };
698
699 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
700 uint3_t rxq_f, uint3_t rxq_s,
701 template (omit) NcellReports reps) := {
702 header := t_RrL3Header(MEASUREMENT_REPORT),
703 payload := {
704 meas_rep := {
705 meas_res := {
706 ba_used := '0'B,
707 dtx_used := '0'B,
708 rxlev_full_srv_cell := rxl_f,
709 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +0100710 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +0100711 rxlev_sub_srv_cell := rxl_s,
712 si23_ba_used := '0'B,
713 rxqual_full_srv_cell := rxq_f,
714 rxqual_sub_srv_cell := rxq_s,
715 no_ncell_m := 0,
716 ncell_reports := reps
717 }
718 }
719 }
720 };
721
Harald Welteb669ee02018-03-09 12:50:02 +0100722 template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
723 ded_or_tbf := {
724 spare := ?,
725 tma := ?,
726 downlink := ?,
727 tbf := true
728 },
729 page_mode := ?,
730 chan_desc := omit,
731 pkt_chan_desc := {
732 channel_Type_spare := ?,
733 tn := ?,
734 tsc := ?,
735 presence := ?,
736 zero := *,
737 one := omit
738 },
739 req_ref := ?,
740 timing_advance := ?,
741 mobile_allocation := ?,
742 rest_octets := {
743 presence := '11'B,
744 ll := omit,
745 lh := omit,
746 hl := omit,
747 hh := {
748 presence := '01'B,
749 ul := omit,
750 dl := {
751 tlli := tlli,
752 group1_present := ?,
753 group1 := *,
754 ta_index_present := ?,
755 ta_index := *,
756 tbf_starting_time_present := ?,
757 tbf_starting_time := *,
758 p0_present := ?,
759 p0 := *,
760 pr_mode := *
761 }
762 }
763 }
764 };
765
766 template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
767 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
768 payload := {
769 imm_ass := t_IMM_ASS_TBF_DL(tlli)
770 }
771 };
772
Harald Weltecbc947f2018-02-22 00:26:55 +0100773
774
Harald Welte9419c8a2017-07-30 04:07:05 +0200775} with { encode "RAW" ; variant "FIELDORDER(msb)" }