BSC_Tests: introduce TC_tch_dlci_link_id_sapi for OS#3716

The aim of this test case is to verify DLCI / RSL Link ID conversion
for MO/MT L3 messages on SAPI0/SAPI3.  In particular, the test suite
verifies the following scenarios:

  - RSL -> BSSAP:
    - 16 MO messages on FACCH/F with SAPI0,
    - 16 MO messages on SACCH/F with SAPI3;
  - BSSAP -> RSL:
    - 16 MT messages on FACCH/F with SAPI0,
    - 16 MT messages on SACCH/F with SAPI3.

Change-Id: Ica69ae95b47a67ba99ba9cc36629b6bd210d11e4
Related: OS#3716
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 0632852..20fcf36 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -2024,6 +2024,62 @@
 	f_shutdown_helper();
 }
 
+/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
+private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
+	var template PDU_BSSAP exp_compl := f_gen_exp_compl();
+	var PDU_BSSAP ass_cmd := f_gen_ass_req();
+
+	ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
+	ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
+
+	f_establish_fully(ass_cmd, exp_compl);
+
+	/* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
+	RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
+	/* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
+	BSSAP.receive(PDU_BSSAP:{
+		discriminator := '1'B,
+		spare := '0000000'B,
+		dlci := 'C3'O,
+		lengthIndicator := ?,
+		pdu := { dtap := '0904'O }
+	});
+
+	/* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
+	for (var integer i := 0; i < 32; i := i + 1) {
+		var octetstring l3 := '09'O & f_rnd_octstring(14);
+		var template (value) RslLinkId link_id;
+		var template (value) OCT1 dlci;
+
+		if (i mod 2 == 0) {
+			/* SAPI0 on FACCH or SDCCH */
+			link_id := ts_RslLinkID_DCCH(0);
+			dlci := '80'O;
+		} else {
+			/* SAPI3 on SACCH */
+			link_id := ts_RslLinkID_SACCH(3);
+			dlci := 'C3'O;
+		}
+
+		/* Send MO message: RSL -> BSSAP */
+		f_mo_l3_transceive(link_id, dlci, l3);
+		/* Send MT message: BSSAP -> RSL */
+		f_mt_l3_transceive(link_id, dlci, l3);
+	}
+}
+testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
+	var TestHdlrParams pars := f_gen_test_hdlr_pars();
+	var MSC_ConnHdlr vc_conn;
+
+	f_init(1, true);
+	f_sleep(1.0);
+
+	vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
+	vc_conn.done;
+
+	f_shutdown_helper();
+}
+
 private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
 				     template myBSSMAP_Cause cause := ?,
 				     float T_val := 2.0)
@@ -7624,6 +7680,9 @@
 	execute( TC_rll_est_ind_inval_sapi3() );
 	execute( TC_rll_est_ind_inval_sacch() );
 
+	/* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
+	execute( TC_tch_dlci_link_id_sapi() );
+
 	/* SAPI N Reject triggered by RLL establishment failures */
 	execute( TC_rll_rel_ind_sapi_n_reject() );
 	execute( TC_rll_err_ind_sapi_n_reject() );