blob: b400267c0d30a4603edd89076f80c491c036ea0d [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 Welte3568dc72018-03-13 17:06:51 +0100313 variant "PADDING(1696)" /* 212 * 8 */
Harald Welte883340c2018-02-28 18:59:29 +0100314};
315
316external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring
317 with { extension "prototype(convert) encode(RAW)" };
318external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message
319 with { extension "prototype(convert) decode(RAW)" };
320
321
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200322/* Generic template for matching messages by type and/or the BTS number */
323template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
324 template uint8_t bts_nr := ?) := {
325 msg_type := msg_type,
326 bts_nr := bts_nr,
327 spare := ?,
328 u := ?
329}
330
Harald Weltee1fd9162019-02-18 19:47:53 +0100331template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
332 template (value) uint8_t trx_nr,
333 template (value) uint8_t ts_nr,
334 template (value) PCUIF_Sapi sapi,
335 template (value) uint32_t fn,
336 template (value) uint16_t arfcn,
337 template (value) uint8_t block_nr
338 ) := {
339 msg_type := PCU_IF_MSG_RTS_REQ,
340 bts_nr := bts_nr,
341 spare := '0000'O,
342 u := {
343 rts_req := {
344 sapi := sapi,
345 spare := '000000'O,
346 fn := fn,
347 arfcn := arfcn,
348 trx_nr := trx_nr,
349 ts_nr := ts_nr,
350 block_nr := block_nr
351 }
352 }
353}
Harald Welte883340c2018-02-28 18:59:29 +0100354template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
355 template uint8_t trx_nr := ?,
356 template uint8_t ts_nr := ?,
357 template PCUIF_Sapi sapi := ?,
358 template uint32_t fn := ?,
359 template uint8_t block_nr := ?
360 ) := {
361 msg_type := PCU_IF_MSG_RTS_REQ,
362 bts_nr := bts_nr,
363 spare := ?,
364 u := {
365 rts_req := {
366 sapi := sapi,
367 spare := ?,
368 fn := fn,
369 arfcn := ?,
370 trx_nr := trx_nr,
371 ts_nr := ts_nr,
372 block_nr := block_nr
373 }
374 }
375}
376
377template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
378 msg_type := PCU_IF_MSG_TXT_IND,
379 bts_nr := bts_nr,
380 spare := '0000'O,
381 u := {
382 txt_ind := {
383 txt_type := tt,
384 text := text
385 }
386 }
387}
Harald Weltee1fd9162019-02-18 19:47:53 +0100388template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
389 template charstring text := ?) := {
390 msg_type := PCU_IF_MSG_TXT_IND,
391 bts_nr := bts_nr,
392 spare := '0000'O,
393 u := {
394 txt_ind := {
395 txt_type := tt,
396 text := text
397 }
398 }
399}
400
401
Harald Welte883340c2018-02-28 18:59:29 +0100402
403template (value) PCUIF_Message ts_PCUIF_ACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
404 msg_type := PCU_IF_MSG_ACT_REQ,
405 bts_nr := bts_nr,
406 spare := '0000'O,
407 u := {
408 act_req := {
409 is_activate := 1,
410 trx_nr := trx_nr,
411 ts_nr := ts_nr,
412 spare := '00'O
413 }
414 }
415}
Harald Weltee1fd9162019-02-18 19:47:53 +0100416template PCUIF_Message tr_PCUIF_ACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
417 template uint8_t ts_nr) := {
418 msg_type := PCU_IF_MSG_ACT_REQ,
419 bts_nr := bts_nr,
420 spare := '0000'O,
421 u := {
422 act_req := {
423 is_activate := 1,
424 trx_nr := trx_nr,
425 ts_nr := ts_nr,
426 spare := '00'O
427 }
428 }
429}
Harald Welte883340c2018-02-28 18:59:29 +0100430
431template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
432 msg_type := PCU_IF_MSG_ACT_REQ,
433 bts_nr := bts_nr,
434 spare := '0000'O,
435 u := {
436 act_req := {
437 is_activate := 0,
438 trx_nr := trx_nr,
439 ts_nr := ts_nr,
440 spare := '00'O
441 }
442 }
443}
Harald Weltee1fd9162019-02-18 19:47:53 +0100444template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
445 template uint8_t ts_nr) := {
446 msg_type := PCU_IF_MSG_ACT_REQ,
447 bts_nr := bts_nr,
448 spare := '0000'O,
449 u := {
450 act_req := {
451 is_activate := 0,
452 trx_nr := trx_nr,
453 ts_nr := ts_nr,
454 spare := '00'O
455 }
456 }
457}
Harald Welte883340c2018-02-28 18:59:29 +0100458
Harald Weltee1fd9162019-02-18 19:47:53 +0100459template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
460 template (value) uint8_t trx_nr,
461 template (value) uint8_t ts_nr,
462 template (value) uint8_t block_nr,
463 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700464 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100465 template (value) uint32_t fn,
466 template (value) uint16_t arfcn,
467 template (value) int8_t rssi := -80,
468 template (value) uint16_t ber10k := 0,
469 template (value) int16_t ta_offs_qbits := 0,
470 template (value) uint16_t lqual_cb := 10) := {
471 msg_type := PCU_IF_MSG_DATA_IND,
472 bts_nr := bts_nr,
473 spare := '0000'O,
474 u := {
475 data_ind := {
476 sapi := sapi,
477 len := lengthof(valueof(data)),
478 data := data,
479 fn := fn,
480 arfcn := arfcn,
481 trx_nr := trx_nr,
482 ts_nr := ts_nr,
483 block_nr := block_nr,
484 rssi := rssi,
485 ber10k := ber10k,
486 ta_offs_qbits := ta_offs_qbits,
487 lqual_cb := lqual_cb
488 }
489 }
490}
Harald Welte883340c2018-02-28 18:59:29 +0100491template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
492 template uint8_t trx_nr := ?,
493 template uint8_t ts_nr := ?,
494 template uint8_t block_nr := ?,
495 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700496 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100497 msg_type := PCU_IF_MSG_DATA_IND,
498 bts_nr := bts_nr,
499 spare := ?,
500 u := {
501 data_ind := {
502 sapi := sapi,
503 len := ?,
504 data := data,
505 fn := ?,
506 arfcn := ?,
507 trx_nr := trx_nr,
508 ts_nr := ts_nr,
509 block_nr := block_nr,
510 rssi := ?,
511 ber10k := ?,
512 ta_offs_qbits := ?,
513 lqual_cb := ?
514 }
515 }
516}
517
518template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
519 uint8_t ts_nr, uint8_t block_nr,
520 uint32_t fn, PCUIF_Sapi sapi,
521 octetstring data) := {
522 msg_type := PCU_IF_MSG_DATA_REQ,
523 bts_nr := bts_nr,
524 spare := '0000'O,
525 u := {
526 data_req := {
527 sapi := sapi,
528 len := lengthof(data),
529 data := data,
530 fn := fn,
531 arfcn := 0, /* unused in BTS */
532 trx_nr := trx_nr,
533 ts_nr := ts_nr,
534 block_nr := block_nr,
535 /* measurement parameters below unused on Tx */
536 rssi := 0,
537 ber10k := 0,
538 ta_offs_qbits := 0,
539 lqual_cb := 0
540 }
541 }
542}
Harald Weltee1fd9162019-02-18 19:47:53 +0100543template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
544 template uint8_t trx_nr,
545 template uint8_t ts_nr,
546 template uint8_t block_nr := ?,
547 template uint32_t fn := ?,
548 template PCUIF_Sapi sapi := ?,
549 template octetstring data := ?) := {
550 msg_type := PCU_IF_MSG_DATA_REQ,
551 bts_nr := bts_nr,
552 spare := '0000'O,
553 u := {
554 data_req := {
555 sapi := sapi,
556 len := ?,
557 data := data,
558 fn := fn,
Harald Welte0a3d63f2019-03-02 00:02:07 +0100559 arfcn := ?, /* unused in BTS */
Harald Weltee1fd9162019-02-18 19:47:53 +0100560 trx_nr := trx_nr,
561 ts_nr := ts_nr,
562 block_nr := block_nr,
563 /* measurement parameters below unused on Tx */
564 rssi := 0,
565 ber10k := 0,
566 ta_offs_qbits := 0,
567 lqual_cb := 0
568 }
569 }
570}
Harald Welte883340c2018-02-28 18:59:29 +0100571
Harald Weltee1fd9162019-02-18 19:47:53 +0100572template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
573 template (value) uint8_t trx_nr,
574 template (value) uint8_t ts_nr,
575 template (value) uint8_t block_nr,
576 template (value) uint32_t fn,
577 template (value) uint16_t arfcn,
578 template (value) PCUIF_Sapi sapi,
579 template (value) octetstring data) := {
580 msg_type := PCU_IF_MSG_DATA_CNF,
581 bts_nr := bts_nr,
582 spare := '0000'O,
583 u := {
584 data_cnf := {
585 sapi := sapi,
586 len := 0, /* overwritten */
587 data := data,
588 fn := fn,
589 arfcn := arfcn,
590 trx_nr := trx_nr,
591 ts_nr := ts_nr,
592 block_nr := block_nr,
593 rssi := 0,
594 ber10k := 0,
595 ta_offs_qbits := 0,
596 lqual_cb := 0
597 }
598 }
599}
Harald Welte883340c2018-02-28 18:59:29 +0100600template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
601 template uint8_t trx_nr := ?,
602 template uint8_t ts_nr := ?,
603 template PCUIF_Sapi sapi := ?,
604 template octetstring data := ?) := {
605 msg_type := PCU_IF_MSG_DATA_CNF,
606 bts_nr := bts_nr,
607 spare := ?,
608 u := {
609 data_cnf := {
610 sapi := sapi,
611 len := ?,
612 data := data,
613 fn := ?,
614 arfcn := ?,
615 trx_nr := trx_nr,
616 ts_nr := ts_nr,
617 block_nr := ?,
618 rssi := ?,
619 ber10k := ?,
620 ta_offs_qbits := ?,
621 lqual_cb := ?
622 }
623 }
624}
625
Harald Weltee1fd9162019-02-18 19:47:53 +0100626template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700627 template (value) uint8_t trx_nr,
628 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100629 template (value) uint16_t ra,
630 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100631 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100632 template (value) uint32_t fn,
633 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700634 template (value) int16_t qta := 0,
635 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100636) := {
637 msg_type := PCU_IF_MSG_RACH_IND,
638 bts_nr := bts_nr,
639 spare := '0000'O,
640 u := {
641 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700642 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100643 ra := ra,
644 qta := qta,
645 fn := fn,
646 arfcn := arfcn,
647 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700648 burst_type := burst_type,
649 trx_nr := trx_nr,
650 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100651 }
652 }
653}
Harald Welte883340c2018-02-28 18:59:29 +0100654template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700655 template uint8_t trx_nr := ?,
656 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100657 template uint16_t ra := ?,
658 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100659 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700660 template uint32_t fn := ?,
661 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100662 msg_type := PCU_IF_MSG_RACH_IND,
663 bts_nr := bts_nr,
664 spare := ?,
665 u := {
666 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700667 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100668 ra := ra,
669 qta := ?,
670 fn := fn,
671 arfcn := ?,
672 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700673 burst_type := burst_type,
674 trx_nr := trx_nr,
675 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100676 }
677 }
678}
679
Harald Weltee1fd9162019-02-18 19:47:53 +0100680template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
681 template (value) OCT9 id_lv,
682 template (value) uint8_t chan_needed,
683 template (value) PCUIF_Sapi sapi) := {
684 msg_type := PCU_IF_MSG_PAG_REQ,
685 bts_nr := bts_nr,
686 spare := '0000'O,
687 u := {
688 pag_req := {
689 sapi := sapi,
690 chan_needed := chan_needed,
691 identity_lv := id_lv
692 }
693 }
694}
Harald Welte883340c2018-02-28 18:59:29 +0100695template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
696 template OCT9 id_lv := ?,
697 template uint8_t chan_needed := ?,
698 template PCUIF_Sapi sapi := ?) := {
699 msg_type := PCU_IF_MSG_PAG_REQ,
700 bts_nr := bts_nr,
701 spare := ?,
702 u := {
703 pag_req := {
704 sapi := ?,
705 chan_needed := chan_needed,
706 identity_lv := id_lv
707 }
708 }
709}
710
Harald Weltee1fd9162019-02-18 19:47:53 +0100711const PCUIF_Flags c_PCUIF_Flags_default := {
712 bts_active := true,
713 sysmo_direct_dsp := false,
714 spare := '00000000000000'B,
715 cs1 := true,
716 cs2 := true,
717 cs3 := true,
718 cs4 := true,
719 mcs1 := true,
720 mcs2 := true,
721 mcs3 := true,
722 mcs4 := true,
723 mcs5 := true,
724 mcs6 := true,
725 mcs7 := true,
726 mcs8 := true,
727 mcs9 := true,
728 spare2 := '000'B
729};
730
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700731template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
732 tsc := tsc,
733 hopping := 0,
734 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700735 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700736 ma := f_pad_bit(''B, 64, '0'B)
737};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700738template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
739 tsc := tsc,
740 hopping := 0,
741 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700742 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700743 ma := ?
744};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700745
746template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
747 template (value) uint6_t hsn := 0,
748 template (value) uint6_t maio := 0,
749 template (value) bitstring ma := ''B) := {
750 tsc := tsc,
751 hopping := 1,
752 hsn := hsn,
753 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700754 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700755 ma := f_pad_bit(valueof(ma), 64, '0'B)
756};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700757template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
758 template uint6_t hsn := ?,
759 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700760 template bitstring ma := ?,
761 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700762 tsc := tsc,
763 hopping := 1,
764 hsn := hsn,
765 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700766 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700767 ma := ma
768};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700769
770template (value) PCUIF_InfoV10Trx ts_PCUIF_InfoV10Trx(template (value) uint16_t arfcn := 871,
771 template (value) BIT8 pdch_mask := '00000001'B,
772 template (value) uint3_t tsc := 7) := {
773 arfcn := arfcn,
774 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700775 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700776 hLayer1 := 0,
777 ts := {
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 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
782 }
783};
784
785template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09Trx(template (value) uint16_t arfcn := 871,
786 template (value) BIT8 pdch_mask := '00000001'B,
787 OCT1 tsc := '07'O) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100788 arfcn := arfcn,
789 pdch_mask := pdch_mask,
790 spare := '00'O,
791 tsc := tsc & tsc & tsc & tsc & tsc & tsc & tsc & tsc,
792 hLayer1 := 0
793}
794
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700795template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09TrxNULL := ts_PCUIF_InfoV09Trx(0, '00000000'B, '00'O);
Harald Weltee1fd9162019-02-18 19:47:53 +0100796
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700797template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def := {
798 v09 := {
799 ts_PCUIF_InfoV09Trx, ts_PCUIF_InfoV09TrxNULL,
800 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
801 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
802 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL
803 }
804};
805
806template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def := {
807 v10 := {
808 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
809 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
810 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
811 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx
812 }
813};
Harald Weltee1fd9162019-02-18 19:47:53 +0100814
Harald Weltee1fd9162019-02-18 19:47:53 +0100815template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200816 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100817 msg_type := PCU_IF_MSG_INFO_IND,
818 bts_nr := bts_nr,
819 spare := '0000'O,
820 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200821 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100822 }
823}
Harald Welted378a252018-03-13 17:02:14 +0100824template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
825 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700826 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100827 msg_type := PCU_IF_MSG_INFO_IND,
828 bts_nr := bts_nr,
829 spare := ?,
830 u := {
831 info_ind := {
832 version := version,
833 flags := flags,
834 trx := ?,
835 bsic := ?,
836 mcc := ?,
837 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100838 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100839 lac := ?,
840 rac := ?,
841 nsei := ?,
842 nse_timer := ?,
843 cell_timer := ?,
844 cell_id := ?,
845 repeat_time := ?,
846 repeat_count := ?,
847 bvci := ?,
848 t3142 := ?,
849 t3169 := ?,
850 t3191 := ?,
851 t3193_10ms := ?,
852 t3195 := ?,
853 t3101 := ?,
854 t3103 := ?,
855 t3105 := ?,
856 cv_countdown := ?,
857 dl_tbf_ext := ?,
858 ul_tbf_ext := ?,
859 initial_cs := ?,
860 initial_mcs := ?,
861 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700862 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100863 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200864 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100865 }
866 }
867}
868
Harald Weltea3219812019-03-02 00:02:28 +0100869template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
870 template (value) uint32_t fn) := {
871 msg_type := PCU_IF_MSG_TIME_IND,
872 bts_nr := bts_nr,
873 spare := '0000'O,
874 u := {
875 time_ind := {
876 fn := fn
877 }
878 }
879}
880template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
881 template uint32_t fn) := {
882 msg_type := PCU_IF_MSG_TIME_IND,
883 bts_nr := bts_nr,
884 spare := ?,
885 u := {
886 time_ind := {
887 fn := fn
888 }
889 }
890}
Harald Welte883340c2018-02-28 18:59:29 +0100891
Harald Welte4bff40a2019-03-21 21:34:10 +0100892template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
893 template (value) OCT4 tlli,
894 template (value) OCT6 ra_id,
895 template (value) uint8_t cause) := {
896 msg_type := PCU_IF_MSG_SUSP_REQ,
897 bts_nr := bts_nr,
898 spare := '0000'O,
899 u := {
900 susp_req := {
901 tlli := tlli,
902 ra_id := ra_id,
903 cause := cause
904 }
905 }
906}
907template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
908 template OCT4 tlli,
909 template OCT6 ra_id,
910 template uint8_t cause) := {
911 msg_type := PCU_IF_MSG_SUSP_REQ,
912 bts_nr := bts_nr,
913 spare := '0000'O,
914 u := {
915 susp_req := {
916 tlli := tlli,
917 ra_id := ra_id,
918 cause := cause
919 }
920 }
921}
922
Harald Welte11b734c2019-09-05 14:17:54 +0200923template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
924 template (value) uint8_t app_type,
925 template (value) octetstring app_data) := {
926 msg_type := PCU_IF_MSG_APP_INFO_REQ,
927 bts_nr := bts_nr,
928 spare := '0000'O,
929 u := {
930 app_info_req := {
931 application_type := app_type,
932 len := 0, /* overwritten */
933 data := app_data
934 }
935 }
936}
937template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
938 template (present) uint8_t app_type,
939 template (present) octetstring app_data) := {
940 msg_type := PCU_IF_MSG_APP_INFO_REQ,
941 bts_nr := bts_nr,
942 spare := '0000'O,
943 u := {
944 app_info_req := {
945 application_type := app_type,
946 len := ?,
947 data := app_data
948 }
949 }
950}
951
Harald Welte4bff40a2019-03-21 21:34:10 +0100952
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700953/* TODO: remove this as soon as we drop version 9 support */
954function f_PCUIF_ver_INFO_Trxs()
955return PCUIF_InfoTrxs {
956 if (PCUIF_Types.mp_pcuif_version >= 10) {
957 return valueof(ts_PCUIF_InfoV10Trxs_def);
958 } else {
959 return valueof(ts_PCUIF_InfoV09Trxs_def);
960 }
961}
962
963function f_PCUIF_ver_INFO_PDCHMask(in PCUIF_info_ind info, uint8_t trx_nr)
964return bitstring {
965 if (PCUIF_Types.mp_pcuif_version >= 10) {
966 return info.trx.v10[trx_nr].pdch_mask;
967 } else {
968 return info.trx.v09[trx_nr].pdch_mask;
969 }
970}
971
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200972/* TODO: second (redundant) NSVC connection is not (yet) supported */
973function f_PCUIF_ver_INFO_RemoteAddr(PCUIF_AddrType addr_type,
974 charstring addr)
975return PCUIF_RemoteAddr {
976 var PCUIF_RemoteAddr remote_addr;
977
978 if (PCUIF_Types.mp_pcuif_version >= 10) {
979 remote_addr.v10.addr_type[0] := addr_type;
980 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
981 remote_addr.v10.addr[0] := f_inet_addr(addr);
982 } else {
983 remote_addr.v10.addr[0] := f_inet6_addr(addr);
984 }
985 remote_addr.v10.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
986 remote_addr.v10.addr[1] := f_pad_oct(''O, 16, '00'O);
987 } else {
988 if (addr_type != PCUIF_ADDR_TYPE_IPV4) {
989 testcase.stop("NSVC address type := ", addr_type,
990 "is not supported in version := ",
991 PCUIF_Types.mp_pcuif_version);
992 }
993 /* v9 requires the IP in host byte order */
994 remote_addr.v09.addr[0] := f_inet_haddr(addr);
995 remote_addr.v09.addr[0] := f_pad_oct(''O, 4, '00'O);
996 }
997
998 return remote_addr;
999}
1000
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001001
Harald Welte883340c2018-02-28 18:59:29 +01001002} with { encode "RAW" variant "BYTEORDER(first)" };