mtp: Store the mtp_link inside the connection

Prepare to have multiple links to the BSC.
diff --git a/include/bsc_data.h b/include/bsc_data.h
index e48e5b7..67d9d02 100644
--- a/include/bsc_data.h
+++ b/include/bsc_data.h
@@ -131,7 +131,7 @@
 void msc_close_connection(struct bsc_data *data);
 
 /* connection tracking and action */
-void update_con_state(int rc, struct sccp_parse_result *result, struct msgb *msg, int from_msc, int sls);
+void update_con_state(struct mtp_link *link, int rc, struct sccp_parse_result *result, struct msgb *msg, int from_msc, int sls);
 unsigned int sls_for_src_ref(struct sccp_source_reference *ref);
 
 /* c7 init */
diff --git a/include/bsc_sccp.h b/include/bsc_sccp.h
index aed5daa..eee9a93 100644
--- a/include/bsc_sccp.h
+++ b/include/bsc_sccp.h
@@ -54,6 +54,9 @@
 	/* how often did we send a RLSD this */
 	unsigned int rls_tries;
 
+	/* MTP link this was coming in */
+	struct mtp_link *link;
+
 	/* sls id */
 	int sls;
 };
diff --git a/src/main.c b/src/main.c
index 8005666..bcb4035 100644
--- a/src/main.c
+++ b/src/main.c
@@ -142,7 +142,7 @@
 	}
 
 	/* update the connection state */
-	update_con_state(rc, &result, _msg, 0, sls);
+	update_con_state(link, rc, &result, _msg, 0, sls);
 
 	if (rc == BSS_FILTER_CLEAR_COMPL) {
 		send_local_rlsd(link, &result);
@@ -208,7 +208,7 @@
 
 
 	/* Update the state, maybe the connection was released? */
-	update_con_state(0, result, inpt, 0, sls);
+	update_con_state(link, 0, result, inpt, 0, sls);
 	if (llist_empty(&bsc.sccp_connections))
 		bsc_resources_released(&bsc);
 	return;
@@ -423,7 +423,7 @@
  *      1.) We are destroying the connection, we might send a RLC to
  *          the MSC if we are waiting for one.
  */
-void update_con_state(int rc, struct sccp_parse_result *res, struct msgb *msg, int from_msc, int sls)
+void update_con_state(struct mtp_link *link, int rc, struct sccp_parse_result *res, struct msgb *msg, int from_msc, int sls)
 {
 	struct active_sccp_con *con;
 	struct sccp_connection_request *cr;
@@ -459,6 +459,7 @@
 
 		con->src_ref = cr->source_local_reference;
 		con->sls = sls;
+		con->link = link;
 		llist_add_tail(&con->entry, &bsc.sccp_connections);
 		LOGP(DINP, LOGL_DEBUG, "Adding CR: local ref: 0x%x\n", sccp_src_ref_to_int(&con->src_ref));
 		break;
diff --git a/src/msc_conn.c b/src/msc_conn.c
index 3d0d93f..6e996d9 100644
--- a/src/msc_conn.c
+++ b/src/msc_conn.c
@@ -207,7 +207,7 @@
 			LOGP(DMSC, LOGL_NOTICE, "Filtering reset ack from the MSC\n");
 		} else if (rc == BSS_FILTER_RLSD) {
 			LOGP(DMSC, LOGL_DEBUG, "Filtering RLSD from the MSC\n");
-			update_con_state(rc, &result, msg, 1, 0);
+			update_con_state(NULL, rc, &result, msg, 1, 0);
 		} else if (rc == BSS_FILTER_RLC) {
 			/* if we receive this we have forwarded a RLSD to the network */
 			LOGP(DMSC, LOGL_ERROR, "RLC from the network. BAD!\n");
@@ -216,7 +216,7 @@
 		} else if (link->sccp_up) {
 			unsigned int sls;
 
-			update_con_state(rc, &result, msg, 1, 0);
+			update_con_state(NULL, rc, &result, msg, 1, 0);
 			sls = sls_for_src_ref(result.destination_local_reference);
 
 			/* Check for Location Update Accept */