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