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