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