Harald Welte | 56db5fd | 2017-07-14 18:25:59 +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) 2018 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 | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 12 | |
| 13 | module GSM_SystemInformation { |
| 14 | |
| 15 | import from General_Types all; |
Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 16 | import from GSM_Types all; |
Harald Welte | f976492 | 2017-08-20 22:47:44 +0200 | [diff] [blame] | 17 | import from GSM_RR_Types all; |
Harald Welte | 615bd54 | 2017-07-14 18:28:55 +0200 | [diff] [blame] | 18 | import from Osmocom_Types all; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 19 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 20 | type union ArfcnOrMaio { |
| 21 | uint12_t arfcn, |
| 22 | MaioHsn maio_hsn |
| 23 | } with { variant "" }; |
| 24 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 25 | /* 24.008 10.5.1.1 */ |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 26 | type uint16_t SysinfoCellIdentity; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 27 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 28 | /* 44.018 10.5.2.1b */ |
| 29 | type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" }; |
| 30 | |
| 31 | /* 44.018 10.5.2.3 */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 32 | type enumerated CellOptions_DTX { |
| 33 | MS_MAY_USE_UL_DTX ('00'B), |
| 34 | MS_SHALL_USE_UL_DTX ('01'B), |
| 35 | MS_SHALL_NOT_USE_UL_DTX ('10'B) |
| 36 | } with { variant "FIELDLENGTH(2)" }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 37 | type record CellOptions { |
| 38 | boolean dn_ind, |
| 39 | boolean pwrc, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 40 | CellOptions_DTX dtx, |
| 41 | uint4_t radio_link_tout_div4 |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 42 | } with { variant "" }; |
| 43 | |
| 44 | /* 44.018 10.5.2.3a */ |
| 45 | type record CellOptionsSacch { |
| 46 | BIT1 dtx_ext, |
| 47 | boolean pwrc, |
| 48 | BIT2 dtx, |
| 49 | BIT4 radio_link_timeout |
| 50 | } with { variant "" }; |
| 51 | |
| 52 | /* 44.018 10.5.2.4 */ |
| 53 | type record CellSelectionParameters { |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 54 | uint3_t cell_resel_hyst_2dB, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 55 | uint5_t ms_txpwr_max_cch, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 56 | BIT1 acs, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 57 | boolean neci, |
| 58 | uint6_t rxlev_access_min |
| 59 | } with { variant "" }; |
| 60 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 61 | /* 44.018 10.5.2.11 */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 62 | type enumerated CtrlChanDesc_CC { |
| 63 | CCHAN_DESC_1CCCH_NOT_COMBINED ('000'B), |
| 64 | CCHAN_DESC_1CCCH_COMBINED ('001'B), |
| 65 | CCHAN_DESC_2CCCH_NOT_COMBINED ('010'B), |
| 66 | CCHAN_DESC_3CCCH_NOT_COMBINED ('100'B), |
| 67 | CCHAN_DESC_4CCCH_NOT_COMBINED ('110'B) |
| 68 | } with { variant "FIELDLENGTH(3)" }; |
| 69 | type enumerated CBQ3 { |
| 70 | CBQ3_IU_MODE_NOT_SUPPORTED ('00'B), |
| 71 | CBQ3_IU_MODE_MS_BARRED ('01'B), |
| 72 | CBQ3_IU_MODE_NOT_BARRED ('10'B) |
| 73 | } with { variant "FIELDLENGTH(2)" }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 74 | type record ControlChannelDescription { |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 75 | boolean msc_r99, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 76 | boolean att, |
| 77 | uint3_t bs_ag_blks_res, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 78 | CtrlChanDesc_CC ccch_conf, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 79 | boolean si22ind, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 80 | CBQ3 cbq3, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 81 | BIT2 spare, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 82 | uint3_t bs_pa_mfrms, /* off by 2 */ |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 83 | uint8_t t3212 |
| 84 | } with { variant "" }; |
| 85 | |
Harald Welte | 162b160 | 2017-07-16 03:05:02 +0200 | [diff] [blame] | 86 | template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? }; |
| 87 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 88 | /* 44.018 10.5.2.21 */ |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 89 | type record MobileAllocationT { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 90 | OCT1 iei, |
| 91 | uint8_t len, |
| 92 | bitstring ma |
| 93 | } with { variant "" }; |
| 94 | |
| 95 | /* 44.018 10.5.2.22 */ |
| 96 | type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" }; |
| 97 | |
| 98 | /* 44.018 10.5.2.22a */ |
| 99 | type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" }; |
| 100 | |
| 101 | type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" }; |
| 102 | |
| 103 | /* 44.018 10.5.2.29 */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 104 | type enumerated RachCtrlPar_MR { |
| 105 | RACH_MAX_RETRANS_1 ('00'B), |
| 106 | RACH_MAX_RETRANS_2 ('01'B), |
| 107 | RACH_MAX_RETRANS_4 ('10'B), |
| 108 | RACH_MAX_RETRANS_7 ('11'B) |
| 109 | } with { variant "FIELDLENGTH(2)" }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 110 | type record RachControlParameters { |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 111 | RachCtrlPar_MR max_retrans, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 112 | BIT4 tx_integer, |
| 113 | boolean cell_barr_access, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 114 | boolean re_not_allowed, |
| 115 | AccessControlClass acc |
| 116 | } with { variant (acc) "FIELDLENGTH(16)" }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 117 | |
| 118 | /* 44.018 10.5.2.32 */ |
| 119 | type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" }; |
| 120 | type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" }; |
| 121 | |
| 122 | /* 44.018 9.1.31 */ |
| 123 | type record SystemInformationType1 { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 124 | CellChannelDescription cell_chan_desc, |
| 125 | RachControlParameters rach_control, |
| 126 | Si1RestOctets rest_octets |
| 127 | } with { variant "" }; |
| 128 | |
| 129 | /* 44.018 9.1.32 */ |
| 130 | type record SystemInformationType2 { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 131 | NeighbourCellDescription bcch_freq_list, |
| 132 | BIT8 ncc_permitted, |
| 133 | RachControlParameters rach_control |
| 134 | } with { variant "" }; |
| 135 | |
| 136 | /* 44.018 9.1.33 */ |
| 137 | type record SystemInformationType2bis { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 138 | NeighbourCellDescription extd_bcch_freq_list, |
| 139 | RachControlParameters rach_control, |
| 140 | OCT1 rest_octets |
| 141 | } with { variant "" }; |
| 142 | |
| 143 | /* 44.018 9.1.34 */ |
| 144 | type record SystemInformationType2ter { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 145 | NeighbourCellDescription2 extd_bcch_freq_list, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 146 | OCT4 rest_octets |
| 147 | } with { variant "" }; |
| 148 | |
| 149 | /* 44.018 9.1.35 */ |
| 150 | type record SystemInformationType3 { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 151 | SysinfoCellIdentity cell_id, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 152 | LocationAreaIdentification lai, |
| 153 | ControlChannelDescription ctrl_chan_desc, |
| 154 | CellOptions cell_options, |
| 155 | CellSelectionParameters cell_sel_par, |
| 156 | RachControlParameters rach_control, |
| 157 | Si3RestOctets rest_octets |
| 158 | } with { variant "" }; |
| 159 | |
Harald Welte | 162b160 | 2017-07-16 03:05:02 +0200 | [diff] [blame] | 160 | template SystemInformationType3 t_SI3 := { |
| 161 | cell_id := ?, |
| 162 | lai := ?, |
| 163 | ctrl_chan_desc := t_ControlChannelDescription, |
| 164 | cell_options := ?, |
| 165 | cell_sel_par := ?, |
| 166 | rach_control := ?, |
| 167 | rest_octets := ? |
| 168 | }; |
| 169 | |
| 170 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 171 | /* 44.018 9.1.36 */ |
| 172 | type record SystemInformationType4 { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 173 | LocationAreaIdentification lai, |
| 174 | CellSelectionParameters cell_sel_par, |
| 175 | RachControlParameters rach_control, |
Harald Welte | ad091b6 | 2017-07-16 21:03:17 +0200 | [diff] [blame] | 176 | ChannelDescriptionTV cbch_chan_desc optional, |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 177 | MobileAllocationT cbch_mobile_alloc optional, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 178 | RestOctets rest_octets |
| 179 | } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" }; |
| 180 | |
| 181 | /* 44.018 9.1.37 */ |
| 182 | type record SystemInformationType5 { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 183 | NeighbourCellDescription bcch_freq_list |
| 184 | } with { variant "" }; |
| 185 | |
| 186 | /* 44.018 9.1.38 */ |
| 187 | type record SystemInformationType5bis { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 188 | NeighbourCellDescription extd_bcch_freq_list |
| 189 | } with { variant "" }; |
| 190 | |
| 191 | /* 44.018 9.1.39 */ |
| 192 | type record SystemInformationType5ter { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 193 | NeighbourCellDescription2 extd_bcch_freq_list |
| 194 | } with { variant "" }; |
| 195 | |
| 196 | /* 44.018 9.1.40 */ |
| 197 | type record SystemInformationType6 { |
Harald Welte | 484160b | 2017-07-28 13:30:24 +0200 | [diff] [blame] | 198 | SysinfoCellIdentity cell_id, |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 199 | LocationAreaIdentification lai, |
| 200 | CellOptionsSacch cell_options, |
| 201 | BIT8 ncc_permitted, |
| 202 | OCT7 rest_octets |
| 203 | } with { variant "" }; |
| 204 | |
Harald Welte | a418918 | 2017-07-15 19:59:33 +0200 | [diff] [blame] | 205 | type union SystemInformationUnion { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 206 | SystemInformationType1 si1, |
| 207 | SystemInformationType2 si2, |
| 208 | SystemInformationType2bis si2bis, |
| 209 | SystemInformationType2ter si2ter, |
| 210 | SystemInformationType3 si3, |
| 211 | SystemInformationType4 si4, |
| 212 | SystemInformationType5 si5, |
| 213 | SystemInformationType5bis si5bis, |
| 214 | SystemInformationType5ter si5ter, |
Harald Welte | 8c5b325 | 2017-07-15 23:59:49 +0200 | [diff] [blame] | 215 | SystemInformationType6 si6, |
| 216 | octetstring other |
Harald Welte | a418918 | 2017-07-15 19:59:33 +0200 | [diff] [blame] | 217 | } with { variant "" }; |
| 218 | |
| 219 | type record SystemInformation { |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 220 | RrHeader header, |
Harald Welte | a418918 | 2017-07-15 19:59:33 +0200 | [diff] [blame] | 221 | SystemInformationUnion payload |
| 222 | } with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1; |
Harald Welte | a082a69 | 2017-07-15 15:58:13 +0200 | [diff] [blame] | 223 | si2, header.message_type = SYSTEM_INFORMATION_TYPE_2; |
| 224 | si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis; |
| 225 | si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter; |
| 226 | si3, header.message_type = SYSTEM_INFORMATION_TYPE_3; |
| 227 | si4, header.message_type = SYSTEM_INFORMATION_TYPE_4; |
| 228 | si5, header.message_type = SYSTEM_INFORMATION_TYPE_5; |
| 229 | si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis; |
| 230 | si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter; |
| 231 | si6, header.message_type = SYSTEM_INFORMATION_TYPE_6; |
Harald Welte | 8c5b325 | 2017-07-15 23:59:49 +0200 | [diff] [blame] | 232 | other, OTHERWISE; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 233 | )" }; |
| 234 | |
| 235 | external function enc_SystemInformation(in SystemInformation si) return octetstring |
| 236 | with { extension "prototype(convert) encode(RAW)" }; |
| 237 | external function dec_SystemInformation(in octetstring stream) return SystemInformation |
| 238 | with { extension "prototype(convert) decode(RAW)" }; |
| 239 | |
| 240 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |