msc: add f_tc_invalid_mgcp_crash

Make sure that osmo-msc doesn't crash if a successful CRCX response contains an
invalid IP address.

Originally/recently, osmo-msc did not validate the IP addresses at all. In an
intermediate patch I added error handling, releasing the call. That uncovered a
use-after-free problem in libosmo-mgcp-client. This problem is fixed by
osmo_fsm_set_dealloc_ctx() and an osmo-mgw fix (see
I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3 in osmo-mgw).

Add this test to make sure the crash is not re-introduced.

Change-Id: I0c76b0a7a33a96a39a242ecd387ba3769161cf7a
diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index a1c8bd3..0846c04 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -711,6 +711,7 @@
 							   (f_mt_call and f_mt_call) */
 	boolean stop_after_cc_setup,			/* Special case: stop call establish after CC Setup */
 	boolean ran_clear_when_alerting,		/* Special case: send Clear upon CC Alerting */
+	boolean expect_release,				/* Special case: expect call establish to cause direct CC Rel */
 
 	MgcpCallId mgcp_call_id optional,		/* MGCP Call ID; CallAgent allocated */
 	MgcpEndpoint mgcp_ep optional			/* MGCP Endpoint, CallAgent or MGW allocated */,
@@ -749,6 +750,7 @@
 	mgw_drop_dlcx := false,
 	stop_after_cc_setup := false,
 	ran_clear_when_alerting := false,
+	expect_release := false,
 	mgcp_call_id := omit,
 	mgcp_ep := "rtpbridge/1@mgw",
 	use_osmux := false,
@@ -1210,6 +1212,8 @@
 		tr_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_conn_1.mgw_rtp_ip), ?);
 
 	var default mdcx := activate(as_optional_mgcp_mdcx(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_port));
+	var boolean got_mncc_setup_compl_ind := false;
+	var boolean got_cc_connect := false;
 
 	interleave {
 	[] MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc {
@@ -1347,15 +1351,27 @@
 
 	[] MNCC.receive(tr_MNCC_SETUP_COMPL_ind(?)) -> value mncc {
 		log("f_mo_call_establish 8: rx MNCC SETUP COMPLETE ind");
+		got_mncc_setup_compl_ind := true;
+		if (not cpars.expect_release and got_cc_connect) {
+			break;
+		}
 		}
 
 	[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CONNECT(cpars.transaction_id))) {
 		log("f_mo_call_establish 10: rx CC CONNECT");
 		BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT_ACK(cpars.transaction_id)));
+		got_cc_connect := true;
+		if (not cpars.expect_release and got_mncc_setup_compl_ind) {
+			break;
+		}
 		}
 
 	[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) {
 		log("f_mo_call_establish 11: rx CC RELEASE");
+		if (not cpars.expect_release) {
+			setverdict(fail, "Got unexpected CC Release");
+			mtc.stop;
+		}
 		f_expect_clear();
 		break;
 		}