bsc: Fix TC_rsl_drop_counter due to IPA_Emulation component being alive-type

IPA_Emulation component was marked with the "alive" type recently, in
order to avoid race conditions leading to errors during tear down of the
test.

It turns out, the way "alive" keeps the component alive is by means of
not closing the sockets when the component is stopped. As a result,
TC_rsl_drop_counter test stopped working properly because it was
specting a TCP FIN to be sent to osmo-bsc when the component was
stopped.

In order to fix it, add a new CFG port to the IPA_Emulation component on
which one can operate. Add a a new method to tell the component to close
the socket.

Then, put that in BSC_Tests into a function which was actually unsued
until now, and use it in the test in order to have the specific logic
enclosed in a function helper.

Fixes: 7138913d664c33b2404e3d293ab820fb3516ff73
Change-Id: I68163b053313d9907ba8e40954a5933d14cb7db6
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index c485ec5..7bfc387 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -595,6 +595,8 @@
 	port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
 	/* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
 	port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
+	/* Configure/manage IPA_Emulation: */
+	port IPA_CFG_PT IPA_CFG_PORT;
 
 	var MGCP_Emulation_CT vc_MGCP;
 	port TELNETasp_PT BSCVTY;
@@ -926,6 +928,7 @@
 	}
 
 	map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
+	connect(clnt.vc_IPA:CFG_PORT, self:IPA_CFG_PORT);
 	if (handler_mode) {
 		connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
 	} else {
@@ -955,9 +958,22 @@
 }
 
 function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
+	var IPL4asp_Types.Result res := {
+		errorCode := omit,
+		connId := omit,
+		os_error_code := omit,
+		os_error_text := omit
+	};
+
 	if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
 		return;
 	}
+
+	/* Alive components don't finish sockets (TCP FIN) when they are
+	 * stopped. Hence, we need to manually call close() on them to make sure
+	 * the IUT knows about it. */
+	f_ipa_cfg_disconnect(IPA_CFG_PORT, res);
+
 	clnt.vc_IPA.stop;
 	if (isbound(clnt.vc_RSL)) {
 		clnt.vc_RSL.stop;
@@ -3555,7 +3571,7 @@
 
 	rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
 
-	bts[0].rsl.vc_IPA.stop;
+	f_ipa_rsl_stop(bts[0].rsl);
 
 	f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);