blob: 8ce8885491f623c14abbe5aacdda48356ae75386 [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 */
20 PCUIF_Version mp_pcuif_version := 9;
21};
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
154/* Version >= 10 specific coding */
155private type record PCUIF_InfoV10Trx {
156 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)" };
162private type record length(8) of PCUIF_InfoV10Trx PCUIF_InfoV10TrxList;
163
164/* Version <= 9 specific coding */
165private type record PCUIF_InfoV09Trx {
Harald Welte883340c2018-02-28 18:59:29 +0100166 uint16_t arfcn,
167 BIT8 pdch_mask,
168 OCT1 spare,
169 OCT8 tsc,
170 uint32_t hLayer1
Harald Weltef1486592018-04-04 19:26:41 +0200171} with { variant (pdch_mask) "BITORDER(msb)" };
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700172private type record length(8) of PCUIF_InfoV09Trx PCUIF_InfoV09TrxList;
173
174type union PCUIF_InfoTrxs {
175 PCUIF_InfoV09TrxList v09,
176 PCUIF_InfoV10TrxList v10
177} with { variant "" };
Harald Welte883340c2018-02-28 18:59:29 +0100178
179type record PCUIF_info_ind {
180 uint32_t version,
181 PCUIF_Flags flags,
Harald Weltee1fd9162019-02-18 19:47:53 +0100182 PCUIF_InfoTrxs trx,
Harald Welte883340c2018-02-28 18:59:29 +0100183 uint8_t bsic,
184
185 uint16_t mcc,
186 uint16_t mnc,
Harald Welte3568dc72018-03-13 17:06:51 +0100187 uint8_t mnc_3_digits,
Harald Welte883340c2018-02-28 18:59:29 +0100188 uint16_t lac,
189 uint16_t rac,
190
191 uint16_t nsei,
192 record length(7) of uint8_t nse_timer,
193 record length(11) of uint8_t cell_timer,
194
195 uint16_t cell_id,
196 uint16_t repeat_time,
197 uint8_t repeat_count,
198 uint16_t bvci,
199 uint8_t t3142,
200 uint8_t t3169,
201 uint8_t t3191,
202 uint8_t t3193_10ms,
203 uint8_t t3195,
204 uint8_t t3101,
205 uint8_t t3103,
206 uint8_t t3105,
207 uint8_t cv_countdown,
208 uint16_t dl_tbf_ext,
209 uint16_t ul_tbf_ext,
210 uint8_t initial_cs,
211 uint8_t initial_mcs,
212
213 record length(2) of uint16_t nsvci,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700214 record length(2) of uint16_t local_port,
Harald Welte883340c2018-02-28 18:59:29 +0100215 record length(2) of uint16_t remote_port,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200216 PCUIF_RemoteAddr remote_addr
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700217} with {
218 /* NOTE: TITAN is not smart enough to handle 'version < 10' and 'version > 9',
219 * so we cannot support more than two versions at the same time here. Sigh. */
220 variant (trx) "CROSSTAG(v09, version = 9; v10, version = 10)"
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200221 variant (remote_addr) "CROSSTAG(v09, version = 9; v10, version = 10)"
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700222};
Harald Welte883340c2018-02-28 18:59:29 +0100223
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200224type union PCUIF_RemoteAddr {
225 PCUIF_RemoteAddrV09 v09,
226 PCUIF_RemoteAddrV10 v10
227} with { variant "" };
228
229type record PCUIF_RemoteAddrV09 {
230 record length(2) of OCT4 addr
231} with { variant "" };
232
233type enumerated PCUIF_AddrType {
234 PCUIF_ADDR_TYPE_UNSPEC ('00'O),
235 PCUIF_ADDR_TYPE_IPV4 ('04'O),
236 PCUIF_ADDR_TYPE_IPV6 ('29'O)
237} with { variant "FIELDLENGTH(8)" };
238
239type record PCUIF_RemoteAddrV10 {
240 record length(2) of PCUIF_AddrType addr_type,
241 record length(2) of octetstring addr length(16)
242} with { variant "" };
243
Harald Welte883340c2018-02-28 18:59:29 +0100244type record PCUIF_act_req {
245 uint8_t is_activate,
246 uint8_t trx_nr,
247 uint8_t ts_nr,
248 OCT1 spare
249} with { variant "" };
250
251type record PCUIF_time_ind {
252 uint32_t fn
253} with { variant "" };
254
255type record PCUIF_pag_req {
256 PCUIF_Sapi sapi,
257 uint8_t chan_needed,
258 OCT9 identity_lv
259} with { variant "" };
260
Harald Welte11b734c2019-09-05 14:17:54 +0200261type record PCUIF_app_info_req {
262 uint8_t application_type,
263 uint8_t len,
264 octetstring data
265} with {
266 variant (len) "LENGTHTO(data)"
267}
268
Harald Welte883340c2018-02-28 18:59:29 +0100269type record PCUIF_susp_req {
270 OCT4 tlli,
271 OCT6 ra_id,
272 uint8_t cause
Harald Welteeaa9a862019-05-26 23:01:08 +0200273} with {
274 variant (tlli) "BYTEORDER(last)"
275};
Harald Welte883340c2018-02-28 18:59:29 +0100276
277
278type union PCUIF_MsgUnion {
279 PCUIF_data data_req,
280 PCUIF_data data_cnf,
281 PCUIF_data_cnf_dt data_cnf_dt,
282 PCUIF_data data_ind,
283 PCUIF_susp_req susp_req,
284 PCUIF_rts_req rts_req,
285 PCUIF_rach_ind rach_ind,
286 PCUIF_txt_ind txt_ind,
287 PCUIF_info_ind info_ind,
288 PCUIF_act_req act_req,
289 PCUIF_time_ind time_ind,
Harald Welte11b734c2019-09-05 14:17:54 +0200290 PCUIF_pag_req pag_req,
291 PCUIF_app_info_req app_info_req
Harald Welte883340c2018-02-28 18:59:29 +0100292} with { variant "" };
293
294type record PCUIF_Message {
295 PCUIF_MsgType msg_type,
296 uint8_t bts_nr,
297 OCT2 spare,
298 PCUIF_MsgUnion u
299} with { variant (u) "CROSSTAG(
300 data_req, msg_type = PCU_IF_MSG_DATA_REQ;
301 data_cnf, msg_type = PCU_IF_MSG_DATA_CNF;
302 data_cnf_dt, msg_type = PCU_IF_MSG_DATA_CNF_DT;
303 data_ind, msg_type = PCU_IF_MSG_DATA_IND;
304 susp_req, msg_type = PCU_IF_MSG_SUSP_REQ;
305 rts_req, msg_type = PCU_IF_MSG_RTS_REQ;
306 rach_ind, msg_type = PCU_IF_MSG_RACH_IND;
307 txt_ind, msg_type = PCU_IF_MSG_TXT_IND;
308 info_ind, msg_type = PCU_IF_MSG_INFO_IND;
309 act_req, msg_type = PCU_IF_MSG_ACT_REQ;
310 time_ind, msg_type = PCU_IF_MSG_TIME_IND;
Harald Welte11b734c2019-09-05 14:17:54 +0200311 pag_req, msg_type = PCU_IF_MSG_PAG_REQ;
312 app_info_req, msg_type = PCU_IF_MSG_APP_INFO_REQ)"
Harald Welte883340c2018-02-28 18:59:29 +0100313};
314
315external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring
316 with { extension "prototype(convert) encode(RAW)" };
317external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message
318 with { extension "prototype(convert) decode(RAW)" };
319
320
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200321/* Generic template for matching messages by type and/or the BTS number */
322template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
323 template uint8_t bts_nr := ?) := {
324 msg_type := msg_type,
325 bts_nr := bts_nr,
326 spare := ?,
327 u := ?
328}
329
Harald Weltee1fd9162019-02-18 19:47:53 +0100330template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
331 template (value) uint8_t trx_nr,
332 template (value) uint8_t ts_nr,
333 template (value) PCUIF_Sapi sapi,
334 template (value) uint32_t fn,
335 template (value) uint16_t arfcn,
336 template (value) uint8_t block_nr
337 ) := {
338 msg_type := PCU_IF_MSG_RTS_REQ,
339 bts_nr := bts_nr,
340 spare := '0000'O,
341 u := {
342 rts_req := {
343 sapi := sapi,
344 spare := '000000'O,
345 fn := fn,
346 arfcn := arfcn,
347 trx_nr := trx_nr,
348 ts_nr := ts_nr,
349 block_nr := block_nr
350 }
351 }
352}
Harald Welte883340c2018-02-28 18:59:29 +0100353template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
354 template uint8_t trx_nr := ?,
355 template uint8_t ts_nr := ?,
356 template PCUIF_Sapi sapi := ?,
357 template uint32_t fn := ?,
358 template uint8_t block_nr := ?
359 ) := {
360 msg_type := PCU_IF_MSG_RTS_REQ,
361 bts_nr := bts_nr,
362 spare := ?,
363 u := {
364 rts_req := {
365 sapi := sapi,
366 spare := ?,
367 fn := fn,
368 arfcn := ?,
369 trx_nr := trx_nr,
370 ts_nr := ts_nr,
371 block_nr := block_nr
372 }
373 }
374}
375
376template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
377 msg_type := PCU_IF_MSG_TXT_IND,
378 bts_nr := bts_nr,
379 spare := '0000'O,
380 u := {
381 txt_ind := {
382 txt_type := tt,
383 text := text
384 }
385 }
386}
Harald Weltee1fd9162019-02-18 19:47:53 +0100387template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
388 template charstring text := ?) := {
389 msg_type := PCU_IF_MSG_TXT_IND,
390 bts_nr := bts_nr,
391 spare := '0000'O,
392 u := {
393 txt_ind := {
394 txt_type := tt,
395 text := text
396 }
397 }
398}
399
400
Harald Welte883340c2018-02-28 18:59:29 +0100401
402template (value) PCUIF_Message ts_PCUIF_ACT_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 := 1,
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_ACT_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 := 1,
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
430template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
431 msg_type := PCU_IF_MSG_ACT_REQ,
432 bts_nr := bts_nr,
433 spare := '0000'O,
434 u := {
435 act_req := {
436 is_activate := 0,
437 trx_nr := trx_nr,
438 ts_nr := ts_nr,
439 spare := '00'O
440 }
441 }
442}
Harald Weltee1fd9162019-02-18 19:47:53 +0100443template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
444 template uint8_t ts_nr) := {
445 msg_type := PCU_IF_MSG_ACT_REQ,
446 bts_nr := bts_nr,
447 spare := '0000'O,
448 u := {
449 act_req := {
450 is_activate := 0,
451 trx_nr := trx_nr,
452 ts_nr := ts_nr,
453 spare := '00'O
454 }
455 }
456}
Harald Welte883340c2018-02-28 18:59:29 +0100457
Harald Weltee1fd9162019-02-18 19:47:53 +0100458template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
459 template (value) uint8_t trx_nr,
460 template (value) uint8_t ts_nr,
461 template (value) uint8_t block_nr,
462 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700463 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100464 template (value) uint32_t fn,
465 template (value) uint16_t arfcn,
466 template (value) int8_t rssi := -80,
467 template (value) uint16_t ber10k := 0,
468 template (value) int16_t ta_offs_qbits := 0,
469 template (value) uint16_t lqual_cb := 10) := {
470 msg_type := PCU_IF_MSG_DATA_IND,
471 bts_nr := bts_nr,
472 spare := '0000'O,
473 u := {
474 data_ind := {
475 sapi := sapi,
476 len := lengthof(valueof(data)),
477 data := data,
478 fn := fn,
479 arfcn := arfcn,
480 trx_nr := trx_nr,
481 ts_nr := ts_nr,
482 block_nr := block_nr,
483 rssi := rssi,
484 ber10k := ber10k,
485 ta_offs_qbits := ta_offs_qbits,
486 lqual_cb := lqual_cb
487 }
488 }
489}
Harald Welte883340c2018-02-28 18:59:29 +0100490template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
491 template uint8_t trx_nr := ?,
492 template uint8_t ts_nr := ?,
493 template uint8_t block_nr := ?,
494 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700495 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100496 msg_type := PCU_IF_MSG_DATA_IND,
497 bts_nr := bts_nr,
498 spare := ?,
499 u := {
500 data_ind := {
501 sapi := sapi,
502 len := ?,
503 data := data,
504 fn := ?,
505 arfcn := ?,
506 trx_nr := trx_nr,
507 ts_nr := ts_nr,
508 block_nr := block_nr,
509 rssi := ?,
510 ber10k := ?,
511 ta_offs_qbits := ?,
512 lqual_cb := ?
513 }
514 }
515}
516
517template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
518 uint8_t ts_nr, uint8_t block_nr,
519 uint32_t fn, PCUIF_Sapi sapi,
520 octetstring data) := {
521 msg_type := PCU_IF_MSG_DATA_REQ,
522 bts_nr := bts_nr,
523 spare := '0000'O,
524 u := {
525 data_req := {
526 sapi := sapi,
527 len := lengthof(data),
528 data := data,
529 fn := fn,
530 arfcn := 0, /* unused in BTS */
531 trx_nr := trx_nr,
532 ts_nr := ts_nr,
533 block_nr := block_nr,
534 /* measurement parameters below unused on Tx */
535 rssi := 0,
536 ber10k := 0,
537 ta_offs_qbits := 0,
538 lqual_cb := 0
539 }
540 }
541}
Harald Weltee1fd9162019-02-18 19:47:53 +0100542template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
543 template uint8_t trx_nr,
544 template uint8_t ts_nr,
545 template uint8_t block_nr := ?,
546 template uint32_t fn := ?,
547 template PCUIF_Sapi sapi := ?,
548 template octetstring data := ?) := {
549 msg_type := PCU_IF_MSG_DATA_REQ,
550 bts_nr := bts_nr,
551 spare := '0000'O,
552 u := {
553 data_req := {
554 sapi := sapi,
555 len := ?,
556 data := data,
557 fn := fn,
Harald Welte0a3d63f2019-03-02 00:02:07 +0100558 arfcn := ?, /* unused in BTS */
Harald Weltee1fd9162019-02-18 19:47:53 +0100559 trx_nr := trx_nr,
560 ts_nr := ts_nr,
561 block_nr := block_nr,
562 /* measurement parameters below unused on Tx */
563 rssi := 0,
564 ber10k := 0,
565 ta_offs_qbits := 0,
566 lqual_cb := 0
567 }
568 }
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
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700730template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
731 tsc := tsc,
732 hopping := 0,
733 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700734 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700735 ma := f_pad_bit(''B, 64, '0'B)
736};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700737template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
738 tsc := tsc,
739 hopping := 0,
740 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700741 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700742 ma := ?
743};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700744
745template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
746 template (value) uint6_t hsn := 0,
747 template (value) uint6_t maio := 0,
748 template (value) bitstring ma := ''B) := {
749 tsc := tsc,
750 hopping := 1,
751 hsn := hsn,
752 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700753 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700754 ma := f_pad_bit(valueof(ma), 64, '0'B)
755};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700756template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
757 template uint6_t hsn := ?,
758 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700759 template bitstring ma := ?,
760 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700761 tsc := tsc,
762 hopping := 1,
763 hsn := hsn,
764 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700765 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700766 ma := ma
767};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700768
769template (value) PCUIF_InfoV10Trx ts_PCUIF_InfoV10Trx(template (value) uint16_t arfcn := 871,
770 template (value) BIT8 pdch_mask := '00000001'B,
771 template (value) uint3_t tsc := 7) := {
772 arfcn := arfcn,
773 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700774 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700775 hLayer1 := 0,
776 ts := {
777 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
778 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
779 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
780 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
781 }
782};
783
784template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09Trx(template (value) uint16_t arfcn := 871,
785 template (value) BIT8 pdch_mask := '00000001'B,
786 OCT1 tsc := '07'O) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100787 arfcn := arfcn,
788 pdch_mask := pdch_mask,
789 spare := '00'O,
790 tsc := tsc & tsc & tsc & tsc & tsc & tsc & tsc & tsc,
791 hLayer1 := 0
792}
793
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700794template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09TrxNULL := ts_PCUIF_InfoV09Trx(0, '00000000'B, '00'O);
Harald Weltee1fd9162019-02-18 19:47:53 +0100795
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700796template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def := {
797 v09 := {
798 ts_PCUIF_InfoV09Trx, ts_PCUIF_InfoV09TrxNULL,
799 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
800 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
801 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL
802 }
803};
804
805template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def := {
806 v10 := {
807 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
808 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
809 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
810 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx
811 }
812};
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 := ?,
852 t3101 := ?,
853 t3103 := ?,
854 t3105 := ?,
855 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
Harald Welte4bff40a2019-03-21 21:34:10 +0100891template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
892 template (value) OCT4 tlli,
893 template (value) OCT6 ra_id,
894 template (value) uint8_t cause) := {
895 msg_type := PCU_IF_MSG_SUSP_REQ,
896 bts_nr := bts_nr,
897 spare := '0000'O,
898 u := {
899 susp_req := {
900 tlli := tlli,
901 ra_id := ra_id,
902 cause := cause
903 }
904 }
905}
906template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
907 template OCT4 tlli,
908 template OCT6 ra_id,
909 template uint8_t cause) := {
910 msg_type := PCU_IF_MSG_SUSP_REQ,
911 bts_nr := bts_nr,
912 spare := '0000'O,
913 u := {
914 susp_req := {
915 tlli := tlli,
916 ra_id := ra_id,
917 cause := cause
918 }
919 }
920}
921
Harald Welte11b734c2019-09-05 14:17:54 +0200922template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
923 template (value) uint8_t app_type,
924 template (value) octetstring app_data) := {
925 msg_type := PCU_IF_MSG_APP_INFO_REQ,
926 bts_nr := bts_nr,
927 spare := '0000'O,
928 u := {
929 app_info_req := {
930 application_type := app_type,
931 len := 0, /* overwritten */
932 data := app_data
933 }
934 }
935}
936template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
937 template (present) uint8_t app_type,
938 template (present) octetstring app_data) := {
939 msg_type := PCU_IF_MSG_APP_INFO_REQ,
940 bts_nr := bts_nr,
941 spare := '0000'O,
942 u := {
943 app_info_req := {
944 application_type := app_type,
945 len := ?,
946 data := app_data
947 }
948 }
949}
950
Harald Welte4bff40a2019-03-21 21:34:10 +0100951
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700952/* TODO: remove this as soon as we drop version 9 support */
953function f_PCUIF_ver_INFO_Trxs()
954return PCUIF_InfoTrxs {
955 if (PCUIF_Types.mp_pcuif_version >= 10) {
956 return valueof(ts_PCUIF_InfoV10Trxs_def);
957 } else {
958 return valueof(ts_PCUIF_InfoV09Trxs_def);
959 }
960}
961
962function f_PCUIF_ver_INFO_PDCHMask(in PCUIF_info_ind info, uint8_t trx_nr)
963return bitstring {
964 if (PCUIF_Types.mp_pcuif_version >= 10) {
965 return info.trx.v10[trx_nr].pdch_mask;
966 } else {
967 return info.trx.v09[trx_nr].pdch_mask;
968 }
969}
970
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200971/* TODO: second (redundant) NSVC connection is not (yet) supported */
972function f_PCUIF_ver_INFO_RemoteAddr(PCUIF_AddrType addr_type,
973 charstring addr)
974return PCUIF_RemoteAddr {
975 var PCUIF_RemoteAddr remote_addr;
976
977 if (PCUIF_Types.mp_pcuif_version >= 10) {
978 remote_addr.v10.addr_type[0] := addr_type;
979 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
980 remote_addr.v10.addr[0] := f_inet_addr(addr);
981 } else {
982 remote_addr.v10.addr[0] := f_inet6_addr(addr);
983 }
984 remote_addr.v10.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
985 remote_addr.v10.addr[1] := f_pad_oct(''O, 16, '00'O);
986 } else {
987 if (addr_type != PCUIF_ADDR_TYPE_IPV4) {
988 testcase.stop("NSVC address type := ", addr_type,
989 "is not supported in version := ",
990 PCUIF_Types.mp_pcuif_version);
991 }
992 /* v9 requires the IP in host byte order */
993 remote_addr.v09.addr[0] := f_inet_haddr(addr);
994 remote_addr.v09.addr[0] := f_pad_oct(''O, 4, '00'O);
995 }
996
997 return remote_addr;
998}
999
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001000
Harald Welte883340c2018-02-28 18:59:29 +01001001} with { encode "RAW" variant "BYTEORDER(first)" };