blob: a86690ed3bc954cf1efccf86ad4dbd06802cd5f7 [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
86 const integer TRAFFIC_DATA_LEN := 40;
87
88 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 Welte52c713c2017-07-16 15:44:44 +020099 template L1ctlHeader t_L1ctlHeader(template L1ctlMsgType msg_type) := {
100 msg_type := msg_type,
101 flags := { padding := '0000000'B, f_done := false },
102 padding := '0000'O
103 };
104
Harald Weltef6543322017-07-16 07:35:10 +0200105 type record L1ctlDlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200106 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200107 RslLinkId link_id,
108 Arfcn arfcn,
Harald Welte5f0d5c82017-07-16 18:56:01 +0200109 uint32_t frame_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200110 GsmRxLev rx_level,
111 uint8_t snr,
112 uint8_t num_biterr,
113 uint8_t fire_crc
114 } with { variant "" };
115
116 type record L1ctlFbsbConf {
117 int16_t initial_freq_err,
118 uint8_t result,
119 uint8_t bsic
120 } with { variant "" };
121
122 type record L1ctlCcchModeConf {
123 L1ctlCcchMode ccch_mode,
124 OCT3 padding
125 } with { variant "" };
126
127 /* gsm48_chan_mode */
128 type uint8_t L1ctlTchMode;
129
130 type record L1ctlAudioMode {
131 BIT4 padding,
132 boolean tx_microphone,
133 boolean tx_traffic_req,
134 boolean rx_speaker,
135 boolean rx_traffic_ind
136 } with { variant "" };
137
Harald Welte66110f02017-07-16 21:05:18 +0200138 template L1ctlAudioMode t_L1CTL_AudioModeNone := { '0000'B, false, false, false, false };
139
Harald Weltef6543322017-07-16 07:35:10 +0200140 type record L1ctlTchModeConf {
141 L1ctlTchMode tch_mode,
142 L1ctlAudioMode audio_mode,
143 OCT2 padding
144 } with { variant "" };
145
146 type record L1ctlDataInd {
147 octetstring payload length(23)
Harald Welte7024baa2018-03-02 23:37:51 +0100148 } with {
149 variant (payload) "BYTEORDER(first)"
150 };
Harald Weltef6543322017-07-16 07:35:10 +0200151
152 type union L1ctlDlPayload {
153 L1ctlFbsbConf fbsb_conf,
154 L1ctlCcchModeConf ccch_mode_conf,
155 L1ctlTchModeConf tch_mode_conf,
156 L1ctlDataInd data_ind,
157 L1ctlTrafficReq traffic_ind,
Harald Welte00d4dac2017-07-30 00:50:32 +0200158 L1ctlTbfCfgReq tbf_cfg_conf,
Harald Weltef6543322017-07-16 07:35:10 +0200159 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100160 } with {
161 variant (other) "BYTEORDER(first)"
162 };
Harald Weltef6543322017-07-16 07:35:10 +0200163
164 type record L1ctlDlMessage {
165 L1ctlHeader header,
166 L1ctlDlInfo dl_info optional,
167 L1ctlDlPayload payload
168 } with { variant (dl_info) "PRESENCE(header.msg_type = L1CTL_FBSB_CONF,
169 header.msg_type = L1CTL_RACH_CONF,
170 header.msg_type = L1CTL_DATA_IND,
171 header.msg_type = L1CTL_DATA_CONF,
172 header.msg_type = L1CTL_TRAFFIC_IND)"
173 variant (payload) "CROSSTAG(fbsb_conf, header.msg_type = L1CTL_FBSB_CONF;
174 ccch_mode_conf, header.msg_type = L1CTL_CCCH_MODE_CONF;
175 tch_mode_conf, header.msg_type = L1CTL_TCH_MODE_CONF;
176 data_ind, header.msg_type = L1CTL_DATA_IND;
177 traffic_ind, header.msg_type = L1CTL_TRAFFIC_IND;
Harald Welte00d4dac2017-07-30 00:50:32 +0200178 tbf_cfg_conf, header.msg_type = L1CTL_TBF_CFG_CONF;
Harald Weltef6543322017-07-16 07:35:10 +0200179 other, OTHERWISE;
180 )" };
181
182 external function enc_L1ctlDlMessage(in L1ctlDlMessage msg) return octetstring
183 with { extension "prototype(convert) encode(RAW)" };
184 external function dec_L1ctlDlMessage(in octetstring stream) return L1ctlDlMessage
185 with { extension "prototype(convert) decode(RAW)" };
186
187
188 type record L1ctlUlInfo {
Harald Welte8e4db2c2017-07-16 18:54:55 +0200189 RslChannelNr chan_nr,
Harald Weltef6543322017-07-16 07:35:10 +0200190 RslLinkId link_id,
191 OCT2 padding
192 } with { variant "" };
193
Harald Welteb3c226e2017-07-30 17:18:01 +0200194 type record L1ctlUlTbfInfo {
195 uint8_t tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200196 L1ctlGprsCs cs,
197 OCT2 padding
Harald Welteb3c226e2017-07-30 17:18:01 +0200198 } with { variant "" };
199
Harald Welte3a40ec72018-03-02 20:45:04 +0100200 type record L1ctlUlAbsInfo {
201 uint8_t tbf_nr,
202 L1ctlGprsCs cs,
203 uint8_t ts_nr,
204 OCT1 padding,
Harald Welte7024baa2018-03-02 23:37:51 +0100205 uint32_le fn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100206 Arfcn arfcn,
207 OCT2 padding2
208 } with { variant "" };
209
Harald Weltef6543322017-07-16 07:35:10 +0200210 type record L1ctlFbsbFlags {
211 BIT5 padding,
212 boolean sb,
213 boolean fb1,
214 boolean fb0
Harald Welte344c0cf2018-03-09 16:17:45 +0100215 } with { variant "FIELDORDER(msb)" };
Harald Weltef6543322017-07-16 07:35:10 +0200216
Harald Welte66110f02017-07-16 21:05:18 +0200217 template L1ctlFbsbFlags t_L1CTL_FBSB_F_ALL := {
218 padding := '00000'B,
219 sb := true,
220 fb1 := true,
221 fb0 := true
222 };
223
Harald Weltef6543322017-07-16 07:35:10 +0200224 type record L1ctlFbsbReq {
225 Arfcn arfcn,
226 uint16_t timeout_tdma_frames,
227 uint16_t freq_err_thresh1,
228 uint16_t freq_err_thresh2,
229 uint8_t num_freqerr_avg,
230 L1ctlFbsbFlags flags,
231 uint8_t sync_info_idx,
232 L1ctlCcchMode ccch_mode,
233 GsmRxLev rxlev_exp
234 } with { variant "" };
235
236 type record L1ctlCcchModeReq {
237 L1ctlTchMode tch_mode,
238 L1ctlAudioMode audio_mode,
239 OCT2 padding
240 } with { variant "" };
241
242 type record L1ctlTchModeReq {
243 L1ctlTchMode tch_mode,
244 L1ctlAudioMode audio_mode,
245 OCT2 padding
246 } with { variant "" };
247
248 type record L1ctlRachReq {
249 uint8_t ra,
250 uint8_t combined,
251 uint16_t offset
252 } with { variant "" };
253
254 type record L1ctlParReq {
255 int8_t ta,
256 uint8_t tx_power,
257 OCT2 padding
258 } with { variant "" };
259
260 type record L1ctlH1 {
261 uint8_t hsn,
262 uint8_t maio,
263 uint8_t n,
264 OCT1 padding,
265 bitstring ma length(64)
266 } with { variant "" };
267
268 type record L1ctlDmEstReq {
269 GsmTsc tsc,
270 uint8_t h,
271 Arfcn arfcn optional,
272 L1ctlH1 hopping optional,
273 L1ctlTchMode tch_mode,
274 L1ctlAudioMode audio_mode
275 } with { variant (arfcn) "PRESENCE(h = 0)"
276 variant (hopping) "PRESENCE(h = 1)" };
277
278 type record L1ctlReset {
279 L1ctlResetType reset_type,
280 OCT3 padding
281 } with { variant "" };
282
283
284 type record L1ctlTrafficReq {
285 octetstring data length(TRAFFIC_DATA_LEN)
Harald Welte7024baa2018-03-02 23:37:51 +0100286 } with {
287 variant (data) "BYTEORDER(first)"
288 }
Harald Weltef6543322017-07-16 07:35:10 +0200289
Harald Welte00d4dac2017-07-30 00:50:32 +0200290 type record length(8) of uint8_t TfiUsfArr;
291
292 type record L1ctlTbfCfgReq {
293 uint8_t tbf_nr,
294 boolean is_uplink,
295 OCT2 padding,
296 TfiUsfArr tfi_usf
297 } with { variant (is_uplink) "FIELDLENGTH(8)" };
298
Harald Weltef6543322017-07-16 07:35:10 +0200299 type union L1ctlUlPayload {
300 L1ctlFbsbReq fbsb_req,
301 L1ctlCcchModeReq ccch_mode_req,
302 L1ctlTchModeReq tch_mode_req,
303 L1ctlRachReq rach_req,
304 L1ctlParReq par_req,
305 L1ctlDmEstReq dm_est_req,
306 L1ctlReset reset_req,
307 //L1ctlNeighPmReq neigh_pm_req,
308 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200309 L1ctlTbfCfgReq tbf_cfg_req,
Harald Weltef6543322017-07-16 07:35:10 +0200310 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100311 } with {
312 variant (other) "BYTEORDER(first)"
313 };
Harald Weltef6543322017-07-16 07:35:10 +0200314
315 type record L1ctlUlMessage {
316 L1ctlHeader header,
317 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200318 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100319 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200320 L1ctlUlPayload payload
321 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
322 header.msg_type = L1CTL_PARAM_REQ,
323 header.msg_type = L1CTL_CRYPTO_REQ,
324 header.msg_type = L1CTL_DATA_REQ,
325 header.msg_type = L1CTL_DM_EST_REQ,
326 header.msg_type = L1CTL_DM_FREQ_REQ,
327 header.msg_type = L1CTL_DM_REL_REQ,
328 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200329 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100330 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200331 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
332 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
333 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
334 rach_req, header.msg_type = L1CTL_RACH_REQ;
335 par_req, header.msg_type = L1CTL_PARAM_REQ;
336 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
337 reset_req, header.msg_type = L1CTL_RESET_REQ;
338 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200339 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200340 other, OTHERWISE;
341 )" };
342
343 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
344 with { extension "prototype(convert) encode(RAW)" };
345 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
346 with { extension "prototype(convert) decode(RAW)" };
347
Harald Welte52c713c2017-07-16 15:44:44 +0200348 type record L1ctlUlMessageLV {
349 uint16_t len,
350 L1ctlUlMessage msg
351 } with { variant (len) "LENGTHTO(msg)" };
352
353 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
354 with { extension "prototype(convert) encode(RAW)" };
355 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
356 with { extension "prototype(convert) decode(RAW)" };
357
358 type record L1ctlDlMessageLV {
359 uint16_t len,
360 L1ctlDlMessage msg
361 } with { variant (len) "LENGTHTO(msg)" };
362
363 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
364 with { extension "prototype(convert) encode(RAW)" };
365 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
366 with { extension "prototype(convert) decode(RAW)" };
367
368
Harald Welte9e4725d2017-07-16 23:18:09 +0200369
370
371 /* for generating RESET_REQ */
372 template L1ctlUlMessage t_L1ctlResetReq(template L1ctlResetType rst_type) := {
373 header := t_L1ctlHeader(L1CTL_RESET_REQ),
374 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200375 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100376 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200377 payload := {
378 reset_req := {
379 reset_type := rst_type,
380 padding := '000000'O
381 }
382 }
383 };
384
385 /* for generating FBSB_REQ */
386 template L1ctlUlMessage t_L1CTL_FBSB_REQ(template Arfcn arfcn, template L1ctlFbsbFlags flags, uint8_t sync_info_idx, L1ctlCcchMode ccch_mode, GsmRxLev rxlev_exp) := {
387 header := t_L1ctlHeader(L1CTL_FBSB_REQ),
388 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200389 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100390 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200391 payload := {
392 fbsb_req := {
393 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100394 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200395 freq_err_thresh1 := 10000,
396 freq_err_thresh2 := 800,
397 num_freqerr_avg := 3,
398 flags := flags,
399 sync_info_idx := sync_info_idx,
400 ccch_mode := ccch_mode,
401 rxlev_exp := rxlev_exp
402 }
403 }
404 };
405
406 /* for matching against incoming FBSB_CONF */
407 template L1ctlDlMessage t_L1CTL_FBSB_CONF(template uint8_t result) := {
408 header := t_L1ctlHeader(L1CTL_FBSB_CONF),
409 dl_info := ?,
410 payload := {
411 fbsb_conf := {
412 initial_freq_err := ?,
413 result := result,
414 bsic := ?
415 }
416 }
417 };
418
419 template L1ctlUlMessage t_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := {
420 header := t_L1ctlHeader(L1CTL_RACH_REQ),
421 ul_info := {
422 chan_nr := t_RslChanNr_RACH(0),
423 link_id := ts_RslLinkID_DCCH(0),
424 padding := '0000'O
425 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200426 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100427 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200428 payload := {
429 rach_req := {
430 ra := ra,
431 combined := combined,
432 offset := offset
433 }
434 }
435 }
436
437 template L1ctlUlMessage t_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
438 header := t_L1ctlHeader(L1CTL_DM_EST_REQ),
439 ul_info := {
440 chan_nr := chan_nr,
441 link_id := ts_RslLinkID_DCCH(0),
442 padding := '0000'O
443 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200444 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100445 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200446 payload := {
447 dm_est_req := {
448 tsc := tsc,
449 h := 0,
450 arfcn := arfcn,
451 hopping := omit,
452 tch_mode := 0,
453 audio_mode := t_L1CTL_AudioModeNone
454 }
455 }
456 }
457
458 template L1ctlUlMessage t_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
Harald Welte143edbd2017-07-17 20:55:42 +0200459 header := t_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200460 ul_info := {
461 chan_nr := chan_nr,
462 link_id := ts_RslLinkID_DCCH(0),
463 padding := '0000'O
464 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200465 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100466 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200467 payload := {
468 other := ''O
469 }
470 }
471
472 template L1ctlUlMessage t_L1CTL_DATA_REQ(template RslChannelNr chan_nr, template RslLinkId link_id, octetstring l2_data) := {
473 header := t_L1ctlHeader(L1CTL_DATA_REQ),
474 ul_info := {
475 chan_nr := chan_nr,
476 link_id := link_id,
477 padding := '0000'O
478 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200479 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100480 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200481 payload := {
482 other := l2_data
483 }
484 }
485
Harald Welte00d4dac2017-07-30 00:50:32 +0200486 template L1ctlUlMessage t_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
487 header := t_L1ctlHeader(L1CTL_TBF_CFG_REQ),
488 ul_info := omit,
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 Welte00d4dac2017-07-30 00:50:32 +0200491 payload := {
492 tbf_cfg_req := {
493 tbf_nr := 0,
494 is_uplink := is_uplink,
495 padding := '0000'O,
496 tfi_usf := tfi_usf
497 }
498 }
499 };
500
501 template L1ctlDlMessage t_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
502 header := t_L1ctlHeader(L1CTL_TBF_CFG_CONF),
503 dl_info := omit,
504 payload := {
505 tbf_cfg_conf := {
506 tbf_nr := 0,
507 is_uplink := is_uplink,
508 padding := ?,
509 tfi_usf := ?
510 }
511 }
512 };
513
Harald Welte1dcc3712017-08-01 00:05:52 +0200514 template L1ctlUlMessage t_L1CTL_DATA_TBF_REQ(octetstring l2_data, L1ctlGprsCs cs := L1CTL_CS1, uint8_t tbf_nr := 0) := {
Harald Welteb3c226e2017-07-30 17:18:01 +0200515 header := t_L1ctlHeader(L1CTL_DATA_TBF_REQ),
516 ul_info := omit,
517 ul_info_tbf := {
518 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200519 cs := cs,
520 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200521 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100522 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200523 payload := {
524 other := l2_data
525 }
526 }
527
Harald Welte3a40ec72018-03-02 20:45:04 +0100528 template L1ctlUlMessage t_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
529 uint8_t ts, GsmFrameNumber fn,
530 L1ctlGprsCs cs := L1CTL_CS1,
531 uint8_t tbf_nr := 0) := {
532 header := t_L1ctlHeader(L1CTL_DATA_ABS_REQ),
533 ul_info := omit,
534 ul_info_tbf := omit,
535 ul_info_abs := {
536 tbf_nr := tbf_nr,
537 cs := cs,
538 ts_nr := ts,
539 padding := '00'O,
540 fn := fn,
541 arfcn := arfcn,
542 padding2 := '0000'O
543 },
544 payload := {
545 other := l2_data
546 }
547 }
548
549
Harald Welte9e4725d2017-07-16 23:18:09 +0200550 /* for matching against incoming RACH_CONF */
551 template L1ctlDlMessage t_L1CTL_RACH_CONF := {
552 header := t_L1ctlHeader(L1CTL_RACH_CONF),
553 dl_info := ?,
554 payload := ?
555 };
556
Harald Weltece6dc442018-02-21 22:00:21 +0100557 /* for matching against incoming DATA_IND */
558 template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100559 template RslLinkId link_id := ?,
560 template octetstring l2_data := ?) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200561 header := t_L1ctlHeader(L1CTL_DATA_IND),
562 dl_info := {
563 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100564 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200565 arfcn := ?,
566 frame_nr := ?,
567 rx_level := ?,
568 snr := ?,
569 num_biterr := ?,
570 fire_crc := ?
571 },
572 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100573 data_ind := {
574 payload := l2_data
575 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200576 }
577 };
578
Harald Welte88849c62017-07-30 17:19:41 +0200579 template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
580 ded_or_tbf := ?,
581 page_mode := ?,
582 chan_desc := *,
583 pkt_chan_desc := *,
584 req_ref := f_compute_ReqRef(ra, fn),
585 timing_advance := ?,
586 mobile_allocation := ?,
587 rest_octets:= ?
588 };
589
590 template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200591 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
592 payload := {
Harald Welte88849c62017-07-30 17:19:41 +0200593 imm_ass := t_IMM_ASS(ra, fn)
Harald Welte9e4725d2017-07-16 23:18:09 +0200594 }
595 };
596
Harald Welte68e495b2018-02-25 00:05:57 +0100597 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
598
Harald Welte7024baa2018-03-02 23:37:51 +0100599/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
600 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200601} with { encode "RAW" };