blob: 457f0f543e521a40cc037437f21b9ce726b197e9 [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,
546 IaRestOctHH hh optional
547 } 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)"
552 };
553
Harald Weltecbc947f2018-02-22 00:26:55 +0100554 type record MeasurementResults {
555 BIT1 ba_used,
556 BIT1 dtx_used,
557 uint6_t rxlev_full_srv_cell,
558 BIT1 threeg_ba_used,
559 BIT1 meas_valid,
560 uint6_t rxlev_sub_srv_cell,
561 BIT1 si23_ba_used,
562 uint3_t rxqual_full_srv_cell,
563 uint3_t rxqual_sub_srv_cell,
564 uint3_t no_ncell_m,
565 NcellReports ncell_reports optional
566 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
567 variant (no_ncell_m) "UNIT(elements)"
568 variant "PADDING(yes)"
569 variant "FIELDLENGTH(16)"
570 };
571
572 type record NcellReport {
573 uint6_t rxlev,
574 uint5_t bcch_freq,
575 uint6_t bsic
576 } with { variant ""};
577 type record of NcellReport NcellReports;
578
Harald Welte9419c8a2017-07-30 04:07:05 +0200579
580 /* 9.1.18 */
581 type record ImmediateAssignment {
582 DedicatedModeOrTbf ded_or_tbf,
583 PageMode page_mode,
584 ChannelDescription chan_desc optional,
585 PacketChannelDescription pkt_chan_desc optional,
586 RequestReference req_ref,
587 TimingAdvance timing_advance,
588 MobileAllocation mobile_allocation,
589 /* TODO: starting time TLV */
Harald Weltecbc947f2018-02-22 00:26:55 +0100590 IaRestOctets rest_octets optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200591 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
592 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
593
594 /* 9.1.20 */
595 type record ReqRefWaitInd {
596 RequestReference req_ref,
597 WaitIndication wait_ind
598 } with { variant "" };
599 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
600 type record ImmediateAssignmentReject {
601 FeatureIndicator feature_ind,
602 PageMode page_mode,
603 ReqRefWaitInd4 payload
604 } with { variant "" };
605
Harald Weltecbc947f2018-02-22 00:26:55 +0100606 /* 9.1.21 */
607 type record MeasurementReport {
608 MeasurementResults meas_res
609 } with { variant "" };
610
Harald Welte9419c8a2017-07-30 04:07:05 +0200611 /* 9.1.22 */
612 type record PagingRequestType1 {
613 ChannelNeeded12 chan_needed,
614 PageMode page_mode,
615 MobileIdentityLV mi1,
616 MobileIdentityTLV mi2 optional,
617 RestOctets rest_octets
618 } with { variant "TAG(mi2, tag = 23)" };
619
620 /* 9.1.23 */
621 type record PagingRequestType2 {
622 ChannelNeeded12 chan_needed,
623 PageMode page_mode,
624 GsmTmsi mi1,
625 GsmTmsi mi2,
626 MobileIdentityTLV mi3 optional,
627 RestOctets rest_octets
628 } with { variant "TAG(mi3, tag = 23)" };
629
630 /* 9.1.24 */
631 type record length(4) of GsmTmsi GsmTmsi4;
632 type record PagingRequestType3 {
633 ChannelNeeded12 chan_needed,
634 PageMode page_mode,
635 GsmTmsi4 mi,
636 RestOctets rest_octets
637 } with { variant "" };
638
Harald Welte9419c8a2017-07-30 04:07:05 +0200639 type union RrUnion {
640/*
641 SystemInformationType1 si1,
642 SystemInformationType2 si2,
643 SystemInformationType2bis si2bis,
644 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100645 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200646 SystemInformationType4 si4,
647 SystemInformationType5 si5,
648 SystemInformationType5bis si5bis,
649 SystemInformationType5ter si5ter,
650 SystemInformationType6 si6,
651*/
652 ImmediateAssignment imm_ass,
653 ImmediateAssignmentReject imm_ass_rej,
654 PagingRequestType1 pag_req_1,
655 PagingRequestType2 pag_req_2,
656 PagingRequestType3 pag_req_3,
657 octetstring other
658 } with { variant "" };
659
660 /* Special RR Message on BCCH / CCCH Dowlink */
661
662 type record GsmRrMessage {
663 RrHeader header,
664 RrUnion payload
665 } with { variant (payload) "CROSSTAG(
666/*
667 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
668 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
669 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
670 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
671 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
672 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
673 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
674 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
675 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
676 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
677*/
678 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
679 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
680 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
681 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
682 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
683 other, OTHERWISE;
684 )" };
685
686 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
687 with { extension "prototype(convert) encode(RAW)" };
688 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
689 with { extension "prototype(convert) decode(RAW)" };
690
691 /* Normal L3 Message on Dedicated Channel */
692
693 /* 9.1.25 Paging Response */
694 type record PagingResponse {
695 uint4_t spare_half_octet,
696 CipheringKeySeqNr cksn,
697 MsClassmark2LV cm2,
698 MobileIdentityLV mi,
699 uint8_t addl_upd_par optional
700 } with { variant "" };
701
702 type union RrL3Union {
703 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100704 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200705 octetstring other
706 };
707
708 type record GsmRrL3Message {
709 RrL3Header header,
710 RrL3Union payload
711 } with { variant (payload) "CROSSTAG(
712 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100713 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200714 other, OTHERWISE;
715 )" }
716
Harald Weltecbc947f2018-02-22 00:26:55 +0100717 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
718 with { extension "prototype(convert) encode(RAW)" };
719 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
720 with { extension "prototype(convert) decode(RAW)" };
721
722
Harald Weltee8d750e2018-06-10 21:41:35 +0200723 template (value) GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
Harald Weltecbc947f2018-02-22 00:26:55 +0100724 ChannelDescription ch_desc, MobileAllocation ma) := {
725 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
726 payload := {
727 imm_ass := {
728 ded_or_tbf := {
729 spare := '0'B,
730 tma := false,
731 downlink := false,
732 tbf := false
733 },
734 page_mode := PAGE_MODE_NORMAL,
735 chan_desc := ch_desc,
736 pkt_chan_desc := omit,
737 req_ref := f_compute_ReqRef(ra, fn),
738 timing_advance := ta,
739 mobile_allocation := ma,
740 rest_octets := omit
741 }
742 }
743 };
744
Harald Weltee8d750e2018-06-10 21:41:35 +0200745 template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?,
746 template TimingAdvance ta := ?,
747 template ChannelDescription ch_desc := ?,
748 template MobileAllocation ma := ?) := {
749 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
750 payload := {
751 imm_ass := {
752 ded_or_tbf := {
753 spare := '0'B,
754 tma := false,
755 downlink := false,
756 tbf := false
757 },
758 page_mode := PAGE_MODE_NORMAL,
759 chan_desc := ch_desc,
760 pkt_chan_desc := omit,
761 req_ref := tr_compute_ReqRef(ra, fn),
762 timing_advance := ta,
763 mobile_allocation := ma,
764 rest_octets := *
765 }
766 }
767 };
768
769
Harald Weltecbc947f2018-02-22 00:26:55 +0100770 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
771 uint3_t rxq_f, uint3_t rxq_s,
772 template (omit) NcellReports reps) := {
773 header := t_RrL3Header(MEASUREMENT_REPORT),
774 payload := {
775 meas_rep := {
776 meas_res := {
777 ba_used := '0'B,
778 dtx_used := '0'B,
779 rxlev_full_srv_cell := rxl_f,
780 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +0100781 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +0100782 rxlev_sub_srv_cell := rxl_s,
783 si23_ba_used := '0'B,
784 rxqual_full_srv_cell := rxq_f,
785 rxqual_sub_srv_cell := rxq_s,
786 no_ncell_m := 0,
787 ncell_reports := reps
788 }
789 }
790 }
791 };
792
Harald Welteb669ee02018-03-09 12:50:02 +0100793 template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
794 ded_or_tbf := {
795 spare := ?,
796 tma := ?,
797 downlink := ?,
798 tbf := true
799 },
800 page_mode := ?,
801 chan_desc := omit,
802 pkt_chan_desc := {
803 channel_Type_spare := ?,
804 tn := ?,
805 tsc := ?,
806 presence := ?,
807 zero := *,
808 one := omit
809 },
810 req_ref := ?,
811 timing_advance := ?,
812 mobile_allocation := ?,
813 rest_octets := {
814 presence := '11'B,
815 ll := omit,
816 lh := omit,
817 hl := omit,
818 hh := {
819 presence := '01'B,
820 ul := omit,
821 dl := {
822 tlli := tlli,
823 group1_present := ?,
824 group1 := *,
825 ta_index_present := ?,
826 ta_index := *,
827 tbf_starting_time_present := ?,
828 tbf_starting_time := *,
829 p0_present := ?,
830 p0 := *,
831 pr_mode := *
832 }
833 }
834 }
835 };
836
837 template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := {
838 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
839 payload := {
840 imm_ass := t_IMM_ASS_TBF_DL(tlli)
841 }
842 };
843
Harald Weltecbc947f2018-02-22 00:26:55 +0100844
845
Harald Welte9419c8a2017-07-30 04:07:05 +0200846} with { encode "RAW" ; variant "FIELDORDER(msb)" }