msc: Expect CommonID from MSC by default

As of osmo-msc Change-Id I2552736477663adb250c55728093500e8ae83ebb,
osmo-msc is always sending BSSMAP CommonID to the BSC.  Let's adjust our
test expectation, while allowing the user to start the tests with
BSC_ConnectionHandler.mp_expect_common_id := false
to get the existing behavior (expect no bSSMAP CommonId) can be
restored, e.g. for testing 'latest'.

Change-Id: I4976d9bb1f07c8ab4ffa02848414f8ddd1bdfd3f
Related: OS#2969
diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index cc69a68..053a5f6 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -61,6 +61,10 @@
 
 import from TCCConversion_Functions { function f_strstr };
 
+modulepar {
+	boolean mp_expect_common_id := true;
+}
+
 /* this component represents a single subscriber connection */
 type component BSC_ConnHdlr extends RAN_ConnHdlr, MNCC_ConnHdlr, GSUP_ConnHdlr, MGCP_ConnHdlr, SMPP_ConnHdlr, CTRL_Adapter_CT, SGsAP_ConnHdlr {
 	var BSC_ConnHdlrPars g_pars;
@@ -519,6 +523,17 @@
 	}
 }
 
+function f_expect_common_id() runs on BSC_ConnHdlr
+{
+	if (g_pars.ran_is_geran) {
+		if (mp_expect_common_id) {
+			BSSAP.receive(tr_BSSMAP_CommonId(g_pars.imsi));
+		}
+	} else {
+		BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
+	}
+}
+
 function f_mm_common() runs on BSC_ConnHdlr
 {
 	f_mm_auth();
@@ -539,6 +554,7 @@
 			}
 			/* FIXME: Send the best available algorithm */
 		}
+		f_expect_common_id();
 	} else { /* UTRAN */
 		alt {
 		[g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(uia_algs := ?,
@@ -549,7 +565,7 @@
 			var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1*/
 			var EncryptionAlgorithm uea_chosen := 1; /*standard_UMTS_encryption_algorith_UEA1*/
 			BSSAP.send(ts_RANAP_SecurityModeCompleteEnc(uia_chosen, uea_chosen));
-			BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
+			f_expect_common_id();
 			}
 		[g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(?,?,?,?,?)) {
 			setverdict(fail, "Invalid SecurityModeCommand (ciphering case)");
@@ -560,7 +576,7 @@
 										    key_sts := ?)) {
 			var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1;*/
 			BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen));
-			BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
+			f_expect_common_id();
 			}
 		[not g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmd(?,?,?)) {
 			setverdict(fail, "Invalid SecurityModeCommand (non-ciphering case)");
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 5497c2d..d668616 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -807,6 +807,7 @@
 
 	/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
 	f_cl3_or_initial_ue(l3_lu);
+	f_expect_common_id();
 
 	/* Send Early Classmark, just for the fun of it */
 	BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
@@ -926,6 +927,7 @@
 	BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI)));
 	BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(overlong_imsi))); /* test for OS#2864 */
 	BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi)));
+	f_expect_common_id();
 
 	/* Expect MSC to do UpdateLocation to HLR; respond to it */
 	GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@@ -3972,6 +3974,7 @@
 		mtc.stop;
 		}
 	}
+	f_expect_common_id();
 
 	/* Expect LU reject from MSC. */
 	alt {
@@ -4008,6 +4011,7 @@
 	/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
 	var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
 	f_cl3_or_initial_ue(l3_lu);
+	f_expect_common_id();
 
 	/* Expect LU reject from MSC. */
 	alt {
@@ -4066,6 +4070,7 @@
 		mtc.stop;
 		}
 	}
+	f_expect_common_id();
 
 	/* TODO: Verify MSC is using the best cipher available! How? */