Change in osmo-ttcn3-hacks[master]: NS_Emulation: support multiple instances at the same time

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Aug 13 16:23:51 UTC 2018


lynxis lazus has submitted this change and it was merged. ( https://gerrit.osmocom.org/10376 )

Change subject: NS_Emulation: support multiple instances at the same time
......................................................................

NS_Emulation: support multiple instances at the same time

The NS_Emulation has configuration values hardcoded or bound
to module parameters which prevents multiple instances.
Replace the module parameter based configuration with configuration
given when starting the NS_Emaulation.

Change-Id: I9128f9ad5c372779c38799269393137ba52576cd
---
M library/NS_Emulation.ttcn
M pcu/PCU_Tests.cfg
M pcu/PCU_Tests.ttcn
M sgsn/SGSN_Tests.default
M sgsn/SGSN_Tests.ttcn
5 files changed, 62 insertions(+), 38 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcn
index 01d45b4..7cccb25 100644
--- a/library/NS_Emulation.ttcn
+++ b/library/NS_Emulation.ttcn
@@ -72,7 +72,8 @@
 		out	NsUnitdataRequest;
 	} with { extension "internal" };
 
-	function NSStart() runs on NS_CT {
+	function NSStart(NSConfiguration init_config) runs on NS_CT {
+		config := init_config;
 		f_init();
 		f_ScanEvents();
 	}
@@ -80,7 +81,7 @@
 	private function f_init() runs on NS_CT {
 		var Result res;
 		/* Connect the UDP socket */
-		res := f_IPL4_connect(NSCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {}});
+		res := f_IPL4_connect(NSCP, config.remote_ip, config.remote_udp_port, config.local_ip, config.local_udp_port, 0, { udp := {}});
 		if (not ispresent(res.connId)) {
 			setverdict(fail, "Could not connect NS UDP socket, check your configuration");
 			mtc.stop;
@@ -97,6 +98,8 @@
 		/* NS-User SAP towards the user */
 		port NS_SP_PT NS_SP;
 
+		var NSConfiguration config;
+
 		var NseState		g_state := NSE_S_DEAD_BLOCKED;
 		var ConnectionId	g_conn_id := -1;
 
@@ -105,24 +108,24 @@
 		timer Tns_block := 10.0;
 	}
 
-	modulepar {
-		PortNumber mp_local_udp_port := 23000;
-		charstring mp_local_ip := "127.0.0.1";
-		PortNumber mp_remote_udp_port := 21000;
-		charstring mp_remote_ip := "127.0.0.1";
-		Nsvci mp_nsvci := 0;
-		Nsvci mp_nsei := 2342;
-	};
+	type record NSConfiguration {
+		PortNumber local_udp_port,
+		charstring local_ip,
+		PortNumber remote_udp_port,
+		charstring remote_ip,
+		Nsvci nsvci,
+		Nsvci nsei
+	}
 
 	private function f_change_state(NseState new_state) runs on NS_CT {
 		var NseState old_state := g_state;
 		g_state := new_state;
 		log("NS State Transition: ", old_state, " -> ", new_state);
-		NS_SP.send(t_NsStsInd(mp_nsei, mp_nsvci, old_state, new_state));
+		NS_SP.send(t_NsStsInd(config.nsei, config.nsvci, old_state, new_state));
 	}
 
 	private function f_sendReset() runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, mp_nsvci, mp_nsei)));
+		NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, config.nsvci, config.nsei)));
 		g_state := NSE_S_WAIT_RESET;
 	}
 
@@ -137,7 +140,7 @@
 	}
 
 	private function f_sendBlock(NsCause cause) runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, mp_nsvci)));
+		NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, config.nsvci)));
 		Tns_block.start;
 	}
 
@@ -176,9 +179,9 @@
 		}
 
 		/* Respond to RESET with correct NSEI/NSVCI */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, mp_nsvci, mp_nsei))) -> value rf {
+		[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, config.nsvci, config.nsei))) -> value rf {
 			f_change_state(NSE_S_ALIVE_BLOCKED);
-			NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(mp_nsvci, mp_nsei)));
+			NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(config.nsvci, config.nsei)));
 		}
 
 		/* Respond to RESET with wrong NSEI/NSVCI */
@@ -210,7 +213,7 @@
 			}
 		} else if (g_state == NSE_S_WAIT_RESET) {
 			alt {
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(mp_nsvci, mp_nsei))) -> value rf {
+				[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(config.nsvci, config.nsei))) -> value rf {
 					f_change_state(NSE_S_ALIVE_BLOCKED);
 					f_sendAlive();
 					f_sendUnblock();
@@ -219,8 +222,8 @@
 		} else if (g_state == NSE_S_ALIVE_BLOCKED) {
 			alt {
 				/* bogus block, just respond with ACK */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
+				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
+					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
 				}
 				/* Respond to UNBLOCK with UNBLOCK-ACK + change state */
 				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf {
@@ -244,26 +247,26 @@
 					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK));
 				}
 				/* Respond to BLOCK with BLOCK-ACK + change state */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
