blob: 76b03a919a8a1bce94b3d6beae296c36f73ea300 [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;
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +070019 import from MobileL3_CommonIE_Types all;
Harald Welte9419c8a2017-07-30 04:07:05 +020020
21 /* Table 10.4.1 of Section 10.4 / 3GPP TS 44.018 */
22 type enumerated RrMessageType {
23 ADDITIONAL_ASSIGNMENT ('00111011'B),
24 IMMEDIATE_ASSIGNMENT ('00111111'B),
25 IMMEDIATE_ASSIGNMENT_EXTENDED ('00111001'B),
26 IMMEDIATE_ASSIGNMENT_REJECT ('00111010'B),
27 IMMEDIATE_PACKET_ASSIGNMENT ('01101001'B),
28
29 CIPHERING_MODE_COMMAND ('00110101'B),
30 CIPHERING_MODE_COMPLETE ('00110010'B),
31
32 CONFIGURATION_CHANGE_COMMAND ('00110000'B),
33 CONFIGURATION_CHANGE_ACK ('00110001'B),
34 CONFIGURATION_CHANGE_REJECT ('00110011'B),
35
36 ASSIGNMENT_COMMAND ('00101110'B),
37 ASSIGNMENT_COMPLETE ('00101001'B),
38 ASSIGNMENT_FAILURE ('00101111'B),
39 HANDOVER_COMMAND ('00101011'B),
40 HANDOVER_COMPLETE ('00101100'B),
41 HANDOVER_FAILURE ('00101000'B),
42 PHYSICAL_INFORMATION ('00101101'B),
43
44 CHANNEL_RELEASE ('00001101'B),
45 PARTIAL_RELEASE ('00001010'B),
46 PARTIAL_RELEASE_COMPLETE ('00001111'B),
47
48 PAGING_REQUEST_TYPE_1 ('00100001'B),
49 PAGING_REQUEST_TYPE_2 ('00100010'B),
50 PAGING_REQUEST_TYPE_3 ('00100100'B),
51 PAGING_RESPONSE ('00100111'B),
52 NOTIFICATION_NCH ('00100000'B),
53 NOTIFICATION_RESPOSNE ('00100110'B),
54
55 SYSTEM_INFORMATION_TYPE_8 ('00011000'B),
56 SYSTEM_INFORMATION_TYPE_1 ('00011001'B),
57 SYSTEM_INFORMATION_TYPE_2 ('00011010'B),
58 SYSTEM_INFORMATION_TYPE_3 ('00011011'B),
59 SYSTEM_INFORMATION_TYPE_4 ('00011100'B),
60 SYSTEM_INFORMATION_TYPE_5 ('00011101'B),
61 SYSTEM_INFORMATION_TYPE_6 ('00011110'B),
62 SYSTEM_INFORMATION_TYPE_7 ('00011111'B),
63 SYSTEM_INFORMATION_TYPE_2bis ('00000010'B),
64 SYSTEM_INFORMATION_TYPE_2ter ('00000011'B),
65 SYSTEM_INFORMATION_TYPE_2quater ('00000111'B),
66 SYSTEM_INFORMATION_TYPE_5bis ('00000101'B),
67 SYSTEM_INFORMATION_TYPE_5ter ('00000110'B),
68 SYSTEM_INFORMATION_TYPE_9 ('00000100'B),
69 SYSTEM_INFORMATION_TYPE_13 ('00000000'B),
70
71 SYSTEM_INFORMATION_TYPE_16 ('00111101'B),
72 SYSTEM_INFORMATION_TYPE_17 ('00111110'B),
73
74 CHANNEL_MODE_MODIFY ('00010000'B),
75 RR_STATUS ('00010010'B),
76 CHANNEL_MODE_MODIFY_ACKNOWLEDGE ('00010111'B),
77 FREQUENCY_REDEFINITION ('00010100'B),
78 MEASUREMENT_REPORT ('00010101'B),
79 CLASSMARK_CHANGE ('00010110'B),
80 CLASSMARK_ENQUIRY ('00010011'B),
81 EXTENDED_MEASUREMENT_REPORT ('00110110'B),
82 EXTENDED_MEASUREMENT_ORDER ('00110111'B),
83 GPRS_SUSPENSION_REQUEST ('00110100'B),
84 //MBMS_ANNOUNCEMENT ('00010110'B), duplicate?
85 //SERVICE_INFORMATION ('00110110'B), duplicate?
86
87 APPLICATION_INFORMATION ('00111000'B),
88
89 SYSTEM_INFORMATION_TYPE_14 ('00000001'B),
90 SYSTEM_INFORMATION_TYPE_15 ('01000011'B),
91 SYSTEM_INFORMATION_TYPE_18 ('01000000'B),
92 SYSTEM_INFORMATION_TYPE_19 ('01000001'B),
93 SYSTEM_INFORMATION_TYPE_20 ('01000010'B),
94 SYSTEM_INFORMATION_TYPE_13alt ('01000100'B),
95 SYSTEM_INFORMATION_TYPE_2n ('01000101'B),
96 SYSTEM_INFORMATION_TYPE_21 ('01000110'B),
97 SYSTEM_INFORMATION_TYPE_22 ('01000111'B),
98 SYSTEM_INFORMATION_TYPE_23 ('01001111'B),
99
100 DTM_ASSIGNMENT_FAILURE ('01001000'B),
101 DTM_REJECT ('01001001'B),
102 DTM_REQUEST ('01001010'B),
103 PACKET_ASSIGNMENT ('01001011'B),
104 DTM_ASSIGNMENT_COMMAND ('01001100'B),
105 DTM_INFORMATION ('01001101'B),
106 PACKET_INFORMATION ('01001110'B),
107
108 UTRAN_CLASSMARK_CHANGE ('01100000'B),
109 CDMA2000_CLASSMARK_CHANGE ('01100010'B),
110 INTERSYS_TO_UTRAN_HO_CMD ('01100011'B),
111 INTERSYS_TO_CDMA2000_HO_CMD ('01100100'B),
112 GERAN_IU_MODE_CLASSMARK_CHG ('01100101'B),
113 INTERSYS_TO_EUTRAN_HO_CMD ('01100110'B)
114 } with { variant "FIELDLENGTH(8)" };
115
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +0200116 type enumerated RR_Cause {
117 GSM48_RR_CAUSE_NORMAL ('00'O),
118 GSM48_RR_CAUSE_ABNORMAL_UNSPEC ('01'O),
119 GSM48_RR_CAUSE_ABNORMAL_UNACCT ('02'O),
120 GSM48_RR_CAUSE_ABNORMAL_TIMER ('03'O),
121 GSM48_RR_CAUSE_ABNORMAL_NOACT ('04'O),
122 GSM48_RR_CAUSE_PREMPTIVE_REL ('05'O),
123 GSM48_RR_CAUSE_HNDOVER_IMP ('08'O),
124 GSM48_RR_CAUSE_CHAN_MODE_UNACCT ('09'O),
125 GSM48_RR_CAUSE_FREQ_NOT_IMPL ('0a'O),
126 GSM48_RR_CAUSE_CALL_CLEARED ('41'O),
127 GSM48_RR_CAUSE_SEMANT_INCORR ('5f'O),
128 GSM48_RR_CAUSE_INVALID_MAND_INF ('60'O),
129 GSM48_RR_CAUSE_MSG_TYPE_N ('61'O),
130 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT('62'O),
131 GSM48_RR_CAUSE_COND_IE_ERROR ('64'O),
132 GSM48_RR_CAUSE_NO_CELL_ALLOC_A ('65'O),
133 GSM48_RR_CAUSE_PROT_ERROR_UNSPC ('6f'O)
134 } with { variant "FIELDLENGTH(8)" };
135
Harald Welte9419c8a2017-07-30 04:07:05 +0200136 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
137 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
138 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
139
140 type record L2PseudoLength {
141 uint6_t l2_plen,
142 BIT2 zero_one
143 } with { variant "" };
144
Harald Weltef8df4cb2018-03-10 15:15:08 +0100145 template L2PseudoLength tr_L2Pseudolength(template uint6_t len) := {
146 l2_plen := len,
147 zero_one := '01'B
148 };
149
150 template (value) L2PseudoLength ts_L2Pseudolength(uint6_t len) := {
Harald Welte9419c8a2017-07-30 04:07:05 +0200151 l2_plen := len,
152 zero_one := '01'B
153 };
154
155 type record RrHeader {
156 L2PseudoLength l2_plen,
157 uint4_t skip_indicator,
158 uint4_t rr_protocol_discriminator,
159 RrMessageType message_type
160 } with { variant "" };
161
162 template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100163 l2_plen := tr_L2Pseudolength(len),
Harald Welte9419c8a2017-07-30 04:07:05 +0200164 skip_indicator := 0,
165 rr_protocol_discriminator := 6,
166 message_type := msg_type
167 };
168
Harald Weltef8df4cb2018-03-10 15:15:08 +0100169 template (value) RrHeader ts_RrHeader(RrMessageType msg_type, uint6_t len) := {
170 l2_plen := ts_L2Pseudolength(len),
171 skip_indicator := 0,
172 rr_protocol_discriminator := 6,
173 message_type := msg_type
174 };
175
176
Harald Welte9419c8a2017-07-30 04:07:05 +0200177 type record RrL3Header {
178 uint4_t skip_indicator,
179 uint4_t rr_protocol_discriminator,
180 RrMessageType message_type
181 } with { variant "" };
182
Harald Weltecbc947f2018-02-22 00:26:55 +0100183 template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
184 skip_indicator := 0,
185 rr_protocol_discriminator := 6,
186 message_type := msg_type
187 }
188
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200189 /* TS 44.004 7.2.1 */
190 type record SacchL1Header {
191 uint2_t reserved,
192 boolean fpc,
193 uint5_t ms_power_lvl,
194 uint8_t actual_ta
195 } with { variant "FIELDORDER(msb)" };
196
197 template (value) SacchL1Header ts_SacchL1Header(uint5_t ms_power_lvl, boolean fpc, uint8_t actual_ta) := {
198 reserved := 0,
199 fpc := fpc,
200 ms_power_lvl := ms_power_lvl,
201 actual_ta := actual_ta
202 };
203
Harald Welte9419c8a2017-07-30 04:07:05 +0200204 type record MaioHsn {
Vadim Yanitskiyff0072c2020-05-27 01:35:39 +0700205 uint6_t maio,
206 uint6_t hsn
Harald Welte9419c8a2017-07-30 04:07:05 +0200207 } with { variant "" };
208
Vadim Yanitskiy5bcd9192020-07-06 20:18:11 +0700209 /* It's more handy to pass HSN first, so the arguments' order is reversed. */
210 template (value) MaioHsn ts_HsnMaio(template (value) uint6_t hsn,
211 template (value) uint6_t maio) := {
212 maio := maio,
213 hsn := hsn
214 };
215 template MaioHsn tr_HsnMaio(template (present) uint6_t hsn,
216 template (present) uint6_t maio) := {
217 maio := maio,
218 hsn := hsn
219 };
220
Harald Welte9419c8a2017-07-30 04:07:05 +0200221 /* TS 24.008 10.5.1.1 */
222 type uint16_t CellIdentity;
223
224 /* TS 24.008 10.5.1.2 */
225 type uint4_t CipheringKeySeqNr (0..7);
226
227 /* 24.008 10.5.1.3 */
228 type record LocationAreaIdentification {
229 BcdMccMnc mcc_mnc,
230 uint16_t lac
Vadim Yanitskiye05d7162020-05-02 16:58:46 +0700231 } with { variant "" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200232
233 /* TS 24.008 10.5.1.4 */
234 type enumerated MobileIdentityType {
235 MI_TYPE_NONE (0),
236 MI_TYPE_IMSI,
237 MI_TYPE_IMEI,
238 MI_TYPE_IMEISV,
239 MI_TYPE_TMSI,
240 MI_TYPE_TMGI
241 } with { variant "FIELDLENGTH(3)" };
242
Harald Welte9419c8a2017-07-30 04:07:05 +0200243 /* TS 24.008 10.5.1.5 */
244 type record MsClassmark1 {
245 BIT1 spare,
246 uint2_t rev_level,
247 boolean es_ind,
248 boolean a51,
249 uint3_t rf_pwr_cap
250 } with { variant "" };
251
252 /* TS 24.008 10.5.1.6 */
253 type record MsClassmark2 {
254 BIT1 spare,
255 uint2_t rev_level,
256 boolean es_ind,
257 boolean a51,
258 uint3_t rf_pwr_cap,
259 BIT1 spare1,
260 boolean ps_cap,
261 uint2_t ss_screen_ind,
262 boolean sm_cap,
263 boolean vbs,
264 boolean vgcs,
265 boolean fc,
266 boolean cm3,
267 BIT1 spare2,
268 boolean lcsva_cap,
269 boolean ucs2,
270 boolean solsa,
271 boolean cmsp,
272 boolean a53,
273 boolean a52
274 } with { variant "" };
275 type record MsClassmark2LV {
276 uint8_t len,
277 MsClassmark2 cm2
278 } with { variant (len) "LENGTHTO(cm2)" };
279
280
281 /* 44.018 10.5.2.5 */
282 type record ChannelDescription {
283 RslChannelNr chan_nr,
284 uint3_t tsc,
285 boolean h,
286 uint12_t arfcn optional,
287 MaioHsn maio_hsn optional
288 } with { variant (arfcn) "PRESENCE(h = false)"
289 variant (maio_hsn) "PRESENCE(h = true)" };
290
291 type record ChannelDescriptionTV {
292 OCT1 iei,
293 ChannelDescription v
294 } with { variant "" };
295
296 /* 10.5.2.21 */
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +0700297 type record MobileAllocationLV {
Harald Welte9419c8a2017-07-30 04:07:05 +0200298 uint8_t len,
299 bitstring ma
Vadim Yanitskiy3ddb3ab2020-07-20 04:29:53 +0700300 } with {
301 variant (len) "LENGTHTO(ma)"
Vadim Yanitskiye2a6fdf2020-07-23 04:53:02 +0700302 variant (ma) "BYTEORDER(first), BITORDER(msb)"
Vadim Yanitskiy3ddb3ab2020-07-20 04:29:53 +0700303 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200304
Vadim Yanitskiy74e1f6b2020-08-25 03:59:45 +0700305 type record MobileAllocationTLV {
306 OCT1 iei ('72'O),
307 MobileAllocationLV v
308 } with { variant "" };
309
Harald Welte9419c8a2017-07-30 04:07:05 +0200310 /* 10.5.2.25a */
Harald Welte1b9b7702017-07-30 04:19:14 +0200311 type record PktChDesc0Ind {
312 uint6_t maio,
313 BIT1 ma_number_ind,
314 BIT1 change_mark1_valid,
315 BIT2 change_mark1
316 } with { variant "" };
317 type record PktChDesc0 {
318 BIT1 hopping,
319 BIT1 spare ('0'B),
320 uint10_t arfcn optional,
321 PktChDesc0Ind indirect optional
322 } with {
323 variant (arfcn) "PRESENCE(hopping = '0'B)"
324 variant (indirect) "PRESENCE(hopping = '1'B)"
325 };
326 type record PktChDesc1 {
327 uint6_t maio,
328 uint6_t hsn
329 } with { variant "" };
330 type record PacketChannelDescription {
331 uint5_t channel_Type_spare,
332 uint3_t tn,
333 uint3_t tsc,
334 BIT1 presence,
335 PktChDesc0 zero optional,
336 PktChDesc1 one optional
337 } with {
338 variant (zero) "PRESENCE(presence = '0'B)"
339 variant (one) "PRESENCE(presence = '1'B)"
340 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200341
342 /* 10.5.2.25b */
343 type record DedicatedModeOrTbf {
344 BIT1 spare,
345 boolean tma,
346 boolean downlink,
347 boolean tbf
348 } with { variant "" };
349
350 /* 10.5.2.26 */
351 type enumerated PageMode {
352 PAGE_MODE_NORMAL,
353 PAGE_MODE_EXTENDED,
354 PAGE_MODE_REORGANIZATION,
355 PAGE_MODE_SAME_AS_BEFORE
356 } with { variant "FIELDLENGTH(4)" };
357
358 /* 10.5.2.30 */
359 type record RequestReference {
360 bitstring ra length(8),
361 uint5_t t1p,
362 uint6_t t3,
363 uint5_t t2
364 } with { variant "" };
365
366 template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := {
367 ra := ra,
368 t1p := t1p,
369 t3 := t3,
370 t2 := t2
371 }
372
373 /* compute the expected request reference for given RA + FN */
374 function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference {
375 var RequestReference req_ref := { ra := int2bit(ra, 8) };
376 req_ref.t1p := (fn / 1326) mod 32;
377 req_ref.t2 := fn mod 26;
378 req_ref.t3 := fn mod 51;
379 return req_ref
380 }
Harald Weltee8d750e2018-06-10 21:41:35 +0200381 function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn)
382 return template RequestReference {
383 var template RequestReference req_ref;
384 if (istemplatekind(ra, "?")) {
385 req_ref.ra := ?;
386 } else {
387 req_ref.ra := int2bit(valueof(ra), 8);
388 }
389 if (istemplatekind(fn, "?")) {
390 req_ref.t1p := ?;
391 req_ref.t2 := ?;
392 req_ref.t3 := ?;
393 } else {
394 var GsmFrameNumber fn_v := valueof(fn);
395 req_ref.t1p := (fn_v / 1326) mod 32;
396 req_ref.t2 := fn_v mod 26;
397 req_ref.t3 := fn_v mod 51;
398 }
399 return req_ref;
400 }
Harald Welte9419c8a2017-07-30 04:07:05 +0200401
402 /* 10.5.2.40 */
403 type integer TimingAdvance (0..219);
404
405 /* 10.5.2.43 */
406 type uint8_t WaitIndication;
407
408 /* 10.5.2.76 */
409 type record FeatureIndicator {
Vadim Yanitskiyc3cebd32020-05-22 02:43:22 +0700410 BIT2 peo_bcch_change_mark,
411 boolean cs_ir,
412 boolean ps_ir
413 } with {
414 variant (cs_ir) "FIELDLENGTH(1)"
415 variant (ps_ir) "FIELDLENGTH(1)"
416 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200417
418 /* 24.008 10.5.5.6 */
419 type record DrxParameter {
420 uint8_t split_pg_cycle_code,
421 uint4_t drx_cycle_len_coeff,
422 boolean split_on_ccch,
423 uint3_t non_drx_timer
424 } with { variant "" };
425
426 /* 24.008 10.5.5.15 */
427 type record RoutingAreaIdentification {
428 LocationAreaIdentification lai,
429 uint8_t rac
430 } with { variant "" };
431
Harald Welteb16516c2019-03-21 21:31:41 +0100432 external function enc_RoutingAreaIdentification(RoutingAreaIdentification rai) return octetstring
433 with { extension "prototype(convert)" extension "encode(RAW)" }
434
Harald Welte9419c8a2017-07-30 04:07:05 +0200435 /* 44.018 10.5.2.16 */
436 type record IaRestOctHL {
437 uint6_t freq_par_len,
438 BIT2 padding ('00'B) optional,
439 uint6_t maio optional,
440 octetstring mobile_allocation optional
441 } with {
442 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
443/*
444 variant (padding) "PRESENCE(freq_par_len != 0)"
445 variant (maio) "PRESENCE(freq_par_len != 0)"
446 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
447*/
448 };
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200449 type record SecondPartAssign {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700450 BIT1 r99, /* L / H */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200451 BIT1 presence optional,
452 BIT5 ext_ra optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200453 } with {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700454 variant (r99) "CSN.1 L/H"
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200455 variant (presence) "PRESENCE(r99 = '1'B)" /* H */
456 variant (ext_ra) "PRESENCE(presence = '1'B)"
Vadim Yanitskiye05d7162020-05-02 16:58:46 +0700457 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562488 */
458 variant (ext_ra) "BYTEORDER(last)" // FIXME: should be first
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200459 };
460 type union PacketUlDlAssignUnion {
461 PacketUlAssign ul,
462 PacketDlAssign dl
463 };
464 type record PacketUlDlAssign {
465 BIT1 ass_disc,
466 PacketUlDlAssignUnion ass
467 } with {
468 variant (ass) "CROSSTAG(dl, ass_disc = '1'B; ul, ass_disc = '0'B)"
469 };
470 type union PacketAssignUnion {
471 SecondPartAssign spa,
472 PacketUlDlAssign uldl
473 };
474 type record IaRestOctHH {
475 /* Packet Assignment discriminator:
476 * Packet Uplink / Downlink Assignment (0)
477 * Second Part Packet Assignment (1) */
478 BIT1 pa_disc,
479 PacketAssignUnion pa
480 } with {
481 variant (pa) "CROSSTAG(spa, pa_disc = '1'B; uldl, pa_disc = '0'B)"
Harald Welte9419c8a2017-07-30 04:07:05 +0200482 };
483 type record PacketUlAssignDyn {
484 uint5_t tfi_assignment,
485 BIT1 polling,
486 BIT1 spare ('0'B),
487 uint3_t usf,
488 BIT1 usf_granularity,
489 BIT1 p0_present,
490 uint4_t p0 optional,
491 BIT1 pr_mode optional,
492 ChCodingCommand ch_coding_cmd,
493 BIT1 tlli_block_chan_coding,
494 BIT1 alpha_present,
495 uint4_t alpha optional,
496 uint5_t gamma,
497 BIT1 ta_index_present,
498 uint4_t ta_index optional,
499 BIT1 tbf_starting_time_present,
500 uint16_t tbf_starting_time optional
501 } with {
502 variant (p0) "PRESENCE(p0_present = '1'B)"
503 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
504 variant (alpha) "PRESENCE(alpha_present = '1'B)"
505 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
506 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
507 };
508 type record PacketUlAssignSgl {
509 BIT1 alpha_present,
510 uint4_t alpha optional,
511 uint5_t gamma,
512 BIT2 padding ('01'B),
513 uint16_t tbf_starting_time
514 /* TODO: P0 / PR_MODE */
515 } with {
516 variant (alpha) "PRESENCE(alpha_present = '1'B)"
517 };
518 type record PacketUlAssign {
519 BIT1 presence,
520 PacketUlAssignDyn dynamic optional,
521 PacketUlAssignSgl single optional
522 /* TODO: Estended RA, PFI */
523 } with {
524 variant (dynamic) "PRESENCE(presence = '1'B)"
525 variant (single) "PRESENCE(presence = '0'B)"
526 };
527 type record PacketDlAssG1 {
528 uint5_t tfi_assignment,
529 BIT1 rlc_mode,
530 BIT1 alpha_present,
531 uint4_t alpha optional,
532 uint5_t gamma,
533 BIT1 polling,
534 BIT1 ta_valid
535 } with { variant "" };
536 type record PacketDlAssign {
537 GprsTlli tlli,
538 BIT1 group1_present,
539 PacketDlAssG1 group1 optional,
540 BIT1 ta_index_present,
541 uint4_t ta_index optional,
542 BIT1 tbf_starting_time_present,
543 uint16_t tbf_starting_time optional,
544 BIT1 p0_present,
545 uint4_t p0 optional,
546 BIT1 pr_mode optional
547 /* TODO: EGPRS window size, etc. */
548 } with {
549 variant (group1) "PRESENCE(group1_present = '1'B)"
550 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
551 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
552 variant (p0) "PRESENCE(p0_present = '1'B)"
553 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
554 };
555 type record IaRestOctLL {
556 BIT1 compressed_irat_ho_info_ind
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700557 } with {
558 variant (compressed_irat_ho_info_ind) "CSN.1 L/H"
559 };
Pau Espin Pedrol461ed612019-12-30 20:18:34 +0100560 type record EgprsUlAssignDyn {
561 uint5_t tfi_assignment,
562 BIT1 polling,
563 BIT1 spare ('0'B),
564 uint3_t usf,
565 BIT1 usf_granularity,
566 BIT1 p0_present,
567 uint4_t p0 optional,
568 BIT1 pr_mode optional,
569 EgprsChCodingCommand egprs_ch_coding_cmd,
570 BIT1 tlli_block_chan_coding,
571 BIT1 bep_period2_present,
572 BIT4 bep_period2 optional,
573 BIT1 resegment,
574 EgprsWindowSize egprs_window_size,
575 BIT1 alpha_present,
576 uint4_t alpha optional,
577 uint5_t gamma,
578 BIT1 ta_index_present,
579 uint4_t ta_index optional,
580 BIT1 tbf_starting_time_present,
581 uint16_t tbf_starting_time optional
582 /* TODO: Additions for Rel-7 */
583 } with {
584 variant (p0) "PRESENCE(p0_present = '1'B)"
585 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
586 variant (bep_period2) "PRESENCE(bep_period2_present = '1'B)"
587 variant (alpha) "PRESENCE(alpha_present = '1'B)"
588 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
589 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
590 };
591 type record EgprsUlAssignMultiblock {
592 BIT1 alpha_present,
593 uint4_t alpha optional,
594 uint5_t gamma,
595 uint16_t tbf_starting_time,
596 BIT2 nr_radio_blocks_allocated,
597 BIT1 p0_present,
598 uint4_t p0 optional,
599 BIT1 spare ('0'B) optional,
600 BIT1 pr_mode optional
601 /* TDO: Additions for Rel-6 */
602 } with {
603 variant (alpha) "PRESENCE(alpha_present = '1'B)"
604 variant (p0) "PRESENCE(p0_present = '1'B)"
605 variant (spare) "PRESENCE(p0_present = '1'B)"
606 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
607 };
608 /* 3GPP TS 44.018 version 13.3.2 10.5.2.16, "EGPRS Packet Uplink Assignment" */
609 type record EgprsUlAss {
610 BIT5 ext_ra,
611 BIT1 ats_present,
612 AccessTechnologiesRequestRepetition ats optional,
613 BIT1 presence,
614 EgprsUlAssignDyn dynamic optional,
615 EgprsUlAssignMultiblock multiblock optional
616 } with {
617 variant (ats) "PRESENCE(ats_present = '1'B)"
618 variant (dynamic) "PRESENCE(presence = '1'B)"
619 variant (multiblock) "PRESENCE(presence = '0'B)"
Vadim Yanitskiye05d7162020-05-02 16:58:46 +0700620 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562488 */
621 variant (ext_ra) "BYTEORDER(last)" // FIXME: should be first
Pau Espin Pedrol461ed612019-12-30 20:18:34 +0100622 };
623
Harald Welte9419c8a2017-07-30 04:07:05 +0200624 type octetstring MblkDlAss; /* TODO */
625 type record IaRestOctLH {
626 BIT2 presence,
627 EgprsUlAss egprs_ul optional,
628 MblkDlAss multiblock_dl_ass optional
629 } with {
630 variant (egprs_ul) "PRESENCE(presence = '00'B)"
631 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
632 };
633 type record IaRestOctets {
634 BIT2 presence,
635 IaRestOctLL ll optional,
636 IaRestOctLH lh optional,
637 IaRestOctHL hl optional,
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200638 IaRestOctHH hh optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200639 } with {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700640 variant (presence) "CSN.1 L/H"
Harald Welte9419c8a2017-07-30 04:07:05 +0200641 variant (ll) "PRESENCE(presence = '00'B)"
642 variant (lh) "PRESENCE(presence = '01'B)"
643 variant (hl) "PRESENCE(presence = '10'B)"
644 variant (hh) "PRESENCE(presence = '11'B)"
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200645 variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
Harald Welte9419c8a2017-07-30 04:07:05 +0200646 };
647
Harald Weltecbc947f2018-02-22 00:26:55 +0100648 type record MeasurementResults {
649 BIT1 ba_used,
650 BIT1 dtx_used,
651 uint6_t rxlev_full_srv_cell,
652 BIT1 threeg_ba_used,
653 BIT1 meas_valid,
654 uint6_t rxlev_sub_srv_cell,
655 BIT1 si23_ba_used,
656 uint3_t rxqual_full_srv_cell,
657 uint3_t rxqual_sub_srv_cell,
658 uint3_t no_ncell_m,
659 NcellReports ncell_reports optional
660 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
661 variant (no_ncell_m) "UNIT(elements)"
662 variant "PADDING(yes)"
663 variant "FIELDLENGTH(16)"
664 };
665
666 type record NcellReport {
667 uint6_t rxlev,
668 uint5_t bcch_freq,
669 uint6_t bsic
670 } with { variant ""};
671 type record of NcellReport NcellReports;
672
Harald Welte9419c8a2017-07-30 04:07:05 +0200673
674 /* 9.1.18 */
675 type record ImmediateAssignment {
676 DedicatedModeOrTbf ded_or_tbf,
677 PageMode page_mode,
678 ChannelDescription chan_desc optional,
679 PacketChannelDescription pkt_chan_desc optional,
680 RequestReference req_ref,
681 TimingAdvance timing_advance,
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +0700682 MobileAllocationLV mobile_allocation,
Harald Welte9419c8a2017-07-30 04:07:05 +0200683 /* TODO: starting time TLV */
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200684 IaRestOctets rest_octets
Harald Welte9419c8a2017-07-30 04:07:05 +0200685 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
Vadim Yanitskiya4aacc22019-09-09 04:41:12 +0200686 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200687
688 /* 9.1.20 */
689 type record ReqRefWaitInd {
690 RequestReference req_ref,
691 WaitIndication wait_ind
692 } with { variant "" };
693 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
694 type record ImmediateAssignmentReject {
695 FeatureIndicator feature_ind,
696 PageMode page_mode,
Vadim Yanitskiy7ef121d2020-05-22 03:04:22 +0700697 ReqRefWaitInd4 payload,
698 IARRestOctets rest_octets
Harald Welte9419c8a2017-07-30 04:07:05 +0200699 } with { variant "" };
700
Vadim Yanitskiy7ef121d2020-05-22 03:04:22 +0700701 /* 10.5.2.17 IAR (Immediate Assignment Reject) Rest Octets */
702 type record IARRestOctets {
703 ExtRAList ext_ra_list,
704 BIT1 rel13_ind, // L/H
705 uint3_t rcc optional
706 /* Addition in Rel-15: PEO IMM Cell Group Details struct */
707 } with {
708 variant (rel13_ind) "CSN.1 L/H"
709 variant (rcc) "PRESENCE(rel13_ind = '1'B)"
710
711 /* The TITAN's RAW encoder generates an octet-aligned octetstring,
712 * so we should make sure that unused bits contain proper padding. */
713 variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
714 };
715
716 /* Optional extended RA: 0 | 1 < Extended RA 1 : bit (5) > */
717 type record ExtRAOpt {
718 BIT1 presence, // L/H
719 BIT5 ext_ra optional
720 } with {
721 variant (presence) "CSN.1 L/H"
722 variant (ext_ra) "PRESENCE(presence = '1'B)"
723 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562488 */
724 variant (ext_ra) "BYTEORDER(last)"
725 };
726
727 type record length(4) of ExtRAOpt ExtRAList;
728
Harald Weltecbc947f2018-02-22 00:26:55 +0100729 /* 9.1.21 */
730 type record MeasurementReport {
731 MeasurementResults meas_res
732 } with { variant "" };
733
Harald Welte9419c8a2017-07-30 04:07:05 +0200734 /* 9.1.22 */
735 type record PagingRequestType1 {
736 ChannelNeeded12 chan_needed,
737 PageMode page_mode,
738 MobileIdentityLV mi1,
739 MobileIdentityTLV mi2 optional,
740 RestOctets rest_octets
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700741 } with { variant "TAG(mi2, elementIdentifier = '0010111'B)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200742
743 /* 9.1.23 */
744 type record PagingRequestType2 {
745 ChannelNeeded12 chan_needed,
746 PageMode page_mode,
747 GsmTmsi mi1,
748 GsmTmsi mi2,
749 MobileIdentityTLV mi3 optional,
750 RestOctets rest_octets
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700751 } with { variant "TAG(mi3, elementIdentifier = '0010111'B)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200752
753 /* 9.1.24 */
754 type record length(4) of GsmTmsi GsmTmsi4;
755 type record PagingRequestType3 {
756 ChannelNeeded12 chan_needed,
757 PageMode page_mode,
758 GsmTmsi4 mi,
759 RestOctets rest_octets
760 } with { variant "" };
761
Harald Welte9419c8a2017-07-30 04:07:05 +0200762 type union RrUnion {
763/*
764 SystemInformationType1 si1,
765 SystemInformationType2 si2,
766 SystemInformationType2bis si2bis,
767 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100768 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200769 SystemInformationType4 si4,
770 SystemInformationType5 si5,
771 SystemInformationType5bis si5bis,
772 SystemInformationType5ter si5ter,
773 SystemInformationType6 si6,
774*/
775 ImmediateAssignment imm_ass,
776 ImmediateAssignmentReject imm_ass_rej,
777 PagingRequestType1 pag_req_1,
778 PagingRequestType2 pag_req_2,
779 PagingRequestType3 pag_req_3,
780 octetstring other
781 } with { variant "" };
782
783 /* Special RR Message on BCCH / CCCH Dowlink */
784
785 type record GsmRrMessage {
786 RrHeader header,
787 RrUnion payload
788 } with { variant (payload) "CROSSTAG(
789/*
790 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
791 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
792 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
793 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
794 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
795 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
796 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
797 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
798 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
799 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
800*/
801 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
802 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
803 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
804 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
805 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
806 other, OTHERWISE;
Vadim Yanitskiya4aacc22019-09-09 04:41:12 +0200807 )"
808 /* Total message length: 184 = 23 * 8. Pad spare bits with '2B'O. */
809 variant "PADDING(184), PADDING_PATTERN('00101011'B)"
810 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200811
812 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
813 with { extension "prototype(convert) encode(RAW)" };
814 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
815 with { extension "prototype(convert) decode(RAW)" };
816
817 /* Normal L3 Message on Dedicated Channel */
818
819 /* 9.1.25 Paging Response */
820 type record PagingResponse {
821 uint4_t spare_half_octet,
822 CipheringKeySeqNr cksn,
823 MsClassmark2LV cm2,
824 MobileIdentityLV mi,
825 uint8_t addl_upd_par optional
826 } with { variant "" };
827
828 type union RrL3Union {
829 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100830 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200831 octetstring other
832 };
833
834 type record GsmRrL3Message {
835 RrL3Header header,
836 RrL3Union payload
837 } with { variant (payload) "CROSSTAG(
838 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100839 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200840 other, OTHERWISE;
841 )" }
842
Harald Weltecbc947f2018-02-22 00:26:55 +0100843 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
844 with { extension "prototype(convert) encode(RAW)" };
845 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
846 with { extension "prototype(convert) decode(RAW)" };
847
848
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200849 template PacketDlAssign tr_PacketDlAssign(template GprsTlli tlli) := {
850 tlli := tlli,
851 group1_present := ?,
852 group1 := *,
853 ta_index_present := ?,
854 ta_index := *,
855 tbf_starting_time_present := ?,
856 tbf_starting_time := *,
857 p0_present := ?,
858 p0 := *,
859 pr_mode := *
860 };
861
862 template IaRestOctets tr_IaRestOctets_DLAss(template PacketDlAssign dl_ass) := {
863 presence := '11'B, /* HH */
864 ll := omit, lh := omit, hl := omit,
865 hh := {
866 pa_disc := '0'B, /* Packet Assignment (0) */
867 pa := {
868 uldl := {
869 ass_disc := '1'B, /* Downlink Assignment (1) */
870 ass := { dl := dl_ass }
871 }
872 }
873 }
874 };
875
876 template PacketUlAssign tr_PacketUlDynAssign(template uint5_t tfi := ?,
877 template BIT1 polling := ?,
878 template uint3_t usf := ?,
879 template BIT1 usf_granularity := ?,
880 template ChCodingCommand cs := ?) := {
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700881 presence := '1'B, /* Dynamic Block Allocation */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200882 dynamic := {
883 tfi_assignment := tfi,
884 polling := polling,
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700885 spare := '0'B, /* Dynamic Block Allocation (mandatory after Rel-4) */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200886 usf := usf,
887 usf_granularity := usf_granularity,
888 p0_present := ?,
889 p0 := *,
890 pr_mode := *,
891 ch_coding_cmd := cs,
892 tlli_block_chan_coding := ?,
893 alpha_present := ?,
894 alpha := *,
895 gamma := ?,
896 /* TODO: add to parameters */
897 ta_index_present := ?,
898 ta_index := *,
899 tbf_starting_time_present := ?,
900 tbf_starting_time := *
901 },
902 single := omit
903 };
904
905 template PacketUlAssign tr_PacketUlSglAssign := {
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700906 presence := '0'B, /* Single Block Allocation */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200907 dynamic := omit,
908 single := {
909 alpha_present := ?,
910 alpha := *,
911 gamma := ?,
912 padding := '01'B,
913 tbf_starting_time := ?
914 }
915 };
916
917 template IaRestOctets tr_IaRestOctets_ULAss(template PacketUlAssign ul_ass) := {
918 presence := '11'B, /* HH */
919 ll := omit, lh := omit, hl := omit,
920 hh := {
921 pa_disc := '0'B, /* Packet Assignment (0) */
922 pa := {
923 uldl := {
924 ass_disc := '0'B, /* Uplink Assignment (0) */
925 ass := { ul := ul_ass }
926 }
927 }
928 }
929 };
930
Vadim Yanitskiya0b47cf2020-04-02 01:50:18 +0700931 template EgprsUlAss tr_EgprsUlAssDynamic(template (present) BIT5 ext_ra := ?,
932 template EgprsUlAssignDyn dyn_ass := ?) := {
933 ext_ra := ext_ra,
934 ats_present := ?,
935 ats := *,
936 presence := '1'B,
937 dynamic := dyn_ass,
938 multiblock := omit
939 };
940 template EgprsUlAss tr_EgprsUlAssMultiblock(template (present) BIT5 ext_ra := ?,
941 template EgprsUlAssignMultiblock mb_ass := ?) := {
942 ext_ra := ext_ra,
943 ats_present := ?,
944 ats := *,
945 presence := '0'B,
946 dynamic := omit,
947 multiblock := mb_ass
948 };
949
950 template IaRestOctets tr_IaRestOctets_EGPRSULAss(template EgprsUlAss ul_ass) := {
951 presence := '01'B, /* LH */
952 ll := omit,
953 lh := {
954 presence := '00'B,
955 egprs_ul := ul_ass,
956 multiblock_dl_ass := omit
957 },
958 hl := omit,
959 hh := omit
960 };
961
Harald Weltee8d750e2018-06-10 21:41:35 +0200962 template (value) GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +0700963 ChannelDescription ch_desc, MobileAllocationLV ma) := {
Harald Weltebae6be82020-08-21 12:42:18 +0200964 header := ts_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
Harald Weltecbc947f2018-02-22 00:26:55 +0100965 payload := {
966 imm_ass := {
967 ded_or_tbf := {
968 spare := '0'B,
969 tma := false,
970 downlink := false,
971 tbf := false
972 },
973 page_mode := PAGE_MODE_NORMAL,
974 chan_desc := ch_desc,
975 pkt_chan_desc := omit,
976 req_ref := f_compute_ReqRef(ra, fn),
977 timing_advance := ta,
978 mobile_allocation := ma,
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200979 rest_octets := {
980 presence := '00'B, /* LL */
981 ll := {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700982 compressed_irat_ho_info_ind := '0'B /* L */
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200983 },
984 lh := omit, hl := omit, hh := omit
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200985 }
Harald Weltecbc947f2018-02-22 00:26:55 +0100986 }
987 }
988 };
989
Harald Weltee8d750e2018-06-10 21:41:35 +0200990 template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?,
991 template TimingAdvance ta := ?,
992 template ChannelDescription ch_desc := ?,
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +0700993 template MobileAllocationLV ma := ?) := {
Vadim Yanitskiyd4205c32019-09-09 16:15:37 +0200994 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
Harald Weltee8d750e2018-06-10 21:41:35 +0200995 payload := {
996 imm_ass := {
997 ded_or_tbf := {
998 spare := '0'B,
999 tma := false,
1000 downlink := false,
1001 tbf := false
1002 },
1003 page_mode := PAGE_MODE_NORMAL,
1004 chan_desc := ch_desc,
1005 pkt_chan_desc := omit,
1006 req_ref := tr_compute_ReqRef(ra, fn),
1007 timing_advance := ta,
1008 mobile_allocation := ma,
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +02001009 rest_octets := ?
Harald Weltee8d750e2018-06-10 21:41:35 +02001010 }
1011 }
1012 };
1013
Vadim Yanitskiy6edd4f52019-09-09 01:51:09 +02001014 /* TODO: implement send version of this template */
1015 template GsmRrMessage tr_IMM_TBF_ASS(template boolean dl := ?,
1016 template uint8_t ra := ?,
1017 template GsmFrameNumber fn := ?,
1018 template TimingAdvance ta := ?,
1019 template PacketChannelDescription ch_desc := ?,
Vadim Yanitskiy3b464a92020-08-25 03:55:32 +07001020 template MobileAllocationLV ma := ?,
Vadim Yanitskiy6edd4f52019-09-09 01:51:09 +02001021 template IaRestOctets rest := ?) := {
1022 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
1023 payload := {
1024 imm_ass := {
1025 ded_or_tbf := {
1026 spare := ?,
1027 tma := ?,
1028 downlink := dl,
1029 tbf := true
1030 },
1031 page_mode := ?,
1032 chan_desc := omit,
1033 pkt_chan_desc := ch_desc,
1034 req_ref := tr_compute_ReqRef(ra, fn),
1035 timing_advance := ta,
Vadim Yanitskiycf1ed3f2020-07-20 04:01:43 +07001036 mobile_allocation := ma,
Vadim Yanitskiy6edd4f52019-09-09 01:51:09 +02001037 rest_octets := rest
1038 }
1039 }
1040 };
Harald Weltee8d750e2018-06-10 21:41:35 +02001041
Vadim Yanitskiy9781ecb2020-03-28 03:59:41 +07001042 template GsmRrMessage tr_PAG_REQ1(template MobileIdentityLV mi1 := ?,
1043 template MobileIdentityTLV mi2 := omit) := {
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001044 header := t_RrHeader(PAGING_REQUEST_TYPE_1, ?),
1045 payload := {
1046 pag_req_1 := {
1047 chan_needed := {
1048 second := ?,
1049 first := ?
1050 },
1051 page_mode := PAGE_MODE_NORMAL,
1052 mi1 := mi1,
Vadim Yanitskiy9781ecb2020-03-28 03:59:41 +07001053 mi2 := mi2,
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001054 rest_octets := ?
1055 }
1056 }
1057 };
1058
Harald Weltecbc947f2018-02-22 00:26:55 +01001059 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
1060 uint3_t rxq_f, uint3_t rxq_s,
1061 template (omit) NcellReports reps) := {
1062 header := t_RrL3Header(MEASUREMENT_REPORT),
1063 payload := {
1064 meas_rep := {
1065 meas_res := {
1066 ba_used := '0'B,
1067 dtx_used := '0'B,
1068 rxlev_full_srv_cell := rxl_f,
1069 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +01001070 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +01001071 rxlev_sub_srv_cell := rxl_s,
1072 si23_ba_used := '0'B,
1073 rxqual_full_srv_cell := rxq_f,
1074 rxqual_sub_srv_cell := rxq_s,
1075 no_ncell_m := 0,
1076 ncell_reports := reps
1077 }
1078 }
1079 }
1080 };
1081
Vadim Yanitskiy16e24aa2020-05-22 03:32:00 +07001082 template GsmRrMessage tr_IMM_ASS_REJ(template FeatureIndicator feature_ind := ?,
1083 template ReqRefWaitInd4 rr_wi_list := ?,
1084 template IARRestOctets rest_octets := ?) := {
1085 header := t_RrHeader(IMMEDIATE_ASSIGNMENT_REJECT, ?),
1086 payload := {
1087 imm_ass_rej := {
1088 feature_ind := feature_ind,
1089 page_mode := ?,
1090 payload := rr_wi_list,
1091 rest_octets := rest_octets
1092 }
1093 }
1094 };
1095
1096 template ReqRefWaitInd tr_ReqRefWaitInd(template RequestReference ref := ?,
1097 template WaitIndication wi := ?) := {
1098 req_ref := ref,
1099 wait_ind := wi
1100 };
1101
1102 template IARRestOctets tr_IARRestOctets(template ExtRAList ext_ra_list := ?,
1103 template uint3_t rcc := ?) := {
1104 ext_ra_list := ext_ra_list,
1105 rel13_ind := ?,
1106 rcc := rcc ifpresent
1107 };
1108
1109 template ExtRAOpt tr_ExtRAOpt(template BIT5 ext_ra := ?) := {
1110 presence := '1'B, // L/H
1111 ext_ra := ext_ra
1112 };
1113
Vadim Yanitskiyf7181ed2020-07-14 20:12:02 +07001114 template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr,
1115 template (value) uint12_t arfcn,
1116 template (value) uint3_t tsc := 7) := {
1117 chan_nr := chan_nr,
1118 tsc := tsc,
1119 h := false,
1120 arfcn := arfcn,
1121 maio_hsn := omit
1122 }
1123
1124 template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr,
1125 template (value) MaioHsn maio_hsn,
1126 template (value) uint3_t tsc := 7) := {
1127 chan_nr := chan_nr,
1128 tsc := tsc,
1129 h := true,
1130 arfcn := omit,
1131 maio_hsn := maio_hsn
1132 }
1133
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001134
1135 /* Templates for the RR Channel Release message's "Cell selection indicator after release of all TCH and SDCCH" IE.
1136 * See 3GPP TS 44.018 9.1.7 and 10.5.2.1e */
1137
1138 /* 3GPP TS 44.018 10.5.2.1e, Cell Selection Indicator after release of all TCH and SDCCH value part */
1139 type record CellSelIndValue {
1140 BIT3 discr,
1141 CellSelIndValueEnum value_list,
1142 BIT1 value_list_term ('0'B)
1143 } with {
1144 variant (value_list) "CROSSTAG(
1145 gsm, discr='000'B;
1146 utran_fdd, discr='001'B;
1147 utran_tdd, discr='010'B;
1148 eutran, discr='011'B;
1149 )"
1150 };
1151
1152 /* 3GPP TS 44.018 10.5.2.1e, Cell Selection Indicator after release of all TCH and SDCCH value part */
1153 private type union CellSelIndValueEnum {
1154 CellSelIndValue_GSM_Descrs gsm,
1155 CellSelIndValue_UTRAN_Descrs utran_fdd,
1156 CellSelIndValue_UTRAN_Descrs utran_tdd,
1157 CellSelIndValue_EUTRAN_Descrs eutran
1158 } with { variant "" };
1159
1160 type record of CellSelIndValue_GSM_Descr CellSelIndValue_GSM_Descrs;
1161 /* 3GPP TS 44.018 10.5.2.1e, GSM Description struct */
1162 type record CellSelIndValue_GSM_Descr {
1163 BIT1 item_ind ('1'B),
1164 BIT1 band_indicator,
1165 uint10_t arfcn,
1166 uint6_t bsic
1167 } with {
1168 variant "PRESENCE(item_ind = '1'B)"
1169 };
1170
1171 type record of CellSelIndValue_UTRAN_Descr CellSelIndValue_UTRAN_Descrs;
1172 /* 3GPP TS 44.018 10.5.2.1e, UTRAN {FDD,TDD} Description struct */
1173 type record CellSelIndValue_UTRAN_Descr {
1174 BIT1 item_ind ('1'B),
1175 BIT1 bandwidth_presence,
1176 uint3_t bandwidth optional,
1177 uint14_t arfcn,
1178 BIT1 cell_info_presence,
1179 UTRAN_CellInfo cell_info optional
1180 } with {
1181 variant "PRESENCE(item_ind = '1'B)"
1182 variant (bandwidth) "PRESENCE(bandwidth_presence = '1'B)"
1183 variant (cell_info) "PRESENCE(cell_info_presence = '1'B)"
1184 };
1185 type record UTRAN_CellInfo {
1186 BIT1 indic0,
1187 uint5_t nr_of_cells,
1188 // TODO: define cell_information_field
1189 octetstring cell_information_field
1190 } with { variant "" };
1191
1192 type record of CellSelIndValue_EUTRAN_Descr CellSelIndValue_EUTRAN_Descrs;
1193 /* 3GPP TS 44.018 10.5.2.1e, E-UTRAN Description struct */
1194 type record CellSelIndValue_EUTRAN_Descr {
1195 BIT1 item_ind ('1'B),
1196 uint16_t earfcn,
1197 BIT1 meas_bw_presence,
1198 uint3_t meas_bw optional,
1199 BIT1 not_allowed_cells_presence,
1200 // define not_allowed_cells
1201 octetstring not_allowed_cells optional,
1202 BIT1 target_pcid_presence,
1203 uint9_t target_pcid optional
1204 } with {
1205 variant "PRESENCE(item_ind = '1'B)"
1206 variant (meas_bw) "PRESENCE(meas_bw_presence = '1'B)"
1207 variant (not_allowed_cells) "PRESENCE(not_allowed_cells_presence = '1'B)"
1208 variant (target_pcid) "PRESENCE(target_pcid_presence = '1'B)"
1209 };
1210
1211 template CellSelIndValue tr_CellSelIndValue_EUTRAN(
1212 template CellSelIndValue_EUTRAN_Descrs cells := {})
1213 := {
1214 discr := '011'B,
1215 value_list := {
1216 eutran := cells
1217 },
1218 value_list_term := '0'B
1219 };
1220
1221 template CellSelIndValue_EUTRAN_Descr tr_CellSelIndValue_EUTRAN_Descr(
1222 template (present) uint16_t earfcn,
1223 template (present) BIT1 meas_bw_presence := ?,
1224 template uint3_t meas_bw := *)
1225 := {
1226 item_ind := '1'B,
1227 earfcn := earfcn,
1228 meas_bw_presence := meas_bw_presence,
1229 meas_bw := meas_bw,
1230 not_allowed_cells_presence := '0'B,
1231 not_allowed_cells := omit,
1232 target_pcid_presence := '0'B,
1233 target_pcid := omit
1234 };
1235
1236 external function enc_CellSelIndValue(in CellSelIndValue ro) return octetstring
1237 with { extension "prototype(convert) encode(RAW)" };
1238 external function dec_CellSelIndValue(in octetstring stream) return CellSelIndValue
1239 with { extension "prototype(convert) decode(RAW)" };
1240
Vadim Yanitskiye05d7162020-05-02 16:58:46 +07001241} with { encode "RAW" ; variant "FIELDORDER(msb)" }