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