blob: ef209e455708aaa23dcb325a56acfeb825844147 [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 }
Harald Weltee8d750e2018-06-10 21:41:35 +0200360 function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn)
361 return template RequestReference {
362 var template RequestReference req_ref;
363 if (istemplatekind(ra, "?")) {
364 req_ref.ra := ?;
365 } else {
366 req_ref.ra := int2bit(valueof(ra), 8);
367 }
368 if (istemplatekind(fn, "?")) {
369 req_ref.t1p := ?;
370 req_ref.t2 := ?;
371 req_ref.t3 := ?;
372 } else {
373 var GsmFrameNumber fn_v := valueof(fn);
374 req_ref.t1p := (fn_v / 1326) mod 32;
375 req_ref.t2 := fn_v mod 26;
376 req_ref.t3 := fn_v mod 51;
377 }
378 return req_ref;
379 }
Harald Welte9419c8a2017-07-30 04:07:05 +0200380
381 /* 10.5.2.40 */
382 type integer TimingAdvance (0..219);
383
384 /* 10.5.2.43 */
385 type uint8_t WaitIndication;
386
387 /* 10.5.2.76 */
388 type record FeatureIndicator {
389 BIT2 spare,
390 boolean cs_ir,
391 boolean ps_ir
392 } with { variant "" };
393
394 /* 24.008 10.5.5.6 */
395 type record DrxParameter {
396 uint8_t split_pg_cycle_code,
397 uint4_t drx_cycle_len_coeff,
398 boolean split_on_ccch,
399 uint3_t non_drx_timer
400 } with { variant "" };
401
402 /* 24.008 10.5.5.15 */
403 type record RoutingAreaIdentification {
404 LocationAreaIdentification lai,
405 uint8_t rac
406 } with { variant "" };
407
408 /* 44.018 10.5.2.16 */
409 type record IaRestOctHL {
410 uint6_t freq_par_len,
411 BIT2 padding ('00'B) optional,
412 uint6_t maio optional,
413 octetstring mobile_allocation optional
414 } with {
415 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
416/*
417 variant (padding) "PRESENCE(freq_par_len != 0)"
418 variant (maio) "PRESENCE(freq_par_len != 0)"
419 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
420*/
421 };
422 type record IaRestOctHH {
423 BIT2 presence,
424 PacketUlAssign ul optional,
425 PacketDlAssign dl optional
426 } with {
427 variant (ul) "PRESENCE(presence = '00'B)"
428 variant (dl) "PRESENCE(presence = '01'B)"
429 };
430 type record PacketUlAssignDyn {
431 uint5_t tfi_assignment,
432 BIT1 polling,
433 BIT1 spare ('0'B),
434 uint3_t usf,
435 BIT1 usf_granularity,
436 BIT1 p0_present,
437 uint4_t p0 optional,
438 BIT1 pr_mode optional,
439 ChCodingCommand ch_coding_cmd,
440 BIT1 tlli_block_chan_coding,
441 BIT1 alpha_present,
442 uint4_t alpha optional,
443 uint5_t gamma,
444 BIT1 ta_index_present,
445 uint4_t ta_index optional,
446 BIT1 tbf_starting_time_present,
447 uint16_t tbf_starting_time optional
448 } with {
449 variant (p0) "PRESENCE(p0_present = '1'B)"
450 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
451 variant (alpha) "PRESENCE(alpha_present = '1'B)"
452 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
453 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
454 };
455 type record PacketUlAssignSgl {
456 BIT1 alpha_present,
457 uint4_t alpha optional,
458 uint5_t gamma,
459 BIT2 padding ('01'B),
460 uint16_t tbf_starting_time
461 /* TODO: P0 / PR_MODE */
462 } with {
463 variant (alpha) "PRESENCE(alpha_present = '1'B)"
464 };
465 type record PacketUlAssign {
466 BIT1 presence,
467 PacketUlAssignDyn dynamic optional,
468 PacketUlAssignSgl single optional
469 /* TODO: Estended RA, PFI */
470 } with {
471 variant (dynamic) "PRESENCE(presence = '1'B)"
472 variant (single) "PRESENCE(presence = '0'B)"
473 };
474 type record PacketDlAssG1 {
475 uint5_t tfi_assignment,
476 BIT1 rlc_mode,
477 BIT1 alpha_present,
478 uint4_t alpha optional,
479 uint5_t gamma,
480 BIT1 polling,
481 BIT1 ta_valid
482 } with { variant "" };
483 type record PacketDlAssign {
484 GprsTlli tlli,
485 BIT1 group1_present,
486 PacketDlAssG1 group1 optional,
487 BIT1 ta_index_present,
488 uint4_t ta_index optional,
489 BIT1 tbf_starting_time_present,
490 uint16_t tbf_starting_time optional,
491 BIT1 p0_present,
492 uint4_t p0 optional,
493 BIT1 pr_mode optional
494 /* TODO: EGPRS window size, etc. */
495 } with {
496 variant (group1) "PRESENCE(group1_present = '1'B)"
497 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
498 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
499 variant (p0) "PRESENCE(p0_present = '1'B)"
500 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
501 };
502 type record IaRestOctLL {
503 BIT1 compressed_irat_ho_info_ind
504 } with { variant "" };
505 type octetstring EgprsUlAss; /* TODO */
506 type octetstring MblkDlAss; /* TODO */
507 type record IaRestOctLH {
508 BIT2 presence,
509 EgprsUlAss egprs_ul optional,
510 MblkDlAss multiblock_dl_ass optional
511 } with {
512 variant (egprs_ul) "PRESENCE(presence = '00'B)"
513 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
514 };
515 type record IaRestOctets {
516 BIT2 presence,
517 IaRestOctLL ll optional,
518 IaRestOctLH lh optional,
519 IaRestOctHL hl optional,
520 IaRestOctHH hh optional
521 } with {
522 variant (ll) "PRESENCE(presence = '00'B)"
523 variant (lh) "PRESENCE(presence = '01'B)"
524 variant (hl) "PRESENCE(presence = '10'B)"
525 variant (hh) "PRESENCE(presence = '11'B)"
526 };
527
Harald Weltecbc947f2018-02-22 00:26:55 +0100528 type record MeasurementResults {
529 BIT1 ba_used,
530 BIT1 dtx_used,
531 uint6_t rxlev_full_srv_cell,
532 BIT1 threeg_ba_used,
533 BIT1 meas_valid,
534 uint6_t rxlev_sub_srv_cell,
535 BIT1 si23_ba_used,
536 uint3_t rxqual_full_srv_cell,
537 uint3_t rxqual_sub_srv_cell,
538 uint3_t no_ncell_m,
539 NcellReports ncell_reports optional
540 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
541 variant (no_ncell_m) "UNIT(elements)"
542 variant "PADDING(yes)"
543 variant "FIELDLENGTH(16)"
544 };
545
546 type record NcellReport {
547 uint6_t rxlev,
548 uint5_t bcch_freq,
549 uint6_t bsic
550 } with { variant ""};
551 type record of NcellReport NcellReports;
552
Harald Welte9419c8a2017-07-30 04:07:05 +0200553
554 /* 9.1.18 */
555 type record ImmediateAssignment {
556 DedicatedModeOrTbf ded_or_tbf,
557 PageMode page_mode,
558 ChannelDescription chan_desc optional,
559 PacketChannelDescription pkt_chan_desc optional,
560 RequestReference req_ref,
561 TimingAdvance timing_advance,
562 MobileAllocation mobile_allocation,
563 /* TODO: starting time TLV */
Harald Weltecbc947f2018-02-22 00:26:55 +0100564 IaRestOctets rest_octets optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200565 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
566 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
567
568 /* 9.1.20 */
569 type record ReqRefWaitInd {
570 RequestReference req_ref,
571 WaitIndication wait_ind
572 } with { variant "" };
573 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
574 type record ImmediateAssignmentReject {
575 FeatureIndicator feature_ind,
576 PageMode page_mode,
577 ReqRefWaitInd4 payload
578 } with { variant "" };
579
Harald Weltecbc947f2018-02-22 00:26:55 +0100580 /* 9.1.21 */
581 type record MeasurementReport {
582 MeasurementResults meas_res
583 } with { variant "" };
584
Harald Welte9419c8a2017-07-30 04:07:05 +0200585 /* 9.1.22 */
586 type record PagingRequestType1 {
587 ChannelNeeded12 chan_needed,
588 PageMode page_mode,
589 MobileIdentityLV mi1,
590 MobileIdentityTLV mi2 optional,
591 RestOctets rest_octets
592 } with { variant "TAG(mi2, tag = 23)" };
593
594 /* 9.1.23 */
595 type record PagingRequestType2 {
596 ChannelNeeded12 chan_needed,
597 PageMode page_mode,
598 GsmTmsi mi1,
599 GsmTmsi mi2,
600 MobileIdentityTLV mi3 optional,
601 RestOctets rest_octets
602 } with { variant "TAG(mi3, tag = 23)" };
603
604 /* 9.1.24 */
605 type record length(4) of GsmTmsi GsmTmsi4;
606 type record PagingRequestType3 {
607 ChannelNeeded12 chan_needed,
608 PageMode page_mode,
609 GsmTmsi4 mi,
610 RestOctets rest_octets
611 } with { variant "" };
612
Harald Welte9419c8a2017-07-30 04:07:05 +0200613 type union RrUnion {
614/*
615 SystemInformationType1 si1,
616 SystemInformationType2 si2,
617 SystemInformationType2bis si2bis,
618 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100619 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200620 SystemInformationType4 si4,
621 SystemInformationType5 si5,
622 SystemInformationType5bis si5bis,
623 SystemInformationType5ter si5ter,
624 SystemInformationType6 si6,
625*/
626 ImmediateAssignment imm_ass,
627 ImmediateAssignmentReject imm_ass_rej,
628 PagingRequestType1 pag_req_1,
629 PagingRequestType2 pag_req_2,
630 PagingRequestType3 pag_req_3,
631 octetstring other
632 } with { variant "" };
633
634 /* Special RR Message on BCCH / CCCH Dowlink */
635
636 type record GsmRrMessage {
637 RrHeader header,
638 RrUnion payload
639 } with { variant (payload) "CROSSTAG(
640/*
641 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
642 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
643 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
644 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
645 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
646 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
647 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
648 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
649 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
650 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
651*/
652 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
653 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
654 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
655 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
656 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
657 other, OTHERWISE;
658 )" };
659
660 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
661 with { extension "prototype(convert) encode(RAW)" };
662 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
663 with { extension "prototype(convert) decode(RAW)" };
664
665 /* Normal L3 Message on Dedicated Channel */
666
667 /* 9.1.25 Paging Response */
668 type record PagingResponse {
669 uint4_t spare_half_octet,
670 CipheringKeySeqNr cksn,
671 MsClassmark2LV cm2,
672 MobileIdentityLV mi,
673 uint8_t addl_upd_par optional
674 } with { variant "" };
675
676 type union RrL3Union {
677 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100678 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200679 octetstring other
680 };
681
682 type record GsmRrL3Message {
683 RrL3Header header,
684 RrL3Union payload
685 } with { variant (payload) "CROSSTAG(
686 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100687 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200688 other, OTHERWISE;
689 )" }
690
Harald Weltecbc947f2018-02-22 00:26:55 +0100691 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
692 with { extension "prototype(convert) encode(RAW)" };
693 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
694 with { extension "prototype(convert) decode(RAW)" };
695
696
Harald Weltee8d750e2018-06-10 21:41:35 +0200697 template (value) GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
Harald Weltecbc947f2018-02-22 00:26:55 +0100698 ChannelDescription ch_desc, MobileAllocation ma) := {
699 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
700 payload := {
701 imm_ass := {
702 ded_or_tbf := {
703 spare := '0'B,
704 tma := false,
705 downlink := false,
706 tbf := false
707 },
708 page_mode := PAGE_MODE_NORMAL,
709 chan_desc := ch_desc,
710 pkt_chan_desc := omit,
711 req_ref := f_compute_ReqRef(ra, fn),
712 timing_advance := ta,
713 mobile_allocation := ma,
714 rest_octets := omit
715 }
716 }
717 };
718
Harald Weltee8d750e2018-06-10 21:41:35 +0200719 template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?,
720 template TimingAdvance ta := ?,
721 template ChannelDescription ch_desc := ?,
722 template MobileAllocation ma := ?) := {
723 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
724 payload := {
725 imm_ass := {
726 ded_or_tbf := {
727 spare := '0'B,
728 tma := false,
729 downlink := false,
730 tbf := false
731 },
732 page_mode := PAGE_MODE_NORMAL,
733 chan_desc := ch_desc,
734 pkt_chan_desc := omit,
735 req_ref := tr_compute_ReqRef(ra, fn),
736 timing_advance := ta,
737 mobile_allocation := ma,
738 rest_octets := *
739 }
740 }
741 };
742
743
Harald Weltecbc947f2018-02-22 00:26:55 +0100744 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
745 uint3_t rxq_f, uint3_t rxq_s,
746 template (omit) NcellReports reps) := {
747 header := t_RrL3Header(MEASUREMENT_REPORT),
748 payload := {
749 meas_rep := {
750 meas_res := {
751 ba_used := '0'B,
752 dtx_used := '0'B,
753 rxlev_full_srv_cell := rxl_f,
754 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +0100755 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +0100756 rxlev_sub_srv_cell := rxl_s,
757 si23_ba_used := '0'B,
758 rxqual_full_srv_cell := rxq_f,
759 rxqual_sub_srv_cell := rxq_s,
760 no_ncell_m := 0,
761 ncell_reports := reps
762 }
763 }
764 }
765 };
766
Harald Welteb669ee02018-03-09 12:50:02 +0100767 template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
768 ded_or_tbf := {
769 spare := ?,
770 tma := ?,
771 downlink := ?,
772 tbf := true
773 },
774 page_mode := ?,
775 chan_desc := omit,
776 pkt_chan_desc := {
777 channel_Type_spare := ?,
778 tn := ?,
779 tsc := ?,
780 presence := ?,
781 zero := *,
782 one := omit
783 },
784 req_ref := ?,
785 timing_advance := ?,
786 mobile_allocation := ?,
787 rest_octets := {
788 presence := '11'B,
789 ll := omit,
790 lh := omit,
791 hl := omit,
792 hh := {
793 presence := '01'B,
794 ul := omit,
795 dl := {
796 tlli := tlli,
797 group1_present := ?,
798 group1 := *,
799 ta_index_present := ?,
800 ta_index := *,
801 tbf_starting_time_present := ?,
802 tbf_starting_time := *,
803 p0_present := ?,
804 p0 := *,
805 pr_mode := *
806 }
807 }
808 }
809 };
810
811 template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
812 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
813 payload := {
814 imm_ass := t_IMM_ASS_TBF_DL(tlli)
815 }
816 };
817
Harald Weltecbc947f2018-02-22 00:26:55 +0100818
819
Harald Welte9419c8a2017-07-30 04:07:05 +0200820} with { encode "RAW" ; variant "FIELDORDER(msb)" }