blob: 4273ba3ed36c28cc6a9f52b375382dc3dddda1a5 [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,
45 L1CTL_TBF_CFG_REQ,
Harald Welteb3c226e2017-07-30 17:18:01 +020046 L1CTL_TBF_CFG_CONF,
47 L1CTL_DATA_TBF_REQ,
Harald Welte3a40ec72018-03-02 20:45:04 +010048 L1CTL_DATA_TBF_CONF,
49 L1CTL_DATA_ABS_REQ
Harald Weltef6543322017-07-16 07:35:10 +020050 } with { variant "FIELDLENGTH(8)" };
51
52 type enumerated L1ctlCcchMode {
53 CCCH_MODE_NONE (0),
54 CCCH_MODE_NON_COMBINED,
55 CCCH_MODE_COMBINED
56 } with { variant "FIELDLENGTH(8)" };
57
58 type enumerated L1ctlNeighMode {
59 NEIGH_MODE_NONE (0),
60 NEIGH_MODE_PM,
61 NEIGH_MODE_SB
62 } with { variant "FIELDLENGTH(8)" };
63
Harald Welte1dcc3712017-08-01 00:05:52 +020064 type enumerated L1ctlGprsCs {
65 L1CTL_CS1 (1),
66 L1CTL_CS2,
67 L1CTL_CS3,
68 L1CTL_CS4,
69 L1CTL_MCS1,
70 L1CTL_MCS2,
71 L1CTL_MCS3,
72 L1CTL_MCS4,
73 L1CTL_MCS5,
74 L1CTL_MCS6,
75 L1CTL_MCS7,
76 L1CTL_MCS8,
77 L1CTL_MCS9
78 } with { variant "FIELDLENGTH(8)" };
79
Harald Weltef6543322017-07-16 07:35:10 +020080 type enumerated L1ctlResetType {
81 L1CTL_RES_T_BOOT (0),
82 L1CTL_RES_T_FULL,
83 L1CTL_RES_T_SCHED
84 } with { variant "FIELDLENGTH(8)" };
85
Harald Weltef6543322017-07-16 07:35:10 +020086 type record L1ctlHdrFlags {
87 BIT7 padding,
88 boolean f_done
89 } with { variant "" };
90
91 type record L1ctlHeader {
92 L1ctlMsgType msg_type,
93 L1ctlHdrFlags flags,
94 OCT2 padding
95 } with { variant "" };
96
Harald Weltef8df4cb2018-03-10 15:15:08 +010097 template L1ctlHeader tr_L1ctlHeader(template L1ctlMsgType msg_type) := {
98 msg_type := msg_type,
99 flags := ?,
100 padding := ?
101 };
102
103 template (value) L1ctlHeader ts_L1ctlHeader(L1ctlMsgType msg_type) := {
Harald Welte52c713c2017-07-16 15:44:44 +0200104 msg_type := msg_type,
105 flags := { padding := '0000000'B, f_done := false },
106 padding := '0000'O
107 };
108
Harald Weltef6543322017-07-16 07:35:10 +0200109 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200110 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200111 RslLinkId link_id,
112 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200113 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200114 GsmRxLev rx_level,
115 uint8_t snr,
116 uint8_t num_biterr,
117 uint8_t fire_crc
118 } with { variant "" };
119
120 type record L1ctlFbsbConf {
121 int16_t initial_freq_err,
122 uint8_t result,
123 uint8_t bsic
124 } with { variant "" };
125
126 type record L1ctlCcchModeConf {
127 L1ctlCcchMode ccch_mode,
128 OCT3 padding
129 } with { variant "" };
130
131 /* gsm48_chan_mode */
132 type uint8_t L1ctlTchMode;
133
134 type record L1ctlAudioMode {
135 BIT4 padding,
136 boolean tx_microphone,
137 boolean tx_traffic_req,
138 boolean rx_speaker,
139 boolean rx_traffic_ind
140 } with { variant "" };
141
Harald Weltef8df4cb2018-03-10 15:15:08 +0100142 template (value) L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
Harald Welte66110f02017-07-16 21:05:18 +0200143
Harald Weltef6543322017-07-16 07:35:10 +0200144 type record L1ctlTchModeConf {
145 L1ctlTchMode tch_mode,
146 L1ctlAudioMode audio_mode,
147 OCT2 padding
148 } with { variant "" };
149
150 type record L1ctlDataInd {
151 octetstring payload length(23)
Harald Welte7024baa2018-03-02 23:37:51 +0100152 } with {
153 variant (payload) "BYTEORDER(first)"
154 };
Harald Weltef6543322017-07-16 07:35:10 +0200155
156 type union L1ctlDlPayload {
157 L1ctlFbsbConf fbsb_conf,
158 L1ctlCcchModeConf ccch_mode_conf,
159 L1ctlTchModeConf tch_mode_conf,
160 L1ctlDataInd data_ind,
161 L1ctlTrafficReq traffic_ind,
Harald Welte00d4dac2017-07-30 00:50:32 +0200162 L1ctlTbfCfgReq tbf_cfg_conf,
Harald Weltef6543322017-07-16 07:35:10 +0200163 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100164 } with {
165 variant (other) "BYTEORDER(first)"
166 };
Harald Weltef6543322017-07-16 07:35:10 +0200167
168 type record L1ctlDlMessage {
169 L1ctlHeader header,
170 L1ctlDlInfo dl_info optional,
Harald Weltef56cc492018-04-15 10:58:43 +0200171 L1ctlDlPayload payload optional
Harald Weltef6543322017-07-16 07:35:10 +0200172 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
173 header.msg_type = L1CTL_RACH_CONF,
174 header.msg_type = L1CTL_DATA_IND,
175 header.msg_type = L1CTL_DATA_CONF,
Harald Welte3c4cbf62018-03-30 10:31:39 +0200176 header.msg_type = L1CTL_TRAFFIC_IND,
177 header.msg_type = L1CTL_TRAFFIC_CONF)"
Harald Weltef6543322017-07-16 07:35:10 +0200178 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
179 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
180 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
181 data_ind, header.msg_type = L1CTL_DATA_IND;
182 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
Harald Welte00d4dac2017-07-30 00:50:32 +0200183 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
Harald Weltef6543322017-07-16 07:35:10 +0200184 other, OTHERWISE;
185 )" };
186
187 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
188 with { extension "prototype(convert) encode(RAW)" };
189 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
190 with { extension "prototype(convert) decode(RAW)" };
191
192
193 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200194 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200195 RslLinkId link_id,
196 OCT2 padding
197 } with { variant "" };
198
Harald Welteb3c226e2017-07-30 17:18:01 +0200199 type record L1ctlUlTbfInfo {
200 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200201 L1ctlGprsCs cs,
202 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200203 } with { variant "" };
204
Harald Welte3a40ec72018-03-02 20:45:04 +0100205 type record L1ctlUlAbsInfo {
206 uint8_t tbf_nr,
207 L1ctlGprsCs cs,
208 uint8_t ts_nr,
209 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100210 uint32_le fn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100211 Arfcn arfcn,
212 OCT2 padding2
213 } with { variant "" };
214
Harald Weltef6543322017-07-16 07:35:10 +0200215 type record L1ctlFbsbFlags {
216 BIT5 padding,
217 boolean sb,
218 boolean fb1,
219 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100220 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200221
Harald Weltef8df4cb2018-03-10 15:15:08 +0100222 template (value) L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
Harald Welte66110f02017-07-16 21:05:18 +0200223 padding := '00000'B,
224 sb := true,
225 fb1 := true,
226 fb0 := true
227 };
228
Harald Weltef6543322017-07-16 07:35:10 +0200229 type record L1ctlFbsbReq {
230 Arfcn arfcn,
231 uint16_t timeout_tdma_frames,
232 uint16_t freq_err_thresh1,
233 uint16_t freq_err_thresh2,
234 uint8_t num_freqerr_avg,
235 L1ctlFbsbFlags flags,
236 uint8_t sync_info_idx,
237 L1ctlCcchMode ccch_mode,
238 GsmRxLev rxlev_exp
239 } with { variant "" };
240
241 type record L1ctlCcchModeReq {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100242 L1ctlCcchMode ccch_mode,
243 OCT3 padding
Harald Weltef6543322017-07-16 07:35:10 +0200244 } with { variant "" };
245
246 type record L1ctlTchModeReq {
247 L1ctlTchMode tch_mode,
248 L1ctlAudioMode audio_mode,
249 OCT2 padding
250 } with { variant "" };
251
252 type record L1ctlRachReq {
253 uint8_t ra,
254 uint8_t combined,
255 uint16_t offset
256 } with { variant "" };
257
258 type record L1ctlParReq {
259 int8_t ta,
260 uint8_t tx_power,
261 OCT2 padding
262 } with { variant "" };
263
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200264 type record L1ctlDataReq {
265 SacchL1Header l1header optional,
266 octetstring l2_payload
267 } with { variant "" };
268
Harald Weltef6543322017-07-16 07:35:10 +0200269 type record L1ctlH1 {
270 uint8_t hsn,
271 uint8_t maio,
272 uint8_t n,
273 OCT1 padding,
274 bitstring ma length(64)
275 } with { variant "" };
276
277 type record L1ctlDmEstReq {
278 GsmTsc tsc,
279 uint8_t h,
280 Arfcn arfcn optional,
281 L1ctlH1 hopping optional,
282 L1ctlTchMode tch_mode,
283 L1ctlAudioMode audio_mode
284 } with { variant (arfcn) "PRESENCE(h = 0)"
285 variant (hopping) "PRESENCE(h = 1)" };
286
287 type record L1ctlReset {
288 L1ctlResetType reset_type,
289 OCT3 padding
290 } with { variant "" };
291
Harald Weltee613f962018-04-18 22:38:16 +0200292 type record L1CtlCryptoReq {
293 uint8_t algo,
294 uint8_t key_len,
295 octetstring key
296 } with { variant (key_len) "LENGTHTO(key)" };
297
Harald Weltef6543322017-07-16 07:35:10 +0200298
299 type record L1ctlTrafficReq {
Vadim Yanitskiye01691d2018-10-29 00:18:04 +0700300 octetstring data
Harald Welte7024baa2018-03-02 23:37:51 +0100301 } with {
302 variant (data) "BYTEORDER(first)"
303 }
Harald Weltef6543322017-07-16 07:35:10 +0200304
Harald Welte00d4dac2017-07-30 00:50:32 +0200305 type record length(8) of uint8_t TfiUsfArr;
306
307 type record L1ctlTbfCfgReq {
308 uint8_t tbf_nr,
309 boolean is_uplink,
310 OCT2 padding,
311 TfiUsfArr tfi_usf
312 } with { variant (is_uplink) "FIELDLENGTH(8)" };
313
Harald Weltef6543322017-07-16 07:35:10 +0200314 type union L1ctlUlPayload {
315 L1ctlFbsbReq fbsb_req,
316 L1ctlCcchModeReq ccch_mode_req,
317 L1ctlTchModeReq tch_mode_req,
318 L1ctlRachReq rach_req,
319 L1ctlParReq par_req,
320 L1ctlDmEstReq dm_est_req,
321 L1ctlReset reset_req,
322 //L1ctlNeighPmReq neigh_pm_req,
Harald Weltee613f962018-04-18 22:38:16 +0200323 L1CtlCryptoReq crypto_req,
Harald Weltef6543322017-07-16 07:35:10 +0200324 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200325 L1ctlTbfCfgReq tbf_cfg_req,
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200326 L1ctlDataReq data_req,
Harald Weltef6543322017-07-16 07:35:10 +0200327 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100328 } with {
329 variant (other) "BYTEORDER(first)"
330 };
Harald Weltef6543322017-07-16 07:35:10 +0200331
332 type record L1ctlUlMessage {
333 L1ctlHeader header,
334 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200335 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100336 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200337 L1ctlUlPayload payload
338 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
339 header.msg_type = L1CTL_PARAM_REQ,
340 header.msg_type = L1CTL_CRYPTO_REQ,
341 header.msg_type = L1CTL_DATA_REQ,
342 header.msg_type = L1CTL_DM_EST_REQ,
343 header.msg_type = L1CTL_DM_FREQ_REQ,
344 header.msg_type = L1CTL_DM_REL_REQ,
345 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200346 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100347 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200348 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
349 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
350 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
351 rach_req, header.msg_type = L1CTL_RACH_REQ;
352 par_req, header.msg_type = L1CTL_PARAM_REQ;
353 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
354 reset_req, header.msg_type = L1CTL_RESET_REQ;
Harald Weltee613f962018-04-18 22:38:16 +0200355 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200356 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200357 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200358 data_req, header.msg_type = L1CTL_DATA_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200359 other, OTHERWISE;
360 )" };
361
362 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
363 with { extension "prototype(convert) encode(RAW)" };
364 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
365 with { extension "prototype(convert) decode(RAW)" };
366
Harald Welte52c713c2017-07-16 15:44:44 +0200367 type record L1ctlUlMessageLV {
368 uint16_t len,
369 L1ctlUlMessage msg
370 } with { variant (len) "LENGTHTO(msg)" };
371
372 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
373 with { extension "prototype(convert) encode(RAW)" };
374 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
375 with { extension "prototype(convert) decode(RAW)" };
376
377 type record L1ctlDlMessageLV {
378 uint16_t len,
379 L1ctlDlMessage msg
380 } with { variant (len) "LENGTHTO(msg)" };
381
382 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
383 with { extension "prototype(convert) encode(RAW)" };
384 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
385 with { extension "prototype(convert) decode(RAW)" };
386
387
Harald Welte9e4725d2017-07-16 23:18:09 +0200388
389
390 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100391 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
392 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200393 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200394 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100395 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200396 payload := {
397 reset_req := {
398 reset_type := rst_type,
399 padding := '000000'O
400 }
401 }
402 };
403
404 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100405 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
406 uint8_t sync_info_idx,
407 L1ctlCcchMode ccch_mode,
408 GsmRxLev rxlev_exp) := {
409 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200410 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200411 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100412 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200413 payload := {
414 fbsb_req := {
415 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100416 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200417 freq_err_thresh1 := 10000,
418 freq_err_thresh2 := 800,
419 num_freqerr_avg := 3,
420 flags := flags,
421 sync_info_idx := sync_info_idx,
422 ccch_mode := ccch_mode,
423 rxlev_exp := rxlev_exp
424 }
425 }
426 };
427
428 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100429 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
430 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200431 dl_info := ?,
432 payload := {
433 fbsb_conf := {
434 initial_freq_err := ?,
435 result := result,
436 bsic := ?
437 }
438 }
439 };
440
Harald Weltef8df4cb2018-03-10 15:15:08 +0100441 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
442 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
443 ul_info := omit,
444 ul_info_tbf := omit,
445 ul_info_abs := omit,
446 payload := {
447 ccch_mode_req := {
448 ccch_mode := ccch_mode,
449 padding := '000000'O
450 }
451 }
452 };
453
Harald Welte3757e602018-03-10 17:12:02 +0100454
455 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
456 header := tr_L1ctlHeader(msg_type),
457 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200458 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100459 }
460
461 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100462
463 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := {
464 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200465 ul_info := {
466 chan_nr := t_RslChanNr_RACH(0),
467 link_id := ts_RslLinkID_DCCH(0),
468 padding := '0000'O
469 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200470 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100471 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200472 payload := {
473 rach_req := {
474 ra := ra,
475 combined := combined,
476 offset := offset
477 }
478 }
479 }
480
Harald Weltef8df4cb2018-03-10 15:15:08 +0100481 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
482 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100483 ul_info := {
484 chan_nr := t_RslChanNr_RACH(0),
485 link_id := ts_RslLinkID_DCCH(0),
486 padding := '0000'O
487 },
488 ul_info_tbf := omit,
489 ul_info_abs := omit,
490 payload := {
491 par_req := {
492 ta := ta,
493 tx_power := tx_power,
494 padding := '0000'O
495 }
496 }
497 }
498
Harald Weltef8df4cb2018-03-10 15:15:08 +0100499 template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
500 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200501 ul_info := {
502 chan_nr := chan_nr,
503 link_id := ts_RslLinkID_DCCH(0),
504 padding := '0000'O
505 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200506 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100507 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200508 payload := {
509 dm_est_req := {
510 tsc := tsc,
511 h := 0,
512 arfcn := arfcn,
513 hopping := omit,
514 tch_mode := 0,
515 audio_mode := t_L1CTL_AudioModeNone
516 }
517 }
518 }
519
Harald Weltef8df4cb2018-03-10 15:15:08 +0100520 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
521 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200522 ul_info := {
523 chan_nr := chan_nr,
524 link_id := ts_RslLinkID_DCCH(0),
525 padding := '0000'O
526 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200527 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100528 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200529 payload := {
530 other := ''O
531 }
532 }
533
Harald Weltef8df4cb2018-03-10 15:15:08 +0100534 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
535 template (value) RslLinkId link_id,
536 octetstring l2_data) := {
537 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200538 ul_info := {
539 chan_nr := chan_nr,
540 link_id := link_id,
541 padding := '0000'O
542 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200543 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100544 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200545 payload := {
546 other := l2_data
547 }
548 }
549
Pau Espin Pedrol0aad5962018-09-28 16:03:55 +0200550 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ_SACCH(template (value) RslChannelNr chan_nr,
551 template (value) RslLinkId link_id,
552 L1ctlDataReq data_req) := {
553 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
554 ul_info := {
555 chan_nr := chan_nr,
556 link_id := link_id,
557 padding := '0000'O
558 },
559 ul_info_tbf := omit,
560 ul_info_abs := omit,
561 payload := {
562 data_req := data_req
563 }
564 }
565
Harald Weltef8df4cb2018-03-10 15:15:08 +0100566 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
567 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200568 ul_info := omit,
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 Welte00d4dac2017-07-30 00:50:32 +0200571 payload := {
572 tbf_cfg_req := {
573 tbf_nr := 0,
574 is_uplink := is_uplink,
575 padding := '0000'O,
576 tfi_usf := tfi_usf
577 }
578 }
579 };
580
Harald Weltef8df4cb2018-03-10 15:15:08 +0100581 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
582 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200583 dl_info := omit,
584 payload := {
585 tbf_cfg_conf := {
586 tbf_nr := 0,
587 is_uplink := is_uplink,
588 padding := ?,
589 tfi_usf := ?
590 }
591 }
592 };
593
Harald Weltef8df4cb2018-03-10 15:15:08 +0100594 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
595 L1ctlGprsCs cs := L1CTL_CS1,
596 uint8_t tbf_nr := 0) := {
597 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200598 ul_info := omit,
599 ul_info_tbf := {
600 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200601 cs := cs,
602 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200603 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100604 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200605 payload := {
606 other := l2_data
607 }
608 }
609
Harald Weltef8df4cb2018-03-10 15:15:08 +0100610 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100611 uint8_t ts, GsmFrameNumber fn,
612 L1ctlGprsCs cs := L1CTL_CS1,
613 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100614 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100615 ul_info := omit,
616 ul_info_tbf := omit,
617 ul_info_abs := {
618 tbf_nr := tbf_nr,
619 cs := cs,
620 ts_nr := ts,
621 padding := '00'O,
622 fn := fn,
623 arfcn := arfcn,
624 padding2 := '0000'O
625 },
626 payload := {
627 other := l2_data
628 }
629 }
630
631
Harald Welte9e4725d2017-07-16 23:18:09 +0200632 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100633 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
634 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200635 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200636 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200637 };
638
Harald Weltece6dc442018-02-21 22:00:21 +0100639 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100640 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100641 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100642 template octetstring l2_data := ?,
643 template uint8_t num_biterr := 0,
644 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100645 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200646 dl_info := {
647 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100648 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200649 arfcn := ?,
650 frame_nr := ?,
651 rx_level := ?,
652 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100653 num_biterr := num_biterr,
654 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200655 },
656 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100657 data_ind := {
658 payload := l2_data
659 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200660 }
661 };
662
Harald Weltee613f962018-04-18 22:38:16 +0200663 template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
664 octetstring key) := {
665 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
666 ul_info := {
667 chan_nr := chan_nr,
668 link_id := ts_RslLinkID_DCCH(0),
669 padding := '0000'O
670 },
671 ul_info_tbf := omit,
672 ul_info_abs := omit,
673 payload := {
674 crypto_req := {
675 algo := algo,
676 key_len := 0, /* overwritten */
677 key := key
678 }
679 }
680 };
681
Harald Welte88849c62017-07-30 17:19:41 +0200682 template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
683 ded_or_tbf := ?,
684 page_mode := ?,
685 chan_desc := *,
686 pkt_chan_desc := *,
687 req_ref := f_compute_ReqRef(ra, fn),
688 timing_advance := ?,
689 mobile_allocation := ?,
690 rest_octets:= ?
691 };
692
693 template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200694 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
695 payload := {
Harald Welte88849c62017-07-30 17:19:41 +0200696 imm_ass := t_IMM_ASS(ra, fn)
Harald Welte9e4725d2017-07-16 23:18:09 +0200697 }
698 };
699
Harald Welte68e495b2018-02-25 00:05:57 +0100700 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
701
Harald Welte7024baa2018-03-02 23:37:51 +0100702/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
703 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200704} with { encode "RAW" };