blob: b53d5f247e7c3e8f6631d1089ca42fe9814b4088 [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 Weltef9764922017-08-20 22:47:44 +020010 import from GSM_RR_Types all;
Harald Welte615bd542017-07-14 18:28:55 +020011 import from Osmocom_Types all;
Harald Welte56db5fd2017-07-14 18:25:59 +020012
Harald Welte56db5fd2017-07-14 18:25:59 +020013 type union ArfcnOrMaio {
14 uint12_t arfcn,
15 MaioHsn maio_hsn
16 } with { variant "" };
17
Harald Welte56db5fd2017-07-14 18:25:59 +020018 /* 24.008 10.5.1.1 */
Harald Welte484160b2017-07-28 13:30:24 +020019 type uint16_t SysinfoCellIdentity;
Harald Welte56db5fd2017-07-14 18:25:59 +020020
Harald Welte56db5fd2017-07-14 18:25:59 +020021 /* 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 Welte56db5fd2017-07-14 18:25:59 +020049 /* 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 Welte162b1602017-07-16 03:05:02 +020062 template ControlChannelDescription t_ControlChannelDescription := { ?, ?, ?, ?, ?, ?, '00'B, ?, ? };
63
Harald Welte56db5fd2017-07-14 18:25:59 +020064 /* 44.018 10.5.2.21 */
Harald Welted2e342f2017-07-16 07:34:13 +020065 type record MobileAllocationT {
Harald Welte56db5fd2017-07-14 18:25:59 +020066 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 Welte56db5fd2017-07-14 18:25:59 +020094 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 Welte56db5fd2017-07-14 18:25:59 +0200101 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 Welte56db5fd2017-07-14 18:25:59 +0200108 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 Welte56db5fd2017-07-14 18:25:59 +0200115 NeighbourCellDescription2 extd_bcch_freq_list,
Harald Welte56db5fd2017-07-14 18:25:59 +0200116 OCT4 rest_octets
117 } with { variant "" };
118
119 /* 44.018 9.1.35 */
120 type record SystemInformationType3 {
Harald Welte484160b2017-07-28 13:30:24 +0200121 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200122 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 Welte162b1602017-07-16 03:05:02 +0200130 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 Welte56db5fd2017-07-14 18:25:59 +0200141 /* 44.018 9.1.36 */
142 type record SystemInformationType4 {
Harald Welte56db5fd2017-07-14 18:25:59 +0200143 LocationAreaIdentification lai,
144 CellSelectionParameters cell_sel_par,
145 RachControlParameters rach_control,
Harald Weltead091b62017-07-16 21:03:17 +0200146 ChannelDescriptionTV cbch_chan_desc optional,
Harald Welted2e342f2017-07-16 07:34:13 +0200147 MobileAllocationT cbch_mobile_alloc optional,
Harald Welte56db5fd2017-07-14 18:25:59 +0200148 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 Welte56db5fd2017-07-14 18:25:59 +0200153 NeighbourCellDescription bcch_freq_list
154 } with { variant "" };
155
156 /* 44.018 9.1.38 */
157 type record SystemInformationType5bis {
Harald Welte56db5fd2017-07-14 18:25:59 +0200158 NeighbourCellDescription extd_bcch_freq_list
159 } with { variant "" };
160
161 /* 44.018 9.1.39 */
162 type record SystemInformationType5ter {
Harald Welte56db5fd2017-07-14 18:25:59 +0200163 NeighbourCellDescription2 extd_bcch_freq_list
164 } with { variant "" };
165
166 /* 44.018 9.1.40 */
167 type record SystemInformationType6 {
Harald Welte484160b2017-07-28 13:30:24 +0200168 SysinfoCellIdentity cell_id,
Harald Welte56db5fd2017-07-14 18:25:59 +0200169 LocationAreaIdentification lai,
170 CellOptionsSacch cell_options,
171 BIT8 ncc_permitted,
172 OCT7 rest_octets
173 } with { variant "" };
174
Harald Weltea4189182017-07-15 19:59:33 +0200175 type union SystemInformationUnion {
Harald Welte56db5fd2017-07-14 18:25:59 +0200176 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 Welte8c5b3252017-07-15 23:59:49 +0200185 SystemInformationType6 si6,
186 octetstring other
Harald Weltea4189182017-07-15 19:59:33 +0200187 } with { variant "" };
188
189 type record SystemInformation {
Harald Welted2e342f2017-07-16 07:34:13 +0200190 RrHeader header,
Harald Weltea4189182017-07-15 19:59:33 +0200191 SystemInformationUnion payload
192 } with { variant (payload) "CROSSTAG(si1, header.message_type = SYSTEM_INFORMATION_TYPE_1;
Harald Weltea082a692017-07-15 15:58:13 +0200193 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 Welte8c5b3252017-07-15 23:59:49 +0200202 other, OTHERWISE;
Harald Welte56db5fd2017-07-14 18:25:59 +0200203 )" };
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)" }