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 | |
Harald Welte | b16516c | 2019-03-21 21:31:41 +0100 | [diff] [blame] | 424 | external function enc_RoutingAreaIdentification(RoutingAreaIdentification rai) return octetstring |
| 425 | with { extension "prototype(convert)" extension "encode(RAW)" } |
| 426 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 427 | /* 44.018 10.5.2.16 */ |
| 428 | type record IaRestOctHL { |
| 429 | uint6_t freq_par_len, |
| 430 | BIT2 padding ('00'B) optional, |
| 431 | uint6_t maio optional, |
| 432 | octetstring mobile_allocation optional |
| 433 | } with { |
| 434 | variant (freq_par_len) "LENGTHTO(mobile_allocation,maio,padding)" |
| 435 | /* |
| 436 | variant (padding) "PRESENCE(freq_par_len != 0)" |
| 437 | variant (maio) "PRESENCE(freq_par_len != 0)" |
| 438 | variant (mobile_allocation) "PRESENCE(freq_par_len != 0)" |
| 439 | */ |
| 440 | }; |
| 441 | type record IaRestOctHH { |
| 442 | BIT2 presence, |
| 443 | PacketUlAssign ul optional, |
| 444 | PacketDlAssign dl optional |
| 445 | } with { |
| 446 | variant (ul) "PRESENCE(presence = '00'B)" |
| 447 | variant (dl) "PRESENCE(presence = '01'B)" |
| 448 | }; |
| 449 | type record PacketUlAssignDyn { |
| 450 | uint5_t tfi_assignment, |
| 451 | BIT1 polling, |
| 452 | BIT1 spare ('0'B), |
| 453 | uint3_t usf, |
| 454 | BIT1 usf_granularity, |
| 455 | BIT1 p0_present, |
| 456 | uint4_t p0 optional, |
| 457 | BIT1 pr_mode optional, |
| 458 | ChCodingCommand ch_coding_cmd, |
| 459 | BIT1 tlli_block_chan_coding, |
| 460 | BIT1 alpha_present, |
| 461 | uint4_t alpha optional, |
| 462 | uint5_t gamma, |
| 463 | BIT1 ta_index_present, |
| 464 | uint4_t ta_index optional, |
| 465 | BIT1 tbf_starting_time_present, |
| 466 | uint16_t tbf_starting_time optional |
| 467 | } with { |
| 468 | variant (p0) "PRESENCE(p0_present = '1'B)" |
| 469 | variant (pr_mode) "PRESENCE(p0_present = '1'B)" |
| 470 | variant (alpha) "PRESENCE(alpha_present = '1'B)" |
| 471 | variant (ta_index) "PRESENCE(ta_index_present = '1'B)" |
| 472 | variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)" |
| 473 | }; |
| 474 | type record PacketUlAssignSgl { |
| 475 | BIT1 alpha_present, |
| 476 | uint4_t alpha optional, |
| 477 | uint5_t gamma, |
| 478 | BIT2 padding ('01'B), |
| 479 | uint16_t tbf_starting_time |
| 480 | /* TODO: P0 / PR_MODE */ |
| 481 | } with { |
| 482 | variant (alpha) "PRESENCE(alpha_present = '1'B)" |
| 483 | }; |
| 484 | type record PacketUlAssign { |
| 485 | BIT1 presence, |
| 486 | PacketUlAssignDyn dynamic optional, |
| 487 | PacketUlAssignSgl single optional |
| 488 | /* TODO: Estended RA, PFI */ |
| 489 | } with { |
| 490 | variant (dynamic) "PRESENCE(presence = '1'B)" |
| 491 | variant (single) "PRESENCE(presence = '0'B)" |
| 492 | }; |
| 493 | type record PacketDlAssG1 { |
| 494 | uint5_t tfi_assignment, |
| 495 | BIT1 rlc_mode, |
| 496 | BIT1 alpha_present, |
| 497 | uint4_t alpha optional, |
| 498 | uint5_t gamma, |
| 499 | BIT1 polling, |
| 500 | BIT1 ta_valid |
| 501 | } with { variant "" }; |
| 502 | type record PacketDlAssign { |
| 503 | GprsTlli tlli, |
| 504 | BIT1 group1_present, |
| 505 | PacketDlAssG1 group1 optional, |
| 506 | BIT1 ta_index_present, |
| 507 | uint4_t ta_index optional, |
| 508 | BIT1 tbf_starting_time_present, |
| 509 | uint16_t tbf_starting_time optional, |
| 510 | BIT1 p0_present, |
| 511 | uint4_t p0 optional, |
| 512 | BIT1 pr_mode optional |
| 513 | /* TODO: EGPRS window size, etc. */ |
| 514 | } with { |
| 515 | variant (group1) "PRESENCE(group1_present = '1'B)" |
| 516 | variant (ta_index) "PRESENCE(ta_index_present = '1'B)" |
| 517 | variant (tbf_starting_time) "PRESENCE(tbf_starting_time_present = '1'B)" |
| 518 | variant (p0) "PRESENCE(p0_present = '1'B)" |
| 519 | variant (pr_mode) "PRESENCE(p0_present = '1'B)" |
| 520 | }; |
| 521 | type record IaRestOctLL { |
| 522 | BIT1 compressed_irat_ho_info_ind |
| 523 | } with { variant "" }; |
| 524 | type octetstring EgprsUlAss; /* TODO */ |
| 525 | type octetstring MblkDlAss; /* TODO */ |
| 526 | type record IaRestOctLH { |
| 527 | BIT2 presence, |
| 528 | EgprsUlAss egprs_ul optional, |
| 529 | MblkDlAss multiblock_dl_ass optional |
| 530 | } with { |
| 531 | variant (egprs_ul) "PRESENCE(presence = '00'B)" |
| 532 | variant (multiblock_dl_ass) "PRESENCE(presence = '01'B)" |
| 533 | }; |
| 534 | type record IaRestOctets { |
| 535 | BIT2 presence, |
| 536 | IaRestOctLL ll optional, |
| 537 | IaRestOctLH lh optional, |
| 538 | IaRestOctHL hl optional, |
| 539 | IaRestOctHH hh optional |
| 540 | } with { |
| 541 | variant (ll) "PRESENCE(presence = '00'B)" |
| 542 | variant (lh) "PRESENCE(presence = '01'B)" |
| 543 | variant (hl) "PRESENCE(presence = '10'B)" |
| 544 | variant (hh) "PRESENCE(presence = '11'B)" |
| 545 | }; |
| 546 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 547 | type record MeasurementResults { |
| 548 | BIT1 ba_used, |
| 549 | BIT1 dtx_used, |
| 550 | uint6_t rxlev_full_srv_cell, |
| 551 | BIT1 threeg_ba_used, |
| 552 | BIT1 meas_valid, |
| 553 | uint6_t rxlev_sub_srv_cell, |
| 554 | BIT1 si23_ba_used, |
| 555 | uint3_t rxqual_full_srv_cell, |
| 556 | uint3_t rxqual_sub_srv_cell, |
| 557 | uint3_t no_ncell_m, |
| 558 | NcellReports ncell_reports optional |
| 559 | } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)" |
| 560 | variant (no_ncell_m) "UNIT(elements)" |
| 561 | variant "PADDING(yes)" |
| 562 | variant "FIELDLENGTH(16)" |
| 563 | }; |
| 564 | |
| 565 | type record NcellReport { |
| 566 | uint6_t rxlev, |
| 567 | uint5_t bcch_freq, |
| 568 | uint6_t bsic |
| 569 | } with { variant ""}; |
| 570 | type record of NcellReport NcellReports; |
| 571 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 572 | |
| 573 | /* 9.1.18 */ |
| 574 | type record ImmediateAssignment { |
| 575 | DedicatedModeOrTbf ded_or_tbf, |
| 576 | PageMode page_mode, |
| 577 | ChannelDescription chan_desc optional, |
| 578 | PacketChannelDescription pkt_chan_desc optional, |
| 579 | RequestReference req_ref, |
| 580 | TimingAdvance timing_advance, |
| 581 | MobileAllocation mobile_allocation, |
| 582 | /* TODO: starting time TLV */ |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 583 | IaRestOctets rest_octets optional |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 584 | } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)" |
| 585 | variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" }; |
| 586 | |
| 587 | /* 9.1.20 */ |
| 588 | type record ReqRefWaitInd { |
| 589 | RequestReference req_ref, |
| 590 | WaitIndication wait_ind |
| 591 | } with { variant "" }; |
| 592 | type record length(4) of ReqRefWaitInd ReqRefWaitInd4; |
| 593 | type record ImmediateAssignmentReject { |
| 594 | FeatureIndicator feature_ind, |
| 595 | PageMode page_mode, |
| 596 | ReqRefWaitInd4 payload |
| 597 | } with { variant "" }; |
| 598 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 599 | /* 9.1.21 */ |
| 600 | type record MeasurementReport { |
| 601 | MeasurementResults meas_res |
| 602 | } with { variant "" }; |
| 603 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 604 | /* 9.1.22 */ |
| 605 | type record PagingRequestType1 { |
| 606 | ChannelNeeded12 chan_needed, |
| 607 | PageMode page_mode, |
| 608 | MobileIdentityLV mi1, |
| 609 | MobileIdentityTLV mi2 optional, |
| 610 | RestOctets rest_octets |
| 611 | } with { variant "TAG(mi2, tag = 23)" }; |
| 612 | |
| 613 | /* 9.1.23 */ |
| 614 | type record PagingRequestType2 { |
| 615 | ChannelNeeded12 chan_needed, |
| 616 | PageMode page_mode, |
| 617 | GsmTmsi mi1, |
| 618 | GsmTmsi mi2, |
| 619 | MobileIdentityTLV mi3 optional, |
| 620 | RestOctets rest_octets |
| 621 | } with { variant "TAG(mi3, tag = 23)" }; |
| 622 | |
| 623 | /* 9.1.24 */ |
| 624 | type record length(4) of GsmTmsi GsmTmsi4; |
| 625 | type record PagingRequestType3 { |
| 626 | ChannelNeeded12 chan_needed, |
| 627 | PageMode page_mode, |
| 628 | GsmTmsi4 mi, |
| 629 | RestOctets rest_octets |
| 630 | } with { variant "" }; |
| 631 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 632 | type union RrUnion { |
| 633 | /* |
| 634 | SystemInformationType1 si1, |
| 635 | SystemInformationType2 si2, |
| 636 | SystemInformationType2bis si2bis, |
| 637 | SystemInformationType2ter si2ter, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 638 | SystemInformationType3 si3, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 639 | SystemInformationType4 si4, |
| 640 | SystemInformationType5 si5, |
| 641 | SystemInformationType5bis si5bis, |
| 642 | SystemInformationType5ter si5ter, |
| 643 | SystemInformationType6 si6, |
| 644 | */ |
| 645 | ImmediateAssignment imm_ass, |
| 646 | ImmediateAssignmentReject imm_ass_rej, |
| 647 | PagingRequestType1 pag_req_1, |
| 648 | PagingRequestType2 pag_req_2, |
| 649 | PagingRequestType3 pag_req_3, |
| 650 | octetstring other |
| 651 | } with { variant "" }; |
| 652 | |
| 653 | /* Special RR Message on BCCH / CCCH Dowlink */ |
| 654 | |
| 655 | type record GsmRrMessage { |
| 656 | RrHeader header, |
| 657 | RrUnion payload |
| 658 | } with { variant (payload) "CROSSTAG( |
| 659 | /* |
| 660 | si1, header.message_type = SYSTEM_INFORMATION_TYPE_1; |
| 661 | si2, header.message_type = SYSTEM_INFORMATION_TYPE_2; |
| 662 | si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis; |
| 663 | si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter; |
| 664 | si3, header.message_type = SYSTEM_INFORMATION_TYPE_3; |
| 665 | si4, header.message_type = SYSTEM_INFORMATION_TYPE_4; |
| 666 | si5, header.message_type = SYSTEM_INFORMATION_TYPE_5; |
| 667 | si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis; |
| 668 | si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter; |
| 669 | si6, header.message_type = SYSTEM_INFORMATION_TYPE_6; |
| 670 | */ |
| 671 | imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT; |
| 672 | imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT; |
| 673 | pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1; |
| 674 | pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2; |
| 675 | pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3; |
| 676 | other, OTHERWISE; |
| 677 | )" }; |
| 678 | |
| 679 | external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring |
| 680 | with { extension "prototype(convert) encode(RAW)" }; |
| 681 | external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage |
| 682 | with { extension "prototype(convert) decode(RAW)" }; |
| 683 | |
| 684 | /* Normal L3 Message on Dedicated Channel */ |
| 685 | |
| 686 | /* 9.1.25 Paging Response */ |
| 687 | type record PagingResponse { |
| 688 | uint4_t spare_half_octet, |
| 689 | CipheringKeySeqNr cksn, |
| 690 | MsClassmark2LV cm2, |
| 691 | MobileIdentityLV mi, |
| 692 | uint8_t addl_upd_par optional |
| 693 | } with { variant "" }; |
| 694 | |
| 695 | type union RrL3Union { |
| 696 | PagingResponse paging_response, |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 697 | MeasurementReport meas_rep, |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 698 | octetstring other |
| 699 | }; |
| 700 | |
| 701 | type record GsmRrL3Message { |
| 702 | RrL3Header header, |
| 703 | RrL3Union payload |
| 704 | } with { variant (payload) "CROSSTAG( |
| 705 | paging_response, header.message_type = PAGING_RESPONSE; |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 706 | meas_rep, header.message_type = MEASUREMENT_REPORT; |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 707 | other, OTHERWISE; |
| 708 | )" } |
| 709 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 710 | external function enc_GsmRrL3Message(in GsmRrL3Message msg) return octetstring |
| 711 | with { extension "prototype(convert) encode(RAW)" }; |
| 712 | external function dec_GsmRrL3Message(in octetstring stream) return GsmRrL3Message |
| 713 | with { extension "prototype(convert) decode(RAW)" }; |
| 714 | |
| 715 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 716 | 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] | 717 | ChannelDescription ch_desc, MobileAllocation ma) := { |
| 718 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0), |
| 719 | payload := { |
| 720 | imm_ass := { |
| 721 | ded_or_tbf := { |
| 722 | spare := '0'B, |
| 723 | tma := false, |
| 724 | downlink := false, |
| 725 | tbf := false |
| 726 | }, |
| 727 | page_mode := PAGE_MODE_NORMAL, |
| 728 | chan_desc := ch_desc, |
| 729 | pkt_chan_desc := omit, |
| 730 | req_ref := f_compute_ReqRef(ra, fn), |
| 731 | timing_advance := ta, |
| 732 | mobile_allocation := ma, |
| 733 | rest_octets := omit |
| 734 | } |
| 735 | } |
| 736 | }; |
| 737 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 738 | template GsmRrMessage tr_IMM_ASS(template uint8_t ra := ?, template GsmFrameNumber fn := ?, |
| 739 | template TimingAdvance ta := ?, |
| 740 | template ChannelDescription ch_desc := ?, |
| 741 | template MobileAllocation ma := ?) := { |
| 742 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0), |
| 743 | payload := { |
| 744 | imm_ass := { |
| 745 | ded_or_tbf := { |
| 746 | spare := '0'B, |
| 747 | tma := false, |
| 748 | downlink := false, |
| 749 | tbf := false |
| 750 | }, |
| 751 | page_mode := PAGE_MODE_NORMAL, |
| 752 | chan_desc := ch_desc, |
| 753 | pkt_chan_desc := omit, |
| 754 | req_ref := tr_compute_ReqRef(ra, fn), |
| 755 | timing_advance := ta, |
| 756 | mobile_allocation := ma, |
| 757 | rest_octets := * |
| 758 | } |
| 759 | } |
| 760 | }; |
| 761 | |
| 762 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 763 | template (value) GsmRrL3Message ts_MEAS_REP(boolean valid, uint6_t rxl_f, uint6_t rxl_s, |
| 764 | uint3_t rxq_f, uint3_t rxq_s, |
| 765 | template (omit) NcellReports reps) := { |
| 766 | header := t_RrL3Header(MEASUREMENT_REPORT), |
| 767 | payload := { |
| 768 | meas_rep := { |
| 769 | meas_res := { |
| 770 | ba_used := '0'B, |
| 771 | dtx_used := '0'B, |
| 772 | rxlev_full_srv_cell := rxl_f, |
| 773 | threeg_ba_used := '0'B, |
Harald Welte | eb1e681 | 2018-02-22 18:43:48 +0100 | [diff] [blame] | 774 | meas_valid := bool2bit(not valid), |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 775 | rxlev_sub_srv_cell := rxl_s, |
| 776 | si23_ba_used := '0'B, |
| 777 | rxqual_full_srv_cell := rxq_f, |
| 778 | rxqual_sub_srv_cell := rxq_s, |
| 779 | no_ncell_m := 0, |
| 780 | ncell_reports := reps |
| 781 | } |
| 782 | } |
| 783 | } |
| 784 | }; |
| 785 | |
Harald Welte | b669ee0 | 2018-03-09 12:50:02 +0100 | [diff] [blame] | 786 | template ImmediateAssignment t_IMM_ASS_TBF_DL(template GprsTlli tlli) := { |
| 787 | ded_or_tbf := { |
| 788 | spare := ?, |
| 789 | tma := ?, |
| 790 | downlink := ?, |
| 791 | tbf := true |
| 792 | }, |
| 793 | page_mode := ?, |
| 794 | chan_desc := omit, |
| 795 | pkt_chan_desc := { |
| 796 | channel_Type_spare := ?, |
| 797 | tn := ?, |
| 798 | tsc := ?, |
| 799 | presence := ?, |
| 800 | zero := *, |
| 801 | one := omit |
| 802 | }, |
| 803 | req_ref := ?, |
| 804 | timing_advance := ?, |
| 805 | mobile_allocation := ?, |
| 806 | rest_octets := { |
| 807 | presence := '11'B, |
| 808 | ll := omit, |
| 809 | lh := omit, |
| 810 | hl := omit, |
| 811 | hh := { |
| 812 | presence := '01'B, |
| 813 | ul := omit, |
| 814 | dl := { |
| 815 | tlli := tlli, |
| 816 | group1_present := ?, |
| 817 | group1 := *, |
| 818 | ta_index_present := ?, |
| 819 | ta_index := *, |
| 820 | tbf_starting_time_present := ?, |
| 821 | tbf_starting_time := *, |
| 822 | p0_present := ?, |
| 823 | p0 := *, |
| 824 | pr_mode := * |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | }; |
| 829 | |
| 830 | template GsmRrMessage t_RR_IMM_ASS_TBF_DL(template GprsTlli tlli) := { |
| 831 | header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?), |
| 832 | payload := { |
| 833 | imm_ass := t_IMM_ASS_TBF_DL(tlli) |
| 834 | } |
| 835 | }; |
| 836 | |
Harald Welte | cbc947f | 2018-02-22 00:26:55 +0100 | [diff] [blame] | 837 | |
| 838 | |
Harald Welte | 9419c8a | 2017-07-30 04:07:05 +0200 | [diff] [blame] | 839 | } with { encode "RAW" ; variant "FIELDORDER(msb)" } |