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