blob: 675271f4d1eabf04e0c5189ae105762cf83681b3 [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
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200161 /* TS 44.004 7.2.1 */
162 type record SacchL1Header {
163 uint2_t reserved,
164 boolean fpc,
165 uint5_t ms_power_lvl,
166 uint8_t actual_ta
167 } with { variant "FIELDORDER(msb)" };
168
169 template (value) SacchL1Header ts_SacchL1Header(uint5_t ms_power_lvl, boolean fpc, uint8_t actual_ta) := {
170 reserved := 0,
171 fpc := fpc,
172 ms_power_lvl := ms_power_lvl,
173 actual_ta := actual_ta
174 };
175
Harald Welte9419c8a2017-07-30 04:07:05 +0200176 type record MaioHsn {
177 } with { variant "" };
178
179 /* TS 24.008 10.5.1.1 */
180 type uint16_t CellIdentity;
181
182 /* TS 24.008 10.5.1.2 */
183 type uint4_t CipheringKeySeqNr (0..7);
184
185 /* 24.008 10.5.1.3 */
186 type record LocationAreaIdentification {
187 BcdMccMnc mcc_mnc,
188 uint16_t lac
189 } with { variant "" };
190
191 /* TS 24.008 10.5.1.4 */
192 type enumerated MobileIdentityType {
193 MI_TYPE_NONE (0),
194 MI_TYPE_IMSI,
195 MI_TYPE_IMEI,
196 MI_TYPE_IMEISV,
197 MI_TYPE_TMSI,
198 MI_TYPE_TMGI
199 } with { variant "FIELDLENGTH(3)" };
200
201 type record MobileIdentityBCD {
202 MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV),
203 boolean odd,
204 hexstring digits
205 } with { variant "FIELDORDER(lsb)" };
206
207 type record MobileIdentityTMSI {
208 BIT4 pad ('1111'B),
209 boolean odd (false),
210 MobileIdentityType mi_type (MI_TYPE_TMSI),
211 GsmTmsi tmsi
212 } with { variant "FIELDORDER(lsb)" };
213
214 type record MobileIdentityNone {
215 BIT4 pad ('1111'B),
216 boolean odd (false),
217 MobileIdentityType mi_type (MI_TYPE_NONE)
218 } with { variant "FIELDORDER(lsb)" };
219
220 type union MobileIdentity {
221 MobileIdentityBCD imsi,
222 MobileIdentityBCD imei,
223 MobileIdentityBCD imeisv,
224 MobileIdentityTMSI tmsi,
225 MobileIdentityNone unused
226 } with { variant "TAG(imsi, mi_type = MI_TYPE_IMSI;
227 imei, mi_type = MI_TYPE_IMEI;
228 imeisv, mi_type = MI_TYPE_IMEISV;
229 tmsi, mi_type = MI_TYPE_TMSI;
230 unused, mi_type = MI_TYPE_NONE)"
231 variant "FIELDORDER(lsb)"
232 };
233
234 type record MobileIdentityLV {
235 uint8_t len,
236 MobileIdentity mi
237 } with { variant (len) "LENGTHTO(mi)" };
238
239 type record MobileIdentityTLV {
240 uint8_t tag,
241 uint8_t len,
242 MobileIdentity mi
243 } with { variant (len) "LENGTHTO(mi)" };
244
245 /* TS 24.008 10.5.1.5 */
246 type record MsClassmark1 {
247 BIT1 spare,
248 uint2_t rev_level,
249 boolean es_ind,
250 boolean a51,
251 uint3_t rf_pwr_cap
252 } with { variant "" };
253
254 /* TS 24.008 10.5.1.6 */
255 type record MsClassmark2 {
256 BIT1 spare,
257 uint2_t rev_level,
258 boolean es_ind,
259 boolean a51,
260 uint3_t rf_pwr_cap,
261 BIT1 spare1,
262 boolean ps_cap,
263 uint2_t ss_screen_ind,
264 boolean sm_cap,
265 boolean vbs,
266 boolean vgcs,
267 boolean fc,
268 boolean cm3,
269 BIT1 spare2,
270 boolean lcsva_cap,
271 boolean ucs2,
272 boolean solsa,
273 boolean cmsp,
274 boolean a53,
275 boolean a52
276 } with { variant "" };
277 type record MsClassmark2LV {
278 uint8_t len,
279 MsClassmark2 cm2
280 } with { variant (len) "LENGTHTO(cm2)" };
281
282
283 /* 44.018 10.5.2.5 */
284 type record ChannelDescription {
285 RslChannelNr chan_nr,
286 uint3_t tsc,
287 boolean h,
288 uint12_t arfcn optional,
289 MaioHsn maio_hsn optional
290 } with { variant (arfcn) "PRESENCE(h = false)"
291 variant (maio_hsn) "PRESENCE(h = true)" };
292
293 type record ChannelDescriptionTV {
294 OCT1 iei,
295 ChannelDescription v
296 } with { variant "" };
297
298 /* 10.5.2.21 */
299 type record MobileAllocation {
300 uint8_t len,
301 bitstring ma
302 } with { variant (len) "LENGTHTO(ma)" };
303
304 /* 10.5.2.25a */
Harald Welte1b9b7702017-07-30 04:19:14 +0200305 type record PktChDesc0Ind {
306 uint6_t maio,
307 BIT1 ma_number_ind,
308 BIT1 change_mark1_valid,
309 BIT2 change_mark1
310 } with { variant "" };
311 type record PktChDesc0 {
312 BIT1 hopping,
313 BIT1 spare ('0'B),
314 uint10_t arfcn optional,
315 PktChDesc0Ind indirect optional
316 } with {
317 variant (arfcn) "PRESENCE(hopping = '0'B)"
318 variant (indirect) "PRESENCE(hopping = '1'B)"
319 };
320 type record PktChDesc1 {
321 uint6_t maio,
322 uint6_t hsn
323 } with { variant "" };
324 type record PacketChannelDescription {
325 uint5_t channel_Type_spare,
326 uint3_t tn,
327 uint3_t tsc,
328 BIT1 presence,
329 PktChDesc0 zero optional,
330 PktChDesc1 one optional
331 } with {
332 variant (zero) "PRESENCE(presence = '0'B)"
333 variant (one) "PRESENCE(presence = '1'B)"
334 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200335
336 /* 10.5.2.25b */
337 type record DedicatedModeOrTbf {
338 BIT1 spare,
339 boolean tma,
340 boolean downlink,
341 boolean tbf
342 } with { variant "" };
343
344 /* 10.5.2.26 */
345 type enumerated PageMode {
346 PAGE_MODE_NORMAL,
347 PAGE_MODE_EXTENDED,
348 PAGE_MODE_REORGANIZATION,
349 PAGE_MODE_SAME_AS_BEFORE
350 } with { variant "FIELDLENGTH(4)" };
351
352 /* 10.5.2.30 */
353 type record RequestReference {
354 bitstring ra length(8),
355 uint5_t t1p,
356 uint6_t t3,
357 uint5_t t2
358 } with { variant "" };
359
360 template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := {
361 ra := ra,
362 t1p := t1p,
363 t3 := t3,
364 t2 := t2
365 }
366
367 /* compute the expected request reference for given RA + FN */
368 function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference {
369 var RequestReference req_ref := { ra := int2bit(ra, 8) };
370 req_ref.t1p := (fn / 1326) mod 32;
371 req_ref.t2 := fn mod 26;
372 req_ref.t3 := fn mod 51;
373 return req_ref
374 }
Harald Weltee8d750e2018-06-10 21:41:35 +0200375 function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn)
376 return template RequestReference {
377 var template RequestReference req_ref;
378 if (istemplatekind(ra, "?")) {
379 req_ref.ra := ?;
380 } else {
381 req_ref.ra := int2bit(valueof(ra), 8);
382 }
383 if (istemplatekind(fn, "?")) {
384 req_ref.t1p := ?;
385 req_ref.t2 := ?;
386 req_ref.t3 := ?;
387 } else {
388 var GsmFrameNumber fn_v := valueof(fn);
389 req_ref.t1p := (fn_v / 1326) mod 32;
390 req_ref.t2 := fn_v mod 26;
391 req_ref.t3 := fn_v mod 51;
392 }
393 return req_ref;
394 }
Harald Welte9419c8a2017-07-30 04:07:05 +0200395
396 /* 10.5.2.40 */
397 type integer TimingAdvance (0..219);
398
399 /* 10.5.2.43 */
400 type uint8_t WaitIndication;
401
402 /* 10.5.2.76 */
403 type record FeatureIndicator {
404 BIT2 spare,
405 boolean cs_ir,
406 boolean ps_ir
407 } with { variant "" };
408
409 /* 24.008 10.5.5.6 */
410 type record DrxParameter {
411 uint8_t split_pg_cycle_code,
412 uint4_t drx_cycle_len_coeff,
413 boolean split_on_ccch,
414 uint3_t non_drx_timer
415 } with { variant "" };
416
417 /* 24.008 10.5.5.15 */
418 type record RoutingAreaIdentification {
419 LocationAreaIdentification lai,
420 uint8_t rac
421 } with { variant "" };
422
423 /* 44.018 10.5.2.16 */
424 type record IaRestOctHL {
425 uint6_t freq_par_len,
426 BIT2 padding ('00'B) optional,
427 uint6_t maio optional,
428 octetstring mobile_allocation optional
429 } with {
430 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
431/*
432 variant (padding) "PRESENCE(freq_par_len != 0)"
433 variant (maio) "PRESENCE(freq_par_len != 0)"
434 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
435*/
436 };
437 type record IaRestOctHH {
438 BIT2 presence,
439 PacketUlAssign ul optional,
440 PacketDlAssign dl optional
441 } with {
442 variant (ul) "PRESENCE(presence = '00'B)"
443 variant (dl) "PRESENCE(presence = '01'B)"
444 };
445 type record PacketUlAssignDyn {
446 uint5_t tfi_assignment,
447 BIT1 polling,
448 BIT1 spare ('0'B),
449 uint3_t usf,
450 BIT1 usf_granularity,
451 BIT1 p0_present,
452 uint4_t p0 optional,
453 BIT1 pr_mode optional,
454 ChCodingCommand ch_coding_cmd,
455 BIT1 tlli_block_chan_coding,
456 BIT1 alpha_present,
457 uint4_t alpha optional,
458 uint5_t gamma,
459 BIT1 ta_index_present,
460 uint4_t ta_index optional,
461 BIT1 tbf_starting_time_present,
462 uint16_t tbf_starting_time optional
463 } with {
464 variant (p0) "PRESENCE(p0_present = '1'B)"
465 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
466 variant (alpha) "PRESENCE(alpha_present = '1'B)"
467 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
468 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
469 };
470 type record PacketUlAssignSgl {
471 BIT1 alpha_present,
472 uint4_t alpha optional,
473 uint5_t gamma,
474 BIT2 padding ('01'B),
475 uint16_t tbf_starting_time
476 /* TODO: P0 / PR_MODE */
477 } with {
478 variant (alpha) "PRESENCE(alpha_present = '1'B)"
479 };
480 type record PacketUlAssign {
481 BIT1 presence,
482 PacketUlAssignDyn dynamic optional,
483 PacketUlAssignSgl single optional
484 /* TODO: Estended RA, PFI */
485 } with {
486 variant (dynamic) "PRESENCE(presence = '1'B)"
487 variant (single) "PRESENCE(presence = '0'B)"
488 };
489 type record PacketDlAssG1 {
490 uint5_t tfi_assignment,
491 BIT1 rlc_mode,
492 BIT1 alpha_present,
493 uint4_t alpha optional,
494 uint5_t gamma,
495 BIT1 polling,
496 BIT1 ta_valid
497 } with { variant "" };
498 type record PacketDlAssign {
499 GprsTlli tlli,
500 BIT1 group1_present,
501 PacketDlAssG1 group1 optional,
502 BIT1 ta_index_present,
503 uint4_t ta_index optional,
504 BIT1 tbf_starting_time_present,
505 uint16_t tbf_starting_time optional,
506 BIT1 p0_present,
507 uint4_t p0 optional,
508 BIT1 pr_mode optional
509 /* TODO: EGPRS window size, etc. */
510 } with {
511 variant (group1) "PRESENCE(group1_present = '1'B)"
512 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
513 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
514 variant (p0) "PRESENCE(p0_present = '1'B)"
515 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
516 };
517 type record IaRestOctLL {
518 BIT1 compressed_irat_ho_info_ind
519 } with { variant "" };
520 type octetstring EgprsUlAss; /* TODO */
521 type octetstring MblkDlAss; /* TODO */
522 type record IaRestOctLH {
523 BIT2 presence,
524 EgprsUlAss egprs_ul optional,
525 MblkDlAss multiblock_dl_ass optional
526 } with {
527 variant (egprs_ul) "PRESENCE(presence = '00'B)"
528 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
529 };
530 type record IaRestOctets {
531 BIT2 presence,
532 IaRestOctLL ll optional,
533 IaRestOctLH lh optional,
534 IaRestOctHL hl optional,
535 IaRestOctHH hh optional
536 } with {
537 variant (ll) "PRESENCE(presence = '00'B)"
538 variant (lh) "PRESENCE(presence = '01'B)"
539 variant (hl) "PRESENCE(presence = '10'B)"
540 variant (hh) "PRESENCE(presence = '11'B)"
541 };
542
Harald Weltecbc947f2018-02-22 00:26:55 +0100543 type record MeasurementResults {
544 BIT1 ba_used,
545 BIT1 dtx_used,
546 uint6_t rxlev_full_srv_cell,
547 BIT1 threeg_ba_used,
548 BIT1 meas_valid,
549 uint6_t rxlev_sub_srv_cell,
550 BIT1 si23_ba_used,
551 uint3_t rxqual_full_srv_cell,
552 uint3_t rxqual_sub_srv_cell,
553 uint3_t no_ncell_m,
554 NcellReports ncell_reports optional
555 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
556 variant (no_ncell_m) "UNIT(elements)"
557 variant "PADDING(yes)"
558 variant "FIELDLENGTH(16)"
559 };
560
561 type record NcellReport {
562 uint6_t rxlev,
563 uint5_t bcch_freq,
564 uint6_t bsic
565 } with { variant ""};
566 type record of NcellReport NcellReports;
567
Harald Welte9419c8a2017-07-30 04:07:05 +0200568
569 /* 9.1.18 */
570 type record ImmediateAssignment {
571 DedicatedModeOrTbf ded_or_tbf,
572 PageMode page_mode,
573 ChannelDescription chan_desc optional,
574 PacketChannelDescription pkt_chan_desc optional,
575 RequestReference req_ref,
576 TimingAdvance timing_advance,
577 MobileAllocation mobile_allocation,
578 /* TODO: starting time TLV */
Harald Weltecbc947f2018-02-22 00:26:55 +0100579 IaRestOctets rest_octets optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200580 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
581 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
582
583 /* 9.1.20 */
584 type record ReqRefWaitInd {
585 RequestReference req_ref,
586 WaitIndication wait_ind
587 } with { variant "" };
588 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
589 type record ImmediateAssignmentReject {
590 FeatureIndicator feature_ind,
591 PageMode page_mode,
592 ReqRefWaitInd4 payload
593 } with { variant "" };
594
Harald Weltecbc947f2018-02-22 00:26:55 +0100595 /* 9.1.21 */
596 type record MeasurementReport {
597 MeasurementResults meas_res
598 } with { variant "" };
599
Harald Welte9419c8a2017-07-30 04:07:05 +0200600 /* 9.1.22 */
601 type record PagingRequestType1 {
602 ChannelNeeded12 chan_needed,
603 PageMode page_mode,
604 MobileIdentityLV mi1,
605 MobileIdentityTLV mi2 optional,
606 RestOctets rest_octets
607 } with { variant "TAG(mi2, tag = 23)" };
608
609 /* 9.1.23 */
610 type record PagingRequestType2 {
611 ChannelNeeded12 chan_needed,
612 PageMode page_mode,
613 GsmTmsi mi1,
614 GsmTmsi mi2,
615 MobileIdentityTLV mi3 optional,
616 RestOctets rest_octets
617 } with { variant "TAG(mi3, tag = 23)" };
618
619 /* 9.1.24 */
620 type record length(4) of GsmTmsi GsmTmsi4;
621 type record PagingRequestType3 {
622 ChannelNeeded12 chan_needed,
623 PageMode page_mode,
624 GsmTmsi4 mi,
625 RestOctets rest_octets
626 } with { variant "" };
627
Harald Welte9419c8a2017-07-30 04:07:05 +0200628 type union RrUnion {
629/*
630 SystemInformationType1 si1,
631 SystemInformationType2 si2,
632 SystemInformationType2bis si2bis,
633 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100634 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200635 SystemInformationType4 si4,
636 SystemInformationType5 si5,
637 SystemInformationType5bis si5bis,
638 SystemInformationType5ter si5ter,
639 SystemInformationType6 si6,
640*/
641 ImmediateAssignment imm_ass,
642 ImmediateAssignmentReject imm_ass_rej,
643 PagingRequestType1 pag_req_1,
644 PagingRequestType2 pag_req_2,
645 PagingRequestType3 pag_req_3,
646 octetstring other
647 } with { variant "" };
648
649 /* Special RR Message on BCCH / CCCH Dowlink */
650
651 type record GsmRrMessage {
652 RrHeader header,
653 RrUnion payload
654 } with { variant (payload) "CROSSTAG(
655/*
656 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
657 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
658 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
659 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
660 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
661 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
662 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
663 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
664 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
665 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
666*/
667 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
668 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
669 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
670 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
671 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
672 other, OTHERWISE;
673 )" };
674
675 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
676 with { extension "prototype(convert) encode(RAW)" };
677 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
678 with { extension "prototype(convert) decode(RAW)" };
679
680 /* Normal L3 Message on Dedicated Channel */
681
682 /* 9.1.25 Paging Response */
683 type record PagingResponse {
684 uint4_t spare_half_octet,
685 CipheringKeySeqNr cksn,
686 MsClassmark2LV cm2,
687 MobileIdentityLV mi,
688 uint8_t addl_upd_par optional
689 } with { variant "" };
690
691 type union RrL3Union {
692 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100693 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200694 octetstring other
695 };
696
697 type record GsmRrL3Message {
698 RrL3Header header,
699 RrL3Union payload
700 } with { variant (payload) "CROSSTAG(
701 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100702 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200703 other, OTHERWISE;
704 )" }
705
Harald Weltecbc947f2018-02-22 00:26:55 +0100706 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
707 with { extension "prototype(convert) encode(RAW)" };
708 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
709 with { extension "prototype(convert) decode(RAW)" };
710
711
Harald Weltee8d750e2018-06-10 21:41:35 +0200712 template (value) GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
Harald Weltecbc947f2018-02-22 00:26:55 +0100713 ChannelDescription ch_desc, MobileAllocation ma) := {
714 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
715 payload := {
716 imm_ass := {
717 ded_or_tbf := {
718 spare := '0'B,
719 tma := false,
720 downlink := false,
721 tbf := false
722 },
723 page_mode := PAGE_MODE_NORMAL,
724 chan_desc := ch_desc,
725 pkt_chan_desc := omit,
726 req_ref := f_compute_ReqRef(ra, fn),
727 timing_advance := ta,
728 mobile_allocation := ma,
729 rest_octets := omit
730 }
731 }
732 };
733
Harald Weltee8d750e2018-06-10 21:41:35 +0200734 template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?,
735 template TimingAdvance ta := ?,
736 template ChannelDescription ch_desc := ?,
737 template MobileAllocation ma := ?) := {
738 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
739 payload := {
740 imm_ass := {
741 ded_or_tbf := {
742 spare := '0'B,
743 tma := false,
744 downlink := false,
745 tbf := false
746 },
747 page_mode := PAGE_MODE_NORMAL,
748 chan_desc := ch_desc,
749 pkt_chan_desc := omit,
750 req_ref := tr_compute_ReqRef(ra, fn),
751 timing_advance := ta,
752 mobile_allocation := ma,
753 rest_octets := *
754 }
755 }
756 };
757
758
Harald Weltecbc947f2018-02-22 00:26:55 +0100759 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
Harald Welteb669ee02018-03-09 12:50:02 +0100782 template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
783 ded_or_tbf := {
784 spare := ?,
785 tma := ?,
786 downlink := ?,
787 tbf := true
788 },
789 page_mode := ?,
790 chan_desc := omit,
791 pkt_chan_desc := {
792 channel_Type_spare := ?,
793 tn := ?,
794 tsc := ?,
795 presence := ?,
796 zero := *,
797 one := omit
798 },
799 req_ref := ?,
800 timing_advance := ?,
801 mobile_allocation := ?,
802 rest_octets := {
803 presence := '11'B,
804 ll := omit,
805 lh := omit,
806 hl := omit,
807 hh := {
808 presence := '01'B,
809 ul := omit,
810 dl := {
811 tlli := tlli,
812 group1_present := ?,
813 group1 := *,
814 ta_index_present := ?,
815 ta_index := *,
816 tbf_starting_time_present := ?,
817 tbf_starting_time := *,
818 p0_present := ?,
819 p0 := *,
820 pr_mode := *
821 }
822 }
823 }
824 };
825
826 template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
827 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
828 payload := {
829 imm_ass := t_IMM_ASS_TBF_DL(tlli)
830 }
831 };
832
Harald Weltecbc947f2018-02-22 00:26:55 +0100833
834
Harald Welte9419c8a2017-07-30 04:07:05 +0200835} with { encode "RAW" ; variant "FIELDORDER(msb)" }