blob: f7592fc819b8093a64efcdc6da54dcff23190c99 [file] [log] [blame]
Harald Weltef6543322017-07-16 07:35:10 +02001/* Data Types / Encoding / Decoding for OsmocomBB L1CTL interface */
2/* (C) 2017 by Harald Welte <laforge@gnumonks.org>, derived from l1ctl_proto.h
Harald Welte34b5a952019-05-27 11:54:11 +02003 * which is (C) 2010 by Harald Welte + Holger Hans Peter Freyther
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
Harald Weltef6543322017-07-16 07:35:10 +020012module L1CTL_Types {
13
14 import from General_Types all;
15 import from GSM_Types all;
Harald Welte9419c8a2017-07-30 04:07:05 +020016 import from GSM_RR_Types all;
Harald Weltef6543322017-07-16 07:35:10 +020017 import from Osmocom_Types all;
18
Harald Welte7024baa2018-03-02 23:37:51 +010019 type uint32_t uint32_le with { variant "BYTEORDER(first)" };
20
Harald Weltef6543322017-07-16 07:35:10 +020021 type enumerated L1ctlMsgType {
22 L1CTL_NONE,
23 L1CTL_FBSB_REQ,
24 L1CTL_FBSB_CONF,
25 L1CTL_DATA_IND,
26 L1CTL_RACH_REQ,
27 L1CTL_DM_EST_REQ,
28 L1CTL_DATA_REQ,
29 L1CTL_RESET_IND,
30 L1CTL_PM_REQ, /* power measurement */
31 L1CTL_PM_CONF, /* power measurement */
32 L1CTL_ECHO_REQ,
33 L1CTL_ECHO_CONF,
34 L1CTL_RACH_CONF,
35 L1CTL_RESET_REQ,
36 L1CTL_RESET_CONF,
37 L1CTL_DATA_CONF,
38 L1CTL_CCCH_MODE_REQ,
39 L1CTL_CCCH_MODE_CONF,
40 L1CTL_DM_REL_REQ,
41 L1CTL_PARAM_REQ,
42 L1CTL_DM_FREQ_REQ,
43 L1CTL_CRYPTO_REQ,
44 L1CTL_SIM_REQ,
45 L1CTL_SIM_CONF,
46 L1CTL_TCH_MODE_REQ,
47 L1CTL_TCH_MODE_CONF,
48 L1CTL_NEIGH_PM_REQ,
49 L1CTL_NEIGH_PM_IND,
50 L1CTL_TRAFFIC_REQ,
51 L1CTL_TRAFFIC_CONF,
Harald Welte00d4dac2017-07-30 00:50:32 +020052 L1CTL_TRAFFIC_IND,
Vadim Yanitskiy4e79ff52019-04-22 06:38:21 +070053 L1CTL_BURST_IND,
Harald Welte00d4dac2017-07-30 00:50:32 +020054 L1CTL_TBF_CFG_REQ,
Harald Welteb3c226e2017-07-30 17:18:01 +020055 L1CTL_TBF_CFG_CONF,
56 L1CTL_DATA_TBF_REQ,
Harald Welte3a40ec72018-03-02 20:45:04 +010057 L1CTL_DATA_TBF_CONF,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +070058 L1CTL_EXT_RACH_REQ,
59 L1CTL_DATA_ABS_REQ /*!< FIXME: no such message in OsmocomBB */
Harald Weltef6543322017-07-16 07:35:10 +020060 } with { variant "FIELDLENGTH(8)" };
61
62 type enumerated L1ctlCcchMode {
63 CCCH_MODE_NONE (0),
64 CCCH_MODE_NON_COMBINED,
Harald Welte990a3612019-05-27 14:02:13 +020065 CCCH_MODE_COMBINED,
66 CCCH_MODE_COMBINED_CBCH
Harald Weltef6543322017-07-16 07:35:10 +020067 } with { variant "FIELDLENGTH(8)" };
68
69 type enumerated L1ctlNeighMode {
70 NEIGH_MODE_NONE (0),
71 NEIGH_MODE_PM,
72 NEIGH_MODE_SB
73 } with { variant "FIELDLENGTH(8)" };
74
Harald Welte1dcc3712017-08-01 00:05:52 +020075 type enumerated L1ctlGprsCs {
76 L1CTL_CS1 (1),
77 L1CTL_CS2,
78 L1CTL_CS3,
79 L1CTL_CS4,
80 L1CTL_MCS1,
81 L1CTL_MCS2,
82 L1CTL_MCS3,
83 L1CTL_MCS4,
84 L1CTL_MCS5,
85 L1CTL_MCS6,
86 L1CTL_MCS7,
87 L1CTL_MCS8,
88 L1CTL_MCS9
89 } with { variant "FIELDLENGTH(8)" };
90
Harald Weltef6543322017-07-16 07:35:10 +020091 type enumerated L1ctlResetType {
92 L1CTL_RES_T_BOOT (0),
93 L1CTL_RES_T_FULL,
94 L1CTL_RES_T_SCHED
95 } with { variant "FIELDLENGTH(8)" };
96
Harald Weltef6543322017-07-16 07:35:10 +020097 type record L1ctlHdrFlags {
98 BIT7 padding,
99 boolean f_done
100 } with { variant "" };
101
102 type record L1ctlHeader {
103 L1ctlMsgType msg_type,
104 L1ctlHdrFlags flags,
105 OCT2 padding
106 } with { variant "" };
107
Harald Weltef8df4cb2018-03-10 15:15:08 +0100108 template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := {
109 msg_type := msg_type,
110 flags := ?,
111 padding := ?
112 };
113
114 template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +0200115 msg_type := msg_type,
116 flags := { padding := '0000000'B, f_done := false },
117 padding := '0000'O
118 };
119
Harald Weltef6543322017-07-16 07:35:10 +0200120 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200121 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200122 RslLinkId link_id,
123 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200124 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200125 GsmRxLev rx_level,
126 uint8_t snr,
127 uint8_t num_biterr,
128 uint8_t fire_crc
129 } with { variant "" };
130
131 type record L1ctlFbsbConf {
132 int16_t initial_freq_err,
133 uint8_t result,
134 uint8_t bsic
135 } with { variant "" };
136
137 type record L1ctlCcchModeConf {
138 L1ctlCcchMode ccch_mode,
139 OCT3 padding
140 } with { variant "" };
141
142 /* gsm48_chan_mode */
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700143 type enumerated L1ctlTchMode {
144 L1CTL_CHAN_MODE_SIGN ('00000000'B), /* Signalling */
145 L1CTL_CHAN_MODE_SPEECH_V1 ('00000001'B), /* FR or HR codec */
146 L1CTL_CHAN_MODE_SPEECH_V2 ('00100001'B), /* EFR codec */
147 L1CTL_CHAN_MODE_SPEECH_V3 ('01000001'B) /* AMR codec */
148 /* Other modes are not supported for now */
149 } with { variant "FIELDLENGTH(8)" };
Harald Weltef6543322017-07-16 07:35:10 +0200150
151 type record L1ctlAudioMode {
152 BIT4 padding,
153 boolean tx_microphone,
154 boolean tx_traffic_req,
155 boolean rx_speaker,
156 boolean rx_traffic_ind
157 } with { variant "" };
158
Harald Weltef8df4cb2018-03-10 15:15:08 +0100159 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200160
Harald Weltef6543322017-07-16 07:35:10 +0200161 type record L1ctlTchModeConf {
162 L1ctlTchMode tch_mode,
163 L1ctlAudioMode audio_mode,
164 OCT2 padding
165 } with { variant "" };
166
167 type record L1ctlDataInd {
Vadim Yanitskiy2a92e2a2019-05-28 21:13:35 +0700168 octetstring payload
Harald Welte7024baa2018-03-02 23:37:51 +0100169 } with {
170 variant (payload) "BYTEORDER(first)"
171 };
Harald Weltef6543322017-07-16 07:35:10 +0200172
173 type union L1ctlDlPayload {
174 L1ctlFbsbConf fbsb_conf,
175 L1ctlCcchModeConf ccch_mode_conf,
176 L1ctlTchModeConf tch_mode_conf,
177 L1ctlDataInd data_ind,
178 L1ctlTrafficReq traffic_ind,
Harald Welte00d4dac2017-07-30 00:50:32 +0200179 L1ctlTbfCfgReq tbf_cfg_conf,
Harald Weltef6543322017-07-16 07:35:10 +0200180 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100181 } with {
182 variant (other) "BYTEORDER(first)"
183 };
Harald Weltef6543322017-07-16 07:35:10 +0200184
185 type record L1ctlDlMessage {
186 L1ctlHeader header,
187 L1ctlDlInfo dl_info optional,
Harald Weltef56cc492018-04-15 10:58:43 +0200188 L1ctlDlPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200189 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
190 header.msg_type = L1CTL_RACH_CONF,
191 header.msg_type = L1CTL_DATA_IND,
192 header.msg_type = L1CTL_DATA_CONF,
Harald Welte3c4cbf62018-03-30 10:31:39 +0200193 header.msg_type = L1CTL_TRAFFIC_IND,
194 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200195 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
196 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
197 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
198 data_ind, header.msg_type = L1CTL_DATA_IND;
199 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
Harald Welte00d4dac2017-07-30 00:50:32 +0200200 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
Harald Weltef6543322017-07-16 07:35:10 +0200201 other, OTHERWISE;
202 )" };
203
204 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
205 with { extension "prototype(convert) encode(RAW)" };
206 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
207 with { extension "prototype(convert) decode(RAW)" };
208
209
210 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200211 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200212 RslLinkId link_id,
213 OCT2 padding
214 } with { variant "" };
215
Harald Welteb3c226e2017-07-30 17:18:01 +0200216 type record L1ctlUlTbfInfo {
217 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200218 L1ctlGprsCs cs,
219 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200220 } with { variant "" };
221
Harald Welte3a40ec72018-03-02 20:45:04 +0100222 type record L1ctlUlAbsInfo {
223 uint8_t tbf_nr,
224 L1ctlGprsCs cs,
225 uint8_t ts_nr,
226 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100227 uint32_le fn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100228 Arfcn arfcn,
229 OCT2 padding2
230 } with { variant "" };
231
Harald Weltef6543322017-07-16 07:35:10 +0200232 type record L1ctlFbsbFlags {
233 BIT5 padding,
234 boolean sb,
235 boolean fb1,
236 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100237 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200238
Harald Weltef8df4cb2018-03-10 15:15:08 +0100239 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200240 padding := '00000'B,
241 sb := true,
242 fb1 := true,
243 fb0 := true
244 };
245
Harald Weltef6543322017-07-16 07:35:10 +0200246 type record L1ctlFbsbReq {
247 Arfcn arfcn,
248 uint16_t timeout_tdma_frames,
249 uint16_t freq_err_thresh1,
250 uint16_t freq_err_thresh2,
251 uint8_t num_freqerr_avg,
252 L1ctlFbsbFlags flags,
253 uint8_t sync_info_idx,
254 L1ctlCcchMode ccch_mode,
255 GsmRxLev rxlev_exp
256 } with { variant "" };
257
258 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100259 L1ctlCcchMode ccch_mode,
260 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200261 } with { variant "" };
262
263 type record L1ctlTchModeReq {
264 L1ctlTchMode tch_mode,
265 L1ctlAudioMode audio_mode,
266 OCT2 padding
267 } with { variant "" };
268
269 type record L1ctlRachReq {
270 uint8_t ra,
271 uint8_t combined,
272 uint16_t offset
273 } with { variant "" };
274
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700275 type enumerated L1ctlRachSynchSeq {
276 RACH_SYNCH_SEQ_TS0 (0),
277 RACH_SYNCH_SEQ_TS1,
278 RACH_SYNCH_SEQ_TS2
279 } with { variant "FIELDLENGTH(8)" };
280
281 type record L1ctlExtRachReq {
282 uint16_t ra11,
283 L1ctlRachSynchSeq synch_seq,
284 uint8_t combined,
285 uint16_t offset
286 } with { variant "" };
287
Harald Weltef6543322017-07-16 07:35:10 +0200288 type record L1ctlParReq {
289 int8_t ta,
290 uint8_t tx_power,
291 OCT2 padding
292 } with { variant "" };
293
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200294 type record L1ctlDataReq {
295 SacchL1Header l1header optional,
296 octetstring l2_payload
297 } with { variant "" };
298
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700299 type record L1ctlH0 {
300 uint8_t h,
301 Arfcn arfcn,
302 octetstring padding length(130)
303 } with { variant "" };
304
Vadim Yanitskiye8ea3ee2020-05-27 13:29:48 +0700305 type record length(0..64) of Arfcn L1ctlMA;
Harald Weltef6543322017-07-16 07:35:10 +0200306 type record L1ctlH1 {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700307 uint8_t h,
Harald Weltef6543322017-07-16 07:35:10 +0200308 uint8_t hsn,
309 uint8_t maio,
310 uint8_t n,
Vadim Yanitskiye8ea3ee2020-05-27 13:29:48 +0700311 OCT1 spare,
312 L1ctlMA ma,
313 octetstring padding
314 } with {
315 variant (n) "LENGTHTO(ma)"
316 variant (n) "UNIT(elements)"
317 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849.
318 * TL;DR The reference point of the PADDING attribute is the beginning
319 * of the message, not the beginning of the type/field it's applied on.
320 * Therefore we cannot use it here, and have to add padding manually.
321 * variant (ma) "PADDING(128)" */
322 };
Harald Weltef6543322017-07-16 07:35:10 +0200323
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700324 type union L1ctlH0H1 {
325 L1ctlH0 h0,
326 L1ctlH1 h1
327 } with { variant "TAG(h0, h = 0; h1, h = 1)" };
328
Harald Weltef6543322017-07-16 07:35:10 +0200329 type record L1ctlDmEstReq {
330 GsmTsc tsc,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700331 L1ctlH0H1 h0h1,
Harald Weltef6543322017-07-16 07:35:10 +0200332 L1ctlTchMode tch_mode,
333 L1ctlAudioMode audio_mode
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700334 } with { variant "" };
Harald Weltef6543322017-07-16 07:35:10 +0200335
336 type record L1ctlReset {
337 L1ctlResetType reset_type,
338 OCT3 padding
339 } with { variant "" };
340
Harald Weltee613f962018-04-18 22:38:16 +0200341 type record L1CtlCryptoReq {
342 uint8_t algo,
343 uint8_t key_len,
344 octetstring key
345 } with { variant (key_len) "LENGTHTO(key)" };
346
Harald Weltef6543322017-07-16 07:35:10 +0200347
348 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700349 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100350 } with {
351 variant (data) "BYTEORDER(first)"
352 }
Harald Weltef6543322017-07-16 07:35:10 +0200353
Harald Welte00d4dac2017-07-30 00:50:32 +0200354 type record length(8) of uint8_t TfiUsfArr;
355
356 type record L1ctlTbfCfgReq {
357 uint8_t tbf_nr,
358 boolean is_uplink,
359 OCT2 padding,
360 TfiUsfArr tfi_usf
361 } with { variant (is_uplink) "FIELDLENGTH(8)" };
362
Harald Weltef6543322017-07-16 07:35:10 +0200363 type union L1ctlUlPayload {
364 L1ctlFbsbReq fbsb_req,
365 L1ctlCcchModeReq ccch_mode_req,
366 L1ctlTchModeReq tch_mode_req,
367 L1ctlRachReq rach_req,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700368 L1ctlExtRachReq ext_rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200369 L1ctlParReq par_req,
370 L1ctlDmEstReq dm_est_req,
371 L1ctlReset reset_req,
372 //L1ctlNeighPmReq neigh_pm_req,
Harald Weltee613f962018-04-18 22:38:16 +0200373 L1CtlCryptoReq crypto_req,
Harald Weltef6543322017-07-16 07:35:10 +0200374 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200375 L1ctlTbfCfgReq tbf_cfg_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200376 L1ctlDataReq data_req,
Harald Weltef6543322017-07-16 07:35:10 +0200377 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100378 } with {
379 variant (other) "BYTEORDER(first)"
380 };
Harald Weltef6543322017-07-16 07:35:10 +0200381
382 type record L1ctlUlMessage {
383 L1ctlHeader header,
384 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200385 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100386 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200387 L1ctlUlPayload payload
388 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700389 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200390 header.msg_type = L1CTL_PARAM_REQ,
391 header.msg_type = L1CTL_CRYPTO_REQ,
392 header.msg_type = L1CTL_DATA_REQ,
393 header.msg_type = L1CTL_DM_EST_REQ,
394 header.msg_type = L1CTL_DM_FREQ_REQ,
395 header.msg_type = L1CTL_DM_REL_REQ,
396 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200397 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100398 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200399 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
400 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
401 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
402 rach_req, header.msg_type = L1CTL_RACH_REQ;
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700403 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200404 par_req, header.msg_type = L1CTL_PARAM_REQ;
405 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
406 reset_req, header.msg_type = L1CTL_RESET_REQ;
Harald Weltee613f962018-04-18 22:38:16 +0200407 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200408 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200409 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200410 data_req, header.msg_type = L1CTL_DATA_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200411 other, OTHERWISE;
412 )" };
413
414 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
415 with { extension "prototype(convert) encode(RAW)" };
416 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
417 with { extension "prototype(convert) decode(RAW)" };
418
Harald Welte52c713c2017-07-16 15:44:44 +0200419 type record L1ctlUlMessageLV {
420 uint16_t len,
421 L1ctlUlMessage msg
422 } with { variant (len) "LENGTHTO(msg)" };
423
424 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
425 with { extension "prototype(convert) encode(RAW)" };
426 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
427 with { extension "prototype(convert) decode(RAW)" };
428
429 type record L1ctlDlMessageLV {
430 uint16_t len,
431 L1ctlDlMessage msg
432 } with { variant (len) "LENGTHTO(msg)" };
433
434 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
435 with { extension "prototype(convert) encode(RAW)" };
436 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
437 with { extension "prototype(convert) decode(RAW)" };
438
439
Harald Welte9e4725d2017-07-16 23:18:09 +0200440
441
442 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100443 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
444 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200445 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200446 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100447 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200448 payload := {
449 reset_req := {
450 reset_type := rst_type,
451 padding := '000000'O
452 }
453 }
454 };
455
456 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100457 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
458 uint8_t sync_info_idx,
459 L1ctlCcchMode ccch_mode,
460 GsmRxLev rxlev_exp) := {
461 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200462 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200463 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100464 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200465 payload := {
466 fbsb_req := {
467 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100468 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200469 freq_err_thresh1 := 10000,
470 freq_err_thresh2 := 800,
471 num_freqerr_avg := 3,
472 flags := flags,
473 sync_info_idx := sync_info_idx,
474 ccch_mode := ccch_mode,
475 rxlev_exp := rxlev_exp
476 }
477 }
478 };
479
480 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100481 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
482 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200483 dl_info := ?,
484 payload := {
485 fbsb_conf := {
486 initial_freq_err := ?,
487 result := result,
488 bsic := ?
489 }
490 }
491 };
492
Harald Weltef8df4cb2018-03-10 15:15:08 +0100493 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
494 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
495 ul_info := omit,
496 ul_info_tbf := omit,
497 ul_info_abs := omit,
498 payload := {
499 ccch_mode_req := {
500 ccch_mode := ccch_mode,
501 padding := '000000'O
502 }
503 }
504 };
505
Harald Welte3757e602018-03-10 17:12:02 +0100506
507 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
508 header := tr_L1ctlHeader(msg_type),
509 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200510 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100511 }
512
513 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100514
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700515 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset,
516 template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
517 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100518 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200519 ul_info := {
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700520 chan_nr := chan_nr,
521 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200522 padding := '0000'O
523 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200524 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100525 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200526 payload := {
527 rach_req := {
528 ra := ra,
529 combined := combined,
530 offset := offset
531 }
532 }
533 }
534
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700535 template L1ctlUlMessage ts_L1CTL_EXT_RACH_REQ(
536 uint16_t ra11, L1ctlRachSynchSeq seq,
537 uint8_t combined, uint16_t offset
538 ) := {
539 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
540 ul_info := {
541 /* FIXME: both RSL chan_nr and link_id should be configurable */
542 chan_nr := t_RslChanNr_RACH(0),
543 link_id := ts_RslLinkID_DCCH(0),
544 padding := '0000'O
545 },
546 ul_info_tbf := omit,
547 ul_info_abs := omit,
548 payload := {
549 ext_rach_req := {
550 ra11 := ra11,
551 synch_seq := seq,
552 combined := combined,
553 offset := offset
554 }
555 }
556 }
557
Harald Weltef8df4cb2018-03-10 15:15:08 +0100558 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
559 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100560 ul_info := {
561 chan_nr := t_RslChanNr_RACH(0),
562 link_id := ts_RslLinkID_DCCH(0),
563 padding := '0000'O
564 },
565 ul_info_tbf := omit,
566 ul_info_abs := omit,
567 payload := {
568 par_req := {
569 ta := ta,
570 tx_power := tx_power,
571 padding := '0000'O
572 }
573 }
574 }
575
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700576 /* Base template to be inherited by ts_L1CTL_DM_EST_REQ_H0 and ts_L1CTL_DM_EST_REQ_H1 */
577 private template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
578 template (value) GsmTsc tsc) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100579 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200580 ul_info := {
581 chan_nr := chan_nr,
582 link_id := ts_RslLinkID_DCCH(0),
583 padding := '0000'O
584 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200585 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100586 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200587 payload := {
588 dm_est_req := {
589 tsc := tsc,
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700590 tch_mode := L1CTL_CHAN_MODE_SIGN,
Harald Welte9e4725d2017-07-16 23:18:09 +0200591 audio_mode := t_L1CTL_AudioModeNone
592 }
593 }
594 }
595
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700596 template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
597 template (value) GsmTsc tsc,
598 template (value) GsmArfcn arfcn)
599 modifies ts_L1CTL_DM_EST_REQ := {
600 payload := {
601 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700602 h0h1 := {
603 h0 := {
604 h := 0,
605 arfcn := { false, arfcn },
606 padding := f_pad_oct(''O, 130, '00'O)
607 }
608 }
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700609 }
610 }
611 }
612
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700613 template (value) L1ctlUlMessage ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr,
614 template (value) GsmTsc tsc,
615 template (value) uint6_t hsn,
616 template (value) uint6_t maio,
617 template (value) L1ctlMA ma)
618 modifies ts_L1CTL_DM_EST_REQ := {
619 payload := {
620 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700621 h0h1 := {
622 h1 := {
623 h := 1,
624 hsn := hsn,
625 maio := maio,
626 n := sizeof(ma),
627 spare := '00'O,
628 ma := ma,
629 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 */
630 padding := f_pad_oct(''O, (64 - sizeof(ma)) * 2, '00'O)
631 }
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700632 }
633 }
634 }
635 }
636
Harald Weltef8df4cb2018-03-10 15:15:08 +0100637 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
638 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200639 ul_info := {
640 chan_nr := chan_nr,
641 link_id := ts_RslLinkID_DCCH(0),
642 padding := '0000'O
643 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200644 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100645 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200646 payload := {
647 other := ''O
648 }
649 }
650
Harald Weltef8df4cb2018-03-10 15:15:08 +0100651 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
652 template (value) RslLinkId link_id,
653 octetstring l2_data) := {
654 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200655 ul_info := {
656 chan_nr := chan_nr,
657 link_id := link_id,
658 padding := '0000'O
659 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200660 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100661 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200662 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700663 data_req := {
664 l1header := omit,
665 l2_payload := l2_data
666 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200667 }
668 }
669
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200670 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
671 template (value) RslLinkId link_id,
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700672 template (value) SacchL1Header l1h,
673 octetstring l2_data) := {
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200674 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
675 ul_info := {
676 chan_nr := chan_nr,
677 link_id := link_id,
678 padding := '0000'O
679 },
680 ul_info_tbf := omit,
681 ul_info_abs := omit,
682 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700683 data_req := {
684 l1header := l1h,
685 l2_payload := l2_data
686 }
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200687 }
688 }
689
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700690 template (value) L1ctlUlMessage ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
691 template (value) RslLinkId link_id,
692 octetstring frame) := {
693 header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
694 ul_info := {
695 chan_nr := chan_nr,
696 link_id := link_id,
697 padding := '0000'O
698 },
699 ul_info_tbf := omit,
700 ul_info_abs := omit,
701 payload := {
702 traffic_req := {
703 data := frame
704 }
705 }
706 };
707
Harald Weltef8df4cb2018-03-10 15:15:08 +0100708 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
709 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200710 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200711 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100712 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200713 payload := {
714 tbf_cfg_req := {
715 tbf_nr := 0,
716 is_uplink := is_uplink,
717 padding := '0000'O,
718 tfi_usf := tfi_usf
719 }
720 }
721 };
722
Harald Weltef8df4cb2018-03-10 15:15:08 +0100723 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
724 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200725 dl_info := omit,
726 payload := {
727 tbf_cfg_conf := {
728 tbf_nr := 0,
729 is_uplink := is_uplink,
730 padding := ?,
731 tfi_usf := ?
732 }
733 }
734 };
735
Harald Weltef8df4cb2018-03-10 15:15:08 +0100736 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
737 L1ctlGprsCs cs := L1CTL_CS1,
738 uint8_t tbf_nr := 0) := {
739 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200740 ul_info := omit,
741 ul_info_tbf := {
742 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200743 cs := cs,
744 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200745 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100746 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200747 payload := {
748 other := l2_data
749 }
750 }
751
Harald Weltef8df4cb2018-03-10 15:15:08 +0100752 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100753 uint8_t ts, GsmFrameNumber fn,
754 L1ctlGprsCs cs := L1CTL_CS1,
755 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100756 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100757 ul_info := omit,
758 ul_info_tbf := omit,
759 ul_info_abs := {
760 tbf_nr := tbf_nr,
761 cs := cs,
762 ts_nr := ts,
763 padding := '00'O,
764 fn := fn,
765 arfcn := arfcn,
766 padding2 := '0000'O
767 },
768 payload := {
769 other := l2_data
770 }
771 }
772
773
Harald Welte9e4725d2017-07-16 23:18:09 +0200774 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100775 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
776 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200777 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200778 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200779 };
780
Harald Weltece6dc442018-02-21 22:00:21 +0100781 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100782 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100783 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100784 template octetstring l2_data := ?,
785 template uint8_t num_biterr := 0,
786 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100787 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200788 dl_info := {
789 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100790 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200791 arfcn := ?,
792 frame_nr := ?,
793 rx_level := ?,
794 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100795 num_biterr := num_biterr,
796 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200797 },
798 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100799 data_ind := {
800 payload := l2_data
801 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200802 }
803 };
804
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700805 /* for matching against incoming TRAFFIC_IND */
806 template L1ctlDlMessage tr_L1CTL_TRAFFIC_IND(template RslChannelNr chan_nr,
807 template RslLinkId link_id := ?,
808 template octetstring frame := ?,
Vadim Yanitskiy32403122020-10-19 15:43:16 +0700809 template uint8_t num_biterr := ?,
810 template uint8_t fire_crc := ?) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700811 header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
812 dl_info := {
813 chan_nr := chan_nr,
814 link_id := link_id,
815 arfcn := ?,
816 frame_nr := ?,
817 rx_level := ?,
818 snr := ?,
819 num_biterr := num_biterr,
820 fire_crc := fire_crc
821 },
822 payload := {
823 traffic_ind := {
824 data := frame
825 }
826 }
827 };
828
Harald Weltee613f962018-04-18 22:38:16 +0200829 template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
830 octetstring key) := {
831 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
832 ul_info := {
833 chan_nr := chan_nr,
834 link_id := ts_RslLinkID_DCCH(0),
835 padding := '0000'O
836 },
837 ul_info_tbf := omit,
838 ul_info_abs := omit,
839 payload := {
840 crypto_req := {
841 algo := algo,
842 key_len := 0, /* overwritten */
843 key := key
844 }
845 }
846 };
847
Harald Welte68e495b2018-02-25 00:05:57 +0100848 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
849
Harald Welte7024baa2018-03-02 23:37:51 +0100850/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
851 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200852} with { encode "RAW" };