blob: 2216a0e7509d118058b3de92dc303d26b5d6ef51 [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* Osmocom PCU Interface Types, as per osmo-pcu/include/osmocom/pcu/pcuif_proto.h
2 * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
3 * contributions by Vadim Yanitskiy <axilirator@gmail.com>
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
Harald Welte883340c2018-02-28 18:59:29 +010012module PCUIF_Types {
13
14import from General_Types all;
15import from Osmocom_Types all;
Alexander Couzens1e5dc482020-07-28 15:38:46 +020016import from Native_Functions all;
Harald Welte883340c2018-02-28 18:59:29 +010017
Vadim Yanitskiyc1559302020-07-19 16:39:12 +070018modulepar {
19 /* PCUIF version supported by the IUT */
Vadim Yanitskiybefa21c2020-09-22 00:53:16 +070020 PCUIF_Version mp_pcuif_version := 10;
Vadim Yanitskiy220fa202020-09-15 19:15:01 +070021 /* Whether to pad outgoing messages */
22 boolean mp_pcuif_padding := true;
Vadim Yanitskiyc1559302020-07-19 16:39:12 +070023};
24
Harald Welte883340c2018-02-28 18:59:29 +010025const charstring PCU_SOCK_DEFAULT := "/tmp/pcu_bts";
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +070026type integer PCUIF_Version (9..10); /* supported versions */
Harald Welte883340c2018-02-28 18:59:29 +010027
28type enumerated PCUIF_MsgType {
29 PCU_IF_MSG_DATA_REQ ('00'O),
30 PCU_IF_MSG_DATA_CNF ('01'O),
31 PCU_IF_MSG_DATA_IND ('02'O),
32 PCU_IF_MSG_SUSP_REQ ('03'O),
Harald Welte11b734c2019-09-05 14:17:54 +020033 PCU_IF_MSG_APP_INFO_REQ ('04'O),
Harald Welte883340c2018-02-28 18:59:29 +010034 PCU_IF_MSG_RTS_REQ ('10'O),
35 PCU_IF_MSG_DATA_CNF_DT ('11'O),
36 PCU_IF_MSG_RACH_IND ('22'O),
37 PCU_IF_MSG_INFO_IND ('32'O),
38 PCU_IF_MSG_ACT_REQ ('40'O),
39 PCU_IF_MSG_TIME_IND ('52'O),
40 PCU_IF_MSG_PAG_REQ ('60'O),
41 PCU_IF_MSG_TXT_IND ('70'O)
42} with { variant "FIELDLENGTH(8)" };
43
44type enumerated PCUIF_Sapi {
45 PCU_IF_SAPI_UNKNOWN ('00'O),
46 PCU_IF_SAPI_RACH ('01'O),
47 PCU_IF_SAPI_AGCH ('02'O),
48 PCU_IF_SAPI_PCH ('03'O),
49 PCU_IF_SAPI_BCCH ('04'O),
50 PCU_IF_SAPI_PDTCH ('05'O),
51 PCU_IF_SAPI_PRACH ('06'O),
52 PCU_IF_SAPI_PTCCH ('07'O),
53 PCU_IF_SAPI_AGCH_DT ('08'O)
54} with { variant "FIELDLENGTH(8)" };
55
56type record PCUIF_Flags {
57 boolean bts_active,
58 boolean sysmo_direct_dsp,
59 BIT14 spare,
60 boolean cs1,
61 boolean cs2,
62 boolean cs3,
63 boolean cs4,
64 boolean mcs1,
65 boolean mcs2,
66 boolean mcs3,
67 boolean mcs4,
68 boolean mcs5,
69 boolean mcs6,
70 boolean mcs7,
71 boolean mcs8,
72 boolean mcs9,
73 BIT3 spare2
74} with { variant "" };
75
76type enumerated PCUIF_TextType {
77 PCU_VERSION (0),
78 PCU_OML_ALERT (1)
79} with { variant "FIELDLENGTH(8)" };
80
Vadim Yanitskiye1527f72019-09-09 02:15:33 +020081type charstring PCUIF_Text length(128) with { variant "FIELDLENGTH(null_terminated)" };
Harald Welte883340c2018-02-28 18:59:29 +010082
83type record PCUIF_txt_ind {
84 PCUIF_TextType txt_type,
85 PCUIF_Text text
86} with { variant "" };
87
Harald Welte883340c2018-02-28 18:59:29 +010088type record PCUIF_data {
89 PCUIF_Sapi sapi,
90 uint8_t len,
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +020091 octetstring data length(162),
Harald Welte883340c2018-02-28 18:59:29 +010092 uint32_t fn,
93 uint16_t arfcn,
94 uint8_t trx_nr,
95 uint8_t ts_nr,
96 uint8_t block_nr,
97 int8_t rssi,
98 uint16_t ber10k,
99 int16_t ta_offs_qbits,
100 int16_t lqual_cb
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +0200101} with { variant (data) "FIELDLENGTH(162), ALIGN(left)" };
Harald Welte883340c2018-02-28 18:59:29 +0100102
103type record PCUIF_data_cnf_dt {
104 PCUIF_Sapi sapi,
105 OCT4 tlli,
106 uint32_t fn,
107 uint16_t arfcn,
108 uint8_t trx_nr,
109 uint8_t ts_nr,
110 uint8_t block_nr,
111 int8_t rssi,
112 uint16_t ber10k,
113 int16_t ta_offs_qbits,
114 int16_t lqual_cb
115} with { variant "" };
116
117type record PCUIF_rts_req {
118 PCUIF_Sapi sapi,
119 OCT3 spare,
120 uint32_t fn,
121 uint16_t arfcn,
122 uint8_t trx_nr,
123 uint8_t ts_nr,
124 uint8_t block_nr
125} with { variant "" };
126
Harald Welte913bbf62019-03-01 00:39:19 +0100127type enumerated PCUIF_BurstType {
128 BURST_TYPE_NONE (0),
129 BURST_TYPE_0 (1),
130 BURST_TYPE_1 (2),
131 BURST_TYPE_2 (3)
132} with { variant "FIELDLENGTH(8)" };
133
Harald Welte883340c2018-02-28 18:59:29 +0100134type record PCUIF_rach_ind {
135 PCUIF_Sapi sapi,
136 uint16_t ra,
137 int16_t qta,
138 uint32_t fn,
139 uint16_t arfcn,
140 uint8_t is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700141 PCUIF_BurstType burst_type,
142 uint8_t trx_nr,
143 uint8_t ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100144} with { variant "" };
145
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700146type record PCUIF_InfoTrxTs {
147 uint8_t tsc,
148 uint8_t hopping,
149 uint8_t hsn,
150 uint8_t maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700151 uint8_t ma_bit_len,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700152 bitstring ma length(64)
153} with { variant (ma) "BYTEORDER(first), BITORDER(msb)" };
154private type record length(8) of PCUIF_InfoTrxTs PCUIF_InfoTrxTsList;
155
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100156private type record PCUIF_InfoTrx {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700157 uint16_t arfcn,
158 BIT8 pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700159 OCT1 spare,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700160 uint32_t hLayer1,
161 PCUIF_InfoTrxTsList ts
162} with { variant (pdch_mask) "BITORDER(msb)" };
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100163type record length(8) of PCUIF_InfoTrx PCUIF_InfoTrxs;
Harald Welte883340c2018-02-28 18:59:29 +0100164
165type record PCUIF_info_ind {
166 uint32_t version,
167 PCUIF_Flags flags,
Harald Weltee1fd9162019-02-18 19:47:53 +0100168 PCUIF_InfoTrxs trx,
Harald Welte883340c2018-02-28 18:59:29 +0100169 uint8_t bsic,
170
171 uint16_t mcc,
172 uint16_t mnc,
Harald Welte3568dc72018-03-13 17:06:51 +0100173 uint8_t mnc_3_digits,
Harald Welte883340c2018-02-28 18:59:29 +0100174 uint16_t lac,
175 uint16_t rac,
176
177 uint16_t nsei,
178 record length(7) of uint8_t nse_timer,
179 record length(11) of uint8_t cell_timer,
180
181 uint16_t cell_id,
182 uint16_t repeat_time,
183 uint8_t repeat_count,
184 uint16_t bvci,
185 uint8_t t3142,
186 uint8_t t3169,
187 uint8_t t3191,
188 uint8_t t3193_10ms,
189 uint8_t t3195,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100190 uint8_t n3101,
191 uint8_t n3103,
192 uint8_t n3105,
Harald Welte883340c2018-02-28 18:59:29 +0100193 uint8_t cv_countdown,
194 uint16_t dl_tbf_ext,
195 uint16_t ul_tbf_ext,
196 uint8_t initial_cs,
197 uint8_t initial_mcs,
198
199 record length(2) of uint16_t nsvci,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700200 record length(2) of uint16_t local_port,
Harald Welte883340c2018-02-28 18:59:29 +0100201 record length(2) of uint16_t remote_port,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200202 PCUIF_RemoteAddr remote_addr
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200203} with { variant "" };
204
205type enumerated PCUIF_AddrType {
206 PCUIF_ADDR_TYPE_UNSPEC ('00'O),
207 PCUIF_ADDR_TYPE_IPV4 ('04'O),
208 PCUIF_ADDR_TYPE_IPV6 ('29'O)
209} with { variant "FIELDLENGTH(8)" };
210
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100211type record PCUIF_RemoteAddr {
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200212 record length(2) of PCUIF_AddrType addr_type,
213 record length(2) of octetstring addr length(16)
214} with { variant "" };
215
Harald Welte883340c2018-02-28 18:59:29 +0100216type record PCUIF_act_req {
217 uint8_t is_activate,
218 uint8_t trx_nr,
219 uint8_t ts_nr,
220 OCT1 spare
221} with { variant "" };
222
223type record PCUIF_time_ind {
224 uint32_t fn
225} with { variant "" };
226
227type record PCUIF_pag_req {
228 PCUIF_Sapi sapi,
229 uint8_t chan_needed,
230 OCT9 identity_lv
231} with { variant "" };
232
Harald Welte11b734c2019-09-05 14:17:54 +0200233type record PCUIF_app_info_req {
234 uint8_t application_type,
235 uint8_t len,
236 octetstring data
237} with {
238 variant (len) "LENGTHTO(data)"
239}
240
Harald Welte883340c2018-02-28 18:59:29 +0100241type record PCUIF_susp_req {
242 OCT4 tlli,
243 OCT6 ra_id,
244 uint8_t cause
Harald Welteeaa9a862019-05-26 23:01:08 +0200245} with {
246 variant (tlli) "BYTEORDER(last)"
247};
Harald Welte883340c2018-02-28 18:59:29 +0100248
249
250type union PCUIF_MsgUnion {
251 PCUIF_data data_req,
252 PCUIF_data data_cnf,
253 PCUIF_data_cnf_dt data_cnf_dt,
254 PCUIF_data data_ind,
255 PCUIF_susp_req susp_req,
256 PCUIF_rts_req rts_req,
257 PCUIF_rach_ind rach_ind,
258 PCUIF_txt_ind txt_ind,
259 PCUIF_info_ind info_ind,
260 PCUIF_act_req act_req,
261 PCUIF_time_ind time_ind,
Harald Welte11b734c2019-09-05 14:17:54 +0200262 PCUIF_pag_req pag_req,
263 PCUIF_app_info_req app_info_req
Harald Welte883340c2018-02-28 18:59:29 +0100264} with { variant "" };
265
266type record PCUIF_Message {
267 PCUIF_MsgType msg_type,
268 uint8_t bts_nr,
269 OCT2 spare,
270 PCUIF_MsgUnion u
271} with { variant (u) "CROSSTAG(
272 data_req, msg_type = PCU_IF_MSG_DATA_REQ;
273 data_cnf, msg_type = PCU_IF_MSG_DATA_CNF;
274 data_cnf_dt, msg_type = PCU_IF_MSG_DATA_CNF_DT;
275 data_ind, msg_type = PCU_IF_MSG_DATA_IND;
276 susp_req, msg_type = PCU_IF_MSG_SUSP_REQ;
277 rts_req, msg_type = PCU_IF_MSG_RTS_REQ;
278 rach_ind, msg_type = PCU_IF_MSG_RACH_IND;
279 txt_ind, msg_type = PCU_IF_MSG_TXT_IND;
280 info_ind, msg_type = PCU_IF_MSG_INFO_IND;
281 act_req, msg_type = PCU_IF_MSG_ACT_REQ;
282 time_ind, msg_type = PCU_IF_MSG_TIME_IND;
Harald Welte11b734c2019-09-05 14:17:54 +0200283 pag_req, msg_type = PCU_IF_MSG_PAG_REQ;
284 app_info_req, msg_type = PCU_IF_MSG_APP_INFO_REQ)"
Harald Welte883340c2018-02-28 18:59:29 +0100285};
286
287external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring
288 with { extension "prototype(convert) encode(RAW)" };
289external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message
290 with { extension "prototype(convert) decode(RAW)" };
291
Vadim Yanitskiy220fa202020-09-15 19:15:01 +0700292function enc_pad_PCUIF_Message(in PCUIF_Message pdu)
293return octetstring {
294 var octetstring stream;
295 var integer len;
296
297 stream := enc_PCUIF_Message(pdu);
298 if (not mp_pcuif_padding) {
299 return stream;
300 }
301
302 select (mp_pcuif_version) {
303 case (9) { len := 212; }
304 /* FIXME: 1006 % 4 > 0 (alignment) */
305 case (10) { len := 1006; }
306 case else { len := 0; }
307 }
308
309 return f_pad_oct(stream, len, '00'O);
310}
311
Harald Welte883340c2018-02-28 18:59:29 +0100312
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200313/* Generic template for matching messages by type and/or the BTS number */
314template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
315 template uint8_t bts_nr := ?) := {
316 msg_type := msg_type,
317 bts_nr := bts_nr,
318 spare := ?,
319 u := ?
320}
321
Harald Weltee1fd9162019-02-18 19:47:53 +0100322template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
323 template (value) uint8_t trx_nr,
324 template (value) uint8_t ts_nr,
325 template (value) PCUIF_Sapi sapi,
326 template (value) uint32_t fn,
327 template (value) uint16_t arfcn,
328 template (value) uint8_t block_nr
329 ) := {
330 msg_type := PCU_IF_MSG_RTS_REQ,
331 bts_nr := bts_nr,
332 spare := '0000'O,
333 u := {
334 rts_req := {
335 sapi := sapi,
336 spare := '000000'O,
337 fn := fn,
338 arfcn := arfcn,
339 trx_nr := trx_nr,
340 ts_nr := ts_nr,
341 block_nr := block_nr
342 }
343 }
344}
Harald Welte883340c2018-02-28 18:59:29 +0100345template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
346 template uint8_t trx_nr := ?,
347 template uint8_t ts_nr := ?,
348 template PCUIF_Sapi sapi := ?,
349 template uint32_t fn := ?,
350 template uint8_t block_nr := ?
351 ) := {
352 msg_type := PCU_IF_MSG_RTS_REQ,
353 bts_nr := bts_nr,
354 spare := ?,
355 u := {
356 rts_req := {
357 sapi := sapi,
358 spare := ?,
359 fn := fn,
360 arfcn := ?,
361 trx_nr := trx_nr,
362 ts_nr := ts_nr,
363 block_nr := block_nr
364 }
365 }
366}
367
368template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
369 msg_type := PCU_IF_MSG_TXT_IND,
370 bts_nr := bts_nr,
371 spare := '0000'O,
372 u := {
373 txt_ind := {
374 txt_type := tt,
375 text := text
376 }
377 }
378}
Harald Weltee1fd9162019-02-18 19:47:53 +0100379template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
380 template charstring text := ?) := {
381 msg_type := PCU_IF_MSG_TXT_IND,
382 bts_nr := bts_nr,
383 spare := '0000'O,
384 u := {
385 txt_ind := {
386 txt_type := tt,
387 text := text
388 }
389 }
390}
391
392
Harald Welte883340c2018-02-28 18:59:29 +0100393
394template (value) PCUIF_Message ts_PCUIF_ACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
395 msg_type := PCU_IF_MSG_ACT_REQ,
396 bts_nr := bts_nr,
397 spare := '0000'O,
398 u := {
399 act_req := {
400 is_activate := 1,
401 trx_nr := trx_nr,
402 ts_nr := ts_nr,
403 spare := '00'O
404 }
405 }
406}
Harald Weltee1fd9162019-02-18 19:47:53 +0100407template PCUIF_Message tr_PCUIF_ACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
408 template uint8_t ts_nr) := {
409 msg_type := PCU_IF_MSG_ACT_REQ,
410 bts_nr := bts_nr,
411 spare := '0000'O,
412 u := {
413 act_req := {
414 is_activate := 1,
415 trx_nr := trx_nr,
416 ts_nr := ts_nr,
417 spare := '00'O
418 }
419 }
420}
Harald Welte883340c2018-02-28 18:59:29 +0100421
422template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
423 msg_type := PCU_IF_MSG_ACT_REQ,
424 bts_nr := bts_nr,
425 spare := '0000'O,
426 u := {
427 act_req := {
428 is_activate := 0,
429 trx_nr := trx_nr,
430 ts_nr := ts_nr,
431 spare := '00'O
432 }
433 }
434}
Harald Weltee1fd9162019-02-18 19:47:53 +0100435template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
436 template uint8_t ts_nr) := {
437 msg_type := PCU_IF_MSG_ACT_REQ,
438 bts_nr := bts_nr,
439 spare := '0000'O,
440 u := {
441 act_req := {
442 is_activate := 0,
443 trx_nr := trx_nr,
444 ts_nr := ts_nr,
445 spare := '00'O
446 }
447 }
448}
Harald Welte883340c2018-02-28 18:59:29 +0100449
Harald Weltee1fd9162019-02-18 19:47:53 +0100450template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
451 template (value) uint8_t trx_nr,
452 template (value) uint8_t ts_nr,
453 template (value) uint8_t block_nr,
454 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700455 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100456 template (value) uint32_t fn,
457 template (value) uint16_t arfcn,
458 template (value) int8_t rssi := -80,
459 template (value) uint16_t ber10k := 0,
460 template (value) int16_t ta_offs_qbits := 0,
461 template (value) uint16_t lqual_cb := 10) := {
462 msg_type := PCU_IF_MSG_DATA_IND,
463 bts_nr := bts_nr,
464 spare := '0000'O,
465 u := {
466 data_ind := {
467 sapi := sapi,
468 len := lengthof(valueof(data)),
469 data := data,
470 fn := fn,
471 arfcn := arfcn,
472 trx_nr := trx_nr,
473 ts_nr := ts_nr,
474 block_nr := block_nr,
475 rssi := rssi,
476 ber10k := ber10k,
477 ta_offs_qbits := ta_offs_qbits,
478 lqual_cb := lqual_cb
479 }
480 }
481}
Harald Welte883340c2018-02-28 18:59:29 +0100482template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
483 template uint8_t trx_nr := ?,
484 template uint8_t ts_nr := ?,
485 template uint8_t block_nr := ?,
486 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700487 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100488 msg_type := PCU_IF_MSG_DATA_IND,
489 bts_nr := bts_nr,
490 spare := ?,
491 u := {
492 data_ind := {
493 sapi := sapi,
494 len := ?,
495 data := data,
496 fn := ?,
497 arfcn := ?,
498 trx_nr := trx_nr,
499 ts_nr := ts_nr,
500 block_nr := block_nr,
501 rssi := ?,
502 ber10k := ?,
503 ta_offs_qbits := ?,
504 lqual_cb := ?
505 }
506 }
507}
508
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100509template PCUIF_data tr_PCUIF_DATA(template uint8_t trx_nr,
510 template uint8_t ts_nr,
511 template uint8_t block_nr := ?,
512 template uint32_t fn := ?,
513 template PCUIF_Sapi sapi := ?,
514 template octetstring data := ?) := {
515 sapi := sapi,
516 len := ?,
517 data := data,
518 fn := fn,
519 arfcn := ?, /* unused in BTS */
520 trx_nr := trx_nr,
521 ts_nr := ts_nr,
522 block_nr := block_nr,
523 /* measurement parameters below unused on Tx */
524 rssi := 0,
525 ber10k := 0,
526 ta_offs_qbits := 0,
527 lqual_cb := 0
528
529}
530
Harald Welte883340c2018-02-28 18:59:29 +0100531template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
532 uint8_t ts_nr, uint8_t block_nr,
533 uint32_t fn, PCUIF_Sapi sapi,
534 octetstring data) := {
535 msg_type := PCU_IF_MSG_DATA_REQ,
536 bts_nr := bts_nr,
537 spare := '0000'O,
538 u := {
539 data_req := {
540 sapi := sapi,
541 len := lengthof(data),
542 data := data,
543 fn := fn,
544 arfcn := 0, /* unused in BTS */
545 trx_nr := trx_nr,
546 ts_nr := ts_nr,
547 block_nr := block_nr,
548 /* measurement parameters below unused on Tx */
549 rssi := 0,
550 ber10k := 0,
551 ta_offs_qbits := 0,
552 lqual_cb := 0
553 }
554 }
555}
Harald Weltee1fd9162019-02-18 19:47:53 +0100556template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
557 template uint8_t trx_nr,
558 template uint8_t ts_nr,
559 template uint8_t block_nr := ?,
560 template uint32_t fn := ?,
561 template PCUIF_Sapi sapi := ?,
562 template octetstring data := ?) := {
563 msg_type := PCU_IF_MSG_DATA_REQ,
564 bts_nr := bts_nr,
565 spare := '0000'O,
566 u := {
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100567 data_req := tr_PCUIF_DATA(trx_nr, ts_nr, block_nr, fn, sapi, data)
Harald Weltee1fd9162019-02-18 19:47:53 +0100568 }
569}
Harald Welte883340c2018-02-28 18:59:29 +0100570
Harald Weltee1fd9162019-02-18 19:47:53 +0100571template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
572 template (value) uint8_t trx_nr,
573 template (value) uint8_t ts_nr,
574 template (value) uint8_t block_nr,
575 template (value) uint32_t fn,
576 template (value) uint16_t arfcn,
577 template (value) PCUIF_Sapi sapi,
578 template (value) octetstring data) := {
579 msg_type := PCU_IF_MSG_DATA_CNF,
580 bts_nr := bts_nr,
581 spare := '0000'O,
582 u := {
583 data_cnf := {
584 sapi := sapi,
585 len := 0, /* overwritten */
586 data := data,
587 fn := fn,
588 arfcn := arfcn,
589 trx_nr := trx_nr,
590 ts_nr := ts_nr,
591 block_nr := block_nr,
592 rssi := 0,
593 ber10k := 0,
594 ta_offs_qbits := 0,
595 lqual_cb := 0
596 }
597 }
598}
Harald Welte883340c2018-02-28 18:59:29 +0100599template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
600 template uint8_t trx_nr := ?,
601 template uint8_t ts_nr := ?,
602 template PCUIF_Sapi sapi := ?,
603 template octetstring data := ?) := {
604 msg_type := PCU_IF_MSG_DATA_CNF,
605 bts_nr := bts_nr,
606 spare := ?,
607 u := {
608 data_cnf := {
609 sapi := sapi,
610 len := ?,
611 data := data,
612 fn := ?,
613 arfcn := ?,
614 trx_nr := trx_nr,
615 ts_nr := ts_nr,
616 block_nr := ?,
617 rssi := ?,
618 ber10k := ?,
619 ta_offs_qbits := ?,
620 lqual_cb := ?
621 }
622 }
623}
624
Harald Weltee1fd9162019-02-18 19:47:53 +0100625template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700626 template (value) uint8_t trx_nr,
627 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100628 template (value) uint16_t ra,
629 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100630 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100631 template (value) uint32_t fn,
632 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700633 template (value) int16_t qta := 0,
634 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100635) := {
636 msg_type := PCU_IF_MSG_RACH_IND,
637 bts_nr := bts_nr,
638 spare := '0000'O,
639 u := {
640 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700641 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100642 ra := ra,
643 qta := qta,
644 fn := fn,
645 arfcn := arfcn,
646 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700647 burst_type := burst_type,
648 trx_nr := trx_nr,
649 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100650 }
651 }
652}
Harald Welte883340c2018-02-28 18:59:29 +0100653template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700654 template uint8_t trx_nr := ?,
655 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100656 template uint16_t ra := ?,
657 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100658 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700659 template uint32_t fn := ?,
660 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100661 msg_type := PCU_IF_MSG_RACH_IND,
662 bts_nr := bts_nr,
663 spare := ?,
664 u := {
665 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700666 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100667 ra := ra,
668 qta := ?,
669 fn := fn,
670 arfcn := ?,
671 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700672 burst_type := burst_type,
673 trx_nr := trx_nr,
674 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100675 }
676 }
677}
678
Harald Weltee1fd9162019-02-18 19:47:53 +0100679template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
680 template (value) OCT9 id_lv,
681 template (value) uint8_t chan_needed,
682 template (value) PCUIF_Sapi sapi) := {
683 msg_type := PCU_IF_MSG_PAG_REQ,
684 bts_nr := bts_nr,
685 spare := '0000'O,
686 u := {
687 pag_req := {
688 sapi := sapi,
689 chan_needed := chan_needed,
690 identity_lv := id_lv
691 }
692 }
693}
Harald Welte883340c2018-02-28 18:59:29 +0100694template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
695 template OCT9 id_lv := ?,
696 template uint8_t chan_needed := ?,
697 template PCUIF_Sapi sapi := ?) := {
698 msg_type := PCU_IF_MSG_PAG_REQ,
699 bts_nr := bts_nr,
700 spare := ?,
701 u := {
702 pag_req := {
703 sapi := ?,
704 chan_needed := chan_needed,
705 identity_lv := id_lv
706 }
707 }
708}
709
Harald Weltee1fd9162019-02-18 19:47:53 +0100710const PCUIF_Flags c_PCUIF_Flags_default := {
711 bts_active := true,
712 sysmo_direct_dsp := false,
713 spare := '00000000000000'B,
714 cs1 := true,
715 cs2 := true,
716 cs3 := true,
717 cs4 := true,
718 mcs1 := true,
719 mcs2 := true,
720 mcs3 := true,
721 mcs4 := true,
722 mcs5 := true,
723 mcs6 := true,
724 mcs7 := true,
725 mcs8 := true,
726 mcs9 := true,
727 spare2 := '000'B
728};
729
Pau Espin Pedrol745a48b2020-10-30 15:31:07 +0100730const PCUIF_Flags c_PCUIF_Flags_noMCS := {
731 bts_active := true,
732 sysmo_direct_dsp := false,
733 spare := '00000000000000'B,
734 cs1 := true,
735 cs2 := true,
736 cs3 := true,
737 cs4 := true,
738 mcs1 := false,
739 mcs2 := false,
740 mcs3 := false,
741 mcs4 := false,
742 mcs5 := false,
743 mcs6 := false,
744 mcs7 := false,
745 mcs8 := false,
746 mcs9 := false,
747 spare2 := '000'B
748};
749
750function f_pcuif_ind_flags_egprs_enabled(PCUIF_Flags flags) return boolean {
751 return flags.mcs1 or flags.mcs2 or flags.mcs3 or flags.mcs4 or
752 flags.mcs5 or flags.mcs6 or flags.mcs7 or flags.mcs8 or
753 flags.mcs9;
754}
755
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700756template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
757 tsc := tsc,
758 hopping := 0,
759 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700760 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700761 ma := f_pad_bit(''B, 64, '0'B)
762};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700763template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
764 tsc := tsc,
765 hopping := 0,
766 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700767 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700768 ma := ?
769};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700770
771template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
772 template (value) uint6_t hsn := 0,
773 template (value) uint6_t maio := 0,
774 template (value) bitstring ma := ''B) := {
775 tsc := tsc,
776 hopping := 1,
777 hsn := hsn,
778 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700779 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700780 ma := f_pad_bit(valueof(ma), 64, '0'B)
781};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700782template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
783 template uint6_t hsn := ?,
784 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700785 template bitstring ma := ?,
786 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700787 tsc := tsc,
788 hopping := 1,
789 hsn := hsn,
790 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700791 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700792 ma := ma
793};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700794
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100795template (value) PCUIF_InfoTrx
796ts_PCUIF_InfoTrx(template (value) uint16_t arfcn := 871,
797 template (value) BIT8 pdch_mask := '00000001'B,
798 template (value) uint3_t tsc := 7) := {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700799 arfcn := arfcn,
800 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700801 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700802 hLayer1 := 0,
803 ts := {
804 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
805 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
806 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
807 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
808 }
809};
810
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100811template (value) PCUIF_InfoTrxs
812ts_PCUIF_InfoTrxs_def(uint16_t base_arfcn) := {
813 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 0),
814 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 1),
815 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 2),
816 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 3),
817 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 4),
818 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 5),
819 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 6),
820 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 7)
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700821};
Harald Weltee1fd9162019-02-18 19:47:53 +0100822
Harald Weltee1fd9162019-02-18 19:47:53 +0100823template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200824 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100825 msg_type := PCU_IF_MSG_INFO_IND,
826 bts_nr := bts_nr,
827 spare := '0000'O,
828 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200829 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100830 }
831}
Harald Welted378a252018-03-13 17:02:14 +0100832template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
833 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700834 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100835 msg_type := PCU_IF_MSG_INFO_IND,
836 bts_nr := bts_nr,
837 spare := ?,
838 u := {
839 info_ind := {
840 version := version,
841 flags := flags,
842 trx := ?,
843 bsic := ?,
844 mcc := ?,
845 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100846 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100847 lac := ?,
848 rac := ?,
849 nsei := ?,
850 nse_timer := ?,
851 cell_timer := ?,
852 cell_id := ?,
853 repeat_time := ?,
854 repeat_count := ?,
855 bvci := ?,
856 t3142 := ?,
857 t3169 := ?,
858 t3191 := ?,
859 t3193_10ms := ?,
860 t3195 := ?,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100861 n3101 := ?,
862 n3103 := ?,
863 n3105 := ?,
Harald Welted378a252018-03-13 17:02:14 +0100864 cv_countdown := ?,
865 dl_tbf_ext := ?,
866 ul_tbf_ext := ?,
867 initial_cs := ?,
868 initial_mcs := ?,
869 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700870 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100871 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200872 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100873 }
874 }
875}
876
Harald Weltea3219812019-03-02 00:02:28 +0100877template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
878 template (value) uint32_t fn) := {
879 msg_type := PCU_IF_MSG_TIME_IND,
880 bts_nr := bts_nr,
881 spare := '0000'O,
882 u := {
883 time_ind := {
884 fn := fn
885 }
886 }
887}
888template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
889 template uint32_t fn) := {
890 msg_type := PCU_IF_MSG_TIME_IND,
891 bts_nr := bts_nr,
892 spare := ?,
893 u := {
894 time_ind := {
895 fn := fn
896 }
897 }
898}
Harald Welte883340c2018-02-28 18:59:29 +0100899
Harald Welte4bff40a2019-03-21 21:34:10 +0100900template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
901 template (value) OCT4 tlli,
902 template (value) OCT6 ra_id,
903 template (value) uint8_t cause) := {
904 msg_type := PCU_IF_MSG_SUSP_REQ,
905 bts_nr := bts_nr,
906 spare := '0000'O,
907 u := {
908 susp_req := {
909 tlli := tlli,
910 ra_id := ra_id,
911 cause := cause
912 }
913 }
914}
915template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
916 template OCT4 tlli,
917 template OCT6 ra_id,
918 template uint8_t cause) := {
919 msg_type := PCU_IF_MSG_SUSP_REQ,
920 bts_nr := bts_nr,
921 spare := '0000'O,
922 u := {
923 susp_req := {
924 tlli := tlli,
925 ra_id := ra_id,
926 cause := cause
927 }
928 }
929}
930
Harald Welte11b734c2019-09-05 14:17:54 +0200931template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
932 template (value) uint8_t app_type,
933 template (value) octetstring app_data) := {
934 msg_type := PCU_IF_MSG_APP_INFO_REQ,
935 bts_nr := bts_nr,
936 spare := '0000'O,
937 u := {
938 app_info_req := {
939 application_type := app_type,
940 len := 0, /* overwritten */
941 data := app_data
942 }
943 }
944}
945template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
946 template (present) uint8_t app_type,
947 template (present) octetstring app_data) := {
948 msg_type := PCU_IF_MSG_APP_INFO_REQ,
949 bts_nr := bts_nr,
950 spare := '0000'O,
951 u := {
952 app_info_req := {
953 application_type := app_type,
954 len := ?,
955 data := app_data
956 }
957 }
958}
959
Harald Welte4bff40a2019-03-21 21:34:10 +0100960
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100961function f_PCUIF_PDCHMask_set(inout PCUIF_info_ind info, BIT8 pdch_mask,
962 template (present) uint8_t trx_nr := ?)
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700963{
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100964 for (var integer nr := 0; nr < lengthof(info.trx); nr := nr + 1) {
965 if (match(nr, trx_nr)) {
966 info.trx[nr].pdch_mask := pdch_mask;
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700967 }
968 }
969}
970
Alexander Couzense0f7c542020-09-13 17:25:18 +0200971function f_PCUIF_AF2addr_type(AddressFamily address_family)
972return PCUIF_AddrType {
973 if (address_family == AF_INET) {
974 return PCUIF_ADDR_TYPE_IPV4;
975 } else if (address_family == AF_INET6) {
976 return PCUIF_ADDR_TYPE_IPV6;
977 } else {
978 return PCUIF_ADDR_TYPE_UNSPEC;
979 }
980}
981
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200982/* TODO: second (redundant) NSVC connection is not (yet) supported */
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100983function f_PCUIF_RemoteAddr(PCUIF_AddrType addr_type,
984 charstring addr_str)
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200985return PCUIF_RemoteAddr {
986 var PCUIF_RemoteAddr remote_addr;
987
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100988 remote_addr.addr_type[0] := addr_type;
989 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
990 remote_addr.addr[0] := f_inet_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200991 } else {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100992 remote_addr.addr[0] := f_inet6_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200993 }
994
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100995 remote_addr.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
996 remote_addr.addr[1] := f_pad_oct(''O, 16, '00'O);
997
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200998 return remote_addr;
999}
1000
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001001
Harald Welte883340c2018-02-28 18:59:29 +01001002} with { encode "RAW" variant "BYTEORDER(first)" };