From 1e5dc48213a7f59512026b4979f7c032f518fed0 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Tue, 28 Jul 2020 15:38:46 +0200 Subject: library/PCUIF_Types: version 10: support IPv6 NSVC addr Change-Id: I13b03c380edc2dc609c5e4053462a3cd6f78ce72 Tweaked-By: Vadim Yanitskiy Related: SYS#4915 --- library/NS_Emulation.ttcn | 2 ++ library/PCUIF_Types.ttcn | 55 +++++++++++++++++++++++++++++++++++++++++++++-- pcu/PCU_Tests.ttcn | 3 ++- pcu/SGSN_Components.ttcn | 1 + sgsn/gen_links.sh | 2 +- 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcn index 697a4821..6f9bc39c 100644 --- a/library/NS_Emulation.ttcn +++ b/library/NS_Emulation.ttcn @@ -16,6 +16,7 @@ module NS_Emulation { import from NS_CodecPort all; import from NS_CodecPort_CtrlFunct all; import from IPL4asp_Types all; + import from PCUIF_Types all; type record NsUnitdataRequest { BssgpBvci bvci, @@ -124,6 +125,7 @@ module NS_Emulation { } type record NSConfiguration { + PCUIF_AddrType remote_proto, PortNumber local_udp_port, charstring local_ip, PortNumber remote_udp_port, diff --git a/library/PCUIF_Types.ttcn b/library/PCUIF_Types.ttcn index f0200af9..b400267c 100644 --- a/library/PCUIF_Types.ttcn +++ b/library/PCUIF_Types.ttcn @@ -13,6 +13,7 @@ module PCUIF_Types { import from General_Types all; import from Osmocom_Types all; +import from Native_Functions all; modulepar { /* PCUIF version supported by the IUT */ @@ -212,13 +213,34 @@ type record PCUIF_info_ind { record length(2) of uint16_t nsvci, record length(2) of uint16_t local_port, record length(2) of uint16_t remote_port, - record length(2) of OCT4 remote_ip + PCUIF_RemoteAddr remote_addr } with { /* NOTE: TITAN is not smart enough to handle 'version < 10' and 'version > 9', * so we cannot support more than two versions at the same time here. Sigh. */ variant (trx) "CROSSTAG(v09, version = 9; v10, version = 10)" + variant (remote_addr) "CROSSTAG(v09, version = 9; v10, version = 10)" }; +type union PCUIF_RemoteAddr { + PCUIF_RemoteAddrV09 v09, + PCUIF_RemoteAddrV10 v10 +} with { variant "" }; + +type record PCUIF_RemoteAddrV09 { + record length(2) of OCT4 addr +} with { variant "" }; + +type enumerated PCUIF_AddrType { + PCUIF_ADDR_TYPE_UNSPEC ('00'O), + PCUIF_ADDR_TYPE_IPV4 ('04'O), + PCUIF_ADDR_TYPE_IPV6 ('29'O) +} with { variant "FIELDLENGTH(8)" }; + +type record PCUIF_RemoteAddrV10 { + record length(2) of PCUIF_AddrType addr_type, + record length(2) of octetstring addr length(16) +} with { variant "" }; + type record PCUIF_act_req { uint8_t is_activate, uint8_t trx_nr, @@ -839,7 +861,7 @@ template PCUIF_Message tr_PCUIF_INFO_IND(template uint8_t bts_nr := ?, nsvci := ?, local_port := ?, remote_port := ?, - remote_ip := ? + remote_addr := ? } } } @@ -947,5 +969,34 @@ return bitstring { } } +/* TODO: second (redundant) NSVC connection is not (yet) supported */ +function f_PCUIF_ver_INFO_RemoteAddr(PCUIF_AddrType addr_type, + charstring addr) +return PCUIF_RemoteAddr { + var PCUIF_RemoteAddr remote_addr; + + if (PCUIF_Types.mp_pcuif_version >= 10) { + remote_addr.v10.addr_type[0] := addr_type; + if (addr_type == PCUIF_ADDR_TYPE_IPV4) { + remote_addr.v10.addr[0] := f_inet_addr(addr); + } else { + remote_addr.v10.addr[0] := f_inet6_addr(addr); + } + remote_addr.v10.addr_type[1] := PCUIF_ADDR_TYPE_UNSPEC; + remote_addr.v10.addr[1] := f_pad_oct(''O, 16, '00'O); + } else { + if (addr_type != PCUIF_ADDR_TYPE_IPV4) { + testcase.stop("NSVC address type := ", addr_type, + "is not supported in version := ", + PCUIF_Types.mp_pcuif_version); + } + /* v9 requires the IP in host byte order */ + remote_addr.v09.addr[0] := f_inet_haddr(addr); + remote_addr.v09.addr[0] := f_pad_oct(''O, 4, '00'O); + } + + return remote_addr; +} + } with { encode "RAW" variant "BYTEORDER(first)" }; diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn index df2964cf..f5176d40 100644 --- a/pcu/PCU_Tests.ttcn +++ b/pcu/PCU_Tests.ttcn @@ -92,7 +92,8 @@ friend template (value) PCUIF_info_ind ts_PCUIF_INFO_default := { nsvci := { mp_nsconfig.nsvci, 0 }, local_port := { mp_nsconfig.remote_udp_port, 0 }, remote_port := { mp_nsconfig.local_udp_port, 0 }, - remote_ip := { f_inet_haddr(mp_nsconfig.local_ip) , '00000000'O } + remote_addr := f_PCUIF_ver_INFO_RemoteAddr( + mp_nsconfig.remote_proto, mp_nsconfig.local_ip) } type record lqual_range { diff --git a/pcu/SGSN_Components.ttcn b/pcu/SGSN_Components.ttcn index 4bbd18ca..7bf8705c 100644 --- a/pcu/SGSN_Components.ttcn +++ b/pcu/SGSN_Components.ttcn @@ -35,6 +35,7 @@ modulepar { }; NSConfiguration mp_nsconfig := { + remote_proto := PCUIF_ADDR_TYPE_IPV4, local_udp_port := 23000, local_ip := "127.0.0.1", remote_udp_port := 21000, diff --git a/sgsn/gen_links.sh b/sgsn/gen_links.sh index bd3a7eaf..541670d6 100755 --- a/sgsn/gen_links.sh +++ b/sgsn/gen_links.sh @@ -84,7 +84,7 @@ gen_links $DIR $FILES DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc " -FILES+="NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc " +FILES+="NS_Emulation.ttcn PCUIF_Types.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc " FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_Types.ttcn " FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn " FILES+="Osmocom_VTY_Functions.ttcn " -- cgit v1.2.3