blob: e939f72272521ff8980fce0b8d10fc64f70b89ae [file] [log] [blame]
Harald Weltef6543322017-07-16 07:35:10 +02001/* Data Types / Encoding / Decoding for OsmocomBB L1CTL interface */
2/* (C) 2017 by Harald Welte <laforge@gnumonks.org>, derived from l1ctl_proto.h
Harald Welte34b5a952019-05-27 11:54:11 +02003 * which is (C) 2010 by Harald Welte + Holger Hans Peter Freyther
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
Harald Weltef6543322017-07-16 07:35:10 +020012module L1CTL_Types {
13
14 import from General_Types all;
15 import from GSM_Types all;
Harald Welte9419c8a2017-07-30 04:07:05 +020016 import from GSM_RR_Types all;
Harald Weltef6543322017-07-16 07:35:10 +020017 import from Osmocom_Types all;
18
Harald Welte7024baa2018-03-02 23:37:51 +010019 type uint32_t uint32_le with { variant "BYTEORDER(first)" };
20
Harald Weltef6543322017-07-16 07:35:10 +020021 type enumerated L1ctlMsgType {
22 L1CTL_NONE,
23 L1CTL_FBSB_REQ,
24 L1CTL_FBSB_CONF,
25 L1CTL_DATA_IND,
26 L1CTL_RACH_REQ,
27 L1CTL_DM_EST_REQ,
28 L1CTL_DATA_REQ,
29 L1CTL_RESET_IND,
30 L1CTL_PM_REQ, /* power measurement */
31 L1CTL_PM_CONF, /* power measurement */
32 L1CTL_ECHO_REQ,
33 L1CTL_ECHO_CONF,
34 L1CTL_RACH_CONF,
35 L1CTL_RESET_REQ,
36 L1CTL_RESET_CONF,
37 L1CTL_DATA_CONF,
38 L1CTL_CCCH_MODE_REQ,
39 L1CTL_CCCH_MODE_CONF,
40 L1CTL_DM_REL_REQ,
41 L1CTL_PARAM_REQ,
42 L1CTL_DM_FREQ_REQ,
43 L1CTL_CRYPTO_REQ,
44 L1CTL_SIM_REQ,
45 L1CTL_SIM_CONF,
46 L1CTL_TCH_MODE_REQ,
47 L1CTL_TCH_MODE_CONF,
48 L1CTL_NEIGH_PM_REQ,
49 L1CTL_NEIGH_PM_IND,
50 L1CTL_TRAFFIC_REQ,
51 L1CTL_TRAFFIC_CONF,
Harald Welte00d4dac2017-07-30 00:50:32 +020052 L1CTL_TRAFFIC_IND,
Vadim Yanitskiy4e79ff52019-04-22 06:38:21 +070053 L1CTL_BURST_IND,
Harald Welte00d4dac2017-07-30 00:50:32 +020054 L1CTL_TBF_CFG_REQ,
Harald Welteb3c226e2017-07-30 17:18:01 +020055 L1CTL_TBF_CFG_CONF,
56 L1CTL_DATA_TBF_REQ,
Harald Welte3a40ec72018-03-02 20:45:04 +010057 L1CTL_DATA_TBF_CONF,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +070058 L1CTL_EXT_RACH_REQ,
59 L1CTL_DATA_ABS_REQ /*!< FIXME: no such message in OsmocomBB */
Harald Weltef6543322017-07-16 07:35:10 +020060 } with { variant "FIELDLENGTH(8)" };
61
62 type enumerated L1ctlCcchMode {
63 CCCH_MODE_NONE (0),
64 CCCH_MODE_NON_COMBINED,
Harald Welte990a3612019-05-27 14:02:13 +020065 CCCH_MODE_COMBINED,
66 CCCH_MODE_COMBINED_CBCH
Harald Weltef6543322017-07-16 07:35:10 +020067 } with { variant "FIELDLENGTH(8)" };
68
69 type enumerated L1ctlNeighMode {
70 NEIGH_MODE_NONE (0),
71 NEIGH_MODE_PM,
72 NEIGH_MODE_SB
73 } with { variant "FIELDLENGTH(8)" };
74
Harald Welte1dcc3712017-08-01 00:05:52 +020075 type enumerated L1ctlGprsCs {
76 L1CTL_CS1 (1),
77 L1CTL_CS2,
78 L1CTL_CS3,
79 L1CTL_CS4,
80 L1CTL_MCS1,
81 L1CTL_MCS2,
82 L1CTL_MCS3,
83 L1CTL_MCS4,
84 L1CTL_MCS5,
85 L1CTL_MCS6,
86 L1CTL_MCS7,
87 L1CTL_MCS8,
88 L1CTL_MCS9
89 } with { variant "FIELDLENGTH(8)" };
90
Harald Weltef6543322017-07-16 07:35:10 +020091 type enumerated L1ctlResetType {
92 L1CTL_RES_T_BOOT (0),
93 L1CTL_RES_T_FULL,
94 L1CTL_RES_T_SCHED
95 } with { variant "FIELDLENGTH(8)" };
96
Harald Weltef6543322017-07-16 07:35:10 +020097 type record L1ctlHdrFlags {
98 BIT7 padding,
99 boolean f_done
100 } with { variant "" };
101
102 type record L1ctlHeader {
103 L1ctlMsgType msg_type,
104 L1ctlHdrFlags flags,
105 OCT2 padding
106 } with { variant "" };
107
Harald Weltef8df4cb2018-03-10 15:15:08 +0100108 template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := {
109 msg_type := msg_type,
110 flags := ?,
111 padding := ?
112 };
113
114 template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +0200115 msg_type := msg_type,
116 flags := { padding := '0000000'B, f_done := false },
117 padding := '0000'O
118 };
119
Harald Weltef6543322017-07-16 07:35:10 +0200120 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200121 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200122 RslLinkId link_id,
123 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200124 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200125 GsmRxLev rx_level,
126 uint8_t snr,
127 uint8_t num_biterr,
128 uint8_t fire_crc
129 } with { variant "" };
130
131 type record L1ctlFbsbConf {
132 int16_t initial_freq_err,
133 uint8_t result,
134 uint8_t bsic
135 } with { variant "" };
136
137 type record L1ctlCcchModeConf {
138 L1ctlCcchMode ccch_mode,
139 OCT3 padding
140 } with { variant "" };
141
142 /* gsm48_chan_mode */
143 type uint8_t L1ctlTchMode;
144
145 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
Harald Weltef6543322017-07-16 07:35:10 +0200155 type record L1ctlTchModeConf {
156 L1ctlTchMode tch_mode,
157 L1ctlAudioMode audio_mode,
158 OCT2 padding
159 } with { variant "" };
160
161 type record L1ctlDataInd {
Vadim Yanitskiy2a92e2a2019-05-28 21:13:35 +0700162 octetstring payload
Harald Welte7024baa2018-03-02 23:37:51 +0100163 } with {
164 variant (payload) "BYTEORDER(first)"
165 };
Harald Weltef6543322017-07-16 07:35:10 +0200166
167 type union L1ctlDlPayload {
168 L1ctlFbsbConf fbsb_conf,
169 L1ctlCcchModeConf ccch_mode_conf,
170 L1ctlTchModeConf tch_mode_conf,
171 L1ctlDataInd data_ind,
172 L1ctlTrafficReq traffic_ind,
Harald Welte00d4dac2017-07-30 00:50:32 +0200173 L1ctlTbfCfgReq tbf_cfg_conf,
Harald Weltef6543322017-07-16 07:35:10 +0200174 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100175 } with {
176 variant (other) "BYTEORDER(first)"
177 };
Harald Weltef6543322017-07-16 07:35:10 +0200178
179 type record L1ctlDlMessage {
180 L1ctlHeader header,
181 L1ctlDlInfo dl_info optional,
Harald Weltef56cc492018-04-15 10:58:43 +0200182 L1ctlDlPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200183 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
184 header.msg_type = L1CTL_RACH_CONF,
185 header.msg_type = L1CTL_DATA_IND,
186 header.msg_type = L1CTL_DATA_CONF,
Harald Welte3c4cbf62018-03-30 10:31:39 +0200187 header.msg_type = L1CTL_TRAFFIC_IND,
188 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200189 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
190 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
191 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
192 data_ind, header.msg_type = L1CTL_DATA_IND;
193 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
Harald Welte00d4dac2017-07-30 00:50:32 +0200194 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
Harald Weltef6543322017-07-16 07:35:10 +0200195 other, OTHERWISE;
196 )" };
197
198 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
199 with { extension "prototype(convert) encode(RAW)" };
200 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
201 with { extension "prototype(convert) decode(RAW)" };
202
203
204 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200205 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200206 RslLinkId link_id,
207 OCT2 padding
208 } with { variant "" };
209
Harald Welteb3c226e2017-07-30 17:18:01 +0200210 type record L1ctlUlTbfInfo {
211 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200212 L1ctlGprsCs cs,
213 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200214 } with { variant "" };
215
Harald Welte3a40ec72018-03-02 20:45:04 +0100216 type record L1ctlUlAbsInfo {
217 uint8_t tbf_nr,
218 L1ctlGprsCs cs,
219 uint8_t ts_nr,
220 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100221 uint32_le fn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100222 Arfcn arfcn,
223 OCT2 padding2
224 } with { variant "" };
225
Harald Weltef6543322017-07-16 07:35:10 +0200226 type record L1ctlFbsbFlags {
227 BIT5 padding,
228 boolean sb,
229 boolean fb1,
230 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100231 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200232
Harald Weltef8df4cb2018-03-10 15:15:08 +0100233 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200234 padding := '00000'B,
235 sb := true,
236 fb1 := true,
237 fb0 := true
238 };
239
Harald Weltef6543322017-07-16 07:35:10 +0200240 type record L1ctlFbsbReq {
241 Arfcn arfcn,
242 uint16_t timeout_tdma_frames,
243 uint16_t freq_err_thresh1,
244 uint16_t freq_err_thresh2,
245 uint8_t num_freqerr_avg,
246 L1ctlFbsbFlags flags,
247 uint8_t sync_info_idx,
248 L1ctlCcchMode ccch_mode,
249 GsmRxLev rxlev_exp
250 } with { variant "" };
251
252 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100253 L1ctlCcchMode ccch_mode,
254 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200255 } with { variant "" };
256
257 type record L1ctlTchModeReq {
258 L1ctlTchMode tch_mode,
259 L1ctlAudioMode audio_mode,
260 OCT2 padding
261 } with { variant "" };
262
263 type record L1ctlRachReq {
264 uint8_t ra,
265 uint8_t combined,
266 uint16_t offset
267 } with { variant "" };
268
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700269 type enumerated L1ctlRachSynchSeq {
270 RACH_SYNCH_SEQ_TS0 (0),
271 RACH_SYNCH_SEQ_TS1,
272 RACH_SYNCH_SEQ_TS2
273 } with { variant "FIELDLENGTH(8)" };
274
275 type record L1ctlExtRachReq {
276 uint16_t ra11,
277 L1ctlRachSynchSeq synch_seq,
278 uint8_t combined,
279 uint16_t offset
280 } with { variant "" };
281
Harald Weltef6543322017-07-16 07:35:10 +0200282 type record L1ctlParReq {
283 int8_t ta,
284 uint8_t tx_power,
285 OCT2 padding
286 } with { variant "" };
287
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200288 type record L1ctlDataReq {
289 SacchL1Header l1header optional,
290 octetstring l2_payload
291 } with { variant "" };
292
Harald Weltef6543322017-07-16 07:35:10 +0200293 type record L1ctlH1 {
294 uint8_t hsn,
295 uint8_t maio,
296 uint8_t n,
297 OCT1 padding,
298 bitstring ma length(64)
299 } with { variant "" };
300
301 type record L1ctlDmEstReq {
302 GsmTsc tsc,
303 uint8_t h,
304 Arfcn arfcn optional,
305 L1ctlH1 hopping optional,
306 L1ctlTchMode tch_mode,
307 L1ctlAudioMode audio_mode
308 } with { variant (arfcn) "PRESENCE(h = 0)"
309 variant (hopping) "PRESENCE(h = 1)" };
310
311 type record L1ctlReset {
312 L1ctlResetType reset_type,
313 OCT3 padding
314 } with { variant "" };
315
Harald Weltee613f962018-04-18 22:38:16 +0200316 type record L1CtlCryptoReq {
317 uint8_t algo,
318 uint8_t key_len,
319 octetstring key
320 } with { variant (key_len) "LENGTHTO(key)" };
321
Harald Weltef6543322017-07-16 07:35:10 +0200322
323 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700324 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100325 } with {
326 variant (data) "BYTEORDER(first)"
327 }
Harald Weltef6543322017-07-16 07:35:10 +0200328
Harald Welte00d4dac2017-07-30 00:50:32 +0200329 type record length(8) of uint8_t TfiUsfArr;
330
331 type record L1ctlTbfCfgReq {
332 uint8_t tbf_nr,
333 boolean is_uplink,
334 OCT2 padding,
335 TfiUsfArr tfi_usf
336 } with { variant (is_uplink) "FIELDLENGTH(8)" };
337
Harald Weltef6543322017-07-16 07:35:10 +0200338 type union L1ctlUlPayload {
339 L1ctlFbsbReq fbsb_req,
340 L1ctlCcchModeReq ccch_mode_req,
341 L1ctlTchModeReq tch_mode_req,
342 L1ctlRachReq rach_req,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700343 L1ctlExtRachReq ext_rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200344 L1ctlParReq par_req,
345 L1ctlDmEstReq dm_est_req,
346 L1ctlReset reset_req,
347 //L1ctlNeighPmReq neigh_pm_req,
Harald Weltee613f962018-04-18 22:38:16 +0200348 L1CtlCryptoReq crypto_req,
Harald Weltef6543322017-07-16 07:35:10 +0200349 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200350 L1ctlTbfCfgReq tbf_cfg_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200351 L1ctlDataReq data_req,
Harald Weltef6543322017-07-16 07:35:10 +0200352 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100353 } with {
354 variant (other) "BYTEORDER(first)"
355 };
Harald Weltef6543322017-07-16 07:35:10 +0200356
357 type record L1ctlUlMessage {
358 L1ctlHeader header,
359 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200360 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100361 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200362 L1ctlUlPayload payload
363 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700364 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200365 header.msg_type = L1CTL_PARAM_REQ,
366 header.msg_type = L1CTL_CRYPTO_REQ,
367 header.msg_type = L1CTL_DATA_REQ,
368 header.msg_type = L1CTL_DM_EST_REQ,
369 header.msg_type = L1CTL_DM_FREQ_REQ,
370 header.msg_type = L1CTL_DM_REL_REQ,
371 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200372 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100373 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200374 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
375 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
376 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
377 rach_req, header.msg_type = L1CTL_RACH_REQ;
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700378 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200379 par_req, header.msg_type = L1CTL_PARAM_REQ;
380 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
381 reset_req, header.msg_type = L1CTL_RESET_REQ;
Harald Weltee613f962018-04-18 22:38:16 +0200382 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200383 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200384 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200385 data_req, header.msg_type = L1CTL_DATA_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200386 other, OTHERWISE;
387 )" };
388
389 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
390 with { extension "prototype(convert) encode(RAW)" };
391 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
392 with { extension "prototype(convert) decode(RAW)" };
393
Harald Welte52c713c2017-07-16 15:44:44 +0200394 type record L1ctlUlMessageLV {
395 uint16_t len,
396 L1ctlUlMessage msg
397 } with { variant (len) "LENGTHTO(msg)" };
398
399 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
400 with { extension "prototype(convert) encode(RAW)" };
401 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
402 with { extension "prototype(convert) decode(RAW)" };
403
404 type record L1ctlDlMessageLV {
405 uint16_t len,
406 L1ctlDlMessage msg
407 } with { variant (len) "LENGTHTO(msg)" };
408
409 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
410 with { extension "prototype(convert) encode(RAW)" };
411 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
412 with { extension "prototype(convert) decode(RAW)" };
413
414
Harald Welte9e4725d2017-07-16 23:18:09 +0200415
416
417 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100418 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
419 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200420 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200421 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100422 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200423 payload := {
424 reset_req := {
425 reset_type := rst_type,
426 padding := '000000'O
427 }
428 }
429 };
430
431 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100432 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
433 uint8_t sync_info_idx,
434 L1ctlCcchMode ccch_mode,
435 GsmRxLev rxlev_exp) := {
436 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200437 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200438 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100439 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200440 payload := {
441 fbsb_req := {
442 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100443 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200444 freq_err_thresh1 := 10000,
445 freq_err_thresh2 := 800,
446 num_freqerr_avg := 3,
447 flags := flags,
448 sync_info_idx := sync_info_idx,
449 ccch_mode := ccch_mode,
450 rxlev_exp := rxlev_exp
451 }
452 }
453 };
454
455 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100456 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
457 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200458 dl_info := ?,
459 payload := {
460 fbsb_conf := {
461 initial_freq_err := ?,
462 result := result,
463 bsic := ?
464 }
465 }
466 };
467
Harald Weltef8df4cb2018-03-10 15:15:08 +0100468 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
469 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
470 ul_info := omit,
471 ul_info_tbf := omit,
472 ul_info_abs := omit,
473 payload := {
474 ccch_mode_req := {
475 ccch_mode := ccch_mode,
476 padding := '000000'O
477 }
478 }
479 };
480
Harald Welte3757e602018-03-10 17:12:02 +0100481
482 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
483 header := tr_L1ctlHeader(msg_type),
484 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200485 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100486 }
487
488 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100489
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700490 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset,
491 template (value) RslChannelNr chan_nr := ts_RslChanNr_RACH(0),
492 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0)) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100493 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200494 ul_info := {
Vadim Yanitskiye432ba92019-05-31 18:44:13 +0700495 chan_nr := chan_nr,
496 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200497 padding := '0000'O
498 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200499 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100500 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200501 payload := {
502 rach_req := {
503 ra := ra,
504 combined := combined,
505 offset := offset
506 }
507 }
508 }
509
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700510 template L1ctlUlMessage ts_L1CTL_EXT_RACH_REQ(
511 uint16_t ra11, L1ctlRachSynchSeq seq,
512 uint8_t combined, uint16_t offset
513 ) := {
514 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
515 ul_info := {
516 /* FIXME: both RSL chan_nr and link_id should be configurable */
517 chan_nr := t_RslChanNr_RACH(0),
518 link_id := ts_RslLinkID_DCCH(0),
519 padding := '0000'O
520 },
521 ul_info_tbf := omit,
522 ul_info_abs := omit,
523 payload := {
524 ext_rach_req := {
525 ra11 := ra11,
526 synch_seq := seq,
527 combined := combined,
528 offset := offset
529 }
530 }
531 }
532
Harald Weltef8df4cb2018-03-10 15:15:08 +0100533 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
534 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100535 ul_info := {
536 chan_nr := t_RslChanNr_RACH(0),
537 link_id := ts_RslLinkID_DCCH(0),
538 padding := '0000'O
539 },
540 ul_info_tbf := omit,
541 ul_info_abs := omit,
542 payload := {
543 par_req := {
544 ta := ta,
545 tx_power := tx_power,
546 padding := '0000'O
547 }
548 }
549 }
550
Harald Weltef8df4cb2018-03-10 15:15:08 +0100551 template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
552 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200553 ul_info := {
554 chan_nr := chan_nr,
555 link_id := ts_RslLinkID_DCCH(0),
556 padding := '0000'O
557 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200558 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100559 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200560 payload := {
561 dm_est_req := {
562 tsc := tsc,
563 h := 0,
564 arfcn := arfcn,
565 hopping := omit,
566 tch_mode := 0,
567 audio_mode := t_L1CTL_AudioModeNone
568 }
569 }
570 }
571
Harald Weltef8df4cb2018-03-10 15:15:08 +0100572 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
573 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200574 ul_info := {
575 chan_nr := chan_nr,
576 link_id := ts_RslLinkID_DCCH(0),
577 padding := '0000'O
578 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200579 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100580 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200581 payload := {
582 other := ''O
583 }
584 }
585
Harald Weltef8df4cb2018-03-10 15:15:08 +0100586 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
587 template (value) RslLinkId link_id,
588 octetstring l2_data) := {
589 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200590 ul_info := {
591 chan_nr := chan_nr,
592 link_id := link_id,
593 padding := '0000'O
594 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200595 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100596 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200597 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700598 data_req := {
599 l1header := omit,
600 l2_payload := l2_data
601 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200602 }
603 }
604
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200605 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
606 template (value) RslLinkId link_id,
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700607 template (value) SacchL1Header l1h,
608 octetstring l2_data) := {
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200609 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
610 ul_info := {
611 chan_nr := chan_nr,
612 link_id := link_id,
613 padding := '0000'O
614 },
615 ul_info_tbf := omit,
616 ul_info_abs := omit,
617 payload := {
Vadim Yanitskiy0a8d6da2019-05-28 22:18:28 +0700618 data_req := {
619 l1header := l1h,
620 l2_payload := l2_data
621 }
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200622 }
623 }
624
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700625 template (value) L1ctlUlMessage ts_L1CTL_TRAFFIC_REQ(template (value) RslChannelNr chan_nr,
626 template (value) RslLinkId link_id,
627 octetstring frame) := {
628 header := ts_L1ctlHeader(L1CTL_TRAFFIC_REQ),
629 ul_info := {
630 chan_nr := chan_nr,
631 link_id := link_id,
632 padding := '0000'O
633 },
634 ul_info_tbf := omit,
635 ul_info_abs := omit,
636 payload := {
637 traffic_req := {
638 data := frame
639 }
640 }
641 };
642
Harald Weltef8df4cb2018-03-10 15:15:08 +0100643 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
644 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200645 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200646 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100647 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200648 payload := {
649 tbf_cfg_req := {
650 tbf_nr := 0,
651 is_uplink := is_uplink,
652 padding := '0000'O,
653 tfi_usf := tfi_usf
654 }
655 }
656 };
657
Harald Weltef8df4cb2018-03-10 15:15:08 +0100658 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
659 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200660 dl_info := omit,
661 payload := {
662 tbf_cfg_conf := {
663 tbf_nr := 0,
664 is_uplink := is_uplink,
665 padding := ?,
666 tfi_usf := ?
667 }
668 }
669 };
670
Harald Weltef8df4cb2018-03-10 15:15:08 +0100671 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
672 L1ctlGprsCs cs := L1CTL_CS1,
673 uint8_t tbf_nr := 0) := {
674 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200675 ul_info := omit,
676 ul_info_tbf := {
677 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200678 cs := cs,
679 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200680 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100681 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200682 payload := {
683 other := l2_data
684 }
685 }
686
Harald Weltef8df4cb2018-03-10 15:15:08 +0100687 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100688 uint8_t ts, GsmFrameNumber fn,
689 L1ctlGprsCs cs := L1CTL_CS1,
690 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100691 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100692 ul_info := omit,
693 ul_info_tbf := omit,
694 ul_info_abs := {
695 tbf_nr := tbf_nr,
696 cs := cs,
697 ts_nr := ts,
698 padding := '00'O,
699 fn := fn,
700 arfcn := arfcn,
701 padding2 := '0000'O
702 },
703 payload := {
704 other := l2_data
705 }
706 }
707
708
Harald Welte9e4725d2017-07-16 23:18:09 +0200709 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100710 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
711 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200712 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200713 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200714 };
715
Harald Weltece6dc442018-02-21 22:00:21 +0100716 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100717 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100718 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100719 template octetstring l2_data := ?,
720 template uint8_t num_biterr := 0,
721 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100722 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200723 dl_info := {
724 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100725 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200726 arfcn := ?,
727 frame_nr := ?,
728 rx_level := ?,
729 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100730 num_biterr := num_biterr,
731 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200732 },
733 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100734 data_ind := {
735 payload := l2_data
736 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200737 }
738 };
739
Vadim Yanitskiyf3cc6492019-06-30 16:34:30 +0700740 /* for matching against incoming TRAFFIC_IND */
741 template L1ctlDlMessage tr_L1CTL_TRAFFIC_IND(template RslChannelNr chan_nr,
742 template RslLinkId link_id := ?,
743 template octetstring frame := ?,
744 template uint8_t num_biterr := 0,
745 template uint8_t fire_crc := 0) := {
746 header := tr_L1ctlHeader(L1CTL_TRAFFIC_IND),
747 dl_info := {
748 chan_nr := chan_nr,
749 link_id := link_id,
750 arfcn := ?,
751 frame_nr := ?,
752 rx_level := ?,
753 snr := ?,
754 num_biterr := num_biterr,
755 fire_crc := fire_crc
756 },
757 payload := {
758 traffic_ind := {
759 data := frame
760 }
761 }
762 };
763
Harald Weltee613f962018-04-18 22:38:16 +0200764 template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
765 octetstring key) := {
766 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
767 ul_info := {
768 chan_nr := chan_nr,
769 link_id := ts_RslLinkID_DCCH(0),
770 padding := '0000'O
771 },
772 ul_info_tbf := omit,
773 ul_info_abs := omit,
774 payload := {
775 crypto_req := {
776 algo := algo,
777 key_len := 0, /* overwritten */
778 key := key
779 }
780 }
781 };
782
Harald Welte68e495b2018-02-25 00:05:57 +0100783 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
784
Harald Welte7024baa2018-03-02 23:37:51 +0100785/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
786 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200787} with { encode "RAW" };