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