blob: 9162eeaf08cea7d00681a5879b8e0279e6bcf378 [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
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700108 template L1ctlHeader
109 tr_L1ctlHeader(template (present) L1ctlMsgType msg_type) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100110 msg_type := msg_type,
111 flags := ?,
112 padding := ?
113 };
114
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700115 template (value) L1ctlHeader
116 ts_L1ctlHeader(template (value) L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +0200117 msg_type := msg_type,
118 flags := { padding := '0000000'B, f_done := false },
119 padding := '0000'O
120 };
121
Harald Weltef6543322017-07-16 07:35:10 +0200122 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200123 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200124 RslLinkId link_id,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700125 GsmBandArfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200126 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200127 GsmRxLev rx_level,
128 uint8_t snr,
129 uint8_t num_biterr,
130 uint8_t fire_crc
131 } with { variant "" };
132
133 type record L1ctlFbsbConf {
134 int16_t initial_freq_err,
135 uint8_t result,
136 uint8_t bsic
137 } with { variant "" };
138
139 type record L1ctlCcchModeConf {
140 L1ctlCcchMode ccch_mode,
141 OCT3 padding
142 } with { variant "" };
143
144 /* gsm48_chan_mode */
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700145 type enumerated L1ctlTchMode {
146 L1CTL_CHAN_MODE_SIGN ('00000000'B), /* Signalling */
147 L1CTL_CHAN_MODE_SPEECH_V1 ('00000001'B), /* FR or HR codec */
148 L1CTL_CHAN_MODE_SPEECH_V2 ('00100001'B), /* EFR codec */
149 L1CTL_CHAN_MODE_SPEECH_V3 ('01000001'B) /* AMR codec */
150 /* Other modes are not supported for now */
151 } with { variant "FIELDLENGTH(8)" };
Harald Weltef6543322017-07-16 07:35:10 +0200152
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700153 type enumerated L1ctlLoopMode {
154 L1CTL_LOOP_MODE_OPEN ('00000000'B),
155 L1CTL_LOOP_MODE_A ('00000001'B),
156 L1CTL_LOOP_MODE_B ('00000010'B),
157 L1CTL_LOOP_MODE_C ('00000011'B),
158 L1CTL_LOOP_MODE_D ('00000100'B),
159 L1CTL_LOOP_MODE_E ('00000101'B),
160 L1CTL_LOOP_MODE_F ('00000110'B),
161 L1CTL_LOOP_MODE_I ('00000111'B)
162 } with { variant "FIELDLENGTH(8)" };
163
Harald Weltef6543322017-07-16 07:35:10 +0200164 type record L1ctlAudioMode {
165 BIT4 padding,
166 boolean tx_microphone,
167 boolean tx_traffic_req,
168 boolean rx_speaker,
169 boolean rx_traffic_ind
170 } with { variant "" };
171
Harald Weltef8df4cb2018-03-10 15:15:08 +0100172 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200173
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700174 /* Traffic forwarding mode (see TRAFFIC.{req,cnf,ind} messages) */
175 template (value) L1ctlAudioMode t_L1CTL_AudioModeFwd
176 modifies t_L1CTL_AudioModeNone := {
177 tx_traffic_req := true,
178 rx_traffic_ind := true
179 };
180
Harald Weltef6543322017-07-16 07:35:10 +0200181 type record L1ctlTchModeConf {
182 L1ctlTchMode tch_mode,
183 L1ctlAudioMode audio_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200184 record {
185 uint8_t start_codec,
186 BIT8 codecs_bitmask
187 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200188 } with { variant "" };
189
190 type record L1ctlDataInd {
Vadim Yanitskiy2a92e2a2019-05-28 21:13:35 +0700191 octetstring payload
Harald Welte7024baa2018-03-02 23:37:51 +0100192 } with {
193 variant (payload) "BYTEORDER(first)"
194 };
Harald Weltef6543322017-07-16 07:35:10 +0200195
Harald Weltef6543322017-07-16 07:35:10 +0200196
197 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200198 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200199 RslLinkId link_id,
200 OCT2 padding
201 } with { variant "" };
202
Harald Welteb3c226e2017-07-30 17:18:01 +0200203 type record L1ctlUlTbfInfo {
204 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200205 L1ctlGprsCs cs,
206 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200207 } with { variant "" };
208
Harald Welte3a40ec72018-03-02 20:45:04 +0100209 type record L1ctlUlAbsInfo {
210 uint8_t tbf_nr,
211 L1ctlGprsCs cs,
212 uint8_t ts_nr,
213 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100214 uint32_le fn,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700215 GsmBandArfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100216 OCT2 padding2
217 } with { variant "" };
218
Harald Weltef6543322017-07-16 07:35:10 +0200219 type record L1ctlFbsbFlags {
220 BIT5 padding,
221 boolean sb,
222 boolean fb1,
223 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100224 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200225
Harald Weltef8df4cb2018-03-10 15:15:08 +0100226 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200227 padding := '00000'B,
228 sb := true,
229 fb1 := true,
230 fb0 := true
231 };
232
Harald Weltef6543322017-07-16 07:35:10 +0200233 type record L1ctlFbsbReq {
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700234 GsmBandArfcn arfcn,
Harald Weltef6543322017-07-16 07:35:10 +0200235 uint16_t timeout_tdma_frames,
236 uint16_t freq_err_thresh1,
237 uint16_t freq_err_thresh2,
238 uint8_t num_freqerr_avg,
239 L1ctlFbsbFlags flags,
240 uint8_t sync_info_idx,
241 L1ctlCcchMode ccch_mode,
242 GsmRxLev rxlev_exp
243 } with { variant "" };
244
245 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100246 L1ctlCcchMode ccch_mode,
247 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200248 } with { variant "" };
249
250 type record L1ctlTchModeReq {
251 L1ctlTchMode tch_mode,
252 L1ctlAudioMode audio_mode,
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700253 L1ctlLoopMode loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200254 record {
255 uint8_t start_codec,
256 BIT8 codecs_bitmask
257 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200258 } with { variant "" };
259
260 type record L1ctlRachReq {
261 uint8_t ra,
262 uint8_t combined,
263 uint16_t offset
264 } with { variant "" };
265
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700266 type enumerated L1ctlRachSynchSeq {
267 RACH_SYNCH_SEQ_TS0 (0),
268 RACH_SYNCH_SEQ_TS1,
269 RACH_SYNCH_SEQ_TS2
270 } with { variant "FIELDLENGTH(8)" };
271
272 type record L1ctlExtRachReq {
273 uint16_t ra11,
274 L1ctlRachSynchSeq synch_seq,
275 uint8_t combined,
276 uint16_t offset
277 } with { variant "" };
278
Harald Weltef6543322017-07-16 07:35:10 +0200279 type record L1ctlParReq {
280 int8_t ta,
281 uint8_t tx_power,
282 OCT2 padding
283 } with { variant "" };
284
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200285 type record L1ctlDataReq {
286 SacchL1Header l1header optional,
287 octetstring l2_payload
288 } with { variant "" };
289
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700290 type record L1ctlH0 {
291 uint8_t h,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700292 GsmBandArfcn arfcn,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700293 octetstring padding length(130)
294 } with { variant "" };
295
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700296 type record length(0..64) of GsmBandArfcn L1ctlMA;
Harald Weltef6543322017-07-16 07:35:10 +0200297 type record L1ctlH1 {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700298 uint8_t h,
Harald Weltef6543322017-07-16 07:35:10 +0200299 uint8_t hsn,
300 uint8_t maio,
301 uint8_t n,
Vadim Yanitskiye8ea3ee2020-05-27 13:29:48 +0700302 OCT1 spare,
303 L1ctlMA ma,
304 octetstring padding
305 } with {
306 variant (n) "LENGTHTO(ma)"
307 variant (n) "UNIT(elements)"
308 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849.
309 * TL;DR The reference point of the PADDING attribute is the beginning
310 * of the message, not the beginning of the type/field it's applied on.
311 * Therefore we cannot use it here, and have to add padding manually.
312 * variant (ma) "PADDING(128)" */
313 };
Harald Weltef6543322017-07-16 07:35:10 +0200314
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700315 type union L1ctlH0H1 {
316 L1ctlH0 h0,
317 L1ctlH1 h1
318 } with { variant "TAG(h0, h = 0; h1, h = 1)" };
319
Harald Weltef6543322017-07-16 07:35:10 +0200320 type record L1ctlDmEstReq {
321 GsmTsc tsc,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700322 L1ctlH0H1 h0h1,
Harald Weltef6543322017-07-16 07:35:10 +0200323 L1ctlTchMode tch_mode,
324 L1ctlAudioMode audio_mode
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700325 } with { variant "" };
Harald Weltef6543322017-07-16 07:35:10 +0200326
327 type record L1ctlReset {
328 L1ctlResetType reset_type,
329 OCT3 padding
330 } with { variant "" };
331
Harald Weltee613f962018-04-18 22:38:16 +0200332 type record L1CtlCryptoReq {
333 uint8_t algo,
334 uint8_t key_len,
335 octetstring key
336 } with { variant (key_len) "LENGTHTO(key)" };
337
Harald Weltef6543322017-07-16 07:35:10 +0200338
339 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700340 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100341 } with {
342 variant (data) "BYTEORDER(first)"
343 }
Harald Weltef6543322017-07-16 07:35:10 +0200344
Harald Welte00d4dac2017-07-30 00:50:32 +0200345 type record length(8) of uint8_t TfiUsfArr;
346
347 type record L1ctlTbfCfgReq {
348 uint8_t tbf_nr,
349 boolean is_uplink,
350 OCT2 padding,
351 TfiUsfArr tfi_usf
352 } with { variant (is_uplink) "FIELDLENGTH(8)" };
353
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700354 type union L1ctlMsgPayload {
Harald Weltef6543322017-07-16 07:35:10 +0200355 L1ctlFbsbReq fbsb_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700356 L1ctlFbsbConf fbsb_conf,
357 L1ctlDataInd data_ind,
Harald Weltef6543322017-07-16 07:35:10 +0200358 L1ctlRachReq rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200359 L1ctlDmEstReq dm_est_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200360 L1ctlDataReq data_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700361 /* TODO: L1CTL_RESET_IND */
362 /* TODO: L1CTL_PM_REQ */
363 /* TODO: L1CTL_PM_CONF */
364 L1ctlReset reset_req,
365 L1ctlCcchModeReq ccch_mode_req,
366 L1ctlCcchModeConf ccch_mode_conf,
367 L1ctlParReq par_req,
368 /* TODO: L1CTL_DM_FREQ_REQ */
369 L1CtlCryptoReq crypto_req,
370 /* TODO: L1CTL_SIM_REQ */
371 /* TODO: L1CTL_SIM_CONF */
372 L1ctlTchModeReq tch_mode_req,
373 L1ctlTchModeConf tch_mode_conf,
374 /* TODO: L1CTL_NEIGH_PM_REQ */
375 /* TODO: L1CTL_NEIGH_PM_IND */
376 L1ctlTrafficReq traffic_req,
377 L1ctlTrafficReq traffic_ind,
378 /* TODO: L1CTL_BURST_IND */
379 L1ctlTbfCfgReq tbf_cfg_req,
380 L1ctlTbfCfgReq tbf_cfg_conf,
381 L1ctlExtRachReq ext_rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200382 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100383 } with {
384 variant (other) "BYTEORDER(first)"
385 };
Harald Weltef6543322017-07-16 07:35:10 +0200386
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700387 type record L1ctlMessage {
Harald Weltef6543322017-07-16 07:35:10 +0200388 L1ctlHeader header,
389 L1ctlUlInfo ul_info optional,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700390 L1ctlDlInfo dl_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200391 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100392 L1ctlUlAbsInfo ul_info_abs optional,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700393 L1ctlMsgPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200394 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700395 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200396 header.msg_type = L1CTL_PARAM_REQ,
397 header.msg_type = L1CTL_CRYPTO_REQ,
398 header.msg_type = L1CTL_DATA_REQ,
399 header.msg_type = L1CTL_DM_EST_REQ,
400 header.msg_type = L1CTL_DM_FREQ_REQ,
401 header.msg_type = L1CTL_DM_REL_REQ,
402 header.msg_type = L1CTL_TRAFFIC_REQ)"
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700403 variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
404 header.msg_type = L1CTL_RACH_CONF,
405 header.msg_type = L1CTL_DATA_IND,
406 header.msg_type = L1CTL_DATA_CONF,
407 header.msg_type = L1CTL_TRAFFIC_IND,
408 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200409 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100410 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200411 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700412 fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
413 data_ind, header.msg_type = L1CTL_DATA_IND;
Harald Weltef6543322017-07-16 07:35:10 +0200414 rach_req, header.msg_type = L1CTL_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200415 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200416 data_req, header.msg_type = L1CTL_DATA_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700417 /* TODO: reset_ind, header.msg_type = L1CTL_RESET_IND */
418 /* TODO: pm_req, header.msg_type = L1CTL_PM_REQ */
419 /* TODO: pm_conf, header.msg_type = L1CTL_PM_CONF */
420 reset_req, header.msg_type = L1CTL_RESET_REQ;
421 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
422 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
423 par_req, header.msg_type = L1CTL_PARAM_REQ;
424 /* TODO: freq_req, header.msg_type = L1CTL_DM_FREQ_REQ */
425 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
426 /* TODO: sim_req, header.msg_type = L1CTL_SIM_REQ */
427 /* TODO: sim_conf, header.msg_type = L1CTL_SIM_CONF */
428 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
429 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
430 /* TODO: neigh_pm_req, header.msg_type = L1CTL_NEIGH_PM_REQ */
431 /* TODO: neigh_pm_ind, header.msg_type = L1CTL_NEIGH_PM_IND */
432 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
433 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
434 /* TODO: burst_ind, header.msg_type = L1CTL_BURST_IND */
435 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
436 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
437 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200438 other, OTHERWISE;
439 )" };
440
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700441 external function enc_L1ctlMessage(in L1ctlMessage msg) return octetstring
Harald Weltef6543322017-07-16 07:35:10 +0200442 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700443 external function dec_L1ctlMessage(in octetstring stream) return L1ctlMessage
Harald Weltef6543322017-07-16 07:35:10 +0200444 with { extension "prototype(convert) decode(RAW)" };
445
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700446 type record L1ctlMessageLV {
Harald Welte52c713c2017-07-16 15:44:44 +0200447 uint16_t len,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700448 L1ctlMessage msg
Harald Welte52c713c2017-07-16 15:44:44 +0200449 } with { variant (len) "LENGTHTO(msg)" };
450
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700451 external function enc_L1ctlMessageLV(in L1ctlMessageLV msg) return octetstring
Harald Welte52c713c2017-07-16 15:44:44 +0200452 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700453 external function dec_L1ctlMessageLV(in octetstring stream) return L1ctlMessageLV
Harald Welte52c713c2017-07-16 15:44:44 +0200454 with { extension "prototype(convert) decode(RAW)" };
455
456
Harald Welte9e4725d2017-07-16 23:18:09 +0200457
458
459 /* for generating RESET_REQ */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700460 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700461 t_L1ctlResetReq(template (value) L1ctlResetType rst_type) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100462 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200463 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700464 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200465 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100466 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200467 payload := {
468 reset_req := {
469 reset_type := rst_type,
470 padding := '000000'O
471 }
472 }
473 };
474
475 /* for generating FBSB_REQ */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700476 template (value) L1ctlMessage
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700477 ts_L1CTL_FBSB_REQ(template (value) GsmBandArfcn arfcn,
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700478 template (value) L1ctlFbsbFlags flags,
479 template (value) uint8_t sync_info_idx,
480 template (value) L1ctlCcchMode ccch_mode,
481 template (value) GsmRxLev rxlev_exp) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100482 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200483 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700484 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200485 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100486 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200487 payload := {
488 fbsb_req := {
489 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100490 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200491 freq_err_thresh1 := 10000,
492 freq_err_thresh2 := 800,
493 num_freqerr_avg := 3,
494 flags := flags,
495 sync_info_idx := sync_info_idx,
496 ccch_mode := ccch_mode,
497 rxlev_exp := rxlev_exp
498 }
499 }
500 };
501
502 /* for matching against incoming FBSB_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700503 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700504 tr_L1CTL_FBSB_CONF(template (present) uint8_t result) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100505 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700506 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200507 dl_info := ?,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700508 ul_info_tbf := omit,
509 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200510 payload := {
511 fbsb_conf := {
512 initial_freq_err := ?,
513 result := result,
514 bsic := ?
515 }
516 }
517 };
518
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700519 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700520 ts_L1CTL_CCCH_MODE_REQ(template (value) L1ctlCcchMode ccch_mode) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100521 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
522 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700523 dl_info := omit,
Harald Weltef8df4cb2018-03-10 15:15:08 +0100524 ul_info_tbf := omit,
525 ul_info_abs := omit,
526 payload := {
527 ccch_mode_req := {
528 ccch_mode := ccch_mode,
529 padding := '000000'O
530 }
531 }
532 };
533
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700534 template (value) L1ctlMessage
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700535 ts_L1CTL_TCH_MODE_REQ(template (value) L1ctlTchMode tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700536 template (value) L1ctlAudioMode audio_mode := t_L1CTL_AudioModeFwd,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200537 template (value) L1ctlLoopMode loop_mode := L1CTL_LOOP_MODE_OPEN,
538 template (value) uint8_t amr_start_codec := 0,
539 template (value) BIT8 amr_codecs_bitmask := '00000000'B) := {
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700540 header := ts_L1ctlHeader(L1CTL_TCH_MODE_REQ),
541 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700542 dl_info := omit,
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700543 ul_info_tbf := omit,
544 ul_info_abs := omit,
545 payload := {
546 tch_mode_req := {
547 tch_mode := tch_mode,
548 audio_mode := audio_mode,
549 loop_mode := loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200550 amr := {
551 start_codec := amr_start_codec,
552 codecs_bitmask := amr_codecs_bitmask
553 }
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700554 }
555 }
556 };
557
Harald Welte3757e602018-03-10 17:12:02 +0100558
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700559 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700560 tr_L1CTL_MsgType(template (present) L1ctlMsgType msg_type) := {
Harald Welte3757e602018-03-10 17:12:02 +0100561 header := tr_L1ctlHeader(msg_type),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700562 ul_info := *,
Harald Welte3757e602018-03-10 17:12:02 +0100563 dl_info := *,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700564 ul_info_tbf := *,
565 ul_info_abs := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200566 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100567 }
568
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700569 template L1ctlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100570
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700571 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700572 ts_L1CTL_RACH_REQ(template (value) uint8_t ra,
573 template (value) uint8_t combined,
574 template (value) uint16_t offset,
575 template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
576 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100577 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200578 ul_info := {
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700579 chan_nr := chan_nr,
580 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200581 padding := '0000'O
582 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700583 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200584 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100585 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200586 payload := {
587 rach_req := {
588 ra := ra,
589 combined := combined,
590 offset := offset
591 }
592 }
593 }
594
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700595 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700596 ts_L1CTL_EXT_RACH_REQ(template (value) uint16_t ra11,
597 template (value) L1ctlRachSynchSeq seq,
598 template (value) uint8_t combined,
599 template (value) uint16_t offset) := {
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700600 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
601 ul_info := {
602 /* FIXME: both RSL chan_nr and link_id should be configurable */
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300603 chan_nr := ts_RslChanNr_RACH(0),
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700604 link_id := ts_RslLinkID_DCCH(0),
605 padding := '0000'O
606 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700607 dl_info := omit,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700608 ul_info_tbf := omit,
609 ul_info_abs := omit,
610 payload := {
611 ext_rach_req := {
612 ra11 := ra11,
613 synch_seq := seq,
614 combined := combined,
615 offset := offset
616 }
617 }
618 }
619
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700620 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700621 ts_L1CTL_PAR_REQ(template (value) uint8_t ta,
622 template (value) uint8_t tx_power) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100623 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100624 ul_info := {
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300625 chan_nr := ts_RslChanNr_RACH(0),
Harald Welte37052732018-03-09 19:38:46 +0100626 link_id := ts_RslLinkID_DCCH(0),
627 padding := '0000'O
628 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700629 dl_info := omit,
Harald Welte37052732018-03-09 19:38:46 +0100630 ul_info_tbf := omit,
631 ul_info_abs := omit,
632 payload := {
633 par_req := {
634 ta := ta,
635 tx_power := tx_power,
636 padding := '0000'O
637 }
638 }
639 }
640
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700641 /* Base template to be inherited by ts_L1CTL_DM_EST_REQ_H0 and ts_L1CTL_DM_EST_REQ_H1 */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700642 private template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700643 ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
644 template (value) GsmTsc tsc) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100645 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200646 ul_info := {
647 chan_nr := chan_nr,
648 link_id := ts_RslLinkID_DCCH(0),
649 padding := '0000'O
650 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700651 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200652 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100653 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200654 payload := {
655 dm_est_req := {
656 tsc := tsc,
Vadim Yanitskiy0a3e31c2022-12-18 08:09:38 +0700657 h0h1 := -,
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700658 tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700659 audio_mode := t_L1CTL_AudioModeFwd
Harald Welte9e4725d2017-07-16 23:18:09 +0200660 }
661 }
662 }
663
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700664 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700665 ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
666 template (value) GsmTsc tsc,
667 template (value) GsmArfcn arfcn)
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700668 modifies ts_L1CTL_DM_EST_REQ := {
669 payload := {
670 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700671 h0h1 := {
672 h0 := {
673 h := 0,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700674 arfcn := ts_GsmBandArfcn(arfcn),
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700675 padding := f_pad_oct(''O, 130, '00'O)
676 }
677 }
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700678 }
679 }
680 }
681
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700682 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700683 ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr,
684 template (value) GsmTsc tsc,
685 template (value) uint6_t hsn,
686 template (value) uint6_t maio,
687 template (value) L1ctlMA ma)
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700688 modifies ts_L1CTL_DM_EST_REQ := {
689 payload := {
690 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700691 h0h1 := {
692 h1 := {
693 h := 1,
694 hsn := hsn,
695 maio := maio,
696 n := sizeof(ma),
697 spare := '00'O,
698 ma := ma,
699 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 */
700 padding := f_pad_oct(''O, (64 - sizeof(ma)) * 2, '00'O)
701 }
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700702 }
703 }
704 }
705 }
706
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700707 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700708 ts_L1CTL_DM_REL_REQ(template (value) RslChannelNr chan_nr) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100709 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200710 ul_info := {
711 chan_nr := chan_nr,
712 link_id := ts_RslLinkID_DCCH(0),
713 padding := '0000'O
714 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700715 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200716 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100717 ul_info_abs := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700718 payload := omit
Harald Welte9e4725d2017-07-16 23:18:09 +0200719 }
720
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700721 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700722 ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
723 template (value) RslLinkId link_id,
724 octetstring l2_data) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100725 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200726 ul_info := {
727 chan_nr := chan_nr,
728 link_id := link_id,
729 padding := '0000'O
730 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700731 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200732 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100733 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200734 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700735 data_req := {
736 l1header := omit,
737 l2_payload := l2_data
738 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200739 }
740 }
741
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700742 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700743 ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
744 template (value) RslLinkId link_id,
745 template (value) SacchL1Header l1h,
746 octetstring l2_data) := {
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200747 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
748 ul_info := {
749 chan_nr := chan_nr,
750 link_id := link_id,
751 padding := '0000'O
752 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700753 dl_info := omit,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200754 ul_info_tbf := omit,
755 ul_info_abs := omit,
756 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700757 data_req := {
758 l1header := l1h,
759 l2_payload := l2_data
760 }
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200761 }
762 }
763
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700764 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700765 ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
766 template (value) RslLinkId link_id,
767 octetstring frame) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700768 header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
769 ul_info := {
770 chan_nr := chan_nr,
771 link_id := link_id,
772 padding := '0000'O
773 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700774 dl_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700775 ul_info_tbf := omit,
776 ul_info_abs := omit,
777 payload := {
778 traffic_req := {
779 data := frame
780 }
781 }
782 };
783
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700784 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700785 ts_L1CTL_TBF_CFG_REQ(template (value) boolean is_uplink,
786 template (value) TfiUsfArr tfi_usf) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100787 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200788 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700789 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200790 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100791 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200792 payload := {
793 tbf_cfg_req := {
794 tbf_nr := 0,
795 is_uplink := is_uplink,
796 padding := '0000'O,
797 tfi_usf := tfi_usf
798 }
799 }
800 };
801
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700802 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700803 tr_L1CTL_TBF_CFG_CONF(template (present) boolean is_uplink) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100804 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700805 ul_info := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200806 dl_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700807 ul_info_tbf := omit,
808 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200809 payload := {
810 tbf_cfg_conf := {
811 tbf_nr := 0,
812 is_uplink := is_uplink,
813 padding := ?,
814 tfi_usf := ?
815 }
816 }
817 };
818
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700819 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700820 ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
821 template (value) L1ctlGprsCs cs := L1CTL_CS1,
822 template (value) uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100823 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200824 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700825 dl_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200826 ul_info_tbf := {
827 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200828 cs := cs,
829 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200830 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100831 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200832 payload := {
833 other := l2_data
834 }
835 }
836
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700837 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700838 ts_L1CTL_DATA_ABS_REQ(octetstring l2_data,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700839 template (value) GsmBandArfcn arfcn,
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700840 template (value) uint8_t ts,
841 template (value) GsmFrameNumber fn,
842 template (value) L1ctlGprsCs cs := L1CTL_CS1,
843 template (value) uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100844 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100845 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700846 dl_info := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100847 ul_info_tbf := omit,
848 ul_info_abs := {
849 tbf_nr := tbf_nr,
850 cs := cs,
851 ts_nr := ts,
852 padding := '00'O,
853 fn := fn,
854 arfcn := arfcn,
855 padding2 := '0000'O
856 },
857 payload := {
858 other := l2_data
859 }
860 }
861
862
Harald Welte9e4725d2017-07-16 23:18:09 +0200863 /* for matching against incoming RACH_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700864 template L1ctlMessage tr_L1CTL_RACH_CONF := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100865 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700866 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200867 dl_info := ?,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700868 ul_info_tbf := omit,
869 ul_info_abs := omit,
Harald Weltef56cc492018-04-15 10:58:43 +0200870 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200871 };
872
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700873 /* for sending and matching L1CTL_DATA_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700874 template (value) L1ctlMessage
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700875 ts_L1CTL_DATA_IND(template (value) RslChannelNr chan_nr,
876 template (value) RslLinkId link_id,
877 template (value) octetstring l2_data,
878 template (value) GsmBandArfcn arfcn,
879 template (value) uint32_t fn := 1337,
880 template (value) GsmRxLev rx_level := 63,
881 template (value) uint8_t num_biterr := 0,
882 template (value) uint8_t fire_crc := 0) := {
883 header := ts_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700884 ul_info := omit,
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700885 dl_info := {
886 chan_nr := chan_nr,
887 link_id := link_id,
888 arfcn := arfcn,
889 frame_nr := fn,
890 rx_level := rx_level,
891 snr := 0,
892 num_biterr := num_biterr,
893 fire_crc := fire_crc
894 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700895 ul_info_tbf := omit,
896 ul_info_abs := omit,
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700897 payload := {
898 data_ind := {
899 payload := l2_data
900 }
901 }
902 };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700903 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700904 tr_L1CTL_DATA_IND(template (present) RslChannelNr chan_nr,
905 template (present) RslLinkId link_id := ?,
906 template (present) octetstring l2_data := ?,
907 template (present) uint8_t num_biterr := 0,
908 template (present) uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100909 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700910 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200911 dl_info := {
912 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100913 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200914 arfcn := ?,
915 frame_nr := ?,
916 rx_level := ?,
917 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100918 num_biterr := num_biterr,
Pau Espin Pedrol17da3232022-09-02 16:35:32 +0200919 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200920 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700921 ul_info_tbf := omit,
922 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200923 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100924 data_ind := {
925 payload := l2_data
926 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200927 }
928 };
929
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700930 /* for matching against incoming TRAFFIC_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700931 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700932 tr_L1CTL_TRAFFIC_IND(template (present) RslChannelNr chan_nr,
933 template (present) RslLinkId link_id := ?,
934 template (present) octetstring frame := ?,
935 template (present) uint8_t num_biterr := ?,
936 template (present) uint8_t fire_crc := ?) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700937 header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700938 ul_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700939 dl_info := {
940 chan_nr := chan_nr,
941 link_id := link_id,
942 arfcn := ?,
943 frame_nr := ?,
944 rx_level := ?,
945 snr := ?,
946 num_biterr := num_biterr,
947 fire_crc := fire_crc
948 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700949 ul_info_tbf := omit,
950 ul_info_abs := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700951 payload := {
952 traffic_ind := {
953 data := frame
954 }
955 }
956 };
957
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700958 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700959 ts_L1CTL_CRYPTO_REQ(template (value) RslChannelNr chan_nr,
960 template (value) uint8_t algo,
961 template (value) octetstring key) := {
Harald Weltee613f962018-04-18 22:38:16 +0200962 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
963 ul_info := {
964 chan_nr := chan_nr,
965 link_id := ts_RslLinkID_DCCH(0),
966 padding := '0000'O
967 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700968 dl_info := omit,
Harald Weltee613f962018-04-18 22:38:16 +0200969 ul_info_tbf := omit,
970 ul_info_abs := omit,
971 payload := {
972 crypto_req := {
973 algo := algo,
974 key_len := 0, /* overwritten */
975 key := key
976 }
977 }
978 };
979
Harald Welte68e495b2018-02-25 00:05:57 +0100980 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
981
Harald Welte7024baa2018-03-02 23:37:51 +0100982/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
983 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200984} with { encode "RAW" };