Change in osmo-ttcn3-hacks[master]: CTRL: Introduce support to run osmocom CTRL server

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/.

pespin gerrit-no-reply at lists.osmocom.org
Fri Jan 8 13:46:45 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22012 )

Change subject: CTRL: Introduce support to run osmocom CTRL server
......................................................................

CTRL: Introduce support to run osmocom CTRL server

Change-Id: I37db9962f51baf2c63bd58ec47ec89f773d7a255
---
M bsc-nat/BSCNAT_Tests.ttcn
M bsc/BSC_Tests.ttcn
M bts/BTS_Tests.ttcn
M hlr/HLR_Tests.ttcn
M library/Osmocom_CTRL_Adapter.ttcn
M library/Osmocom_CTRL_Functions.ttcn
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
M sip/SIP_Tests.ttcn
9 files changed, 60 insertions(+), 22 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/bsc-nat/BSCNAT_Tests.ttcn b/bsc-nat/BSCNAT_Tests.ttcn
index 41d58d7..1b24855 100644
--- a/bsc-nat/BSCNAT_Tests.ttcn
+++ b/bsc-nat/BSCNAT_Tests.ttcn
@@ -151,7 +151,7 @@
 
 	f_init_vty("VirtBSCNAT");
 	f_vty_allow_osmux(use_osmux);
-	f_ipa_ctrl_start(mp_nat_ip, mp_nat_ctrl_port);
+	f_ipa_ctrl_start_client(mp_nat_ip, mp_nat_ctrl_port);
 
 	for (i := 0; i < NUM_MSC; i := i+1) {
 		f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index a1fa4dd..2c02e36 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1103,7 +1103,7 @@
 	/* start the test with exactly all enabled MSCs allowed to attach */
 	f_vty_msc_allow_attach(BSCVTY, allow_attach);
 
-	f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
+	f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
 
 	f_init_mgcp("VirtMSC");
 
@@ -3080,7 +3080,7 @@
 	bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
 	bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
 
-	f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
+	f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
 
 	f_init_mgcp("VirtMSC");
 
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 16e3d71..c843032 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -547,7 +547,7 @@
 	f_init_rsl(id);
 	f_sleep(0.5);	/* workaround for OS#3000 */
 	f_init_vty(id);
-	f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port);
+	f_ipa_ctrl_start_client(mp_ctrl_ip, mp_ctrl_port);
 
 	/* Send SI3 to the BTS, it is needed for various computations */
 	f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default);
@@ -5376,7 +5376,7 @@
 
 	/* re-connect CTRL port from BTS to BSC */
 	f_ipa_ctrl_stop();
-	f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
+	f_ipa_ctrl_start_client(mp_bsc_ctrl_ip, mp_bsc_ctrl_port);
 
 	/* Send that OML Alert */
 	PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename())));
diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 36e28b8..ea450b3 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -245,7 +245,7 @@
 		f_init_gsup_server("HLR_Test");
 	}
 
-	f_ipa_ctrl_start(mp_hlr_ip, mp_hlr_ctrl_port);
+	f_ipa_ctrl_start_client(mp_hlr_ip, mp_hlr_ctrl_port);
 }
 
 /*! Start HLR_ConnHdlr from testCT in a separate thread.
diff --git a/library/Osmocom_CTRL_Adapter.ttcn b/library/Osmocom_CTRL_Adapter.ttcn
index 0be3ebb..fefff8b 100644
--- a/library/Osmocom_CTRL_Adapter.ttcn
+++ b/library/Osmocom_CTRL_Adapter.ttcn
@@ -26,12 +26,24 @@
 	port IPA_CTRL_PT IPA_CTRL;
 }
 
-
-/*! Start the CTRL connection to the specified BSC IP+Port */
-function f_ipa_ctrl_start(charstring bsc_host, PortNumber bsc_port)
+/* wait for IPA CTRL link to connect and send UP */
+function f_ipa_ctrl_wait_link_up()
 runs on CTRL_Adapter_CT {
-	var charstring id := "IPA-CTRL"
 	timer T := 10.0;
+	T.start;
+	alt {
+	[] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { }
+	[] T.timeout {
+		setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP");
+		mtc.stop;
+		}
+	}
+}
+
+/*! Start the CTRL client connection to the specified CTRL IP+Port server*/
+function f_ipa_ctrl_start_client(charstring bsc_host, PortNumber bsc_port)
+runs on CTRL_Adapter_CT {
+	var charstring id := "IPA-CTRL-CLI"
 
 	vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA");
 
@@ -41,15 +53,21 @@
 	vc_CTRL_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 0,
 						    c_IPA_default_ccm_pars, false));
 
