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