DAHDI: Deliver ALARM/NOALARM as input signal to RBS2000 driver

... and re-start LAPD SABM as required
diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h
index 866fa29..0273586 100644
--- a/openbsc/include/openbsc/signal.h
+++ b/openbsc/include/openbsc/signal.h
@@ -145,6 +145,8 @@
 	S_INP_TEI_UP,
 	S_INP_TEI_DN,
 	S_INP_LINE_INIT,
+	S_INP_LINE_ALARM,
+	S_INP_LINE_NOALARM,
 };
 
 struct gsm_subscriber;
diff --git a/openbsc/src/bts_ericsson_rbs2000.c b/openbsc/src/bts_ericsson_rbs2000.c
index 9c6a98f..5ad47b2 100644
--- a/openbsc/src/bts_ericsson_rbs2000.c
+++ b/openbsc/src/bts_ericsson_rbs2000.c
@@ -53,7 +53,7 @@
 
 /* Tell LAPD to start start the SAP (send SABM requests) for all signalling
  * timeslots in this line */
-static void start_sabm_in_line(struct e1inp_line *line)
+static void start_sabm_in_line(struct e1inp_line *line, int start)
 {
 	struct e1inp_sign_link *link;
 	int i;
@@ -65,7 +65,10 @@
 			continue;
 
 		llist_for_each_entry(link, &ts->sign.sign_links, list) {
-			lapd_sap_start(ts->driver.dahdi.lapd, link->tei, link->sapi);
+			if (start)
+				lapd_sap_start(ts->driver.dahdi.lapd, link->tei, link->sapi);
+			else
+				lapd_sap_stop(ts->driver.dahdi.lapd, link->tei, link->sapi);
 		}
 	}
 }
@@ -113,7 +116,17 @@
 		/* Right now Ericsson RBS are only supported on DAHDI */
 		if (strcasecmp(isd->line->driver->name, "DAHDI"))
 			break;
-		start_sabm_in_line(isd->line);
+		start_sabm_in_line(isd->line, 1);
+		break;
+	case S_INP_LINE_ALARM:
+		if (strcasecmp(isd->line->driver->name, "DAHDI"))
+			break;
+		start_sabm_in_line(isd->line, 0);
+		break;
+	case S_INP_LINE_NOALARM:
+		if (strcasecmp(isd->line->driver->name, "DAHDI"))
+			break;
+		start_sabm_in_line(isd->line, 1);
 		break;
 	}
 
diff --git a/openbsc/src/input/dahdi.c b/openbsc/src/input/dahdi.c
index c142b8a..56851ee 100644
--- a/openbsc/src/input/dahdi.c
+++ b/openbsc/src/input/dahdi.c
@@ -69,6 +69,7 @@
 static void handle_dahdi_exception(struct e1inp_ts *ts)
 {
 	int rc, evt;
+	struct input_signal_data isd;
 
 	rc = ioctl(ts->driver.dahdi.fd.fd, DAHDI_GETEVENT, &evt);
 	if (rc < 0)
@@ -78,12 +79,16 @@
 		ts->line->num, ts->line->name, ts->num,
 		get_value_string(dahdi_evt_names, evt));
 
+	isd.line = ts->line;
+
 	switch (evt) {
 	case DAHDI_EVENT_ALARM:
-		/* FIXME: we should notify the code that the line is gone */
+		/* we should notify the code that the line is gone */
+		dispatch_signal(SS_INPUT, S_INP_LINE_ALARM, &isd);
 		break;
 	case DAHDI_EVENT_NOALARM:
-		/* FIXME: alarm has gone, we should re-start the SABM requests */
+		/* alarm has gone, we should re-start the SABM requests */
+		dispatch_signal(SS_INPUT, S_INP_LINE_NOALARM, &isd);
 		break;
 	}
 }