blob: 6ffbbb88e8343a5bb9ced9be6308574cb8c9cc07 [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
3 * (C) 2010 by Harald Welte + Holger Hans Peter Freyther */
4module L1CTL_Types {
5
6 import from General_Types all;
7 import from GSM_Types all;
Harald Welte9419c8a2017-07-30 04:07:05 +02008 import from GSM_RR_Types all;
Harald Weltef6543322017-07-16 07:35:10 +02009 import from Osmocom_Types all;
10
Harald Welte7024baa2018-03-02 23:37:51 +010011 type uint32_t uint32_le with { variant "BYTEORDER(first)" };
12
Harald Weltef6543322017-07-16 07:35:10 +020013 type enumerated L1ctlMsgType {
14 L1CTL_NONE,
15 L1CTL_FBSB_REQ,
16 L1CTL_FBSB_CONF,
17 L1CTL_DATA_IND,
18 L1CTL_RACH_REQ,
19 L1CTL_DM_EST_REQ,
20 L1CTL_DATA_REQ,
21 L1CTL_RESET_IND,
22 L1CTL_PM_REQ, /* power measurement */
23 L1CTL_PM_CONF, /* power measurement */
24 L1CTL_ECHO_REQ,
25 L1CTL_ECHO_CONF,
26 L1CTL_RACH_CONF,
27 L1CTL_RESET_REQ,
28 L1CTL_RESET_CONF,
29 L1CTL_DATA_CONF,
30 L1CTL_CCCH_MODE_REQ,
31 L1CTL_CCCH_MODE_CONF,
32 L1CTL_DM_REL_REQ,
33 L1CTL_PARAM_REQ,
34 L1CTL_DM_FREQ_REQ,
35 L1CTL_CRYPTO_REQ,
36 L1CTL_SIM_REQ,
37 L1CTL_SIM_CONF,
38 L1CTL_TCH_MODE_REQ,
39 L1CTL_TCH_MODE_CONF,
40 L1CTL_NEIGH_PM_REQ,
41 L1CTL_NEIGH_PM_IND,
42 L1CTL_TRAFFIC_REQ,
43 L1CTL_TRAFFIC_CONF,
Harald Welte00d4dac2017-07-30 00:50:32 +020044 L1CTL_TRAFFIC_IND,
Vadim Yanitskiy4e79ff52019-04-22 06:38:21 +070045 L1CTL_BURST_IND,
Harald Welte00d4dac2017-07-30 00:50:32 +020046 L1CTL_TBF_CFG_REQ,
Harald Welteb3c226e2017-07-30 17:18:01 +020047 L1CTL_TBF_CFG_CONF,
48 L1CTL_DATA_TBF_REQ,
Harald Welte3a40ec72018-03-02 20:45:04 +010049 L1CTL_DATA_TBF_CONF,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +070050 L1CTL_EXT_RACH_REQ,
51 L1CTL_DATA_ABS_REQ /*!< FIXME: no such message in OsmocomBB */
Harald Weltef6543322017-07-16 07:35:10 +020052 } with { variant "FIELDLENGTH(8)" };
53
54 type enumerated L1ctlCcchMode {
55 CCCH_MODE_NONE (0),
56 CCCH_MODE_NON_COMBINED,
57 CCCH_MODE_COMBINED
58 } with { variant "FIELDLENGTH(8)" };
59
60 type enumerated L1ctlNeighMode {
61 NEIGH_MODE_NONE (0),
62 NEIGH_MODE_PM,
63 NEIGH_MODE_SB
64 } with { variant "FIELDLENGTH(8)" };
65
Harald Welte1dcc3712017-08-01 00:05:52 +020066 type enumerated L1ctlGprsCs {
67 L1CTL_CS1 (1),
68 L1CTL_CS2,
69 L1CTL_CS3,
70 L1CTL_CS4,
71 L1CTL_MCS1,
72 L1CTL_MCS2,
73 L1CTL_MCS3,
74 L1CTL_MCS4,
75 L1CTL_MCS5,
76 L1CTL_MCS6,
77 L1CTL_MCS7,
78 L1CTL_MCS8,
79 L1CTL_MCS9
80 } with { variant "FIELDLENGTH(8)" };
81
Harald Weltef6543322017-07-16 07:35:10 +020082 type enumerated L1ctlResetType {
83 L1CTL_RES_T_BOOT (0),
84 L1CTL_RES_T_FULL,
85 L1CTL_RES_T_SCHED
86 } with { variant "FIELDLENGTH(8)" };
87
Harald Weltef6543322017-07-16 07:35:10 +020088 type record L1ctlHdrFlags {
89 BIT7 padding,
90 boolean f_done
91 } with { variant "" };
92
93 type record L1ctlHeader {
94 L1ctlMsgType msg_type,
95 L1ctlHdrFlags flags,
96 OCT2 padding
97 } with { variant "" };
98
Harald Weltef8df4cb2018-03-10 15:15:08 +010099 template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := {
100 msg_type := msg_type,
101 flags := ?,
102 padding := ?
103 };
104
105 template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +0200106 msg_type := msg_type,
107 flags := { padding := '0000000'B, f_done := false },
108 padding := '0000'O
109 };
110
Harald Weltef6543322017-07-16 07:35:10 +0200111 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200112 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200113 RslLinkId link_id,
114 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200115 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200116 GsmRxLev rx_level,
117 uint8_t snr,
118 uint8_t num_biterr,
119 uint8_t fire_crc
120 } with { variant "" };
121
122 type record L1ctlFbsbConf {
123 int16_t initial_freq_err,
124 uint8_t result,
125 uint8_t bsic
126 } with { variant "" };
127
128 type record L1ctlCcchModeConf {
129 L1ctlCcchMode ccch_mode,
130 OCT3 padding
131 } with { variant "" };
132
133 /* gsm48_chan_mode */
134 type uint8_t L1ctlTchMode;
135
136 type record L1ctlAudioMode {
137 BIT4 padding,
138 boolean tx_microphone,
139 boolean tx_traffic_req,
140 boolean rx_speaker,
141 boolean rx_traffic_ind
142 } with { variant "" };
143
Harald Weltef8df4cb2018-03-10 15:15:08 +0100144 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200145
Harald Weltef6543322017-07-16 07:35:10 +0200146 type record L1ctlTchModeConf {
147 L1ctlTchMode tch_mode,
148 L1ctlAudioMode audio_mode,
149 OCT2 padding
150 } with { variant "" };
151
152 type record L1ctlDataInd {
153 octetstring payload length(23)
Harald Welte7024baa2018-03-02 23:37:51 +0100154 } with {
155 variant (payload) "BYTEORDER(first)"
156 };
Harald Weltef6543322017-07-16 07:35:10 +0200157
158 type union L1ctlDlPayload {
159 L1ctlFbsbConf fbsb_conf,
160 L1ctlCcchModeConf ccch_mode_conf,
161 L1ctlTchModeConf tch_mode_conf,
162 L1ctlDataInd data_ind,
163 L1ctlTrafficReq traffic_ind,
Harald Welte00d4dac2017-07-30 00:50:32 +0200164 L1ctlTbfCfgReq tbf_cfg_conf,
Harald Weltef6543322017-07-16 07:35:10 +0200165 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100166 } with {
167 variant (other) "BYTEORDER(first)"
168 };
Harald Weltef6543322017-07-16 07:35:10 +0200169
170 type record L1ctlDlMessage {
171 L1ctlHeader header,
172 L1ctlDlInfo dl_info optional,
Harald Weltef56cc492018-04-15 10:58:43 +0200173 L1ctlDlPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200174 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
175 header.msg_type = L1CTL_RACH_CONF,
176 header.msg_type = L1CTL_DATA_IND,
177 header.msg_type = L1CTL_DATA_CONF,
Harald Welte3c4cbf62018-03-30 10:31:39 +0200178 header.msg_type = L1CTL_TRAFFIC_IND,
179 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200180 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
181 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
182 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
183 data_ind, header.msg_type = L1CTL_DATA_IND;
184 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
Harald Welte00d4dac2017-07-30 00:50:32 +0200185 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
Harald Weltef6543322017-07-16 07:35:10 +0200186 other, OTHERWISE;
187 )" };
188
189 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
190 with { extension "prototype(convert) encode(RAW)" };
191 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
192 with { extension "prototype(convert) decode(RAW)" };
193
194
195 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200196 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200197 RslLinkId link_id,
198 OCT2 padding
199 } with { variant "" };
200
Harald Welteb3c226e2017-07-30 17:18:01 +0200201 type record L1ctlUlTbfInfo {
202 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200203 L1ctlGprsCs cs,
204 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200205 } with { variant "" };
206
Harald Welte3a40ec72018-03-02 20:45:04 +0100207 type record L1ctlUlAbsInfo {
208 uint8_t tbf_nr,
209 L1ctlGprsCs cs,
210 uint8_t ts_nr,
211 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100212 uint32_le fn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100213 Arfcn arfcn,
214 OCT2 padding2
215 } with { variant "" };
216
Harald Weltef6543322017-07-16 07:35:10 +0200217 type record L1ctlFbsbFlags {
218 BIT5 padding,
219 boolean sb,
220 boolean fb1,
221 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100222 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200223
Harald Weltef8df4cb2018-03-10 15:15:08 +0100224 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200225 padding := '00000'B,
226 sb := true,
227 fb1 := true,
228 fb0 := true
229 };
230
Harald Weltef6543322017-07-16 07:35:10 +0200231 type record L1ctlFbsbReq {
232 Arfcn arfcn,
233 uint16_t timeout_tdma_frames,
234 uint16_t freq_err_thresh1,
235 uint16_t freq_err_thresh2,
236 uint8_t num_freqerr_avg,
237 L1ctlFbsbFlags flags,
238 uint8_t sync_info_idx,
239 L1ctlCcchMode ccch_mode,
240 GsmRxLev rxlev_exp
241 } with { variant "" };
242
243 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100244 L1ctlCcchMode ccch_mode,
245 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200246 } with { variant "" };
247
248 type record L1ctlTchModeReq {
249 L1ctlTchMode tch_mode,
250 L1ctlAudioMode audio_mode,
251 OCT2 padding
252 } with { variant "" };
253
254 type record L1ctlRachReq {
255 uint8_t ra,
256 uint8_t combined,
257 uint16_t offset
258 } with { variant "" };
259
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700260 type enumerated L1ctlRachSynchSeq {
261 RACH_SYNCH_SEQ_TS0 (0),
262 RACH_SYNCH_SEQ_TS1,
263 RACH_SYNCH_SEQ_TS2
264 } with { variant "FIELDLENGTH(8)" };
265
266 type record L1ctlExtRachReq {
267 uint16_t ra11,
268 L1ctlRachSynchSeq synch_seq,
269 uint8_t combined,
270 uint16_t offset
271 } with { variant "" };
272
Harald Weltef6543322017-07-16 07:35:10 +0200273 type record L1ctlParReq {
274 int8_t ta,
275 uint8_t tx_power,
276 OCT2 padding
277 } with { variant "" };
278
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200279 type record L1ctlDataReq {
280 SacchL1Header l1header optional,
281 octetstring l2_payload
282 } with { variant "" };
283
Harald Weltef6543322017-07-16 07:35:10 +0200284 type record L1ctlH1 {
285 uint8_t hsn,
286 uint8_t maio,
287 uint8_t n,
288 OCT1 padding,
289 bitstring ma length(64)
290 } with { variant "" };
291
292 type record L1ctlDmEstReq {
293 GsmTsc tsc,
294 uint8_t h,
295 Arfcn arfcn optional,
296 L1ctlH1 hopping optional,
297 L1ctlTchMode tch_mode,
298 L1ctlAudioMode audio_mode
299 } with { variant (arfcn) "PRESENCE(h = 0)"
300 variant (hopping) "PRESENCE(h = 1)" };
301
302 type record L1ctlReset {
303 L1ctlResetType reset_type,
304 OCT3 padding
305 } with { variant "" };
306
Harald Weltee613f962018-04-18 22:38:16 +0200307 type record L1CtlCryptoReq {
308 uint8_t algo,
309 uint8_t key_len,
310 octetstring key
311 } with { variant (key_len) "LENGTHTO(key)" };
312
Harald Weltef6543322017-07-16 07:35:10 +0200313
314 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700315 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100316 } with {
317 variant (data) "BYTEORDER(first)"
318 }
Harald Weltef6543322017-07-16 07:35:10 +0200319
Harald Welte00d4dac2017-07-30 00:50:32 +0200320 type record length(8) of uint8_t TfiUsfArr;
321
322 type record L1ctlTbfCfgReq {
323 uint8_t tbf_nr,
324 boolean is_uplink,
325 OCT2 padding,
326 TfiUsfArr tfi_usf
327 } with { variant (is_uplink) "FIELDLENGTH(8)" };
328
Harald Weltef6543322017-07-16 07:35:10 +0200329 type union L1ctlUlPayload {
330 L1ctlFbsbReq fbsb_req,
331 L1ctlCcchModeReq ccch_mode_req,
332 L1ctlTchModeReq tch_mode_req,
333 L1ctlRachReq rach_req,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700334 L1ctlExtRachReq ext_rach_req,
Harald Weltef6543322017-07-16 07:35:10 +0200335 L1ctlParReq par_req,
336 L1ctlDmEstReq dm_est_req,
337 L1ctlReset reset_req,
338 //L1ctlNeighPmReq neigh_pm_req,
Harald Weltee613f962018-04-18 22:38:16 +0200339 L1CtlCryptoReq crypto_req,
Harald Weltef6543322017-07-16 07:35:10 +0200340 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200341 L1ctlTbfCfgReq tbf_cfg_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200342 L1ctlDataReq data_req,
Harald Weltef6543322017-07-16 07:35:10 +0200343 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100344 } with {
345 variant (other) "BYTEORDER(first)"
346 };
Harald Weltef6543322017-07-16 07:35:10 +0200347
348 type record L1ctlUlMessage {
349 L1ctlHeader header,
350 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200351 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100352 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200353 L1ctlUlPayload payload
354 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700355 header.msg_type = L1CTL_EXT_RACH_REQ,
Harald Weltef6543322017-07-16 07:35:10 +0200356 header.msg_type = L1CTL_PARAM_REQ,
357 header.msg_type = L1CTL_CRYPTO_REQ,
358 header.msg_type = L1CTL_DATA_REQ,
359 header.msg_type = L1CTL_DM_EST_REQ,
360 header.msg_type = L1CTL_DM_FREQ_REQ,
361 header.msg_type = L1CTL_DM_REL_REQ,
362 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200363 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100364 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200365 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
366 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
367 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
368 rach_req, header.msg_type = L1CTL_RACH_REQ;
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700369 ext_rach_req, header.msg_type = L1CTL_EXT_RACH_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200370 par_req, header.msg_type = L1CTL_PARAM_REQ;
371 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
372 reset_req, header.msg_type = L1CTL_RESET_REQ;
Harald Weltee613f962018-04-18 22:38:16 +0200373 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200374 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200375 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200376 data_req, header.msg_type = L1CTL_DATA_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200377 other, OTHERWISE;
378 )" };
379
380 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
381 with { extension "prototype(convert) encode(RAW)" };
382 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
383 with { extension "prototype(convert) decode(RAW)" };
384
Harald Welte52c713c2017-07-16 15:44:44 +0200385 type record L1ctlUlMessageLV {
386 uint16_t len,
387 L1ctlUlMessage msg
388 } with { variant (len) "LENGTHTO(msg)" };
389
390 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
391 with { extension "prototype(convert) encode(RAW)" };
392 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
393 with { extension "prototype(convert) decode(RAW)" };
394
395 type record L1ctlDlMessageLV {
396 uint16_t len,
397 L1ctlDlMessage msg
398 } with { variant (len) "LENGTHTO(msg)" };
399
400 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
401 with { extension "prototype(convert) encode(RAW)" };
402 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
403 with { extension "prototype(convert) decode(RAW)" };
404
405
Harald Welte9e4725d2017-07-16 23:18:09 +0200406
407
408 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100409 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
410 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200411 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200412 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100413 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200414 payload := {
415 reset_req := {
416 reset_type := rst_type,
417 padding := '000000'O
418 }
419 }
420 };
421
422 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100423 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
424 uint8_t sync_info_idx,
425 L1ctlCcchMode ccch_mode,
426 GsmRxLev rxlev_exp) := {
427 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200428 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200429 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100430 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200431 payload := {
432 fbsb_req := {
433 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100434 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200435 freq_err_thresh1 := 10000,
436 freq_err_thresh2 := 800,
437 num_freqerr_avg := 3,
438 flags := flags,
439 sync_info_idx := sync_info_idx,
440 ccch_mode := ccch_mode,
441 rxlev_exp := rxlev_exp
442 }
443 }
444 };
445
446 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100447 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
448 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200449 dl_info := ?,
450 payload := {
451 fbsb_conf := {
452 initial_freq_err := ?,
453 result := result,
454 bsic := ?
455 }
456 }
457 };
458
Harald Weltef8df4cb2018-03-10 15:15:08 +0100459 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
460 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
461 ul_info := omit,
462 ul_info_tbf := omit,
463 ul_info_abs := omit,
464 payload := {
465 ccch_mode_req := {
466 ccch_mode := ccch_mode,
467 padding := '000000'O
468 }
469 }
470 };
471
Harald Welte3757e602018-03-10 17:12:02 +0100472
473 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
474 header := tr_L1ctlHeader(msg_type),
475 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200476 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100477 }
478
479 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100480
481 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := {
482 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200483 ul_info := {
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700484 /* FIXME: both RSL chan_nr and link_id should be configurable */
Harald Welte9e4725d2017-07-16 23:18:09 +0200485 chan_nr := t_RslChanNr_RACH(0),
486 link_id := ts_RslLinkID_DCCH(0),
487 padding := '0000'O
488 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200489 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100490 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200491 payload := {
492 rach_req := {
493 ra := ra,
494 combined := combined,
495 offset := offset
496 }
497 }
498 }
499
Vadim Yanitskiy5c836792019-04-22 05:45:03 +0700500 template L1ctlUlMessage ts_L1CTL_EXT_RACH_REQ(
501 uint16_t ra11, L1ctlRachSynchSeq seq,
502 uint8_t combined, uint16_t offset
503 ) := {
504 header := ts_L1ctlHeader(L1CTL_EXT_RACH_REQ),
505 ul_info := {
506 /* FIXME: both RSL chan_nr and link_id should be configurable */
507 chan_nr := t_RslChanNr_RACH(0),
508 link_id := ts_RslLinkID_DCCH(0),
509 padding := '0000'O
510 },
511 ul_info_tbf := omit,
512 ul_info_abs := omit,
513 payload := {
514 ext_rach_req := {
515 ra11 := ra11,
516 synch_seq := seq,
517 combined := combined,
518 offset := offset
519 }
520 }
521 }
522
Harald Weltef8df4cb2018-03-10 15:15:08 +0100523 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
524 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100525 ul_info := {
526 chan_nr := t_RslChanNr_RACH(0),
527 link_id := ts_RslLinkID_DCCH(0),
528 padding := '0000'O
529 },
530 ul_info_tbf := omit,
531 ul_info_abs := omit,
532 payload := {
533 par_req := {
534 ta := ta,
535 tx_power := tx_power,
536 padding := '0000'O
537 }
538 }
539 }
540
Harald Weltef8df4cb2018-03-10 15:15:08 +0100541 template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
542 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200543 ul_info := {
544 chan_nr := chan_nr,
545 link_id := ts_RslLinkID_DCCH(0),
546 padding := '0000'O
547 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200548 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100549 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200550 payload := {
551 dm_est_req := {
552 tsc := tsc,
553 h := 0,
554 arfcn := arfcn,
555 hopping := omit,
556 tch_mode := 0,
557 audio_mode := t_L1CTL_AudioModeNone
558 }
559 }
560 }
561
Harald Weltef8df4cb2018-03-10 15:15:08 +0100562 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
563 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200564 ul_info := {
565 chan_nr := chan_nr,
566 link_id := ts_RslLinkID_DCCH(0),
567 padding := '0000'O
568 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200569 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100570 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200571 payload := {
572 other := ''O
573 }
574 }
575
Harald Weltef8df4cb2018-03-10 15:15:08 +0100576 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
577 template (value) RslLinkId link_id,
578 octetstring l2_data) := {
579 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200580 ul_info := {
581 chan_nr := chan_nr,
582 link_id := link_id,
583 padding := '0000'O
584 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200585 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100586 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200587 payload := {
588 other := l2_data
589 }
590 }
591
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200592 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
593 template (value) RslLinkId link_id,
594 L1ctlDataReq data_req) := {
595 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
596 ul_info := {
597 chan_nr := chan_nr,
598 link_id := link_id,
599 padding := '0000'O
600 },
601 ul_info_tbf := omit,
602 ul_info_abs := omit,
603 payload := {
604 data_req := data_req
605 }
606 }
607
Harald Weltef8df4cb2018-03-10 15:15:08 +0100608 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
609 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200610 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200611 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100612 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200613 payload := {
614 tbf_cfg_req := {
615 tbf_nr := 0,
616 is_uplink := is_uplink,
617 padding := '0000'O,
618 tfi_usf := tfi_usf
619 }
620 }
621 };
622
Harald Weltef8df4cb2018-03-10 15:15:08 +0100623 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
624 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200625 dl_info := omit,
626 payload := {
627 tbf_cfg_conf := {
628 tbf_nr := 0,
629 is_uplink := is_uplink,
630 padding := ?,
631 tfi_usf := ?
632 }
633 }
634 };
635
Harald Weltef8df4cb2018-03-10 15:15:08 +0100636 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
637 L1ctlGprsCs cs := L1CTL_CS1,
638 uint8_t tbf_nr := 0) := {
639 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200640 ul_info := omit,
641 ul_info_tbf := {
642 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200643 cs := cs,
644 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200645 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100646 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200647 payload := {
648 other := l2_data
649 }
650 }
651
Harald Weltef8df4cb2018-03-10 15:15:08 +0100652 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100653 uint8_t ts, GsmFrameNumber fn,
654 L1ctlGprsCs cs := L1CTL_CS1,
655 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100656 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100657 ul_info := omit,
658 ul_info_tbf := omit,
659 ul_info_abs := {
660 tbf_nr := tbf_nr,
661 cs := cs,
662 ts_nr := ts,
663 padding := '00'O,
664 fn := fn,
665 arfcn := arfcn,
666 padding2 := '0000'O
667 },
668 payload := {
669 other := l2_data
670 }
671 }
672
673
Harald Welte9e4725d2017-07-16 23:18:09 +0200674 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100675 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
676 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200677 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200678 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200679 };
680
Harald Weltece6dc442018-02-21 22:00:21 +0100681 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100682 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100683 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100684 template octetstring l2_data := ?,
685 template uint8_t num_biterr := 0,
686 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100687 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200688 dl_info := {
689 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100690 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200691 arfcn := ?,
692 frame_nr := ?,
693 rx_level := ?,
694 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100695 num_biterr := num_biterr,
696 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200697 },
698 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100699 data_ind := {
700 payload := l2_data
701 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200702 }
703 };
704
Harald Weltee613f962018-04-18 22:38:16 +0200705 template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
706 octetstring key) := {
707 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
708 ul_info := {
709 chan_nr := chan_nr,
710 link_id := ts_RslLinkID_DCCH(0),
711 padding := '0000'O
712 },
713 ul_info_tbf := omit,
714 ul_info_abs := omit,
715 payload := {
716 crypto_req := {
717 algo := algo,
718 key_len := 0, /* overwritten */
719 key := key
720 }
721 }
722 };
723
Harald Welte88849c62017-07-30 17:19:41 +0200724 template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
725 ded_or_tbf := ?,
726 page_mode := ?,
727 chan_desc := *,
728 pkt_chan_desc := *,
729 req_ref := f_compute_ReqRef(ra, fn),
730 timing_advance := ?,
731 mobile_allocation := ?,
732 rest_octets:= ?
733 };
734
735 template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200736 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
737 payload := {
Harald Welte88849c62017-07-30 17:19:41 +0200738 imm_ass := t_IMM_ASS(ra, fn)
Harald Welte9e4725d2017-07-16 23:18:09 +0200739 }
740 };
741
Harald Welte68e495b2018-02-25 00:05:57 +0100742 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
743
Harald Welte7024baa2018-03-02 23:37:51 +0100744/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
745 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200746} with { encode "RAW" };