Add support for LCLS to the MSC

This commit is largely based on work by
Max <msuraev@sysmocom.de>

Adds LCLS parameters for A-interface transactions
This commit also adds a vty option to facilitate globally
disabling LCLS for all calls on this MSC.

Add a global call reference (GCR) to MNCC and therefore
bump the MNCC version to version 8. (This commit has to be
merged at the same time as the corresponing commit in the
osmo-sip-connector for mncc-external use.)

Depends: osmo-sip-connector Id40d7e0fed9356f801b3627c118150055e7232b1
Change-Id: I705c860e51637b4537cad65a330ecbaaca96dd5b
diff --git a/include/osmocom/msc/debug.h b/include/osmocom/msc/debug.h
index 3347e20..0d08ceb 100644
--- a/include/osmocom/msc/debug.h
+++ b/include/osmocom/msc/debug.h
@@ -8,6 +8,7 @@
 	DCC,
 	DMM,
 	DRR,
+	DLCLS,
 	DMNCC,
 	DPAG,
 	DMSC,
diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 170d884..72e33a6 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -260,6 +260,10 @@
 
 	/* Whether to use call waiting on the network */
 	bool call_waiting;
+
+	/* Whether to use lcls on the network */
+	bool lcls_permitted;
+
 	char *sms_db_file_path;
 };
 
diff --git a/include/osmocom/msc/mncc.h b/include/osmocom/msc/mncc.h
index 1c8aff0..5002227 100644
--- a/include/osmocom/msc/mncc.h
+++ b/include/osmocom/msc/mncc.h
@@ -26,6 +26,7 @@
 
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/gsm/mncc.h>
+#include <osmocom/gsm/gsm29205.h>
 
 #include <stdint.h>
 #include <netinet/in.h>
@@ -160,7 +161,7 @@
 
 	unsigned char	lchan_type;
 	unsigned char	lchan_mode;
-
+	struct osmo_gcr_parsed gcr;
 	/* A buffer to contain SDP ('\0' terminated) */
 	char		sdp[1024];
 };
@@ -171,7 +172,7 @@
 	unsigned char	data[0];
 };
 
-#define MNCC_SOCK_VERSION	7
+#define MNCC_SOCK_VERSION	8
 struct gsm_mncc_hello {
 	uint32_t	msg_type;
 	uint32_t	version;
diff --git a/include/osmocom/msc/ran_msg.h b/include/osmocom/msc/ran_msg.h
index 1303ba3..fd2439f 100644
--- a/include/osmocom/msc/ran_msg.h
+++ b/include/osmocom/msc/ran_msg.h
@@ -88,6 +88,7 @@
 	uint8_t osmux_cid;
 	bool call_id_present;
 	uint32_t call_id;
+	struct osmo_lcls *lcls;
 };
 
 struct ran_cipher_mode_command {
diff --git a/include/osmocom/msc/transaction.h b/include/osmocom/msc/transaction.h
index 928b137..14b89bb 100644
--- a/include/osmocom/msc/transaction.h
+++ b/include/osmocom/msc/transaction.h
@@ -100,6 +100,7 @@
 			struct osmo_timer_list timer_guard;
 			struct gsm_mncc msg;	/* stores setup/disconnect/release message */
 			bool mncc_initiated;	/* Whether an MNCC Release is necessary on failure */
+			struct osmo_lcls *lcls;
 		} cc;
 		struct {
 			struct gsm411_smc_inst smc_inst;
@@ -145,6 +146,8 @@
 					 const struct vlr_subscr *vsub,
 					 uint8_t sm_rp_mr);
 
+struct osmo_lcls *trans_lcls_compose(const struct gsm_trans *trans, bool use_lac);
+
 struct gsm_trans *trans_alloc(struct gsm_network *net,
 			      struct vlr_subscr *vsub,
 			      enum trans_type type, uint8_t trans_id,