bsc: Add Lb interface support

This introduces the Lb interface stack, which allows BSC_Tests.ttcn
to emulate a SMLC towards the BSC.

In accordance with https://osmocom.org/projects/cellular-infrastructure/wiki/Point_Codes
we use 0.23.6 as point code for emulating the SMLC.

Change-Id: Id41246f0dd812f7ddee9d920bfd07a4e3aac3504
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index df4b45e..8adf113 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -28,6 +28,8 @@
 
 import from BSSAP_Types all;
 import from RAN_Adapter all;
+import from BSSAP_LE_Adapter all;
+import from BSSAP_LE_CodecPort all;
 import from BSSAP_CodecPort all;
 import from BSSMAP_Templates all;
 import from IPA_Emulation all;
@@ -530,8 +532,10 @@
 	var StatsD_Checker_CT vc_STATSD;
 
 	var RAN_Adapter g_bssap[NUM_MSC];
+	var BSSAP_LE_Adapter g_bssap_le;
 	/* for old legacy-tests only */
 	port BSSAP_CODEC_PT BSSAP;
+	port BSSAP_LE_CODEC_PT BSSAP_LE;
 
 	/* are we initialized yet */
 	var boolean g_initialized := false;
@@ -605,6 +609,17 @@
 		}
 	};
 
+	BSSAP_LE_Configuration mp_bssap_le_cfg := {
+		sccp_service_type := "mtp3_itu",
+		sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
+		own_pc := 6,	/* 0.0.6 SMLC emulation */
+		own_ssn := 252,	/* SMLC side SSN */
+		peer_pc := 187, /* 0.23.3 osmo-bsc */
+		peer_ssn := 250, /* BSC side SSN */
+		sio := '83'O,
+		rctx := 6
+	};
+
 	/* Whether to enable osmux tests. Can be dropped completely and enable
 	   unconditionally once new version of osmo-bsc is released (current
 	   version: 1.4.1) */
@@ -1066,6 +1081,14 @@
 		}
 	}
 
+	if (handler_mode) {
+		f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
+	} else {
+		f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
+		connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
+	}
+	f_bssap_le_adapter_start(g_bssap_le);
+
 	/* start the test with exactly all enabled MSCs allowed to attach */
 	f_vty_msc_allow_attach(BSCVTY, allow_attach);
 
@@ -3095,6 +3118,7 @@
  ***********************************************************************/
 
 import from RAN_Emulation all;
+import from BSSAP_LE_Emulation all;
 import from RSL_Emulation all;
 import from MSC_ConnectionHandler all;
 
@@ -3115,6 +3139,7 @@
 		connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
 	}
 	connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
+	connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
 	connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
 	connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
 	connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);