From 5e8573e9b79d512e75a5e53a667d0e0477b39e27 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 13 Sep 2020 15:32:56 +0200 Subject: NS_Emulation: Prepare NSConfiguration for non-IP providers NSConfiguration currently contains parameters relevant only for IP based transport. Move IP/UDP parameters into a sub-structure in anticipation of Frame Relay support. Change-Id: I6904520d8c2f546327029777d68b1907611a8cf5 --- library/NS_Emulation.ttcn | 17 ++++++++++++----- library/NS_Provider_IPL4.ttcn | 10 +++++----- library/RAW_NS.ttcn | 9 +++++---- 3 files changed, 22 insertions(+), 14 deletions(-) (limited to 'library') diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcn index 97a48e54..a0b24c9c 100644 --- a/library/NS_Emulation.ttcn +++ b/library/NS_Emulation.ttcn @@ -131,12 +131,18 @@ module NS_Emulation { timer Tns_block := 10.0; } - type record NSConfiguration { + type record NSConfigurationIP { AddressFamily address_family, PortNumber local_udp_port, charstring local_ip, PortNumber remote_udp_port, - charstring remote_ip, + charstring remote_ip + }; + type union NSConfigurationP { + NSConfigurationIP ip + }; + type record NSConfiguration { + NSConfigurationP provider, Nsvci nsvci, Nsvci nsei, boolean role_sgsn, @@ -216,7 +222,7 @@ module NS_Emulation { /* FIXME */ } - [config.role_sgsn and config.handle_sns] as_sns_sgsn(); + [config.role_sgsn and config.handle_sns and ischosen(config.provider.ip)] as_sns_sgsn(); /* default case of handling unknown PDUs */ [] NSCP.receive(PDU_NS: ?) -> value rf { @@ -238,11 +244,12 @@ module NS_Emulation { self.stop; } [] NSCP.receive(tr_SNS_CONFIG(config.nsei, true, - {tr_SNS_IPv4(config.remote_ip, config.remote_udp_port)})) -> value rf { + {tr_SNS_IPv4(config.provider.ip.remote_ip, + config.provider.ip.remote_udp_port)})) -> value rf { /* blindly acknowledge whatever the PCU sends */ NSCP.send(ts_SNS_CONFIG_ACK(config.nsei, omit)); /* send a SNS-CONFIG in response and expect a SNS-CONFIG-ACK */ - var IP4_Elements v4 := { valueof(ts_SNS_IPv4(config.local_ip, config.local_udp_port)) }; + var IP4_Elements v4 := { valueof(ts_SNS_IPv4(config.provider.ip.local_ip, config.provider.ip.local_udp_port)) }; NSCP.send(ts_SNS_CONFIG(config.nsei, true, v4)); alt { [] NSCP.receive(tr_SNS_CONFIG_ACK(config.nsei, omit)) { diff --git a/library/NS_Provider_IPL4.ttcn b/library/NS_Provider_IPL4.ttcn index 8ab8caac..14149350 100644 --- a/library/NS_Provider_IPL4.ttcn +++ b/library/NS_Provider_IPL4.ttcn @@ -27,12 +27,12 @@ function main(NSConfiguration config) runs on NS_Provider_IPL4_CT { /* connect socket */ map(self:IPL4, system:IPL4); - var Result res := f_IPL4_connect(IPL4, config.remote_ip, config.remote_udp_port, config.local_ip, - config.local_udp_port, 0, { udp := {}}); + var Result res := f_IPL4_connect(IPL4, config.provider.ip.remote_ip, + config.provider.ip.remote_udp_port, + config.provider.ip.local_ip, + config.provider.ip.local_udp_port, 0, { udp := {}}); if (not ispresent(res.connId)) { - setverdict(fail, "Could not connect NS UDP socket from " & - config.local_ip & ":" & int2str(config.local_udp_port) & - " to " & config.remote_ip & ":" & int2str(config.remote_udp_port)); + setverdict(fail, "Could not connect NS UDP socket ", config.provider.ip); mtc.stop; } g_conn_id := res.connId; diff --git a/library/RAW_NS.ttcn b/library/RAW_NS.ttcn index d02f4ca9..dca352f2 100644 --- a/library/RAW_NS.ttcn +++ b/library/RAW_NS.ttcn @@ -50,14 +50,15 @@ function f_init_ns_codec(NSConfiguration ns_config, integer idx := 0, float guar g_nsconfig[idx] := ns_config; /* adjust those parts different for each NS-VC */ g_nsconfig[idx].nsvci := ns_config.nsvci + idx; - g_nsconfig[idx].local_udp_port := ns_config.local_udp_port + idx + tc_offset; + g_nsconfig[idx].provider.ip.local_udp_port := ns_config.provider.ip.local_udp_port + idx + tc_offset; } map(self:NSCP[idx], system:NSCP); /* Connect the UDP socket */ - log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]); - res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port, - g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}}); + var NSConfiguration nscfg := g_nsconfig[idx]; + log("connecting NSCP[", idx, "] to ", nscfg); + res := f_IPL4_connect(NSCP[idx], nscfg.provider.ip.remote_ip, nscfg.provider.ip.remote_udp_port, + nscfg.provider.ip.local_ip, nscfg.provider.ip.local_udp_port, 0, { udp := {}}); if (not ispresent(res.connId)) { setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]); mtc.stop; -- cgit v1.2.3