+				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
+					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
 					Tns_block.stop;
 					f_change_state(NSE_S_ALIVE_BLOCKED);
 				}
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(mp_nsvci))) -> value rf {
+				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(config.nsvci))) -> value rf {
 					Tns_block.stop;
 				}
 				/* NS-UNITDATA PDU from network to NS-UNITDATA.ind to user */
 				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNITDATA(?, ?, ?))) -> value rf {
-					NS_SP.send(t_NsUdInd(mp_nsei,
+					NS_SP.send(t_NsUdInd(config.nsei,
 							     oct2int(rf.msg.pDU_NS_Unitdata.bVCI),
 							     rf.msg.pDU_NS_Unitdata.nS_SDU));
 				}
 				/* NS-UNITDATA.req from user to NS-UNITDATA PDU on network */
-				[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, ?, omit)) -> value ud_req {
+				[] NS_SP.receive(t_NsUdReq(config.nsei, ?, ?, omit)) -> value ud_req {
 					/* using raw octetstring PDU */
 					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu)));
 				}
-				[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, omit, ?)) -> value ud_req {
+				[] NS_SP.receive(t_NsUdReq(config.nsei, ?, omit, ?)) -> value ud_req {
 					/* using decoded BSSGP PDU that we need to encode first */
 					var octetstring enc := enc_PDU_BSSGP(ud_req.bssgp);
 					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc)));
diff --git a/pcu/PCU_Tests.cfg b/pcu/PCU_Tests.cfg
index 20de54c..7e0b9f2 100644
--- a/pcu/PCU_Tests.cfg
+++ b/pcu/PCU_Tests.cfg
@@ -11,12 +11,15 @@
 #mp_local_udp_port := 23000
 #mp_remote_ip := "192.168.100.196"
 #mp_remote_udp_port := 21000
-NS_Emulation.mp_local_ip := "127.0.0.1"
-NS_Emulation.mp_local_udp_port := 23000
-NS_Emulation.mp_remote_ip := "127.0.0.1"
-NS_Emulation.mp_remote_udp_port := 23001
-NS_Emulation.mp_nsei := 1234
-NS_Emulation.mp_nsvci := 1234
+PCU_Tests.mp_nsconfig := {
+	local_ip := "127.0.0.1",
+	local_udp_port := 23000,
+	remote_ip := "127.0.0.1",
+	remote_udp_port := 23001,
+	nsvci := 1234,
+	nsei := 1234
+}
+
 PCU_Tests.mp_gb_cfg := {
 	nsei := 1234,
 	bvci := 1234,
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index dfd380d..d59ac11 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -33,6 +33,15 @@
 			},
 			sgsn_role := true
 		};
+
+		NSConfiguration mp_nsconfig := {
+			local_udp_port := 23000,
+			local_ip := "127.0.0.1",
+			remote_udp_port := 21000,
+			remote_ip := "127.0.0.1",
+			nsvci := 0,
+			nsei := 2342
+		};
 	}
 
 	type component dummy_CT extends BSSGP_Client_CT {
@@ -66,7 +75,7 @@
 		connect(bssgp_component:BSCP, ns_component:NS_SP);
 		/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
 		map(ns_component:NSCP, system:NS_CODEC_PORT);
-		ns_component.start(NSStart());
+		ns_component.start(NSStart(mp_nsconfig));
 		bssgp_component.start(BssgpStart(mp_gb_cfg));
 
 		lapdm_component := lapdm_CT.create;
diff --git a/sgsn/SGSN_Tests.default b/sgsn/SGSN_Tests.default
index 3957e82..82682e2 100644
--- a/sgsn/SGSN_Tests.default
+++ b/sgsn/SGSN_Tests.default
@@ -20,12 +20,12 @@
 
 
 [MODULE_PARAMETERS]
-#NS_Emulation.mp_local_ip := "192.168.100.239"
-NS_Emulation.mp_local_udp_port := 21000
-#NS_Emulation.mp_remote_ip := "192.168.100.196"
-NS_Emulation.mp_remote_udp_port := 23000
-NS_Emulation.mp_nsvci := 97
-NS_Emulation.mp_nsei := 96
+SGSN_Tests.mp_nsconfig := {
+	local_udp_port := 21000,
+	remote_udp_port := 23000,
+	nsvci := 97,
+	nsei := 96
+}
 Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoSGSN";
 
 [MAIN_CONTROLLER]
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 6c94d14..d2db909 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -43,6 +43,15 @@
 	charstring mp_hlr_ip := "127.0.0.1";
 	integer mp_hlr_port := 4222;
 	charstring mp_ggsn_ip := "127.0.0.2";
+
+	NSConfiguration mp_nsconfig := {
+		local_udp_port := 23000,
+		local_ip := "127.0.0.1",
+		remote_udp_port := 21000,
+		remote_ip := "127.0.0.1",
+		nsvci := 0,
+		nsei := 2342
+	};
 };
 
 type record GbInstance {
@@ -106,7 +115,7 @@
 	/* connect lower end of NS emulation to NS codec port (on top of IPL4) */
 	map(gb.vc_NS:NSCP, system:NS_CODEC_PORT);
 
-	gb.vc_NS.start(NSStart());
+	gb.vc_NS.start(NSStart(mp_nsconfig));
 	gb.vc_BSSGP.start(BssgpStart(gb.cfg));
 }
 

-- 
To view, visit https://gerrit.osmocom.org/10376
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9128f9ad5c372779c38799269393137ba52576cd
Gerrit-Change-Number: 10376
Gerrit-PatchSet: 9
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180813/3ebd8c15/attachment.htm>


More information about the gerrit-log mailing list