blob: 90fa425884eee856d4f6ac004f54878777477129 [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;
Harald Weltea082a692017-07-15 15:58:13 +02009 import from GSM_Types all;
Harald Welte615bd542017-07-14 18:28:55 +020010 import from Osmocom_Types all;
Harald Welte56db5fd2017-07-14 18:25:59 +020011
Harald Welte56db5fd2017-07-14 18:25:59 +020012 type union ArfcnOrMaio {
13 uint12_t arfcn,
14 MaioHsn maio_hsn
15 } with { variant "" };
16
Harald Welte56db5fd2017-07-14 18:25:59 +020017 /* 24.008 10.5.1.1 */
Harald Welte484160b2017-07-28 13:30:24 +020018 type uint16_t SysinfoCellIdentity;
Harald Welte56db5fd2017-07-14 18:25:59 +020019
Harald Welte56db5fd2017-07-14 18:25:59 +020020 /* 44.018 10.5.2.1b */
21 type octetstring CellChannelDescription with { variant "FIELDLENGTH(16)" };
22
23 /* 44.018 10.5.2.3 */
24 type record CellOptions {
25 boolean dn_ind,
26 boolean pwrc,
27 BIT2 dtx,
28 BIT4 radio_link_timeout
29 } with { variant "" };
30
31 /* 44.018 10.5.2.3a */
32 type record CellOptionsSacch {
33 BIT1 dtx_ext,
34 boolean pwrc,
35 BIT2 dtx,
36 BIT4 radio_link_timeout
37 } with { variant "" };
38
39 /* 44.018 10.5.2.4 */
40 type record CellSelectionParameters {
41 uint3_t cell_resel_hyst,
42 uint5_t ms_txpwr_max_cch,
43 boolean acs,
44 boolean neci,
45 uint6_t rxlev_access_min
46 } with { variant "" };
47
Harald Welte56db5fd2017-07-14 18:25:59 +020048 /* 44.018 10.5.2.11 */
49 type record ControlChannelDescription {
50 boolean mscrr,
51 boolean att,
52 uint3_t bs_ag_blks_res,
53 uint3_t ccch_conf,
54 boolean si22ind,
55 uint2_t cbq3,
56 BIT2 spare,
57 uint3_t bs_pa_mfrms,
58 uint8_t t3212
59 } with { variant "" };
60
Harald Welte162b1602017-07-16 03:05:02 +020061 template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? };
62
Harald Welte56db5fd2017-07-14 18:25:59 +020063 /* 44.018 10.5.2.21 */
Harald Welted2e342f2017-07-16 07:34:13 +020064 type record MobileAllocationT {
Harald Welte56db5fd2017-07-14 18:25:59 +020065 OCT1 iei,
66 uint8_t len,
67 bitstring ma
68 } with { variant "" };
69
70 /* 44.018 10.5.2.22 */
71 type octetstring NeighbourCellDescription with { variant "FIELDLENGTH(16)" };
72
73 /* 44.018 10.5.2.22a */
74 type octetstring NeighbourCellDescription2 with { variant "FIELDLENGTH(16)" };
75
76 type bitstring AccessControlClass with { variant "FIELDLENGTH(16), BYTEORDER(last)" };
77
78 /* 44.018 10.5.2.29 */
79 type record RachControlParameters {
80 BIT2 max_retrans,
81 BIT4 tx_integer,
82 boolean cell_barr_access,
83 boolean re,
84 AccessControlClass ac
85 } with { variant (ac) "FIELDLENGTH(16)" };
86
87 /* 44.018 10.5.2.32 */
88 type RestOctets Si1RestOctets with { variant "FIELDLENGTH(1)" };
89 type RestOctets Si3RestOctets with { variant "FIELDLENGTH(4)" };
90
91 /* 44.018 9.1.31 */
92 type record SystemInformationType1 {
Harald Welte56db5fd2017-07-14 18:25:59 +020093 CellChannelDescription cell_chan_desc,
94 RachControlParameters rach_control,
95 Si1RestOctets rest_octets
96 } with { variant "" };
97
98 /* 44.018 9.1.32 */
99 type record SystemInformationType2 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200100 NeighbourCellDescription bcch_freq_list,
101 BIT8 ncc_permitted,
102 RachControlParameters rach_control
103 } with { variant "" };
104
105 /* 44.018 9.1.33 */
106 type record SystemInformationType2bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200107 NeighbourCellDescription extd_bcch_freq_list,
108 RachControlParameters rach_control,
109 OCT1 rest_octets
110 } with { variant "" };
111
112 /* 44.018 9.1.34 */
113 type record SystemInformationType2ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200114 NeighbourCellDescription2 extd_bcch_freq_list,
Harald Welte56db5fd2017-07-14 18:25:59 +0200115 OCT4 rest_octets
116 } with { variant "" };
117
118 /* 44.018 9.1.35 */
119 type record SystemInformationType3 {
Harald Welte484160b2017-07-28 13:30:24 +0200120 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200121 LocationAreaIdentification lai,
122 ControlChannelDescription ctrl_chan_desc,
123 CellOptions cell_options,
124 CellSelectionParameters cell_sel_par,
125 RachControlParameters rach_control,
126 Si3RestOctets rest_octets
127 } with { variant "" };
128
Harald Welte162b1602017-07-16 03:05:02 +0200129 template SystemInformationType3 t_SI3 := {
130 cell_id := ?,
131 lai := ?,
132 ctrl_chan_desc := t_ControlChannelDescription,
133 cell_options := ?,
134 cell_sel_par := ?,
135 rach_control := ?,
136 rest_octets := ?
137 };
138
139
Harald Welte56db5fd2017-07-14 18:25:59 +0200140 /* 44.018 9.1.36 */
141 type record SystemInformationType4 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200142 LocationAreaIdentification lai,
143 CellSelectionParameters cell_sel_par,
144 RachControlParameters rach_control,
Harald Weltead091b62017-07-16 21:03:17 +0200145 ChannelDescriptionTV cbch_chan_desc optional,
Harald Welted2e342f2017-07-16 07:34:13 +0200146 MobileAllocationT cbch_mobile_alloc optional,
Harald Welte56db5fd2017-07-14 18:25:59 +0200147 RestOctets rest_octets
148 } with { variant "TAG(cbch_chan_desc, iei = '64'O; cbch_mobile_alloc, iei = '72'O)" };
149
150 /* 44.018 9.1.37 */
151 type record SystemInformationType5 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200152 NeighbourCellDescription bcch_freq_list
153 } with { variant "" };
154
155 /* 44.018 9.1.38 */
156 type record SystemInformationType5bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200157 NeighbourCellDescription extd_bcch_freq_list
158 } with { variant "" };
159
160 /* 44.018 9.1.39 */
161 type record SystemInformationType5ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200162 NeighbourCellDescription2 extd_bcch_freq_list
163 } with { variant "" };
164
165 /* 44.018 9.1.40 */
166 type record SystemInformationType6 {
Harald Welte484160b2017-07-28 13:30:24 +0200167 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200168 LocationAreaIdentification lai,
169 CellOptionsSacch cell_options,
170 BIT8 ncc_permitted,
171 OCT7 rest_octets
172 } with { variant "" };
173
Harald Weltea4189182017-07-15 19:59:33 +0200174 type union SystemInformationUnion {
Harald Welte56db5fd2017-07-14 18:25:59 +0200175 SystemInformationType1 si1,
176 SystemInformationType2 si2,
177 SystemInformationType2bis si2bis,
178 SystemInformationType2ter si2ter,
179 SystemInformationType3 si3,
180 SystemInformationType4 si4,
181 SystemInformationType5 si5,
182 SystemInformationType5bis si5bis,
183 SystemInformationType5ter si5ter,
Harald Welte8c5b3252017-07-15 23:59:49 +0200184 SystemInformationType6 si6,
185 octetstring other
Harald Weltea4189182017-07-15 19:59:33 +0200186 } with { variant "" };
187
188 type record SystemInformation {
Harald Welted2e342f2017-07-16 07:34:13 +0200189 RrHeader header,
Harald Weltea4189182017-07-15 19:59:33 +0200190 SystemInformationUnion payload
191 } with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
Harald Weltea082a692017-07-15 15:58:13 +0200192 si2, header.message_type = SYSTEM_INFORMATION_TYPE_2;
193 si2bis, header.message_type = SYSTEM_INFORMATION_TYPE_2bis;
194 si2ter, header.message_type = SYSTEM_INFORMATION_TYPE_2ter;
195 si3, header.message_type = SYSTEM_INFORMATION_TYPE_3;
196 si4, header.message_type = SYSTEM_INFORMATION_TYPE_4;
197 si5, header.message_type = SYSTEM_INFORMATION_TYPE_5;
198 si5bis, header.message_type = SYSTEM_INFORMATION_TYPE_5bis;
199 si5ter, header.message_type = SYSTEM_INFORMATION_TYPE_5ter;
200 si6, header.message_type = SYSTEM_INFORMATION_TYPE_6;
Harald Welte8c5b3252017-07-15 23:59:49 +0200201 other, OTHERWISE;
Harald Welte56db5fd2017-07-14 18:25:59 +0200202 )" };
203
204 external function enc_SystemInformation(in SystemInformation si) return octetstring
205 with { extension "prototype(convert) encode(RAW)" };
206 external function dec_SystemInformation(in octetstring stream) return SystemInformation
207 with { extension "prototype(convert) decode(RAW)" };
208
209} with { encode "RAW"; variant "FIELDORDER(msb)" }