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