-	/* wait for IPA CTRL link to connect and send UP */
-	T.start;
-	alt {
-	[] IPA_CTRL.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { }
-	[] T.timeout {
-		setverdict(fail, "Timeout CTRL waiting for ASP_IPA_EVENT_UP");
-		mtc.stop;
-		}
-	}
+	f_ipa_ctrl_wait_link_up();
+}
+
+/*! Start the CTRL server on the specified CTRL IP+Port */
+function f_ipa_ctrl_start_server(charstring listen_host, PortNumber listen_port)
+runs on CTRL_Adapter_CT {
+	var charstring id := "IPA-CTRL-SRV"
+	timer T := 10.0;
+
+	vc_CTRL_IPA := IPA_Emulation_CT.create(id & "-IPA");
+
+	map(vc_CTRL_IPA:IPA_PORT, system:IPA_CODEC_PT);
+	connect(vc_CTRL_IPA:IPA_CTRL_PORT, self:IPA_CTRL);
+
+	vc_CTRL_IPA.start(IPA_Emulation.main_server(listen_host, listen_port, false));
 }
 
 function f_ipa_ctrl_stop() runs on CTRL_Adapter_CT {
diff --git a/library/Osmocom_CTRL_Functions.ttcn b/library/Osmocom_CTRL_Functions.ttcn
index d26dc89..294fe33 100644
--- a/library/Osmocom_CTRL_Functions.ttcn
+++ b/library/Osmocom_CTRL_Functions.ttcn
@@ -117,6 +117,26 @@
 		return rx.cmd.val;
 	}
 
+	/* Expect a matching SET, optionally answer */
+	function f_ctrl_exp_get(IPA_CTRL_PT pt, template CtrlVariable variable,
+				 template (omit) CtrlValue rsp := omit,
+				 float timeout_val := 2.0) {
+		timer T := timeout_val;
+		var CtrlMessage rx;
+		T.start;
+		alt {
+		[] pt.receive(tr_CtrlMsgGet(?, variable)) -> value rx {
+			if (ispresent(rsp)) {
+				pt.send(ts_CtrlMsgGetRepl(rx.cmd.id, valueof(variable), valueof(rsp)));
+			}
+			}
+		[] T.timeout {
+			setverdict(fail, "Timeout waiting for GET ", variable);
+			mtc.stop;
+			}
+		}
+	}
+
 	/* Expect a matching GET result */
 	function f_ctrl_get_exp(IPA_CTRL_PT pt, CtrlVariable variable, template CtrlValue exp) {
 		var charstring ctrl_resp;
diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 6ea4f86..3996a87 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -182,7 +182,7 @@
 	}
 
 	if (g_pars.ipa_ctrl_enable == true) {
-		f_ipa_ctrl_start(g_pars.ipa_ctrl_ip, g_pars.ipa_ctrl_port);
+		f_ipa_ctrl_start_client(g_pars.ipa_ctrl_ip, g_pars.ipa_ctrl_port);
 	}
 
 	map(self:MSCVTY, system:MSCVTY);
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 5129c5b..e6681bb 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -318,7 +318,7 @@
 		}
 	}
 
-	f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port);
+	f_ipa_ctrl_start_client(mp_msc_ip, mp_msc_ctrl_port);
 	f_init_mncc("MSC_Test");
 	f_init_mgcp("MSC_Test");
 
diff --git a/sip/SIP_Tests.ttcn b/sip/SIP_Tests.ttcn
index 053395e..37c158e 100644
--- a/sip/SIP_Tests.ttcn
+++ b/sip/SIP_Tests.ttcn
@@ -134,7 +134,7 @@
 }
 
 function f_init() runs on test_CT {
-	//f_ipa_ctrl_start(mp_osmosip_host, mp_osmosip_port_ctrl);
+	//f_ipa_ctrl_start_client(mp_osmosip_host, mp_osmosip_port_ctrl);
 	f_init_mncc("SIP_Test");
 	log("end of f_init_mncc");
 	f_init_sip(vc_SIP, "SIP_Test");

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/22012
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I37db9962f51baf2c63bd58ec47ec89f773d7a255
Gerrit-Change-Number: 22012
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210108/f435fa8e/attachment.htm>


More information about the gerrit-log mailing list