library/PCUIF_Types: version 10: support IPv6 NSVC addr

Change-Id: I13b03c380edc2dc609c5e4053462a3cd6f78ce72
Tweaked-By: Vadim Yanitskiy <vyanitskiy@sysmocom.de>
Related: SYS#4915
This commit is contained in:
Alexander Couzens 2020-07-28 15:38:46 +02:00 committed by lynxis lazus
parent 9e0141aa84
commit 1e5dc48213
5 changed files with 59 additions and 4 deletions

View File

@ -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,

View File

@ -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)" };

View File

@ -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 {

View File

@ -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,

View File

@ -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 "