blob: 6cfe41009ba7fd542b5b656289c5cd7c0252ea6e [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 Yanitskiyc1559302020-07-19 16:39:12 +070021};
22
Harald Welte883340c2018-02-28 18:59:29 +010023const charstring PCU_SOCK_DEFAULT := "/tmp/pcu_bts";
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +070024type integer PCUIF_Version (9..10); /* supported versions */
Harald Welte883340c2018-02-28 18:59:29 +010025
26type enumerated PCUIF_MsgType {
27 PCU_IF_MSG_DATA_REQ ('00'O),
28 PCU_IF_MSG_DATA_CNF ('01'O),
29 PCU_IF_MSG_DATA_IND ('02'O),
30 PCU_IF_MSG_SUSP_REQ ('03'O),
Harald Welte11b734c2019-09-05 14:17:54 +020031 PCU_IF_MSG_APP_INFO_REQ ('04'O),
Harald Welte883340c2018-02-28 18:59:29 +010032 PCU_IF_MSG_RTS_REQ ('10'O),
33 PCU_IF_MSG_DATA_CNF_DT ('11'O),
34 PCU_IF_MSG_RACH_IND ('22'O),
35 PCU_IF_MSG_INFO_IND ('32'O),
36 PCU_IF_MSG_ACT_REQ ('40'O),
37 PCU_IF_MSG_TIME_IND ('52'O),
Vadim Yanitskiyd0766b22021-06-18 15:39:04 +020038 PCU_IF_MSG_INTERF_IND ('53'O),
Harald Welte883340c2018-02-28 18:59:29 +010039 PCU_IF_MSG_PAG_REQ ('60'O),
40 PCU_IF_MSG_TXT_IND ('70'O)
41} with { variant "FIELDLENGTH(8)" };
42
43type enumerated PCUIF_Sapi {
44 PCU_IF_SAPI_UNKNOWN ('00'O),
45 PCU_IF_SAPI_RACH ('01'O),
46 PCU_IF_SAPI_AGCH ('02'O),
47 PCU_IF_SAPI_PCH ('03'O),
48 PCU_IF_SAPI_BCCH ('04'O),
49 PCU_IF_SAPI_PDTCH ('05'O),
50 PCU_IF_SAPI_PRACH ('06'O),
51 PCU_IF_SAPI_PTCCH ('07'O),
52 PCU_IF_SAPI_AGCH_DT ('08'O)
53} with { variant "FIELDLENGTH(8)" };
54
55type record PCUIF_Flags {
56 boolean bts_active,
57 boolean sysmo_direct_dsp,
58 BIT14 spare,
59 boolean cs1,
60 boolean cs2,
61 boolean cs3,
62 boolean cs4,
63 boolean mcs1,
64 boolean mcs2,
65 boolean mcs3,
66 boolean mcs4,
67 boolean mcs5,
68 boolean mcs6,
69 boolean mcs7,
70 boolean mcs8,
71 boolean mcs9,
72 BIT3 spare2
73} with { variant "" };
74
75type enumerated PCUIF_TextType {
76 PCU_VERSION (0),
77 PCU_OML_ALERT (1)
78} with { variant "FIELDLENGTH(8)" };
79
Vadim Yanitskiye1527f72019-09-09 02:15:33 +020080type charstring PCUIF_Text length(128) with { variant "FIELDLENGTH(null_terminated)" };
Harald Welte883340c2018-02-28 18:59:29 +010081
82type record PCUIF_txt_ind {
83 PCUIF_TextType txt_type,
84 PCUIF_Text text
85} with { variant "" };
86
Harald Welte883340c2018-02-28 18:59:29 +010087type record PCUIF_data {
88 PCUIF_Sapi sapi,
89 uint8_t len,
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +020090 octetstring data length(162),
Harald Welte883340c2018-02-28 18:59:29 +010091 uint32_t fn,
92 uint16_t arfcn,
93 uint8_t trx_nr,
94 uint8_t ts_nr,
95 uint8_t block_nr,
96 int8_t rssi,
97 uint16_t ber10k,
98 int16_t ta_offs_qbits,
99 int16_t lqual_cb
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +0200100} with { variant (data) "FIELDLENGTH(162), ALIGN(left)" };
Harald Welte883340c2018-02-28 18:59:29 +0100101
102type record PCUIF_data_cnf_dt {
103 PCUIF_Sapi sapi,
104 OCT4 tlli,
105 uint32_t fn,
106 uint16_t arfcn,
107 uint8_t trx_nr,
108 uint8_t ts_nr,
109 uint8_t block_nr,
110 int8_t rssi,
111 uint16_t ber10k,
112 int16_t ta_offs_qbits,
113 int16_t lqual_cb
114} with { variant "" };
115
116type record PCUIF_rts_req {
117 PCUIF_Sapi sapi,
118 OCT3 spare,
119 uint32_t fn,
120 uint16_t arfcn,
121 uint8_t trx_nr,
122 uint8_t ts_nr,
123 uint8_t block_nr
124} with { variant "" };
125
Harald Welte913bbf62019-03-01 00:39:19 +0100126type enumerated PCUIF_BurstType {
127 BURST_TYPE_NONE (0),
128 BURST_TYPE_0 (1),
129 BURST_TYPE_1 (2),
130 BURST_TYPE_2 (3)
131} with { variant "FIELDLENGTH(8)" };
132
Harald Welte883340c2018-02-28 18:59:29 +0100133type record PCUIF_rach_ind {
134 PCUIF_Sapi sapi,
135 uint16_t ra,
136 int16_t qta,
137 uint32_t fn,
138 uint16_t arfcn,
139 uint8_t is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700140 PCUIF_BurstType burst_type,
141 uint8_t trx_nr,
142 uint8_t ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100143} with { variant "" };
144
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700145type record PCUIF_InfoTrxTs {
146 uint8_t tsc,
147 uint8_t hopping,
148 uint8_t hsn,
149 uint8_t maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700150 uint8_t ma_bit_len,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700151 bitstring ma length(64)
152} with { variant (ma) "BYTEORDER(first), BITORDER(msb)" };
153private type record length(8) of PCUIF_InfoTrxTs PCUIF_InfoTrxTsList;
154
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100155private type record PCUIF_InfoTrx {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700156 uint16_t arfcn,
157 BIT8 pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700158 OCT1 spare,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700159 uint32_t hLayer1,
160 PCUIF_InfoTrxTsList ts
161} with { variant (pdch_mask) "BITORDER(msb)" };
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100162type record length(8) of PCUIF_InfoTrx PCUIF_InfoTrxs;
Harald Welte883340c2018-02-28 18:59:29 +0100163
164type record PCUIF_info_ind {
165 uint32_t version,
166 PCUIF_Flags flags,
Harald Weltee1fd9162019-02-18 19:47:53 +0100167 PCUIF_InfoTrxs trx,
Harald Welte883340c2018-02-28 18:59:29 +0100168 uint8_t bsic,
169
170 uint16_t mcc,
171 uint16_t mnc,
Harald Welte3568dc72018-03-13 17:06:51 +0100172 uint8_t mnc_3_digits,
Harald Welte883340c2018-02-28 18:59:29 +0100173 uint16_t lac,
174 uint16_t rac,
175
176 uint16_t nsei,
177 record length(7) of uint8_t nse_timer,
178 record length(11) of uint8_t cell_timer,
179
180 uint16_t cell_id,
181 uint16_t repeat_time,
182 uint8_t repeat_count,
183 uint16_t bvci,
184 uint8_t t3142,
185 uint8_t t3169,
186 uint8_t t3191,
187 uint8_t t3193_10ms,
188 uint8_t t3195,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100189 uint8_t n3101,
190 uint8_t n3103,
191 uint8_t n3105,
Harald Welte883340c2018-02-28 18:59:29 +0100192 uint8_t cv_countdown,
193 uint16_t dl_tbf_ext,
194 uint16_t ul_tbf_ext,
195 uint8_t initial_cs,
196 uint8_t initial_mcs,
197
198 record length(2) of uint16_t nsvci,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700199 record length(2) of uint16_t local_port,
Harald Welte883340c2018-02-28 18:59:29 +0100200 record length(2) of uint16_t remote_port,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200201 PCUIF_RemoteAddr remote_addr
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200202} with { variant "" };
203
204type enumerated PCUIF_AddrType {
205 PCUIF_ADDR_TYPE_UNSPEC ('00'O),
206 PCUIF_ADDR_TYPE_IPV4 ('04'O),
207 PCUIF_ADDR_TYPE_IPV6 ('29'O)
208} with { variant "FIELDLENGTH(8)" };
209
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100210type record PCUIF_RemoteAddr {
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200211 record length(2) of PCUIF_AddrType addr_type,
212 record length(2) of octetstring addr length(16)
213} with { variant "" };
214
Harald Welte883340c2018-02-28 18:59:29 +0100215type record PCUIF_act_req {
216 uint8_t is_activate,
217 uint8_t trx_nr,
218 uint8_t ts_nr,
219 OCT1 spare
220} with { variant "" };
221
222type record PCUIF_time_ind {
223 uint32_t fn
224} with { variant "" };
225
Vadim Yanitskiyd0766b22021-06-18 15:39:04 +0200226type record length(8) of uint8_t PCUIF_interf;
227type record PCUIF_interf_ind {
228 uint8_t trx_nr,
229 OCT3 spare,
230 uint32_t fn,
231 PCUIF_interf interf
232} with { variant "" };
233
Harald Welte883340c2018-02-28 18:59:29 +0100234type record PCUIF_pag_req {
235 PCUIF_Sapi sapi,
236 uint8_t chan_needed,
237 OCT9 identity_lv
238} with { variant "" };
239
Harald Welte11b734c2019-09-05 14:17:54 +0200240type record PCUIF_app_info_req {
241 uint8_t application_type,
242 uint8_t len,
243 octetstring data
244} with {
245 variant (len) "LENGTHTO(data)"
246}
247
Harald Welte883340c2018-02-28 18:59:29 +0100248type record PCUIF_susp_req {
249 OCT4 tlli,
250 OCT6 ra_id,
251 uint8_t cause
Harald Welteeaa9a862019-05-26 23:01:08 +0200252} with {
253 variant (tlli) "BYTEORDER(last)"
254};
Harald Welte883340c2018-02-28 18:59:29 +0100255
256
257type union PCUIF_MsgUnion {
258 PCUIF_data data_req,
259 PCUIF_data data_cnf,
260 PCUIF_data_cnf_dt data_cnf_dt,
261 PCUIF_data data_ind,
262 PCUIF_susp_req susp_req,
263 PCUIF_rts_req rts_req,
264 PCUIF_rach_ind rach_ind,
265 PCUIF_txt_ind txt_ind,
266 PCUIF_info_ind info_ind,
267 PCUIF_act_req act_req,
268 PCUIF_time_ind time_ind,
Vadim Yanitskiyd0766b22021-06-18 15:39:04 +0200269 PCUIF_interf_ind interf_ind,
Harald Welte11b734c2019-09-05 14:17:54 +0200270 PCUIF_pag_req pag_req,
271 PCUIF_app_info_req app_info_req
Harald Welte883340c2018-02-28 18:59:29 +0100272} with { variant "" };
273
274type record PCUIF_Message {
275 PCUIF_MsgType msg_type,
276 uint8_t bts_nr,
277 OCT2 spare,
278 PCUIF_MsgUnion u
279} with { variant (u) "CROSSTAG(
280 data_req, msg_type = PCU_IF_MSG_DATA_REQ;
281 data_cnf, msg_type = PCU_IF_MSG_DATA_CNF;
282 data_cnf_dt, msg_type = PCU_IF_MSG_DATA_CNF_DT;
283 data_ind, msg_type = PCU_IF_MSG_DATA_IND;
284 susp_req, msg_type = PCU_IF_MSG_SUSP_REQ;
285 rts_req, msg_type = PCU_IF_MSG_RTS_REQ;
286 rach_ind, msg_type = PCU_IF_MSG_RACH_IND;
287 txt_ind, msg_type = PCU_IF_MSG_TXT_IND;
288 info_ind, msg_type = PCU_IF_MSG_INFO_IND;
289 act_req, msg_type = PCU_IF_MSG_ACT_REQ;
290 time_ind, msg_type = PCU_IF_MSG_TIME_IND;
Vadim Yanitskiyd0766b22021-06-18 15:39:04 +0200291 interf_ind, msg_type = PCU_IF_MSG_INTERF_IND;
Harald Welte11b734c2019-09-05 14:17:54 +0200292 pag_req, msg_type = PCU_IF_MSG_PAG_REQ;
293 app_info_req, msg_type = PCU_IF_MSG_APP_INFO_REQ)"
Vadim Yanitskiy204fe622021-03-23 04:49:41 +0100294 /* PCUIFv10: 1006 * 8 = 8048 bits */
295 variant "PADDING(8048)"
Harald Welte883340c2018-02-28 18:59:29 +0100296};
297
298external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring
299 with { extension "prototype(convert) encode(RAW)" };
300external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message
301 with { extension "prototype(convert) decode(RAW)" };
302
303
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200304/* Generic template for matching messages by type and/or the BTS number */
305template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
306 template uint8_t bts_nr := ?) := {
307 msg_type := msg_type,
308 bts_nr := bts_nr,
309 spare := ?,
310 u := ?
311}
312
Harald Weltee1fd9162019-02-18 19:47:53 +0100313template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
314 template (value) uint8_t trx_nr,
315 template (value) uint8_t ts_nr,
316 template (value) PCUIF_Sapi sapi,
317 template (value) uint32_t fn,
318 template (value) uint16_t arfcn,
319 template (value) uint8_t block_nr
320 ) := {
321 msg_type := PCU_IF_MSG_RTS_REQ,
322 bts_nr := bts_nr,
323 spare := '0000'O,
324 u := {
325 rts_req := {
326 sapi := sapi,
327 spare := '000000'O,
328 fn := fn,
329 arfcn := arfcn,
330 trx_nr := trx_nr,
331 ts_nr := ts_nr,
332 block_nr := block_nr
333 }
334 }
335}
Harald Welte883340c2018-02-28 18:59:29 +0100336template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
337 template uint8_t trx_nr := ?,
338 template uint8_t ts_nr := ?,
339 template PCUIF_Sapi sapi := ?,
340 template uint32_t fn := ?,
341 template uint8_t block_nr := ?
342 ) := {
343 msg_type := PCU_IF_MSG_RTS_REQ,
344 bts_nr := bts_nr,
345 spare := ?,
346 u := {
347 rts_req := {
348 sapi := sapi,
349 spare := ?,
350 fn := fn,
351 arfcn := ?,
352 trx_nr := trx_nr,
353 ts_nr := ts_nr,
354 block_nr := block_nr
355 }
356 }
357}
358
359template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
360 msg_type := PCU_IF_MSG_TXT_IND,
361 bts_nr := bts_nr,
362 spare := '0000'O,
363 u := {
364 txt_ind := {
365 txt_type := tt,
366 text := text
367 }
368 }
369}
Harald Weltee1fd9162019-02-18 19:47:53 +0100370template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
371 template charstring text := ?) := {
372 msg_type := PCU_IF_MSG_TXT_IND,
373 bts_nr := bts_nr,
374 spare := '0000'O,
375 u := {
376 txt_ind := {
377 txt_type := tt,
378 text := text
379 }
380 }
381}
382
383
Harald Welte883340c2018-02-28 18:59:29 +0100384
385template (value) PCUIF_Message ts_PCUIF_ACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
386 msg_type := PCU_IF_MSG_ACT_REQ,
387 bts_nr := bts_nr,
388 spare := '0000'O,
389 u := {
390 act_req := {
391 is_activate := 1,
392 trx_nr := trx_nr,
393 ts_nr := ts_nr,
394 spare := '00'O
395 }
396 }
397}
Harald Weltee1fd9162019-02-18 19:47:53 +0100398template PCUIF_Message tr_PCUIF_ACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
399 template uint8_t ts_nr) := {
400 msg_type := PCU_IF_MSG_ACT_REQ,
401 bts_nr := bts_nr,
402 spare := '0000'O,
403 u := {
404 act_req := {
405 is_activate := 1,
406 trx_nr := trx_nr,
407 ts_nr := ts_nr,
408 spare := '00'O
409 }
410 }
411}
Harald Welte883340c2018-02-28 18:59:29 +0100412
413template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
414 msg_type := PCU_IF_MSG_ACT_REQ,
415 bts_nr := bts_nr,
416 spare := '0000'O,
417 u := {
418 act_req := {
419 is_activate := 0,
420 trx_nr := trx_nr,
421 ts_nr := ts_nr,
422 spare := '00'O
423 }
424 }
425}
Harald Weltee1fd9162019-02-18 19:47:53 +0100426template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
427 template uint8_t ts_nr) := {
428 msg_type := PCU_IF_MSG_ACT_REQ,
429 bts_nr := bts_nr,
430 spare := '0000'O,
431 u := {
432 act_req := {
433 is_activate := 0,
434 trx_nr := trx_nr,
435 ts_nr := ts_nr,
436 spare := '00'O
437 }
438 }
439}
Harald Welte883340c2018-02-28 18:59:29 +0100440
Harald Weltee1fd9162019-02-18 19:47:53 +0100441template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
442 template (value) uint8_t trx_nr,
443 template (value) uint8_t ts_nr,
444 template (value) uint8_t block_nr,
445 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700446 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100447 template (value) uint32_t fn,
448 template (value) uint16_t arfcn,
449 template (value) int8_t rssi := -80,
450 template (value) uint16_t ber10k := 0,
451 template (value) int16_t ta_offs_qbits := 0,
Vadim Yanitskiy45749a82021-05-26 13:29:04 +0200452 template (value) int16_t lqual_cb := 10) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100453 msg_type := PCU_IF_MSG_DATA_IND,
454 bts_nr := bts_nr,
455 spare := '0000'O,
456 u := {
457 data_ind := {
458 sapi := sapi,
459 len := lengthof(valueof(data)),
460 data := data,
461 fn := fn,
462 arfcn := arfcn,
463 trx_nr := trx_nr,
464 ts_nr := ts_nr,
465 block_nr := block_nr,
466 rssi := rssi,
467 ber10k := ber10k,
468 ta_offs_qbits := ta_offs_qbits,
469 lqual_cb := lqual_cb
470 }
471 }
472}
Harald Welte883340c2018-02-28 18:59:29 +0100473template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
474 template uint8_t trx_nr := ?,
475 template uint8_t ts_nr := ?,
476 template uint8_t block_nr := ?,
477 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700478 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100479 msg_type := PCU_IF_MSG_DATA_IND,
480 bts_nr := bts_nr,
481 spare := ?,
482 u := {
483 data_ind := {
484 sapi := sapi,
485 len := ?,
486 data := data,
487 fn := ?,
488 arfcn := ?,
489 trx_nr := trx_nr,
490 ts_nr := ts_nr,
491 block_nr := block_nr,
492 rssi := ?,
493 ber10k := ?,
494 ta_offs_qbits := ?,
495 lqual_cb := ?
496 }
497 }
498}
499
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100500template PCUIF_data tr_PCUIF_DATA(template uint8_t trx_nr,
501 template uint8_t ts_nr,
502 template uint8_t block_nr := ?,
503 template uint32_t fn := ?,
504 template PCUIF_Sapi sapi := ?,
505 template octetstring data := ?) := {
506 sapi := sapi,
507 len := ?,
508 data := data,
509 fn := fn,
510 arfcn := ?, /* unused in BTS */
511 trx_nr := trx_nr,
512 ts_nr := ts_nr,
513 block_nr := block_nr,
514 /* measurement parameters below unused on Tx */
515 rssi := 0,
516 ber10k := 0,
517 ta_offs_qbits := 0,
518 lqual_cb := 0
519
520}
521
Harald Welte883340c2018-02-28 18:59:29 +0100522template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
523 uint8_t ts_nr, uint8_t block_nr,
524 uint32_t fn, PCUIF_Sapi sapi,
525 octetstring data) := {
526 msg_type := PCU_IF_MSG_DATA_REQ,
527 bts_nr := bts_nr,
528 spare := '0000'O,
529 u := {
530 data_req := {
531 sapi := sapi,
532 len := lengthof(data),
533 data := data,
534 fn := fn,
535 arfcn := 0, /* unused in BTS */
536 trx_nr := trx_nr,
537 ts_nr := ts_nr,
538 block_nr := block_nr,
539 /* measurement parameters below unused on Tx */
540 rssi := 0,
541 ber10k := 0,
542 ta_offs_qbits := 0,
543 lqual_cb := 0
544 }
545 }
546}
Harald Weltee1fd9162019-02-18 19:47:53 +0100547template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
548 template uint8_t trx_nr,
549 template uint8_t ts_nr,
550 template uint8_t block_nr := ?,
551 template uint32_t fn := ?,
552 template PCUIF_Sapi sapi := ?,
553 template octetstring data := ?) := {
554 msg_type := PCU_IF_MSG_DATA_REQ,
555 bts_nr := bts_nr,
556 spare := '0000'O,
557 u := {
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100558 data_req := tr_PCUIF_DATA(trx_nr, ts_nr, block_nr, fn, sapi, data)
Harald Weltee1fd9162019-02-18 19:47:53 +0100559 }
560}
Harald Welte883340c2018-02-28 18:59:29 +0100561
Harald Weltee1fd9162019-02-18 19:47:53 +0100562template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
563 template (value) uint8_t trx_nr,
564 template (value) uint8_t ts_nr,
565 template (value) uint8_t block_nr,
566 template (value) uint32_t fn,
567 template (value) uint16_t arfcn,
568 template (value) PCUIF_Sapi sapi,
569 template (value) octetstring data) := {
570 msg_type := PCU_IF_MSG_DATA_CNF,
571 bts_nr := bts_nr,
572 spare := '0000'O,
573 u := {
574 data_cnf := {
575 sapi := sapi,
576 len := 0, /* overwritten */
577 data := data,
578 fn := fn,
579 arfcn := arfcn,
580 trx_nr := trx_nr,
581 ts_nr := ts_nr,
582 block_nr := block_nr,
583 rssi := 0,
584 ber10k := 0,
585 ta_offs_qbits := 0,
586 lqual_cb := 0
587 }
588 }
589}
Harald Welte883340c2018-02-28 18:59:29 +0100590template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
591 template uint8_t trx_nr := ?,
592 template uint8_t ts_nr := ?,
593 template PCUIF_Sapi sapi := ?,
594 template octetstring data := ?) := {
595 msg_type := PCU_IF_MSG_DATA_CNF,
596 bts_nr := bts_nr,
597 spare := ?,
598 u := {
599 data_cnf := {
600 sapi := sapi,
601 len := ?,
602 data := data,
603 fn := ?,
604 arfcn := ?,
605 trx_nr := trx_nr,
606 ts_nr := ts_nr,
607 block_nr := ?,
608 rssi := ?,
609 ber10k := ?,
610 ta_offs_qbits := ?,
611 lqual_cb := ?
612 }
613 }
614}
615
Harald Weltee1fd9162019-02-18 19:47:53 +0100616template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700617 template (value) uint8_t trx_nr,
618 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100619 template (value) uint16_t ra,
620 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100621 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100622 template (value) uint32_t fn,
623 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700624 template (value) int16_t qta := 0,
625 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100626) := {
627 msg_type := PCU_IF_MSG_RACH_IND,
628 bts_nr := bts_nr,
629 spare := '0000'O,
630 u := {
631 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700632 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100633 ra := ra,
634 qta := qta,
635 fn := fn,
636 arfcn := arfcn,
637 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700638 burst_type := burst_type,
639 trx_nr := trx_nr,
640 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100641 }
642 }
643}
Harald Welte883340c2018-02-28 18:59:29 +0100644template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700645 template uint8_t trx_nr := ?,
646 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100647 template uint16_t ra := ?,
648 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100649 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700650 template uint32_t fn := ?,
651 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100652 msg_type := PCU_IF_MSG_RACH_IND,
653 bts_nr := bts_nr,
654 spare := ?,
655 u := {
656 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700657 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100658 ra := ra,
659 qta := ?,
660 fn := fn,
661 arfcn := ?,
662 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700663 burst_type := burst_type,
664 trx_nr := trx_nr,
665 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100666 }
667 }
668}
669
Harald Weltee1fd9162019-02-18 19:47:53 +0100670template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
671 template (value) OCT9 id_lv,
672 template (value) uint8_t chan_needed,
673 template (value) PCUIF_Sapi sapi) := {
674 msg_type := PCU_IF_MSG_PAG_REQ,
675 bts_nr := bts_nr,
676 spare := '0000'O,
677 u := {
678 pag_req := {
679 sapi := sapi,
680 chan_needed := chan_needed,
681 identity_lv := id_lv
682 }
683 }
684}
Harald Welte883340c2018-02-28 18:59:29 +0100685template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
686 template OCT9 id_lv := ?,
687 template uint8_t chan_needed := ?,
688 template PCUIF_Sapi sapi := ?) := {
689 msg_type := PCU_IF_MSG_PAG_REQ,
690 bts_nr := bts_nr,
691 spare := ?,
692 u := {
693 pag_req := {
694 sapi := ?,
695 chan_needed := chan_needed,
696 identity_lv := id_lv
697 }
698 }
699}
700
Harald Weltee1fd9162019-02-18 19:47:53 +0100701const PCUIF_Flags c_PCUIF_Flags_default := {
702 bts_active := true,
703 sysmo_direct_dsp := false,
704 spare := '00000000000000'B,
705 cs1 := true,
706 cs2 := true,
707 cs3 := true,
708 cs4 := true,
709 mcs1 := true,
710 mcs2 := true,
711 mcs3 := true,
712 mcs4 := true,
713 mcs5 := true,
714 mcs6 := true,
715 mcs7 := true,
716 mcs8 := true,
717 mcs9 := true,
718 spare2 := '000'B
719};
720
Pau Espin Pedrol745a48b2020-10-30 15:31:07 +0100721const PCUIF_Flags c_PCUIF_Flags_noMCS := {
722 bts_active := true,
723 sysmo_direct_dsp := false,
724 spare := '00000000000000'B,
725 cs1 := true,
726 cs2 := true,
727 cs3 := true,
728 cs4 := true,
729 mcs1 := false,
730 mcs2 := false,
731 mcs3 := false,
732 mcs4 := false,
733 mcs5 := false,
734 mcs6 := false,
735 mcs7 := false,
736 mcs8 := false,
737 mcs9 := false,
738 spare2 := '000'B
739};
740
741function f_pcuif_ind_flags_egprs_enabled(PCUIF_Flags flags) return boolean {
742 return flags.mcs1 or flags.mcs2 or flags.mcs3 or flags.mcs4 or
743 flags.mcs5 or flags.mcs6 or flags.mcs7 or flags.mcs8 or
744 flags.mcs9;
745}
746
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700747template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
748 tsc := tsc,
749 hopping := 0,
750 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700751 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700752 ma := f_pad_bit(''B, 64, '0'B)
753};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700754template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
755 tsc := tsc,
756 hopping := 0,
757 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700758 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700759 ma := ?
760};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700761
762template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
763 template (value) uint6_t hsn := 0,
764 template (value) uint6_t maio := 0,
765 template (value) bitstring ma := ''B) := {
766 tsc := tsc,
767 hopping := 1,
768 hsn := hsn,
769 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700770 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700771 ma := f_pad_bit(valueof(ma), 64, '0'B)
772};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700773template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
774 template uint6_t hsn := ?,
775 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700776 template bitstring ma := ?,
777 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700778 tsc := tsc,
779 hopping := 1,
780 hsn := hsn,
781 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700782 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700783 ma := ma
784};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700785
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100786template (value) PCUIF_InfoTrx
787ts_PCUIF_InfoTrx(template (value) uint16_t arfcn := 871,
788 template (value) BIT8 pdch_mask := '00000001'B,
789 template (value) uint3_t tsc := 7) := {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700790 arfcn := arfcn,
791 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700792 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700793 hLayer1 := 0,
794 ts := {
795 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
796 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
797 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
798 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
799 }
800};
801
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100802template (value) PCUIF_InfoTrxs
803ts_PCUIF_InfoTrxs_def(uint16_t base_arfcn) := {
804 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 0),
805 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 1),
806 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 2),
807 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 3),
808 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 4),
809 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 5),
810 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 6),
811 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 7)
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700812};
Harald Weltee1fd9162019-02-18 19:47:53 +0100813
Harald Weltee1fd9162019-02-18 19:47:53 +0100814template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200815 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100816 msg_type := PCU_IF_MSG_INFO_IND,
817 bts_nr := bts_nr,
818 spare := '0000'O,
819 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200820 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100821 }
822}
Harald Welted378a252018-03-13 17:02:14 +0100823template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
824 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700825 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100826 msg_type := PCU_IF_MSG_INFO_IND,
827 bts_nr := bts_nr,
828 spare := ?,
829 u := {
830 info_ind := {
831 version := version,
832 flags := flags,
833 trx := ?,
834 bsic := ?,
835 mcc := ?,
836 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100837 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100838 lac := ?,
839 rac := ?,
840 nsei := ?,
841 nse_timer := ?,
842 cell_timer := ?,
843 cell_id := ?,
844 repeat_time := ?,
845 repeat_count := ?,
846 bvci := ?,
847 t3142 := ?,
848 t3169 := ?,
849 t3191 := ?,
850 t3193_10ms := ?,
851 t3195 := ?,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100852 n3101 := ?,
853 n3103 := ?,
854 n3105 := ?,
Harald Welted378a252018-03-13 17:02:14 +0100855 cv_countdown := ?,
856 dl_tbf_ext := ?,
857 ul_tbf_ext := ?,
858 initial_cs := ?,
859 initial_mcs := ?,
860 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700861 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100862 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200863 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100864 }
865 }
866}
867
Harald Weltea3219812019-03-02 00:02:28 +0100868template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
869 template (value) uint32_t fn) := {
870 msg_type := PCU_IF_MSG_TIME_IND,
871 bts_nr := bts_nr,
872 spare := '0000'O,
873 u := {
874 time_ind := {
875 fn := fn
876 }
877 }
878}
879template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
880 template uint32_t fn) := {
881 msg_type := PCU_IF_MSG_TIME_IND,
882 bts_nr := bts_nr,
883 spare := ?,
884 u := {
885 time_ind := {
886 fn := fn
887 }
888 }
889}
Harald Welte883340c2018-02-28 18:59:29 +0100890
Vadim Yanitskiyd0766b22021-06-18 15:39:04 +0200891template (value) PCUIF_Message
892ts_PCUIF_INTERF_IND(template (value) uint8_t bts_nr,
893 template (value) uint8_t trx_nr,
894 template (value) uint32_t fn,
895 template (value) PCUIF_interf interf) := {
896 msg_type := PCU_IF_MSG_INTERF_IND,
897 bts_nr := bts_nr,
898 spare := '0000'O,
899 u := {
900 interf_ind := {
901 trx_nr := trx_nr,
902 spare := '000000'O,
903 fn := fn,
904 interf := interf
905 }
906 }
907}
908template PCUIF_Message
909tr_PCUIF_INTERF_IND(template (present) uint8_t bts_nr := ?,
910 template (present) uint8_t trx_nr := ?,
911 template (present) uint32_t fn := ?,
912 template (present) PCUIF_interf interf := ?) := {
913 msg_type := PCU_IF_MSG_INTERF_IND,
914 bts_nr := bts_nr,
915 spare := ?,
916 u := {
917 interf_ind := {
918 trx_nr := trx_nr,
919 spare := ?,
920 fn := fn,
921 interf := interf
922 }
923 }
924}
925
Harald Welte4bff40a2019-03-21 21:34:10 +0100926template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
927 template (value) OCT4 tlli,
928 template (value) OCT6 ra_id,
929 template (value) uint8_t cause) := {
930 msg_type := PCU_IF_MSG_SUSP_REQ,
931 bts_nr := bts_nr,
932 spare := '0000'O,
933 u := {
934 susp_req := {
935 tlli := tlli,
936 ra_id := ra_id,
937 cause := cause
938 }
939 }
940}
941template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
942 template OCT4 tlli,
943 template OCT6 ra_id,
944 template uint8_t cause) := {
945 msg_type := PCU_IF_MSG_SUSP_REQ,
946 bts_nr := bts_nr,
947 spare := '0000'O,
948 u := {
949 susp_req := {
950 tlli := tlli,
951 ra_id := ra_id,
952 cause := cause
953 }
954 }
955}
956
Harald Welte11b734c2019-09-05 14:17:54 +0200957template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
958 template (value) uint8_t app_type,
959 template (value) octetstring app_data) := {
960 msg_type := PCU_IF_MSG_APP_INFO_REQ,
961 bts_nr := bts_nr,
962 spare := '0000'O,
963 u := {
964 app_info_req := {
965 application_type := app_type,
966 len := 0, /* overwritten */
967 data := app_data
968 }
969 }
970}
971template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
972 template (present) uint8_t app_type,
973 template (present) octetstring app_data) := {
974 msg_type := PCU_IF_MSG_APP_INFO_REQ,
975 bts_nr := bts_nr,
976 spare := '0000'O,
977 u := {
978 app_info_req := {
979 application_type := app_type,
980 len := ?,
981 data := app_data
982 }
983 }
984}
985
Harald Welte4bff40a2019-03-21 21:34:10 +0100986
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100987function f_PCUIF_PDCHMask_set(inout PCUIF_info_ind info, BIT8 pdch_mask,
988 template (present) uint8_t trx_nr := ?)
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700989{
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100990 for (var integer nr := 0; nr < lengthof(info.trx); nr := nr + 1) {
991 if (match(nr, trx_nr)) {
992 info.trx[nr].pdch_mask := pdch_mask;
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700993 }
994 }
995}
996
Alexander Couzense0f7c542020-09-13 17:25:18 +0200997function f_PCUIF_AF2addr_type(AddressFamily address_family)
998return PCUIF_AddrType {
999 if (address_family == AF_INET) {
1000 return PCUIF_ADDR_TYPE_IPV4;
1001 } else if (address_family == AF_INET6) {
1002 return PCUIF_ADDR_TYPE_IPV6;
1003 } else {
1004 return PCUIF_ADDR_TYPE_UNSPEC;
1005 }
1006}
1007
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001008/* TODO: second (redundant) NSVC connection is not (yet) supported */
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01001009function f_PCUIF_RemoteAddr(PCUIF_AddrType addr_type,
1010 charstring addr_str)
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001011return PCUIF_RemoteAddr {
1012 var PCUIF_RemoteAddr remote_addr;
1013
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01001014 remote_addr.addr_type[0] := addr_type;
1015 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
1016 remote_addr.addr[0] := f_inet_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001017 } else {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01001018 remote_addr.addr[0] := f_inet6_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001019 }
1020
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +01001021 remote_addr.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
1022 remote_addr.addr[1] := f_pad_oct(''O, 16, '00'O);
1023
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001024 return remote_addr;
1025}
1026
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001027
Harald Welte883340c2018-02-28 18:59:29 +01001028} with { encode "RAW" variant "BYTEORDER(first)" };