blob: 192091ef8893d0eae07abf23c2393d451ffb918d [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 */
130 L1CTL_CHAN_MODE_SPEECH_V3 ('01000001'B) /* AMR codec */
131 /* Other modes are not supported for now */
132 } with { variant "FIELDLENGTH(8)" };
Harald Weltef6543322017-07-16 07:35:10 +0200133
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700134 type enumerated L1ctlLoopMode {
135 L1CTL_LOOP_MODE_OPEN ('00000000'B),
136 L1CTL_LOOP_MODE_A ('00000001'B),
137 L1CTL_LOOP_MODE_B ('00000010'B),
138 L1CTL_LOOP_MODE_C ('00000011'B),
139 L1CTL_LOOP_MODE_D ('00000100'B),
140 L1CTL_LOOP_MODE_E ('00000101'B),
141 L1CTL_LOOP_MODE_F ('00000110'B),
142 L1CTL_LOOP_MODE_I ('00000111'B)
143 } with { variant "FIELDLENGTH(8)" };
144
Harald Weltef6543322017-07-16 07:35:10 +0200145 type record L1ctlAudioMode {
146 BIT4 padding,
147 boolean tx_microphone,
148 boolean tx_traffic_req,
149 boolean rx_speaker,
150 boolean rx_traffic_ind
151 } with { variant "" };
152
Harald Weltef8df4cb2018-03-10 15:15:08 +0100153 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200154
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700155 /* Traffic forwarding mode (see TRAFFIC.{req,cnf,ind} messages) */
156 template (value) L1ctlAudioMode t_L1CTL_AudioModeFwd
157 modifies t_L1CTL_AudioModeNone := {
158 tx_traffic_req := true,
159 rx_traffic_ind := true
160 };
161
Harald Weltef6543322017-07-16 07:35:10 +0200162 type record L1ctlTchModeConf {
163 L1ctlTchMode tch_mode,
164 L1ctlAudioMode audio_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200165 record {
166 uint8_t start_codec,
167 BIT8 codecs_bitmask
168 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200169 } with { variant "" };
170
171 type record L1ctlDataInd {
Vadim Yanitskiy2a92e2a2019-05-28 21:13:35 +0700172 octetstring payload
Harald Welte7024baa2018-03-02 23:37:51 +0100173 } with {
174 variant (payload) "BYTEORDER(first)"
175 };
Harald Weltef6543322017-07-16 07:35:10 +0200176
Harald Weltef6543322017-07-16 07:35:10 +0200177
178 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200179 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200180 RslLinkId link_id,
181 OCT2 padding
182 } with { variant "" };
183
184 type record L1ctlFbsbFlags {
185 BIT5 padding,
186 boolean sb,
187 boolean fb1,
188 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100189 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200190
Harald Weltef8df4cb2018-03-10 15:15:08 +0100191 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200192 padding := '00000'B,
193 sb := true,
194 fb1 := true,
195 fb0 := true
196 };
197
Harald Weltef6543322017-07-16 07:35:10 +0200198 type record L1ctlFbsbReq {
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700199 GsmBandArfcn arfcn,
Harald Weltef6543322017-07-16 07:35:10 +0200200 uint16_t timeout_tdma_frames,
201 uint16_t freq_err_thresh1,
202 uint16_t freq_err_thresh2,
203 uint8_t num_freqerr_avg,
204 L1ctlFbsbFlags flags,
205 uint8_t sync_info_idx,
206 L1ctlCcchMode ccch_mode,
207 GsmRxLev rxlev_exp
208 } with { variant "" };
209
210 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100211 L1ctlCcchMode ccch_mode,
212 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200213 } with { variant "" };
214
215 type record L1ctlTchModeReq {
216 L1ctlTchMode tch_mode,
217 L1ctlAudioMode audio_mode,
Vadim Yanitskiy7ce605f2020-10-19 16:04:38 +0700218 L1ctlLoopMode loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200219 record {
220 uint8_t start_codec,
221 BIT8 codecs_bitmask
222 } amr
Harald Weltef6543322017-07-16 07:35:10 +0200223 } with { variant "" };
224
225 type record L1ctlRachReq {
226 uint8_t ra,
227 uint8_t combined,
228 uint16_t offset
229 } with { variant "" };
230
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700231 type enumerated L1ctlRachSynchSeq {
232 RACH_SYNCH_SEQ_TS0 (0),
233 RACH_SYNCH_SEQ_TS1,
234 RACH_SYNCH_SEQ_TS2
235 } with { variant "FIELDLENGTH(8)" };
236
237 type record L1ctlExtRachReq {
238 uint16_t ra11,
239 L1ctlRachSynchSeq synch_seq,
240 uint8_t combined,
241 uint16_t offset
242 } with { variant "" };
243
Harald Weltef6543322017-07-16 07:35:10 +0200244 type record L1ctlParReq {
245 int8_t ta,
246 uint8_t tx_power,
247 OCT2 padding
248 } with { variant "" };
249
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200250 type record L1ctlDataReq {
251 SacchL1Header l1header optional,
252 octetstring l2_payload
253 } with { variant "" };
254
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700255 type record L1ctlH0 {
256 uint8_t h,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700257 GsmBandArfcn arfcn,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700258 octetstring padding length(130)
259 } with { variant "" };
260
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700261 type record length(0..64) of GsmBandArfcn L1ctlMA;
Harald Weltef6543322017-07-16 07:35:10 +0200262 type record L1ctlH1 {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700263 uint8_t h,
Harald Weltef6543322017-07-16 07:35:10 +0200264 uint8_t hsn,
265 uint8_t maio,
266 uint8_t n,
Vadim Yanitskiye8ea3ee2020-05-27 13:29:48 +0700267 OCT1 spare,
268 L1ctlMA ma,
269 octetstring padding
270 } with {
271 variant (n) "LENGTHTO(ma)"
272 variant (n) "UNIT(elements)"
273 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849.
274 * TL;DR The reference point of the PADDING attribute is the beginning
275 * of the message, not the beginning of the type/field it's applied on.
276 * Therefore we cannot use it here, and have to add padding manually.
277 * variant (ma) "PADDING(128)" */
278 };
Harald Weltef6543322017-07-16 07:35:10 +0200279
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700280 type union L1ctlH0H1 {
281 L1ctlH0 h0,
282 L1ctlH1 h1
283 } with { variant "TAG(h0, h = 0; h1, h = 1)" };
284
Harald Weltef6543322017-07-16 07:35:10 +0200285 type record L1ctlDmEstReq {
286 GsmTsc tsc,
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700287 L1ctlH0H1 h0h1,
Harald Weltef6543322017-07-16 07:35:10 +0200288 L1ctlTchMode tch_mode,
289 L1ctlAudioMode audio_mode
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700290 } with { variant "" };
Harald Weltef6543322017-07-16 07:35:10 +0200291
292 type record L1ctlReset {
293 L1ctlResetType reset_type,
294 OCT3 padding
295 } with { variant "" };
296
Harald Weltee613f962018-04-18 22:38:16 +0200297 type record L1CtlCryptoReq {
298 uint8_t algo,
299 uint8_t key_len,
300 octetstring key
301 } with { variant (key_len) "LENGTHTO(key)" };
302
Harald Weltef6543322017-07-16 07:35:10 +0200303
304 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700305 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100306 } with {
307 variant (data) "BYTEORDER(first)"
308 }
Harald Weltef6543322017-07-16 07:35:10 +0200309
Harald Welte00d4dac2017-07-30 00:50:32 +0200310
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700311 /* payload of L1CTL_GPRS_UL_TBF_CFG_REQ */
312 type record L1ctlGprsUlTbfCfgReq {
313 uint8_t tbf_ref,
314 BIT8 slotmask,
315 OCT2 pad ('0000'O)
316 } with { variant (slotmask) "BITORDER(msb)" };
317
318 /* payload of L1CTL_GPRS_DL_TBF_CFG_REQ */
319 type record L1ctlGprsDlTbfCfgReq {
320 uint8_t tbf_ref,
321 BIT8 slotmask,
322 uint8_t dl_tfi,
323 OCT1 pad ('00'O)
324 } with { variant (slotmask) "BITORDER(msb)" };
325
326 /* part of L1CTL_GPRS_{UL,DL}_BLOCK_{REQ,IND} */
327 type record L1ctlGprsBlockHdr {
328 uint32_t fn,
329 uint8_t tn,
330 OCT3 pad ('000000'O)
331 } with { variant "" };
332
333 /* payload of L1CTL_GPRS_UL_BLOCK_REQ */
334 type record L1ctlGprsUlBlockReq {
335 L1ctlGprsBlockHdr hdr,
336 octetstring data
337 } with { variant (data) "BYTEORDER(first)" };
338
339 /* payload of L1CTL_GPRS_DL_BLOCK_IND */
340 type record L1ctlGprsDlBlockInd {
341 L1ctlGprsBlockHdr hdr,
342 record {
343 uint16_t ber10k, /* Bit Error Rate */
344 int16_t ci_cb, /* C/I in centiBels */
345 uint8_t rx_level /* RxLev 0..63 */
346 } meas,
347 uint8_t usf,
348 octetstring data
349 } with { variant (data) "BYTEORDER(first)" };
350
Harald Welte00d4dac2017-07-30 00:50:32 +0200351
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700352 type union L1ctlMsgPayload {
Harald Weltef6543322017-07-16 07:35:10 +0200353 L1ctlFbsbReq fbsb_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700354 L1ctlFbsbConf fbsb_conf,
355 L1ctlDataInd data_ind,
Harald Weltef6543322017-07-16 07:35:10 +0200356 L1ctlRachReq rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200357 L1ctlDmEstReq dm_est_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200358 L1ctlDataReq data_req,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700359 /* TODO: L1CTL_RESET_IND */
360 /* TODO: L1CTL_PM_REQ */
361 /* TODO: L1CTL_PM_CONF */
362 L1ctlReset reset_req,
363 L1ctlCcchModeReq ccch_mode_req,
364 L1ctlCcchModeConf ccch_mode_conf,
365 L1ctlParReq par_req,
366 /* TODO: L1CTL_DM_FREQ_REQ */
367 L1CtlCryptoReq crypto_req,
368 /* TODO: L1CTL_SIM_REQ */
369 /* TODO: L1CTL_SIM_CONF */
370 L1ctlTchModeReq tch_mode_req,
371 L1ctlTchModeConf tch_mode_conf,
372 /* TODO: L1CTL_NEIGH_PM_REQ */
373 /* TODO: L1CTL_NEIGH_PM_IND */
374 L1ctlTrafficReq traffic_req,
375 L1ctlTrafficReq traffic_ind,
376 /* TODO: L1CTL_BURST_IND */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700377 L1ctlGprsUlTbfCfgReq ul_tbf_cfg_req,
378 L1ctlGprsDlTbfCfgReq dl_tbf_cfg_req,
379 L1ctlGprsUlBlockReq ul_block_req,
380 L1ctlGprsDlBlockInd dl_block_ind,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700381 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,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700391 L1ctlMsgPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200392 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700393 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200394 header.msg_type = L1CTL_PARAM_REQ,
395 header.msg_type = L1CTL_CRYPTO_REQ,
396 header.msg_type = L1CTL_DATA_REQ,
397 header.msg_type = L1CTL_DM_EST_REQ,
398 header.msg_type = L1CTL_DM_FREQ_REQ,
399 header.msg_type = L1CTL_DM_REL_REQ,
400 header.msg_type = L1CTL_TRAFFIC_REQ)"
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700401 variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
402 header.msg_type = L1CTL_RACH_CONF,
403 header.msg_type = L1CTL_DATA_IND,
404 header.msg_type = L1CTL_DATA_CONF,
405 header.msg_type = L1CTL_TRAFFIC_IND,
406 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200407 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700408 fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
409 data_ind, header.msg_type = L1CTL_DATA_IND;
Harald Weltef6543322017-07-16 07:35:10 +0200410 rach_req, header.msg_type = L1CTL_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200411 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200412 data_req, header.msg_type = L1CTL_DATA_REQ;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700413 /* TODO: reset_ind, header.msg_type = L1CTL_RESET_IND */
414 /* TODO: pm_req, header.msg_type = L1CTL_PM_REQ */
415 /* TODO: pm_conf, header.msg_type = L1CTL_PM_CONF */
416 reset_req, header.msg_type = L1CTL_RESET_REQ;
417 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
418 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
419 par_req, header.msg_type = L1CTL_PARAM_REQ;
420 /* TODO: freq_req, header.msg_type = L1CTL_DM_FREQ_REQ */
421 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
422 /* TODO: sim_req, header.msg_type = L1CTL_SIM_REQ */
423 /* TODO: sim_conf, header.msg_type = L1CTL_SIM_CONF */
424 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
425 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
426 /* TODO: neigh_pm_req, header.msg_type = L1CTL_NEIGH_PM_REQ */
427 /* TODO: neigh_pm_ind, header.msg_type = L1CTL_NEIGH_PM_IND */
428 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
429 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
430 /* TODO: burst_ind, header.msg_type = L1CTL_BURST_IND */
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700431 ul_tbf_cfg_req, header.msg_type = L1CTL_GPRS_UL_TBF_CFG_REQ;
432 dl_tbf_cfg_req, header.msg_type = L1CTL_GPRS_DL_TBF_CFG_REQ;
433 ul_block_req, header.msg_type = L1CTL_GPRS_UL_BLOCK_REQ;
434 dl_block_ind, header.msg_type = L1CTL_GPRS_DL_BLOCK_IND;
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700435 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200436 other, OTHERWISE;
437 )" };
438
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700439 external function enc_L1ctlMessage(in L1ctlMessage msg) return octetstring
Harald Weltef6543322017-07-16 07:35:10 +0200440 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700441 external function dec_L1ctlMessage(in octetstring stream) return L1ctlMessage
Harald Weltef6543322017-07-16 07:35:10 +0200442 with { extension "prototype(convert) decode(RAW)" };
443
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700444 type record L1ctlMessageLV {
Harald Welte52c713c2017-07-16 15:44:44 +0200445 uint16_t len,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700446 L1ctlMessage msg
Harald Welte52c713c2017-07-16 15:44:44 +0200447 } with { variant (len) "LENGTHTO(msg)" };
448
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700449 external function enc_L1ctlMessageLV(in L1ctlMessageLV msg) return octetstring
Harald Welte52c713c2017-07-16 15:44:44 +0200450 with { extension "prototype(convert) encode(RAW)" };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700451 external function dec_L1ctlMessageLV(in octetstring stream) return L1ctlMessageLV
Harald Welte52c713c2017-07-16 15:44:44 +0200452 with { extension "prototype(convert) decode(RAW)" };
453
454
Harald Welte9e4725d2017-07-16 23:18:09 +0200455
Harald Welte9e4725d2017-07-16 23:18:09 +0200456 /* for generating RESET_REQ */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700457 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700458 t_L1ctlResetReq(template (value) L1ctlResetType rst_type) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100459 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200460 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700461 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200462 payload := {
463 reset_req := {
464 reset_type := rst_type,
465 padding := '000000'O
466 }
467 }
468 };
469
470 /* for generating FBSB_REQ */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700471 template (value) L1ctlMessage
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700472 ts_L1CTL_FBSB_REQ(template (value) GsmBandArfcn arfcn,
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700473 template (value) L1ctlFbsbFlags flags,
474 template (value) uint8_t sync_info_idx,
475 template (value) L1ctlCcchMode ccch_mode,
476 template (value) GsmRxLev rxlev_exp) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100477 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200478 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700479 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200480 payload := {
481 fbsb_req := {
482 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100483 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200484 freq_err_thresh1 := 10000,
485 freq_err_thresh2 := 800,
486 num_freqerr_avg := 3,
487 flags := flags,
488 sync_info_idx := sync_info_idx,
489 ccch_mode := ccch_mode,
490 rxlev_exp := rxlev_exp
491 }
492 }
493 };
494
495 /* for matching against incoming FBSB_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700496 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700497 tr_L1CTL_FBSB_CONF(template (present) uint8_t result) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100498 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700499 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200500 dl_info := ?,
501 payload := {
502 fbsb_conf := {
503 initial_freq_err := ?,
504 result := result,
505 bsic := ?
506 }
507 }
508 };
509
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700510 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700511 ts_L1CTL_CCCH_MODE_REQ(template (value) L1ctlCcchMode ccch_mode) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100512 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
513 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700514 dl_info := omit,
Harald Weltef8df4cb2018-03-10 15:15:08 +0100515 payload := {
516 ccch_mode_req := {
517 ccch_mode := ccch_mode,
518 padding := '000000'O
519 }
520 }
521 };
522
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700523 template (value) L1ctlMessage
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700524 ts_L1CTL_TCH_MODE_REQ(template (value) L1ctlTchMode tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700525 template (value) L1ctlAudioMode audio_mode := t_L1CTL_AudioModeFwd,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200526 template (value) L1ctlLoopMode loop_mode := L1CTL_LOOP_MODE_OPEN,
527 template (value) uint8_t amr_start_codec := 0,
528 template (value) BIT8 amr_codecs_bitmask := '00000000'B) := {
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700529 header := ts_L1ctlHeader(L1CTL_TCH_MODE_REQ),
530 ul_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700531 dl_info := omit,
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700532 payload := {
533 tch_mode_req := {
534 tch_mode := tch_mode,
535 audio_mode := audio_mode,
536 loop_mode := loop_mode,
Pau Espin Pedrol440e1dc2022-09-02 16:35:49 +0200537 amr := {
538 start_codec := amr_start_codec,
539 codecs_bitmask := amr_codecs_bitmask
540 }
Vadim Yanitskiy3b1fae42020-10-19 16:16:41 +0700541 }
542 }
543 };
544
Harald Welte3757e602018-03-10 17:12:02 +0100545
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700546 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700547 tr_L1CTL_MsgType(template (present) L1ctlMsgType msg_type) := {
Harald Welte3757e602018-03-10 17:12:02 +0100548 header := tr_L1ctlHeader(msg_type),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700549 ul_info := *,
Harald Welte3757e602018-03-10 17:12:02 +0100550 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200551 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100552 }
553
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700554 template L1ctlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100555
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700556 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700557 ts_L1CTL_RACH_REQ(template (value) uint8_t ra,
558 template (value) uint8_t combined,
559 template (value) uint16_t offset,
560 template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
561 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100562 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200563 ul_info := {
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700564 chan_nr := chan_nr,
565 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200566 padding := '0000'O
567 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700568 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200569 payload := {
570 rach_req := {
571 ra := ra,
572 combined := combined,
573 offset := offset
574 }
575 }
576 }
577
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700578 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700579 ts_L1CTL_EXT_RACH_REQ(template (value) uint16_t ra11,
580 template (value) L1ctlRachSynchSeq seq,
581 template (value) uint8_t combined,
582 template (value) uint16_t offset) := {
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700583 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
584 ul_info := {
585 /* FIXME: both RSL chan_nr and link_id should be configurable */
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300586 chan_nr := ts_RslChanNr_RACH(0),
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700587 link_id := ts_RslLinkID_DCCH(0),
588 padding := '0000'O
589 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700590 dl_info := omit,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700591 payload := {
592 ext_rach_req := {
593 ra11 := ra11,
594 synch_seq := seq,
595 combined := combined,
596 offset := offset
597 }
598 }
599 }
600
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700601 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700602 ts_L1CTL_PAR_REQ(template (value) uint8_t ta,
603 template (value) uint8_t tx_power) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100604 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100605 ul_info := {
Vadim Yanitskiy443891b2022-03-12 17:46:57 +0300606 chan_nr := ts_RslChanNr_RACH(0),
Harald Welte37052732018-03-09 19:38:46 +0100607 link_id := ts_RslLinkID_DCCH(0),
608 padding := '0000'O
609 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700610 dl_info := omit,
Harald Welte37052732018-03-09 19:38:46 +0100611 payload := {
612 par_req := {
613 ta := ta,
614 tx_power := tx_power,
615 padding := '0000'O
616 }
617 }
618 }
619
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700620 /* 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 +0700621 private template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700622 ts_L1CTL_DM_EST_REQ(template (value) RslChannelNr chan_nr,
623 template (value) GsmTsc tsc) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100624 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200625 ul_info := {
626 chan_nr := chan_nr,
627 link_id := ts_RslLinkID_DCCH(0),
628 padding := '0000'O
629 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700630 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200631 payload := {
632 dm_est_req := {
633 tsc := tsc,
Vadim Yanitskiy0a3e31c2022-12-18 08:09:38 +0700634 h0h1 := -,
Vadim Yanitskiyfe052962020-10-19 13:27:09 +0700635 tch_mode := L1CTL_CHAN_MODE_SIGN,
Vadim Yanitskiy16185832020-10-19 21:20:43 +0700636 audio_mode := t_L1CTL_AudioModeFwd
Harald Welte9e4725d2017-07-16 23:18:09 +0200637 }
638 }
639 }
640
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700641 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700642 ts_L1CTL_DM_EST_REQ_H0(template (value) RslChannelNr chan_nr,
643 template (value) GsmTsc tsc,
644 template (value) GsmArfcn arfcn)
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700645 modifies ts_L1CTL_DM_EST_REQ := {
646 payload := {
647 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700648 h0h1 := {
649 h0 := {
650 h := 0,
Vadim Yanitskiy1acc7bb2020-11-14 04:24:57 +0700651 arfcn := ts_GsmBandArfcn(arfcn),
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700652 padding := f_pad_oct(''O, 130, '00'O)
653 }
654 }
Vadim Yanitskiy5afe8852020-05-27 14:40:51 +0700655 }
656 }
657 }
658
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700659 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700660 ts_L1CTL_DM_EST_REQ_H1(template (value) RslChannelNr chan_nr,
661 template (value) GsmTsc tsc,
662 template (value) uint6_t hsn,
663 template (value) uint6_t maio,
664 template (value) L1ctlMA ma)
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700665 modifies ts_L1CTL_DM_EST_REQ := {
666 payload := {
667 dm_est_req := {
Vadim Yanitskiy2cdb97f2020-10-19 14:17:38 +0700668 h0h1 := {
669 h1 := {
670 h := 1,
671 hsn := hsn,
672 maio := maio,
673 n := sizeof(ma),
674 spare := '00'O,
675 ma := ma,
676 /* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=562849 */
677 padding := f_pad_oct(''O, (64 - sizeof(ma)) * 2, '00'O)
678 }
Vadim Yanitskiyeda90812020-05-27 14:51:18 +0700679 }
680 }
681 }
682 }
683
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700684 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700685 ts_L1CTL_DM_REL_REQ(template (value) RslChannelNr chan_nr) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100686 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200687 ul_info := {
688 chan_nr := chan_nr,
689 link_id := ts_RslLinkID_DCCH(0),
690 padding := '0000'O
691 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700692 dl_info := omit,
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700693 payload := omit
Harald Welte9e4725d2017-07-16 23:18:09 +0200694 }
695
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700696 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700697 ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
698 template (value) RslLinkId link_id,
699 octetstring l2_data) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100700 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200701 ul_info := {
702 chan_nr := chan_nr,
703 link_id := link_id,
704 padding := '0000'O
705 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700706 dl_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200707 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700708 data_req := {
709 l1header := omit,
710 l2_payload := l2_data
711 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200712 }
713 }
714
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700715 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700716 ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
717 template (value) RslLinkId link_id,
718 template (value) SacchL1Header l1h,
719 octetstring l2_data) := {
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200720 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
721 ul_info := {
722 chan_nr := chan_nr,
723 link_id := link_id,
724 padding := '0000'O
725 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700726 dl_info := omit,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200727 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700728 data_req := {
729 l1header := l1h,
730 l2_payload := l2_data
731 }
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200732 }
733 }
734
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700735 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700736 ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
737 template (value) RslLinkId link_id,
738 octetstring frame) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700739 header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
740 ul_info := {
741 chan_nr := chan_nr,
742 link_id := link_id,
743 padding := '0000'O
744 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700745 dl_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700746 payload := {
747 traffic_req := {
748 data := frame
749 }
750 }
751 };
752
Harald Welte9e4725d2017-07-16 23:18:09 +0200753 /* for matching against incoming RACH_CONF */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700754 template L1ctlMessage tr_L1CTL_RACH_CONF := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100755 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700756 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200757 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200758 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200759 };
760
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700761 /* for sending and matching L1CTL_DATA_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700762 template (value) L1ctlMessage
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700763 ts_L1CTL_DATA_IND(template (value) RslChannelNr chan_nr,
764 template (value) RslLinkId link_id,
765 template (value) octetstring l2_data,
766 template (value) GsmBandArfcn arfcn,
767 template (value) uint32_t fn := 1337,
768 template (value) GsmRxLev rx_level := 63,
769 template (value) uint8_t num_biterr := 0,
770 template (value) uint8_t fire_crc := 0) := {
771 header := ts_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700772 ul_info := omit,
Vadim Yanitskiy60b61882022-12-18 06:02:22 +0700773 dl_info := {
774 chan_nr := chan_nr,
775 link_id := link_id,
776 arfcn := arfcn,
777 frame_nr := fn,
778 rx_level := rx_level,
779 snr := 0,
780 num_biterr := num_biterr,
781 fire_crc := fire_crc
782 },
783 payload := {
784 data_ind := {
785 payload := l2_data
786 }
787 }
788 };
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700789 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700790 tr_L1CTL_DATA_IND(template (present) RslChannelNr chan_nr,
791 template (present) RslLinkId link_id := ?,
792 template (present) octetstring l2_data := ?,
793 template (present) uint8_t num_biterr := 0,
794 template (present) uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100795 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700796 ul_info := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200797 dl_info := {
798 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100799 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200800 arfcn := ?,
801 frame_nr := ?,
802 rx_level := ?,
803 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100804 num_biterr := num_biterr,
Pau Espin Pedrol17da3232022-09-02 16:35:32 +0200805 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200806 },
807 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100808 data_ind := {
809 payload := l2_data
810 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200811 }
812 };
813
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700814 /* for matching against incoming TRAFFIC_IND */
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700815 template L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700816 tr_L1CTL_TRAFFIC_IND(template (present) RslChannelNr chan_nr,
817 template (present) RslLinkId link_id := ?,
818 template (present) octetstring frame := ?,
819 template (present) uint8_t num_biterr := ?,
820 template (present) uint8_t fire_crc := ?) := {
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700821 header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700822 ul_info := omit,
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700823 dl_info := {
824 chan_nr := chan_nr,
825 link_id := link_id,
826 arfcn := ?,
827 frame_nr := ?,
828 rx_level := ?,
829 snr := ?,
830 num_biterr := num_biterr,
831 fire_crc := fire_crc
832 },
833 payload := {
834 traffic_ind := {
835 data := frame
836 }
837 }
838 };
839
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700840 template (value) L1ctlMessage
Vadim Yanitskiybe33f6b2020-11-14 04:05:34 +0700841 ts_L1CTL_CRYPTO_REQ(template (value) RslChannelNr chan_nr,
842 template (value) uint8_t algo,
843 template (value) octetstring key) := {
Harald Weltee613f962018-04-18 22:38:16 +0200844 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
845 ul_info := {
846 chan_nr := chan_nr,
847 link_id := ts_RslLinkID_DCCH(0),
848 padding := '0000'O
849 },
Vadim Yanitskiyaf0aae62023-03-18 06:49:18 +0700850 dl_info := omit,
Harald Weltee613f962018-04-18 22:38:16 +0200851 payload := {
852 crypto_req := {
853 algo := algo,
854 key_len := 0, /* overwritten */
855 key := key
856 }
857 }
858 };
859
Vadim Yanitskiy72a76b52023-03-18 00:12:09 +0700860
861 template (value) L1ctlMessage
862 ts_L1CTL_GPRS_UL_TBF_CFG_REQ(template (value) uint8_t tbf_ref,
863 template (value) BIT8 slotmask := '00000000'B) := {
864 header := ts_L1ctlHeader(L1CTL_GPRS_UL_TBF_CFG_REQ),
865 ul_info := omit,
866 dl_info := omit,
867 payload := {
868 ul_tbf_cfg_req := {
869 tbf_ref := tbf_ref,
870 slotmask := slotmask,
871 pad := '0000'O
872 }
873 }
874 };
875 template L1ctlMessage
876 tr_L1CTL_GPRS_UL_TBF_CFG_REQ(template (present) uint8_t tbf_ref := ?,
877 template (present) BIT8 slotmask := ?) := {
878 header := tr_L1ctlHeader(L1CTL_GPRS_UL_TBF_CFG_REQ),
879 ul_info := omit,
880 dl_info := omit,
881 payload := {
882 ul_tbf_cfg_req := {
883 tbf_ref := tbf_ref,
884 slotmask := slotmask,
885 pad := ?
886 }
887 }
888 };
889
890 template (value) L1ctlMessage
891 ts_L1CTL_GPRS_DL_TBF_CFG_REQ(template (value) uint8_t tbf_ref,
892 template (value) BIT8 slotmask := '00000000'B,
893 template (value) uint5_t dl_tfi := 0) := {
894 header := ts_L1ctlHeader(L1CTL_GPRS_DL_TBF_CFG_REQ),
895 ul_info := omit,
896 dl_info := omit,
897 payload := {
898 dl_tbf_cfg_req := {
899 tbf_ref := tbf_ref,
900 slotmask := slotmask,
901 dl_tfi := dl_tfi,
902 pad := '00'O
903 }
904 }
905 };
906 template L1ctlMessage
907 tr_L1CTL_GPRS_DL_TBF_CFG_REQ(template (present) uint8_t tbf_ref := ?,
908 template (present) BIT8 slotmask := ?,
909 template (present) uint5_t dl_tfi := ?) := {
910 header := tr_L1ctlHeader(L1CTL_GPRS_DL_TBF_CFG_REQ),
911 ul_info := omit,
912 dl_info := omit,
913 payload := {
914 dl_tbf_cfg_req := {
915 tbf_ref := tbf_ref,
916 slotmask := slotmask,
917 dl_tfi := dl_tfi,
918 pad := ?
919 }
920 }
921 };
922
923 template (value) L1ctlMessage
924 ts_L1CTL_GPRS_UL_BLOCK_REQ(template (value) GsmFrameNumber fn,
925 template (value) uint3_t tn,
926 template (value) octetstring data) := {
927 header := ts_L1ctlHeader(L1CTL_GPRS_UL_BLOCK_REQ),
928 ul_info := omit,
929 dl_info := omit,
930 payload := {
931 ul_block_req := {
932 hdr := {
933 fn := fn,
934 tn := tn,
935 pad := '000000'O
936 },
937 data := data
938 }
939 }
940 };
941 template L1ctlMessage
942 tr_L1CTL_GPRS_UL_BLOCK_REQ(template (present) GsmFrameNumber fn := ?,
943 template (present) uint3_t tn := ?,
944 template (present) octetstring data := ?) := {
945 header := tr_L1ctlHeader(L1CTL_GPRS_UL_BLOCK_REQ),
946 ul_info := omit,
947 dl_info := omit,
948 payload := {
949 ul_block_req := {
950 hdr := {
951 fn := fn,
952 tn := tn,
953 pad := ?
954 },
955 data := data
956 }
957 }
958 };
959
960 template (value) L1ctlMessage
961 ts_L1CTL_GPRS_DL_BLOCK_IND(template (value) GsmFrameNumber fn,
962 template (value) uint3_t tn,
963 template (value) uint3_t usf,
964 template (value) octetstring data,
965 template (value) uint16_t ber10k := 0,
966 template (value) int16_t ci_cb := 180 /* 18 dB */,
967 template (value) GsmRxLev rx_level := 63) := {
968 header := ts_L1ctlHeader(L1CTL_GPRS_DL_BLOCK_IND),
969 ul_info := omit,
970 dl_info := omit,
971 payload := {
972 dl_block_ind := {
973 hdr := {
974 fn := fn,
975 tn := tn,
976 pad := '000000'O
977 },
978 meas := {
979 ber10k := ber10k,
980 ci_cb := ci_cb,
981 rx_level := rx_level
982 },
983 usf := usf,
984 data := data
985 }
986 }
987 };
988 template L1ctlMessage
989 tr_L1CTL_GPRS_DL_BLOCK_IND(template (present) GsmFrameNumber fn := ?,
990 template (present) uint3_t tn := ?,
991 template (present) uint3_t usf := ?,
992 template (present) octetstring data := ?,
993 template (present) uint16_t ber10k := ?,
994 template (present) int16_t ci_cb := ?,
995 template (present) GsmRxLev rx_level := ?) := {
996 header := tr_L1ctlHeader(L1CTL_GPRS_DL_BLOCK_IND),
997 ul_info := omit,
998 dl_info := omit,
999 payload := {
1000 dl_block_ind := {
1001 hdr := {
1002 fn := fn,
1003 tn := tn,
1004 pad := ?
1005 },
1006 meas := {
1007 ber10k := ber10k,
1008 ci_cb := ci_cb,
1009 rx_level := rx_level
1010 },
1011 usf := usf,
1012 data := data
1013 }
1014 }
1015 };
1016
Harald Welte68e495b2018-02-25 00:05:57 +01001017 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
1018
Harald Welte7024baa2018-03-02 23:37:51 +01001019/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
1020 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +02001021} with { encode "RAW" };