blob: 6e359ab99f20bd49c417e37c640f9bc0658a4a75 [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
116 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
117 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
118 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
119
120 type record L2PseudoLength {
121 uint6_t l2_plen,
122 BIT2 zero_one
123 } with { variant "" };
124
Harald Weltef8df4cb2018-03-10 15:15:08 +0100125 template L2PseudoLength tr_L2Pseudolength(template uint6_t len) := {
126 l2_plen := len,
127 zero_one := '01'B
128 };
129
130 template (value) L2PseudoLength ts_L2Pseudolength(uint6_t len) := {
Harald Welte9419c8a2017-07-30 04:07:05 +0200131 l2_plen := len,
132 zero_one := '01'B
133 };
134
135 type record RrHeader {
136 L2PseudoLength l2_plen,
137 uint4_t skip_indicator,
138 uint4_t rr_protocol_discriminator,
139 RrMessageType message_type
140 } with { variant "" };
141
142 template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100143 l2_plen := tr_L2Pseudolength(len),
Harald Welte9419c8a2017-07-30 04:07:05 +0200144 skip_indicator := 0,
145 rr_protocol_discriminator := 6,
146 message_type := msg_type
147 };
148
Harald Weltef8df4cb2018-03-10 15:15:08 +0100149 template (value) RrHeader ts_RrHeader(RrMessageType msg_type, uint6_t len) := {
150 l2_plen := ts_L2Pseudolength(len),
151 skip_indicator := 0,
152 rr_protocol_discriminator := 6,
153 message_type := msg_type
154 };
155
156
Harald Welte9419c8a2017-07-30 04:07:05 +0200157 type record RrL3Header {
158 uint4_t skip_indicator,
159 uint4_t rr_protocol_discriminator,
160 RrMessageType message_type
161 } with { variant "" };
162
Harald Weltecbc947f2018-02-22 00:26:55 +0100163 template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
164 skip_indicator := 0,
165 rr_protocol_discriminator := 6,
166 message_type := msg_type
167 }
168
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200169 /* TS 44.004 7.2.1 */
170 type record SacchL1Header {
171 uint2_t reserved,
172 boolean fpc,
173 uint5_t ms_power_lvl,
174 uint8_t actual_ta
175 } with { variant "FIELDORDER(msb)" };
176
177 template (value) SacchL1Header ts_SacchL1Header(uint5_t ms_power_lvl, boolean fpc, uint8_t actual_ta) := {
178 reserved := 0,
179 fpc := fpc,
180 ms_power_lvl := ms_power_lvl,
181 actual_ta := actual_ta
182 };
183
Harald Welte9419c8a2017-07-30 04:07:05 +0200184 type record MaioHsn {
185 } with { variant "" };
186
187 /* TS 24.008 10.5.1.1 */
188 type uint16_t CellIdentity;
189
190 /* TS 24.008 10.5.1.2 */
191 type uint4_t CipheringKeySeqNr (0..7);
192
193 /* 24.008 10.5.1.3 */
194 type record LocationAreaIdentification {
195 BcdMccMnc mcc_mnc,
196 uint16_t lac
Vadim Yanitskiy0a71fca2020-04-29 15:31:40 +0700197 } with {
198 /* Otherwise '262F45'H is encoded as '24F262'H */
199 variant (mcc_mnc) "BYTEORDER(first)"
200 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200201
202 /* TS 24.008 10.5.1.4 */
203 type enumerated MobileIdentityType {
204 MI_TYPE_NONE (0),
205 MI_TYPE_IMSI,
206 MI_TYPE_IMEI,
207 MI_TYPE_IMEISV,
208 MI_TYPE_TMSI,
209 MI_TYPE_TMGI
210 } with { variant "FIELDLENGTH(3)" };
211
Harald Welte9419c8a2017-07-30 04:07:05 +0200212 /* TS 24.008 10.5.1.5 */
213 type record MsClassmark1 {
214 BIT1 spare,
215 uint2_t rev_level,
216 boolean es_ind,
217 boolean a51,
218 uint3_t rf_pwr_cap
219 } with { variant "" };
220
221 /* TS 24.008 10.5.1.6 */
222 type record MsClassmark2 {
223 BIT1 spare,
224 uint2_t rev_level,
225 boolean es_ind,
226 boolean a51,
227 uint3_t rf_pwr_cap,
228 BIT1 spare1,
229 boolean ps_cap,
230 uint2_t ss_screen_ind,
231 boolean sm_cap,
232 boolean vbs,
233 boolean vgcs,
234 boolean fc,
235 boolean cm3,
236 BIT1 spare2,
237 boolean lcsva_cap,
238 boolean ucs2,
239 boolean solsa,
240 boolean cmsp,
241 boolean a53,
242 boolean a52
243 } with { variant "" };
244 type record MsClassmark2LV {
245 uint8_t len,
246 MsClassmark2 cm2
247 } with { variant (len) "LENGTHTO(cm2)" };
248
249
250 /* 44.018 10.5.2.5 */
251 type record ChannelDescription {
252 RslChannelNr chan_nr,
253 uint3_t tsc,
254 boolean h,
255 uint12_t arfcn optional,
256 MaioHsn maio_hsn optional
257 } with { variant (arfcn) "PRESENCE(h = false)"
258 variant (maio_hsn) "PRESENCE(h = true)" };
259
260 type record ChannelDescriptionTV {
261 OCT1 iei,
262 ChannelDescription v
263 } with { variant "" };
264
265 /* 10.5.2.21 */
266 type record MobileAllocation {
267 uint8_t len,
268 bitstring ma
269 } with { variant (len) "LENGTHTO(ma)" };
270
271 /* 10.5.2.25a */
Harald Welte1b9b7702017-07-30 04:19:14 +0200272 type record PktChDesc0Ind {
273 uint6_t maio,
274 BIT1 ma_number_ind,
275 BIT1 change_mark1_valid,
276 BIT2 change_mark1
277 } with { variant "" };
278 type record PktChDesc0 {
279 BIT1 hopping,
280 BIT1 spare ('0'B),
281 uint10_t arfcn optional,
282 PktChDesc0Ind indirect optional
283 } with {
284 variant (arfcn) "PRESENCE(hopping = '0'B)"
285 variant (indirect) "PRESENCE(hopping = '1'B)"
286 };
287 type record PktChDesc1 {
288 uint6_t maio,
289 uint6_t hsn
290 } with { variant "" };
291 type record PacketChannelDescription {
292 uint5_t channel_Type_spare,
293 uint3_t tn,
294 uint3_t tsc,
295 BIT1 presence,
296 PktChDesc0 zero optional,
297 PktChDesc1 one optional
298 } with {
299 variant (zero) "PRESENCE(presence = '0'B)"
300 variant (one) "PRESENCE(presence = '1'B)"
301 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200302
303 /* 10.5.2.25b */
304 type record DedicatedModeOrTbf {
305 BIT1 spare,
306 boolean tma,
307 boolean downlink,
308 boolean tbf
309 } with { variant "" };
310
311 /* 10.5.2.26 */
312 type enumerated PageMode {
313 PAGE_MODE_NORMAL,
314 PAGE_MODE_EXTENDED,
315 PAGE_MODE_REORGANIZATION,
316 PAGE_MODE_SAME_AS_BEFORE
317 } with { variant "FIELDLENGTH(4)" };
318
319 /* 10.5.2.30 */
320 type record RequestReference {
321 bitstring ra length(8),
322 uint5_t t1p,
323 uint6_t t3,
324 uint5_t t2
325 } with { variant "" };
326
327 template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := {
328 ra := ra,
329 t1p := t1p,
330 t3 := t3,
331 t2 := t2
332 }
333
334 /* compute the expected request reference for given RA + FN */
335 function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference {
336 var RequestReference req_ref := { ra := int2bit(ra, 8) };
337 req_ref.t1p := (fn / 1326) mod 32;
338 req_ref.t2 := fn mod 26;
339 req_ref.t3 := fn mod 51;
340 return req_ref
341 }
Harald Weltee8d750e2018-06-10 21:41:35 +0200342 function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn)
343 return template RequestReference {
344 var template RequestReference req_ref;
345 if (istemplatekind(ra, "?")) {
346 req_ref.ra := ?;
347 } else {
348 req_ref.ra := int2bit(valueof(ra), 8);
349 }
350 if (istemplatekind(fn, "?")) {
351 req_ref.t1p := ?;
352 req_ref.t2 := ?;
353 req_ref.t3 := ?;
354 } else {
355 var GsmFrameNumber fn_v := valueof(fn);
356 req_ref.t1p := (fn_v / 1326) mod 32;
357 req_ref.t2 := fn_v mod 26;
358 req_ref.t3 := fn_v mod 51;
359 }
360 return req_ref;
361 }
Harald Welte9419c8a2017-07-30 04:07:05 +0200362
363 /* 10.5.2.40 */
364 type integer TimingAdvance (0..219);
365
366 /* 10.5.2.43 */
367 type uint8_t WaitIndication;
368
369 /* 10.5.2.76 */
370 type record FeatureIndicator {
371 BIT2 spare,
372 boolean cs_ir,
373 boolean ps_ir
374 } with { variant "" };
375
376 /* 24.008 10.5.5.6 */
377 type record DrxParameter {
378 uint8_t split_pg_cycle_code,
379 uint4_t drx_cycle_len_coeff,
380 boolean split_on_ccch,
381 uint3_t non_drx_timer
382 } with { variant "" };
383
384 /* 24.008 10.5.5.15 */
385 type record RoutingAreaIdentification {
386 LocationAreaIdentification lai,
387 uint8_t rac
388 } with { variant "" };
389
Harald Welteb16516c2019-03-21 21:31:41 +0100390 external function enc_RoutingAreaIdentification(RoutingAreaIdentification rai) return octetstring
391 with { extension "prototype(convert)" extension "encode(RAW)" }
392
Harald Welte9419c8a2017-07-30 04:07:05 +0200393 /* 44.018 10.5.2.16 */
394 type record IaRestOctHL {
395 uint6_t freq_par_len,
396 BIT2 padding ('00'B) optional,
397 uint6_t maio optional,
398 octetstring mobile_allocation optional
399 } with {
400 variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)"
401/*
402 variant (padding) "PRESENCE(freq_par_len != 0)"
403 variant (maio) "PRESENCE(freq_par_len != 0)"
404 variant (mobile_allocation) "PRESENCE(freq_par_len != 0)"
405*/
406 };
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200407 type record SecondPartAssign {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700408 BIT1 r99, /* L / H */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200409 BIT1 presence optional,
410 BIT5 ext_ra optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200411 } with {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700412 variant (r99) "CSN.1 L/H"
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200413 variant (presence) "PRESENCE(r99 = '1'B)" /* H */
414 variant (ext_ra) "PRESENCE(presence = '1'B)"
415 };
416 type union PacketUlDlAssignUnion {
417 PacketUlAssign ul,
418 PacketDlAssign dl
419 };
420 type record PacketUlDlAssign {
421 BIT1 ass_disc,
422 PacketUlDlAssignUnion ass
423 } with {
424 variant (ass) "CROSSTAG(dl, ass_disc = '1'B; ul, ass_disc = '0'B)"
425 };
426 type union PacketAssignUnion {
427 SecondPartAssign spa,
428 PacketUlDlAssign uldl
429 };
430 type record IaRestOctHH {
431 /* Packet Assignment discriminator:
432 * Packet Uplink / Downlink Assignment (0)
433 * Second Part Packet Assignment (1) */
434 BIT1 pa_disc,
435 PacketAssignUnion pa
436 } with {
437 variant (pa) "CROSSTAG(spa, pa_disc = '1'B; uldl, pa_disc = '0'B)"
Harald Welte9419c8a2017-07-30 04:07:05 +0200438 };
439 type record PacketUlAssignDyn {
440 uint5_t tfi_assignment,
441 BIT1 polling,
442 BIT1 spare ('0'B),
443 uint3_t usf,
444 BIT1 usf_granularity,
445 BIT1 p0_present,
446 uint4_t p0 optional,
447 BIT1 pr_mode optional,
448 ChCodingCommand ch_coding_cmd,
449 BIT1 tlli_block_chan_coding,
450 BIT1 alpha_present,
451 uint4_t alpha optional,
452 uint5_t gamma,
453 BIT1 ta_index_present,
454 uint4_t ta_index optional,
455 BIT1 tbf_starting_time_present,
456 uint16_t tbf_starting_time optional
457 } with {
458 variant (p0) "PRESENCE(p0_present = '1'B)"
459 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
460 variant (alpha) "PRESENCE(alpha_present = '1'B)"
461 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
462 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
463 };
464 type record PacketUlAssignSgl {
465 BIT1 alpha_present,
466 uint4_t alpha optional,
467 uint5_t gamma,
468 BIT2 padding ('01'B),
469 uint16_t tbf_starting_time
470 /* TODO: P0 / PR_MODE */
471 } with {
472 variant (alpha) "PRESENCE(alpha_present = '1'B)"
473 };
474 type record PacketUlAssign {
475 BIT1 presence,
476 PacketUlAssignDyn dynamic optional,
477 PacketUlAssignSgl single optional
478 /* TODO: Estended RA, PFI */
479 } with {
480 variant (dynamic) "PRESENCE(presence = '1'B)"
481 variant (single) "PRESENCE(presence = '0'B)"
482 };
483 type record PacketDlAssG1 {
484 uint5_t tfi_assignment,
485 BIT1 rlc_mode,
486 BIT1 alpha_present,
487 uint4_t alpha optional,
488 uint5_t gamma,
489 BIT1 polling,
490 BIT1 ta_valid
491 } with { variant "" };
492 type record PacketDlAssign {
493 GprsTlli tlli,
494 BIT1 group1_present,
495 PacketDlAssG1 group1 optional,
496 BIT1 ta_index_present,
497 uint4_t ta_index optional,
498 BIT1 tbf_starting_time_present,
499 uint16_t tbf_starting_time optional,
500 BIT1 p0_present,
501 uint4_t p0 optional,
502 BIT1 pr_mode optional
503 /* TODO: EGPRS window size, etc. */
504 } with {
505 variant (group1) "PRESENCE(group1_present = '1'B)"
506 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
507 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
508 variant (p0) "PRESENCE(p0_present = '1'B)"
509 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
510 };
511 type record IaRestOctLL {
512 BIT1 compressed_irat_ho_info_ind
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700513 } with {
514 variant (compressed_irat_ho_info_ind) "CSN.1 L/H"
515 };
Pau Espin Pedrol461ed612019-12-30 20:18:34 +0100516
517
518 type record of AccessTechnologiesRequest
519 AccessTechnologiesRequestRepetition
520 with { variant "EXTENSION_BIT(reverse)" };
521
522 type record AccessTechnologiesRequest
523 {
524 BIT4 accessTechnType,
525 BIT1 extensionBit
526 } with { variant "FIELDORDER(msb)" };
527
528 type enumerated EgprsChCodingCommand {
529 CH_CODING_MCS1 ('0000'B),
530 CH_CODING_MCS2 ('0001'B),
531 CH_CODING_MCS3 ('0010'B),
532 CH_CODING_MCS4 ('0011'B),
533 CH_CODING_MCS5 ('0100'B),
534 CH_CODING_MCS6 ('0101'B),
535 CH_CODING_MCS7 ('0110'B),
536 CH_CODING_MCS8 ('0111'B),
537 CH_CODING_MCS9 ('1000'B),
538 CH_CODING_MCS5_7 ('1001'B),
539 CH_CODING_MCS6_9 ('1010'B)
540 } with { variant "FIELDLENGTH(4)" };
541
542 /* TS 44.060 Table 12.5.2.1 */
543 type enumerated EgprsWindowSize {
544 EGPRS_WS_64 ('00000'B),
545 EGPRS_WS_96 ('00001'B),
546 EGPRS_WS_128 ('00010'B),
547 EGPRS_WS_160 ('00011'B),
548 EGPRS_WS_192 ('00100'B),
549 EGPRS_WS_224 ('00101'B),
550 EGPRS_WS_256 ('00110'B),
551 EGPRS_WS_288 ('00111'B),
552 EGPRS_WS_320 ('01000'B),
553 EGPRS_WS_352 ('01001'B),
554 EGPRS_WS_384 ('01010'B),
555 EGPRS_WS_416 ('01011'B),
556 EGPRS_WS_448 ('01100'B),
557 EGPRS_WS_480 ('01101'B),
558 EGPRS_WS_512 ('01110'B),
559 EGPRS_WS_544 ('01111'B),
560 EGPRS_WS_576 ('10000'B),
561 EGPRS_WS_608 ('10001'B),
562 EGPRS_WS_640 ('10010'B),
563 EGPRS_WS_672 ('10011'B),
564 EGPRS_WS_704 ('10100'B),
565 EGPRS_WS_736 ('10101'B),
566 EGPRS_WS_768 ('10110'B),
567 EGPRS_WS_800 ('10111'B),
568 EGPRS_WS_832 ('11000'B),
569 EGPRS_WS_864 ('11001'B),
570 EGPRS_WS_896 ('11010'B),
571 EGPRS_WS_928 ('11011'B),
572 EGPRS_WS_960 ('11100'B),
573 EGPRS_WS_992 ('11101'B),
574 EGPRS_WS_1024 ('11110'B)
575 } with { variant "FIELDLENGTH(5)" };
576
577 type record EgprsUlAssignDyn {
578 uint5_t tfi_assignment,
579 BIT1 polling,
580 BIT1 spare ('0'B),
581 uint3_t usf,
582 BIT1 usf_granularity,
583 BIT1 p0_present,
584 uint4_t p0 optional,
585 BIT1 pr_mode optional,
586 EgprsChCodingCommand egprs_ch_coding_cmd,
587 BIT1 tlli_block_chan_coding,
588 BIT1 bep_period2_present,
589 BIT4 bep_period2 optional,
590 BIT1 resegment,
591 EgprsWindowSize egprs_window_size,
592 BIT1 alpha_present,
593 uint4_t alpha optional,
594 uint5_t gamma,
595 BIT1 ta_index_present,
596 uint4_t ta_index optional,
597 BIT1 tbf_starting_time_present,
598 uint16_t tbf_starting_time optional
599 /* TODO: Additions for Rel-7 */
600 } with {
601 variant (p0) "PRESENCE(p0_present = '1'B)"
602 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
603 variant (bep_period2) "PRESENCE(bep_period2_present = '1'B)"
604 variant (alpha) "PRESENCE(alpha_present = '1'B)"
605 variant (ta_index) "PRESENCE(ta_index_present = '1'B)"
606 variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)"
607 };
608 type record EgprsUlAssignMultiblock {
609 BIT1 alpha_present,
610 uint4_t alpha optional,
611 uint5_t gamma,
612 uint16_t tbf_starting_time,
613 BIT2 nr_radio_blocks_allocated,
614 BIT1 p0_present,
615 uint4_t p0 optional,
616 BIT1 spare ('0'B) optional,
617 BIT1 pr_mode optional
618 /* TDO: Additions for Rel-6 */
619 } with {
620 variant (alpha) "PRESENCE(alpha_present = '1'B)"
621 variant (p0) "PRESENCE(p0_present = '1'B)"
622 variant (spare) "PRESENCE(p0_present = '1'B)"
623 variant (pr_mode) "PRESENCE(p0_present = '1'B)"
624 };
625 /* 3GPP TS 44.018 version 13.3.2 10.5.2.16, "EGPRS Packet Uplink Assignment" */
626 type record EgprsUlAss {
627 BIT5 ext_ra,
628 BIT1 ats_present,
629 AccessTechnologiesRequestRepetition ats optional,
630 BIT1 presence,
631 EgprsUlAssignDyn dynamic optional,
632 EgprsUlAssignMultiblock multiblock optional
633 } with {
634 variant (ats) "PRESENCE(ats_present = '1'B)"
635 variant (dynamic) "PRESENCE(presence = '1'B)"
636 variant (multiblock) "PRESENCE(presence = '0'B)"
637 };
638
Harald Welte9419c8a2017-07-30 04:07:05 +0200639 type octetstring MblkDlAss; /* TODO */
640 type record IaRestOctLH {
641 BIT2 presence,
642 EgprsUlAss egprs_ul optional,
643 MblkDlAss multiblock_dl_ass optional
644 } with {
645 variant (egprs_ul) "PRESENCE(presence = '00'B)"
646 variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)"
647 };
648 type record IaRestOctets {
649 BIT2 presence,
650 IaRestOctLL ll optional,
651 IaRestOctLH lh optional,
652 IaRestOctHL hl optional,
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200653 IaRestOctHH hh optional
Harald Welte9419c8a2017-07-30 04:07:05 +0200654 } with {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700655 variant (presence) "CSN.1 L/H"
Harald Welte9419c8a2017-07-30 04:07:05 +0200656 variant (ll) "PRESENCE(presence = '00'B)"
657 variant (lh) "PRESENCE(presence = '01'B)"
658 variant (hl) "PRESENCE(presence = '10'B)"
659 variant (hh) "PRESENCE(presence = '11'B)"
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200660 variant "PADDING(yes), PADDING_PATTERN('00101011'B)"
Harald Welte9419c8a2017-07-30 04:07:05 +0200661 };
662
Harald Weltecbc947f2018-02-22 00:26:55 +0100663 type record MeasurementResults {
664 BIT1 ba_used,
665 BIT1 dtx_used,
666 uint6_t rxlev_full_srv_cell,
667 BIT1 threeg_ba_used,
668 BIT1 meas_valid,
669 uint6_t rxlev_sub_srv_cell,
670 BIT1 si23_ba_used,
671 uint3_t rxqual_full_srv_cell,
672 uint3_t rxqual_sub_srv_cell,
673 uint3_t no_ncell_m,
674 NcellReports ncell_reports optional
675 } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
676 variant (no_ncell_m) "UNIT(elements)"
677 variant "PADDING(yes)"
678 variant "FIELDLENGTH(16)"
679 };
680
681 type record NcellReport {
682 uint6_t rxlev,
683 uint5_t bcch_freq,
684 uint6_t bsic
685 } with { variant ""};
686 type record of NcellReport NcellReports;
687
Harald Welte9419c8a2017-07-30 04:07:05 +0200688
689 /* 9.1.18 */
690 type record ImmediateAssignment {
691 DedicatedModeOrTbf ded_or_tbf,
692 PageMode page_mode,
693 ChannelDescription chan_desc optional,
694 PacketChannelDescription pkt_chan_desc optional,
695 RequestReference req_ref,
696 TimingAdvance timing_advance,
697 MobileAllocation mobile_allocation,
698 /* TODO: starting time TLV */
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200699 IaRestOctets rest_octets
Harald Welte9419c8a2017-07-30 04:07:05 +0200700 } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
Vadim Yanitskiya4aacc22019-09-09 04:41:12 +0200701 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200702
703 /* 9.1.20 */
704 type record ReqRefWaitInd {
705 RequestReference req_ref,
706 WaitIndication wait_ind
707 } with { variant "" };
708 type record length(4) of ReqRefWaitInd ReqRefWaitInd4;
709 type record ImmediateAssignmentReject {
710 FeatureIndicator feature_ind,
711 PageMode page_mode,
712 ReqRefWaitInd4 payload
713 } with { variant "" };
714
Harald Weltecbc947f2018-02-22 00:26:55 +0100715 /* 9.1.21 */
716 type record MeasurementReport {
717 MeasurementResults meas_res
718 } with { variant "" };
719
Harald Welte9419c8a2017-07-30 04:07:05 +0200720 /* 9.1.22 */
721 type record PagingRequestType1 {
722 ChannelNeeded12 chan_needed,
723 PageMode page_mode,
724 MobileIdentityLV mi1,
725 MobileIdentityTLV mi2 optional,
726 RestOctets rest_octets
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700727 } with { variant "TAG(mi2, elementIdentifier = '0010111'B)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200728
729 /* 9.1.23 */
730 type record PagingRequestType2 {
731 ChannelNeeded12 chan_needed,
732 PageMode page_mode,
733 GsmTmsi mi1,
734 GsmTmsi mi2,
735 MobileIdentityTLV mi3 optional,
736 RestOctets rest_octets
Vadim Yanitskiy98bb2d52020-03-28 00:57:21 +0700737 } with { variant "TAG(mi3, elementIdentifier = '0010111'B)" };
Harald Welte9419c8a2017-07-30 04:07:05 +0200738
739 /* 9.1.24 */
740 type record length(4) of GsmTmsi GsmTmsi4;
741 type record PagingRequestType3 {
742 ChannelNeeded12 chan_needed,
743 PageMode page_mode,
744 GsmTmsi4 mi,
745 RestOctets rest_octets
746 } with { variant "" };
747
Harald Welte9419c8a2017-07-30 04:07:05 +0200748 type union RrUnion {
749/*
750 SystemInformationType1 si1,
751 SystemInformationType2 si2,
752 SystemInformationType2bis si2bis,
753 SystemInformationType2ter si2ter,
Harald Welte82ccef72018-02-25 16:17:33 +0100754 SystemInformationType3 si3,
Harald Welte9419c8a2017-07-30 04:07:05 +0200755 SystemInformationType4 si4,
756 SystemInformationType5 si5,
757 SystemInformationType5bis si5bis,
758 SystemInformationType5ter si5ter,
759 SystemInformationType6 si6,
760*/
761 ImmediateAssignment imm_ass,
762 ImmediateAssignmentReject imm_ass_rej,
763 PagingRequestType1 pag_req_1,
764 PagingRequestType2 pag_req_2,
765 PagingRequestType3 pag_req_3,
766 octetstring other
767 } with { variant "" };
768
769 /* Special RR Message on BCCH / CCCH Dowlink */
770
771 type record GsmRrMessage {
772 RrHeader header,
773 RrUnion payload
774 } with { variant (payload) "CROSSTAG(
775/*
776 si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
777 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
778 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
779 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
780 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
781 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
782 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
783 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
784 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
785 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
786*/
787 imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT;
788 imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT;
789 pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1;
790 pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2;
791 pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3;
792 other, OTHERWISE;
Vadim Yanitskiya4aacc22019-09-09 04:41:12 +0200793 )"
794 /* Total message length: 184 = 23 * 8. Pad spare bits with '2B'O. */
795 variant "PADDING(184), PADDING_PATTERN('00101011'B)"
796 };
Harald Welte9419c8a2017-07-30 04:07:05 +0200797
798 external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring
799 with { extension "prototype(convert) encode(RAW)" };
800 external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage
801 with { extension "prototype(convert) decode(RAW)" };
802
803 /* Normal L3 Message on Dedicated Channel */
804
805 /* 9.1.25 Paging Response */
806 type record PagingResponse {
807 uint4_t spare_half_octet,
808 CipheringKeySeqNr cksn,
809 MsClassmark2LV cm2,
810 MobileIdentityLV mi,
811 uint8_t addl_upd_par optional
812 } with { variant "" };
813
814 type union RrL3Union {
815 PagingResponse paging_response,
Harald Weltecbc947f2018-02-22 00:26:55 +0100816 MeasurementReport meas_rep,
Harald Welte9419c8a2017-07-30 04:07:05 +0200817 octetstring other
818 };
819
820 type record GsmRrL3Message {
821 RrL3Header header,
822 RrL3Union payload
823 } with { variant (payload) "CROSSTAG(
824 paging_response, header.message_type = PAGING_RESPONSE;
Harald Weltecbc947f2018-02-22 00:26:55 +0100825 meas_rep, header.message_type = MEASUREMENT_REPORT;
Harald Welte9419c8a2017-07-30 04:07:05 +0200826 other, OTHERWISE;
827 )" }
828
Harald Weltecbc947f2018-02-22 00:26:55 +0100829 external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring
830 with { extension "prototype(convert) encode(RAW)" };
831 external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message
832 with { extension "prototype(convert) decode(RAW)" };
833
834
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200835 template PacketDlAssign tr_PacketDlAssign(template GprsTlli tlli) := {
836 tlli := tlli,
837 group1_present := ?,
838 group1 := *,
839 ta_index_present := ?,
840 ta_index := *,
841 tbf_starting_time_present := ?,
842 tbf_starting_time := *,
843 p0_present := ?,
844 p0 := *,
845 pr_mode := *
846 };
847
848 template IaRestOctets tr_IaRestOctets_DLAss(template PacketDlAssign dl_ass) := {
849 presence := '11'B, /* HH */
850 ll := omit, lh := omit, hl := omit,
851 hh := {
852 pa_disc := '0'B, /* Packet Assignment (0) */
853 pa := {
854 uldl := {
855 ass_disc := '1'B, /* Downlink Assignment (1) */
856 ass := { dl := dl_ass }
857 }
858 }
859 }
860 };
861
862 template PacketUlAssign tr_PacketUlDynAssign(template uint5_t tfi := ?,
863 template BIT1 polling := ?,
864 template uint3_t usf := ?,
865 template BIT1 usf_granularity := ?,
866 template ChCodingCommand cs := ?) := {
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700867 presence := '1'B, /* Dynamic Block Allocation */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200868 dynamic := {
869 tfi_assignment := tfi,
870 polling := polling,
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700871 spare := '0'B, /* Dynamic Block Allocation (mandatory after Rel-4) */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200872 usf := usf,
873 usf_granularity := usf_granularity,
874 p0_present := ?,
875 p0 := *,
876 pr_mode := *,
877 ch_coding_cmd := cs,
878 tlli_block_chan_coding := ?,
879 alpha_present := ?,
880 alpha := *,
881 gamma := ?,
882 /* TODO: add to parameters */
883 ta_index_present := ?,
884 ta_index := *,
885 tbf_starting_time_present := ?,
886 tbf_starting_time := *
887 },
888 single := omit
889 };
890
891 template PacketUlAssign tr_PacketUlSglAssign := {
Vadim Yanitskiy06ca64d2019-09-29 20:17:10 +0700892 presence := '0'B, /* Single Block Allocation */
Vadim Yanitskiy7091e8d2019-09-09 01:07:37 +0200893 dynamic := omit,
894 single := {
895 alpha_present := ?,
896 alpha := *,
897 gamma := ?,
898 padding := '01'B,
899 tbf_starting_time := ?
900 }
901 };
902
903 template IaRestOctets tr_IaRestOctets_ULAss(template PacketUlAssign ul_ass) := {
904 presence := '11'B, /* HH */
905 ll := omit, lh := omit, hl := omit,
906 hh := {
907 pa_disc := '0'B, /* Packet Assignment (0) */
908 pa := {
909 uldl := {
910 ass_disc := '0'B, /* Uplink Assignment (0) */
911 ass := { ul := ul_ass }
912 }
913 }
914 }
915 };
916
Vadim Yanitskiya0b47cf2020-04-02 01:50:18 +0700917 template EgprsUlAss tr_EgprsUlAssDynamic(template (present) BIT5 ext_ra := ?,
918 template EgprsUlAssignDyn dyn_ass := ?) := {
919 ext_ra := ext_ra,
920 ats_present := ?,
921 ats := *,
922 presence := '1'B,
923 dynamic := dyn_ass,
924 multiblock := omit
925 };
926 template EgprsUlAss tr_EgprsUlAssMultiblock(template (present) BIT5 ext_ra := ?,
927 template EgprsUlAssignMultiblock mb_ass := ?) := {
928 ext_ra := ext_ra,
929 ats_present := ?,
930 ats := *,
931 presence := '0'B,
932 dynamic := omit,
933 multiblock := mb_ass
934 };
935
936 template IaRestOctets tr_IaRestOctets_EGPRSULAss(template EgprsUlAss ul_ass) := {
937 presence := '01'B, /* LH */
938 ll := omit,
939 lh := {
940 presence := '00'B,
941 egprs_ul := ul_ass,
942 multiblock_dl_ass := omit
943 },
944 hl := omit,
945 hh := omit
946 };
947
Harald Weltee8d750e2018-06-10 21:41:35 +0200948 template (value) GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, TimingAdvance ta,
Harald Weltecbc947f2018-02-22 00:26:55 +0100949 ChannelDescription ch_desc, MobileAllocation ma) := {
950 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
951 payload := {
952 imm_ass := {
953 ded_or_tbf := {
954 spare := '0'B,
955 tma := false,
956 downlink := false,
957 tbf := false
958 },
959 page_mode := PAGE_MODE_NORMAL,
960 chan_desc := ch_desc,
961 pkt_chan_desc := omit,
962 req_ref := f_compute_ReqRef(ra, fn),
963 timing_advance := ta,
964 mobile_allocation := ma,
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200965 rest_octets := {
966 presence := '00'B, /* LL */
967 ll := {
Vadim Yanitskiyb021ed42020-04-27 23:25:13 +0700968 compressed_irat_ho_info_ind := '0'B /* L */
Vadim Yanitskiy9b2a3e82019-09-08 15:37:15 +0200969 },
970 lh := omit, hl := omit, hh := omit
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200971 }
Harald Weltecbc947f2018-02-22 00:26:55 +0100972 }
973 }
974 };
975
Harald Weltee8d750e2018-06-10 21:41:35 +0200976 template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?,
977 template TimingAdvance ta := ?,
978 template ChannelDescription ch_desc := ?,
979 template MobileAllocation ma := ?) := {
Vadim Yanitskiyd4205c32019-09-09 16:15:37 +0200980 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
Harald Weltee8d750e2018-06-10 21:41:35 +0200981 payload := {
982 imm_ass := {
983 ded_or_tbf := {
984 spare := '0'B,
985 tma := false,
986 downlink := false,
987 tbf := false
988 },
989 page_mode := PAGE_MODE_NORMAL,
990 chan_desc := ch_desc,
991 pkt_chan_desc := omit,
992 req_ref := tr_compute_ReqRef(ra, fn),
993 timing_advance := ta,
994 mobile_allocation := ma,
Vadim Yanitskiyf10bb452019-09-05 13:53:01 +0200995 rest_octets := ?
Harald Weltee8d750e2018-06-10 21:41:35 +0200996 }
997 }
998 };
999
Vadim Yanitskiy6edd4f52019-09-09 01:51:09 +02001000 /* TODO: implement send version of this template */
1001 template GsmRrMessage tr_IMM_TBF_ASS(template boolean dl := ?,
1002 template uint8_t ra := ?,
1003 template GsmFrameNumber fn := ?,
1004 template TimingAdvance ta := ?,
1005 template PacketChannelDescription ch_desc := ?,
1006 template IaRestOctets rest := ?) := {
1007 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
1008 payload := {
1009 imm_ass := {
1010 ded_or_tbf := {
1011 spare := ?,
1012 tma := ?,
1013 downlink := dl,
1014 tbf := true
1015 },
1016 page_mode := ?,
1017 chan_desc := omit,
1018 pkt_chan_desc := ch_desc,
1019 req_ref := tr_compute_ReqRef(ra, fn),
1020 timing_advance := ta,
1021 mobile_allocation := ?,
1022 rest_octets := rest
1023 }
1024 }
1025 };
Harald Weltee8d750e2018-06-10 21:41:35 +02001026
Vadim Yanitskiy9781ecb2020-03-28 03:59:41 +07001027 template GsmRrMessage tr_PAG_REQ1(template MobileIdentityLV mi1 := ?,
1028 template MobileIdentityTLV mi2 := omit) := {
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001029 header := t_RrHeader(PAGING_REQUEST_TYPE_1, ?),
1030 payload := {
1031 pag_req_1 := {
1032 chan_needed := {
1033 second := ?,
1034 first := ?
1035 },
1036 page_mode := PAGE_MODE_NORMAL,
1037 mi1 := mi1,
Vadim Yanitskiy9781ecb2020-03-28 03:59:41 +07001038 mi2 := mi2,
Pau Espin Pedrol88bf5372019-12-09 21:12:28 +01001039 rest_octets := ?
1040 }
1041 }
1042 };
1043
Harald Weltecbc947f2018-02-22 00:26:55 +01001044 template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s,
1045 uint3_t rxq_f, uint3_t rxq_s,
1046 template (omit) NcellReports reps) := {
1047 header := t_RrL3Header(MEASUREMENT_REPORT),
1048 payload := {
1049 meas_rep := {
1050 meas_res := {
1051 ba_used := '0'B,
1052 dtx_used := '0'B,
1053 rxlev_full_srv_cell := rxl_f,
1054 threeg_ba_used := '0'B,
Harald Welteeb1e6812018-02-22 18:43:48 +01001055 meas_valid := bool2bit(not valid),
Harald Weltecbc947f2018-02-22 00:26:55 +01001056 rxlev_sub_srv_cell := rxl_s,
1057 si23_ba_used := '0'B,
1058 rxqual_full_srv_cell := rxq_f,
1059 rxqual_sub_srv_cell := rxq_s,
1060 no_ncell_m := 0,
1061 ncell_reports := reps
1062 }
1063 }
1064 }
1065 };
1066
Vadim Yanitskiy1175b5e2020-04-27 22:04:01 +07001067} with { encode "RAW" ; variant "FIELDORDER(msb)" variant "BYTEORDER(last)" }