[DAHDI] integrate DAHDI driver into E1 Input layer
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index 351b269..3f21406 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -21,8 +21,8 @@
 		gsm_subscriber_base.c subchan_demux.c bsc_rll.c transaction.c \
 		trau_frame.c trau_mux.c paging.c \
 		e1_config.c e1_input.c e1_input_vty.c \
-		input/misdn.c input/ipaccess.c handover_logic.c \
-		talloc_ctx.c system_information.c rest_octets.c \
+		input/misdn.c input/ipaccess.c input/dahdi.c input/lapd.c \
+		handover_logic.c talloc_ctx.c system_information.c rest_octets.c \
 		bts_siemens_bs11.c bts_ipaccess_nanobts.c mncc_upqueue.c \
 		bts_unknown.c bsc_version.c bsc_api.c bsc_vty.c meas_rep.c gsm_04_80.c
 
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index d98dbe3..8233878 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -613,6 +613,7 @@
 }
 
 void e1inp_misdn_init(void);
+void e1inp_dahdi_init(void);
 
 void e1inp_init(void)
 {
@@ -621,4 +622,5 @@
 	register_signal_handler(SS_GLOBAL, e1i_sig_cb, NULL);
 
 	e1inp_misdn_init();
+	e1inp_dahdi_init();
 }
diff --git a/openbsc/src/e1_input_vty.c b/openbsc/src/e1_input_vty.c
index b8050a8..3909f65 100644
--- a/openbsc/src/e1_input_vty.c
+++ b/openbsc/src/e1_input_vty.c
@@ -38,8 +38,9 @@
 
 #include "../bscconfig.h"
 
-#define E1_DRIVER_NAMES		"(misdn|misdn)"
-#define E1_DRIVER_HELP		"mISDN supported E1 Card\n"
+#define E1_DRIVER_NAMES		"(misdn|dahdi)"
+#define E1_DRIVER_HELP		"mISDN supported E1 Card\n" \
+				"DAHDI supported E1/T1/J1 Card\n"
 
 DEFUN(cfg_e1line_driver, cfg_e1_line_driver_cmd,
 	"e1_line <0-255> driver " E1_DRIVER_NAMES,
diff --git a/openbsc/src/input/dahdi.c b/openbsc/src/input/dahdi.c
index 5b45715..8f6bdda 100644
--- a/openbsc/src/input/dahdi.c
+++ b/openbsc/src/input/dahdi.c
@@ -35,15 +35,15 @@
 #include <arpa/inet.h>
 #include <dahdi/user.h>
 
-#include <openbsc/select.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/subchan_demux.h>
 #include <openbsc/e1_input.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 #include "lapd.h"
 
@@ -96,7 +96,7 @@
 		break;
 	case LAPD_DL_DATA_IND:
 	case LAPD_DL_UNITDATA_IND:
-		if (prim == DL_DATA_IND)
+		if (prim == LAPD_DL_DATA_IND)
 			msg->l2h = msg->data + 2;
 		else
 			msg->l2h = msg->data + 1;
@@ -232,7 +232,7 @@
 
 	ret = write(bfd->fd, tx_buf, ret);
 	if (ret < D_BCHAN_TX_GRAN)
-		fprintf(stderr, "send returns %d instead of %lu\n", ret,
+		fprintf(stderr, "send returns %d instead of %d\n", ret,
 			D_BCHAN_TX_GRAN);
 
 	return ret;
@@ -308,9 +308,12 @@
 	return rc;
 }
 
+static int dahdi_e1_line_update(struct e1inp_line *line);
+
 struct e1inp_driver dahdi_driver = {
 	.name = "DAHDI",
 	.want_write = ts_want_write,
+	.line_update = &dahdi_e1_line_update,
 };
 
 void dahdi_set_bufinfo(int fd, int as_sigchan)
@@ -408,7 +411,7 @@
 	return 0;
 }
 
-int mi_e1_line_update(struct e1inp_line *line)
+static int dahdi_e1_line_update(struct e1inp_line *line)
 {
 	int ret;
 
@@ -436,7 +439,7 @@
 	return 0;
 }
 
-static __attribute__((constructor)) void on_dso_load_sms(void)
+int e1inp_dahdi_init(void)
 {
 	/* register the driver with the core */
 	e1inp_driver_register(&dahdi_driver);