Harald Welte | a082a69 | 2017-07-15 15:58:13 +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_Types { |
| 7 | |
| 8 | import from General_Types all; |
| 9 | import from Osmocom_Types all; |
| 10 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 11 | type integer GsmArfcn (0..1023); |
| 12 | type integer UmtsArfcn (0..16383); |
| 13 | type integer UmtsScramblingCode (0..511); |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 14 | const integer GsmMaxFrameNumber := 26*51*2048; |
| 15 | type integer GsmFrameNumber (0..GsmMaxFrameNumber); |
| 16 | type integer GsmRxLev (0..63); |
| 17 | type integer GsmTsc (0..7) with { variant "FIELDLENGTH(8)" }; |
| 18 | type uint32_t GsmTmsi; |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 19 | type uint32_t GprsTlli; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 20 | |
Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 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 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 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 | |
| 125 | template L2PseudoLength t_L2Pseudolength(template uint6_t len) := { |
| 126 | l2_plen := len, |
| 127 | zero_one := '01'B |
| 128 | }; |
| 129 | |
| 130 | type record RrHeader { |
| 131 | L2PseudoLength l2_plen, |
| 132 | uint4_t skip_indicator, |
| 133 | uint4_t rr_protocol_discriminator, |
| 134 | RrMessageType message_type |
| 135 | } with { variant "" }; |
| 136 | |
| 137 | template RrHeader t_RrHeader(RrMessageType msg_type, template uint6_t len) := { |
| 138 | l2_plen := t_L2Pseudolength(len), |
| 139 | skip_indicator := 0, |
| 140 | rr_protocol_discriminator := 6, |
| 141 | message_type := msg_type |
| 142 | }; |
| 143 | |
| 144 | type record RrL3Header { |
| 145 | uint4_t skip_indicator, |
| 146 | uint4_t rr_protocol_discriminator, |
| 147 | RrMessageType message_type |
| 148 | } with { variant "" }; |
| 149 | |
| 150 | type record MaioHsn { |
| 151 | } with { variant "" }; |
| 152 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 153 | /* TS 24.008 10.5.1.1 */ |
| 154 | type uint16_t CellIdentity; |
| 155 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 156 | /* TS 24.008 10.5.1.2 */ |
| 157 | type uint4_t CipheringKeySeqNr (0..7); |
| 158 | |
| 159 | /* 24.008 10.5.1.3 */ |
| 160 | type record LocationAreaIdentification { |
| 161 | BcdMccMnc mcc_mnc, |
| 162 | uint16_t lac |
| 163 | } with { variant "" }; |
| 164 | |
| 165 | /* TS 24.008 10.5.1.4 */ |
| 166 | type enumerated MobileIdentityType { |
| 167 | MI_TYPE_NONE (0), |
| 168 | MI_TYPE_IMSI, |
| 169 | MI_TYPE_IMEI, |
| 170 | MI_TYPE_IMEISV, |
| 171 | MI_TYPE_TMSI, |
| 172 | MI_TYPE_TMGI |
| 173 | } with { variant "FIELDLENGTH(3)" }; |
| 174 | |
| 175 | type record MobileIdentityBCD { |
| 176 | MobileIdentityType mi_type (MI_TYPE_IMSI, MI_TYPE_IMEI, MI_TYPE_IMEISV), |
| 177 | boolean odd, |
| 178 | hexstring digits |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 179 | } with { variant "FIELDORDER(lsb)" }; |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 180 | |
| 181 | type record MobileIdentityTMSI { |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 182 | BIT4 pad ('1111'B), |
Harald Welte | 57a3150 | 2017-07-16 21:03:47 +0200 | [diff] [blame] | 183 | boolean odd (false), |
| 184 | MobileIdentityType mi_type (MI_TYPE_TMSI), |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 185 | GsmTmsi tmsi |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 186 | } with { variant "FIELDORDER(lsb)" }; |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 187 | |
Harald Welte | 57a3150 | 2017-07-16 21:03:47 +0200 | [diff] [blame] | 188 | type record MobileIdentityNone { |
| 189 | BIT4 pad ('1111'B), |
| 190 | boolean odd (false), |
| 191 | MobileIdentityType mi_type (MI_TYPE_NONE) |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 192 | } with { variant "FIELDORDER(lsb)" }; |
Harald Welte | 57a3150 | 2017-07-16 21:03:47 +0200 | [diff] [blame] | 193 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 194 | type union MobileIdentity { |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 195 | MobileIdentityBCD imsi, |
| 196 | MobileIdentityBCD imei, |
| 197 | MobileIdentityBCD imeisv, |
Harald Welte | 57a3150 | 2017-07-16 21:03:47 +0200 | [diff] [blame] | 198 | MobileIdentityTMSI tmsi, |
| 199 | MobileIdentityNone unused |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 200 | } with { variant "TAG(imsi, mi_type = MI_TYPE_IMSI; |
| 201 | imei, mi_type = MI_TYPE_IMEI; |
| 202 | imeisv, mi_type = MI_TYPE_IMEISV; |
Harald Welte | 57a3150 | 2017-07-16 21:03:47 +0200 | [diff] [blame] | 203 | tmsi, mi_type = MI_TYPE_TMSI; |
Harald Welte | bda65a3 | 2017-07-30 00:49:04 +0200 | [diff] [blame] | 204 | unused, mi_type = MI_TYPE_NONE)" |
| 205 | variant "FIELDORDER(lsb)" |
| 206 | }; |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 207 | |
| 208 | type record MobileIdentityLV { |
| 209 | uint8_t len, |
| 210 | MobileIdentity mi |
| 211 | } with { variant (len) "LENGTHTO(mi)" }; |
| 212 | |
| 213 | type record MobileIdentityTLV { |
| 214 | uint8_t tag, |
| 215 | uint8_t len, |
| 216 | MobileIdentity mi |
| 217 | } with { variant (len) "LENGTHTO(mi)" }; |
| 218 | |
| 219 | /* TS 24.008 10.5.1.5 */ |
| 220 | type record MsClassmark1 { |
| 221 | BIT1 spare, |
| 222 | uint2_t rev_level, |
| 223 | boolean es_ind, |
| 224 | boolean a51, |
| 225 | uint3_t rf_pwr_cap |
| 226 | } with { variant "" }; |
| 227 | |
| 228 | /* TS 24.008 10.5.1.6 */ |
| 229 | type record MsClassmark2 { |
| 230 | BIT1 spare, |
| 231 | uint2_t rev_level, |
| 232 | boolean es_ind, |
| 233 | boolean a51, |
| 234 | uint3_t rf_pwr_cap, |
| 235 | BIT1 spare1, |
| 236 | boolean ps_cap, |
| 237 | uint2_t ss_screen_ind, |
| 238 | boolean sm_cap, |
| 239 | boolean vbs, |
| 240 | boolean vgcs, |
| 241 | boolean fc, |
| 242 | boolean cm3, |
| 243 | BIT1 spare2, |
| 244 | boolean lcsva_cap, |
| 245 | boolean ucs2, |
| 246 | boolean solsa, |
| 247 | boolean cmsp, |
| 248 | boolean a53, |
| 249 | boolean a52 |
| 250 | } with { variant "" }; |
| 251 | type record MsClassmark2LV { |
| 252 | uint8_t len, |
| 253 | MsClassmark2 cm2 |
| 254 | } with { variant (len) "LENGTHTO(cm2)" }; |
| 255 | |
| 256 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 257 | /* 44.018 10.5.2.5 */ |
| 258 | type record ChannelDescription { |
Harald Welte | ad091b6 | 2017-07-16 21:03:17 +0200 | [diff] [blame] | 259 | RslChannelNr chan_nr, |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 260 | uint3_t tsc, |
| 261 | boolean h, |
| 262 | uint12_t arfcn optional, |
| 263 | MaioHsn maio_hsn optional |
Harald Welte | ad091b6 | 2017-07-16 21:03:17 +0200 | [diff] [blame] | 264 | } with { variant (arfcn) "PRESENCE(h = false)" |
| 265 | variant (maio_hsn) "PRESENCE(h = true)" }; |
| 266 | |
| 267 | type record ChannelDescriptionTV { |
| 268 | OCT1 iei, |
| 269 | ChannelDescription v |
| 270 | } with { variant "" }; |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 271 | |
| 272 | /* 10.5.2.8 */ |
| 273 | type enumerated ChannelNeeded { |
| 274 | CHAN_NEED_ANY (0), |
| 275 | CHAN_NEED_SDCCH (1), |
| 276 | CHAN_NEED_TCH_F (2), |
| 277 | CHAN_NEED_TCH_H (3) |
| 278 | } with { variant "FIELDLENGTH(2)" }; |
| 279 | type record ChannelNeeded12 { |
| 280 | ChannelNeeded second, |
| 281 | ChannelNeeded first |
| 282 | } with { variant "" }; |
| 283 | |
| 284 | /* 10.5.2.21 */ |
| 285 | type record MobileAllocation { |
| 286 | uint8_t len, |
| 287 | bitstring ma |
| 288 | } with { variant (len) "LENGTHTO(ma)" }; |
| 289 | |
| 290 | /* 10.5.2.25a */ |
| 291 | type OCT3 PacketChannelDescription; |
| 292 | |
| 293 | /* 10.5.2.25b */ |
| 294 | type record DedicatedModeOrTbf { |
| 295 | BIT1 spare, |
| 296 | boolean tma, |
| 297 | boolean downlink, |
| 298 | boolean tbf |
| 299 | } with { variant "" }; |
| 300 | |
| 301 | /* 10.5.2.26 */ |
| 302 | type enumerated PageMode { |
| 303 | PAGE_MODE_NORMAL, |
| 304 | PAGE_MODE_EXTENDED, |
| 305 | PAGE_MODE_REORGANIZATION, |
| 306 | PAGE_MODE_SAME_AS_BEFORE |
| 307 | } with { variant "FIELDLENGTH(4)" }; |
| 308 | |
| 309 | /* 10.5.2.30 */ |
| 310 | type record RequestReference { |
| 311 | bitstring ra length(8), |
| 312 | uint5_t t1p, |
| 313 | uint6_t t3, |
Harald Welte | c3286cc | 2017-07-16 21:04:34 +0200 | [diff] [blame] | 314 | uint5_t t2 |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 315 | } with { variant "" }; |
| 316 | |
Harald Welte | c3286cc | 2017-07-16 21:04:34 +0200 | [diff] [blame] | 317 | template RequestReference t_RequestReference(template bitstring ra, template uint5_t t1p, template uint6_t t3, template uint5_t t2) := { |
| 318 | ra := ra, |
| 319 | t1p := t1p, |
| 320 | t3 := t3, |
| 321 | t2 := t2 |
| 322 | } |
| 323 | |
| 324 | /* compute the expected request reference for given RA + FN */ |
| 325 | function f_compute_ReqRef(uint8_t ra, GsmFrameNumber fn) return RequestReference { |
| 326 | var RequestReference req_ref := { ra := int2bit(ra, 8) }; |
| 327 | req_ref.t1p := (fn / 1326) mod 32; |
| 328 | req_ref.t2 := fn mod 26; |
| 329 | req_ref.t3 := fn mod 51; |
| 330 | return req_ref |
| 331 | } |
| 332 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 333 | /* 10.5.2.40 */ |
| 334 | type integer TimingAdvance (0..219); |
| 335 | |
| 336 | /* 10.5.2.43 */ |
| 337 | type uint8_t WaitIndication; |
| 338 | |
| 339 | /* 10.5.2.76 */ |
| 340 | type record FeatureIndicator { |
| 341 | BIT2 spare, |
| 342 | boolean cs_ir, |
| 343 | boolean ps_ir |
| 344 | } with { variant "" }; |
| 345 | |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 346 | /* 24.008 10.5.5.6 */ |
| 347 | type record DrxParameter { |
| 348 | uint8_t split_pg_cycle_code, |
| 349 | uint4_t drx_cycle_len_coeff, |
| 350 | boolean split_on_ccch, |
| 351 | uint3_t non_drx_timer |
| 352 | } with { variant "" }; |
| 353 | |
| 354 | /* 24.008 10.5.5.15 */ |
| 355 | type record RoutingAreaIdentification { |
| 356 | LocationAreaIdentification lai, |
| 357 | uint8_t rac |
| 358 | } with { variant "" }; |
| 359 | |
| 360 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 361 | |
| 362 | /* 9.1.18 */ |
| 363 | type record ImmediateAssignment { |
| 364 | DedicatedModeOrTbf ded_or_tbf, |
| 365 | PageMode page_mode, |
| 366 | ChannelDescription chan_desc optional, |
| 367 | PacketChannelDescription pkt_chan_desc optional, |
| 368 | RequestReference req_ref, |
| 369 | TimingAdvance timing_advance, |
| 370 | MobileAllocation mobile_allocation |
| 371 | } with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)" |
| 372 | variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" }; |
| 373 | |
| 374 | /* 9.1.20 */ |
| 375 | type record ReqRefWaitInd { |
| 376 | RequestReference req_ref, |
| 377 | WaitIndication wait_ind |
| 378 | } with { variant "" }; |
| 379 | type record length(4) of ReqRefWaitInd ReqRefWaitInd4; |
| 380 | type record ImmediateAssignmentReject { |
| 381 | FeatureIndicator feature_ind, |
| 382 | PageMode page_mode, |
| 383 | ReqRefWaitInd4 payload |
| 384 | } with { variant "" }; |
| 385 | |
| 386 | /* 9.1.22 */ |
| 387 | type record PagingRequestType1 { |
| 388 | ChannelNeeded12 chan_needed, |
| 389 | PageMode page_mode, |
| 390 | MobileIdentityLV mi1, |
| 391 | MobileIdentityTLV mi2 optional, |
| 392 | RestOctets rest_octets |
| 393 | } with { variant "TAG(mi2, tag = 23)" }; |
| 394 | |
| 395 | /* 9.1.23 */ |
| 396 | type record PagingRequestType2 { |
| 397 | ChannelNeeded12 chan_needed, |
| 398 | PageMode page_mode, |
| 399 | GsmTmsi mi1, |
| 400 | GsmTmsi mi2, |
| 401 | MobileIdentityTLV mi3 optional, |
| 402 | RestOctets rest_octets |
| 403 | } with { variant "TAG(mi3, tag = 23)" }; |
| 404 | |
| 405 | /* 9.1.24 */ |
| 406 | type record length(4) of GsmTmsi GsmTmsi4; |
| 407 | type record PagingRequestType3 { |
| 408 | ChannelNeeded12 chan_needed, |
| 409 | PageMode page_mode, |
| 410 | GsmTmsi4 mi, |
| 411 | RestOctets rest_octets |
| 412 | } with { variant "" }; |
| 413 | |
| 414 | |
| 415 | type union RrUnion { |
| 416 | /* |
| 417 | SystemInformationType1 si1, |
| 418 | SystemInformationType2 si2, |
| 419 | SystemInformationType2bis si2bis, |
| 420 | SystemInformationType2ter si2ter, |
| 421 | SystemInformationType3 si3, |
| 422 | SystemInformationType4 si4, |
| 423 | SystemInformationType5 si5, |
| 424 | SystemInformationType5bis si5bis, |
| 425 | SystemInformationType5ter si5ter, |
| 426 | SystemInformationType6 si6, |
| 427 | */ |
| 428 | ImmediateAssignment imm_ass, |
| 429 | ImmediateAssignmentReject imm_ass_rej, |
| 430 | PagingRequestType1 pag_req_1, |
| 431 | PagingRequestType2 pag_req_2, |
| 432 | PagingRequestType3 pag_req_3, |
| 433 | octetstring other |
| 434 | } with { variant "" }; |
| 435 | |
| 436 | /* Special RR Message on BCCH / CCCH Dowlink */ |
| 437 | |
| 438 | type record GsmRrMessage { |
| 439 | RrHeader header, |
| 440 | RrUnion payload |
| 441 | } with { variant (payload) "CROSSTAG( |
| 442 | /* |
| 443 | si1, header.message_type = SYSTEM_INFORMATION_TYPE_1; |
| 444 | si2, header.message_type = SYSTEM_INFORMATION_TYPE_2; |
| 445 | si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis; |
| 446 | si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter; |
| 447 | si3, header.message_type = SYSTEM_INFORMATION_TYPE_3; |
| 448 | si4, header.message_type = SYSTEM_INFORMATION_TYPE_4; |
| 449 | si5, header.message_type = SYSTEM_INFORMATION_TYPE_5; |
| 450 | si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis; |
| 451 | si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter; |
| 452 | si6, header.message_type = SYSTEM_INFORMATION_TYPE_6; |
| 453 | */ |
| 454 | imm_ass, header.message_type = IMMEDIATE_ASSIGNMENT; |
| 455 | imm_ass_rej, header.message_type = IMMEDIATE_ASSIGNMENT_REJECT; |
| 456 | pag_req_1, header.message_type = PAGING_REQUEST_TYPE_1; |
| 457 | pag_req_2, header.message_type = PAGING_REQUEST_TYPE_2; |
| 458 | pag_req_3, header.message_type = PAGING_REQUEST_TYPE_3; |
| 459 | other, OTHERWISE; |
| 460 | )" }; |
| 461 | |
Harald Welte | 0b1e5b8 | 2017-07-16 18:53:17 +0200 | [diff] [blame] | 462 | external function enc_GsmRrMessage(in GsmRrMessage msg) return octetstring |
| 463 | with { extension "prototype(convert) encode(RAW)" }; |
| 464 | external function dec_GsmRrMessage(in octetstring stream) return GsmRrMessage |
| 465 | with { extension "prototype(convert) decode(RAW)" }; |
| 466 | |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 467 | /* Normal L3 Message on Dedicated Channel */ |
| 468 | |
| 469 | /* 9.1.25 Paging Response */ |
| 470 | type record PagingResponse { |
| 471 | uint4_t spare_half_octet, |
| 472 | CipheringKeySeqNr cksn, |
| 473 | MsClassmark2LV cm2, |
| 474 | MobileIdentityLV mi, |
| 475 | uint8_t addl_upd_par optional |
| 476 | } with { variant "" }; |
| 477 | |
| 478 | type union RrL3Union { |
| 479 | PagingResponse paging_response, |
| 480 | octetstring other |
| 481 | }; |
| 482 | |
| 483 | type record GsmRrL3Message { |
| 484 | RrL3Header header, |
| 485 | RrL3Union payload |
| 486 | } with { variant (payload) "CROSSTAG( |
| 487 | paging_response, header.message_type = PAGING_RESPONSE; |
| 488 | |
| 489 | other, OTHERWISE; |
| 490 | )" } |
| 491 | |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 492 | /* TS 48.058 9.3.1 Channel Number IE */ |
| 493 | type enumerated RslChanNr0 { |
| 494 | RSL_CHAN_NR_INVALID ('00'H), |
| 495 | RSL_CHAN_NR_Bm_ACCH ('01'H), |
| 496 | RSL_CHAN_NR_BCCH ('10'H), |
| 497 | RSL_CHAN_NR_RACH ('11'H), |
| 498 | RSL_CHAN_NR_PCH_AGCH ('12'H) |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 499 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 500 | |
| 501 | type record RslChanNr2 { |
| 502 | BIT4 tag ('0001'B), |
| 503 | uint1_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 504 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 505 | |
| 506 | type record RslChanNr4 { |
| 507 | BIT3 tag ('001'B), |
| 508 | uint2_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 509 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 510 | |
| 511 | type record RslChanNr8 { |
| 512 | BIT2 tag ('01'B), |
| 513 | uint3_t sub_chan |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 514 | } with { variant "FIELDLENGTH(5)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 515 | |
| 516 | type union RslChanNrU { |
| 517 | RslChanNr0 ch0, |
| 518 | RslChanNr2 lm, |
| 519 | RslChanNr4 sdcch4, |
| 520 | RslChanNr8 sdcch8 |
| 521 | } with { |
| 522 | variant "TAG(lm, tag = '0001'B; |
| 523 | sdcch4, tag = '001'B; |
| 524 | sdcch8, tag = '01'B; |
| 525 | ch0, OTHERWISE)" |
| 526 | variant "FIELDLENGTH(5)" |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 527 | variant "FIELDORDER(msb)" |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 528 | }; |
| 529 | |
| 530 | type record RslChannelNr { |
| 531 | RslChanNrU u, |
| 532 | uint3_t tn |
Harald Welte | c84d847 | 2017-07-30 00:49:56 +0200 | [diff] [blame^] | 533 | } with { variant "FIELDLENGTH(8)" variant "FIELDORDER(msb)" }; |
Harald Welte | 0c8d5c0 | 2017-07-16 18:53:58 +0200 | [diff] [blame] | 534 | |
| 535 | template RslChannelNr t_RslChanNr0(template uint3_t tn, template RslChanNr0 cht) := { |
| 536 | u := { ch0 := cht }, |
| 537 | tn := tn |
| 538 | } |
| 539 | |
| 540 | template RslChannelNr t_RslChanNr_RACH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_RACH); |
| 541 | template RslChannelNr t_RslChanNr_BCCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_BCCH); |
| 542 | template RslChannelNr t_RslChanNr_PCH_AGCH(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_PCH_AGCH); |
| 543 | template RslChannelNr t_RslChanNr_Bm(template uint3_t tn) := t_RslChanNr0(tn, RSL_CHAN_NR_Bm_ACCH); |
| 544 | template RslChannelNr t_RslChanNr_Lm(template uint3_t tn, uint1_t sub_slot) := { |
| 545 | u := { lm := { tag := '0001'B, sub_chan := sub_slot } }, |
| 546 | tn := tn |
| 547 | } |
| 548 | template RslChannelNr t_RslChanNr_SDCCH4(template uint3_t tn, template uint2_t sub_slot) := { |
| 549 | u := { sdcch4 := { tag := '001'B, sub_chan := sub_slot } }, |
| 550 | tn := tn |
| 551 | } |
| 552 | template RslChannelNr t_RslChanNr_SDCCH8(template uint3_t tn, template uint3_t sub_slot) := { |
| 553 | u := { sdcch8 := { tag := '01'B, sub_chan := sub_slot } }, |
| 554 | tn := tn |
| 555 | } |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 556 | |
Harald Welte | b33e727 | 2017-07-16 21:04:12 +0200 | [diff] [blame] | 557 | /* TS 48.058 9.3.2 Link ID */ |
| 558 | type enumerated RslLinkIdC { |
| 559 | FACCH_SDCCH (0), |
| 560 | SACCH (1) |
| 561 | } with { variant "FIELDLENGTH(2)" }; |
| 562 | |
| 563 | type enumerated RslSapi0Prio { |
| 564 | SAPI0_PRIO_NORMAL (0), |
| 565 | SAPI0_PRIO_HIGH (1), |
| 566 | SAPI0_PRIO_LOW (2) |
| 567 | } with { variant "FIELDLENGTH(2)" }; |
| 568 | |
| 569 | type uint3_t GsmSapi; |
| 570 | |
| 571 | type record RslLinkId { |
| 572 | RslLinkIdC c, |
| 573 | boolean na, |
| 574 | RslSapi0Prio prio, |
| 575 | GsmSapi sapi |
| 576 | } with { variant "" }; |
| 577 | |
| 578 | template RslLinkId tr_RslLinkId := { |
| 579 | c := ?, |
| 580 | na := ?, |
| 581 | prio := ?, |
| 582 | sapi := ? |
| 583 | }; |
| 584 | |
| 585 | template RslLinkId tr_RslLinkID_DCCH(template GsmSapi sapi) modifies tr_RslLinkId := { |
| 586 | c := FACCH_SDCCH, |
| 587 | na := false, |
| 588 | sapi := sapi |
| 589 | }; |
| 590 | |
| 591 | template RslLinkId tr_RslLinkID_SACCH(template GsmSapi sapi) modifies tr_RslLinkId := { |
| 592 | c := SACCH, |
| 593 | na := false, |
| 594 | sapi := sapi |
| 595 | }; |
| 596 | |
| 597 | template RslLinkId ts_RslLinkID_DCCH(GsmSapi sapi) := { |
| 598 | c := FACCH_SDCCH, |
| 599 | na := false, |
| 600 | prio := SAPI0_PRIO_NORMAL, |
| 601 | sapi := sapi |
| 602 | }; |
| 603 | |
Harald Welte | cb5d1fb | 2017-07-17 21:00:15 +0200 | [diff] [blame] | 604 | template RslLinkId ts_RslLinkID_SACCH(GsmSapi sapi) := { |
| 605 | c := SACCH, |
| 606 | na := false, |
| 607 | prio := SAPI0_PRIO_NORMAL, |
| 608 | sapi := sapi |
Harald Welte | b33e727 | 2017-07-16 21:04:12 +0200 | [diff] [blame] | 609 | }; |
| 610 | |
Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 611 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |