bsc: add new testcase TC_srvcc_eutran_to_geran_a5_3

According to 3GPP TS 44.018, section 9.1.15, the RR Handover Command
message may optionally contain the Cipher Mode Setting IE (10.5.2.9).
Section 9.1.15.10 states that this IE may be omitted in case of the
intra-RAT GERAN-to-GERAN handover, however in case of the inter-RAT
handover (e.g. EUTRAN-to-GERAN), this IE *shall* always be included.

In f_ho_into_this_bsc(), check presence and correctness of the Cipher
Mode Setting IE.  Add TC_srvcc_eutran_to_geran_a5_3, which is similar
to TC_srvcc_eutran_to_geran, but enables ciphering on the target channel.

This patch makes all SRVCC relates test cases fail, until [1] is merged.

Change-Id: Ic3dfc4e31a7ed078cdfdaced9986ee9551c5aa7c
Related: [1] osmo-bsc.git I1d270e82d0a9b12897fc94dae4e8999aa132a22f
Related: SYS#5838
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 8f70452..758b989 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -6115,6 +6115,26 @@
 		log("handoverCommand: verified TSC = ", got_tsc);
 	}
 
+	/* Check the Cipher Mode Setting IE (shall be present during inter-RAT handover) */
+	if (ispresent(ho_command.msgs.rrm.handoverCommand.cipherModeSetting)) {
+		var CipherModeSetting_TV cms := ho_command.msgs.rrm.handoverCommand.cipherModeSetting;
+		var template (present) CipherModeSetting_TV tr_cms := {
+			sC := '0'B, /* no ciphering by default */
+			algorithmIdentifier := '000'B,
+			elementIdentifier := ?
+		};
+		if (ispresent(g_pars.encr) and g_pars.encr.enc_alg_expect != '01'O) { /* A5/N */
+			tr_cms.algorithmIdentifier := f_cipher_mode_bssmap_to_rr(g_pars.encr.enc_alg_expect);
+			tr_cms.sC := '1'B;
+		}
+		if (not match(cms, tr_cms)) {
+			setverdict(fail, "RR Handover Command: unexpected Cipher Mode Setting IE: ",
+				   cms, ", expected: ", tr_cms);
+		}
+	} else {
+		setverdict(fail, "RR Handover Command: Cipher Mode Setting IE is not present");
+	}
+
 	/* Now the MSC forwards the RR Handover Command to the other BSC, which
 	 * tells the MS to handover to the new lchan. Here comes the new MS on
 	 * the new lchan with a Handover RACH: */
@@ -6260,6 +6280,20 @@
 	f_shutdown_helper();
 }
 
+/* Same as TC_srvcc_eutran_to_geran, but enables ciphering on the target channel. */
+testcase TC_srvcc_eutran_to_geran_a5_3() runs on test_CT {
+	var TestHdlrParams pars := f_gen_test_hdlr_pars();
+	pars.encr := f_encr_params('08'O); /* only A5/3 */
+	pars.last_used_eutran_plmn := '323454'O;
+	pars.exp_fast_return := true;
+	f_tc_ho_into_this_bsc_main(pars);
+
+	f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
+	f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
+	f_ctrs_bsc_and_bts_verify();
+	f_shutdown_helper();
+}
+
 /* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
    on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
    list when the channel is released. */
@@ -11367,6 +11401,7 @@
 		execute( TC_ho_into_this_bsc_tla_v6() );
 	}
 	execute( TC_srvcc_eutran_to_geran() );
+	execute( TC_srvcc_eutran_to_geran_a5_3() );
 	execute( TC_srvcc_eutran_to_geran_src_sai() );
 	execute( TC_srvcc_eutran_to_geran_ho_out() );
 	execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
diff --git a/bsc/expected-results.xml b/bsc/expected-results.xml
index f9f022e..572c657 100644
--- a/bsc/expected-results.xml
+++ b/bsc/expected-results.xml
@@ -157,6 +157,7 @@
   <testcase classname='BSC_Tests' name='TC_ho_into_this_bsc_a5_4' time='MASKED'/>
   <testcase classname='BSC_Tests' name='TC_ho_into_this_bsc_tla_v6' time='MASKED'/>
   <testcase classname='BSC_Tests' name='TC_srvcc_eutran_to_geran' time='MASKED'/>
+  <testcase classname='BSC_Tests' name='TC_srvcc_eutran_to_geran_a5_3' time='MASKED'/>
   <testcase classname='BSC_Tests' name='TC_srvcc_eutran_to_geran_ho_out' time='MASKED'/>
   <testcase classname='BSC_Tests' name='TC_srvcc_eutran_to_geran_forbid_fast_return' time='MASKED'/>
   <testcase classname='BSC_Tests' name='TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return' time='MASKED'/>