blob: b259cfc406e6538c6ad6dddb2eeb7a751465604d [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),
38 PCU_IF_MSG_PAG_REQ ('60'O),
39 PCU_IF_MSG_TXT_IND ('70'O)
40} with { variant "FIELDLENGTH(8)" };
41
42type enumerated PCUIF_Sapi {
43 PCU_IF_SAPI_UNKNOWN ('00'O),
44 PCU_IF_SAPI_RACH ('01'O),
45 PCU_IF_SAPI_AGCH ('02'O),
46 PCU_IF_SAPI_PCH ('03'O),
47 PCU_IF_SAPI_BCCH ('04'O),
48 PCU_IF_SAPI_PDTCH ('05'O),
49 PCU_IF_SAPI_PRACH ('06'O),
50 PCU_IF_SAPI_PTCCH ('07'O),
51 PCU_IF_SAPI_AGCH_DT ('08'O)
52} with { variant "FIELDLENGTH(8)" };
53
54type record PCUIF_Flags {
55 boolean bts_active,
56 boolean sysmo_direct_dsp,
57 BIT14 spare,
58 boolean cs1,
59 boolean cs2,
60 boolean cs3,
61 boolean cs4,
62 boolean mcs1,
63 boolean mcs2,
64 boolean mcs3,
65 boolean mcs4,
66 boolean mcs5,
67 boolean mcs6,
68 boolean mcs7,
69 boolean mcs8,
70 boolean mcs9,
71 BIT3 spare2
72} with { variant "" };
73
74type enumerated PCUIF_TextType {
75 PCU_VERSION (0),
76 PCU_OML_ALERT (1)
77} with { variant "FIELDLENGTH(8)" };
78
Vadim Yanitskiye1527f72019-09-09 02:15:33 +020079type charstring PCUIF_Text length(128) with { variant "FIELDLENGTH(null_terminated)" };
Harald Welte883340c2018-02-28 18:59:29 +010080
81type record PCUIF_txt_ind {
82 PCUIF_TextType txt_type,
83 PCUIF_Text text
84} with { variant "" };
85
Harald Welte883340c2018-02-28 18:59:29 +010086type record PCUIF_data {
87 PCUIF_Sapi sapi,
88 uint8_t len,
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +020089 octetstring data length(162),
Harald Welte883340c2018-02-28 18:59:29 +010090 uint32_t fn,
91 uint16_t arfcn,
92 uint8_t trx_nr,
93 uint8_t ts_nr,
94 uint8_t block_nr,
95 int8_t rssi,
96 uint16_t ber10k,
97 int16_t ta_offs_qbits,
98 int16_t lqual_cb
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +020099} with { variant (data) "FIELDLENGTH(162), ALIGN(left)" };
Harald Welte883340c2018-02-28 18:59:29 +0100100
101type record PCUIF_data_cnf_dt {
102 PCUIF_Sapi sapi,
103 OCT4 tlli,
104 uint32_t fn,
105 uint16_t arfcn,
106 uint8_t trx_nr,
107 uint8_t ts_nr,
108 uint8_t block_nr,
109 int8_t rssi,
110 uint16_t ber10k,
111 int16_t ta_offs_qbits,
112 int16_t lqual_cb
113} with { variant "" };
114
115type record PCUIF_rts_req {
116 PCUIF_Sapi sapi,
117 OCT3 spare,
118 uint32_t fn,
119 uint16_t arfcn,
120 uint8_t trx_nr,
121 uint8_t ts_nr,
122 uint8_t block_nr
123} with { variant "" };
124
Harald Welte913bbf62019-03-01 00:39:19 +0100125type enumerated PCUIF_BurstType {
126 BURST_TYPE_NONE (0),
127 BURST_TYPE_0 (1),
128 BURST_TYPE_1 (2),
129 BURST_TYPE_2 (3)
130} with { variant "FIELDLENGTH(8)" };
131
Harald Welte883340c2018-02-28 18:59:29 +0100132type record PCUIF_rach_ind {
133 PCUIF_Sapi sapi,
134 uint16_t ra,
135 int16_t qta,
136 uint32_t fn,
137 uint16_t arfcn,
138 uint8_t is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700139 PCUIF_BurstType burst_type,
140 uint8_t trx_nr,
141 uint8_t ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100142} with { variant "" };
143
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700144type record PCUIF_InfoTrxTs {
145 uint8_t tsc,
146 uint8_t hopping,
147 uint8_t hsn,
148 uint8_t maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700149 uint8_t ma_bit_len,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700150 bitstring ma length(64)
151} with { variant (ma) "BYTEORDER(first), BITORDER(msb)" };
152private type record length(8) of PCUIF_InfoTrxTs PCUIF_InfoTrxTsList;
153
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100154private type record PCUIF_InfoTrx {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700155 uint16_t arfcn,
156 BIT8 pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700157 OCT1 spare,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700158 uint32_t hLayer1,
159 PCUIF_InfoTrxTsList ts
160} with { variant (pdch_mask) "BITORDER(msb)" };
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100161type record length(8) of PCUIF_InfoTrx PCUIF_InfoTrxs;
Harald Welte883340c2018-02-28 18:59:29 +0100162
163type record PCUIF_info_ind {
164 uint32_t version,
165 PCUIF_Flags flags,
Harald Weltee1fd9162019-02-18 19:47:53 +0100166 PCUIF_InfoTrxs trx,
Harald Welte883340c2018-02-28 18:59:29 +0100167 uint8_t bsic,
168
169 uint16_t mcc,
170 uint16_t mnc,
Harald Welte3568dc72018-03-13 17:06:51 +0100171 uint8_t mnc_3_digits,
Harald Welte883340c2018-02-28 18:59:29 +0100172 uint16_t lac,
173 uint16_t rac,
174
175 uint16_t nsei,
176 record length(7) of uint8_t nse_timer,
177 record length(11) of uint8_t cell_timer,
178
179 uint16_t cell_id,
180 uint16_t repeat_time,
181 uint8_t repeat_count,
182 uint16_t bvci,
183 uint8_t t3142,
184 uint8_t t3169,
185 uint8_t t3191,
186 uint8_t t3193_10ms,
187 uint8_t t3195,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100188 uint8_t n3101,
189 uint8_t n3103,
190 uint8_t n3105,
Harald Welte883340c2018-02-28 18:59:29 +0100191 uint8_t cv_countdown,
192 uint16_t dl_tbf_ext,
193 uint16_t ul_tbf_ext,
194 uint8_t initial_cs,
195 uint8_t initial_mcs,
196
197 record length(2) of uint16_t nsvci,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700198 record length(2) of uint16_t local_port,
Harald Welte883340c2018-02-28 18:59:29 +0100199 record length(2) of uint16_t remote_port,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200200 PCUIF_RemoteAddr remote_addr
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200201} with { variant "" };
202
203type enumerated PCUIF_AddrType {
204 PCUIF_ADDR_TYPE_UNSPEC ('00'O),
205 PCUIF_ADDR_TYPE_IPV4 ('04'O),
206 PCUIF_ADDR_TYPE_IPV6 ('29'O)
207} with { variant "FIELDLENGTH(8)" };
208
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100209type record PCUIF_RemoteAddr {
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200210 record length(2) of PCUIF_AddrType addr_type,
211 record length(2) of octetstring addr length(16)
212} with { variant "" };
213
Harald Welte883340c2018-02-28 18:59:29 +0100214type record PCUIF_act_req {
215 uint8_t is_activate,
216 uint8_t trx_nr,
217 uint8_t ts_nr,
218 OCT1 spare
219} with { variant "" };
220
221type record PCUIF_time_ind {
222 uint32_t fn
223} with { variant "" };
224
225type record PCUIF_pag_req {
226 PCUIF_Sapi sapi,
227 uint8_t chan_needed,
228 OCT9 identity_lv
229} with { variant "" };
230
Harald Welte11b734c2019-09-05 14:17:54 +0200231type record PCUIF_app_info_req {
232 uint8_t application_type,
233 uint8_t len,
234 octetstring data
235} with {
236 variant (len) "LENGTHTO(data)"
237}
238
Harald Welte883340c2018-02-28 18:59:29 +0100239type record PCUIF_susp_req {
240 OCT4 tlli,
241 OCT6 ra_id,
242 uint8_t cause
Harald Welteeaa9a862019-05-26 23:01:08 +0200243} with {
244 variant (tlli) "BYTEORDER(last)"
245};
Harald Welte883340c2018-02-28 18:59:29 +0100246
247
248type union PCUIF_MsgUnion {
249 PCUIF_data data_req,
250 PCUIF_data data_cnf,
251 PCUIF_data_cnf_dt data_cnf_dt,
252 PCUIF_data data_ind,
253 PCUIF_susp_req susp_req,
254 PCUIF_rts_req rts_req,
255 PCUIF_rach_ind rach_ind,
256 PCUIF_txt_ind txt_ind,
257 PCUIF_info_ind info_ind,
258 PCUIF_act_req act_req,
259 PCUIF_time_ind time_ind,
Harald Welte11b734c2019-09-05 14:17:54 +0200260 PCUIF_pag_req pag_req,
261 PCUIF_app_info_req app_info_req
Harald Welte883340c2018-02-28 18:59:29 +0100262} with { variant "" };
263
264type record PCUIF_Message {
265 PCUIF_MsgType msg_type,
266 uint8_t bts_nr,
267 OCT2 spare,
268 PCUIF_MsgUnion u
269} with { variant (u) "CROSSTAG(
270 data_req, msg_type = PCU_IF_MSG_DATA_REQ;
271 data_cnf, msg_type = PCU_IF_MSG_DATA_CNF;
272 data_cnf_dt, msg_type = PCU_IF_MSG_DATA_CNF_DT;
273 data_ind, msg_type = PCU_IF_MSG_DATA_IND;
274 susp_req, msg_type = PCU_IF_MSG_SUSP_REQ;
275 rts_req, msg_type = PCU_IF_MSG_RTS_REQ;
276 rach_ind, msg_type = PCU_IF_MSG_RACH_IND;
277 txt_ind, msg_type = PCU_IF_MSG_TXT_IND;
278 info_ind, msg_type = PCU_IF_MSG_INFO_IND;
279 act_req, msg_type = PCU_IF_MSG_ACT_REQ;
280 time_ind, msg_type = PCU_IF_MSG_TIME_IND;
Harald Welte11b734c2019-09-05 14:17:54 +0200281 pag_req, msg_type = PCU_IF_MSG_PAG_REQ;
282 app_info_req, msg_type = PCU_IF_MSG_APP_INFO_REQ)"
Vadim Yanitskiy204fe622021-03-23 04:49:41 +0100283 /* PCUIFv10: 1006 * 8 = 8048 bits */
284 variant "PADDING(8048)"
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
292
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200293/* Generic template for matching messages by type and/or the BTS number */
294template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
295 template uint8_t bts_nr := ?) := {
296 msg_type := msg_type,
297 bts_nr := bts_nr,
298 spare := ?,
299 u := ?
300}
301
Harald Weltee1fd9162019-02-18 19:47:53 +0100302template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
303 template (value) uint8_t trx_nr,
304 template (value) uint8_t ts_nr,
305 template (value) PCUIF_Sapi sapi,
306 template (value) uint32_t fn,
307 template (value) uint16_t arfcn,
308 template (value) uint8_t block_nr
309 ) := {
310 msg_type := PCU_IF_MSG_RTS_REQ,
311 bts_nr := bts_nr,
312 spare := '0000'O,
313 u := {
314 rts_req := {
315 sapi := sapi,
316 spare := '000000'O,
317 fn := fn,
318 arfcn := arfcn,
319 trx_nr := trx_nr,
320 ts_nr := ts_nr,
321 block_nr := block_nr
322 }
323 }
324}
Harald Welte883340c2018-02-28 18:59:29 +0100325template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
326 template uint8_t trx_nr := ?,
327 template uint8_t ts_nr := ?,
328 template PCUIF_Sapi sapi := ?,
329 template uint32_t fn := ?,
330 template uint8_t block_nr := ?
331 ) := {
332 msg_type := PCU_IF_MSG_RTS_REQ,
333 bts_nr := bts_nr,
334 spare := ?,
335 u := {
336 rts_req := {
337 sapi := sapi,
338 spare := ?,
339 fn := fn,
340 arfcn := ?,
341 trx_nr := trx_nr,
342 ts_nr := ts_nr,
343 block_nr := block_nr
344 }
345 }
346}
347
348template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
349 msg_type := PCU_IF_MSG_TXT_IND,
350 bts_nr := bts_nr,
351 spare := '0000'O,
352 u := {
353 txt_ind := {
354 txt_type := tt,
355 text := text
356 }
357 }
358}
Harald Weltee1fd9162019-02-18 19:47:53 +0100359template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
360 template charstring text := ?) := {
361 msg_type := PCU_IF_MSG_TXT_IND,
362 bts_nr := bts_nr,
363 spare := '0000'O,
364 u := {
365 txt_ind := {
366 txt_type := tt,
367 text := text
368 }
369 }
370}
371
372
Harald Welte883340c2018-02-28 18:59:29 +0100373
374template (value) PCUIF_Message ts_PCUIF_ACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
375 msg_type := PCU_IF_MSG_ACT_REQ,
376 bts_nr := bts_nr,
377 spare := '0000'O,
378 u := {
379 act_req := {
380 is_activate := 1,
381 trx_nr := trx_nr,
382 ts_nr := ts_nr,
383 spare := '00'O
384 }
385 }
386}
Harald Weltee1fd9162019-02-18 19:47:53 +0100387template PCUIF_Message tr_PCUIF_ACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
388 template uint8_t ts_nr) := {
389 msg_type := PCU_IF_MSG_ACT_REQ,
390 bts_nr := bts_nr,
391 spare := '0000'O,
392 u := {
393 act_req := {
394 is_activate := 1,
395 trx_nr := trx_nr,
396 ts_nr := ts_nr,
397 spare := '00'O
398 }
399 }
400}
Harald Welte883340c2018-02-28 18:59:29 +0100401
402template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
403 msg_type := PCU_IF_MSG_ACT_REQ,
404 bts_nr := bts_nr,
405 spare := '0000'O,
406 u := {
407 act_req := {
408 is_activate := 0,
409 trx_nr := trx_nr,
410 ts_nr := ts_nr,
411 spare := '00'O
412 }
413 }
414}
Harald Weltee1fd9162019-02-18 19:47:53 +0100415template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
416 template uint8_t ts_nr) := {
417 msg_type := PCU_IF_MSG_ACT_REQ,
418 bts_nr := bts_nr,
419 spare := '0000'O,
420 u := {
421 act_req := {
422 is_activate := 0,
423 trx_nr := trx_nr,
424 ts_nr := ts_nr,
425 spare := '00'O
426 }
427 }
428}
Harald Welte883340c2018-02-28 18:59:29 +0100429
Harald Weltee1fd9162019-02-18 19:47:53 +0100430template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
431 template (value) uint8_t trx_nr,
432 template (value) uint8_t ts_nr,
433 template (value) uint8_t block_nr,
434 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700435 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100436 template (value) uint32_t fn,
437 template (value) uint16_t arfcn,
438 template (value) int8_t rssi := -80,
439 template (value) uint16_t ber10k := 0,
440 template (value) int16_t ta_offs_qbits := 0,
441 template (value) uint16_t lqual_cb := 10) := {
442 msg_type := PCU_IF_MSG_DATA_IND,
443 bts_nr := bts_nr,
444 spare := '0000'O,
445 u := {
446 data_ind := {
447 sapi := sapi,
448 len := lengthof(valueof(data)),
449 data := data,
450 fn := fn,
451 arfcn := arfcn,
452 trx_nr := trx_nr,
453 ts_nr := ts_nr,
454 block_nr := block_nr,
455 rssi := rssi,
456 ber10k := ber10k,
457 ta_offs_qbits := ta_offs_qbits,
458 lqual_cb := lqual_cb
459 }
460 }
461}
Harald Welte883340c2018-02-28 18:59:29 +0100462template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
463 template uint8_t trx_nr := ?,
464 template uint8_t ts_nr := ?,
465 template uint8_t block_nr := ?,
466 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700467 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100468 msg_type := PCU_IF_MSG_DATA_IND,
469 bts_nr := bts_nr,
470 spare := ?,
471 u := {
472 data_ind := {
473 sapi := sapi,
474 len := ?,
475 data := data,
476 fn := ?,
477 arfcn := ?,
478 trx_nr := trx_nr,
479 ts_nr := ts_nr,
480 block_nr := block_nr,
481 rssi := ?,
482 ber10k := ?,
483 ta_offs_qbits := ?,
484 lqual_cb := ?
485 }
486 }
487}
488
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100489template PCUIF_data tr_PCUIF_DATA(template uint8_t trx_nr,
490 template uint8_t ts_nr,
491 template uint8_t block_nr := ?,
492 template uint32_t fn := ?,
493 template PCUIF_Sapi sapi := ?,
494 template octetstring data := ?) := {
495 sapi := sapi,
496 len := ?,
497 data := data,
498 fn := fn,
499 arfcn := ?, /* unused in BTS */
500 trx_nr := trx_nr,
501 ts_nr := ts_nr,
502 block_nr := block_nr,
503 /* measurement parameters below unused on Tx */
504 rssi := 0,
505 ber10k := 0,
506 ta_offs_qbits := 0,
507 lqual_cb := 0
508
509}
510
Harald Welte883340c2018-02-28 18:59:29 +0100511template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
512 uint8_t ts_nr, uint8_t block_nr,
513 uint32_t fn, PCUIF_Sapi sapi,
514 octetstring data) := {
515 msg_type := PCU_IF_MSG_DATA_REQ,
516 bts_nr := bts_nr,
517 spare := '0000'O,
518 u := {
519 data_req := {
520 sapi := sapi,
521 len := lengthof(data),
522 data := data,
523 fn := fn,
524 arfcn := 0, /* unused in BTS */
525 trx_nr := trx_nr,
526 ts_nr := ts_nr,
527 block_nr := block_nr,
528 /* measurement parameters below unused on Tx */
529 rssi := 0,
530 ber10k := 0,
531 ta_offs_qbits := 0,
532 lqual_cb := 0
533 }
534 }
535}
Harald Weltee1fd9162019-02-18 19:47:53 +0100536template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
537 template uint8_t trx_nr,
538 template uint8_t ts_nr,
539 template uint8_t block_nr := ?,
540 template uint32_t fn := ?,
541 template PCUIF_Sapi sapi := ?,
542 template octetstring data := ?) := {
543 msg_type := PCU_IF_MSG_DATA_REQ,
544 bts_nr := bts_nr,
545 spare := '0000'O,
546 u := {
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100547 data_req := tr_PCUIF_DATA(trx_nr, ts_nr, block_nr, fn, sapi, data)
Harald Weltee1fd9162019-02-18 19:47:53 +0100548 }
549}
Harald Welte883340c2018-02-28 18:59:29 +0100550
Harald Weltee1fd9162019-02-18 19:47:53 +0100551template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
552 template (value) uint8_t trx_nr,
553 template (value) uint8_t ts_nr,
554 template (value) uint8_t block_nr,
555 template (value) uint32_t fn,
556 template (value) uint16_t arfcn,
557 template (value) PCUIF_Sapi sapi,
558 template (value) octetstring data) := {
559 msg_type := PCU_IF_MSG_DATA_CNF,
560 bts_nr := bts_nr,
561 spare := '0000'O,
562 u := {
563 data_cnf := {
564 sapi := sapi,
565 len := 0, /* overwritten */
566 data := data,
567 fn := fn,
568 arfcn := arfcn,
569 trx_nr := trx_nr,
570 ts_nr := ts_nr,
571 block_nr := block_nr,
572 rssi := 0,
573 ber10k := 0,
574 ta_offs_qbits := 0,
575 lqual_cb := 0
576 }
577 }
578}
Harald Welte883340c2018-02-28 18:59:29 +0100579template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
580 template uint8_t trx_nr := ?,
581 template uint8_t ts_nr := ?,
582 template PCUIF_Sapi sapi := ?,
583 template octetstring data := ?) := {
584 msg_type := PCU_IF_MSG_DATA_CNF,
585 bts_nr := bts_nr,
586 spare := ?,
587 u := {
588 data_cnf := {
589 sapi := sapi,
590 len := ?,
591 data := data,
592 fn := ?,
593 arfcn := ?,
594 trx_nr := trx_nr,
595 ts_nr := ts_nr,
596 block_nr := ?,
597 rssi := ?,
598 ber10k := ?,
599 ta_offs_qbits := ?,
600 lqual_cb := ?
601 }
602 }
603}
604
Harald Weltee1fd9162019-02-18 19:47:53 +0100605template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700606 template (value) uint8_t trx_nr,
607 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100608 template (value) uint16_t ra,
609 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100610 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100611 template (value) uint32_t fn,
612 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700613 template (value) int16_t qta := 0,
614 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100615) := {
616 msg_type := PCU_IF_MSG_RACH_IND,
617 bts_nr := bts_nr,
618 spare := '0000'O,
619 u := {
620 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700621 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100622 ra := ra,
623 qta := qta,
624 fn := fn,
625 arfcn := arfcn,
626 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700627 burst_type := burst_type,
628 trx_nr := trx_nr,
629 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100630 }
631 }
632}
Harald Welte883340c2018-02-28 18:59:29 +0100633template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700634 template uint8_t trx_nr := ?,
635 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100636 template uint16_t ra := ?,
637 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100638 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700639 template uint32_t fn := ?,
640 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100641 msg_type := PCU_IF_MSG_RACH_IND,
642 bts_nr := bts_nr,
643 spare := ?,
644 u := {
645 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700646 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100647 ra := ra,
648 qta := ?,
649 fn := fn,
650 arfcn := ?,
651 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700652 burst_type := burst_type,
653 trx_nr := trx_nr,
654 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100655 }
656 }
657}
658
Harald Weltee1fd9162019-02-18 19:47:53 +0100659template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
660 template (value) OCT9 id_lv,
661 template (value) uint8_t chan_needed,
662 template (value) PCUIF_Sapi sapi) := {
663 msg_type := PCU_IF_MSG_PAG_REQ,
664 bts_nr := bts_nr,
665 spare := '0000'O,
666 u := {
667 pag_req := {
668 sapi := sapi,
669 chan_needed := chan_needed,
670 identity_lv := id_lv
671 }
672 }
673}
Harald Welte883340c2018-02-28 18:59:29 +0100674template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
675 template OCT9 id_lv := ?,
676 template uint8_t chan_needed := ?,
677 template PCUIF_Sapi sapi := ?) := {
678 msg_type := PCU_IF_MSG_PAG_REQ,
679 bts_nr := bts_nr,
680 spare := ?,
681 u := {
682 pag_req := {
683 sapi := ?,
684 chan_needed := chan_needed,
685 identity_lv := id_lv
686 }
687 }
688}
689
Harald Weltee1fd9162019-02-18 19:47:53 +0100690const PCUIF_Flags c_PCUIF_Flags_default := {
691 bts_active := true,
692 sysmo_direct_dsp := false,
693 spare := '00000000000000'B,
694 cs1 := true,
695 cs2 := true,
696 cs3 := true,
697 cs4 := true,
698 mcs1 := true,
699 mcs2 := true,
700 mcs3 := true,
701 mcs4 := true,
702 mcs5 := true,
703 mcs6 := true,
704 mcs7 := true,
705 mcs8 := true,
706 mcs9 := true,
707 spare2 := '000'B
708};
709
Pau Espin Pedrol745a48b2020-10-30 15:31:07 +0100710const PCUIF_Flags c_PCUIF_Flags_noMCS := {
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 := false,
719 mcs2 := false,
720 mcs3 := false,
721 mcs4 := false,
722 mcs5 := false,
723 mcs6 := false,
724 mcs7 := false,
725 mcs8 := false,
726 mcs9 := false,
727 spare2 := '000'B
728};
729
730function f_pcuif_ind_flags_egprs_enabled(PCUIF_Flags flags) return boolean {
731 return flags.mcs1 or flags.mcs2 or flags.mcs3 or flags.mcs4 or
732 flags.mcs5 or flags.mcs6 or flags.mcs7 or flags.mcs8 or
733 flags.mcs9;
734}
735
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700736template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
737 tsc := tsc,
738 hopping := 0,
739 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700740 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700741 ma := f_pad_bit(''B, 64, '0'B)
742};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700743template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
744 tsc := tsc,
745 hopping := 0,
746 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700747 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700748 ma := ?
749};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700750
751template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
752 template (value) uint6_t hsn := 0,
753 template (value) uint6_t maio := 0,
754 template (value) bitstring ma := ''B) := {
755 tsc := tsc,
756 hopping := 1,
757 hsn := hsn,
758 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700759 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700760 ma := f_pad_bit(valueof(ma), 64, '0'B)
761};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700762template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
763 template uint6_t hsn := ?,
764 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700765 template bitstring ma := ?,
766 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700767 tsc := tsc,
768 hopping := 1,
769 hsn := hsn,
770 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700771 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700772 ma := ma
773};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700774
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100775template (value) PCUIF_InfoTrx
776ts_PCUIF_InfoTrx(template (value) uint16_t arfcn := 871,
777 template (value) BIT8 pdch_mask := '00000001'B,
778 template (value) uint3_t tsc := 7) := {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700779 arfcn := arfcn,
780 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700781 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700782 hLayer1 := 0,
783 ts := {
784 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
785 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
786 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
787 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
788 }
789};
790
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100791template (value) PCUIF_InfoTrxs
792ts_PCUIF_InfoTrxs_def(uint16_t base_arfcn) := {
793 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 0),
794 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 1),
795 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 2),
796 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 3),
797 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 4),
798 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 5),
799 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 6),
800 ts_PCUIF_InfoTrx(arfcn := base_arfcn + 7)
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700801};
Harald Weltee1fd9162019-02-18 19:47:53 +0100802
Harald Weltee1fd9162019-02-18 19:47:53 +0100803template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200804 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100805 msg_type := PCU_IF_MSG_INFO_IND,
806 bts_nr := bts_nr,
807 spare := '0000'O,
808 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200809 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100810 }
811}
Harald Welted378a252018-03-13 17:02:14 +0100812template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
813 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700814 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100815 msg_type := PCU_IF_MSG_INFO_IND,
816 bts_nr := bts_nr,
817 spare := ?,
818 u := {
819 info_ind := {
820 version := version,
821 flags := flags,
822 trx := ?,
823 bsic := ?,
824 mcc := ?,
825 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100826 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100827 lac := ?,
828 rac := ?,
829 nsei := ?,
830 nse_timer := ?,
831 cell_timer := ?,
832 cell_id := ?,
833 repeat_time := ?,
834 repeat_count := ?,
835 bvci := ?,
836 t3142 := ?,
837 t3169 := ?,
838 t3191 := ?,
839 t3193_10ms := ?,
840 t3195 := ?,
Pau Espin Pedrol76de1662021-03-01 17:40:58 +0100841 n3101 := ?,
842 n3103 := ?,
843 n3105 := ?,
Harald Welted378a252018-03-13 17:02:14 +0100844 cv_countdown := ?,
845 dl_tbf_ext := ?,
846 ul_tbf_ext := ?,
847 initial_cs := ?,
848 initial_mcs := ?,
849 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700850 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100851 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200852 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100853 }
854 }
855}
856
Harald Weltea3219812019-03-02 00:02:28 +0100857template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
858 template (value) uint32_t fn) := {
859 msg_type := PCU_IF_MSG_TIME_IND,
860 bts_nr := bts_nr,
861 spare := '0000'O,
862 u := {
863 time_ind := {
864 fn := fn
865 }
866 }
867}
868template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
869 template uint32_t fn) := {
870 msg_type := PCU_IF_MSG_TIME_IND,
871 bts_nr := bts_nr,
872 spare := ?,
873 u := {
874 time_ind := {
875 fn := fn
876 }
877 }
878}
Harald Welte883340c2018-02-28 18:59:29 +0100879
Harald Welte4bff40a2019-03-21 21:34:10 +0100880template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
881 template (value) OCT4 tlli,
882 template (value) OCT6 ra_id,
883 template (value) uint8_t cause) := {
884 msg_type := PCU_IF_MSG_SUSP_REQ,
885 bts_nr := bts_nr,
886 spare := '0000'O,
887 u := {
888 susp_req := {
889 tlli := tlli,
890 ra_id := ra_id,
891 cause := cause
892 }
893 }
894}
895template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
896 template OCT4 tlli,
897 template OCT6 ra_id,
898 template uint8_t cause) := {
899 msg_type := PCU_IF_MSG_SUSP_REQ,
900 bts_nr := bts_nr,
901 spare := '0000'O,
902 u := {
903 susp_req := {
904 tlli := tlli,
905 ra_id := ra_id,
906 cause := cause
907 }
908 }
909}
910
Harald Welte11b734c2019-09-05 14:17:54 +0200911template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
912 template (value) uint8_t app_type,
913 template (value) octetstring app_data) := {
914 msg_type := PCU_IF_MSG_APP_INFO_REQ,
915 bts_nr := bts_nr,
916 spare := '0000'O,
917 u := {
918 app_info_req := {
919 application_type := app_type,
920 len := 0, /* overwritten */
921 data := app_data
922 }
923 }
924}
925template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
926 template (present) uint8_t app_type,
927 template (present) octetstring app_data) := {
928 msg_type := PCU_IF_MSG_APP_INFO_REQ,
929 bts_nr := bts_nr,
930 spare := '0000'O,
931 u := {
932 app_info_req := {
933 application_type := app_type,
934 len := ?,
935 data := app_data
936 }
937 }
938}
939
Harald Welte4bff40a2019-03-21 21:34:10 +0100940
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100941function f_PCUIF_PDCHMask_set(inout PCUIF_info_ind info, BIT8 pdch_mask,
942 template (present) uint8_t trx_nr := ?)
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700943{
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100944 for (var integer nr := 0; nr < lengthof(info.trx); nr := nr + 1) {
945 if (match(nr, trx_nr)) {
946 info.trx[nr].pdch_mask := pdch_mask;
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +0700947 }
948 }
949}
950
Alexander Couzense0f7c542020-09-13 17:25:18 +0200951function f_PCUIF_AF2addr_type(AddressFamily address_family)
952return PCUIF_AddrType {
953 if (address_family == AF_INET) {
954 return PCUIF_ADDR_TYPE_IPV4;
955 } else if (address_family == AF_INET6) {
956 return PCUIF_ADDR_TYPE_IPV6;
957 } else {
958 return PCUIF_ADDR_TYPE_UNSPEC;
959 }
960}
961
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200962/* TODO: second (redundant) NSVC connection is not (yet) supported */
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100963function f_PCUIF_RemoteAddr(PCUIF_AddrType addr_type,
964 charstring addr_str)
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200965return PCUIF_RemoteAddr {
966 var PCUIF_RemoteAddr remote_addr;
967
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100968 remote_addr.addr_type[0] := addr_type;
969 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
970 remote_addr.addr[0] := f_inet_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200971 } else {
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100972 remote_addr.addr[0] := f_inet6_addr(addr_str);
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200973 }
974
Vadim Yanitskiy1da1fef2021-03-23 04:28:18 +0100975 remote_addr.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
976 remote_addr.addr[1] := f_pad_oct(''O, 16, '00'O);
977
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200978 return remote_addr;
979}
980
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700981
Harald Welte883340c2018-02-28 18:59:29 +0100982} with { encode "RAW" variant "BYTEORDER(first)" };