blob: 31721c834986826591798d793df3dfaae8c1ccbc [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* Osmocom PCU Interface Types, as per osmo-pcu/include/osmocom/pcu/pcuif_proto.h
2 * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
3 * contributions by Vadim Yanitskiy <axilirator@gmail.com>
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
Harald Welte883340c2018-02-28 18:59:29 +010012module PCUIF_Types {
13
14import from General_Types all;
15import from Osmocom_Types all;
Alexander Couzens1e5dc482020-07-28 15:38:46 +020016import from Native_Functions all;
Harald Welte883340c2018-02-28 18:59:29 +010017
Vadim Yanitskiyc1559302020-07-19 16:39:12 +070018modulepar {
19 /* PCUIF version supported by the IUT */
Vadim Yanitskiybefa21c2020-09-22 00:53:16 +070020 PCUIF_Version mp_pcuif_version := 10;
Vadim 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
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100539template PCUIF_data tr_PCUIF_DATA(template uint8_t trx_nr,
540 template uint8_t ts_nr,
541 template uint8_t block_nr := ?,
542 template uint32_t fn := ?,
543 template PCUIF_Sapi sapi := ?,
544 template octetstring data := ?) := {
545 sapi := sapi,
546 len := ?,
547 data := data,
548 fn := fn,
549 arfcn := ?, /* unused in BTS */
550 trx_nr := trx_nr,
551 ts_nr := ts_nr,
552 block_nr := block_nr,
553 /* measurement parameters below unused on Tx */
554 rssi := 0,
555 ber10k := 0,
556 ta_offs_qbits := 0,
557 lqual_cb := 0
558
559}
560
Harald Welte883340c2018-02-28 18:59:29 +0100561template (value) PCUIF_Message ts_PCUIF_DATA_REQ(uint8_t bts_nr, uint8_t trx_nr,
562 uint8_t ts_nr, uint8_t block_nr,
563 uint32_t fn, PCUIF_Sapi sapi,
564 octetstring data) := {
565 msg_type := PCU_IF_MSG_DATA_REQ,
566 bts_nr := bts_nr,
567 spare := '0000'O,
568 u := {
569 data_req := {
570 sapi := sapi,
571 len := lengthof(data),
572 data := data,
573 fn := fn,
574 arfcn := 0, /* unused in BTS */
575 trx_nr := trx_nr,
576 ts_nr := ts_nr,
577 block_nr := block_nr,
578 /* measurement parameters below unused on Tx */
579 rssi := 0,
580 ber10k := 0,
581 ta_offs_qbits := 0,
582 lqual_cb := 0
583 }
584 }
585}
Harald Weltee1fd9162019-02-18 19:47:53 +0100586template PCUIF_Message tr_PCUIF_DATA_REQ(template uint8_t bts_nr,
587 template uint8_t trx_nr,
588 template uint8_t ts_nr,
589 template uint8_t block_nr := ?,
590 template uint32_t fn := ?,
591 template PCUIF_Sapi sapi := ?,
592 template octetstring data := ?) := {
593 msg_type := PCU_IF_MSG_DATA_REQ,
594 bts_nr := bts_nr,
595 spare := '0000'O,
596 u := {
Pau Espin Pedrolcf5c33e2021-01-19 18:56:55 +0100597 data_req := tr_PCUIF_DATA(trx_nr, ts_nr, block_nr, fn, sapi, data)
Harald Weltee1fd9162019-02-18 19:47:53 +0100598 }
599}
Harald Welte883340c2018-02-28 18:59:29 +0100600
Harald Weltee1fd9162019-02-18 19:47:53 +0100601template (value) PCUIF_Message ts_PCUIF_DATA_CNF(template (value) uint8_t bts_nr,
602 template (value) uint8_t trx_nr,
603 template (value) uint8_t ts_nr,
604 template (value) uint8_t block_nr,
605 template (value) uint32_t fn,
606 template (value) uint16_t arfcn,
607 template (value) PCUIF_Sapi sapi,
608 template (value) octetstring data) := {
609 msg_type := PCU_IF_MSG_DATA_CNF,
610 bts_nr := bts_nr,
611 spare := '0000'O,
612 u := {
613 data_cnf := {
614 sapi := sapi,
615 len := 0, /* overwritten */
616 data := data,
617 fn := fn,
618 arfcn := arfcn,
619 trx_nr := trx_nr,
620 ts_nr := ts_nr,
621 block_nr := block_nr,
622 rssi := 0,
623 ber10k := 0,
624 ta_offs_qbits := 0,
625 lqual_cb := 0
626 }
627 }
628}
Harald Welte883340c2018-02-28 18:59:29 +0100629template PCUIF_Message tr_PCUIF_DATA_CNF(template uint8_t bts_nr := ?,
630 template uint8_t trx_nr := ?,
631 template uint8_t ts_nr := ?,
632 template PCUIF_Sapi sapi := ?,
633 template octetstring data := ?) := {
634 msg_type := PCU_IF_MSG_DATA_CNF,
635 bts_nr := bts_nr,
636 spare := ?,
637 u := {
638 data_cnf := {
639 sapi := sapi,
640 len := ?,
641 data := data,
642 fn := ?,
643 arfcn := ?,
644 trx_nr := trx_nr,
645 ts_nr := ts_nr,
646 block_nr := ?,
647 rssi := ?,
648 ber10k := ?,
649 ta_offs_qbits := ?,
650 lqual_cb := ?
651 }
652 }
653}
654
Harald Weltee1fd9162019-02-18 19:47:53 +0100655template (value) PCUIF_Message ts_PCUIF_RACH_IND(template (value) uint8_t bts_nr,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700656 template (value) uint8_t trx_nr,
657 template (value) uint8_t ts_nr,
Harald Weltee1fd9162019-02-18 19:47:53 +0100658 template (value) uint16_t ra,
659 template (value) uint8_t is_11bit,
Harald Welte913bbf62019-03-01 00:39:19 +0100660 template (value) PCUIF_BurstType burst_type,
Harald Weltee1fd9162019-02-18 19:47:53 +0100661 template (value) uint32_t fn,
662 template (value) uint16_t arfcn,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700663 template (value) int16_t qta := 0,
664 template (value) PCUIF_Sapi sapi := PCU_IF_SAPI_RACH
Harald Weltee1fd9162019-02-18 19:47:53 +0100665) := {
666 msg_type := PCU_IF_MSG_RACH_IND,
667 bts_nr := bts_nr,
668 spare := '0000'O,
669 u := {
670 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700671 sapi := sapi,
Harald Weltee1fd9162019-02-18 19:47:53 +0100672 ra := ra,
673 qta := qta,
674 fn := fn,
675 arfcn := arfcn,
676 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700677 burst_type := burst_type,
678 trx_nr := trx_nr,
679 ts_nr := ts_nr
Harald Weltee1fd9162019-02-18 19:47:53 +0100680 }
681 }
682}
Harald Welte883340c2018-02-28 18:59:29 +0100683template PCUIF_Message tr_PCUIF_RACH_IND(template uint8_t bts_nr := ?,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700684 template uint8_t trx_nr := ?,
685 template uint8_t ts_nr := ?,
Harald Welte883340c2018-02-28 18:59:29 +0100686 template uint16_t ra := ?,
687 template uint8_t is_11bit := ?,
Harald Welte913bbf62019-03-01 00:39:19 +0100688 template PCUIF_BurstType burst_type := ?,
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700689 template uint32_t fn := ?,
690 template PCUIF_Sapi sapi := PCU_IF_SAPI_RACH) := {
Harald Welte883340c2018-02-28 18:59:29 +0100691 msg_type := PCU_IF_MSG_RACH_IND,
692 bts_nr := bts_nr,
693 spare := ?,
694 u := {
695 rach_ind := {
Vadim Yanitskiy36aa6112019-10-04 16:43:00 +0700696 sapi := sapi,
Harald Welte883340c2018-02-28 18:59:29 +0100697 ra := ra,
698 qta := ?,
699 fn := fn,
700 arfcn := ?,
701 is_11bit := is_11bit,
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700702 burst_type := burst_type,
703 trx_nr := trx_nr,
704 ts_nr := ts_nr
Harald Welte883340c2018-02-28 18:59:29 +0100705 }
706 }
707}
708
Harald Weltee1fd9162019-02-18 19:47:53 +0100709template (value) PCUIF_Message ts_PCUIF_PAG_REQ(template (value) uint8_t bts_nr,
710 template (value) OCT9 id_lv,
711 template (value) uint8_t chan_needed,
712 template (value) PCUIF_Sapi sapi) := {
713 msg_type := PCU_IF_MSG_PAG_REQ,
714 bts_nr := bts_nr,
715 spare := '0000'O,
716 u := {
717 pag_req := {
718 sapi := sapi,
719 chan_needed := chan_needed,
720 identity_lv := id_lv
721 }
722 }
723}
Harald Welte883340c2018-02-28 18:59:29 +0100724template PCUIF_Message tr_PCUIF_PAG_REQ(template uint8_t bts_nr := ?,
725 template OCT9 id_lv := ?,
726 template uint8_t chan_needed := ?,
727 template PCUIF_Sapi sapi := ?) := {
728 msg_type := PCU_IF_MSG_PAG_REQ,
729 bts_nr := bts_nr,
730 spare := ?,
731 u := {
732 pag_req := {
733 sapi := ?,
734 chan_needed := chan_needed,
735 identity_lv := id_lv
736 }
737 }
738}
739
Harald Weltee1fd9162019-02-18 19:47:53 +0100740const PCUIF_Flags c_PCUIF_Flags_default := {
741 bts_active := true,
742 sysmo_direct_dsp := false,
743 spare := '00000000000000'B,
744 cs1 := true,
745 cs2 := true,
746 cs3 := true,
747 cs4 := true,
748 mcs1 := true,
749 mcs2 := true,
750 mcs3 := true,
751 mcs4 := true,
752 mcs5 := true,
753 mcs6 := true,
754 mcs7 := true,
755 mcs8 := true,
756 mcs9 := true,
757 spare2 := '000'B
758};
759
Pau Espin Pedrol745a48b2020-10-30 15:31:07 +0100760const PCUIF_Flags c_PCUIF_Flags_noMCS := {
761 bts_active := true,
762 sysmo_direct_dsp := false,
763 spare := '00000000000000'B,
764 cs1 := true,
765 cs2 := true,
766 cs3 := true,
767 cs4 := true,
768 mcs1 := false,
769 mcs2 := false,
770 mcs3 := false,
771 mcs4 := false,
772 mcs5 := false,
773 mcs6 := false,
774 mcs7 := false,
775 mcs8 := false,
776 mcs9 := false,
777 spare2 := '000'B
778};
779
780function f_pcuif_ind_flags_egprs_enabled(PCUIF_Flags flags) return boolean {
781 return flags.mcs1 or flags.mcs2 or flags.mcs3 or flags.mcs4 or
782 flags.mcs5 or flags.mcs6 or flags.mcs7 or flags.mcs8 or
783 flags.mcs9;
784}
785
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700786template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH0(template (value) uint3_t tsc := 7) := {
787 tsc := tsc,
788 hopping := 0,
789 hsn := 0, maio := 0,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700790 ma_bit_len := 0,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700791 ma := f_pad_bit(''B, 64, '0'B)
792};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700793template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH0(template uint3_t tsc := ?) := {
794 tsc := tsc,
795 hopping := 0,
796 hsn := ?, maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700797 ma_bit_len := ?,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700798 ma := ?
799};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700800
801template (value) PCUIF_InfoTrxTs ts_PCUIF_InfoTrxTsH1(template (value) uint3_t tsc := 7,
802 template (value) uint6_t hsn := 0,
803 template (value) uint6_t maio := 0,
804 template (value) bitstring ma := ''B) := {
805 tsc := tsc,
806 hopping := 1,
807 hsn := hsn,
808 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700809 ma_bit_len := lengthof(valueof(ma)),
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700810 ma := f_pad_bit(valueof(ma), 64, '0'B)
811};
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700812template PCUIF_InfoTrxTs tr_PCUIF_InfoTrxTsH1(template uint3_t tsc := ?,
813 template uint6_t hsn := ?,
814 template uint6_t maio := ?,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700815 template bitstring ma := ?,
816 template uint8_t ma_bit_len := ?) := {
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700817 tsc := tsc,
818 hopping := 1,
819 hsn := hsn,
820 maio := maio,
Vadim Yanitskiy43ccaf52020-09-05 21:35:13 +0700821 ma_bit_len := ma_bit_len,
Vadim Yanitskiy355604c2020-08-03 04:19:05 +0700822 ma := ma
823};
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700824
825template (value) PCUIF_InfoV10Trx ts_PCUIF_InfoV10Trx(template (value) uint16_t arfcn := 871,
826 template (value) BIT8 pdch_mask := '00000001'B,
827 template (value) uint3_t tsc := 7) := {
828 arfcn := arfcn,
829 pdch_mask := pdch_mask,
Vadim Yanitskiyd8051722020-08-22 02:33:17 +0700830 spare := '00'O,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700831 hLayer1 := 0,
832 ts := {
833 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
834 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
835 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc),
836 ts_PCUIF_InfoTrxTsH0(tsc), ts_PCUIF_InfoTrxTsH0(tsc)
837 }
838};
839
840template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09Trx(template (value) uint16_t arfcn := 871,
841 template (value) BIT8 pdch_mask := '00000001'B,
842 OCT1 tsc := '07'O) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100843 arfcn := arfcn,
844 pdch_mask := pdch_mask,
845 spare := '00'O,
846 tsc := tsc & tsc & tsc & tsc & tsc & tsc & tsc & tsc,
847 hLayer1 := 0
848}
849
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700850template (value) PCUIF_InfoV09Trx ts_PCUIF_InfoV09TrxNULL := ts_PCUIF_InfoV09Trx(0, '00000000'B, '00'O);
Harald Weltee1fd9162019-02-18 19:47:53 +0100851
Pau Espin Pedrol2aead382020-10-29 20:46:47 +0100852template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV09Trxs_def(uint16_t base_arfcn) := {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700853 v09 := {
Pau Espin Pedrol2aead382020-10-29 20:46:47 +0100854 ts_PCUIF_InfoV09Trx(arfcn := base_arfcn + 0), ts_PCUIF_InfoV09TrxNULL,
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700855 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
856 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL,
857 ts_PCUIF_InfoV09TrxNULL, ts_PCUIF_InfoV09TrxNULL
858 }
859};
860
Pau Espin Pedrol2aead382020-10-29 20:46:47 +0100861template (value) PCUIF_InfoTrxs ts_PCUIF_InfoV10Trxs_def(uint16_t base_arfcn) := {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700862 v10 := {
Pau Espin Pedrol2aead382020-10-29 20:46:47 +0100863 ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 0), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 1),
864 ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 2), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 3),
865 ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 4), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 5),
866 ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 6), ts_PCUIF_InfoV10Trx(arfcn := base_arfcn + 7)
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +0700867 }
868};
Harald Weltee1fd9162019-02-18 19:47:53 +0100869
Harald Weltee1fd9162019-02-18 19:47:53 +0100870template (value) PCUIF_Message ts_PCUIF_INFO_IND(template (value) uint8_t bts_nr,
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200871 template (value) PCUIF_info_ind info_ind) := {
Harald Weltee1fd9162019-02-18 19:47:53 +0100872 msg_type := PCU_IF_MSG_INFO_IND,
873 bts_nr := bts_nr,
874 spare := '0000'O,
875 u := {
Pau Espin Pedrolf787b092019-10-04 18:34:05 +0200876 info_ind := info_ind
Harald Weltee1fd9162019-02-18 19:47:53 +0100877 }
878}
Harald Welted378a252018-03-13 17:02:14 +0100879template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?,
880 template PCUIF_Flags flags := ?,
Vadim Yanitskiyc1559302020-07-19 16:39:12 +0700881 template uint32_t version := mp_pcuif_version) := {
Harald Welted378a252018-03-13 17:02:14 +0100882 msg_type := PCU_IF_MSG_INFO_IND,
883 bts_nr := bts_nr,
884 spare := ?,
885 u := {
886 info_ind := {
887 version := version,
888 flags := flags,
889 trx := ?,
890 bsic := ?,
891 mcc := ?,
892 mnc :=?,
Harald Welte3568dc72018-03-13 17:06:51 +0100893 mnc_3_digits := ?,
Harald Welted378a252018-03-13 17:02:14 +0100894 lac := ?,
895 rac := ?,
896 nsei := ?,
897 nse_timer := ?,
898 cell_timer := ?,
899 cell_id := ?,
900 repeat_time := ?,
901 repeat_count := ?,
902 bvci := ?,
903 t3142 := ?,
904 t3169 := ?,
905 t3191 := ?,
906 t3193_10ms := ?,
907 t3195 := ?,
908 t3101 := ?,
909 t3103 := ?,
910 t3105 := ?,
911 cv_countdown := ?,
912 dl_tbf_ext := ?,
913 ul_tbf_ext := ?,
914 initial_cs := ?,
915 initial_mcs := ?,
916 nsvci := ?,
Vadim Yanitskiy0d590802020-08-21 00:14:22 +0700917 local_port := ?,
Harald Welted378a252018-03-13 17:02:14 +0100918 remote_port := ?,
Alexander Couzens1e5dc482020-07-28 15:38:46 +0200919 remote_addr := ?
Harald Welted378a252018-03-13 17:02:14 +0100920 }
921 }
922}
923
Harald Weltea3219812019-03-02 00:02:28 +0100924template (value) PCUIF_Message ts_PCUIF_TIME_IND(template (value) uint8_t bts_nr,
925 template (value) uint32_t fn) := {
926 msg_type := PCU_IF_MSG_TIME_IND,
927 bts_nr := bts_nr,
928 spare := '0000'O,
929 u := {
930 time_ind := {
931 fn := fn
932 }
933 }
934}
935template PCUIF_Message tr_PCUIF_TIME_IND(template uint8_t bts_nr,
936 template uint32_t fn) := {
937 msg_type := PCU_IF_MSG_TIME_IND,
938 bts_nr := bts_nr,
939 spare := ?,
940 u := {
941 time_ind := {
942 fn := fn
943 }
944 }
945}
Harald Welte883340c2018-02-28 18:59:29 +0100946
Harald Welte4bff40a2019-03-21 21:34:10 +0100947template (value) PCUIF_Message ts_PCUIF_SUSP_REQ(template (value) uint8_t bts_nr,
948 template (value) OCT4 tlli,
949 template (value) OCT6 ra_id,
950 template (value) uint8_t cause) := {
951 msg_type := PCU_IF_MSG_SUSP_REQ,
952 bts_nr := bts_nr,
953 spare := '0000'O,
954 u := {
955 susp_req := {
956 tlli := tlli,
957 ra_id := ra_id,
958 cause := cause
959 }
960 }
961}
962template PCUIF_Message tr_PCUIF_SUSP_REQ(template uint8_t bts_nr,
963 template OCT4 tlli,
964 template OCT6 ra_id,
965 template uint8_t cause) := {
966 msg_type := PCU_IF_MSG_SUSP_REQ,
967 bts_nr := bts_nr,
968 spare := '0000'O,
969 u := {
970 susp_req := {
971 tlli := tlli,
972 ra_id := ra_id,
973 cause := cause
974 }
975 }
976}
977
Harald Welte11b734c2019-09-05 14:17:54 +0200978template (value) PCUIF_Message ts_PCUIF_APP_INFO_REQ(template (value) uint8_t bts_nr,
979 template (value) uint8_t app_type,
980 template (value) octetstring app_data) := {
981 msg_type := PCU_IF_MSG_APP_INFO_REQ,
982 bts_nr := bts_nr,
983 spare := '0000'O,
984 u := {
985 app_info_req := {
986 application_type := app_type,
987 len := 0, /* overwritten */
988 data := app_data
989 }
990 }
991}
992template (present) PCUIF_Message tr_PCUIF_APP_INFO_REQ(template (present) uint8_t bts_nr,
993 template (present) uint8_t app_type,
994 template (present) octetstring app_data) := {
995 msg_type := PCU_IF_MSG_APP_INFO_REQ,
996 bts_nr := bts_nr,
997 spare := '0000'O,
998 u := {
999 app_info_req := {
1000 application_type := app_type,
1001 len := ?,
1002 data := app_data
1003 }
1004 }
1005}
1006
Harald Welte4bff40a2019-03-21 21:34:10 +01001007
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001008/* TODO: remove this as soon as we drop version 9 support */
Pau Espin Pedrol2aead382020-10-29 20:46:47 +01001009function f_PCUIF_ver_INFO_Trxs(uint16_t base_arfcn)
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001010return PCUIF_InfoTrxs {
1011 if (PCUIF_Types.mp_pcuif_version >= 10) {
Pau Espin Pedrol2aead382020-10-29 20:46:47 +01001012 return valueof(ts_PCUIF_InfoV10Trxs_def(base_arfcn));
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001013 } else {
Pau Espin Pedrol2aead382020-10-29 20:46:47 +01001014 return valueof(ts_PCUIF_InfoV09Trxs_def(base_arfcn));
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001015 }
1016}
1017
Vadim Yanitskiy2f8ee5a2020-10-31 20:15:21 +07001018function f_PCUIF_ver_INFO_PDCHMask_get(in PCUIF_info_ind info, uint8_t trx_nr)
Vadim Yanitskiy2a9acce2020-10-31 20:19:06 +07001019return BIT8 {
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001020 if (PCUIF_Types.mp_pcuif_version >= 10) {
1021 return info.trx.v10[trx_nr].pdch_mask;
1022 } else {
1023 return info.trx.v09[trx_nr].pdch_mask;
1024 }
1025}
1026
Vadim Yanitskiyd5321fb2020-10-31 20:23:47 +07001027function f_PCUIF_ver_INFO_PDCHMask_set(inout PCUIF_info_ind info, BIT8 pdch_mask,
1028 template (present) uint8_t trx_nr := ?)
1029{
1030 if (PCUIF_Types.mp_pcuif_version >= 10) {
1031 for (var integer nr := 0; nr < lengthof(info.trx.v10); nr := nr + 1) {
1032 if (match(nr, trx_nr)) {
1033 info.trx.v10[nr].pdch_mask := pdch_mask;
1034 }
1035 }
1036 } else {
1037 for (var integer nr := 0; nr < lengthof(info.trx.v09); nr := nr + 1) {
1038 if (match(nr, trx_nr)) {
1039 info.trx.v09[nr].pdch_mask := pdch_mask;
1040 }
1041 }
1042 }
1043}
1044
Alexander Couzense0f7c542020-09-13 17:25:18 +02001045function f_PCUIF_AF2addr_type(AddressFamily address_family)
1046return PCUIF_AddrType {
1047 if (address_family == AF_INET) {
1048 return PCUIF_ADDR_TYPE_IPV4;
1049 } else if (address_family == AF_INET6) {
1050 return PCUIF_ADDR_TYPE_IPV6;
1051 } else {
1052 return PCUIF_ADDR_TYPE_UNSPEC;
1053 }
1054}
1055
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001056/* TODO: second (redundant) NSVC connection is not (yet) supported */
1057function f_PCUIF_ver_INFO_RemoteAddr(PCUIF_AddrType addr_type,
1058 charstring addr)
1059return PCUIF_RemoteAddr {
1060 var PCUIF_RemoteAddr remote_addr;
1061
1062 if (PCUIF_Types.mp_pcuif_version >= 10) {
1063 remote_addr.v10.addr_type[0] := addr_type;
1064 if (addr_type == PCUIF_ADDR_TYPE_IPV4) {
1065 remote_addr.v10.addr[0] := f_inet_addr(addr);
1066 } else {
1067 remote_addr.v10.addr[0] := f_inet6_addr(addr);
1068 }
1069 remote_addr.v10.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC;
1070 remote_addr.v10.addr[1] := f_pad_oct(''O, 16, '00'O);
1071 } else {
1072 if (addr_type != PCUIF_ADDR_TYPE_IPV4) {
1073 testcase.stop("NSVC address type := ", addr_type,
1074 "is not supported in version := ",
1075 PCUIF_Types.mp_pcuif_version);
1076 }
1077 /* v9 requires the IP in host byte order */
1078 remote_addr.v09.addr[0] := f_inet_haddr(addr);
Alexander Couzensefca79d2020-09-16 04:57:47 +02001079 remote_addr.v09.addr[1] := f_pad_oct(''O, 4, '00'O);
Alexander Couzens1e5dc482020-07-28 15:38:46 +02001080 }
1081
1082 return remote_addr;
1083}
1084
Vadim Yanitskiy9e1206c2020-07-19 15:52:31 +07001085
Harald Welte883340c2018-02-28 18:59:29 +01001086} with { encode "RAW" variant "BYTEORDER(first)" };