blob: 01565c1304a5f8842ab03cbb2180f31a0c5e30fd [file] [log] [blame]
Harald Welte56db5fd2017-07-14 18:25:59 +02001/* 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
6module GSM_SystemInformation {
7
8 import from General_Types all;
9
10 type integer uint32_t (0..4294967295) with { variant "unsigned 32 bit" };
11 type integer uint16_t (0..65535) with { variant "unsigned 16 bit" };
12 type integer uint2_t (0..3) with { variant "unsigned 2 bit" };
13 type integer uint3_t (0..7) with { variant "unsigned 3 bit" };
14 type integer uint4_t (0..15) with { variant "unsigned 4 bit" };
15 type integer uint5_t (0..31) with { variant "unsigned 5 bit" };
16 type integer uint6_t (0..63) with { variant "unsigned 6 bit" };
17 type integer uint7_t (0..127) with { variant "unsigned 7 bit" };
18 type integer uint8_t (0..255) with { variant "unsigned 8 bit" };
19 type integer uint9_t (0..511) with { variant "unsigned 9 bit" };
20 type integer uint10_t (0..1023) with { variant "unsigned 10 bit" };
21 type integer uint11_t (0..2047) with { variant "unsigned 11 bit" };
22 type integer uint12_t (0..4095) with { variant "unsigned 12 bit" };
23
24 type record L2PseudoLength {
25 uint6_t l2_plen,
26 BIT2 zero_one
27 } with { variant "" };
28
29 template L2PseudoLength t_L2Pseudolength(uint6_t len) := {
30 l2_plen := len,
31 zero_one := '01'B
32 };
33
34 type octetstring RestOctets with { variant "PADDING(yes), PADDING_PATTERN('00101011'B)" };
35
36 type record MaioHsn {
37 } with { variant "" };
38
39 type union ArfcnOrMaio {
40 uint12_t arfcn,
41 MaioHsn maio_hsn
42 } with { variant "" };
43
44 type record SystemInformationHeader {
45 L2PseudoLength l2_plen,
46 uint4_t skip_indicator,
47 uint4_t rr_protocol_discriminator,
48 OCT1 message_type
49 } with { variant "" };
50
51 template SystemInformationHeader t_SiHeader(OCT1 msg_type, uint6_t len) := {
52 l2_plen := t_L2Pseudolength(len),
53 rr_protocol_discriminator := 6,
54 message_type := msg_type
55 };
56
57 external function enc_SystemInformationHeader(in SystemInformationHeader si) return octetstring
58 with { extension "prototype(convert) encode(RAW)" };
59 external function dec_SystemInformationHeader(in octetstring stream) return SystemInformationHeader
60 with { extension "prototype(convert) decode(RAW)" };
61
62 type hexstring GsmBcdString with { variant "HEXORDER(low)" };
63 type GsmBcdString BcdMccMnc with { variant "FIELDLENGTH(6)" };
64
65 /* 24.008 10.5.1.1 */
66 type uint16_t CellIdentity;
67
68 /* 24.008 10.5.1.3 */
69 type record LocationAreaIdentification {
70 BcdMccMnc mcc_mnc,
71 uint16_t lac
72 } with { variant "" };
73
74 /* 44.018 10.5.2.1b */
75 type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
76
77 /* 44.018 10.5.2.3 */
78 type record CellOptions {
79 boolean dn_ind,
80 boolean pwrc,
81 BIT2 dtx,
82 BIT4 radio_link_timeout
83 } with { variant "" };
84
85 /* 44.018 10.5.2.3a */
86 type record CellOptionsSacch {
87 BIT1 dtx_ext,
88 boolean pwrc,
89 BIT2 dtx,
90 BIT4 radio_link_timeout
91 } with { variant "" };
92
93 /* 44.018 10.5.2.4 */
94 type record CellSelectionParameters {
95 uint3_t cell_resel_hyst,
96 uint5_t ms_txpwr_max_cch,
97 boolean acs,
98 boolean neci,
99 uint6_t rxlev_access_min
100 } with { variant "" };
101
102 /* 44.018 10.5.2.5 */
103 type record ChannelDescription {
104 OCT1 iei,
105 BIT5 chan_type_tdma_offset,
106 uint3_t tn,
107 uint3_t tsc,
108 boolean h,
109 uint12_t arfcn optional,
110 MaioHsn maio_hsn optional
111 } with { variant (arfcn) "PRESENCE(h = true)"
112 variant (maio_hsn) "PRESENCE(h = false)" };
113
114 /* 44.018 10.5.2.11 */
115 type record ControlChannelDescription {
116 boolean mscrr,
117 boolean att,
118 uint3_t bs_ag_blks_res,
119 uint3_t ccch_conf,
120 boolean si22ind,
121 uint2_t cbq3,
122 BIT2 spare,
123 uint3_t bs_pa_mfrms,
124 uint8_t t3212
125 } with { variant "" };
126
127 /* 44.018 10.5.2.21 */
128 type record MobileAllocation {
129 OCT1 iei,
130 uint8_t len,
131 bitstring ma
132 } with { variant "" };
133
134 /* 44.018 10.5.2.22 */
135 type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
136
137 /* 44.018 10.5.2.22a */
138 type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
139
140 type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
141
142 /* 44.018 10.5.2.29 */
143 type record RachControlParameters {
144 BIT2 max_retrans,
145 BIT4 tx_integer,
146 boolean cell_barr_access,
147 boolean re,
148 AccessControlClass ac
149 } with { variant (ac) "FIELDLENGTH(16)" };
150
151 /* 44.018 10.5.2.32 */
152 type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" };
153 type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" };
154
155 /* 44.018 9.1.31 */
156 type record SystemInformationType1 {
157 SystemInformationHeader header,
158 CellChannelDescription cell_chan_desc,
159 RachControlParameters rach_control,
160 Si1RestOctets rest_octets
161 } with { variant "" };
162
163 /* 44.018 9.1.32 */
164 type record SystemInformationType2 {
165 SystemInformationHeader header,
166 NeighbourCellDescription bcch_freq_list,
167 BIT8 ncc_permitted,
168 RachControlParameters rach_control
169 } with { variant "" };
170
171 /* 44.018 9.1.33 */
172 type record SystemInformationType2bis {
173 SystemInformationHeader header,
174 NeighbourCellDescription extd_bcch_freq_list,
175 RachControlParameters rach_control,
176 OCT1 rest_octets
177 } with { variant "" };
178
179 /* 44.018 9.1.34 */
180 type record SystemInformationType2ter {
181 SystemInformationHeader header,
182 NeighbourCellDescription2 extd_bcch_freq_list,
183 RachControlParameters rach_control,
184 OCT4 rest_octets
185 } with { variant "" };
186
187 /* 44.018 9.1.35 */
188 type record SystemInformationType3 {
189 SystemInformationHeader header,
190 CellIdentity cell_id,
191 LocationAreaIdentification lai,
192 ControlChannelDescription ctrl_chan_desc,
193 CellOptions cell_options,
194 CellSelectionParameters cell_sel_par,
195 RachControlParameters rach_control,
196 Si3RestOctets rest_octets
197 } with { variant "" };
198
199 /* 44.018 9.1.36 */
200 type record SystemInformationType4 {
201 SystemInformationHeader header,
202 LocationAreaIdentification lai,
203 CellSelectionParameters cell_sel_par,
204 RachControlParameters rach_control,
205 ChannelDescription cbch_chan_desc optional,
206 MobileAllocation cbch_mobile_alloc optional,
207 RestOctets rest_octets
208 } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
209
210 /* 44.018 9.1.37 */
211 type record SystemInformationType5 {
212 SystemInformationHeader header,
213 NeighbourCellDescription bcch_freq_list
214 } with { variant "" };
215
216 /* 44.018 9.1.38 */
217 type record SystemInformationType5bis {
218 SystemInformationHeader header,
219 NeighbourCellDescription extd_bcch_freq_list
220 } with { variant "" };
221
222 /* 44.018 9.1.39 */
223 type record SystemInformationType5ter {
224 SystemInformationHeader header,
225 NeighbourCellDescription2 extd_bcch_freq_list
226 } with { variant "" };
227
228 /* 44.018 9.1.40 */
229 type record SystemInformationType6 {
230 SystemInformationHeader header,
231 CellIdentity cell_id,
232 LocationAreaIdentification lai,
233 CellOptionsSacch cell_options,
234 BIT8 ncc_permitted,
235 OCT7 rest_octets
236 } with { variant "" };
237
238
239 type union SystemInformation {
240 SystemInformationType1 si1,
241 SystemInformationType2 si2,
242 SystemInformationType2bis si2bis,
243 SystemInformationType2ter si2ter,
244 SystemInformationType3 si3,
245 SystemInformationType4 si4,
246 SystemInformationType5 si5,
247 SystemInformationType5bis si5bis,
248 SystemInformationType5ter si5ter,
249 SystemInformationType6 si6
250 } with { variant "TAG(si1, header.message_type = '19'O;
251 si2, header.message_type = '1A'O;
252 si2bis, header.message_type = '02'O;
253 si2ter, header.message_type = '03'O;
254 si3, header.message_type = '1B'O;
255 si4, header.message_type = '1C'O;
256 si5, header.message_type = '1D'O;
257 si5bis, header.message_type = '05'O;
258 si5ter, header.message_type = '06'O;
259 si6, header.message_type = '1E'O;
260 )" };
261
262 external function enc_SystemInformation(in SystemInformation si) return octetstring
263 with { extension "prototype(convert) encode(RAW)" };
264 external function dec_SystemInformation(in octetstring stream) return SystemInformation
265 with { extension "prototype(convert) decode(RAW)" };
266
267} with { encode "RAW"; variant "FIELDORDER(msb)" }