MSC_Tests: Support wildcarded endpoints

At the moment the testsuite is unable to detect when the call agent
performs a CRCX request with a wildcarded endpoint.

- Set a default endpoint name in cpars in case the MSC does
  a CRCX request with wildcarded endpoint name.

- Detect if the MSC supplied a wildcarded endpoint name. Do
  not overwrite the default setting in cpars then.

- Attach the endpoint name as Z: parameter in the response so
  that the MSC knows which endpoint to use. (Unconditional,
  does not harm on non wildcarded requests)

Change-Id: I0efeae0f8a6e98deb843e79648f84a262f1d98f8
Related: OS#2710
diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 1189112..48da793 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -444,8 +444,14 @@
 	/* First MGCP CRCX (for BSS/RAN side) */
 	MGCP.receive(tr_CRCX) -> value mgcp_cmd {
 		cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
-		/* TODO: dynamic EP allocation case */
-		cpars.mgcp_ep := mgcp_cmd.line.ep;
+
+		/* When the endpoint contains a wildcard we keep the endpoint
+		 * identifier we have set up in cpars. Otherwise we use the
+		 * endpoint name that the call agent has supplied */
+		if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard) == false) {
+			cpars.mgcp_ep := mgcp_cmd.line.ep;
+		}
+
 		var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_rtp_ip_bss, cpars.mgw_rtp_ip_bss,
 							hex2str(cpars.mgcp_call_id), "42",
 							cpars.mgw_rtp_port_bss,
@@ -453,7 +459,10 @@
 							{ valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
 										cpars.rtp_sdp_format)),
 							  valueof(ts_SDP_ptime(20)) }));
-		MGCP.send(ts_CRCX_ACK(mgcp_cmd.line.trans_id, cpars.mgcp_connection_id_bss, sdp));
+		var template MgcpResponse mgcp_resp;
+		mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, cpars.mgcp_connection_id_bss, sdp);
+		f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(cpars.mgcp_ep));
+		MGCP.send(mgcp_resp);
 		}
 	/* Second MGCP CRCX (this time for MSS/CN side) */
 	MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd {
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 159538c..e7ee9e7 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -1604,6 +1604,10 @@
 	cpars.mgcp_connection_id_bss := '10004'H;
 	cpars.mgcp_connection_id_mss := '10005'H;
 
+	/* Note: This is an optional parameter. When the call-agent (MSC) does
+	 * supply a full endpoint name this setting will be overwritten. */
+	cpars.mgcp_ep := "rtpbridge/1@mgw";
+
 	f_perform_lu();
 	f_mt_call(cpars);
 }