summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-04 19:01:31 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2021-01-07 15:06:39 +0100
commit9a5b8ffc5bc28bcb57b37b16b36398cf8664a3eb (patch)
tree814f3c5e1a018da7d694e4fc2ee9b3db2fd533cc
parentec2ee466b7ca7a30c560be635825ac43e60a7eb1 (diff)
CTRL: Introduce support to run osmocom CTRL server
-rw-r--r--bsc-nat/BSCNAT_Tests.ttcn2
-rw-r--r--bsc/BSC_Tests.ttcn4
-rw-r--r--bts/BTS_Tests.ttcn4
-rw-r--r--hlr/HLR_Tests.ttcn2
-rw-r--r--library/Osmocom_CTRL_Adapter.ttcn44
-rw-r--r--library/Osmocom_CTRL_Functions.ttcn20
-rw-r--r--msc/BSC_ConnectionHandler.ttcn2
-rw-r--r--msc/MSC_Tests.ttcn2
-rw-r--r--sip/SIP_Tests.ttcn2
9 files changed, 60 insertions, 22 deletions
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 @@ function f_init(void_fn_bsc_ms fn_bsc_ms, void_fn_bsc fn_bsc, BssmapCreateCallba
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 @@ function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolea
/* 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 @@ function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return b
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 @@ runs on test_CT
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 @@ testcase TC_pcu_oml_alert() runs on test_CT {
/* 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 @@ function f_init(boolean legacy := true, boolean gsup_server := false) runs on te
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 @@ type component CTRL_Adapter_CT {
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 @@ runs on CTRL_Adapter_CT {
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 @@ module Osmocom_CTRL_Functions {
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 @@ function f_init_handler(BSC_ConnHdlrPars pars, float t_guard := 60.0) runs on BS
}
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 @@ function f_init(integer num_bsc := 1, boolean sgsap := false, boolean gsup := tr
}
}
- 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_mncc(charstring id) runs on test_CT {
}
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");