blob: a8b6db2b0d9f377dd3159a34c4c1ddb7d53f179c [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
117 template L2PseudoLength t_L2Pseudolength(template uint6_t len) := {
118 l2_plen := len,
119 zero_one := '01'B
120 };
121
122 type record RrHeader {
123 L2PseudoLength l2_plen,
124 uint4_t skip_indicator,
125 uint4_t rr_protocol_discriminator,
126 RrMessageType message_type
127 } with { variant "" };
128
129 template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := {
130 l2_plen := t_L2Pseudolength(len),
131 skip_indicator := 0,
132 rr_protocol_discriminator := 6,
133 message_type := msg_type
134 };
135
136 type record RrL3Header {
137 uint4_t skip_indicator,
138 uint4_t rr_protocol_discriminator,
139 RrMessageType message_type
140 } with { variant "" };
141
Harald Weltecbc947f2018-02-22 00:26:55 +0100142 template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
143 skip_indicator := 0,
144 rr_protocol_discriminator := 6,
145 message_type := msg_type
146 }
147
Harald Welte9419c8a2017-07-30 04:07:05 +0200148 type record MaioHsn {
149 } with { variant "" };
150
151 /* TS 24.008 10.5.1.1 */
152 type uint16_t CellIdentity;
153
154 /* TS 24.008 10.5.1.2 */
155 type uint4_t CipheringKeySeqNr (0..7);
156
157 /* 24.008 10.5.1.3 */
158 type record LocationAreaIdentification {
159 BcdMccMnc mcc_mnc,
160 uint16_t lac
161 } with { variant "" };
162
163 /* TS 24.008 10.5.1.4 */
164 type enumerated MobileIdentityType {
165 MI_TYPE_NONE (0),
166 MI_TYPE_IMSI,
167 MI_TYPE_IMEI,
168 MI_TYPE_IMEISV,
169 MI_TYPE_TMSI,
170 MI_TYPE_TMGI
171 } with { variant "FIELDLENGTH(3)" };
172
173 type record MobileIdentityBCD {
174 MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV),
175 boolean odd,
176 hexstring digits
177 } with { variant "FIELDORDER(lsb)" };
178
179 type record MobileIdentityTMSI {
180 BIT4 pad ('1111'B),
181 boolean odd (false),
182 MobileIdentityType mi_type (MI_TYPE_TMSI),
183 GsmTmsi tmsi
184 } with { variant "FIELDORDER(lsb)" };
185
186 type record MobileIdentityNone {
187 BIT4 pad ('1111'B),
188 boolean odd (false),
189 MobileIdentityType mi_type (MI_TYPE_NONE)
190 } with { variant "FIELDORDER(lsb)" };
191
192 type union MobileIdentity {
193 MobileIdentityBCD imsi,
194 MobileIdentityBCD imei,
195 MobileIdentityBCD imeisv,
196 MobileIdentityTMSI tmsi,
197 MobileIdentityNone unused
198 } with { variant "TAG(imsi, mi_type = MI_TYPE_IMSI;
199 imei, mi_type = MI_TYPE_IMEI;
200 imeisv, mi_type = MI_TYPE_IMEISV;
201 tmsi, mi_type = MI_TYPE_TMSI;
202 unused, mi_type = MI_TYPE_NONE)"
203 variant "FIELDORDER(lsb)"
204 };
205
206 type record MobileIdentityLV {
207 uint8_t len,
208 MobileIdentity mi
209 } with { variant (len) "LENGTHTO(mi)" };
210
211 type record MobileIdentityTLV {
212 uint8_t tag,
213 uint8_t len,
214 MobileIdentity mi
215 } with { variant (len) "LENGTHTO(mi)" };
216
217 /* TS 24.008 10.5.1.5 */
218 type record MsClassmark1 {
219 BIT1 spare,
220 uint2_t rev_level,
221 boolean es_ind,
222 boolean a51,
223 uint3_t rf_pwr_cap
224 } with { variant "" };
225
226 /* TS 24.008 10.5.1.6 */
227 type record MsClassmark2 {
228 BIT1 spare,
229 uint2_t rev_level,
230 boolean es_ind,
231 boolean a51,
232 uint3_t rf_pwr_cap,
233 BIT1 spare1,
234 boolean ps_cap,
235 uint2_t ss_screen_ind,
236 boolean sm_cap,
237 boolean vbs,
238 boolean vgcs,
239 boolean fc,
240 boolean cm3,
241 BIT1 spare2,
242 boolean lcsva_cap,
243 boolean ucs2,
244 boolean solsa,
245 boolean cmsp,
246 boolean a53,
247 boolean a52
248 } with { variant "" };
249 type record MsClassmark2LV {
250 uint8_t len,
251 MsClassmark2 cm2
252 } with { variant (len) "LENGTHTO(cm2)" };
253
254
255 /* 44.018 10.5.2.5 */
256 type record ChannelDescription {
257 RslChannelNr chan_nr,
258 uint3_t tsc,
259 boolean h,
260 uint12_t arfcn optional,
261 MaioHsn maio_hsn optional
262 } with { variant (arfcn) "PRESENCE(h = false)"
263 variant (maio_hsn) "PRESENCE(h = true)" };
264
265 type record ChannelDescriptionTV {
266 OCT1 iei,
267 ChannelDescription v
268 } with { variant "" };
269
270 /* 10.5.2.21 */
271 type record MobileAllocation {
272 uint8_t len,
273 bitstring ma
274 } with { variant (len) "LENGTHTO(ma)" };
275
276 /* 10.5.2.25a */
Harald Welte1b9b7702017-07-30 04:19:14 +0200277 type record PktChDesc0Ind {
278 uint6_t maio,
279 BIT1 ma_number_ind,
280 BIT1 change_mark1_valid,
281 BIT2 change_mark1
282 } with { variant "" };
283 type record PktChDesc0 {
284 BIT1 hopping,
285 BIT1 spare ('0'B),
286 uint10_t arfcn optional,
287 PktChDesc0Ind indirect optional
288 } with {
289 variant (arfcn) "PRESENCE(hopping = '0'B)"
290 variant (indirect) "PRESENCE(hopping = '1'B)"
291 };
292 type record PktChDesc1 {
293 uint6_t maio,
294 uint6_t hsn
295 } with { variant "" };
296 type record PacketChannelDescription {
297 uint5_t channel_Type_spare,
298 uint3_t tn,
299 uint3_t tsc,
300 BIT1 presence,
301 PktChDesc0 zero optional,
302 PktChDesc1 one optional
303 } with {
304 variant (zero) "PRESENCE(presence = '0'B)"
305 variant (one) "PRESENCE(presence = '1'B)"
306 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200307
308 /* 10.5.2.25b */
309 type record DedicatedModeOrTbf {
310 BIT1 spare,
311 boolean tma,
312 boolean downlink,
313 boolean tbf
314 } with { variant "" };
315
316 /* 10.5.2.26 */
317 type enumerated PageMode {
318 PAGE_MODE_NORMAL,
319 PAGE_MODE_EXTENDED,
320 PAGE_MODE_REORGANIZATION,
321 PAGE_MODE_SAME_AS_BEFORE
322 } with { variant "FIELDLENGTH(4)" };
323
324 /* 10.5.2.30 */
325 type record RequestReference {
326 bitstring ra length(8),
327 uint5_t t1p,
328 uint6_t t3,
329 uint5_t t2
330 } with { variant "" };
331
332 template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := {
333 ra := ra,
334 t1p := t1p,
335 t3 := t3,
336 t2 := t2
337 }
338
339 /* compute the expected request reference for given RA + FN */
340 function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference {
341 var RequestReference req_ref := { ra := int2bit(ra, 8) };
342 req_ref.t1p := (fn / 1326) mod 32;
343 req_ref.t2 := fn mod 26;
344 req_ref.t3 := fn mod 51;
345 return req_ref
346 }
347
348 /* 10.5.2.40 */
349 type integer TimingAdvance (0..219);
350
351 /* 10.5.2.43 */
352 type uint8_t WaitIndication;
353
354 /* 10.5.2.76 */
355 type record FeatureIndicator {
356 BIT2 spare,
357 boolean cs_ir,
358 boolean ps_ir
359 } with { variant "" };
360
361 /* 24.008 10.5.5.6 */
362 type record DrxParameter {
363 uint8_t split_pg_cycle_code,
364 uint4_t drx_cycle_len_coeff,
365 boolean split_on_ccch,
366 uint3_t non_drx_timer
367 } with { variant "" };
368
Harald Welte7484fc42018-02-24 14:09:45 +0100369 /* 44.018 10.5.2.3 */
370 type enumerated CellOptions_DTX {
371 MS_MAY_USE_UL_DTX ('00'B),
372 MS_SHALL_USE_UL_DTX ('01'B),
373 MS_SHALL_NOT_USE_UL_DTX ('10'B)
374 } with { variant "FIELDLENGTH(2)" };
375 type record CellOptions {
376 boolean dn_ind,
377 boolean pwrc,
378 CellOptions_DTX dtx,
379 uint4_t radio_link_tout_div4
380 } with { variant "" };
381
382 /* 44.018 10.5.2.4 */
383 type record CellSelectionPars {
384 uint3_t cell_resel_hyst_2dB,
385 uint5_t ms_txpwr_max_cch,
386 BIT1 acs,
387 boolean neci,
388 uint6_t rxlev_access_min
389 } with { variant "" };
390
391 /* 44.018 10.5.2.29 */
392 type enumerated RachCtrlPar_MR {
393 RACH_MAX_RETRANS_1 ('00'B),
394 RACH_MAX_RETRANS_2 ('01'B),
395 RACH_MAX_RETRANS_4 ('10'B),
396 RACH_MAX_RETRANS_7 ('11'B)
397 } with { variant "FIELDLENGTH(2)" };
398 type record RachControlPars {
399 RachCtrlPar_MR max_retrans,
400 BIT4 tx_integer,
401 boolean cell_bar_access,
402 boolean re_not_allowed,
403 BIT16 acc
404 } with { variant "" };
405
406 /* 44.018 10.5.2.11 */
407 type enumerated CtrlChanDesc_CC {
408 CCHAN_DESC_1CCCH_NOT_COMBINED ('000'B),
409 CCHAN_DESC_1CCCH_COMBINED ('001'B),
410 CCHAN_DESC_2CCCH_NOT_COMBINED ('010'B),
411 CCHAN_DESC_3CCCH_NOT_COMBINED ('100'B),
412 CCHAN_DESC_4CCCH_NOT_COMBINED ('110'B)
413 } with { variant "FIELDLENGTH(3)" };
414 type enumerated CBQ3 {
415 CBQ3_IU_MODE_NOT_SUPPORTED ('00'B),
416 CBQ3_IU_MODE_MS_BARRED ('01'B),
417 CBQ3_IU_MODE_NOT_BARRED ('10'B)
418 } with { variant "FIELDLENGTH(2)" };
419 type record CtrlChanDesc {
420 boolean msc_r99,
421 boolean att,
422 uint3_t bs_ag_blks_res,
423 CtrlChanDesc_CC ccch_conf,
424 boolean si22_ind,
425 CBQ3 cbq3,
426 BIT2 spare,
427 uint3_t bs_pa_mfrms, /* off by 2 */
428 uint8_t t3212
429 } with { variant "" };
430
Harald Welte9419c8a2017-07-30 04:07:05 +0200431 /* 24.008 10.5.5.15 */
432 type record RoutingAreaIdentification {
433 LocationAreaIdentification lai,
434 uint8_t rac
435 } with { variant "" };
436
437 /* 44.018 10.5.2.16 */
438 type record IaRestOctHL {
439 uint6_t freq_par_len,
440 BIT2 padding ('00'B) optional,
441 uint6_t maio optional,
442 octetstring mobile_allocation optional
443 } with {
444 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
445/*
446 variant (padding) "PRESENCE(freq_par_len != 0)"
447 variant (maio) "PRESENCE(freq_par_len != 0)"
448 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
449*/
450 };
451 type record IaRestOctHH {
452 BIT2 presence,
453 PacketUlAssign ul optional,
454 PacketDlAssign dl optional
455 } with {
456 variant (ul) "PRESENCE(presence = '00'B)"
457 variant (dl) "PRESENCE(presence = '01'B)"
458 };
459 type record PacketUlAssignDyn {
460 uint5_t tfi_assignment,
461 BIT1 polling,
462 BIT1 spare ('0'B),
463 uint3_t usf,
464 BIT1 usf_granularity,
465 BIT1 p0_present,
466 uint4_t p0 optional,
467 BIT1 pr_mode optional,
468 ChCodingCommand ch_coding_cmd,
469 BIT1 tlli_block_chan_coding,
470 BIT1 alpha_present,
471 uint4_t alpha optional,
472 uint5_t gamma,
473 BIT1 ta_index_present,
474 uint4_t ta_index optional,
475 BIT1 tbf_starting_time_present,
476 uint16_t tbf_starting_time optional
477 } with {
478 variant (p0) "PRESENCE(p0_present = '1'B)"
479 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
480 variant (alpha) "PRESENCE(alpha_present = '1'B)"
481 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
482 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
483 };
484 type record PacketUlAssignSgl {
485 BIT1 alpha_present,
486 uint4_t alpha optional,
487 uint5_t gamma,
488 BIT2 padding ('01'B),
489 uint16_t tbf_starting_time
490 /* TODO: P0 / PR_MODE */
491 } with {
492 variant (alpha) "PRESENCE(alpha_present = '1'B)"
493 };
494 type record PacketUlAssign {
495 BIT1 presence,
496 PacketUlAssignDyn dynamic optional,
497 PacketUlAssignSgl single optional
498 /* TODO: Estended RA, PFI */
499 } with {
500 variant (dynamic) "PRESENCE(presence = '1'B)"
501 variant (single) "PRESENCE(presence = '0'B)"
502 };
503 type record PacketDlAssG1 {
504 uint5_t tfi_assignment,
505 BIT1 rlc_mode,
506 BIT1 alpha_present,
507 uint4_t alpha optional,
508 uint5_t gamma,
509 BIT1 polling,
510 BIT1 ta_valid
511 } with { variant "" };
512 type record PacketDlAssign {
513 GprsTlli tlli,
514 BIT1 group1_present,
515 PacketDlAssG1 group1 optional,
516 BIT1 ta_index_present,
517 uint4_t ta_index optional,
518 BIT1 tbf_starting_time_present,
519 uint16_t tbf_starting_time optional,
520 BIT1 p0_present,
521 uint4_t p0 optional,
522 BIT1 pr_mode optional
523 /* TODO: EGPRS window size, etc. */
524 } with {
525 variant (group1) "PRESENCE(group1_present = '1'B)"
526 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
527 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
528 variant (p0) "PRESENCE(p0_present = '1'B)"
529 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
530 };
531 type record IaRestOctLL {
532 BIT1 compressed_irat_ho_info_ind
533 } with { variant "" };
534 type octetstring EgprsUlAss; /* TODO */
535 type octetstring MblkDlAss; /* TODO */
536 type record IaRestOctLH {
537 BIT2 presence,
538 EgprsUlAss egprs_ul optional,
539 MblkDlAss multiblock_dl_ass optional
540 } with {
541 variant (egprs_ul) "PRESENCE(presence = '00'B)"
542 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
543 };
544 type record IaRestOctets {
545 BIT2 presence,
546 IaRestOctLL ll optional,
547 IaRestOctLH lh optional,
548 IaRestOctHL hl optional,
549 IaRestOctHH hh optional
550 } with {
551 variant (ll) "PRESENCE(presence = '00'B)"
552 variant (lh) "PRESENCE(presence = '01'B)"
553 variant (hl) "PRESENCE(presence = '10'B)"
554 variant (hh) "PRESENCE(presence = '11'B)"
555 };
556
Harald Weltecbc947f2018-02-22 00:26:55 +0100557 type record MeasurementResults {
558 BIT1 ba_used,
559 BIT1 dtx_used,
560 uint6_t rxlev_full_srv_cell,
561 BIT1 threeg_ba_used,
562 BIT1 meas_valid,
563 uint6_t rxlev_sub_srv_cell,
564 BIT1 si23_ba_used,
565 uint3_t rxqual_full_srv_cell,
566 uint3_t rxqual_sub_srv_cell,
567 uint3_t no_ncell_m,
568 NcellReports ncell_reports optional
569 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
570 variant (no_ncell_m) "UNIT(elements)"
571 variant "PADDING(yes)"
572 variant "FIELDLENGTH(16)"
573 };
574
575 type record NcellReport {
576 uint6_t rxlev,
577 uint5_t bcch_freq,
578 uint6_t bsic
579 } with { variant ""};
580 type record of NcellReport NcellReports;
581
Harald Welte9419c8a2017-07-30 04:07:05 +0200582
583 /* 9.1.18 */
584 type record ImmediateAssignment {
585 DedicatedModeOrTbf ded_or_tbf,
586 PageMode page_mode,
587 ChannelDescription chan_desc optional,
588 PacketChannelDescription pkt_chan_desc optional,
589 RequestReference req_ref,
590 TimingAdvance timing_advance,
591 MobileAllocation mobile_allocation,
592 /* TODO: starting time TLV */
Harald Weltecbc947f2018-02-22 00:26:55 +0100593 IaRestOctets rest_octets optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200594 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
595 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
596
597 /* 9.1.20 */
598 type record ReqRefWaitInd {
599 RequestReference req_ref,
600 WaitIndication wait_ind
601 } with { variant "" };
602 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
603 type record ImmediateAssignmentReject {
604 FeatureIndicator feature_ind,
605 PageMode page_mode,
606 ReqRefWaitInd4 payload
607 } with { variant "" };
608
Harald Weltecbc947f2018-02-22 00:26:55 +0100609 /* 9.1.21 */
610 type record MeasurementReport {
611 MeasurementResults meas_res
612 } with { variant "" };
613
Harald Welte9419c8a2017-07-30 04:07:05 +0200614 /* 9.1.22 */
615 type record PagingRequestType1 {
616 ChannelNeeded12 chan_needed,
617 PageMode page_mode,
618 MobileIdentityLV mi1,
619 MobileIdentityTLV mi2 optional,
620 RestOctets rest_octets
621 } with { variant "TAG(mi2, tag = 23)" };
622
623 /* 9.1.23 */
624 type record PagingRequestType2 {
625 ChannelNeeded12 chan_needed,
626 PageMode page_mode,
627 GsmTmsi mi1,
628 GsmTmsi mi2,
629 MobileIdentityTLV mi3 optional,
630 RestOctets rest_octets
631 } with { variant "TAG(mi3, tag = 23)" };
632
633 /* 9.1.24 */
634 type record length(4) of GsmTmsi GsmTmsi4;
635 type record PagingRequestType3 {
636 ChannelNeeded12 chan_needed,
637 PageMode page_mode,
638 GsmTmsi4 mi,
639 RestOctets rest_octets
640 } with { variant "" };
641
Harald Welte7484fc42018-02-24 14:09:45 +0100642 /* 9.1.35 */
643 type record SystemInformationType3 {
644 CellIdentity cell_id,
645 LocationAreaIdentification lai,
646 CtrlChanDesc ctrl_chan_desc,
647 CellOptions cell_opts,
648 CellSelectionPars cell_sel_pars,
649 RachControlPars rach_ctrl_pars,
650 RestOctets rest_octets
651 } with { variant (rest_octets) "FIELDLENGTH(4)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200652
653 type union RrUnion {
654/*
655 SystemInformationType1 si1,
656 SystemInformationType2 si2,
657 SystemInformationType2bis si2bis,
658 SystemInformationType2ter si2ter,
Harald Welte9419c8a2017-07-30 04:07:05 +0200659 SystemInformationType4 si4,
660 SystemInformationType5 si5,
661 SystemInformationType5bis si5bis,
662 SystemInformationType5ter si5ter,
663 SystemInformationType6 si6,
664*/
Harald Welte7484fc42018-02-24 14:09:45 +0100665 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200666 ImmediateAssignment imm_ass,
667 ImmediateAssignmentReject imm_ass_rej,
668 PagingRequestType1 pag_req_1,
669 PagingRequestType2 pag_req_2,
670 PagingRequestType3 pag_req_3,
671 octetstring other
672 } with { variant "" };
673
674 /* Special RR Message on BCCH / CCCH Dowlink */
675
676 type record GsmRrMessage {
677 RrHeader header,
678 RrUnion payload
679 } with { variant (payload) "CROSSTAG(
680/*
681 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
682 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
683 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
684 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
685 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
686 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
687 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
688 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
689 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
690 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
691*/
692 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
693 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
694 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
695 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
696 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
697 other, OTHERWISE;
698 )" };
699
700 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
701 with { extension "prototype(convert) encode(RAW)" };
702 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
703 with { extension "prototype(convert) decode(RAW)" };
704
705 /* Normal L3 Message on Dedicated Channel */
706
707 /* 9.1.25 Paging Response */
708 type record PagingResponse {
709 uint4_t spare_half_octet,
710 CipheringKeySeqNr cksn,
711 MsClassmark2LV cm2,
712 MobileIdentityLV mi,
713 uint8_t addl_upd_par optional
714 } with { variant "" };
715
716 type union RrL3Union {
717 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100718 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200719 octetstring other
720 };
721
722 type record GsmRrL3Message {
723 RrL3Header header,
724 RrL3Union payload
725 } with { variant (payload) "CROSSTAG(
726 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100727 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200728 other, OTHERWISE;
729 )" }
730
Harald Weltecbc947f2018-02-22 00:26:55 +0100731 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
732 with { extension "prototype(convert) encode(RAW)" };
733 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
734 with { extension "prototype(convert) decode(RAW)" };
735
736
737 template GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
738 ChannelDescription ch_desc, MobileAllocation ma) := {
739 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
740 payload := {
741 imm_ass := {
742 ded_or_tbf := {
743 spare := '0'B,
744 tma := false,
745 downlink := false,
746 tbf := false
747 },
748 page_mode := PAGE_MODE_NORMAL,
749 chan_desc := ch_desc,
750 pkt_chan_desc := omit,
751 req_ref := f_compute_ReqRef(ra, fn),
752 timing_advance := ta,
753 mobile_allocation := ma,
754 rest_octets := omit
755 }
756 }
757 };
758
759 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
760 uint3_t rxq_f, uint3_t rxq_s,
761 template (omit) NcellReports reps) := {
762 header := t_RrL3Header(MEASUREMENT_REPORT),
763 payload := {
764 meas_rep := {
765 meas_res := {
766 ba_used := '0'B,
767 dtx_used := '0'B,
768 rxlev_full_srv_cell := rxl_f,
769 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +0100770 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +0100771 rxlev_sub_srv_cell := rxl_s,
772 si23_ba_used := '0'B,
773 rxqual_full_srv_cell := rxq_f,
774 rxqual_sub_srv_cell := rxq_s,
775 no_ncell_m := 0,
776 ncell_reports := reps
777 }
778 }
779 }
780 };
781
782
783
Harald Welte9419c8a2017-07-30 04:07:05 +0200784} with { encode "RAW" ; variant "FIELDORDER(msb)" }