blob: 079455fd824af0c3f3518baea8ae29968e01d145 [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;
Vadim Yanitskiy220fa202020-09-15 19:15:01 +070021 /* Whether to pad outgoing messages */
22 boolean mp_pcuif_padding := true;
Vadim Yanitskiyc1559302020-07-19 16:39:12 +070023};
24
Harald Welte883340c2018-02-28 18:59:29 +010025const charstring PCU_SOCK_DEFAULT := "/tmp/pcu_bts";
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +070026type integer PCUIF_Version (9..10); /* supported versions */
Harald Welte883340c2018-02-28 18:59:29 +010027
28type enumerated PCUIF_MsgType {
29 PCU_IF_MSG_DATA_REQ ('00'O),
30 PCU_IF_MSG_DATA_CNF ('01'O),
31 PCU_IF_MSG_DATA_IND ('02'O),
32 PCU_IF_MSG_SUSP_REQ ('03'O),
Harald Welte11b734c2019-09-05 14:17:54 +020033 PCU_IF_MSG_APP_INFO_REQ ('04'O),
Harald Welte883340c2018-02-28 18:59:29 +010034 PCU_IF_MSG_RTS_REQ ('10'O),
35 PCU_IF_MSG_DATA_CNF_DT ('11'O),
36 PCU_IF_MSG_RACH_IND ('22'O),
37 PCU_IF_MSG_INFO_IND ('32'O),
38 PCU_IF_MSG_ACT_REQ ('40'O),
39 PCU_IF_MSG_TIME_IND ('52'O),
40 PCU_IF_MSG_PAG_REQ ('60'O),
41 PCU_IF_MSG_TXT_IND ('70'O)
42} with { variant "FIELDLENGTH(8)" };
43
44type enumerated PCUIF_Sapi {
45 PCU_IF_SAPI_UNKNOWN ('00'O),
46 PCU_IF_SAPI_RACH ('01'O),
47 PCU_IF_SAPI_AGCH ('02'O),
48 PCU_IF_SAPI_PCH ('03'O),
49 PCU_IF_SAPI_BCCH ('04'O),
50 PCU_IF_SAPI_PDTCH ('05'O),
51 PCU_IF_SAPI_PRACH ('06'O),
52 PCU_IF_SAPI_PTCCH ('07'O),
53 PCU_IF_SAPI_AGCH_DT ('08'O)
54} with { variant "FIELDLENGTH(8)" };
55
56type record PCUIF_Flags {
57 boolean bts_active,
58 boolean sysmo_direct_dsp,
59 BIT14 spare,
60 boolean cs1,
61 boolean cs2,
62 boolean cs3,
63 boolean cs4,
64 boolean mcs1,
65 boolean mcs2,
66 boolean mcs3,
67 boolean mcs4,
68 boolean mcs5,
69 boolean mcs6,
70 boolean mcs7,
71 boolean mcs8,
72 boolean mcs9,
73 BIT3 spare2
74} with { variant "" };
75
76type enumerated PCUIF_TextType {
77 PCU_VERSION (0),
78 PCU_OML_ALERT (1)
79} with { variant "FIELDLENGTH(8)" };
80
Vadim Yanitskiye1527f72019-09-09 02:15:33 +020081type charstring PCUIF_Text length(128) with { variant "FIELDLENGTH(null_terminated)" };
Harald Welte883340c2018-02-28 18:59:29 +010082
83type record PCUIF_txt_ind {
84 PCUIF_TextType txt_type,
85 PCUIF_Text text
86} with { variant "" };
87
Harald Welte883340c2018-02-28 18:59:29 +010088type record PCUIF_data {
89 PCUIF_Sapi sapi,
90 uint8_t len,
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +020091 octetstring data length(162),
Harald Welte883340c2018-02-28 18:59:29 +010092 uint32_t fn,
93 uint16_t arfcn,
94 uint8_t trx_nr,
95 uint8_t ts_nr,
96 uint8_t block_nr,
97 int8_t rssi,
98 uint16_t ber10k,
99 int16_t ta_offs_qbits,
100 int16_t lqual_cb
Vadim Yanitskiyd8f28e62019-09-10 18:11:52 +0200101} with { variant (data) "FIELDLENGTH(162), ALIGN(left)" };
Harald Welte883340c2018-02-28 18:59:29 +0100102
103type record PCUIF_data_cnf_dt {
104 PCUIF_Sapi sapi,
105 OCT4 tlli,
106 uint32_t fn,
107 uint16_t arfcn,
108 uint8_t trx_nr,
109 uint8_t ts_nr,
110 uint8_t block_nr,
111 int8_t rssi,
112 uint16_t ber10k,
113 int16_t ta_offs_qbits,
114 int16_t lqual_cb
115} with { variant "" };
116
117type record PCUIF_rts_req {
118 PCUIF_Sapi sapi,
119 OCT3 spare,
120 uint32_t fn,
121 uint16_t arfcn,
122 uint8_t trx_nr,
123 uint8_t ts_nr,
124 uint8_t block_nr
125} with { variant "" };
126
Harald Welte913bbf62019-03-01 00:39:19 +0100127type enumerated PCUIF_BurstType {
128 BURST_TYPE_NONE (0),
129 BURST_TYPE_0 (1),
130 BURST_TYPE_1 (2),
131 BURST_TYPE_2 (3)
132} with { variant "FIELDLENGTH(8)" };
133
Harald Welte883340c2018-02-28 18:59:29 +0100134type record PCUIF_rach_ind {
135 PCUIF_Sapi sapi,
136 uint16_t ra,
137 int16_t qta,
138 uint32_t fn,
139 uint16_t arfcn,
140 uint8_t is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700141 PCUIF_BurstType burst_type,
142 uint8_t trx_nr,
143 uint8_t ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100144} with { variant "" };
145
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700146type record PCUIF_InfoTrxTs {
147 uint8_t tsc,
148 uint8_t hopping,
149 uint8_t hsn,
150 uint8_t maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700151 uint8_t ma_bit_len,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700152 bitstring ma length(64)
153} with { variant (ma) "BYTEORDER(first), BITORDER(msb)" };
154private type record length(8) of PCUIF_InfoTrxTs PCUIF_InfoTrxTsList;
155
156/* Version >= 10 specific coding */
157private type record PCUIF_InfoV10Trx {
158 uint16_t arfcn,
159 BIT8 pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700160 OCT1 spare,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700161 uint32_t hLayer1,
162 PCUIF_InfoTrxTsList ts
163} with { variant (pdch_mask) "BITORDER(msb)" };
164private type record length(8) of PCUIF_InfoV10Trx PCUIF_InfoV10TrxList;
165
166/* Version <= 9 specific coding */
167private type record PCUIF_InfoV09Trx {
Harald Welte883340c2018-02-28 18:59:29 +0100168 uint16_t arfcn,
169 BIT8 pdch_mask,
170 OCT1 spare,
171 OCT8 tsc,
172 uint32_t hLayer1
Harald Weltef1486592018-04-04 19:26:41 +0200173} with { variant (pdch_mask) "BITORDER(msb)" };
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700174private type record length(8) of PCUIF_InfoV09Trx PCUIF_InfoV09TrxList;
175
176type union PCUIF_InfoTrxs {
177 PCUIF_InfoV09TrxList v09,
178 PCUIF_InfoV10TrxList v10
179} with { variant "" };
Harald Welte883340c2018-02-28 18:59:29 +0100180
181type record PCUIF_info_ind {
182 uint32_t version,
183 PCUIF_Flags flags,
Harald Weltee1fd9162019-02-18 19:47:53 +0100184 PCUIF_InfoTrxs trx,
Harald Welte883340c2018-02-28 18:59:29 +0100185 uint8_t bsic,
186
187 uint16_t mcc,
188 uint16_t mnc,
Harald Welte3568dc72018-03-13 17:06:51 +0100189 uint8_t mnc_3_digits,
Harald Welte883340c2018-02-28 18:59:29 +0100190 uint16_t lac,
191 uint16_t rac,
192
193 uint16_t nsei,
194 record length(7) of uint8_t nse_timer,
195 record length(11) of uint8_t cell_timer,
196
197 uint16_t cell_id,
198 uint16_t repeat_time,
199 uint8_t repeat_count,
200 uint16_t bvci,
201 uint8_t t3142,
202 uint8_t t3169,
203 uint8_t t3191,
204 uint8_t t3193_10ms,
205 uint8_t t3195,
206 uint8_t t3101,
207 uint8_t t3103,
208 uint8_t t3105,
209 uint8_t cv_countdown,
210 uint16_t dl_tbf_ext,
211 uint16_t ul_tbf_ext,
212 uint8_t initial_cs,
213 uint8_t initial_mcs,
214
215 record length(2) of uint16_t nsvci,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700216 record length(2) of uint16_t local_port,
Harald Welte883340c2018-02-28 18:59:29 +0100217 record length(2) of uint16_t remote_port,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200218 PCUIF_RemoteAddr remote_addr
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700219} with {
220 /* NOTE: TITAN is not smart enough to handle 'version < 10' and 'version > 9',
221 * so we cannot support more than two versions at the same time here. Sigh. */
222 variant (trx) "CROSSTAG(v09, version = 9; v10, version = 10)"
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200223 variant (remote_addr) "CROSSTAG(v09, version = 9; v10, version = 10)"
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700224};
Harald Welte883340c2018-02-28 18:59:29 +0100225
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200226type union PCUIF_RemoteAddr {
227 PCUIF_RemoteAddrV09 v09,
228 PCUIF_RemoteAddrV10 v10
229} with { variant "" };
230
231type record PCUIF_RemoteAddrV09 {
232 record length(2) of OCT4 addr
233} with { variant "" };
234
235type enumerated PCUIF_AddrType {
236 PCUIF_ADDR_TYPE_UNSPEC ('00'O),
237 PCUIF_ADDR_TYPE_IPV4 ('04'O),
238 PCUIF_ADDR_TYPE_IPV6 ('29'O)
239} with { variant "FIELDLENGTH(8)" };
240
241type record PCUIF_RemoteAddrV10 {
242 record length(2) of PCUIF_AddrType addr_type,
243 record length(2) of octetstring addr length(16)
244} with { variant "" };
245
Harald Welte883340c2018-02-28 18:59:29 +0100246type record PCUIF_act_req {
247 uint8_t is_activate,
248 uint8_t trx_nr,
249 uint8_t ts_nr,
250 OCT1 spare
251} with { variant "" };
252
253type record PCUIF_time_ind {
254 uint32_t fn
255} with { variant "" };
256
257type record PCUIF_pag_req {
258 PCUIF_Sapi sapi,
259 uint8_t chan_needed,
260 OCT9 identity_lv
261} with { variant "" };
262
Harald Welte11b734c2019-09-05 14:17:54 +0200263type record PCUIF_app_info_req {
264 uint8_t application_type,
265 uint8_t len,
266 octetstring data
267} with {
268 variant (len) "LENGTHTO(data)"
269}
270
Harald Welte883340c2018-02-28 18:59:29 +0100271type record PCUIF_susp_req {
272 OCT4 tlli,
273 OCT6 ra_id,
274 uint8_t cause
Harald Welteeaa9a862019-05-26 23:01:08 +0200275} with {
276 variant (tlli) "BYTEORDER(last)"
277};
Harald Welte883340c2018-02-28 18:59:29 +0100278
279
280type union PCUIF_MsgUnion {
281 PCUIF_data data_req,
282 PCUIF_data data_cnf,
283 PCUIF_data_cnf_dt data_cnf_dt,
284 PCUIF_data data_ind,
285 PCUIF_susp_req susp_req,
286 PCUIF_rts_req rts_req,
287 PCUIF_rach_ind rach_ind,
288 PCUIF_txt_ind txt_ind,
289 PCUIF_info_ind info_ind,
290 PCUIF_act_req act_req,
291 PCUIF_time_ind time_ind,
Harald Welte11b734c2019-09-05 14:17:54 +0200292 PCUIF_pag_req pag_req,
293 PCUIF_app_info_req app_info_req
Harald Welte883340c2018-02-28 18:59:29 +0100294} with { variant "" };
295
296type record PCUIF_Message {
297 PCUIF_MsgType msg_type,
298 uint8_t bts_nr,
299 OCT2 spare,
300 PCUIF_MsgUnion u
301} with { variant (u) "CROSSTAG(
302 data_req, msg_type = PCU_IF_MSG_DATA_REQ;
303 data_cnf, msg_type = PCU_IF_MSG_DATA_CNF;
304 data_cnf_dt, msg_type = PCU_IF_MSG_DATA_CNF_DT;
305 data_ind, msg_type = PCU_IF_MSG_DATA_IND;
306 susp_req, msg_type = PCU_IF_MSG_SUSP_REQ;
307 rts_req, msg_type = PCU_IF_MSG_RTS_REQ;
308 rach_ind, msg_type = PCU_IF_MSG_RACH_IND;
309 txt_ind, msg_type = PCU_IF_MSG_TXT_IND;
310 info_ind, msg_type = PCU_IF_MSG_INFO_IND;
311 act_req, msg_type = PCU_IF_MSG_ACT_REQ;
312 time_ind, msg_type = PCU_IF_MSG_TIME_IND;
Harald Welte11b734c2019-09-05 14:17:54 +0200313 pag_req, msg_type = PCU_IF_MSG_PAG_REQ;
314 app_info_req, msg_type = PCU_IF_MSG_APP_INFO_REQ)"
Harald Welte883340c2018-02-28 18:59:29 +0100315};
316
317external function enc_PCUIF_Message(in PCUIF_Message pdu) return octetstring
318 with { extension "prototype(convert) encode(RAW)" };
319external function dec_PCUIF_Message(in octetstring stream) return PCUIF_Message
320 with { extension "prototype(convert) decode(RAW)" };
321
Vadim Yanitskiy220fa202020-09-15 19:15:01 +0700322function enc_pad_PCUIF_Message(in PCUIF_Message pdu)
323return octetstring {
324 var octetstring stream;
325 var integer len;
326
327 stream := enc_PCUIF_Message(pdu);
328 if (not mp_pcuif_padding) {
329 return stream;
330 }
331
332 select (mp_pcuif_version) {
333 case (9) { len := 212; }
334 /* FIXME: 1006 % 4 > 0 (alignment) */
335 case (10) { len := 1006; }
336 case else { len := 0; }
337 }
338
339 return f_pad_oct(stream, len, '00'O);
340}
341
Harald Welte883340c2018-02-28 18:59:29 +0100342
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200343/* Generic template for matching messages by type and/or the BTS number */
344template PCUIF_Message tr_PCUIF_MSG(template PCUIF_MsgType msg_type := ?,
345 template uint8_t bts_nr := ?) := {
346 msg_type := msg_type,
347 bts_nr := bts_nr,
348 spare := ?,
349 u := ?
350}
351
Harald Weltee1fd9162019-02-18 19:47:53 +0100352template (value) PCUIF_Message ts_PCUIF_RTS_REQ(template (value) uint8_t bts_nr,
353 template (value) uint8_t trx_nr,
354 template (value) uint8_t ts_nr,
355 template (value) PCUIF_Sapi sapi,
356 template (value) uint32_t fn,
357 template (value) uint16_t arfcn,
358 template (value) uint8_t block_nr
359 ) := {
360 msg_type := PCU_IF_MSG_RTS_REQ,
361 bts_nr := bts_nr,
362 spare := '0000'O,
363 u := {
364 rts_req := {
365 sapi := sapi,
366 spare := '000000'O,
367 fn := fn,
368 arfcn := arfcn,
369 trx_nr := trx_nr,
370 ts_nr := ts_nr,
371 block_nr := block_nr
372 }
373 }
374}
Harald Welte883340c2018-02-28 18:59:29 +0100375template PCUIF_Message tr_PCUIF_RTS_REQ(template uint8_t bts_nr := ?,
376 template uint8_t trx_nr := ?,
377 template uint8_t ts_nr := ?,
378 template PCUIF_Sapi sapi := ?,
379 template uint32_t fn := ?,
380 template uint8_t block_nr := ?
381 ) := {
382 msg_type := PCU_IF_MSG_RTS_REQ,
383 bts_nr := bts_nr,
384 spare := ?,
385 u := {
386 rts_req := {
387 sapi := sapi,
388 spare := ?,
389 fn := fn,
390 arfcn := ?,
391 trx_nr := trx_nr,
392 ts_nr := ts_nr,
393 block_nr := block_nr
394 }
395 }
396}
397
398template (value) PCUIF_Message ts_PCUIF_TXT_IND(uint8_t bts_nr, PCUIF_TextType tt, charstring text) := {
399 msg_type := PCU_IF_MSG_TXT_IND,
400 bts_nr := bts_nr,
401 spare := '0000'O,
402 u := {
403 txt_ind := {
404 txt_type := tt,
405 text := text
406 }
407 }
408}
Harald Weltee1fd9162019-02-18 19:47:53 +0100409template PCUIF_Message tr_PCUIF_TXT_IND(template uint8_t bts_nr, template PCUIF_TextType tt,
410 template charstring text := ?) := {
411 msg_type := PCU_IF_MSG_TXT_IND,
412 bts_nr := bts_nr,
413 spare := '0000'O,
414 u := {
415 txt_ind := {
416 txt_type := tt,
417 text := text
418 }
419 }
420}
421
422
Harald Welte883340c2018-02-28 18:59:29 +0100423
424template (value) PCUIF_Message ts_PCUIF_ACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
425 msg_type := PCU_IF_MSG_ACT_REQ,
426 bts_nr := bts_nr,
427 spare := '0000'O,
428 u := {
429 act_req := {
430 is_activate := 1,
431 trx_nr := trx_nr,
432 ts_nr := ts_nr,
433 spare := '00'O
434 }
435 }
436}
Harald Weltee1fd9162019-02-18 19:47:53 +0100437template PCUIF_Message tr_PCUIF_ACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
438 template uint8_t ts_nr) := {
439 msg_type := PCU_IF_MSG_ACT_REQ,
440 bts_nr := bts_nr,
441 spare := '0000'O,
442 u := {
443 act_req := {
444 is_activate := 1,
445 trx_nr := trx_nr,
446 ts_nr := ts_nr,
447 spare := '00'O
448 }
449 }
450}
Harald Welte883340c2018-02-28 18:59:29 +0100451
452template (value) PCUIF_Message ts_PCUIF_DEACT_REQ(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) := {
453 msg_type := PCU_IF_MSG_ACT_REQ,
454 bts_nr := bts_nr,
455 spare := '0000'O,
456 u := {
457 act_req := {
458 is_activate := 0,
459 trx_nr := trx_nr,
460 ts_nr := ts_nr,
461 spare := '00'O
462 }
463 }
464}
Harald Weltee1fd9162019-02-18 19:47:53 +0100465template PCUIF_Message tr_PCUIF_DEACT_REQ(template uint8_t bts_nr, template uint8_t trx_nr,
466 template uint8_t ts_nr) := {
467 msg_type := PCU_IF_MSG_ACT_REQ,
468 bts_nr := bts_nr,
469 spare := '0000'O,
470 u := {
471 act_req := {
472 is_activate := 0,
473 trx_nr := trx_nr,
474 ts_nr := ts_nr,
475 spare := '00'O
476 }
477 }
478}
Harald Welte883340c2018-02-28 18:59:29 +0100479
Harald Weltee1fd9162019-02-18 19:47:53 +0100480template (value) PCUIF_Message ts_PCUIF_DATA_IND(template (value) uint8_t bts_nr,
481 template (value) uint8_t trx_nr,
482 template (value) uint8_t ts_nr,
483 template (value) uint8_t block_nr,
484 template (value) PCUIF_Sapi sapi,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700485 template (value) octetstring data,
Harald Weltee1fd9162019-02-18 19:47:53 +0100486 template (value) uint32_t fn,
487 template (value) uint16_t arfcn,
488 template (value) int8_t rssi := -80,
489 template (value) uint16_t ber10k := 0,
490 template (value) int16_t ta_offs_qbits := 0,
491 template (value) uint16_t lqual_cb := 10) := {
492 msg_type := PCU_IF_MSG_DATA_IND,
493 bts_nr := bts_nr,
494 spare := '0000'O,
495 u := {
496 data_ind := {
497 sapi := sapi,
498 len := lengthof(valueof(data)),
499 data := data,
500 fn := fn,
501 arfcn := arfcn,
502 trx_nr := trx_nr,
503 ts_nr := ts_nr,
504 block_nr := block_nr,
505 rssi := rssi,
506 ber10k := ber10k,
507 ta_offs_qbits := ta_offs_qbits,
508 lqual_cb := lqual_cb
509 }
510 }
511}
Harald Welte883340c2018-02-28 18:59:29 +0100512template PCUIF_Message tr_PCUIF_DATA_IND(template uint8_t bts_nr := ?,
513 template uint8_t trx_nr := ?,
514 template uint8_t ts_nr := ?,
515 template uint8_t block_nr := ?,
516 template PCUIF_Sapi sapi := ?,
Vadim Yanitskiyc78ea262019-05-17 01:08:08 +0700517 template octetstring data := ?) := {
Harald Welte883340c2018-02-28 18:59:29 +0100518 msg_type := PCU_IF_MSG_DATA_IND,
519 bts_nr := bts_nr,
520 spare := ?,
521 u := {
522 data_ind := {
523 sapi := sapi,
524 len := ?,
525 data := data,
526 fn := ?,
527 arfcn := ?,
528 trx_nr := trx_nr,
529 ts_nr := ts_nr,
530 block_nr := block_nr,
531 rssi := ?,
532 ber10k := ?,
533 ta_offs_qbits := ?,
534 lqual_cb := ?
535 }
536 }
537}
538
539template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
540 uint8_t ts_nr, uint8_t block_nr,
541 uint32_t fn, PCUIF_Sapi sapi,
542 octetstring data) := {
543 msg_type := PCU_IF_MSG_DATA_REQ,
544 bts_nr := bts_nr,
545 spare := '0000'O,
546 u := {
547 data_req := {
548 sapi := sapi,
549 len := lengthof(data),
550 data := data,
551 fn := fn,
552 arfcn := 0, /* unused in BTS */
553 trx_nr := trx_nr,
554 ts_nr := ts_nr,
555 block_nr := block_nr,
556 /* measurement parameters below unused on Tx */
557 rssi := 0,
558 ber10k := 0,
559 ta_offs_qbits := 0,
560 lqual_cb := 0
561 }
562 }
563}
Harald Weltee1fd9162019-02-18 19:47:53 +0100564template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
565 template uint8_t trx_nr,
566 template uint8_t ts_nr,
567 template uint8_t block_nr := ?,
568 template uint32_t fn := ?,
569 template PCUIF_Sapi sapi := ?,
570 template octetstring data := ?) := {
571 msg_type := PCU_IF_MSG_DATA_REQ,
572 bts_nr := bts_nr,
573 spare := '0000'O,
574 u := {
575 data_req := {
576 sapi := sapi,
577 len := ?,
578 data := data,
579 fn := fn,
Harald Welte0a3d63f2019-03-02 00:02:07 +0100580 arfcn := ?, /* unused in BTS */
Harald Weltee1fd9162019-02-18 19:47:53 +0100581 trx_nr := trx_nr,
582 ts_nr := ts_nr,
583 block_nr := block_nr,
584 /* measurement parameters below unused on Tx */
585 rssi := 0,
586 ber10k := 0,
587 ta_offs_qbits := 0,
588 lqual_cb := 0
589 }
590 }
591}
Harald Welte883340c2018-02-28 18:59:29 +0100592
Harald Weltee1fd9162019-02-18 19:47:53 +0100593template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
594 template (value) uint8_t trx_nr,
595 template (value) uint8_t ts_nr,
596 template (value) uint8_t block_nr,
597 template (value) uint32_t fn,
598 template (value) uint16_t arfcn,
599 template (value) PCUIF_Sapi sapi,
600 template (value) octetstring data) := {
601 msg_type := PCU_IF_MSG_DATA_CNF,
602 bts_nr := bts_nr,
603 spare := '0000'O,
604 u := {
605 data_cnf := {
606 sapi := sapi,
607 len := 0, /* overwritten */
608 data := data,
609 fn := fn,
610 arfcn := arfcn,
611 trx_nr := trx_nr,
612 ts_nr := ts_nr,
613 block_nr := block_nr,
614 rssi := 0,
615 ber10k := 0,
616 ta_offs_qbits := 0,
617 lqual_cb := 0
618 }
619 }
620}
Harald Welte883340c2018-02-28 18:59:29 +0100621template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
622 template uint8_t trx_nr := ?,
623 template uint8_t ts_nr := ?,
624 template PCUIF_Sapi sapi := ?,
625 template octetstring data := ?) := {
626 msg_type := PCU_IF_MSG_DATA_CNF,
627 bts_nr := bts_nr,
628 spare := ?,
629 u := {
630 data_cnf := {
631 sapi := sapi,
632 len := ?,
633 data := data,
634 fn := ?,
635 arfcn := ?,
636 trx_nr := trx_nr,
637 ts_nr := ts_nr,
638 block_nr := ?,
639 rssi := ?,
640 ber10k := ?,
641 ta_offs_qbits := ?,
642 lqual_cb := ?
643 }
644 }
645}
646
Harald Weltee1fd9162019-02-18 19:47:53 +0100647template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700648 template (value) uint8_t trx_nr,
649 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100650 template (value) uint16_t ra,
651 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100652 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100653 template (value) uint32_t fn,
654 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700655 template (value) int16_t qta := 0,
656 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100657) := {
658 msg_type := PCU_IF_MSG_RACH_IND,
659 bts_nr := bts_nr,
660 spare := '0000'O,
661 u := {
662 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700663 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100664 ra := ra,
665 qta := qta,
666 fn := fn,
667 arfcn := arfcn,
668 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700669 burst_type := burst_type,
670 trx_nr := trx_nr,
671 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100672 }
673 }
674}
Harald Welte883340c2018-02-28 18:59:29 +0100675template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700676 template uint8_t trx_nr := ?,
677 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100678 template uint16_t ra := ?,
679 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100680 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700681 template uint32_t fn := ?,
682 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100683 msg_type := PCU_IF_MSG_RACH_IND,
684 bts_nr := bts_nr,
685 spare := ?,
686 u := {
687 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700688 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100689 ra := ra,
690 qta := ?,
691 fn := fn,
692 arfcn := ?,
693 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700694 burst_type := burst_type,
695 trx_nr := trx_nr,
696 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100697 }
698 }
699}
700
Harald Weltee1fd9162019-02-18 19:47:53 +0100701template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
702 template (value) OCT9 id_lv,
703 template (value) uint8_t chan_needed,
704 template (value) PCUIF_Sapi sapi) := {
705 msg_type := PCU_IF_MSG_PAG_REQ,
706 bts_nr := bts_nr,
707 spare := '0000'O,
708 u := {
709 pag_req := {
710 sapi := sapi,
711 chan_needed := chan_needed,
712 identity_lv := id_lv
713 }
714 }
715}
Harald Welte883340c2018-02-28 18:59:29 +0100716template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
717 template OCT9 id_lv := ?,
718 template uint8_t chan_needed := ?,
719 template PCUIF_Sapi sapi := ?) := {
720 msg_type := PCU_IF_MSG_PAG_REQ,
721 bts_nr := bts_nr,
722 spare := ?,
723 u := {
724 pag_req := {
725 sapi := ?,
726 chan_needed := chan_needed,
727 identity_lv := id_lv
728 }
729 }
730}
731
Harald Weltee1fd9162019-02-18 19:47:53 +0100732const PCUIF_Flags c_PCUIF_Flags_default := {
733 bts_active := true,
734 sysmo_direct_dsp := false,
735 spare := '00000000000000'B,
736 cs1 := true,
737 cs2 := true,
738 cs3 := true,
739 cs4 := true,
740 mcs1 := true,
741 mcs2 := true,
742 mcs3 := true,
743 mcs4 := true,
744 mcs5 := true,
745 mcs6 := true,
746 mcs7 := true,
747 mcs8 := true,
748 mcs9 := true,
749 spare2 := '000'B
750};
751
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700752template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
753 tsc := tsc,
754 hopping := 0,
755 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700756 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700757 ma := f_pad_bit(''B, 64, '0'B)
758};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700759template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
760 tsc := tsc,
761 hopping := 0,
762 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700763 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700764 ma := ?
765};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700766
767template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
768 template (value) uint6_t hsn := 0,
769 template (value) uint6_t maio := 0,
770 template (value) bitstring ma := ''B) := {
771 tsc := tsc,
772 hopping := 1,
773 hsn := hsn,
774 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700775 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700776 ma := f_pad_bit(valueof(ma), 64, '0'B)
777};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700778template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
779 template uint6_t hsn := ?,
780 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700781 template bitstring ma := ?,
782 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700783 tsc := tsc,
784 hopping := 1,
785 hsn := hsn,
786 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700787 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700788 ma := ma
789};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700790
791template (value) PCUIF_InfoV10Trx ts_PCUIF_InfoV10Trx(template (value) uint16_t arfcn := 871,
792 template (value) BIT8 pdch_mask := '00000001'B,
793 template (value) uint3_t tsc := 7) := {
794 arfcn := arfcn,
795 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700796 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700797 hLayer1 := 0,
798 ts := {
799 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
800 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
801 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
802 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
803 }
804};
805
806template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09Trx(template (value) uint16_t arfcn := 871,
807 template (value) BIT8 pdch_mask := '00000001'B,
808 OCT1 tsc := '07'O) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100809 arfcn := arfcn,
810 pdch_mask := pdch_mask,
811 spare := '00'O,
812 tsc := tsc & tsc & tsc & tsc & tsc & tsc & tsc & tsc,
813 hLayer1 := 0
814}
815
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700816template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09TrxNULL := ts_PCUIF_InfoV09Trx(0, '00000000'B, '00'O);
Harald Weltee1fd9162019-02-18 19:47:53 +0100817
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700818template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def := {
819 v09 := {
820 ts_PCUIF_InfoV09Trx, ts_PCUIF_InfoV09TrxNULL,
821 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
822 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
823 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL
824 }
825};
826
827template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def := {
828 v10 := {
829 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
830 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
831 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx,
832 ts_PCUIF_InfoV10Trx, ts_PCUIF_InfoV10Trx
833 }
834};
Harald Weltee1fd9162019-02-18 19:47:53 +0100835
Harald Weltee1fd9162019-02-18 19:47:53 +0100836template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200837 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100838 msg_type := PCU_IF_MSG_INFO_IND,
839 bts_nr := bts_nr,
840 spare := '0000'O,
841 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200842 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100843 }
844}
Harald Welted378a252018-03-13 17:02:14 +0100845template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
846 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700847 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100848 msg_type := PCU_IF_MSG_INFO_IND,
849 bts_nr := bts_nr,
850 spare := ?,
851 u := {
852 info_ind := {
853 version := version,
854 flags := flags,
855 trx := ?,
856 bsic := ?,
857 mcc := ?,
858 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100859 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100860 lac := ?,
861 rac := ?,
862 nsei := ?,
863 nse_timer := ?,
864 cell_timer := ?,
865 cell_id := ?,
866 repeat_time := ?,
867 repeat_count := ?,
868 bvci := ?,
869 t3142 := ?,
870 t3169 := ?,
871 t3191 := ?,
872 t3193_10ms := ?,
873 t3195 := ?,
874 t3101 := ?,
875 t3103 := ?,
876 t3105 := ?,
877 cv_countdown := ?,
878 dl_tbf_ext := ?,
879 ul_tbf_ext := ?,
880 initial_cs := ?,
881 initial_mcs := ?,
882 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700883 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100884 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200885 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100886 }
887 }
888}
889
Harald Weltea3219812019-03-02 00:02:28 +0100890template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
891 template (value) uint32_t fn) := {
892 msg_type := PCU_IF_MSG_TIME_IND,
893 bts_nr := bts_nr,
894 spare := '0000'O,
895 u := {
896 time_ind := {
897 fn := fn
898 }
899 }
900}
901template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
902 template uint32_t fn) := {
903 msg_type := PCU_IF_MSG_TIME_IND,
904 bts_nr := bts_nr,
905 spare := ?,
906 u := {
907 time_ind := {
908 fn := fn
909 }
910 }
911}
Harald Welte883340c2018-02-28 18:59:29 +0100912
Harald Welte4bff40a2019-03-21 21:34:10 +0100913template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
914 template (value) OCT4 tlli,
915 template (value) OCT6 ra_id,
916 template (value) uint8_t cause) := {
917 msg_type := PCU_IF_MSG_SUSP_REQ,
918 bts_nr := bts_nr,
919 spare := '0000'O,
920 u := {
921 susp_req := {
922 tlli := tlli,
923 ra_id := ra_id,
924 cause := cause
925 }
926 }
927}
928template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
929 template OCT4 tlli,
930 template OCT6 ra_id,
931 template uint8_t cause) := {
932 msg_type := PCU_IF_MSG_SUSP_REQ,
933 bts_nr := bts_nr,
934 spare := '0000'O,
935 u := {
936 susp_req := {
937 tlli := tlli,
938 ra_id := ra_id,
939 cause := cause
940 }
941 }
942}
943
Harald Welte11b734c2019-09-05 14:17:54 +0200944template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
945 template (value) uint8_t app_type,
946 template (value) octetstring app_data) := {
947 msg_type := PCU_IF_MSG_APP_INFO_REQ,
948 bts_nr := bts_nr,
949 spare := '0000'O,
950 u := {
951 app_info_req := {
952 application_type := app_type,
953 len := 0, /* overwritten */
954 data := app_data
955 }
956 }
957}
958template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
959 template (present) uint8_t app_type,
960 template (present) octetstring app_data) := {
961 msg_type := PCU_IF_MSG_APP_INFO_REQ,
962 bts_nr := bts_nr,
963 spare := '0000'O,
964 u := {
965 app_info_req := {
966 application_type := app_type,
967 len := ?,
968 data := app_data
969 }
970 }
971}
972
Harald Welte4bff40a2019-03-21 21:34:10 +0100973
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700974/* TODO: remove this as soon as we drop version 9 support */
975function f_PCUIF_ver_INFO_Trxs()
976return PCUIF_InfoTrxs {
977 if (PCUIF_Types.mp_pcuif_version >= 10) {
978 return valueof(ts_PCUIF_InfoV10Trxs_def);
979 } else {
980 return valueof(ts_PCUIF_InfoV09Trxs_def);
981 }
982}
983
984function f_PCUIF_ver_INFO_PDCHMask(in PCUIF_info_ind info, uint8_t trx_nr)
985return bitstring {
986 if (PCUIF_Types.mp_pcuif_version >= 10) {
987 return info.trx.v10[trx_nr].pdch_mask;
988 } else {
989 return info.trx.v09[trx_nr].pdch_mask;
990 }
991}
992
Alexander Couzense0f7c542020-09-13 17:25:18 +0200993function f_PCUIF_AF2addr_type(AddressFamily address_family)
994return PCUIF_AddrType {
995 if (address_family == AF_INET) {
996 return PCUIF_ADDR_TYPE_IPV4;
997 } else if (address_family == AF_INET6) {
998 return PCUIF_ADDR_TYPE_IPV6;
999 } else {
1000 return PCUIF_ADDR_TYPE_UNSPEC;
1001 }
1002}
1003
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001004/* TODO: second (redundant) NSVC connection is not (yet) supported */
1005function f_PCUIF_ver_INFO_RemoteAddr(PCUIF_AddrType addr_type,
1006 charstring addr)
1007return PCUIF_RemoteAddr {
1008 var PCUIF_RemoteAddr remote_addr;
1009
1010 if (PCUIF_Types.mp_pcuif_version >= 10) {
1011 remote_addr.v10.addr_type[0] := addr_type;
1012 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
1013 remote_addr.v10.addr[0] := f_inet_addr(addr);
1014 } else {
1015 remote_addr.v10.addr[0] := f_inet6_addr(addr);
1016 }
1017 remote_addr.v10.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
1018 remote_addr.v10.addr[1] := f_pad_oct(''O, 16, '00'O);
1019 } else {
1020 if (addr_type != PCUIF_ADDR_TYPE_IPV4) {
1021 testcase.stop("NSVC address type := ", addr_type,
1022 "is not supported in version := ",
1023 PCUIF_Types.mp_pcuif_version);
1024 }
1025 /* v9 requires the IP in host byte order */
1026 remote_addr.v09.addr[0] := f_inet_haddr(addr);
Alexander Couzensefca79d2020-09-16 04:57:47 +02001027 remote_addr.v09.addr[1] := f_pad_oct(''O, 4, '00'O);
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001028 }
1029
1030 return remote_addr;
1031}
1032
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001033
Harald Welte883340c2018-02-28 18:59:29 +01001034} with { encode "RAW" variant "BYTEORDER(first)" };