blob: 4c0e14d6dacae33473f451a2a4343364414c169e [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 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
260 type record L1ctlParReq {
261 int8_t ta,
262 uint8_t tx_power,
263 OCT2 padding
264 } with { variant "" };
265
266 type record L1ctlH1 {
267 uint8_t hsn,
268 uint8_t maio,
269 uint8_t n,
270 OCT1 padding,
271 bitstring ma length(64)
272 } with { variant "" };
273
274 type record L1ctlDmEstReq {
275 GsmTsc tsc,
276 uint8_t h,
277 Arfcn arfcn optional,
278 L1ctlH1 hopping optional,
279 L1ctlTchMode tch_mode,
280 L1ctlAudioMode audio_mode
281 } with { variant (arfcn) "PRESENCE(h = 0)"
282 variant (hopping) "PRESENCE(h = 1)" };
283
284 type record L1ctlReset {
285 L1ctlResetType reset_type,
286 OCT3 padding
287 } with { variant "" };
288
289
290 type record L1ctlTrafficReq {
291 octetstring data length(TRAFFIC_DATA_LEN)
Harald Welte7024baa2018-03-02 23:37:51 +0100292 } with {
293 variant (data) "BYTEORDER(first)"
294 }
Harald Weltef6543322017-07-16 07:35:10 +0200295
Harald Welte00d4dac2017-07-30 00:50:32 +0200296 type record length(8) of uint8_t TfiUsfArr;
297
298 type record L1ctlTbfCfgReq {
299 uint8_t tbf_nr,
300 boolean is_uplink,
301 OCT2 padding,
302 TfiUsfArr tfi_usf
303 } with { variant (is_uplink) "FIELDLENGTH(8)" };
304
Harald Weltef6543322017-07-16 07:35:10 +0200305 type union L1ctlUlPayload {
306 L1ctlFbsbReq fbsb_req,
307 L1ctlCcchModeReq ccch_mode_req,
308 L1ctlTchModeReq tch_mode_req,
309 L1ctlRachReq rach_req,
310 L1ctlParReq par_req,
311 L1ctlDmEstReq dm_est_req,
312 L1ctlReset reset_req,
313 //L1ctlNeighPmReq neigh_pm_req,
314 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200315 L1ctlTbfCfgReq tbf_cfg_req,
Harald Weltef6543322017-07-16 07:35:10 +0200316 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100317 } with {
318 variant (other) "BYTEORDER(first)"
319 };
Harald Weltef6543322017-07-16 07:35:10 +0200320
321 type record L1ctlUlMessage {
322 L1ctlHeader header,
323 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200324 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100325 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200326 L1ctlUlPayload payload
327 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
328 header.msg_type = L1CTL_PARAM_REQ,
329 header.msg_type = L1CTL_CRYPTO_REQ,
330 header.msg_type = L1CTL_DATA_REQ,
331 header.msg_type = L1CTL_DM_EST_REQ,
332 header.msg_type = L1CTL_DM_FREQ_REQ,
333 header.msg_type = L1CTL_DM_REL_REQ,
334 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200335 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100336 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200337 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
338 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
339 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
340 rach_req, header.msg_type = L1CTL_RACH_REQ;
341 par_req, header.msg_type = L1CTL_PARAM_REQ;
342 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
343 reset_req, header.msg_type = L1CTL_RESET_REQ;
344 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200345 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200346 other, OTHERWISE;
347 )" };
348
349 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
350 with { extension "prototype(convert) encode(RAW)" };
351 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
352 with { extension "prototype(convert) decode(RAW)" };
353
Harald Welte52c713c2017-07-16 15:44:44 +0200354 type record L1ctlUlMessageLV {
355 uint16_t len,
356 L1ctlUlMessage msg
357 } with { variant (len) "LENGTHTO(msg)" };
358
359 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
360 with { extension "prototype(convert) encode(RAW)" };
361 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
362 with { extension "prototype(convert) decode(RAW)" };
363
364 type record L1ctlDlMessageLV {
365 uint16_t len,
366 L1ctlDlMessage msg
367 } with { variant (len) "LENGTHTO(msg)" };
368
369 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
370 with { extension "prototype(convert) encode(RAW)" };
371 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
372 with { extension "prototype(convert) decode(RAW)" };
373
374
Harald Welte9e4725d2017-07-16 23:18:09 +0200375
376
377 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100378 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
379 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200380 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200381 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100382 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200383 payload := {
384 reset_req := {
385 reset_type := rst_type,
386 padding := '000000'O
387 }
388 }
389 };
390
391 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100392 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
393 uint8_t sync_info_idx,
394 L1ctlCcchMode ccch_mode,
395 GsmRxLev rxlev_exp) := {
396 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200397 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200398 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100399 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200400 payload := {
401 fbsb_req := {
402 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100403 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200404 freq_err_thresh1 := 10000,
405 freq_err_thresh2 := 800,
406 num_freqerr_avg := 3,
407 flags := flags,
408 sync_info_idx := sync_info_idx,
409 ccch_mode := ccch_mode,
410 rxlev_exp := rxlev_exp
411 }
412 }
413 };
414
415 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100416 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
417 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200418 dl_info := ?,
419 payload := {
420 fbsb_conf := {
421 initial_freq_err := ?,
422 result := result,
423 bsic := ?
424 }
425 }
426 };
427
Harald Weltef8df4cb2018-03-10 15:15:08 +0100428 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
429 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
430 ul_info := omit,
431 ul_info_tbf := omit,
432 ul_info_abs := omit,
433 payload := {
434 ccch_mode_req := {
435 ccch_mode := ccch_mode,
436 padding := '000000'O
437 }
438 }
439 };
440
Harald Welte3757e602018-03-10 17:12:02 +0100441
442 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
443 header := tr_L1ctlHeader(msg_type),
444 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200445 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100446 }
447
448 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100449
450 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := {
451 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200452 ul_info := {
453 chan_nr := t_RslChanNr_RACH(0),
454 link_id := ts_RslLinkID_DCCH(0),
455 padding := '0000'O
456 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200457 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100458 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200459 payload := {
460 rach_req := {
461 ra := ra,
462 combined := combined,
463 offset := offset
464 }
465 }
466 }
467
Harald Weltef8df4cb2018-03-10 15:15:08 +0100468 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
469 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100470 ul_info := {
471 chan_nr := t_RslChanNr_RACH(0),
472 link_id := ts_RslLinkID_DCCH(0),
473 padding := '0000'O
474 },
475 ul_info_tbf := omit,
476 ul_info_abs := omit,
477 payload := {
478 par_req := {
479 ta := ta,
480 tx_power := tx_power,
481 padding := '0000'O
482 }
483 }
484 }
485
Harald Weltef8df4cb2018-03-10 15:15:08 +0100486 template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
487 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200488 ul_info := {
489 chan_nr := chan_nr,
490 link_id := ts_RslLinkID_DCCH(0),
491 padding := '0000'O
492 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200493 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100494 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200495 payload := {
496 dm_est_req := {
497 tsc := tsc,
498 h := 0,
499 arfcn := arfcn,
500 hopping := omit,
501 tch_mode := 0,
502 audio_mode := t_L1CTL_AudioModeNone
503 }
504 }
505 }
506
Harald Weltef8df4cb2018-03-10 15:15:08 +0100507 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
508 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200509 ul_info := {
510 chan_nr := chan_nr,
511 link_id := ts_RslLinkID_DCCH(0),
512 padding := '0000'O
513 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200514 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100515 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200516 payload := {
517 other := ''O
518 }
519 }
520
Harald Weltef8df4cb2018-03-10 15:15:08 +0100521 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
522 template (value) RslLinkId link_id,
523 octetstring l2_data) := {
524 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200525 ul_info := {
526 chan_nr := chan_nr,
527 link_id := link_id,
528 padding := '0000'O
529 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200530 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100531 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200532 payload := {
533 other := l2_data
534 }
535 }
536
Harald Weltef8df4cb2018-03-10 15:15:08 +0100537 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
538 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200539 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200540 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100541 ul_info_abs := omit,
Harald Welte00d4dac2017-07-30 00:50:32 +0200542 payload := {
543 tbf_cfg_req := {
544 tbf_nr := 0,
545 is_uplink := is_uplink,
546 padding := '0000'O,
547 tfi_usf := tfi_usf
548 }
549 }
550 };
551
Harald Weltef8df4cb2018-03-10 15:15:08 +0100552 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
553 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200554 dl_info := omit,
555 payload := {
556 tbf_cfg_conf := {
557 tbf_nr := 0,
558 is_uplink := is_uplink,
559 padding := ?,
560 tfi_usf := ?
561 }
562 }
563 };
564
Harald Weltef8df4cb2018-03-10 15:15:08 +0100565 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
566 L1ctlGprsCs cs := L1CTL_CS1,
567 uint8_t tbf_nr := 0) := {
568 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200569 ul_info := omit,
570 ul_info_tbf := {
571 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200572 cs := cs,
573 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200574 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100575 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200576 payload := {
577 other := l2_data
578 }
579 }
580
Harald Weltef8df4cb2018-03-10 15:15:08 +0100581 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100582 uint8_t ts, GsmFrameNumber fn,
583 L1ctlGprsCs cs := L1CTL_CS1,
584 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100585 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100586 ul_info := omit,
587 ul_info_tbf := omit,
588 ul_info_abs := {
589 tbf_nr := tbf_nr,
590 cs := cs,
591 ts_nr := ts,
592 padding := '00'O,
593 fn := fn,
594 arfcn := arfcn,
595 padding2 := '0000'O
596 },
597 payload := {
598 other := l2_data
599 }
600 }
601
602
Harald Welte9e4725d2017-07-16 23:18:09 +0200603 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100604 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
605 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200606 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200607 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200608 };
609
Harald Weltece6dc442018-02-21 22:00:21 +0100610 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100611 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100612 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100613 template octetstring l2_data := ?,
614 template uint8_t num_biterr := 0,
615 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100616 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200617 dl_info := {
618 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100619 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200620 arfcn := ?,
621 frame_nr := ?,
622 rx_level := ?,
623 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100624 num_biterr := num_biterr,
625 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200626 },
627 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100628 data_ind := {
629 payload := l2_data
630 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200631 }
632 };
633
Harald Welte88849c62017-07-30 17:19:41 +0200634 template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
635 ded_or_tbf := ?,
636 page_mode := ?,
637 chan_desc := *,
638 pkt_chan_desc := *,
639 req_ref := f_compute_ReqRef(ra, fn),
640 timing_advance := ?,
641 mobile_allocation := ?,
642 rest_octets:= ?
643 };
644
645 template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200646 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
647 payload := {
Harald Welte88849c62017-07-30 17:19:41 +0200648 imm_ass := t_IMM_ASS(ra, fn)
Harald Welte9e4725d2017-07-16 23:18:09 +0200649 }
650 };
651
Harald Welte68e495b2018-02-25 00:05:57 +0100652 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
653
Harald Welte7024baa2018-03-02 23:37:51 +0100654/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
655 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200656} with { encode "RAW" };