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; |
Vadim Yanitskiy | 150d6d1 | 2022-10-20 19:10:04 +0700 | [diff] [blame] | 18 | import from GSM_RestOctets all; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 19 | import from RLCMAC_CSN1_Types all; |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 20 | import from MobileL3_CommonIE_Types all; |
Vadim Yanitskiy | 27b3801 | 2020-09-01 05:14:46 +0700 | [diff] [blame] | 21 | import from MobileL3_RRM_Types all; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 22 | |
| 23 | /* Table 10.4.1 of Section 10.4 / 3GPP TS 44.018 */ |
| 24 | type enumerated RrMessageType { |
| 25 | ADDITIONAL_ASSIGNMENT ('00111011'B), |
| 26 | IMMEDIATE_ASSIGNMENT ('00111111'B), |
| 27 | IMMEDIATE_ASSIGNMENT_EXTENDED ('00111001'B), |
| 28 | IMMEDIATE_ASSIGNMENT_REJECT ('00111010'B), |
| 29 | IMMEDIATE_PACKET_ASSIGNMENT ('01101001'B), |
| 30 | |
| 31 | CIPHERING_MODE_COMMAND ('00110101'B), |
| 32 | CIPHERING_MODE_COMPLETE ('00110010'B), |
| 33 | |
| 34 | CONFIGURATION_CHANGE_COMMAND ('00110000'B), |
| 35 | CONFIGURATION_CHANGE_ACK ('00110001'B), |
| 36 | CONFIGURATION_CHANGE_REJECT ('00110011'B), |
| 37 | |
| 38 | ASSIGNMENT_COMMAND ('00101110'B), |
| 39 | ASSIGNMENT_COMPLETE ('00101001'B), |
| 40 | ASSIGNMENT_FAILURE ('00101111'B), |
| 41 | HANDOVER_COMMAND ('00101011'B), |
| 42 | HANDOVER_COMPLETE ('00101100'B), |
| 43 | HANDOVER_FAILURE ('00101000'B), |
| 44 | PHYSICAL_INFORMATION ('00101101'B), |
| 45 | |
| 46 | CHANNEL_RELEASE ('00001101'B), |
| 47 | PARTIAL_RELEASE ('00001010'B), |
| 48 | PARTIAL_RELEASE_COMPLETE ('00001111'B), |
| 49 | |
| 50 | PAGING_REQUEST_TYPE_1 ('00100001'B), |
| 51 | PAGING_REQUEST_TYPE_2 ('00100010'B), |
| 52 | PAGING_REQUEST_TYPE_3 ('00100100'B), |
| 53 | PAGING_RESPONSE ('00100111'B), |
| 54 | NOTIFICATION_NCH ('00100000'B), |
| 55 | NOTIFICATION_RESPOSNE ('00100110'B), |
| 56 | |
| 57 | SYSTEM_INFORMATION_TYPE_8 ('00011000'B), |
| 58 | SYSTEM_INFORMATION_TYPE_1 ('00011001'B), |
| 59 | SYSTEM_INFORMATION_TYPE_2 ('00011010'B), |
| 60 | SYSTEM_INFORMATION_TYPE_3 ('00011011'B), |
| 61 | SYSTEM_INFORMATION_TYPE_4 ('00011100'B), |
| 62 | SYSTEM_INFORMATION_TYPE_5 ('00011101'B), |
| 63 | SYSTEM_INFORMATION_TYPE_6 ('00011110'B), |
| 64 | SYSTEM_INFORMATION_TYPE_7 ('00011111'B), |
| 65 | SYSTEM_INFORMATION_TYPE_2bis ('00000010'B), |
| 66 | SYSTEM_INFORMATION_TYPE_2ter ('00000011'B), |
| 67 | SYSTEM_INFORMATION_TYPE_2quater ('00000111'B), |
| 68 | SYSTEM_INFORMATION_TYPE_5bis ('00000101'B), |
| 69 | SYSTEM_INFORMATION_TYPE_5ter ('00000110'B), |
| 70 | SYSTEM_INFORMATION_TYPE_9 ('00000100'B), |
| 71 | SYSTEM_INFORMATION_TYPE_13 ('00000000'B), |
| 72 | |
| 73 | SYSTEM_INFORMATION_TYPE_16 ('00111101'B), |
| 74 | SYSTEM_INFORMATION_TYPE_17 ('00111110'B), |
| 75 | |
| 76 | CHANNEL_MODE_MODIFY ('00010000'B), |
| 77 | RR_STATUS ('00010010'B), |
| 78 | CHANNEL_MODE_MODIFY_ACKNOWLEDGE ('00010111'B), |
| 79 | FREQUENCY_REDEFINITION ('00010100'B), |
| 80 | MEASUREMENT_REPORT ('00010101'B), |
| 81 | CLASSMARK_CHANGE ('00010110'B), |
| 82 | CLASSMARK_ENQUIRY ('00010011'B), |
| 83 | EXTENDED_MEASUREMENT_REPORT ('00110110'B), |
| 84 | EXTENDED_MEASUREMENT_ORDER ('00110111'B), |
| 85 | GPRS_SUSPENSION_REQUEST ('00110100'B), |
| 86 | //MBMS_ANNOUNCEMENT ('00010110'B), duplicate? |
| 87 | //SERVICE_INFORMATION ('00110110'B), duplicate? |
| 88 | |
| 89 | APPLICATION_INFORMATION ('00111000'B), |
| 90 | |
| 91 | SYSTEM_INFORMATION_TYPE_14 ('00000001'B), |
| 92 | SYSTEM_INFORMATION_TYPE_15 ('01000011'B), |
| 93 | SYSTEM_INFORMATION_TYPE_18 ('01000000'B), |
| 94 | SYSTEM_INFORMATION_TYPE_19 ('01000001'B), |
| 95 | SYSTEM_INFORMATION_TYPE_20 ('01000010'B), |
| 96 | SYSTEM_INFORMATION_TYPE_13alt ('01000100'B), |
| 97 | SYSTEM_INFORMATION_TYPE_2n ('01000101'B), |
| 98 | SYSTEM_INFORMATION_TYPE_21 ('01000110'B), |
| 99 | SYSTEM_INFORMATION_TYPE_22 ('01000111'B), |
| 100 | SYSTEM_INFORMATION_TYPE_23 ('01001111'B), |
| 101 | |
| 102 | DTM_ASSIGNMENT_FAILURE ('01001000'B), |
| 103 | DTM_REJECT ('01001001'B), |
| 104 | DTM_REQUEST ('01001010'B), |
| 105 | PACKET_ASSIGNMENT ('01001011'B), |
| 106 | DTM_ASSIGNMENT_COMMAND ('01001100'B), |
| 107 | DTM_INFORMATION ('01001101'B), |
| 108 | PACKET_INFORMATION ('01001110'B), |
| 109 | |
| 110 | UTRAN_CLASSMARK_CHANGE ('01100000'B), |
| 111 | CDMA2000_CLASSMARK_CHANGE ('01100010'B), |
| 112 | INTERSYS_TO_UTRAN_HO_CMD ('01100011'B), |
| 113 | INTERSYS_TO_CDMA2000_HO_CMD ('01100100'B), |
| 114 | GERAN_IU_MODE_CLASSMARK_CHG ('01100101'B), |
| 115 | INTERSYS_TO_EUTRAN_HO_CMD ('01100110'B) |
| 116 | } with { variant "FIELDLENGTH(8)" }; |
| 117 | |
Neels Hofmeyr | 95a5edc | 2020-07-11 02:57:04 +0200 | [diff] [blame] | 118 | type enumerated RR_Cause { |
| 119 | GSM48_RR_CAUSE_NORMAL ('00'O), |
| 120 | GSM48_RR_CAUSE_ABNORMAL_UNSPEC ('01'O), |
| 121 | GSM48_RR_CAUSE_ABNORMAL_UNACCT ('02'O), |
| 122 | GSM48_RR_CAUSE_ABNORMAL_TIMER ('03'O), |
| 123 | GSM48_RR_CAUSE_ABNORMAL_NOACT ('04'O), |
| 124 | GSM48_RR_CAUSE_PREMPTIVE_REL ('05'O), |
| 125 | GSM48_RR_CAUSE_HNDOVER_IMP ('08'O), |
| 126 | GSM48_RR_CAUSE_CHAN_MODE_UNACCT ('09'O), |
| 127 | GSM48_RR_CAUSE_FREQ_NOT_IMPL ('0a'O), |
| 128 | GSM48_RR_CAUSE_CALL_CLEARED ('41'O), |
| 129 | GSM48_RR_CAUSE_SEMANT_INCORR ('5f'O), |
| 130 | GSM48_RR_CAUSE_INVALID_MAND_INF ('60'O), |
| 131 | GSM48_RR_CAUSE_MSG_TYPE_N ('61'O), |
| 132 | GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT('62'O), |
| 133 | GSM48_RR_CAUSE_COND_IE_ERROR ('64'O), |
| 134 | GSM48_RR_CAUSE_NO_CELL_ALLOC_A ('65'O), |
| 135 | GSM48_RR_CAUSE_PROT_ERROR_UNSPC ('6f'O) |
| 136 | } with { variant "FIELDLENGTH(8)" }; |
| 137 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 138 | type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 139 | |
| 140 | type record L2PseudoLength { |
| 141 | uint6_t l2_plen, |
| 142 | BIT2 zero_one |
| 143 | } with { variant "" }; |
| 144 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 145 | template L2PseudoLength tr_L2Pseudolength(template uint6_t len) := { |
| 146 | l2_plen := len, |
| 147 | zero_one := '01'B |
| 148 | }; |
| 149 | |
| 150 | template (value) L2PseudoLength ts_L2Pseudolength(uint6_t len) := { |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 151 | l2_plen := len, |
| 152 | zero_one := '01'B |
| 153 | }; |
| 154 | |
| 155 | type record RrHeader { |
| 156 | L2PseudoLength l2_plen, |
| 157 | uint4_t skip_indicator, |
| 158 | uint4_t rr_protocol_discriminator, |
| 159 | RrMessageType message_type |
| 160 | } with { variant "" }; |
| 161 | |
| 162 | template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 163 | l2_plen := tr_L2Pseudolength(len), |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 164 | skip_indicator := 0, |
| 165 | rr_protocol_discriminator := 6, |
| 166 | message_type := msg_type |
| 167 | }; |
| 168 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 169 | template (value) RrHeader ts_RrHeader(RrMessageType msg_type, uint6_t len) := { |
| 170 | l2_plen := ts_L2Pseudolength(len), |
| 171 | skip_indicator := 0, |
| 172 | rr_protocol_discriminator := 6, |
| 173 | message_type := msg_type |
| 174 | }; |
| 175 | |
| 176 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 177 | type record RrL3Header { |
| 178 | uint4_t skip_indicator, |
| 179 | uint4_t rr_protocol_discriminator, |
| 180 | RrMessageType message_type |
| 181 | } with { variant "" }; |
| 182 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 183 | template RrL3Header t_RrL3Header(RrMessageType msg_type) := { |
| 184 | skip_indicator := 0, |
| 185 | rr_protocol_discriminator := 6, |
| 186 | message_type := msg_type |
| 187 | } |
| 188 | |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 189 | /* TS 44.004 7.2.1 */ |
| 190 | type record SacchL1Header { |
| 191 | uint2_t reserved, |
| 192 | boolean fpc, |
| 193 | uint5_t ms_power_lvl, |
| 194 | uint8_t actual_ta |
| 195 | } with { variant "FIELDORDER(msb)" }; |
| 196 | |
Vadim Yanitskiy | 79da4ce | 2020-10-17 15:48:47 +0700 | [diff] [blame] | 197 | external function enc_SacchL1Header(in SacchL1Header hdr) return octetstring |
| 198 | with { extension "prototype(convert) encode(RAW)" }; |
| 199 | external function dec_SacchL1Header(in octetstring stream) return SacchL1Header |
| 200 | with { extension "prototype(convert) decode(RAW)" }; |
| 201 | |
Vadim Yanitskiy | 68c4cff | 2022-07-30 23:45:02 +0700 | [diff] [blame] | 202 | template (value) SacchL1Header |
| 203 | ts_SacchL1Header(uint5_t ms_power_lvl, |
| 204 | uint8_t actual_ta, |
| 205 | boolean fpc := false) := { |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 206 | reserved := 0, |
| 207 | fpc := fpc, |
| 208 | ms_power_lvl := ms_power_lvl, |
| 209 | actual_ta := actual_ta |
| 210 | }; |
| 211 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 212 | type record MaioHsn { |
Vadim Yanitskiy | ff0072c | 2020-05-27 01:35:39 +0700 | [diff] [blame] | 213 | uint6_t maio, |
| 214 | uint6_t hsn |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 215 | } with { variant "" }; |
| 216 | |
Vadim Yanitskiy | 5bcd919 | 2020-07-06 20:18:11 +0700 | [diff] [blame] | 217 | /* It's more handy to pass HSN first, so the arguments' order is reversed. */ |
| 218 | template (value) MaioHsn ts_HsnMaio(template (value) uint6_t hsn, |
| 219 | template (value) uint6_t maio) := { |
| 220 | maio := maio, |
| 221 | hsn := hsn |
| 222 | }; |
| 223 | template MaioHsn tr_HsnMaio(template (present) uint6_t hsn, |
| 224 | template (present) uint6_t maio) := { |
| 225 | maio := maio, |
| 226 | hsn := hsn |
| 227 | }; |
| 228 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 229 | /* TS 24.008 10.5.1.2 */ |
| 230 | type uint4_t CipheringKeySeqNr (0..7); |
| 231 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 232 | /* TS 24.008 10.5.1.4 */ |
| 233 | type enumerated MobileIdentityType { |
| 234 | MI_TYPE_NONE (0), |
| 235 | MI_TYPE_IMSI, |
| 236 | MI_TYPE_IMEI, |
| 237 | MI_TYPE_IMEISV, |
| 238 | MI_TYPE_TMSI, |
| 239 | MI_TYPE_TMGI |
| 240 | } with { variant "FIELDLENGTH(3)" }; |
| 241 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 242 | /* TS 24.008 10.5.1.5 */ |
| 243 | type record MsClassmark1 { |
| 244 | BIT1 spare, |
| 245 | uint2_t rev_level, |
| 246 | boolean es_ind, |
| 247 | boolean a51, |
| 248 | uint3_t rf_pwr_cap |
| 249 | } with { variant "" }; |
| 250 | |
| 251 | /* TS 24.008 10.5.1.6 */ |
| 252 | type record MsClassmark2 { |
| 253 | BIT1 spare, |
| 254 | uint2_t rev_level, |
| 255 | boolean es_ind, |
| 256 | boolean a51, |
| 257 | uint3_t rf_pwr_cap, |
| 258 | BIT1 spare1, |
| 259 | boolean ps_cap, |
| 260 | uint2_t ss_screen_ind, |
| 261 | boolean sm_cap, |
| 262 | boolean vbs, |
| 263 | boolean vgcs, |
| 264 | boolean fc, |
| 265 | boolean cm3, |
| 266 | BIT1 spare2, |
| 267 | boolean lcsva_cap, |
| 268 | boolean ucs2, |
| 269 | boolean solsa, |
| 270 | boolean cmsp, |
| 271 | boolean a53, |
| 272 | boolean a52 |
| 273 | } with { variant "" }; |
| 274 | type record MsClassmark2LV { |
| 275 | uint8_t len, |
| 276 | MsClassmark2 cm2 |
| 277 | } with { variant (len) "LENGTHTO(cm2)" }; |
| 278 | |
| 279 | |
| 280 | /* 44.018 10.5.2.5 */ |
| 281 | type record ChannelDescription { |
| 282 | RslChannelNr chan_nr, |
| 283 | uint3_t tsc, |
| 284 | boolean h, |
| 285 | uint12_t arfcn optional, |
| 286 | MaioHsn maio_hsn optional |
| 287 | } with { variant (arfcn) "PRESENCE(h = false)" |
| 288 | variant (maio_hsn) "PRESENCE(h = true)" }; |
| 289 | |
| 290 | type record ChannelDescriptionTV { |
| 291 | OCT1 iei, |
| 292 | ChannelDescription v |
| 293 | } with { variant "" }; |
| 294 | |
| 295 | /* 10.5.2.21 */ |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 296 | type record MobileAllocationLV { |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 297 | uint8_t len, |
Vadim Yanitskiy | 7d6eef3 | 2020-08-29 02:56:58 +0700 | [diff] [blame] | 298 | bitstring ma length (0..64) |
Vadim Yanitskiy | 3ddb3ab | 2020-07-20 04:29:53 +0700 | [diff] [blame] | 299 | } with { |
| 300 | variant (len) "LENGTHTO(ma)" |
Vadim Yanitskiy | e2a6fdf | 2020-07-23 04:53:02 +0700 | [diff] [blame] | 301 | variant (ma) "BYTEORDER(first), BITORDER(msb)" |
Vadim Yanitskiy | 3ddb3ab | 2020-07-20 04:29:53 +0700 | [diff] [blame] | 302 | }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 303 | |
Vadim Yanitskiy | 74e1f6b | 2020-08-25 03:59:45 +0700 | [diff] [blame] | 304 | type record MobileAllocationTLV { |
| 305 | OCT1 iei ('72'O), |
| 306 | MobileAllocationLV v |
| 307 | } with { variant "" }; |
| 308 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 309 | /* 10.5.2.25a */ |
Harald Welte | 1b9b770 | 2017-07-30 04:19:14 +0200 | [diff] [blame] | 310 | type record PktChDesc0Ind { |
| 311 | uint6_t maio, |
| 312 | BIT1 ma_number_ind, |
| 313 | BIT1 change_mark1_valid, |
| 314 | BIT2 change_mark1 |
| 315 | } with { variant "" }; |
| 316 | type record PktChDesc0 { |
| 317 | BIT1 hopping, |
| 318 | BIT1 spare ('0'B), |
| 319 | uint10_t arfcn optional, |
| 320 | PktChDesc0Ind indirect optional |
| 321 | } with { |
| 322 | variant (arfcn) "PRESENCE(hopping = '0'B)" |
| 323 | variant (indirect) "PRESENCE(hopping = '1'B)" |
| 324 | }; |
| 325 | type record PktChDesc1 { |
| 326 | uint6_t maio, |
| 327 | uint6_t hsn |
| 328 | } with { variant "" }; |
| 329 | type record PacketChannelDescription { |
| 330 | uint5_t channel_Type_spare, |
| 331 | uint3_t tn, |
| 332 | uint3_t tsc, |
| 333 | BIT1 presence, |
| 334 | PktChDesc0 zero optional, |
| 335 | PktChDesc1 one optional |
| 336 | } with { |
| 337 | variant (zero) "PRESENCE(presence = '0'B)" |
| 338 | variant (one) "PRESENCE(presence = '1'B)" |
| 339 | }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 340 | |
| 341 | /* 10.5.2.25b */ |
| 342 | type record DedicatedModeOrTbf { |
| 343 | BIT1 spare, |
| 344 | boolean tma, |
| 345 | boolean downlink, |
| 346 | boolean tbf |
| 347 | } with { variant "" }; |
| 348 | |
| 349 | /* 10.5.2.26 */ |
| 350 | type enumerated PageMode { |
| 351 | PAGE_MODE_NORMAL, |
| 352 | PAGE_MODE_EXTENDED, |
| 353 | PAGE_MODE_REORGANIZATION, |
| 354 | PAGE_MODE_SAME_AS_BEFORE |
| 355 | } with { variant "FIELDLENGTH(4)" }; |
| 356 | |
| 357 | /* 10.5.2.30 */ |
| 358 | type record RequestReference { |
| 359 | bitstring ra length(8), |
| 360 | uint5_t t1p, |
| 361 | uint6_t t3, |
| 362 | uint5_t t2 |
| 363 | } with { variant "" }; |
| 364 | |
| 365 | template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := { |
| 366 | ra := ra, |
| 367 | t1p := t1p, |
| 368 | t3 := t3, |
| 369 | t2 := t2 |
| 370 | } |
| 371 | |
| 372 | /* compute the expected request reference for given RA + FN */ |
| 373 | function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference { |
| 374 | var RequestReference req_ref := { ra := int2bit(ra, 8) }; |
| 375 | req_ref.t1p := (fn / 1326) mod 32; |
| 376 | req_ref.t2 := fn mod 26; |
| 377 | req_ref.t3 := fn mod 51; |
| 378 | return req_ref |
| 379 | } |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 380 | function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn) |
| 381 | return template RequestReference { |
| 382 | var template RequestReference req_ref; |
| 383 | if (istemplatekind(ra, "?")) { |
| 384 | req_ref.ra := ?; |
| 385 | } else { |
| 386 | req_ref.ra := int2bit(valueof(ra), 8); |
| 387 | } |
| 388 | if (istemplatekind(fn, "?")) { |
| 389 | req_ref.t1p := ?; |
| 390 | req_ref.t2 := ?; |
| 391 | req_ref.t3 := ?; |
| 392 | } else { |
| 393 | var GsmFrameNumber fn_v := valueof(fn); |
| 394 | req_ref.t1p := (fn_v / 1326) mod 32; |
| 395 | req_ref.t2 := fn_v mod 26; |
| 396 | req_ref.t3 := fn_v mod 51; |
| 397 | } |
| 398 | return req_ref; |
| 399 | } |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 400 | |
| 401 | /* 10.5.2.40 */ |
| 402 | type integer TimingAdvance (0..219); |
| 403 | |
| 404 | /* 10.5.2.43 */ |
| 405 | type uint8_t WaitIndication; |
| 406 | |
| 407 | /* 10.5.2.76 */ |
| 408 | type record FeatureIndicator { |
Vadim Yanitskiy | c3cebd3 | 2020-05-22 02:43:22 +0700 | [diff] [blame] | 409 | BIT2 peo_bcch_change_mark, |
| 410 | boolean cs_ir, |
| 411 | boolean ps_ir |
| 412 | } with { |
| 413 | variant (cs_ir) "FIELDLENGTH(1)" |
| 414 | variant (ps_ir) "FIELDLENGTH(1)" |
| 415 | }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 416 | |
| 417 | /* 24.008 10.5.5.6 */ |
| 418 | type record DrxParameter { |
| 419 | uint8_t split_pg_cycle_code, |
| 420 | uint4_t drx_cycle_len_coeff, |
| 421 | boolean split_on_ccch, |
| 422 | uint3_t non_drx_timer |
| 423 | } with { variant "" }; |
| 424 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 425 | type record MeasurementResults { |
| 426 | BIT1 ba_used, |
| 427 | BIT1 dtx_used, |
| 428 | uint6_t rxlev_full_srv_cell, |
| 429 | BIT1 threeg_ba_used, |
| 430 | BIT1 meas_valid, |
| 431 | uint6_t rxlev_sub_srv_cell, |
| 432 | BIT1 si23_ba_used, |
| 433 | uint3_t rxqual_full_srv_cell, |
| 434 | uint3_t rxqual_sub_srv_cell, |
| 435 | uint3_t no_ncell_m, |
| 436 | NcellReports ncell_reports optional |
| 437 | } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)" |
| 438 | variant (no_ncell_m) "UNIT(elements)" |
Vadim Yanitskiy | 9cbb86f | 2021-11-04 18:50:22 +0300 | [diff] [blame] | 439 | /* FIXME: pad to 16 octets */ |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 440 | }; |
| 441 | |
| 442 | type record NcellReport { |
| 443 | uint6_t rxlev, |
| 444 | uint5_t bcch_freq, |
| 445 | uint6_t bsic |
| 446 | } with { variant ""}; |
| 447 | type record of NcellReport NcellReports; |
| 448 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 449 | |
Vadim Yanitskiy | 27b3801 | 2020-09-01 05:14:46 +0700 | [diff] [blame] | 450 | /* 3GPP TS 44.018, section 9.1.2 (minimalistic implementation) */ |
| 451 | type record AssignmentCommand { |
| 452 | ChannelDescription chan_desc, |
| 453 | PowerCommand_V power_cmd, |
| 454 | FrequencyList_TLV freq_list_at optional, |
| 455 | CellChannelDescription_TV cell_chan_desc optional, |
| 456 | /* TODO: Multislot Allocation IE */ |
| 457 | ChannelMode_TV chan1_mode optional, |
| 458 | ChannelMode_TV chan2_mode optional, |
| 459 | /* TODO: Mode of Channel Set 3..8 IE */ |
| 460 | MobileAllocationTLV mobile_allocation optional |
| 461 | /* TODO: more optional IEs... */ |
| 462 | } with { |
| 463 | variant "TAG( |
| 464 | freq_list_at, elementIdentifier = '05'O; |
| 465 | cell_chan_desc, elementIdentifier = '62'O; |
| 466 | chan1_mode, elementIdentifier = '63'O; |
| 467 | chan2_mode, elementIdentifier = '11'O; |
| 468 | mobile_allocation, iei = '72'O; |
| 469 | )" |
| 470 | }; |
| 471 | |
Vadim Yanitskiy | 5fec37c | 2020-09-02 17:19:47 +0700 | [diff] [blame] | 472 | /* 3GPP TS 44.018, section 9.1.15 (minimalistic implementation) */ |
| 473 | type record HandoverCommand { |
| 474 | CellDescriptionV cell_desc, |
| 475 | ChannelDescription chan_desc, |
| 476 | OCT1 ho_ref, |
| 477 | PowerCommandAndAccesstype_V power_cmd_acc_type, |
| 478 | FrequencyList_TLV freq_list_at optional, |
| 479 | CellChannelDescription_TV cell_chan_desc optional, |
| 480 | ChannelMode_TV chan1_mode optional, |
| 481 | ChannelMode_TV chan2_mode optional, |
| 482 | /* TODO: Mode of Channel Set 3..8 IE */ |
| 483 | MobileAllocationTLV mobile_allocation optional |
| 484 | /* TODO: more optional IEs... */ |
| 485 | } with { |
| 486 | variant "TAG( |
| 487 | freq_list_at, elementIdentifier = '05'O; |
| 488 | cell_chan_desc, elementIdentifier = '62'O; |
| 489 | chan1_mode, elementIdentifier = '63'O; |
| 490 | chan2_mode, elementIdentifier = '11'O; |
| 491 | mobile_allocation, iei = '72'O; |
| 492 | )" |
| 493 | }; |
| 494 | |
| 495 | /* 10.5.2.2 Cell Description IE */ |
| 496 | type record CellDescriptionV { |
| 497 | uint3_t bcc, /* PLMN colour code */ |
| 498 | uint3_t ncc, /* BS colour code */ |
| 499 | uint10_t bcch_arfcn |
| 500 | } with { variant "FIELDORDER(lsb)" }; |
| 501 | |
Vadim Yanitskiy | 27b3801 | 2020-09-01 05:14:46 +0700 | [diff] [blame] | 502 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 503 | /* 9.1.18 */ |
| 504 | type record ImmediateAssignment { |
| 505 | DedicatedModeOrTbf ded_or_tbf, |
| 506 | PageMode page_mode, |
| 507 | ChannelDescription chan_desc optional, |
| 508 | PacketChannelDescription pkt_chan_desc optional, |
| 509 | RequestReference req_ref, |
| 510 | TimingAdvance timing_advance, |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 511 | MobileAllocationLV mobile_allocation, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 512 | /* TODO: starting time TLV */ |
Vadim Yanitskiy | f10bb45 | 2019-09-05 13:53:01 +0200 | [diff] [blame] | 513 | IaRestOctets rest_octets |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 514 | } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)" |
Vadim Yanitskiy | a4aacc2 | 2019-09-09 04:41:12 +0200 | [diff] [blame] | 515 | variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 516 | |
| 517 | /* 9.1.20 */ |
| 518 | type record ReqRefWaitInd { |
| 519 | RequestReference req_ref, |
| 520 | WaitIndication wait_ind |
| 521 | } with { variant "" }; |
| 522 | type record length(4) of ReqRefWaitInd ReqRefWaitInd4; |
| 523 | type record ImmediateAssignmentReject { |
| 524 | FeatureIndicator feature_ind, |
| 525 | PageMode page_mode, |
Vadim Yanitskiy | 7ef121d | 2020-05-22 03:04:22 +0700 | [diff] [blame] | 526 | ReqRefWaitInd4 payload, |
| 527 | IARRestOctets rest_octets |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 528 | } with { variant "" }; |
| 529 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 530 | /* 9.1.21 */ |
| 531 | type record MeasurementReport { |
| 532 | MeasurementResults meas_res |
| 533 | } with { variant "" }; |
| 534 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 535 | /* 9.1.22 */ |
| 536 | type record PagingRequestType1 { |
| 537 | ChannelNeeded12 chan_needed, |
| 538 | PageMode page_mode, |
| 539 | MobileIdentityLV mi1, |
| 540 | MobileIdentityTLV mi2 optional, |
| 541 | RestOctets rest_octets |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 542 | } with { variant "TAG(mi2, elementIdentifier = '0010111'B)" }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 543 | |
| 544 | /* 9.1.23 */ |
| 545 | type record PagingRequestType2 { |
| 546 | ChannelNeeded12 chan_needed, |
| 547 | PageMode page_mode, |
| 548 | GsmTmsi mi1, |
| 549 | GsmTmsi mi2, |
| 550 | MobileIdentityTLV mi3 optional, |
| 551 | RestOctets rest_octets |
Vadim Yanitskiy | 98bb2d5 | 2020-03-28 00:57:21 +0700 | [diff] [blame] | 552 | } with { variant "TAG(mi3, elementIdentifier = '0010111'B)" }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 553 | |
| 554 | /* 9.1.24 */ |
| 555 | type record length(4) of GsmTmsi GsmTmsi4; |
| 556 | type record PagingRequestType3 { |
| 557 | ChannelNeeded12 chan_needed, |
| 558 | PageMode page_mode, |
| 559 | GsmTmsi4 mi, |
| 560 | RestOctets rest_octets |
| 561 | } with { variant "" }; |
| 562 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 563 | type union RrUnion { |
| 564 | /* |
| 565 | SystemInformationType1 si1, |
| 566 | SystemInformationType2 si2, |
| 567 | SystemInformationType2bis si2bis, |
| 568 | SystemInformationType2ter si2ter, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 569 | SystemInformationType3 si3, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 570 | SystemInformationType4 si4, |
| 571 | SystemInformationType5 si5, |
| 572 | SystemInformationType5bis si5bis, |
| 573 | SystemInformationType5ter si5ter, |
| 574 | SystemInformationType6 si6, |
| 575 | */ |
| 576 | ImmediateAssignment imm_ass, |
| 577 | ImmediateAssignmentReject imm_ass_rej, |
| 578 | PagingRequestType1 pag_req_1, |
| 579 | PagingRequestType2 pag_req_2, |
| 580 | PagingRequestType3 pag_req_3, |
| 581 | octetstring other |
| 582 | } with { variant "" }; |
| 583 | |
| 584 | /* Special RR Message on BCCH / CCCH Dowlink */ |
| 585 | |
| 586 | type record GsmRrMessage { |
| 587 | RrHeader header, |
| 588 | RrUnion payload |
| 589 | } with { variant (payload) "CROSSTAG( |
| 590 | /* |
| 591 | si1, header.message_type = SYSTEM_INFORMATION_TYPE_1; |
| 592 | si2, header.message_type = SYSTEM_INFORMATION_TYPE_2; |
| 593 | si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis; |
| 594 | si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter; |
| 595 | si3, header.message_type = SYSTEM_INFORMATION_TYPE_3; |
| 596 | si4, header.message_type = SYSTEM_INFORMATION_TYPE_4; |
| 597 | si5, header.message_type = SYSTEM_INFORMATION_TYPE_5; |
| 598 | si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis; |
| 599 | si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter; |
| 600 | si6, header.message_type = SYSTEM_INFORMATION_TYPE_6; |
| 601 | */ |
| 602 | imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT; |
| 603 | imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT; |
| 604 | pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1; |
| 605 | pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2; |
| 606 | pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3; |
| 607 | other, OTHERWISE; |
Vadim Yanitskiy | a4aacc2 | 2019-09-09 04:41:12 +0200 | [diff] [blame] | 608 | )" |
| 609 | /* Total message length: 184 = 23 * 8. Pad spare bits with '2B'O. */ |
| 610 | variant "PADDING(184), PADDING_PATTERN('00101011'B)" |
| 611 | }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 612 | |
| 613 | external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring |
| 614 | with { extension "prototype(convert) encode(RAW)" }; |
| 615 | external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage |
| 616 | with { extension "prototype(convert) decode(RAW)" }; |
| 617 | |
| 618 | /* Normal L3 Message on Dedicated Channel */ |
| 619 | |
| 620 | /* 9.1.25 Paging Response */ |
| 621 | type record PagingResponse { |
| 622 | uint4_t spare_half_octet, |
| 623 | CipheringKeySeqNr cksn, |
| 624 | MsClassmark2LV cm2, |
| 625 | MobileIdentityLV mi, |
| 626 | uint8_t addl_upd_par optional |
| 627 | } with { variant "" }; |
| 628 | |
| 629 | type union RrL3Union { |
Vadim Yanitskiy | 480c2ac | 2020-09-01 05:43:06 +0700 | [diff] [blame] | 630 | PagingResponse paging_response, |
| 631 | MeasurementReport meas_rep, |
| 632 | AssignmentCommand ass_cmd, |
Vadim Yanitskiy | 5fec37c | 2020-09-02 17:19:47 +0700 | [diff] [blame] | 633 | HandoverCommand ho_cmd, |
Vadim Yanitskiy | 480c2ac | 2020-09-01 05:43:06 +0700 | [diff] [blame] | 634 | octetstring other |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 635 | }; |
| 636 | |
| 637 | type record GsmRrL3Message { |
| 638 | RrL3Header header, |
| 639 | RrL3Union payload |
| 640 | } with { variant (payload) "CROSSTAG( |
| 641 | paging_response, header.message_type = PAGING_RESPONSE; |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 642 | meas_rep, header.message_type = MEASUREMENT_REPORT; |
Vadim Yanitskiy | 27b3801 | 2020-09-01 05:14:46 +0700 | [diff] [blame] | 643 | ass_cmd, header.message_type = ASSIGNMENT_COMMAND; |
Vadim Yanitskiy | 5fec37c | 2020-09-02 17:19:47 +0700 | [diff] [blame] | 644 | ho_cmd, header.message_type = HANDOVER_COMMAND; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 645 | other, OTHERWISE; |
| 646 | )" } |
| 647 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 648 | external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring |
| 649 | with { extension "prototype(convert) encode(RAW)" }; |
| 650 | external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message |
| 651 | with { extension "prototype(convert) decode(RAW)" }; |
| 652 | |
| 653 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 654 | 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] | 655 | ChannelDescription ch_desc, MobileAllocationLV ma) := { |
Harald Welte | bae6be8 | 2020-08-21 12:42:18 +0200 | [diff] [blame] | 656 | header := ts_RrHeader(IMMEDIATE_ASSIGNMENT, 0), |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 657 | payload := { |
| 658 | imm_ass := { |
| 659 | ded_or_tbf := { |
| 660 | spare := '0'B, |
| 661 | tma := false, |
| 662 | downlink := false, |
| 663 | tbf := false |
| 664 | }, |
| 665 | page_mode := PAGE_MODE_NORMAL, |
| 666 | chan_desc := ch_desc, |
| 667 | pkt_chan_desc := omit, |
| 668 | req_ref := f_compute_ReqRef(ra, fn), |
| 669 | timing_advance := ta, |
| 670 | mobile_allocation := ma, |
Vadim Yanitskiy | f10bb45 | 2019-09-05 13:53:01 +0200 | [diff] [blame] | 671 | rest_octets := { |
| 672 | presence := '00'B, /* LL */ |
| 673 | ll := { |
Vadim Yanitskiy | b021ed4 | 2020-04-27 23:25:13 +0700 | [diff] [blame] | 674 | compressed_irat_ho_info_ind := '0'B /* L */ |
Vadim Yanitskiy | 9b2a3e8 | 2019-09-08 15:37:15 +0200 | [diff] [blame] | 675 | }, |
| 676 | lh := omit, hl := omit, hh := omit |
Vadim Yanitskiy | f10bb45 | 2019-09-05 13:53:01 +0200 | [diff] [blame] | 677 | } |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 678 | } |
| 679 | } |
| 680 | }; |
| 681 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 682 | template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?, |
| 683 | template TimingAdvance ta := ?, |
| 684 | template ChannelDescription ch_desc := ?, |
Neels Hofmeyr | b07b295 | 2021-08-07 04:23:14 +0200 | [diff] [blame] | 685 | template MobileAllocationLV ma := ?, |
| 686 | template PageMode page_mode := PAGE_MODE_NORMAL) := { |
Vadim Yanitskiy | d4205c3 | 2019-09-09 16:15:37 +0200 | [diff] [blame] | 687 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 688 | payload := { |
| 689 | imm_ass := { |
| 690 | ded_or_tbf := { |
| 691 | spare := '0'B, |
| 692 | tma := false, |
| 693 | downlink := false, |
| 694 | tbf := false |
| 695 | }, |
Neels Hofmeyr | b07b295 | 2021-08-07 04:23:14 +0200 | [diff] [blame] | 696 | page_mode := page_mode, |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 697 | chan_desc := ch_desc, |
| 698 | pkt_chan_desc := omit, |
| 699 | req_ref := tr_compute_ReqRef(ra, fn), |
| 700 | timing_advance := ta, |
| 701 | mobile_allocation := ma, |
Vadim Yanitskiy | f10bb45 | 2019-09-05 13:53:01 +0200 | [diff] [blame] | 702 | rest_octets := ? |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | }; |
| 706 | |
Vadim Yanitskiy | 6edd4f5 | 2019-09-09 01:51:09 +0200 | [diff] [blame] | 707 | /* TODO: implement send version of this template */ |
| 708 | template GsmRrMessage tr_IMM_TBF_ASS(template boolean dl := ?, |
| 709 | template uint8_t ra := ?, |
| 710 | template GsmFrameNumber fn := ?, |
| 711 | template TimingAdvance ta := ?, |
| 712 | template PacketChannelDescription ch_desc := ?, |
Vadim Yanitskiy | 3b464a9 | 2020-08-25 03:55:32 +0700 | [diff] [blame] | 713 | template MobileAllocationLV ma := ?, |
Vadim Yanitskiy | 6edd4f5 | 2019-09-09 01:51:09 +0200 | [diff] [blame] | 714 | template IaRestOctets rest := ?) := { |
| 715 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
| 716 | payload := { |
| 717 | imm_ass := { |
| 718 | ded_or_tbf := { |
| 719 | spare := ?, |
| 720 | tma := ?, |
| 721 | downlink := dl, |
| 722 | tbf := true |
| 723 | }, |
| 724 | page_mode := ?, |
| 725 | chan_desc := omit, |
| 726 | pkt_chan_desc := ch_desc, |
| 727 | req_ref := tr_compute_ReqRef(ra, fn), |
| 728 | timing_advance := ta, |
Vadim Yanitskiy | cf1ed3f | 2020-07-20 04:01:43 +0700 | [diff] [blame] | 729 | mobile_allocation := ma, |
Vadim Yanitskiy | 6edd4f5 | 2019-09-09 01:51:09 +0200 | [diff] [blame] | 730 | rest_octets := rest |
| 731 | } |
| 732 | } |
| 733 | }; |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 734 | |
Vadim Yanitskiy | 9781ecb | 2020-03-28 03:59:41 +0700 | [diff] [blame] | 735 | template GsmRrMessage tr_PAG_REQ1(template MobileIdentityLV mi1 := ?, |
| 736 | template MobileIdentityTLV mi2 := omit) := { |
Pau Espin Pedrol | 88bf537 | 2019-12-09 21:12:28 +0100 | [diff] [blame] | 737 | header := t_RrHeader(PAGING_REQUEST_TYPE_1, ?), |
| 738 | payload := { |
| 739 | pag_req_1 := { |
| 740 | chan_needed := { |
| 741 | second := ?, |
| 742 | first := ? |
| 743 | }, |
| 744 | page_mode := PAGE_MODE_NORMAL, |
| 745 | mi1 := mi1, |
Vadim Yanitskiy | 9781ecb | 2020-03-28 03:59:41 +0700 | [diff] [blame] | 746 | mi2 := mi2, |
Pau Espin Pedrol | 88bf537 | 2019-12-09 21:12:28 +0100 | [diff] [blame] | 747 | rest_octets := ? |
| 748 | } |
| 749 | } |
| 750 | }; |
| 751 | |
Vadim Yanitskiy | f9e31d2 | 2021-11-06 18:43:28 +0300 | [diff] [blame] | 752 | template (value) MeasurementResults |
| 753 | ts_MeasurementResults(template (value) uint6_t rxl_f := 63, |
| 754 | template (value) uint6_t rxl_s := 63, |
| 755 | template (value) uint3_t rxq_f := 0, |
| 756 | template (value) uint3_t rxq_s := 0, |
| 757 | boolean dtx_used := false, |
| 758 | boolean valid := true, |
| 759 | template (omit) NcellReports reps := omit) := { |
| 760 | ba_used := '0'B, |
| 761 | dtx_used := bool2bit(dtx_used), |
| 762 | rxlev_full_srv_cell := rxl_f, |
| 763 | threeg_ba_used := '0'B, |
| 764 | meas_valid := bool2bit(not valid), |
| 765 | rxlev_sub_srv_cell := rxl_s, |
| 766 | si23_ba_used := '0'B, |
| 767 | rxqual_full_srv_cell := rxq_f, |
| 768 | rxqual_sub_srv_cell := rxq_s, |
| 769 | no_ncell_m := 0, |
| 770 | ncell_reports := reps |
| 771 | }; |
| 772 | |
Vadim Yanitskiy | bc8ebce | 2020-11-11 19:31:56 +0700 | [diff] [blame] | 773 | template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, |
| 774 | template (value) uint6_t rxl_f, |
| 775 | template (value) uint6_t rxl_s, |
| 776 | template (value) uint3_t rxq_f := 0, |
| 777 | template (value) uint3_t rxq_s := 0, |
| 778 | template (omit) NcellReports reps := omit) := { |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 779 | header := t_RrL3Header(MEASUREMENT_REPORT), |
| 780 | payload := { |
| 781 | meas_rep := { |
| 782 | meas_res := { |
| 783 | ba_used := '0'B, |
| 784 | dtx_used := '0'B, |
| 785 | rxlev_full_srv_cell := rxl_f, |
| 786 | threeg_ba_used := '0'B, |
Harald Welte | eb1e681 | 2018-02-22 18:43:48 +0100 | [diff] [blame] | 787 | meas_valid := bool2bit(not valid), |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 788 | rxlev_sub_srv_cell := rxl_s, |
| 789 | si23_ba_used := '0'B, |
| 790 | rxqual_full_srv_cell := rxq_f, |
| 791 | rxqual_sub_srv_cell := rxq_s, |
| 792 | no_ncell_m := 0, |
| 793 | ncell_reports := reps |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | }; |
| 798 | |
Vadim Yanitskiy | 16e24aa | 2020-05-22 03:32:00 +0700 | [diff] [blame] | 799 | template GsmRrMessage tr_IMM_ASS_REJ(template FeatureIndicator feature_ind := ?, |
| 800 | template ReqRefWaitInd4 rr_wi_list := ?, |
| 801 | template IARRestOctets rest_octets := ?) := { |
| 802 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT_REJECT, ?), |
| 803 | payload := { |
| 804 | imm_ass_rej := { |
| 805 | feature_ind := feature_ind, |
| 806 | page_mode := ?, |
| 807 | payload := rr_wi_list, |
| 808 | rest_octets := rest_octets |
| 809 | } |
| 810 | } |
| 811 | }; |
| 812 | |
| 813 | template ReqRefWaitInd tr_ReqRefWaitInd(template RequestReference ref := ?, |
| 814 | template WaitIndication wi := ?) := { |
| 815 | req_ref := ref, |
| 816 | wait_ind := wi |
| 817 | }; |
| 818 | |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 819 | template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, |
| 820 | template (value) uint12_t arfcn, |
| 821 | template (value) uint3_t tsc := 7) := { |
| 822 | chan_nr := chan_nr, |
| 823 | tsc := tsc, |
| 824 | h := false, |
| 825 | arfcn := arfcn, |
| 826 | maio_hsn := omit |
| 827 | } |
Vadim Yanitskiy | c3156ed | 2020-08-29 17:49:27 +0700 | [diff] [blame] | 828 | template ChannelDescription tr_ChanDescH0(template (present) RslChannelNr chan_nr := ?, |
| 829 | template (present) uint12_t arfcn := ?, |
| 830 | template (present) uint3_t tsc := ?) := { |
| 831 | chan_nr := chan_nr, |
| 832 | tsc := tsc, |
| 833 | h := false, |
| 834 | arfcn := arfcn, |
| 835 | maio_hsn := omit |
| 836 | } |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 837 | |
| 838 | template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, |
| 839 | template (value) MaioHsn maio_hsn, |
| 840 | template (value) uint3_t tsc := 7) := { |
| 841 | chan_nr := chan_nr, |
| 842 | tsc := tsc, |
| 843 | h := true, |
| 844 | arfcn := omit, |
| 845 | maio_hsn := maio_hsn |
| 846 | } |
Vadim Yanitskiy | c3156ed | 2020-08-29 17:49:27 +0700 | [diff] [blame] | 847 | template ChannelDescription tr_ChanDescH1(template (present) RslChannelNr chan_nr := ?, |
| 848 | template (present) MaioHsn maio_hsn := ?, |
| 849 | template (present) uint3_t tsc := ?) := { |
| 850 | chan_nr := chan_nr, |
| 851 | tsc := tsc, |
| 852 | h := true, |
| 853 | arfcn := omit, |
| 854 | maio_hsn := maio_hsn |
| 855 | } |
Vadim Yanitskiy | f7181ed | 2020-07-14 20:12:02 +0700 | [diff] [blame] | 856 | |
Neels Hofmeyr | 0edf4ac | 2020-07-10 17:33:24 +0200 | [diff] [blame] | 857 | |
| 858 | /* Templates for the RR Channel Release message's "Cell selection indicator after release of all TCH and SDCCH" IE. |
| 859 | * See 3GPP TS 44.018 9.1.7 and 10.5.2.1e */ |
| 860 | |
| 861 | /* 3GPP TS 44.018 10.5.2.1e, Cell Selection Indicator after release of all TCH and SDCCH value part */ |
| 862 | type record CellSelIndValue { |
| 863 | BIT3 discr, |
| 864 | CellSelIndValueEnum value_list, |
| 865 | BIT1 value_list_term ('0'B) |
| 866 | } with { |
| 867 | variant (value_list) "CROSSTAG( |
| 868 | gsm, discr='000'B; |
| 869 | utran_fdd, discr='001'B; |
| 870 | utran_tdd, discr='010'B; |
| 871 | eutran, discr='011'B; |
| 872 | )" |
| 873 | }; |
| 874 | |
| 875 | /* 3GPP TS 44.018 10.5.2.1e, Cell Selection Indicator after release of all TCH and SDCCH value part */ |
| 876 | private type union CellSelIndValueEnum { |
| 877 | CellSelIndValue_GSM_Descrs gsm, |
| 878 | CellSelIndValue_UTRAN_Descrs utran_fdd, |
| 879 | CellSelIndValue_UTRAN_Descrs utran_tdd, |
| 880 | CellSelIndValue_EUTRAN_Descrs eutran |
| 881 | } with { variant "" }; |
| 882 | |
| 883 | type record of CellSelIndValue_GSM_Descr CellSelIndValue_GSM_Descrs; |
| 884 | /* 3GPP TS 44.018 10.5.2.1e, GSM Description struct */ |
| 885 | type record CellSelIndValue_GSM_Descr { |
| 886 | BIT1 item_ind ('1'B), |
| 887 | BIT1 band_indicator, |
| 888 | uint10_t arfcn, |
| 889 | uint6_t bsic |
| 890 | } with { |
| 891 | variant "PRESENCE(item_ind = '1'B)" |
| 892 | }; |
| 893 | |
| 894 | type record of CellSelIndValue_UTRAN_Descr CellSelIndValue_UTRAN_Descrs; |
| 895 | /* 3GPP TS 44.018 10.5.2.1e, UTRAN {FDD,TDD} Description struct */ |
| 896 | type record CellSelIndValue_UTRAN_Descr { |
| 897 | BIT1 item_ind ('1'B), |
| 898 | BIT1 bandwidth_presence, |
| 899 | uint3_t bandwidth optional, |
| 900 | uint14_t arfcn, |
| 901 | BIT1 cell_info_presence, |
| 902 | UTRAN_CellInfo cell_info optional |
| 903 | } with { |
| 904 | variant "PRESENCE(item_ind = '1'B)" |
| 905 | variant (bandwidth) "PRESENCE(bandwidth_presence = '1'B)" |
| 906 | variant (cell_info) "PRESENCE(cell_info_presence = '1'B)" |
| 907 | }; |
| 908 | type record UTRAN_CellInfo { |
| 909 | BIT1 indic0, |
| 910 | uint5_t nr_of_cells, |
| 911 | // TODO: define cell_information_field |
| 912 | octetstring cell_information_field |
| 913 | } with { variant "" }; |
| 914 | |
| 915 | type record of CellSelIndValue_EUTRAN_Descr CellSelIndValue_EUTRAN_Descrs; |
| 916 | /* 3GPP TS 44.018 10.5.2.1e, E-UTRAN Description struct */ |
| 917 | type record CellSelIndValue_EUTRAN_Descr { |
| 918 | BIT1 item_ind ('1'B), |
| 919 | uint16_t earfcn, |
| 920 | BIT1 meas_bw_presence, |
| 921 | uint3_t meas_bw optional, |
| 922 | BIT1 not_allowed_cells_presence, |
| 923 | // define not_allowed_cells |
| 924 | octetstring not_allowed_cells optional, |
| 925 | BIT1 target_pcid_presence, |
| 926 | uint9_t target_pcid optional |
| 927 | } with { |
| 928 | variant "PRESENCE(item_ind = '1'B)" |
| 929 | variant (meas_bw) "PRESENCE(meas_bw_presence = '1'B)" |
| 930 | variant (not_allowed_cells) "PRESENCE(not_allowed_cells_presence = '1'B)" |
| 931 | variant (target_pcid) "PRESENCE(target_pcid_presence = '1'B)" |
| 932 | }; |
| 933 | |
| 934 | template CellSelIndValue tr_CellSelIndValue_EUTRAN( |
| 935 | template CellSelIndValue_EUTRAN_Descrs cells := {}) |
| 936 | := { |
| 937 | discr := '011'B, |
| 938 | value_list := { |
| 939 | eutran := cells |
| 940 | }, |
| 941 | value_list_term := '0'B |
| 942 | }; |
| 943 | |
| 944 | template CellSelIndValue_EUTRAN_Descr tr_CellSelIndValue_EUTRAN_Descr( |
| 945 | template (present) uint16_t earfcn, |
| 946 | template (present) BIT1 meas_bw_presence := ?, |
| 947 | template uint3_t meas_bw := *) |
| 948 | := { |
| 949 | item_ind := '1'B, |
| 950 | earfcn := earfcn, |
| 951 | meas_bw_presence := meas_bw_presence, |
| 952 | meas_bw := meas_bw, |
| 953 | not_allowed_cells_presence := '0'B, |
| 954 | not_allowed_cells := omit, |
| 955 | target_pcid_presence := '0'B, |
| 956 | target_pcid := omit |
| 957 | }; |
| 958 | |
| 959 | external function enc_CellSelIndValue(in CellSelIndValue ro) return octetstring |
| 960 | with { extension "prototype(convert) encode(RAW)" }; |
| 961 | external function dec_CellSelIndValue(in octetstring stream) return CellSelIndValue |
| 962 | with { extension "prototype(convert) decode(RAW)" }; |
| 963 | |
Vadim Yanitskiy | e05d716 | 2020-05-02 16:58:46 +0700 | [diff] [blame] | 964 | } with { encode "RAW" ; variant "FIELDORDER(msb)" } |