blob: 73e09fc80a9833a5c70c7af554e9e093f235716c [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
19 type enumerated L1ctlMsgType {
20 L1CTL_NONE,
21 L1CTL_FBSB_REQ,
22 L1CTL_FBSB_CONF,
23 L1CTL_DATA_IND,
24 L1CTL_RACH_REQ,
25 L1CTL_DM_EST_REQ,
26 L1CTL_DATA_REQ,
27 L1CTL_RESET_IND,
28 L1CTL_PM_REQ, /* power measurement */
29 L1CTL_PM_CONF, /* power measurement */
30 L1CTL_ECHO_REQ,
31 L1CTL_ECHO_CONF,
32 L1CTL_RACH_CONF,
33 L1CTL_RESET_REQ,
34 L1CTL_RESET_CONF,
35 L1CTL_DATA_CONF,
36 L1CTL_CCCH_MODE_REQ,
37 L1CTL_CCCH_MODE_CONF,
38 L1CTL_DM_REL_REQ,
39 L1CTL_PARAM_REQ,
40 L1CTL_DM_FREQ_REQ,
41 L1CTL_CRYPTO_REQ,
42 L1CTL_SIM_REQ,
43 L1CTL_SIM_CONF,
44 L1CTL_TCH_MODE_REQ,
45 L1CTL_TCH_MODE_CONF,
46 L1CTL_NEIGH_PM_REQ,
47 L1CTL_NEIGH_PM_IND,
48 L1CTL_TRAFFIC_REQ,
49 L1CTL_TRAFFIC_CONF,
Harald Welte00d4dac2017-07-30 00:50:32 +020050 L1CTL_TRAFFIC_IND,
Vadim Yanitskiy4e79ff52019-04-22 06:38:21 +070051 L1CTL_BURST_IND,
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +070052 L1CTL_GPRS_UL_TBF_CFG_REQ,
53 L1CTL_GPRS_DL_TBF_CFG_REQ,
54 L1CTL_GPRS_UL_BLOCK_REQ,
55 L1CTL_GPRS_DL_BLOCK_IND,
56 L1CTL_EXT_RACH_REQ
Harald Weltef6543322017-07-16 07:35:10 +020057 } with { variant "FIELDLENGTH(8)" };
58
59 type enumerated L1ctlCcchMode {
60 CCCH_MODE_NONE (0),
61 CCCH_MODE_NON_COMBINED,
Harald Welte990a3612019-05-27 14:02:13 +020062 CCCH_MODE_COMBINED,
63 CCCH_MODE_COMBINED_CBCH
Harald Weltef6543322017-07-16 07:35:10 +020064 } with { variant "FIELDLENGTH(8)" };
65
66 type enumerated L1ctlNeighMode {
67 NEIGH_MODE_NONE (0),
68 NEIGH_MODE_PM,
69 NEIGH_MODE_SB
70 } with { variant "FIELDLENGTH(8)" };
71
72 type enumerated L1ctlResetType {
73 L1CTL_RES_T_BOOT (0),
74 L1CTL_RES_T_FULL,
75 L1CTL_RES_T_SCHED
76 } with { variant "FIELDLENGTH(8)" };
77
Harald Weltef6543322017-07-16 07:35:10 +020078 type record L1ctlHdrFlags {
79 BIT7 padding,
80 boolean f_done
81 } with { variant "" };
82
83 type record L1ctlHeader {
84 L1ctlMsgType msg_type,
85 L1ctlHdrFlags flags,
86 OCT2 padding
87 } with { variant "" };
88
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +070089 template L1ctlHeader
90 tr_L1ctlHeader(template (present) L1ctlMsgType msg_type) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +010091 msg_type := msg_type,
92 flags := ?,
93 padding := ?
94 };
95
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +070096 template (value) L1ctlHeader
97 ts_L1ctlHeader(template (value) L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +020098 msg_type := msg_type,
99 flags := { padding := '0000000'B, f_done := false },
100 padding := '0000'O
101 };
102
Harald Weltef6543322017-07-16 07:35:10 +0200103 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200104 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200105 RslLinkId link_id,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700106 GsmBandArfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200107 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200108 GsmRxLev rx_level,
109 uint8_t snr,
110 uint8_t num_biterr,
111 uint8_t fire_crc
112 } with { variant "" };
113
114 type record L1ctlFbsbConf {
115 int16_t initial_freq_err,
116 uint8_t result,
117 uint8_t bsic
118 } with { variant "" };
119
120 type record L1ctlCcchModeConf {
121 L1ctlCcchMode ccch_mode,
122 OCT3 padding
123 } with { variant "" };
124
125 /* gsm48_chan_mode */
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700126 type enumerated L1ctlTchMode {
127 L1CTL_CHAN_MODE_SIGN ('00000000'B), /* Signalling */
128 L1CTL_CHAN_MODE_SPEECH_V1 ('00000001'B), /* FR or HR codec */
129 L1CTL_CHAN_MODE_SPEECH_V2 ('00100001'B), /* EFR codec */
Vadim Yanitskiy8fd78f72023-05-26 19:21:55 +0700130 L1CTL_CHAN_MODE_SPEECH_V3 ('01000001'B), /* AMR codec */
131 L1CTL_CHAN_MODE_DATA_14k5 ('00001111'B), /* CSD: TCH/F14.4 */
132 L1CTL_CHAN_MODE_DATA_12k0 ('00000011'B), /* CSD: TCH/F9.6 */
133 L1CTL_CHAN_MODE_DATA_6k0 ('00001011'B), /* CSD: TCH/{FH}4.8 */
134 L1CTL_CHAN_MODE_DATA_3k6 ('00010011'B) /* CSD: TCH/{FH}2.4 */
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700135 } with { variant "FIELDLENGTH(8)" };
Harald Weltef6543322017-07-16 07:35:10 +0200136
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700137 type enumerated L1ctlLoopMode {
138 L1CTL_LOOP_MODE_OPEN ('00000000'B),
139 L1CTL_LOOP_MODE_A ('00000001'B),
140 L1CTL_LOOP_MODE_B ('00000010'B),
141 L1CTL_LOOP_MODE_C ('00000011'B),
142 L1CTL_LOOP_MODE_D ('00000100'B),
143 L1CTL_LOOP_MODE_E ('00000101'B),
144 L1CTL_LOOP_MODE_F ('00000110'B),
145 L1CTL_LOOP_MODE_I ('00000111'B)
146 } with { variant "FIELDLENGTH(8)" };
147
Harald Weltef6543322017-07-16 07:35:10 +0200148 type record L1ctlAudioMode {
149 BIT4 padding,
150 boolean tx_microphone,
151 boolean tx_traffic_req,
152 boolean rx_speaker,
153 boolean rx_traffic_ind
154 } with { variant "" };
155
Harald Weltef8df4cb2018-03-10 15:15:08 +0100156 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200157
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700158 /* Traffic forwarding mode (see TRAFFIC.{req,cnf,ind} messages) */
159 template (value) L1ctlAudioMode t_L1CTL_AudioModeFwd
160 modifies t_L1CTL_AudioModeNone := {
161 tx_traffic_req := true,
162 rx_traffic_ind := true
163 };
164
Harald Weltef6543322017-07-16 07:35:10 +0200165 type record L1ctlTchModeConf {
166 L1ctlTchMode tch_mode,
167 L1ctlAudioMode audio_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200168 record {
169 uint8_t start_codec,
170 BIT8 codecs_bitmask
171 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200172 } with { variant "" };
173
174 type record L1ctlDataInd {
Vadim Yanitskiy2a92e2a2019-05-28 21:13:35 +0700175 octetstring payload
Harald Welte7024baa2018-03-02 23:37:51 +0100176 } with {
177 variant (payload) "BYTEORDER(first)"
178 };
Harald Weltef6543322017-07-16 07:35:10 +0200179
Harald Weltef6543322017-07-16 07:35:10 +0200180
181 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200182 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200183 RslLinkId link_id,
184 OCT2 padding
185 } with { variant "" };
186
187 type record L1ctlFbsbFlags {
188 BIT5 padding,
189 boolean sb,
190 boolean fb1,
191 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100192 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200193
Harald Weltef8df4cb2018-03-10 15:15:08 +0100194 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200195 padding := '00000'B,
196 sb := true,
197 fb1 := true,
198 fb0 := true
199 };
200
Harald Weltef6543322017-07-16 07:35:10 +0200201 type record L1ctlFbsbReq {
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700202 GsmBandArfcn arfcn,
Harald Weltef6543322017-07-16 07:35:10 +0200203 uint16_t timeout_tdma_frames,
204 uint16_t freq_err_thresh1,
205 uint16_t freq_err_thresh2,
206 uint8_t num_freqerr_avg,
207 L1ctlFbsbFlags flags,
208 uint8_t sync_info_idx,
209 L1ctlCcchMode ccch_mode,
210 GsmRxLev rxlev_exp
211 } with { variant "" };
212
213 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100214 L1ctlCcchMode ccch_mode,
215 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200216 } with { variant "" };
217
218 type record L1ctlTchModeReq {
219 L1ctlTchMode tch_mode,
220 L1ctlAudioMode audio_mode,
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700221 L1ctlLoopMode loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200222 record {
223 uint8_t start_codec,
224 BIT8 codecs_bitmask
225 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200226 } with { variant "" };
227
228 type record L1ctlRachReq {
229 uint8_t ra,
230 uint8_t combined,
231 uint16_t offset
232 } with { variant "" };
233
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700234 type enumerated L1ctlRachSynchSeq {
235 RACH_SYNCH_SEQ_TS0 (0),
236 RACH_SYNCH_SEQ_TS1,
237 RACH_SYNCH_SEQ_TS2
238 } with { variant "FIELDLENGTH(8)" };
239
240 type record L1ctlExtRachReq {
241 uint16_t ra11,
242 L1ctlRachSynchSeq synch_seq,
243 uint8_t combined,
244 uint16_t offset
245 } with { variant "" };
246
Harald Weltef6543322017-07-16 07:35:10 +0200247 type record L1ctlParReq {
248 int8_t ta,
249 uint8_t tx_power,
250 OCT2 padding
251 } with { variant "" };
252
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200253 type record L1ctlDataReq {
254 SacchL1Header l1header optional,
255 octetstring l2_payload
256 } with { variant "" };
257
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700258 type record L1ctlH0 {
259 uint8_t h,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700260 GsmBandArfcn arfcn,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700261 octetstring padding length(130)
262 } with { variant "" };
263
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700264 type record length(0..64) of GsmBandArfcn L1ctlMA;
Harald Weltef6543322017-07-16 07:35:10 +0200265 type record L1ctlH1 {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700266 uint8_t h,
Harald Weltef6543322017-07-16 07:35:10 +0200267 uint8_t hsn,
268 uint8_t maio,
269 uint8_t n,
Vadim Yanitskiye8ea3ee2020-05-27 13:29:48 +0700270 OCT1 spare,
271 L1ctlMA ma,
272 octetstring padding
273 } with {
274 variant (n) "LENGTHTO(ma)"
275 variant (n) "UNIT(elements)"
276 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849.
277 * TL;DR The reference point of the PADDING attribute is the beginning
278 * of the message, not the beginning of the type/field it's applied on.
279 * Therefore we cannot use it here, and have to add padding manually.
280 * variant (ma) "PADDING(128)" */
281 };
Harald Weltef6543322017-07-16 07:35:10 +0200282
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700283 type union L1ctlH0H1 {
284 L1ctlH0 h0,
285 L1ctlH1 h1
286 } with { variant "TAG(h0, h = 0; h1, h = 1)" };
287
Harald Weltef6543322017-07-16 07:35:10 +0200288 type record L1ctlDmEstReq {
289 GsmTsc tsc,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700290 L1ctlH0H1 h0h1,
Harald Weltef6543322017-07-16 07:35:10 +0200291 L1ctlTchMode tch_mode,
292 L1ctlAudioMode audio_mode
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700293 } with { variant "" };
Harald Weltef6543322017-07-16 07:35:10 +0200294
295 type record L1ctlReset {
296 L1ctlResetType reset_type,
297 OCT3 padding
298 } with { variant "" };
299
Harald Weltee613f962018-04-18 22:38:16 +0200300 type record L1CtlCryptoReq {
301 uint8_t algo,
302 uint8_t key_len,
303 octetstring key
304 } with { variant (key_len) "LENGTHTO(key)" };
305
Harald Weltef6543322017-07-16 07:35:10 +0200306
307 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700308 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100309 } with {
310 variant (data) "BYTEORDER(first)"
311 }
Harald Weltef6543322017-07-16 07:35:10 +0200312
Harald Welte00d4dac2017-07-30 00:50:32 +0200313
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700314 /* payload of L1CTL_GPRS_UL_TBF_CFG_REQ */
315 type record L1ctlGprsUlTbfCfgReq {
316 uint8_t tbf_ref,
317 BIT8 slotmask,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700318 OCT2 pad ('0000'O),
319 uint32_t start_fn /* TBF Starting Time (absolute Fn) */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700320 } with { variant (slotmask) "BITORDER(msb)" };
321
322 /* payload of L1CTL_GPRS_DL_TBF_CFG_REQ */
323 type record L1ctlGprsDlTbfCfgReq {
324 uint8_t tbf_ref,
325 BIT8 slotmask,
326 uint8_t dl_tfi,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700327 OCT1 pad ('00'O),
328 uint32_t start_fn /* TBF Starting Time (absolute Fn) */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700329 } with { variant (slotmask) "BITORDER(msb)" };
330
331 /* part of L1CTL_GPRS_{UL,DL}_BLOCK_{REQ,IND} */
332 type record L1ctlGprsBlockHdr {
333 uint32_t fn,
334 uint8_t tn,
335 OCT3 pad ('000000'O)
336 } with { variant "" };
337
338 /* payload of L1CTL_GPRS_UL_BLOCK_REQ */
339 type record L1ctlGprsUlBlockReq {
340 L1ctlGprsBlockHdr hdr,
341 octetstring data
342 } with { variant (data) "BYTEORDER(first)" };
343
344 /* payload of L1CTL_GPRS_DL_BLOCK_IND */
345 type record L1ctlGprsDlBlockInd {
346 L1ctlGprsBlockHdr hdr,
347 record {
348 uint16_t ber10k, /* Bit Error Rate */
349 int16_t ci_cb, /* C/I in centiBels */
350 uint8_t rx_level /* RxLev 0..63 */
351 } meas,
352 uint8_t usf,
353 octetstring data
354 } with { variant (data) "BYTEORDER(first)" };
355
Harald Welte00d4dac2017-07-30 00:50:32 +0200356
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700357 type union L1ctlMsgPayload {
Harald Weltef6543322017-07-16 07:35:10 +0200358 L1ctlFbsbReq fbsb_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700359 L1ctlFbsbConf fbsb_conf,
360 L1ctlDataInd data_ind,
Harald Weltef6543322017-07-16 07:35:10 +0200361 L1ctlRachReq rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200362 L1ctlDmEstReq dm_est_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200363 L1ctlDataReq data_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700364 /* TODO: L1CTL_RESET_IND */
365 /* TODO: L1CTL_PM_REQ */
366 /* TODO: L1CTL_PM_CONF */
367 L1ctlReset reset_req,
368 L1ctlCcchModeReq ccch_mode_req,
369 L1ctlCcchModeConf ccch_mode_conf,
370 L1ctlParReq par_req,
371 /* TODO: L1CTL_DM_FREQ_REQ */
372 L1CtlCryptoReq crypto_req,
373 /* TODO: L1CTL_SIM_REQ */
374 /* TODO: L1CTL_SIM_CONF */
375 L1ctlTchModeReq tch_mode_req,
376 L1ctlTchModeConf tch_mode_conf,
377 /* TODO: L1CTL_NEIGH_PM_REQ */
378 /* TODO: L1CTL_NEIGH_PM_IND */
379 L1ctlTrafficReq traffic_req,
380 L1ctlTrafficReq traffic_ind,
381 /* TODO: L1CTL_BURST_IND */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700382 L1ctlGprsUlTbfCfgReq ul_tbf_cfg_req,
383 L1ctlGprsDlTbfCfgReq dl_tbf_cfg_req,
384 L1ctlGprsUlBlockReq ul_block_req,
385 L1ctlGprsDlBlockInd dl_block_ind,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700386 L1ctlExtRachReq ext_rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200387 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100388 } with {
389 variant (other) "BYTEORDER(first)"
390 };
Harald Weltef6543322017-07-16 07:35:10 +0200391
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700392 type record L1ctlMessage {
Harald Weltef6543322017-07-16 07:35:10 +0200393 L1ctlHeader header,
394 L1ctlUlInfo ul_info optional,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700395 L1ctlDlInfo dl_info optional,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700396 L1ctlMsgPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200397 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700398 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200399 header.msg_type = L1CTL_PARAM_REQ,
400 header.msg_type = L1CTL_CRYPTO_REQ,
401 header.msg_type = L1CTL_DATA_REQ,
402 header.msg_type = L1CTL_DM_EST_REQ,
403 header.msg_type = L1CTL_DM_FREQ_REQ,
404 header.msg_type = L1CTL_DM_REL_REQ,
405 header.msg_type = L1CTL_TRAFFIC_REQ)"
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700406 variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
407 header.msg_type = L1CTL_RACH_CONF,
408 header.msg_type = L1CTL_DATA_IND,
409 header.msg_type = L1CTL_DATA_CONF,
410 header.msg_type = L1CTL_TRAFFIC_IND,
411 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200412 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700413 fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
414 data_ind, header.msg_type = L1CTL_DATA_IND;
Harald Weltef6543322017-07-16 07:35:10 +0200415 rach_req, header.msg_type = L1CTL_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200416 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200417 data_req, header.msg_type = L1CTL_DATA_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700418 /* TODO: reset_ind, header.msg_type = L1CTL_RESET_IND */
419 /* TODO: pm_req, header.msg_type = L1CTL_PM_REQ */
420 /* TODO: pm_conf, header.msg_type = L1CTL_PM_CONF */
421 reset_req, header.msg_type = L1CTL_RESET_REQ;
422 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
423 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
424 par_req, header.msg_type = L1CTL_PARAM_REQ;
425 /* TODO: freq_req, header.msg_type = L1CTL_DM_FREQ_REQ */
426 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
427 /* TODO: sim_req, header.msg_type = L1CTL_SIM_REQ */
428 /* TODO: sim_conf, header.msg_type = L1CTL_SIM_CONF */
429 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
430 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
431 /* TODO: neigh_pm_req, header.msg_type = L1CTL_NEIGH_PM_REQ */
432 /* TODO: neigh_pm_ind, header.msg_type = L1CTL_NEIGH_PM_IND */
433 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
434 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
435 /* TODO: burst_ind, header.msg_type = L1CTL_BURST_IND */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700436 ul_tbf_cfg_req, header.msg_type = L1CTL_GPRS_UL_TBF_CFG_REQ;
437 dl_tbf_cfg_req, header.msg_type = L1CTL_GPRS_DL_TBF_CFG_REQ;
438 ul_block_req, header.msg_type = L1CTL_GPRS_UL_BLOCK_REQ;
439 dl_block_ind, header.msg_type = L1CTL_GPRS_DL_BLOCK_IND;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700440 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200441 other, OTHERWISE;
442 )" };
443
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700444 external function enc_L1ctlMessage(in L1ctlMessage msg) return octetstring
Harald Weltef6543322017-07-16 07:35:10 +0200445 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700446 external function dec_L1ctlMessage(in octetstring stream) return L1ctlMessage
Harald Weltef6543322017-07-16 07:35:10 +0200447 with { extension "prototype(convert) decode(RAW)" };
448
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700449 type record L1ctlMessageLV {
Harald Welte52c713c2017-07-16 15:44:44 +0200450 uint16_t len,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700451 L1ctlMessage msg
Harald Welte52c713c2017-07-16 15:44:44 +0200452 } with { variant (len) "LENGTHTO(msg)" };
453
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700454 external function enc_L1ctlMessageLV(in L1ctlMessageLV msg) return octetstring
Harald Welte52c713c2017-07-16 15:44:44 +0200455 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700456 external function dec_L1ctlMessageLV(in octetstring stream) return L1ctlMessageLV
Harald Welte52c713c2017-07-16 15:44:44 +0200457 with { extension "prototype(convert) decode(RAW)" };
458
459
Harald Welte9e4725d2017-07-16 23:18:09 +0200460
Harald Welte9e4725d2017-07-16 23:18:09 +0200461 /* for generating RESET_REQ */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700462 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700463 t_L1ctlResetReq(template (value) L1ctlResetType rst_type) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100464 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200465 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700466 dl_info := 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 Welte9e4725d2017-07-16 23:18:09 +0200485 payload := {
486 fbsb_req := {
487 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100488 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200489 freq_err_thresh1 := 10000,
490 freq_err_thresh2 := 800,
491 num_freqerr_avg := 3,
492 flags := flags,
493 sync_info_idx := sync_info_idx,
494 ccch_mode := ccch_mode,
495 rxlev_exp := rxlev_exp
496 }
497 }
498 };
499
500 /* for matching against incoming FBSB_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700501 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700502 tr_L1CTL_FBSB_CONF(template (present) uint8_t result) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100503 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700504 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200505 dl_info := ?,
506 payload := {
507 fbsb_conf := {
508 initial_freq_err := ?,
509 result := result,
510 bsic := ?
511 }
512 }
513 };
514
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700515 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700516 ts_L1CTL_CCCH_MODE_REQ(template (value) L1ctlCcchMode ccch_mode) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100517 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
518 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700519 dl_info := omit,
Harald Weltef8df4cb2018-03-10 15:15:08 +0100520 payload := {
521 ccch_mode_req := {
522 ccch_mode := ccch_mode,
523 padding := '000000'O
524 }
525 }
526 };
527
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700528 template (value) L1ctlMessage
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700529 ts_L1CTL_TCH_MODE_REQ(template (value) L1ctlTchMode tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700530 template (value) L1ctlAudioMode audio_mode := t_L1CTL_AudioModeFwd,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200531 template (value) L1ctlLoopMode loop_mode := L1CTL_LOOP_MODE_OPEN,
532 template (value) uint8_t amr_start_codec := 0,
533 template (value) BIT8 amr_codecs_bitmask := '00000000'B) := {
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700534 header := ts_L1ctlHeader(L1CTL_TCH_MODE_REQ),
535 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700536 dl_info := omit,
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700537 payload := {
538 tch_mode_req := {
539 tch_mode := tch_mode,
540 audio_mode := audio_mode,
541 loop_mode := loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200542 amr := {
543 start_codec := amr_start_codec,
544 codecs_bitmask := amr_codecs_bitmask
545 }
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700546 }
547 }
548 };
549
Harald Welte3757e602018-03-10 17:12:02 +0100550
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700551 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700552 tr_L1CTL_MsgType(template (present) L1ctlMsgType msg_type) := {
Harald Welte3757e602018-03-10 17:12:02 +0100553 header := tr_L1ctlHeader(msg_type),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700554 ul_info := *,
Harald Welte3757e602018-03-10 17:12:02 +0100555 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200556 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100557 }
558
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700559 template L1ctlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100560
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700561 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700562 ts_L1CTL_RACH_REQ(template (value) uint8_t ra,
563 template (value) uint8_t combined,
564 template (value) uint16_t offset,
565 template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
566 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100567 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200568 ul_info := {
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700569 chan_nr := chan_nr,
570 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200571 padding := '0000'O
572 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700573 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200574 payload := {
575 rach_req := {
576 ra := ra,
577 combined := combined,
578 offset := offset
579 }
580 }
581 }
582
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700583 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700584 ts_L1CTL_EXT_RACH_REQ(template (value) uint16_t ra11,
585 template (value) L1ctlRachSynchSeq seq,
586 template (value) uint8_t combined,
587 template (value) uint16_t offset) := {
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700588 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
589 ul_info := {
590 /* FIXME: both RSL chan_nr and link_id should be configurable */
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300591 chan_nr := ts_RslChanNr_RACH(0),
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700592 link_id := ts_RslLinkID_DCCH(0),
593 padding := '0000'O
594 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700595 dl_info := omit,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700596 payload := {
597 ext_rach_req := {
598 ra11 := ra11,
599 synch_seq := seq,
600 combined := combined,
601 offset := offset
602 }
603 }
604 }
605
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700606 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700607 ts_L1CTL_PAR_REQ(template (value) uint8_t ta,
608 template (value) uint8_t tx_power) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100609 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100610 ul_info := {
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300611 chan_nr := ts_RslChanNr_RACH(0),
Harald Welte37052732018-03-09 19:38:46 +0100612 link_id := ts_RslLinkID_DCCH(0),
613 padding := '0000'O
614 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700615 dl_info := omit,
Harald Welte37052732018-03-09 19:38:46 +0100616 payload := {
617 par_req := {
618 ta := ta,
619 tx_power := tx_power,
620 padding := '0000'O
621 }
622 }
623 }
624
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700625 /* 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 +0700626 private template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700627 ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
628 template (value) GsmTsc tsc) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100629 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200630 ul_info := {
631 chan_nr := chan_nr,
632 link_id := ts_RslLinkID_DCCH(0),
633 padding := '0000'O
634 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700635 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200636 payload := {
637 dm_est_req := {
638 tsc := tsc,
Vadim Yanitskiy0a3e31c2022-12-18 08:09:38 +0700639 h0h1 := -,
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700640 tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700641 audio_mode := t_L1CTL_AudioModeFwd
Harald Welte9e4725d2017-07-16 23:18:09 +0200642 }
643 }
644 }
645
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700646 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700647 ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
648 template (value) GsmTsc tsc,
649 template (value) GsmArfcn arfcn)
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700650 modifies ts_L1CTL_DM_EST_REQ := {
651 payload := {
652 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700653 h0h1 := {
654 h0 := {
655 h := 0,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700656 arfcn := ts_GsmBandArfcn(arfcn),
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700657 padding := f_pad_oct(''O, 130, '00'O)
658 }
659 }
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700660 }
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_H1(template (value) RslChannelNr chan_nr,
666 template (value) GsmTsc tsc,
667 template (value) uint6_t hsn,
668 template (value) uint6_t maio,
669 template (value) L1ctlMA ma)
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700670 modifies ts_L1CTL_DM_EST_REQ := {
671 payload := {
672 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700673 h0h1 := {
674 h1 := {
675 h := 1,
676 hsn := hsn,
677 maio := maio,
678 n := sizeof(ma),
679 spare := '00'O,
680 ma := ma,
681 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 */
682 padding := f_pad_oct(''O, (64 - sizeof(ma)) * 2, '00'O)
683 }
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700684 }
685 }
686 }
687 }
688
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700689 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700690 ts_L1CTL_DM_REL_REQ(template (value) RslChannelNr chan_nr) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100691 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200692 ul_info := {
693 chan_nr := chan_nr,
694 link_id := ts_RslLinkID_DCCH(0),
695 padding := '0000'O
696 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700697 dl_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700698 payload := omit
Harald Welte9e4725d2017-07-16 23:18:09 +0200699 }
700
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700701 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700702 ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
703 template (value) RslLinkId link_id,
704 octetstring l2_data) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100705 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200706 ul_info := {
707 chan_nr := chan_nr,
708 link_id := link_id,
709 padding := '0000'O
710 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700711 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200712 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700713 data_req := {
714 l1header := omit,
715 l2_payload := l2_data
716 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200717 }
718 }
719
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700720 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700721 ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
722 template (value) RslLinkId link_id,
723 template (value) SacchL1Header l1h,
724 octetstring l2_data) := {
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200725 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
726 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,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200732 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700733 data_req := {
734 l1header := l1h,
735 l2_payload := l2_data
736 }
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200737 }
738 }
739
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700740 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700741 ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
742 template (value) RslLinkId link_id,
743 octetstring frame) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700744 header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
745 ul_info := {
746 chan_nr := chan_nr,
747 link_id := link_id,
748 padding := '0000'O
749 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700750 dl_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700751 payload := {
752 traffic_req := {
753 data := frame
754 }
755 }
756 };
757
Harald Welte9e4725d2017-07-16 23:18:09 +0200758 /* for matching against incoming RACH_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700759 template L1ctlMessage tr_L1CTL_RACH_CONF := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100760 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700761 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200762 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200763 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200764 };
765
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700766 /* for sending and matching L1CTL_DATA_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700767 template (value) L1ctlMessage
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700768 ts_L1CTL_DATA_IND(template (value) RslChannelNr chan_nr,
769 template (value) RslLinkId link_id,
770 template (value) octetstring l2_data,
771 template (value) GsmBandArfcn arfcn,
772 template (value) uint32_t fn := 1337,
773 template (value) GsmRxLev rx_level := 63,
774 template (value) uint8_t num_biterr := 0,
775 template (value) uint8_t fire_crc := 0) := {
776 header := ts_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700777 ul_info := omit,
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700778 dl_info := {
779 chan_nr := chan_nr,
780 link_id := link_id,
781 arfcn := arfcn,
782 frame_nr := fn,
783 rx_level := rx_level,
784 snr := 0,
785 num_biterr := num_biterr,
786 fire_crc := fire_crc
787 },
788 payload := {
789 data_ind := {
790 payload := l2_data
791 }
792 }
793 };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700794 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700795 tr_L1CTL_DATA_IND(template (present) RslChannelNr chan_nr,
796 template (present) RslLinkId link_id := ?,
797 template (present) octetstring l2_data := ?,
798 template (present) uint8_t num_biterr := 0,
799 template (present) uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100800 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700801 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200802 dl_info := {
803 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100804 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200805 arfcn := ?,
806 frame_nr := ?,
807 rx_level := ?,
808 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100809 num_biterr := num_biterr,
Pau Espin Pedrol17da3232022-09-02 16:35:32 +0200810 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200811 },
812 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100813 data_ind := {
814 payload := l2_data
815 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200816 }
817 };
818
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700819 /* for matching against incoming TRAFFIC_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700820 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700821 tr_L1CTL_TRAFFIC_IND(template (present) RslChannelNr chan_nr,
822 template (present) RslLinkId link_id := ?,
823 template (present) octetstring frame := ?,
824 template (present) uint8_t num_biterr := ?,
825 template (present) uint8_t fire_crc := ?) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700826 header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700827 ul_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700828 dl_info := {
829 chan_nr := chan_nr,
830 link_id := link_id,
831 arfcn := ?,
832 frame_nr := ?,
833 rx_level := ?,
834 snr := ?,
835 num_biterr := num_biterr,
836 fire_crc := fire_crc
837 },
838 payload := {
839 traffic_ind := {
840 data := frame
841 }
842 }
843 };
844
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700845 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700846 ts_L1CTL_CRYPTO_REQ(template (value) RslChannelNr chan_nr,
847 template (value) uint8_t algo,
848 template (value) octetstring key) := {
Harald Weltee613f962018-04-18 22:38:16 +0200849 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
850 ul_info := {
851 chan_nr := chan_nr,
852 link_id := ts_RslLinkID_DCCH(0),
853 padding := '0000'O
854 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700855 dl_info := omit,
Harald Weltee613f962018-04-18 22:38:16 +0200856 payload := {
857 crypto_req := {
858 algo := algo,
859 key_len := 0, /* overwritten */
860 key := key
861 }
862 }
863 };
864
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700865
866 template (value) L1ctlMessage
867 ts_L1CTL_GPRS_UL_TBF_CFG_REQ(template (value) uint8_t tbf_ref,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700868 template (value) BIT8 slotmask := '00000000'B,
869 template (value) uint32_t start_fn := c_UINT32_MAX) := {
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700870 header := ts_L1ctlHeader(L1CTL_GPRS_UL_TBF_CFG_REQ),
871 ul_info := omit,
872 dl_info := omit,
873 payload := {
874 ul_tbf_cfg_req := {
875 tbf_ref := tbf_ref,
876 slotmask := slotmask,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700877 pad := '0000'O,
878 start_fn := start_fn
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700879 }
880 }
881 };
882 template L1ctlMessage
883 tr_L1CTL_GPRS_UL_TBF_CFG_REQ(template (present) uint8_t tbf_ref := ?,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700884 template (present) BIT8 slotmask := ?,
885 template (present) uint32_t start_fn := ?) := {
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700886 header := tr_L1ctlHeader(L1CTL_GPRS_UL_TBF_CFG_REQ),
887 ul_info := omit,
888 dl_info := omit,
889 payload := {
890 ul_tbf_cfg_req := {
891 tbf_ref := tbf_ref,
892 slotmask := slotmask,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700893 pad := ?,
894 start_fn := start_fn
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700895 }
896 }
897 };
898
899 template (value) L1ctlMessage
900 ts_L1CTL_GPRS_DL_TBF_CFG_REQ(template (value) uint8_t tbf_ref,
901 template (value) BIT8 slotmask := '00000000'B,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700902 template (value) uint32_t start_fn := c_UINT32_MAX,
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700903 template (value) uint5_t dl_tfi := 0) := {
904 header := ts_L1ctlHeader(L1CTL_GPRS_DL_TBF_CFG_REQ),
905 ul_info := omit,
906 dl_info := omit,
907 payload := {
908 dl_tbf_cfg_req := {
909 tbf_ref := tbf_ref,
910 slotmask := slotmask,
911 dl_tfi := dl_tfi,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700912 pad := '00'O,
913 start_fn := start_fn
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700914 }
915 }
916 };
917 template L1ctlMessage
918 tr_L1CTL_GPRS_DL_TBF_CFG_REQ(template (present) uint8_t tbf_ref := ?,
919 template (present) BIT8 slotmask := ?,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700920 template (present) uint32_t start_fn := ?,
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700921 template (present) uint5_t dl_tfi := ?) := {
922 header := tr_L1ctlHeader(L1CTL_GPRS_DL_TBF_CFG_REQ),
923 ul_info := omit,
924 dl_info := omit,
925 payload := {
926 dl_tbf_cfg_req := {
927 tbf_ref := tbf_ref,
928 slotmask := slotmask,
929 dl_tfi := dl_tfi,
Vadim Yanitskiy0e5693f2023-08-27 14:09:32 +0700930 pad := ?,
931 start_fn := start_fn
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700932 }
933 }
934 };
935
936 template (value) L1ctlMessage
937 ts_L1CTL_GPRS_UL_BLOCK_REQ(template (value) GsmFrameNumber fn,
938 template (value) uint3_t tn,
939 template (value) octetstring data) := {
940 header := ts_L1ctlHeader(L1CTL_GPRS_UL_BLOCK_REQ),
941 ul_info := omit,
942 dl_info := omit,
943 payload := {
944 ul_block_req := {
945 hdr := {
946 fn := fn,
947 tn := tn,
948 pad := '000000'O
949 },
950 data := data
951 }
952 }
953 };
954 template L1ctlMessage
955 tr_L1CTL_GPRS_UL_BLOCK_REQ(template (present) GsmFrameNumber fn := ?,
956 template (present) uint3_t tn := ?,
957 template (present) octetstring data := ?) := {
958 header := tr_L1ctlHeader(L1CTL_GPRS_UL_BLOCK_REQ),
959 ul_info := omit,
960 dl_info := omit,
961 payload := {
962 ul_block_req := {
963 hdr := {
964 fn := fn,
965 tn := tn,
966 pad := ?
967 },
968 data := data
969 }
970 }
971 };
972
973 template (value) L1ctlMessage
974 ts_L1CTL_GPRS_DL_BLOCK_IND(template (value) GsmFrameNumber fn,
975 template (value) uint3_t tn,
976 template (value) uint3_t usf,
977 template (value) octetstring data,
978 template (value) uint16_t ber10k := 0,
979 template (value) int16_t ci_cb := 180 /* 18 dB */,
980 template (value) GsmRxLev rx_level := 63) := {
981 header := ts_L1ctlHeader(L1CTL_GPRS_DL_BLOCK_IND),
982 ul_info := omit,
983 dl_info := omit,
984 payload := {
985 dl_block_ind := {
986 hdr := {
987 fn := fn,
988 tn := tn,
989 pad := '000000'O
990 },
991 meas := {
992 ber10k := ber10k,
993 ci_cb := ci_cb,
994 rx_level := rx_level
995 },
996 usf := usf,
997 data := data
998 }
999 }
1000 };
1001 template L1ctlMessage
1002 tr_L1CTL_GPRS_DL_BLOCK_IND(template (present) GsmFrameNumber fn := ?,
1003 template (present) uint3_t tn := ?,
1004 template (present) uint3_t usf := ?,
1005 template (present) octetstring data := ?,
1006 template (present) uint16_t ber10k := ?,
1007 template (present) int16_t ci_cb := ?,
1008 template (present) GsmRxLev rx_level := ?) := {
1009 header := tr_L1ctlHeader(L1CTL_GPRS_DL_BLOCK_IND),
1010 ul_info := omit,
1011 dl_info := omit,
1012 payload := {
1013 dl_block_ind := {
1014 hdr := {
1015 fn := fn,
1016 tn := tn,
1017 pad := ?
1018 },
1019 meas := {
1020 ber10k := ber10k,
1021 ci_cb := ci_cb,
1022 rx_level := rx_level
1023 },
1024 usf := usf,
1025 data := data
1026 }
1027 }
1028 };
1029
Harald Welte68e495b2018-02-25 00:05:57 +01001030 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
1031
Harald Welte7024baa2018-03-02 23:37:51 +01001032/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
1033 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +02001034} with { encode "RAW" };