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