blob: 656f292d2cd567e76f5305428c720b75cbfd7abd [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
Harald Weltee613f962018-04-18 22:38:16 +0200289 type record L1CtlCryptoReq {
290 uint8_t algo,
291 uint8_t key_len,
292 octetstring key
293 } with { variant (key_len) "LENGTHTO(key)" };
294
Harald Weltef6543322017-07-16 07:35:10 +0200295
296 type record L1ctlTrafficReq {
297 octetstring data length(TRAFFIC_DATA_LEN)
Harald Welte7024baa2018-03-02 23:37:51 +0100298 } with {
299 variant (data) "BYTEORDER(first)"
300 }
Harald Weltef6543322017-07-16 07:35:10 +0200301
Harald Welte00d4dac2017-07-30 00:50:32 +0200302 type record length(8) of uint8_t TfiUsfArr;
303
304 type record L1ctlTbfCfgReq {
305 uint8_t tbf_nr,
306 boolean is_uplink,
307 OCT2 padding,
308 TfiUsfArr tfi_usf
309 } with { variant (is_uplink) "FIELDLENGTH(8)" };
310
Harald Weltef6543322017-07-16 07:35:10 +0200311 type union L1ctlUlPayload {
312 L1ctlFbsbReq fbsb_req,
313 L1ctlCcchModeReq ccch_mode_req,
314 L1ctlTchModeReq tch_mode_req,
315 L1ctlRachReq rach_req,
316 L1ctlParReq par_req,
317 L1ctlDmEstReq dm_est_req,
318 L1ctlReset reset_req,
319 //L1ctlNeighPmReq neigh_pm_req,
Harald Weltee613f962018-04-18 22:38:16 +0200320 L1CtlCryptoReq crypto_req,
Harald Weltef6543322017-07-16 07:35:10 +0200321 L1ctlTrafficReq traffic_req,
Harald Welte00d4dac2017-07-30 00:50:32 +0200322 L1ctlTbfCfgReq tbf_cfg_req,
Harald Weltef6543322017-07-16 07:35:10 +0200323 octetstring other
Harald Welte7024baa2018-03-02 23:37:51 +0100324 } with {
325 variant (other) "BYTEORDER(first)"
326 };
Harald Weltef6543322017-07-16 07:35:10 +0200327
328 type record L1ctlUlMessage {
329 L1ctlHeader header,
330 L1ctlUlInfo ul_info optional,
Harald Welteb3c226e2017-07-30 17:18:01 +0200331 L1ctlUlTbfInfo ul_info_tbf optional,
Harald Welte3a40ec72018-03-02 20:45:04 +0100332 L1ctlUlAbsInfo ul_info_abs optional,
Harald Weltef6543322017-07-16 07:35:10 +0200333 L1ctlUlPayload payload
334 } with { variant (ul_info) "PRESENCE(header.msg_type = L1CTL_RACH_REQ,
335 header.msg_type = L1CTL_PARAM_REQ,
336 header.msg_type = L1CTL_CRYPTO_REQ,
337 header.msg_type = L1CTL_DATA_REQ,
338 header.msg_type = L1CTL_DM_EST_REQ,
339 header.msg_type = L1CTL_DM_FREQ_REQ,
340 header.msg_type = L1CTL_DM_REL_REQ,
341 header.msg_type = L1CTL_TRAFFIC_REQ)"
Harald Welteb3c226e2017-07-30 17:18:01 +0200342 variant (ul_info_tbf) "PRESENCE(header.msg_type = L1CTL_DATA_TBF_REQ)"
Harald Welte3a40ec72018-03-02 20:45:04 +0100343 variant (ul_info_abs) "PRESENCE(header.msg_type = L1CTL_DATA_ABS_REQ)"
Harald Weltef6543322017-07-16 07:35:10 +0200344 variant (payload) "CROSSTAG(fbsb_req, header.msg_type = L1CTL_FBSB_REQ;
345 ccch_mode_req, header.msg_type = L1CTL_CCCH_MODE_REQ;
346 tch_mode_req, header.msg_type = L1CTL_TCH_MODE_REQ;
347 rach_req, header.msg_type = L1CTL_RACH_REQ;
348 par_req, header.msg_type = L1CTL_PARAM_REQ;
349 dm_est_req, header.msg_type = L1CTL_DM_EST_REQ;
350 reset_req, header.msg_type = L1CTL_RESET_REQ;
Harald Weltee613f962018-04-18 22:38:16 +0200351 crypto_req, header.msg_type = L1CTL_CRYPTO_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200352 traffic_req, header.msg_type = L1CTL_TRAFFIC_REQ;
Harald Welte00d4dac2017-07-30 00:50:32 +0200353 tbf_cfg_req, header.msg_type = L1CTL_TBF_CFG_REQ;
Harald Weltef6543322017-07-16 07:35:10 +0200354 other, OTHERWISE;
355 )" };
356
357 external function enc_L1ctlUlMessage(in L1ctlUlMessage msg) return octetstring
358 with { extension "prototype(convert) encode(RAW)" };
359 external function dec_L1ctlUlMessage(in octetstring stream) return L1ctlUlMessage
360 with { extension "prototype(convert) decode(RAW)" };
361
Harald Welte52c713c2017-07-16 15:44:44 +0200362 type record L1ctlUlMessageLV {
363 uint16_t len,
364 L1ctlUlMessage msg
365 } with { variant (len) "LENGTHTO(msg)" };
366
367 external function enc_L1ctlUlMessageLV(in L1ctlUlMessageLV msg) return octetstring
368 with { extension "prototype(convert) encode(RAW)" };
369 external function dec_L1ctlUlMessageLV(in octetstring stream) return L1ctlUlMessageLV
370 with { extension "prototype(convert) decode(RAW)" };
371
372 type record L1ctlDlMessageLV {
373 uint16_t len,
374 L1ctlDlMessage msg
375 } with { variant (len) "LENGTHTO(msg)" };
376
377 external function enc_L1ctlDlMessageLV(in L1ctlDlMessageLV msg) return octetstring
378 with { extension "prototype(convert) encode(RAW)" };
379 external function dec_L1ctlDlMessageLV(in octetstring stream) return L1ctlDlMessageLV
380 with { extension "prototype(convert) decode(RAW)" };
381
382
Harald Welte9e4725d2017-07-16 23:18:09 +0200383
384
385 /* for generating RESET_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100386 template (value) L1ctlUlMessage t_L1ctlResetReq(L1ctlResetType rst_type) := {
387 header := ts_L1ctlHeader(L1CTL_RESET_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200388 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 reset_req := {
393 reset_type := rst_type,
394 padding := '000000'O
395 }
396 }
397 };
398
399 /* for generating FBSB_REQ */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100400 template (value) L1ctlUlMessage ts_L1CTL_FBSB_REQ(Arfcn arfcn, L1ctlFbsbFlags flags,
401 uint8_t sync_info_idx,
402 L1ctlCcchMode ccch_mode,
403 GsmRxLev rxlev_exp) := {
404 header := ts_L1ctlHeader(L1CTL_FBSB_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200405 ul_info := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200406 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100407 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200408 payload := {
409 fbsb_req := {
410 arfcn := arfcn,
Harald Weltea82f7e62018-02-22 18:51:33 +0100411 timeout_tdma_frames := 250, /* about 1s */
Harald Welte9e4725d2017-07-16 23:18:09 +0200412 freq_err_thresh1 := 10000,
413 freq_err_thresh2 := 800,
414 num_freqerr_avg := 3,
415 flags := flags,
416 sync_info_idx := sync_info_idx,
417 ccch_mode := ccch_mode,
418 rxlev_exp := rxlev_exp
419 }
420 }
421 };
422
423 /* for matching against incoming FBSB_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100424 template L1ctlDlMessage tr_L1CTL_FBSB_CONF(template uint8_t result) := {
425 header := tr_L1ctlHeader(L1CTL_FBSB_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200426 dl_info := ?,
427 payload := {
428 fbsb_conf := {
429 initial_freq_err := ?,
430 result := result,
431 bsic := ?
432 }
433 }
434 };
435
Harald Weltef8df4cb2018-03-10 15:15:08 +0100436 template (value) L1ctlUlMessage ts_L1CTL_CCCH_MODE_REQ(L1ctlCcchMode ccch_mode) := {
437 header := ts_L1ctlHeader(L1CTL_CCCH_MODE_REQ),
438 ul_info := omit,
439 ul_info_tbf := omit,
440 ul_info_abs := omit,
441 payload := {
442 ccch_mode_req := {
443 ccch_mode := ccch_mode,
444 padding := '000000'O
445 }
446 }
447 };
448
Harald Welte3757e602018-03-10 17:12:02 +0100449
450 template L1ctlDlMessage tr_L1CTL_MsgType(template L1ctlMsgType msg_type) := {
451 header := tr_L1ctlHeader(msg_type),
452 dl_info := *,
Harald Weltef56cc492018-04-15 10:58:43 +0200453 payload := *
Harald Welte3757e602018-03-10 17:12:02 +0100454 }
455
456 template L1ctlDlMessage tr_L1CTL_CCCH_MODE_CONF := tr_L1CTL_MsgType(L1CTL_CCCH_MODE_CONF);
Harald Weltef8df4cb2018-03-10 15:15:08 +0100457
458 template L1ctlUlMessage ts_L1CTL_RACH_REQ(uint8_t ra, uint8_t combined, uint16_t offset) := {
459 header := ts_L1ctlHeader(L1CTL_RACH_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200460 ul_info := {
461 chan_nr := t_RslChanNr_RACH(0),
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 rach_req := {
469 ra := ra,
470 combined := combined,
471 offset := offset
472 }
473 }
474 }
475
Harald Weltef8df4cb2018-03-10 15:15:08 +0100476 template L1ctlUlMessage ts_L1CTL_PAR_REQ(uint8_t ta, uint8_t tx_power) := {
477 header := ts_L1ctlHeader(L1CTL_PARAM_REQ),
Harald Welte37052732018-03-09 19:38:46 +0100478 ul_info := {
479 chan_nr := t_RslChanNr_RACH(0),
480 link_id := ts_RslLinkID_DCCH(0),
481 padding := '0000'O
482 },
483 ul_info_tbf := omit,
484 ul_info_abs := omit,
485 payload := {
486 par_req := {
487 ta := ta,
488 tx_power := tx_power,
489 padding := '0000'O
490 }
491 }
492 }
493
Harald Weltef8df4cb2018-03-10 15:15:08 +0100494 template L1ctlUlMessage ts_L1CTL_DM_EST_REQ(Arfcn arfcn, RslChannelNr chan_nr, GsmTsc tsc) := {
495 header := ts_L1ctlHeader(L1CTL_DM_EST_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200496 ul_info := {
497 chan_nr := chan_nr,
498 link_id := ts_RslLinkID_DCCH(0),
499 padding := '0000'O
500 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200501 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100502 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200503 payload := {
504 dm_est_req := {
505 tsc := tsc,
506 h := 0,
507 arfcn := arfcn,
508 hopping := omit,
509 tch_mode := 0,
510 audio_mode := t_L1CTL_AudioModeNone
511 }
512 }
513 }
514
Harald Weltef8df4cb2018-03-10 15:15:08 +0100515 template L1ctlUlMessage ts_L1CTL_DM_REL_REQ(RslChannelNr chan_nr) := {
516 header := ts_L1ctlHeader(L1CTL_DM_REL_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200517 ul_info := {
518 chan_nr := chan_nr,
519 link_id := ts_RslLinkID_DCCH(0),
520 padding := '0000'O
521 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200522 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100523 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200524 payload := {
525 other := ''O
526 }
527 }
528
Harald Weltef8df4cb2018-03-10 15:15:08 +0100529 template (value) L1ctlUlMessage ts_L1CTL_DATA_REQ(template (value) RslChannelNr chan_nr,
530 template (value) RslLinkId link_id,
531 octetstring l2_data) := {
532 header := ts_L1ctlHeader(L1CTL_DATA_REQ),
Harald Welte9e4725d2017-07-16 23:18:09 +0200533 ul_info := {
534 chan_nr := chan_nr,
535 link_id := link_id,
536 padding := '0000'O
537 },
Harald Welteb3c226e2017-07-30 17:18:01 +0200538 ul_info_tbf := omit,
Harald Welte3a40ec72018-03-02 20:45:04 +0100539 ul_info_abs := omit,
Harald Welte9e4725d2017-07-16 23:18:09 +0200540 payload := {
541 other := l2_data
542 }
543 }
544
Harald Weltef8df4cb2018-03-10 15:15:08 +0100545 template (value) L1ctlUlMessage ts_L1CTL_TBF_CFG_REQ(boolean is_uplink, TfiUsfArr tfi_usf) := {
546 header := ts_L1ctlHeader(L1CTL_TBF_CFG_REQ),
Harald Welte00d4dac2017-07-30 00:50:32 +0200547 ul_info := omit,
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 Welte00d4dac2017-07-30 00:50:32 +0200550 payload := {
551 tbf_cfg_req := {
552 tbf_nr := 0,
553 is_uplink := is_uplink,
554 padding := '0000'O,
555 tfi_usf := tfi_usf
556 }
557 }
558 };
559
Harald Weltef8df4cb2018-03-10 15:15:08 +0100560 template L1ctlDlMessage tr_L1CTL_TBF_CFG_CONF(template boolean is_uplink) := {
561 header := tr_L1ctlHeader(L1CTL_TBF_CFG_CONF),
Harald Welte00d4dac2017-07-30 00:50:32 +0200562 dl_info := omit,
563 payload := {
564 tbf_cfg_conf := {
565 tbf_nr := 0,
566 is_uplink := is_uplink,
567 padding := ?,
568 tfi_usf := ?
569 }
570 }
571 };
572
Harald Weltef8df4cb2018-03-10 15:15:08 +0100573 template (value) L1ctlUlMessage ts_L1CTL_DATA_TBF_REQ(octetstring l2_data,
574 L1ctlGprsCs cs := L1CTL_CS1,
575 uint8_t tbf_nr := 0) := {
576 header := ts_L1ctlHeader(L1CTL_DATA_TBF_REQ),
Harald Welteb3c226e2017-07-30 17:18:01 +0200577 ul_info := omit,
578 ul_info_tbf := {
579 tbf_nr := tbf_nr,
Harald Welte1dcc3712017-08-01 00:05:52 +0200580 cs := cs,
581 padding := '0000'O
Harald Welteb3c226e2017-07-30 17:18:01 +0200582 },
Harald Welte3a40ec72018-03-02 20:45:04 +0100583 ul_info_abs := omit,
Harald Welteb3c226e2017-07-30 17:18:01 +0200584 payload := {
585 other := l2_data
586 }
587 }
588
Harald Weltef8df4cb2018-03-10 15:15:08 +0100589 template (value) L1ctlUlMessage ts_L1CTL_DATA_ABS_REQ(octetstring l2_data, Arfcn arfcn,
Harald Welte3a40ec72018-03-02 20:45:04 +0100590 uint8_t ts, GsmFrameNumber fn,
591 L1ctlGprsCs cs := L1CTL_CS1,
592 uint8_t tbf_nr := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100593 header := ts_L1ctlHeader(L1CTL_DATA_ABS_REQ),
Harald Welte3a40ec72018-03-02 20:45:04 +0100594 ul_info := omit,
595 ul_info_tbf := omit,
596 ul_info_abs := {
597 tbf_nr := tbf_nr,
598 cs := cs,
599 ts_nr := ts,
600 padding := '00'O,
601 fn := fn,
602 arfcn := arfcn,
603 padding2 := '0000'O
604 },
605 payload := {
606 other := l2_data
607 }
608 }
609
610
Harald Welte9e4725d2017-07-16 23:18:09 +0200611 /* for matching against incoming RACH_CONF */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100612 template L1ctlDlMessage tr_L1CTL_RACH_CONF := {
613 header := tr_L1ctlHeader(L1CTL_RACH_CONF),
Harald Welte9e4725d2017-07-16 23:18:09 +0200614 dl_info := ?,
Harald Weltef56cc492018-04-15 10:58:43 +0200615 payload := *
Harald Welte9e4725d2017-07-16 23:18:09 +0200616 };
617
Harald Weltece6dc442018-02-21 22:00:21 +0100618 /* for matching against incoming DATA_IND */
Harald Weltef8df4cb2018-03-10 15:15:08 +0100619 template L1ctlDlMessage tr_L1CTL_DATA_IND(template RslChannelNr chan_nr,
Harald Welte68e495b2018-02-25 00:05:57 +0100620 template RslLinkId link_id := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100621 template octetstring l2_data := ?,
622 template uint8_t num_biterr := 0,
623 template uint8_t fire_crc := 0) := {
Harald Weltef8df4cb2018-03-10 15:15:08 +0100624 header := tr_L1ctlHeader(L1CTL_DATA_IND),
Harald Welte9e4725d2017-07-16 23:18:09 +0200625 dl_info := {
626 chan_nr := chan_nr,
Harald Weltece6dc442018-02-21 22:00:21 +0100627 link_id := link_id,
Harald Welte9e4725d2017-07-16 23:18:09 +0200628 arfcn := ?,
629 frame_nr := ?,
630 rx_level := ?,
631 snr := ?,
Harald Welte629cc6b2018-03-11 17:19:05 +0100632 num_biterr := num_biterr,
633 fire_crc := fire_crc
Harald Welte9e4725d2017-07-16 23:18:09 +0200634 },
635 payload := {
Harald Welte68e495b2018-02-25 00:05:57 +0100636 data_ind := {
637 payload := l2_data
638 }
Harald Welte9e4725d2017-07-16 23:18:09 +0200639 }
640 };
641
Harald Weltee613f962018-04-18 22:38:16 +0200642 template (value) L1ctlUlMessage ts_L1CTL_CRYPTO_REQ(RslChannelNr chan_nr, uint8_t algo,
643 octetstring key) := {
644 header := ts_L1ctlHeader(L1CTL_CRYPTO_REQ),
645 ul_info := {
646 chan_nr := chan_nr,
647 link_id := ts_RslLinkID_DCCH(0),
648 padding := '0000'O
649 },
650 ul_info_tbf := omit,
651 ul_info_abs := omit,
652 payload := {
653 crypto_req := {
654 algo := algo,
655 key_len := 0, /* overwritten */
656 key := key
657 }
658 }
659 };
660
Harald Welte88849c62017-07-30 17:19:41 +0200661 template ImmediateAssignment t_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
662 ded_or_tbf := ?,
663 page_mode := ?,
664 chan_desc := *,
665 pkt_chan_desc := *,
666 req_ref := f_compute_ReqRef(ra, fn),
667 timing_advance := ?,
668 mobile_allocation := ?,
669 rest_octets:= ?
670 };
671
672 template GsmRrMessage t_RR_IMM_ASS(uint8_t ra, GsmFrameNumber fn) := {
Harald Welte9e4725d2017-07-16 23:18:09 +0200673 header := t_RrHeader(IMMEDIATE_ASSIGNMENT, ?),
674 payload := {
Harald Welte88849c62017-07-30 17:19:41 +0200675 imm_ass := t_IMM_ASS(ra, fn)
Harald Welte9e4725d2017-07-16 23:18:09 +0200676 }
677 };
678
Harald Welte68e495b2018-02-25 00:05:57 +0100679 const octetstring c_DummyUI := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O;
680
Harald Welte7024baa2018-03-02 23:37:51 +0100681/* We use "BYTEORDER(last)" so we get little-endian integers. Unfortuantely, this also
682 switches the byte ordering in octet strings, so we need to explicitly annotate them :/ */
Harald Weltef6543322017-07-16 07:35:10 +0200683} with { encode "RAW" };