Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 1 | /* Encoding/Decoding routines for GSM System Information messages |
| 2 | * according to 3GPP TS 44.018 Version 12.3.0 Release 12 */ |
| 3 | |
| 4 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org> */ |
| 5 | |
| 6 | module GSM_RR_Types { |
| 7 | |
| 8 | import from General_Types all; |
| 9 | import from Osmocom_Types all; |
| 10 | import from GSM_Types all; |
| 11 | import from RLCMAC_CSN1_Types all; |
| 12 | |
| 13 | /* Table 10.4.1 of Section 10.4 / 3GPP TS 44.018 */ |
| 14 | type enumerated RrMessageType { |
| 15 | ADDITIONAL_ASSIGNMENT ('00111011'B), |
| 16 | IMMEDIATE_ASSIGNMENT ('00111111'B), |
| 17 | IMMEDIATE_ASSIGNMENT_EXTENDED ('00111001'B), |
| 18 | IMMEDIATE_ASSIGNMENT_REJECT ('00111010'B), |
| 19 | IMMEDIATE_PACKET_ASSIGNMENT ('01101001'B), |
| 20 | |
| 21 | CIPHERING_MODE_COMMAND ('00110101'B), |
| 22 | CIPHERING_MODE_COMPLETE ('00110010'B), |
| 23 | |
| 24 | CONFIGURATION_CHANGE_COMMAND ('00110000'B), |
| 25 | CONFIGURATION_CHANGE_ACK ('00110001'B), |
| 26 | CONFIGURATION_CHANGE_REJECT ('00110011'B), |
| 27 | |
| 28 | ASSIGNMENT_COMMAND ('00101110'B), |
| 29 | ASSIGNMENT_COMPLETE ('00101001'B), |
| 30 | ASSIGNMENT_FAILURE ('00101111'B), |
| 31 | HANDOVER_COMMAND ('00101011'B), |
| 32 | HANDOVER_COMPLETE ('00101100'B), |
| 33 | HANDOVER_FAILURE ('00101000'B), |
| 34 | PHYSICAL_INFORMATION ('00101101'B), |
| 35 | |
| 36 | CHANNEL_RELEASE ('00001101'B), |
| 37 | PARTIAL_RELEASE ('00001010'B), |
| 38 | PARTIAL_RELEASE_COMPLETE ('00001111'B), |
| 39 | |
| 40 | PAGING_REQUEST_TYPE_1 ('00100001'B), |
| 41 | PAGING_REQUEST_TYPE_2 ('00100010'B), |
| 42 | PAGING_REQUEST_TYPE_3 ('00100100'B), |
| 43 | PAGING_RESPONSE ('00100111'B), |
| 44 | NOTIFICATION_NCH ('00100000'B), |
| 45 | NOTIFICATION_RESPOSNE ('00100110'B), |
| 46 | |
| 47 | SYSTEM_INFORMATION_TYPE_8 ('00011000'B), |
| 48 | SYSTEM_INFORMATION_TYPE_1 ('00011001'B), |
| 49 | SYSTEM_INFORMATION_TYPE_2 ('00011010'B), |
| 50 | SYSTEM_INFORMATION_TYPE_3 ('00011011'B), |
| 51 | SYSTEM_INFORMATION_TYPE_4 ('00011100'B), |
| 52 | SYSTEM_INFORMATION_TYPE_5 ('00011101'B), |
| 53 | SYSTEM_INFORMATION_TYPE_6 ('00011110'B), |
| 54 | SYSTEM_INFORMATION_TYPE_7 ('00011111'B), |
| 55 | SYSTEM_INFORMATION_TYPE_2bis ('00000010'B), |
| 56 | SYSTEM_INFORMATION_TYPE_2ter ('00000011'B), |
| 57 | SYSTEM_INFORMATION_TYPE_2quater ('00000111'B), |
| 58 | SYSTEM_INFORMATION_TYPE_5bis ('00000101'B), |
| 59 | SYSTEM_INFORMATION_TYPE_5ter ('00000110'B), |
| 60 | SYSTEM_INFORMATION_TYPE_9 ('00000100'B), |
| 61 | SYSTEM_INFORMATION_TYPE_13 ('00000000'B), |
| 62 | |
| 63 | SYSTEM_INFORMATION_TYPE_16 ('00111101'B), |
| 64 | SYSTEM_INFORMATION_TYPE_17 ('00111110'B), |
| 65 | |
| 66 | CHANNEL_MODE_MODIFY ('00010000'B), |
| 67 | RR_STATUS ('00010010'B), |
| 68 | CHANNEL_MODE_MODIFY_ACKNOWLEDGE ('00010111'B), |
| 69 | FREQUENCY_REDEFINITION ('00010100'B), |
| 70 | MEASUREMENT_REPORT ('00010101'B), |
| 71 | CLASSMARK_CHANGE ('00010110'B), |
| 72 | CLASSMARK_ENQUIRY ('00010011'B), |
| 73 | EXTENDED_MEASUREMENT_REPORT ('00110110'B), |
| 74 | EXTENDED_MEASUREMENT_ORDER ('00110111'B), |
| 75 | GPRS_SUSPENSION_REQUEST ('00110100'B), |
| 76 | //MBMS_ANNOUNCEMENT ('00010110'B), duplicate? |
| 77 | //SERVICE_INFORMATION ('00110110'B), duplicate? |
| 78 | |
| 79 | APPLICATION_INFORMATION ('00111000'B), |
| 80 | |
| 81 | SYSTEM_INFORMATION_TYPE_14 ('00000001'B), |
| 82 | SYSTEM_INFORMATION_TYPE_15 ('01000011'B), |
| 83 | SYSTEM_INFORMATION_TYPE_18 ('01000000'B), |
| 84 | SYSTEM_INFORMATION_TYPE_19 ('01000001'B), |
| 85 | SYSTEM_INFORMATION_TYPE_20 ('01000010'B), |
| 86 | SYSTEM_INFORMATION_TYPE_13alt ('01000100'B), |
| 87 | SYSTEM_INFORMATION_TYPE_2n ('01000101'B), |
| 88 | SYSTEM_INFORMATION_TYPE_21 ('01000110'B), |
| 89 | SYSTEM_INFORMATION_TYPE_22 ('01000111'B), |
| 90 | SYSTEM_INFORMATION_TYPE_23 ('01001111'B), |
| 91 | |
| 92 | DTM_ASSIGNMENT_FAILURE ('01001000'B), |
| 93 | DTM_REJECT ('01001001'B), |
| 94 | DTM_REQUEST ('01001010'B), |
| 95 | PACKET_ASSIGNMENT ('01001011'B), |
| 96 | DTM_ASSIGNMENT_COMMAND ('01001100'B), |
| 97 | DTM_INFORMATION ('01001101'B), |
| 98 | PACKET_INFORMATION ('01001110'B), |
| 99 | |
| 100 | UTRAN_CLASSMARK_CHANGE ('01100000'B), |
| 101 | CDMA2000_CLASSMARK_CHANGE ('01100010'B), |
| 102 | INTERSYS_TO_UTRAN_HO_CMD ('01100011'B), |
| 103 | INTERSYS_TO_CDMA2000_HO_CMD ('01100100'B), |
| 104 | GERAN_IU_MODE_CLASSMARK_CHG ('01100101'B), |
| 105 | INTERSYS_TO_EUTRAN_HO_CMD ('01100110'B) |
| 106 | } with { variant "FIELDLENGTH(8)" }; |
| 107 | |
| 108 | type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" }; |
| 109 | type hexstring GsmBcdString with { variant "HEXORDER(low)" }; |
| 110 | type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" }; |
| 111 | |
| 112 | type record L2PseudoLength { |
| 113 | uint6_t l2_plen, |
| 114 | BIT2 zero_one |
| 115 | } with { variant "" }; |
| 116 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 117 | template L2PseudoLength tr_L2Pseudolength(template uint6_t len) := { |
| 118 | l2_plen := len, |
| 119 | zero_one := '01'B |
| 120 | }; |
| 121 | |
| 122 | template (value) L2PseudoLength ts_L2Pseudolength(uint6_t len) := { |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 123 | l2_plen := len, |
| 124 | zero_one := '01'B |
| 125 | }; |
| 126 | |
| 127 | type record RrHeader { |
| 128 | L2PseudoLength l2_plen, |
| 129 | uint4_t skip_indicator, |
| 130 | uint4_t rr_protocol_discriminator, |
| 131 | RrMessageType message_type |
| 132 | } with { variant "" }; |
| 133 | |
| 134 | template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 135 | l2_plen := tr_L2Pseudolength(len), |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 136 | skip_indicator := 0, |
| 137 | rr_protocol_discriminator := 6, |
| 138 | message_type := msg_type |
| 139 | }; |
| 140 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 141 | template (value) RrHeader ts_RrHeader(RrMessageType msg_type, uint6_t len) := { |
| 142 | l2_plen := ts_L2Pseudolength(len), |
| 143 | skip_indicator := 0, |
| 144 | rr_protocol_discriminator := 6, |
| 145 | message_type := msg_type |
| 146 | }; |
| 147 | |
| 148 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 149 | type record RrL3Header { |
| 150 | uint4_t skip_indicator, |
| 151 | uint4_t rr_protocol_discriminator, |
| 152 | RrMessageType message_type |
| 153 | } with { variant "" }; |
| 154 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 155 | template RrL3Header t_RrL3Header(RrMessageType msg_type) := { |
| 156 | skip_indicator := 0, |
| 157 | rr_protocol_discriminator := 6, |
| 158 | message_type := msg_type |
| 159 | } |
| 160 | |
Pau Espin Pedrol | 0aad596 | 2018-09-28 16:03:55 +0200 | [diff] [blame] | 161 | /* TS 44.004 7.2.1 */ |
| 162 | type record SacchL1Header { |
| 163 | uint2_t reserved, |
| 164 | boolean fpc, |
| 165 | uint5_t ms_power_lvl, |
| 166 | uint8_t actual_ta |
| 167 | } with { variant "FIELDORDER(msb)" }; |
| 168 | |
| 169 | template (value) SacchL1Header ts_SacchL1Header(uint5_t ms_power_lvl, boolean fpc, uint8_t actual_ta) := { |
| 170 | reserved := 0, |
| 171 | fpc := fpc, |
| 172 | ms_power_lvl := ms_power_lvl, |
| 173 | actual_ta := actual_ta |
| 174 | }; |
| 175 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 176 | type record MaioHsn { |
| 177 | } with { variant "" }; |
| 178 | |
| 179 | /* TS 24.008 10.5.1.1 */ |
| 180 | type uint16_t CellIdentity; |
| 181 | |
| 182 | /* TS 24.008 10.5.1.2 */ |
| 183 | type uint4_t CipheringKeySeqNr (0..7); |
| 184 | |
| 185 | /* 24.008 10.5.1.3 */ |
| 186 | type record LocationAreaIdentification { |
| 187 | BcdMccMnc mcc_mnc, |
| 188 | uint16_t lac |
| 189 | } with { variant "" }; |
| 190 | |
| 191 | /* TS 24.008 10.5.1.4 */ |
| 192 | type enumerated MobileIdentityType { |
| 193 | MI_TYPE_NONE (0), |
| 194 | MI_TYPE_IMSI, |
| 195 | MI_TYPE_IMEI, |
| 196 | MI_TYPE_IMEISV, |
| 197 | MI_TYPE_TMSI, |
| 198 | MI_TYPE_TMGI |
| 199 | } with { variant "FIELDLENGTH(3)" }; |
| 200 | |
| 201 | type record MobileIdentityBCD { |
| 202 | MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV), |
| 203 | boolean odd, |
| 204 | hexstring digits |
| 205 | } with { variant "FIELDORDER(lsb)" }; |
| 206 | |
| 207 | type record MobileIdentityTMSI { |
| 208 | BIT4 pad ('1111'B), |
| 209 | boolean odd (false), |
| 210 | MobileIdentityType mi_type (MI_TYPE_TMSI), |
| 211 | GsmTmsi tmsi |
| 212 | } with { variant "FIELDORDER(lsb)" }; |
| 213 | |
| 214 | type record MobileIdentityNone { |
| 215 | BIT4 pad ('1111'B), |
| 216 | boolean odd (false), |
| 217 | MobileIdentityType mi_type (MI_TYPE_NONE) |
| 218 | } with { variant "FIELDORDER(lsb)" }; |
| 219 | |
| 220 | type union MobileIdentity { |
| 221 | MobileIdentityBCD imsi, |
| 222 | MobileIdentityBCD imei, |
| 223 | MobileIdentityBCD imeisv, |
| 224 | MobileIdentityTMSI tmsi, |
| 225 | MobileIdentityNone unused |
| 226 | } with { variant "TAG(imsi, mi_type = MI_TYPE_IMSI; |
| 227 | imei, mi_type = MI_TYPE_IMEI; |
| 228 | imeisv, mi_type = MI_TYPE_IMEISV; |
| 229 | tmsi, mi_type = MI_TYPE_TMSI; |
| 230 | unused, mi_type = MI_TYPE_NONE)" |
| 231 | variant "FIELDORDER(lsb)" |
| 232 | }; |
| 233 | |
Stefan Sperling | 59c15d6 | 2018-10-10 11:09:25 +0200 | [diff] [blame] | 234 | /* TS 24.008 10.5.1.4 "Mobile Identity" */ |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 235 | type record MobileIdentityLV { |
| 236 | uint8_t len, |
| 237 | MobileIdentity mi |
| 238 | } with { variant (len) "LENGTHTO(mi)" }; |
| 239 | |
| 240 | type record MobileIdentityTLV { |
| 241 | uint8_t tag, |
| 242 | uint8_t len, |
| 243 | MobileIdentity mi |
| 244 | } with { variant (len) "LENGTHTO(mi)" }; |
| 245 | |
| 246 | /* TS 24.008 10.5.1.5 */ |
| 247 | type record MsClassmark1 { |
| 248 | BIT1 spare, |
| 249 | uint2_t rev_level, |
| 250 | boolean es_ind, |
| 251 | boolean a51, |
| 252 | uint3_t rf_pwr_cap |
| 253 | } with { variant "" }; |
| 254 | |
| 255 | /* TS 24.008 10.5.1.6 */ |
| 256 | type record MsClassmark2 { |
| 257 | BIT1 spare, |
| 258 | uint2_t rev_level, |
| 259 | boolean es_ind, |
| 260 | boolean a51, |
| 261 | uint3_t rf_pwr_cap, |
| 262 | BIT1 spare1, |
| 263 | boolean ps_cap, |
| 264 | uint2_t ss_screen_ind, |
| 265 | boolean sm_cap, |
| 266 | boolean vbs, |
| 267 | boolean vgcs, |
| 268 | boolean fc, |
| 269 | boolean cm3, |
| 270 | BIT1 spare2, |
| 271 | boolean lcsva_cap, |
| 272 | boolean ucs2, |
| 273 | boolean solsa, |
| 274 | boolean cmsp, |
| 275 | boolean a53, |
| 276 | boolean a52 |
| 277 | } with { variant "" }; |
| 278 | type record MsClassmark2LV { |
| 279 | uint8_t len, |
| 280 | MsClassmark2 cm2 |
| 281 | } with { variant (len) "LENGTHTO(cm2)" }; |
| 282 | |
| 283 | |
| 284 | /* 44.018 10.5.2.5 */ |
| 285 | type record ChannelDescription { |
| 286 | RslChannelNr chan_nr, |
| 287 | uint3_t tsc, |
| 288 | boolean h, |
| 289 | uint12_t arfcn optional, |
| 290 | MaioHsn maio_hsn optional |
| 291 | } with { variant (arfcn) "PRESENCE(h = false)" |
| 292 | variant (maio_hsn) "PRESENCE(h = true)" }; |
| 293 | |
| 294 | type record ChannelDescriptionTV { |
| 295 | OCT1 iei, |
| 296 | ChannelDescription v |
| 297 | } with { variant "" }; |
| 298 | |
| 299 | /* 10.5.2.21 */ |
| 300 | type record MobileAllocation { |
| 301 | uint8_t len, |
| 302 | bitstring ma |
| 303 | } with { variant (len) "LENGTHTO(ma)" }; |
| 304 | |
| 305 | /* 10.5.2.25a */ |
Harald Welte | 1b9b770 | 2017-07-30 04:19:14 +0200 | [diff] [blame] | 306 | type record PktChDesc0Ind { |
| 307 | uint6_t maio, |
| 308 | BIT1 ma_number_ind, |
| 309 | BIT1 change_mark1_valid, |
| 310 | BIT2 change_mark1 |
| 311 | } with { variant "" }; |
| 312 | type record PktChDesc0 { |
| 313 | BIT1 hopping, |
| 314 | BIT1 spare ('0'B), |
| 315 | uint10_t arfcn optional, |
| 316 | PktChDesc0Ind indirect optional |
| 317 | } with { |
| 318 | variant (arfcn) "PRESENCE(hopping = '0'B)" |
| 319 | variant (indirect) "PRESENCE(hopping = '1'B)" |
| 320 | }; |
| 321 | type record PktChDesc1 { |
| 322 | uint6_t maio, |
| 323 | uint6_t hsn |
| 324 | } with { variant "" }; |
| 325 | type record PacketChannelDescription { |
| 326 | uint5_t channel_Type_spare, |
| 327 | uint3_t tn, |
| 328 | uint3_t tsc, |
| 329 | BIT1 presence, |
| 330 | PktChDesc0 zero optional, |
| 331 | PktChDesc1 one optional |
| 332 | } with { |
| 333 | variant (zero) "PRESENCE(presence = '0'B)" |
| 334 | variant (one) "PRESENCE(presence = '1'B)" |
| 335 | }; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 336 | |
| 337 | /* 10.5.2.25b */ |
| 338 | type record DedicatedModeOrTbf { |
| 339 | BIT1 spare, |
| 340 | boolean tma, |
| 341 | boolean downlink, |
| 342 | boolean tbf |
| 343 | } with { variant "" }; |
| 344 | |
| 345 | /* 10.5.2.26 */ |
| 346 | type enumerated PageMode { |
| 347 | PAGE_MODE_NORMAL, |
| 348 | PAGE_MODE_EXTENDED, |
| 349 | PAGE_MODE_REORGANIZATION, |
| 350 | PAGE_MODE_SAME_AS_BEFORE |
| 351 | } with { variant "FIELDLENGTH(4)" }; |
| 352 | |
| 353 | /* 10.5.2.30 */ |
| 354 | type record RequestReference { |
| 355 | bitstring ra length(8), |
| 356 | uint5_t t1p, |
| 357 | uint6_t t3, |
| 358 | uint5_t t2 |
| 359 | } with { variant "" }; |
| 360 | |
| 361 | template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := { |
| 362 | ra := ra, |
| 363 | t1p := t1p, |
| 364 | t3 := t3, |
| 365 | t2 := t2 |
| 366 | } |
| 367 | |
| 368 | /* compute the expected request reference for given RA + FN */ |
| 369 | function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference { |
| 370 | var RequestReference req_ref := { ra := int2bit(ra, 8) }; |
| 371 | req_ref.t1p := (fn / 1326) mod 32; |
| 372 | req_ref.t2 := fn mod 26; |
| 373 | req_ref.t3 := fn mod 51; |
| 374 | return req_ref |
| 375 | } |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 376 | function tr_compute_ReqRef(template uint8_t ra, template GsmFrameNumber fn) |
| 377 | return template RequestReference { |
| 378 | var template RequestReference req_ref; |
| 379 | if (istemplatekind(ra, "?")) { |
| 380 | req_ref.ra := ?; |
| 381 | } else { |
| 382 | req_ref.ra := int2bit(valueof(ra), 8); |
| 383 | } |
| 384 | if (istemplatekind(fn, "?")) { |
| 385 | req_ref.t1p := ?; |
| 386 | req_ref.t2 := ?; |
| 387 | req_ref.t3 := ?; |
| 388 | } else { |
| 389 | var GsmFrameNumber fn_v := valueof(fn); |
| 390 | req_ref.t1p := (fn_v / 1326) mod 32; |
| 391 | req_ref.t2 := fn_v mod 26; |
| 392 | req_ref.t3 := fn_v mod 51; |
| 393 | } |
| 394 | return req_ref; |
| 395 | } |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 396 | |
| 397 | /* 10.5.2.40 */ |
| 398 | type integer TimingAdvance (0..219); |
| 399 | |
| 400 | /* 10.5.2.43 */ |
| 401 | type uint8_t WaitIndication; |
| 402 | |
| 403 | /* 10.5.2.76 */ |
| 404 | type record FeatureIndicator { |
| 405 | BIT2 spare, |
| 406 | boolean cs_ir, |
| 407 | boolean ps_ir |
| 408 | } with { variant "" }; |
| 409 | |
| 410 | /* 24.008 10.5.5.6 */ |
| 411 | type record DrxParameter { |
| 412 | uint8_t split_pg_cycle_code, |
| 413 | uint4_t drx_cycle_len_coeff, |
| 414 | boolean split_on_ccch, |
| 415 | uint3_t non_drx_timer |
| 416 | } with { variant "" }; |
| 417 | |
| 418 | /* 24.008 10.5.5.15 */ |
| 419 | type record RoutingAreaIdentification { |
| 420 | LocationAreaIdentification lai, |
| 421 | uint8_t rac |
| 422 | } with { variant "" }; |
| 423 | |
| 424 | /* 44.018 10.5.2.16 */ |
| 425 | type record IaRestOctHL { |
| 426 | uint6_t freq_par_len, |
| 427 | BIT2 padding ('00'B) optional, |
| 428 | uint6_t maio optional, |
| 429 | octetstring mobile_allocation optional |
| 430 | } with { |
| 431 | variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)" |
| 432 | /* |
| 433 | variant (padding) "PRESENCE(freq_par_len != 0)" |
| 434 | variant (maio) "PRESENCE(freq_par_len != 0)" |
| 435 | variant (mobile_allocation) "PRESENCE(freq_par_len != 0)" |
| 436 | */ |
| 437 | }; |
| 438 | type record IaRestOctHH { |
| 439 | BIT2 presence, |
| 440 | PacketUlAssign ul optional, |
| 441 | PacketDlAssign dl optional |
| 442 | } with { |
| 443 | variant (ul) "PRESENCE(presence = '00'B)" |
| 444 | variant (dl) "PRESENCE(presence = '01'B)" |
| 445 | }; |
| 446 | type record PacketUlAssignDyn { |
| 447 | uint5_t tfi_assignment, |
| 448 | BIT1 polling, |
| 449 | BIT1 spare ('0'B), |
| 450 | uint3_t usf, |
| 451 | BIT1 usf_granularity, |
| 452 | BIT1 p0_present, |
| 453 | uint4_t p0 optional, |
| 454 | BIT1 pr_mode optional, |
| 455 | ChCodingCommand ch_coding_cmd, |
| 456 | BIT1 tlli_block_chan_coding, |
| 457 | BIT1 alpha_present, |
| 458 | uint4_t alpha optional, |
| 459 | uint5_t gamma, |
| 460 | BIT1 ta_index_present, |
| 461 | uint4_t ta_index optional, |
| 462 | BIT1 tbf_starting_time_present, |
| 463 | uint16_t tbf_starting_time optional |
| 464 | } with { |
| 465 | variant (p0) "PRESENCE(p0_present = '1'B)" |
| 466 | variant (pr_mode) "PRESENCE(p0_present = '1'B)" |
| 467 | variant (alpha) "PRESENCE(alpha_present = '1'B)" |
| 468 | variant (ta_index) "PRESENCE(ta_index_present = '1'B)" |
| 469 | variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)" |
| 470 | }; |
| 471 | type record PacketUlAssignSgl { |
| 472 | BIT1 alpha_present, |
| 473 | uint4_t alpha optional, |
| 474 | uint5_t gamma, |
| 475 | BIT2 padding ('01'B), |
| 476 | uint16_t tbf_starting_time |
| 477 | /* TODO: P0 / PR_MODE */ |
| 478 | } with { |
| 479 | variant (alpha) "PRESENCE(alpha_present = '1'B)" |
| 480 | }; |
| 481 | type record PacketUlAssign { |
| 482 | BIT1 presence, |
| 483 | PacketUlAssignDyn dynamic optional, |
| 484 | PacketUlAssignSgl single optional |
| 485 | /* TODO: Estended RA, PFI */ |
| 486 | } with { |
| 487 | variant (dynamic) "PRESENCE(presence = '1'B)" |
| 488 | variant (single) "PRESENCE(presence = '0'B)" |
| 489 | }; |
| 490 | type record PacketDlAssG1 { |
| 491 | uint5_t tfi_assignment, |
| 492 | BIT1 rlc_mode, |
| 493 | BIT1 alpha_present, |
| 494 | uint4_t alpha optional, |
| 495 | uint5_t gamma, |
| 496 | BIT1 polling, |
| 497 | BIT1 ta_valid |
| 498 | } with { variant "" }; |
| 499 | type record PacketDlAssign { |
| 500 | GprsTlli tlli, |
| 501 | BIT1 group1_present, |
| 502 | PacketDlAssG1 group1 optional, |
| 503 | BIT1 ta_index_present, |
| 504 | uint4_t ta_index optional, |
| 505 | BIT1 tbf_starting_time_present, |
| 506 | uint16_t tbf_starting_time optional, |
| 507 | BIT1 p0_present, |
| 508 | uint4_t p0 optional, |
| 509 | BIT1 pr_mode optional |
| 510 | /* TODO: EGPRS window size, etc. */ |
| 511 | } with { |
| 512 | variant (group1) "PRESENCE(group1_present = '1'B)" |
| 513 | variant (ta_index) "PRESENCE(ta_index_present = '1'B)" |
| 514 | variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)" |
| 515 | variant (p0) "PRESENCE(p0_present = '1'B)" |
| 516 | variant (pr_mode) "PRESENCE(p0_present = '1'B)" |
| 517 | }; |
| 518 | type record IaRestOctLL { |
| 519 | BIT1 compressed_irat_ho_info_ind |
| 520 | } with { variant "" }; |
| 521 | type octetstring EgprsUlAss; /* TODO */ |
| 522 | type octetstring MblkDlAss; /* TODO */ |
| 523 | type record IaRestOctLH { |
| 524 | BIT2 presence, |
| 525 | EgprsUlAss egprs_ul optional, |
| 526 | MblkDlAss multiblock_dl_ass optional |
| 527 | } with { |
| 528 | variant (egprs_ul) "PRESENCE(presence = '00'B)" |
| 529 | variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)" |
| 530 | }; |
| 531 | type record IaRestOctets { |
| 532 | BIT2 presence, |
| 533 | IaRestOctLL ll optional, |
| 534 | IaRestOctLH lh optional, |
| 535 | IaRestOctHL hl optional, |
| 536 | IaRestOctHH hh optional |
| 537 | } with { |
| 538 | variant (ll) "PRESENCE(presence = '00'B)" |
| 539 | variant (lh) "PRESENCE(presence = '01'B)" |
| 540 | variant (hl) "PRESENCE(presence = '10'B)" |
| 541 | variant (hh) "PRESENCE(presence = '11'B)" |
| 542 | }; |
| 543 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 544 | type record MeasurementResults { |
| 545 | BIT1 ba_used, |
| 546 | BIT1 dtx_used, |
| 547 | uint6_t rxlev_full_srv_cell, |
| 548 | BIT1 threeg_ba_used, |
| 549 | BIT1 meas_valid, |
| 550 | uint6_t rxlev_sub_srv_cell, |
| 551 | BIT1 si23_ba_used, |
| 552 | uint3_t rxqual_full_srv_cell, |
| 553 | uint3_t rxqual_sub_srv_cell, |
| 554 | uint3_t no_ncell_m, |
| 555 | NcellReports ncell_reports optional |
| 556 | } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)" |
| 557 | variant (no_ncell_m) "UNIT(elements)" |
| 558 | variant "PADDING(yes)" |
| 559 | variant "FIELDLENGTH(16)" |
| 560 | }; |
| 561 | |
| 562 | type record NcellReport { |
| 563 | uint6_t rxlev, |
| 564 | uint5_t bcch_freq, |
| 565 | uint6_t bsic |
| 566 | } with { variant ""}; |
| 567 | type record of NcellReport NcellReports; |
| 568 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 569 | |
| 570 | /* 9.1.18 */ |
| 571 | type record ImmediateAssignment { |
| 572 | DedicatedModeOrTbf ded_or_tbf, |
| 573 | PageMode page_mode, |
| 574 | ChannelDescription chan_desc optional, |
| 575 | PacketChannelDescription pkt_chan_desc optional, |
| 576 | RequestReference req_ref, |
| 577 | TimingAdvance timing_advance, |
| 578 | MobileAllocation mobile_allocation, |
| 579 | /* TODO: starting time TLV */ |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 580 | IaRestOctets rest_octets optional |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 581 | } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)" |
| 582 | variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" }; |
| 583 | |
| 584 | /* 9.1.20 */ |
| 585 | type record ReqRefWaitInd { |
| 586 | RequestReference req_ref, |
| 587 | WaitIndication wait_ind |
| 588 | } with { variant "" }; |
| 589 | type record length(4) of ReqRefWaitInd ReqRefWaitInd4; |
| 590 | type record ImmediateAssignmentReject { |
| 591 | FeatureIndicator feature_ind, |
| 592 | PageMode page_mode, |
| 593 | ReqRefWaitInd4 payload |
| 594 | } with { variant "" }; |
| 595 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 596 | /* 9.1.21 */ |
| 597 | type record MeasurementReport { |
| 598 | MeasurementResults meas_res |
| 599 | } with { variant "" }; |
| 600 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 601 | /* 9.1.22 */ |
| 602 | type record PagingRequestType1 { |
| 603 | ChannelNeeded12 chan_needed, |
| 604 | PageMode page_mode, |
| 605 | MobileIdentityLV mi1, |
| 606 | MobileIdentityTLV mi2 optional, |
| 607 | RestOctets rest_octets |
| 608 | } with { variant "TAG(mi2, tag = 23)" }; |
| 609 | |
| 610 | /* 9.1.23 */ |
| 611 | type record PagingRequestType2 { |
| 612 | ChannelNeeded12 chan_needed, |
| 613 | PageMode page_mode, |
| 614 | GsmTmsi mi1, |
| 615 | GsmTmsi mi2, |
| 616 | MobileIdentityTLV mi3 optional, |
| 617 | RestOctets rest_octets |
| 618 | } with { variant "TAG(mi3, tag = 23)" }; |
| 619 | |
| 620 | /* 9.1.24 */ |
| 621 | type record length(4) of GsmTmsi GsmTmsi4; |
| 622 | type record PagingRequestType3 { |
| 623 | ChannelNeeded12 chan_needed, |
| 624 | PageMode page_mode, |
| 625 | GsmTmsi4 mi, |
| 626 | RestOctets rest_octets |
| 627 | } with { variant "" }; |
| 628 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 629 | type union RrUnion { |
| 630 | /* |
| 631 | SystemInformationType1 si1, |
| 632 | SystemInformationType2 si2, |
| 633 | SystemInformationType2bis si2bis, |
| 634 | SystemInformationType2ter si2ter, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 635 | SystemInformationType3 si3, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 636 | SystemInformationType4 si4, |
| 637 | SystemInformationType5 si5, |
| 638 | SystemInformationType5bis si5bis, |
| 639 | SystemInformationType5ter si5ter, |
| 640 | SystemInformationType6 si6, |
| 641 | */ |
| 642 | ImmediateAssignment imm_ass, |
| 643 | ImmediateAssignmentReject imm_ass_rej, |
| 644 | PagingRequestType1 pag_req_1, |
| 645 | PagingRequestType2 pag_req_2, |
| 646 | PagingRequestType3 pag_req_3, |
| 647 | octetstring other |
| 648 | } with { variant "" }; |
| 649 | |
| 650 | /* Special RR Message on BCCH / CCCH Dowlink */ |
| 651 | |
| 652 | type record GsmRrMessage { |
| 653 | RrHeader header, |
| 654 | RrUnion payload |
| 655 | } with { variant (payload) "CROSSTAG( |
| 656 | /* |
| 657 | si1, header.message_type = SYSTEM_INFORMATION_TYPE_1; |
| 658 | si2, header.message_type = SYSTEM_INFORMATION_TYPE_2; |
| 659 | si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis; |
| 660 | si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter; |
| 661 | si3, header.message_type = SYSTEM_INFORMATION_TYPE_3; |
| 662 | si4, header.message_type = SYSTEM_INFORMATION_TYPE_4; |
| 663 | si5, header.message_type = SYSTEM_INFORMATION_TYPE_5; |
| 664 | si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis; |
| 665 | si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter; |
| 666 | si6, header.message_type = SYSTEM_INFORMATION_TYPE_6; |
| 667 | */ |
| 668 | imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT; |
| 669 | imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT; |
| 670 | pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1; |
| 671 | pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2; |
| 672 | pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3; |
| 673 | other, OTHERWISE; |
| 674 | )" }; |
| 675 | |
| 676 | external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring |
| 677 | with { extension "prototype(convert) encode(RAW)" }; |
| 678 | external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage |
| 679 | with { extension "prototype(convert) decode(RAW)" }; |
| 680 | |
| 681 | /* Normal L3 Message on Dedicated Channel */ |
| 682 | |
| 683 | /* 9.1.25 Paging Response */ |
| 684 | type record PagingResponse { |
| 685 | uint4_t spare_half_octet, |
| 686 | CipheringKeySeqNr cksn, |
| 687 | MsClassmark2LV cm2, |
| 688 | MobileIdentityLV mi, |
| 689 | uint8_t addl_upd_par optional |
| 690 | } with { variant "" }; |
| 691 | |
| 692 | type union RrL3Union { |
| 693 | PagingResponse paging_response, |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 694 | MeasurementReport meas_rep, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 695 | octetstring other |
| 696 | }; |
| 697 | |
| 698 | type record GsmRrL3Message { |
| 699 | RrL3Header header, |
| 700 | RrL3Union payload |
| 701 | } with { variant (payload) "CROSSTAG( |
| 702 | paging_response, header.message_type = PAGING_RESPONSE; |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 703 | meas_rep, header.message_type = MEASUREMENT_REPORT; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 704 | other, OTHERWISE; |
| 705 | )" } |
| 706 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 707 | external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring |
| 708 | with { extension "prototype(convert) encode(RAW)" }; |
| 709 | external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message |
| 710 | with { extension "prototype(convert) decode(RAW)" }; |
| 711 | |
| 712 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 713 | 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] | 714 | ChannelDescription ch_desc, MobileAllocation ma) := { |
| 715 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0), |
| 716 | payload := { |
| 717 | imm_ass := { |
| 718 | ded_or_tbf := { |
| 719 | spare := '0'B, |
| 720 | tma := false, |
| 721 | downlink := false, |
| 722 | tbf := false |
| 723 | }, |
| 724 | page_mode := PAGE_MODE_NORMAL, |
| 725 | chan_desc := ch_desc, |
| 726 | pkt_chan_desc := omit, |
| 727 | req_ref := f_compute_ReqRef(ra, fn), |
| 728 | timing_advance := ta, |
| 729 | mobile_allocation := ma, |
| 730 | rest_octets := omit |
| 731 | } |
| 732 | } |
| 733 | }; |
| 734 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 735 | template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?, |
| 736 | template TimingAdvance ta := ?, |
| 737 | template ChannelDescription ch_desc := ?, |
| 738 | template MobileAllocation ma := ?) := { |
| 739 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0), |
| 740 | payload := { |
| 741 | imm_ass := { |
| 742 | ded_or_tbf := { |
| 743 | spare := '0'B, |
| 744 | tma := false, |
| 745 | downlink := false, |
| 746 | tbf := false |
| 747 | }, |
| 748 | page_mode := PAGE_MODE_NORMAL, |
| 749 | chan_desc := ch_desc, |
| 750 | pkt_chan_desc := omit, |
| 751 | req_ref := tr_compute_ReqRef(ra, fn), |
| 752 | timing_advance := ta, |
| 753 | mobile_allocation := ma, |
| 754 | rest_octets := * |
| 755 | } |
| 756 | } |
| 757 | }; |
| 758 | |
| 759 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 760 | template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s, |
| 761 | uint3_t rxq_f, uint3_t rxq_s, |
| 762 | template (omit) NcellReports reps) := { |
| 763 | header := t_RrL3Header(MEASUREMENT_REPORT), |
| 764 | payload := { |
| 765 | meas_rep := { |
| 766 | meas_res := { |
| 767 | ba_used := '0'B, |
| 768 | dtx_used := '0'B, |
| 769 | rxlev_full_srv_cell := rxl_f, |
| 770 | threeg_ba_used := '0'B, |
Harald Welte | eb1e681 | 2018-02-22 18:43:48 +0100 | [diff] [blame] | 771 | meas_valid := bool2bit(not valid), |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 772 | rxlev_sub_srv_cell := rxl_s, |
| 773 | si23_ba_used := '0'B, |
| 774 | rxqual_full_srv_cell := rxq_f, |
| 775 | rxqual_sub_srv_cell := rxq_s, |
| 776 | no_ncell_m := 0, |
| 777 | ncell_reports := reps |
| 778 | } |
| 779 | } |
| 780 | } |
| 781 | }; |
| 782 | |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 783 | template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := { |
| 784 | ded_or_tbf := { |
| 785 | spare := ?, |
| 786 | tma := ?, |
| 787 | downlink := ?, |
| 788 | tbf := true |
| 789 | }, |
| 790 | page_mode := ?, |
| 791 | chan_desc := omit, |
| 792 | pkt_chan_desc := { |
| 793 | channel_Type_spare := ?, |
| 794 | tn := ?, |
| 795 | tsc := ?, |
| 796 | presence := ?, |
| 797 | zero := *, |
| 798 | one := omit |
| 799 | }, |
| 800 | req_ref := ?, |
| 801 | timing_advance := ?, |
| 802 | mobile_allocation := ?, |
| 803 | rest_octets := { |
| 804 | presence := '11'B, |
| 805 | ll := omit, |
| 806 | lh := omit, |
| 807 | hl := omit, |
| 808 | hh := { |
| 809 | presence := '01'B, |
| 810 | ul := omit, |
| 811 | dl := { |
| 812 | tlli := tlli, |
| 813 | group1_present := ?, |
| 814 | group1 := *, |
| 815 | ta_index_present := ?, |
| 816 | ta_index := *, |
| 817 | tbf_starting_time_present := ?, |
| 818 | tbf_starting_time := *, |
| 819 | p0_present := ?, |
| 820 | p0 := *, |
| 821 | pr_mode := * |
| 822 | } |
| 823 | } |
| 824 | } |
| 825 | }; |
| 826 | |
| 827 | template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := { |
| 828 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
| 829 | payload := { |
| 830 | imm_ass := t_IMM_ASS_TBF_DL(tlli) |
| 831 | } |
| 832 | }; |
| 833 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 834 | |
| 835 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 836 | } with { encode "RAW" ; variant "FIELDORDER(msb)" } |