msc: Send a signal when the connections to the MSC dropped

Send a signal, this way another module can close all connections
to the MSC and all local channels.
diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h
index 9c9d645..40766db 100644
--- a/openbsc/include/openbsc/signal.h
+++ b/openbsc/include/openbsc/signal.h
@@ -1,6 +1,7 @@
 /* Generic signalling/notification infrastructure */
 /* (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
  * (C) 2009 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2010 by On-Waves
  * All Rights Reserved
  *
  * This program is free software; you can redistribute it and/or modify
@@ -45,6 +46,7 @@
 	SS_NS,
 	SS_IPAC_NWL,
 	SS_RF,
+	SS_MSC,
 };
 
 /* SS_PAGING signals */
@@ -180,4 +182,16 @@
 	uint8_t cause;
 };
 
+/* MSC signals */
+enum signal_msc {
+	S_MSC_LOST,
+	S_MSC_CONNECTED,
+};
+
+struct osmo_msc_data;
+struct msc_signal_data {
+	struct osmo_msc_data *data;
+};
+
+
 #endif
diff --git a/openbsc/src/bsc/osmo_bsc_msc.c b/openbsc/src/bsc/osmo_bsc_msc.c
index 2530399..6644982 100644
--- a/openbsc/src/bsc/osmo_bsc_msc.c
+++ b/openbsc/src/bsc/osmo_bsc_msc.c
@@ -26,7 +26,7 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/ipaccess.h>
 #include <openbsc/osmo_msc_data.h>
-
+#include <openbsc/signal.h>
 
 #include <osmocore/gsm0808.h>
 
@@ -274,6 +274,7 @@
 
 static void msc_connection_connected(struct bsc_msc_connection *con)
 {
+	struct msc_signal_data sig;
 	struct osmo_msc_data *data;
 	int ret, on;
 	on = 1;
@@ -283,6 +284,9 @@
 
 	data = (struct osmo_msc_data *) con->write_queue.bfd.data;
 	msc_ping_timeout_cb(con);
+
+	sig.data = data;
+	dispatch_signal(SS_MSC, S_MSC_CONNECTED, &sig);
 }
 
 /*
@@ -291,23 +295,18 @@
  */
 static void msc_connection_was_lost(struct bsc_msc_connection *msc)
 {
+	struct msc_signal_data sig;
 	struct osmo_msc_data *data;
 
 	LOGP(DMSC, LOGL_ERROR, "Lost MSC connection. Freing stuff.\n");
 
-#if 0
-	struct bss_sccp_connection_data *bss, *tmp;
-	llist_for_each_entry_safe(bss, tmp, &active_connections, active_connections) {
-		bss_force_close(bss);
-	}
-#else
-#warning "This needs to be ported..."
-#endif
-
 	data = (struct osmo_msc_data *) msc->write_queue.bfd.data;
 	bsc_del_timer(&data->ping_timer);
 	bsc_del_timer(&data->pong_timer);
 
+	sig.data = data;
+	dispatch_signal(SS_MSC, S_MSC_LOST, &sig);
+
 	msc->is_authenticated = 0;
 	bsc_msc_schedule_connect(msc);
 }