src: port openBSC over libosmo-abis

This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.

The main changes are:

- The directory libabis/ has been removed as it now lives in
  libosmo-abis.

- new configuration file format for nanoBTS and HSL femto, we
  need to define the virtual e1_line and attach it to the OML
  link.

- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
  BS11 and rbs2000) now use the new libosmo-abis framework.

- use r232 input driver available in libosmo-abis for bs11_config.

- use ipa_msg_recv instead of old ipaccess_read_msg function.

- delete definition of gsm_e1_subslot and input_signal_data.
  These structures now lives in libosmo-abis.

Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.

This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:

- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node

This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 89cfcac..a8e29b4 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -46,6 +46,7 @@
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.2)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
 PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.3.0)
+PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.0.2)
 
 dnl checks for header files
 AC_HEADER_STDC
@@ -90,7 +91,6 @@
     include/Makefile
     src/Makefile
     src/libtrau/Makefile
-    src/libabis/Makefile
     src/libbsc/Makefile
     src/libctrl/Makefile
     src/libmsc/Makefile
diff --git a/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg b/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
index 0a64917..97704fb 100644
--- a/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
+++ b/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
@@ -39,6 +39,8 @@
 line vty
  no login
 !
+e1_input
+ e1_line 0 driver ipa
 network
  network country code 1
  mobile network code 1
@@ -86,7 +88,7 @@
   rach tx integer 9
   rach max transmission 7
   ip.access unit_id 0 0
-  oml ip.access stream_id 255
+  oml ip.access stream_id 255 line 0
   neighbor-list mode manual-si5
   neighbor-list add arfcn 100
   neighbor-list add arfcn 200
diff --git a/openbsc/doc/examples/osmo-nitb/hsl/openbsc.cfg b/openbsc/doc/examples/osmo-nitb/hsl/openbsc.cfg
index 831f6bb..3d95748 100644
--- a/openbsc/doc/examples/osmo-nitb/hsl/openbsc.cfg
+++ b/openbsc/doc/examples/osmo-nitb/hsl/openbsc.cfg
@@ -6,6 +6,8 @@
 line vty
  no login
 !
+e1_input
+ e1_line 0 driver hsl
 network
  network country code 262
  mobile network code 42
@@ -54,6 +56,7 @@
   rach max transmission 1
   hsl serial-number 8303701
   neighbor-list mode automatic
+  oml hsl line 0
   gprs mode none
   trx 0
    rf_locked 0
diff --git a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc-multitrx.cfg b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc-multitrx.cfg
index 9c9108c..7a187f8 100644
--- a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc-multitrx.cfg
+++ b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc-multitrx.cfg
@@ -6,6 +6,8 @@
 line vty
  no login
 !
+e1_input
+ e1_line 0 driver ipa
 network
  network country code 1
  mobile network code 1
@@ -49,7 +51,7 @@
   rach tx integer 9
   rach max transmission 7
   ip.access unit_id 1800 0
-  oml ip.access stream_id 255
+  oml ip.access stream_id 255 line 0
   gprs mode none
   trx 0
    rf_locked 0
diff --git a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
index 3e7b932..78e9787 100644
--- a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
+++ b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
@@ -6,6 +6,8 @@
 line vty
  no login
 !
+e1_input
+ e1_line 0 driver ipa
 network
  network country code 1
  mobile network code 1
@@ -49,7 +51,7 @@
   rach tx integer 9
   rach max transmission 7
   ip.access unit_id 1801 0
-  oml ip.access stream_id 255
+  oml ip.access stream_id 255 line 0
   gprs mode none
   trx 0
    rf_locked 0
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index 9ec92c1..53cc5ee 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -1,8 +1,7 @@
 noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \
 		 gsm_subscriber.h gsm_04_11.h debug.h signal.h \
 		 misdn.h chan_alloc.h paging.h \
-		 subchan_demux.h trau_frame.h e1_input.h trau_mux.h \
-		 ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \
+		 trau_mux.h rs232.h openbscdefines.h rtp_proxy.h \
 		 bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \
 		 silent_call.h mgcp.h meas_rep.h rest_octets.h \
 		 system_information.h handover.h mgcp_internal.h \
diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h
index ae4f625..f11ac11 100644
--- a/openbsc/include/openbsc/abis_nm.h
+++ b/openbsc/include/openbsc/abis_nm.h
@@ -160,5 +160,8 @@
 
 void abis_nm_clear_queue(struct gsm_bts *bts);
 
+int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml);
+
+void abis_nm_queue_send_next(struct gsm_bts *bts);	/* for bs11_config. */
 
 #endif /* _NM_H */
diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index d78252a..43f0ff8 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -19,10 +19,6 @@
 	DSMS,
 	DPAG,
 	DMEAS,
-	DMI,
-	DMIB,
-	DMUX,
-	DINP,
 	DSCCP,
 	DMSC,
 	DMGCP,
diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h
deleted file mode 100644
index 4a375ed..0000000
--- a/openbsc/include/openbsc/e1_input.h
+++ /dev/null
@@ -1,200 +0,0 @@
-#ifndef _E1_INPUT_H
-#define _E1_INPUT_H
-
-#include <stdlib.h>
-#include <netinet/in.h>
-
-#include <osmocom/core/linuxlist.h>
-#include <openbsc/gsm_data.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/select.h>
-#include <osmocom/core/rate_ctr.h>
-#include <openbsc/subchan_demux.h>
-
-#define NUM_E1_TS   32
-
-enum e1inp_sign_type {
-	E1INP_SIGN_NONE,
-	E1INP_SIGN_OML,
-	E1INP_SIGN_RSL,
-};
-const char *e1inp_signtype_name(enum e1inp_sign_type tp);
-
-enum e1inp_ctr {
-	E1I_CTR_HDLC_ABORT,
-	E1I_CTR_HDLC_BADFCS,
-	E1I_CTR_HDLC_OVERR,
-	E1I_CTR_ALARM,
-	E1I_CTR_REMOVED,
-};
-
-struct e1inp_ts;
-
-struct e1inp_sign_link {
-	/* list of signalling links */
-	struct llist_head list;
-
-	/* to which timeslot do we belong? */
-	struct e1inp_ts *ts;
-
-	enum e1inp_sign_type type;
-
-	/* trx for msg->trx of received msgs */	
-	struct gsm_bts_trx *trx;
-
-	/* msgb queue of to-be-transmitted msgs */
-	struct llist_head tx_list;
-
-	/* SAPI and TEI on the E1 TS */
-	uint8_t sapi;
-	uint8_t tei;
-
-	union {
-		struct {
-			uint8_t channel;
-		} misdn;
-	} driver;
-};
-
-enum e1inp_ts_type {
-	E1INP_TS_TYPE_NONE,
-	E1INP_TS_TYPE_SIGN,
-	E1INP_TS_TYPE_TRAU,
-};
-const char *e1inp_tstype_name(enum e1inp_ts_type tp);
-
-/* A timeslot in the E1 interface */
-struct e1inp_ts {
-	enum e1inp_ts_type type;
-	int num;
-
-	/* to which line do we belong ? */
-	struct e1inp_line *line;
-
-	union {
-		struct {
-			/* list of all signalling links on this TS */
-			struct llist_head sign_links;
-			/* delay for the queue */
-			int delay;
-			/* timer when to dequeue next frame */
-			struct osmo_timer_list tx_timer;
-		} sign;
-		struct {
-			/* subchannel demuxer for frames from E1 */
-			struct subch_demux demux;
-			/* subchannel muxer for frames to E1 */
-			struct subch_mux mux;
-		} trau;
-	};
-	union {
-		struct {
-			/* mISDN driver has one fd for each ts */
-			struct osmo_fd fd;
-		} misdn;
-		struct {
-			/* ip.access driver has one fd for each ts */
-			struct osmo_fd fd;
-		} ipaccess;
-		struct {
-			/* DAHDI driver has one fd for each ts */
-			struct osmo_fd fd;
-			struct lapd_instance *lapd;
-		} dahdi;
-	} driver;
-};
-
-struct e1inp_driver {
-	struct llist_head list;
-	const char *name;
-	int (*want_write)(struct e1inp_ts *ts);
-	int (*line_update)(struct e1inp_line *line);
-	int default_delay;
-};	
-
-struct e1inp_line {
-	struct llist_head list;
-	unsigned int num;
-	const char *name;
-	struct rate_ctr_group *rate_ctr;
-
-	/* array of timestlots */
-	struct e1inp_ts ts[NUM_E1_TS];
-
-	struct e1inp_driver *driver;
-	void *driver_data;
-};
-
-/* register a driver with the E1 core */
-int e1inp_driver_register(struct e1inp_driver *drv);
-
-/* fine a previously registered driver */
-struct e1inp_driver *e1inp_driver_find(const char *name);
-
-/* register a line with the E1 core */
-int e1inp_line_register(struct e1inp_line *line);
-
-/* get a line by its ID */
-struct e1inp_line *e1inp_line_get(uint8_t e1_nr);
-
-/* create a line in the E1 input core */
-struct e1inp_line *e1inp_line_create(uint8_t e1_nr, const char *driver_name);
-
-/* find a sign_link for given TEI and SAPI in a TS */
-struct e1inp_sign_link *
-e1inp_lookup_sign_link(struct e1inp_ts *ts, uint8_t tei,
-			uint8_t sapi);
-
-/* create a new signalling link in a E1 timeslot */
-struct e1inp_sign_link *
-e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
-			struct gsm_bts_trx *trx, uint8_t tei,
-			uint8_t sapi);
-
-/* configure and initialize one e1inp_ts */
-int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
-		    enum e1inp_ts_type type);
-
-/* Call from the Stack: configuration of this TS has changed */
-int e1inp_update_ts(struct e1inp_ts *ts);
-
-/* Receive a packet from the E1 driver */
-int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
-		uint8_t tei, uint8_t sapi);
-
-/* called by driver if it wants to transmit on a given TS */
-struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
-			 struct e1inp_sign_link **sign_link);
-
-/* called by driver in case some kind of link state event */
-int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi);
-
-/* Write LAPD frames to the fd. */
-void e1_set_pcap_fd(int fd);
-
-/* called by TRAU muxer to obtain the destination mux entity */
-struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr);
-
-void e1inp_sign_link_destroy(struct e1inp_sign_link *link);
-int e1inp_line_update(struct e1inp_line *line);
-
-/* e1_config.c */
-int e1_reconfig_ts(struct gsm_bts_trx_ts *ts);
-int e1_reconfig_trx(struct gsm_bts_trx *trx);
-int e1_reconfig_bts(struct gsm_bts *bts);
-
-int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin);
-int ipaccess_setup(struct gsm_network *gsmnet);
-int hsl_setup(struct gsm_network *gsmnet);
-
-extern struct llist_head e1inp_driver_list;
-extern struct llist_head e1inp_line_list;
-
-int e1inp_vty_init(void);
-void e1inp_init(void);
-
-int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml);
-
-int abis_sendmsg(struct msgb *msg);
-
-#endif /* _E1_INPUT_H */
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 715ff1b..20b8fe7 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -7,6 +7,7 @@
 #include <osmocom/core/select.h>
 
 #include <openbsc/rest_octets.h>
+#include <osmocom/abis/e1_input.h>
 
 #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
 
@@ -382,4 +383,7 @@
 int gsm_bts_has_feature(struct gsm_bts *bts, enum gsm_bts_features feat);
 struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
 
+/* generic E1 line operations for all ISDN-based BTS. */
+extern struct e1inp_line_ops bts_isdn_e1inp_line_ops;
+
 #endif /* _GSM_DATA_H */
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 89375cf..1dec0e4 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -225,16 +225,6 @@
 #endif
 };
 
-
-struct gsm_e1_subslot {
-	/* Number of E1 link */
-	uint8_t	e1_nr;
-	/* Number of E1 TS inside E1 link */
-	uint8_t	e1_ts;
-	/* Sub-slot within the E1 TS, 0xff if full TS */
-	uint8_t	e1_ts_ss;
-};
-
 #define TS_F_PDCH_MODE	0x1000
 /* One Timeslot in a TRX */
 struct gsm_bts_trx_ts {
@@ -341,6 +331,8 @@
 	int (*start)(struct gsm_network *net);
 	int (*oml_rcvmsg)(struct msgb *msg);
 
+	void (*e1line_bind_ops)(struct e1inp_line *line);
+
 	void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
 	void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
 	void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h
index c2ca2a5..d3c9d1d 100644
--- a/openbsc/include/openbsc/ipaccess.h
+++ b/openbsc/include/openbsc/ipaccess.h
@@ -1,7 +1,7 @@
 #ifndef _IPACCESS_H
 #define _IPACCESS_H
 
-#include "e1_input.h"
+#include <osmocom/abis/e1_input.h>
 #include "gsm_subscriber.h"
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/gsm/protocol/ipaccess.h>
@@ -26,13 +26,10 @@
 	uint8_t data[0];
 } __attribute__((packed));
 
-int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa);
-
 /*
  * methods for parsing and sending a message
  */
 int ipaccess_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
-struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error);
 void ipaccess_prepend_header(struct msgb *msg, int proto);
 void ipaccess_prepend_header_ext(struct msgb *msg, int proto);
 int ipaccess_send_pong(int fd);
diff --git a/openbsc/include/openbsc/misdn.h b/openbsc/include/openbsc/misdn.h
index 0a8b063..9851ad3 100644
--- a/openbsc/include/openbsc/misdn.h
+++ b/openbsc/include/openbsc/misdn.h
@@ -19,7 +19,7 @@
 #ifndef MISDN_H
 #define MISDN_H
 
-#include "e1_input.h"
+#include <osmocom/abis/e1_input.h>
 
 int mi_setup(int cardnr,  struct e1inp_line *line, int release_l2);
 int mi_e1_line_update(struct e1inp_line *line);
diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h
index 71e1dee..7f30f4f 100644
--- a/openbsc/include/openbsc/signal.h
+++ b/openbsc/include/openbsc/signal.h
@@ -40,14 +40,12 @@
 	SS_LCHAN,
 	SS_SUBSCR,
 	SS_SCALL,
-	SS_GLOBAL,
 	SS_CHALLOC,
 	SS_NS,
 	SS_IPAC_NWL,
 	SS_RF,
 	SS_MSC,
 	SS_HO,
-	SS_INPUT,
 };
 
 /* SS_PAGING signals */
@@ -129,7 +127,6 @@
 };
 
 enum signal_global {
-	S_GLOBAL_SHUTDOWN,
 	S_GLOBAL_BTS_CLOSE_OM,
 };
 
@@ -140,17 +137,6 @@
 	S_RF_GRACE,
 };
 
-/* SS_INPUT signals */
-enum signal_input {
-	S_INP_NONE,
-	S_INP_TEI_UP,
-	S_INP_TEI_DN,
-	S_INP_TEI_UNKNOWN,
-	S_INP_LINE_INIT,
-	S_INP_LINE_ALARM,
-	S_INP_LINE_NOALARM,
-};
-
 struct gsm_subscriber;
 
 struct paging_signal_data {
@@ -261,12 +247,4 @@
 	struct gsm_lchan *new_lchan;
 };
 
-struct input_signal_data {
-	int link_type;
-	uint8_t tei;
-	uint8_t sapi;
-	struct gsm_bts_trx *trx;
-	struct e1inp_line *line;
-};
-
 #endif
diff --git a/openbsc/include/openbsc/subchan_demux.h b/openbsc/include/openbsc/subchan_demux.h
deleted file mode 100644
index b71c856..0000000
--- a/openbsc/include/openbsc/subchan_demux.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef _SUBCH_DEMUX_H
-#define _SUBCH_DEMUX_H
-/* A E1 sub-channel (de)multiplexer with TRAU frame sync */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdint.h>
-#include <osmocom/core/linuxlist.h>
-
-#define NR_SUBCH	4
-#define TRAU_FRAME_SIZE	40
-#define TRAU_FRAME_BITS	(TRAU_FRAME_SIZE*8)
-
-/***********************************************************************/
-/* DEMULTIPLEXER */
-/***********************************************************************/
-
-struct demux_subch {
-	uint8_t out_bitbuf[TRAU_FRAME_BITS];
-	uint16_t out_idx; /* next bit to be written in out_bitbuf */
-	/* number of consecutive zeros that we have received (for sync) */
-	unsigned int consecutive_zeros;
-	/* are we in TRAU frame sync or not? */
-	unsigned int in_sync;
-};
-
-struct subch_demux {
-	/* bitmask of currently active subchannels */
-	uint8_t chan_activ;
-	/* one demux_subch struct for every subchannel */
-	struct demux_subch subch[NR_SUBCH];
-	/* callback to be called once we have received a complete
-	 * frame on a given subchannel */
-	int (*out_cb)(struct subch_demux *dmx, int ch, uint8_t *data, int len,
-		      void *);
-	/* user-provided data, transparently passed to out_cb() */
-	void *data;
-};
-
-/* initialize one demultiplexer instance */
-int subch_demux_init(struct subch_demux *dmx);
-
-/* feed 'len' number of muxed bytes into the demultiplexer */
-int subch_demux_in(struct subch_demux *dmx, uint8_t *data, int len);
-
-/* activate decoding/processing for one subchannel */
-int subch_demux_activate(struct subch_demux *dmx, int subch);
-
-/* deactivate decoding/processing for one subchannel */
-int subch_demux_deactivate(struct subch_demux *dmx, int subch);
-
-/***********************************************************************/
-/* MULTIPLEXER */
-/***********************************************************************/
-
-/* one element in the tx_queue of a muxer sub-channel */
-struct subch_txq_entry {
-	struct llist_head list;
-
-	unsigned int bit_len;	/* total number of bits in 'bits' */
-	unsigned int next_bit;	/* next bit to be transmitted */
-
-	uint8_t bits[0];	/* one bit per byte */
-};
-
-struct mux_subch {
-	struct llist_head tx_queue;
-};
-
-/* structure representing one instance of the subchannel muxer */
-struct subch_mux {
-	struct mux_subch subch[NR_SUBCH];
-};
-
-/* initialize a subchannel muxer instance */
-int subchan_mux_init(struct subch_mux *mx);
-
-/* request the output of 'len' multiplexed bytes */
-int subchan_mux_out(struct subch_mux *mx, uint8_t *data, int len);
-
-/* enqueue some data into one sub-channel of the muxer */
-int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const uint8_t *data,
-			int len);
-
-#endif /* _SUBCH_DEMUX_H */
diff --git a/openbsc/include/openbsc/trau_frame.h b/openbsc/include/openbsc/trau_frame.h
deleted file mode 100644
index c15e24b..0000000
--- a/openbsc/include/openbsc/trau_frame.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef _TRAU_FRAME_H
-#define _TRAU_FRAME_H
-/* TRAU frame handling according to GSM TS 08.60 */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdint.h>
-
-/* 21 for FR/EFR, 25 for AMR, 15 for OM, 15 for data, 13 for E-data, 21 idle */
-#define MAX_C_BITS	25
-/* 260 for FR/EFR, 256 for AMR, 264 for OM, 288 for E-data */
-#define MAX_D_BITS	288
-/* for all speech frames */
-#define MAX_T_BITS	4
-/* for OM */
-#define MAX_S_BITS	6
-/* for E-data */
-#define MAX_M_BITS	2
-
-struct decoded_trau_frame {
-	uint8_t c_bits[MAX_C_BITS];
-	uint8_t d_bits[MAX_D_BITS];
-	uint8_t t_bits[MAX_T_BITS];
-	uint8_t s_bits[MAX_S_BITS];
-	uint8_t m_bits[MAX_M_BITS];
-};
-
-#define TRAU_FT_FR_UP		0x02	/* 0 0 0 1 0 - 3.5.1.1.1 */
-#define TRAU_FT_FR_DOWN		0x1c	/* 1 1 1 0 0 - 3.5.1.1.1 */
-#define TRAU_FT_EFR		0x1a	/* 1 1 0 1 0 - 3.5.1.1.1 */
-#define TRAU_FT_AMR		0x06	/* 0 0 1 1 0 - 3.5.1.2 */
-#define TRAU_FT_OM_UP		0x07	/* 0 0 1 0 1 - 3.5.2 */
-#define TRAU_FT_OM_DOWN		0x1b	/* 1 1 0 1 1 - 3.5.2 */
-#define TRAU_FT_DATA_UP		0x08	/* 0 1 0 0 0 - 3.5.3 */
-#define TRAU_FT_DATA_DOWN	0x16	/* 1 0 1 1 0 - 3.5.3 */
-#define TRAU_FT_D145_SYNC	0x14	/* 1 0 1 0 0 - 3.5.3 */
-#define TRAU_FT_EDATA		0x1f	/* 1 1 1 1 1 - 3.5.4 */
-#define TRAU_FT_IDLE_UP		0x10	/* 1 0 0 0 0 - 3.5.5 */
-#define TRAU_FT_IDLE_DOWN	0x0e	/* 0 1 1 1 0 - 3.5.5 */
-
-
-int decode_trau_frame(struct decoded_trau_frame *fr, const uint8_t *trau_bits);
-int encode_trau_frame(uint8_t *trau_bits, const struct decoded_trau_frame *fr);
-int trau_frame_up2down(struct decoded_trau_frame *fr);
-uint8_t *trau_idle_frame(void);
-
-
-#endif /* _TRAU_FRAME_H */
diff --git a/openbsc/include/openbsc/trau_mux.h b/openbsc/include/openbsc/trau_mux.h
index 9936ba1..2c01b06 100644
--- a/openbsc/include/openbsc/trau_mux.h
+++ b/openbsc/include/openbsc/trau_mux.h
@@ -50,3 +50,6 @@
 
 /* send trau from application */
 int trau_send_frame(struct gsm_lchan *lchan, struct gsm_data_frame *frame);
+
+/* callback invoked if we receive TRAU frames */
+int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len, void *_priv);
diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h
index 6635896..d455a2b 100644
--- a/openbsc/include/openbsc/vty.h
+++ b/openbsc/include/openbsc/vty.h
@@ -29,7 +29,6 @@
 	NS_NODE,
 	BSSGP_NODE,
 	OML_NODE,
-	E1INP_NODE,
 	NAT_NODE,
 	NAT_BSC_NODE,
 	MSC_NODE,
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index c7de811..805fb1c 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -2,7 +2,7 @@
 AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
 AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
 
-SUBDIRS = libcommon libabis libmgcp libbsc libmsc libtrau libctrl osmo-nitb osmo-bsc_mgcp utils ipaccess libgb gprs
+SUBDIRS = libcommon libmgcp libbsc libmsc libtrau libctrl osmo-nitb osmo-bsc_mgcp utils ipaccess libgb gprs
 
 # Conditional modules
 if BUILD_NAT
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index ee8a870..c66350c 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -97,7 +97,7 @@
 
 	switch (signal) {
 	case SIGINT:
-		osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+		osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
 		sleep(1);
 		exit(0);
 		break;
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index fa61e0e..93ad33a 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -105,7 +105,7 @@
 
 	switch (signal) {
 	case SIGINT:
-		osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+		osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
 		sleep(1);
 		exit(0);
 		break;
diff --git a/openbsc/src/ipaccess/Makefile.am b/openbsc/src/ipaccess/Makefile.am
index 4fe1e37..6d163f6 100644
--- a/openbsc/src/ipaccess/Makefile.am
+++ b/openbsc/src/ipaccess/Makefile.am
@@ -1,12 +1,11 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 bin_PROGRAMS = ipaccess-find ipaccess-config ipaccess-proxy
 
 ipaccess_find_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
 		      $(top_builddir)/src/libmsc/libmsc.a \
-		      $(top_builddir)/src/libabis/libabis.a \
 		      $(top_builddir)/src/libbsc/libbsc.a \
 		      $(top_builddir)/src/libtrau/libtrau.a \
 		      $(top_builddir)/src/libcommon/libcommon.a
@@ -17,7 +16,6 @@
 # FIXME: resolve the bogus dependencies patched around here:
 ipaccess_config_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
 			$(top_builddir)/src/libmsc/libmsc.a \
-			$(top_builddir)/src/libabis/libabis.a \
 			$(top_builddir)/src/libbsc/libbsc.a \
 			$(top_builddir)/src/libtrau/libtrau.a \
 			$(top_builddir)/src/libcommon/libcommon.a \
@@ -26,7 +24,6 @@
 ipaccess_proxy_SOURCES = ipaccess-proxy.c
 ipaccess_proxy_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
 		       $(top_builddir)/src/libmsc/libmsc.a \
-		       $(top_builddir)/src/libabis/libabis.a \
 		       $(top_builddir)/src/libbsc/libbsc.a \
 		       $(top_builddir)/src/libtrau/libtrau.a \
 		       $(top_builddir)/src/libcommon/libcommon.a
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 368f788..05fdc14 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -39,12 +39,19 @@
 #include <osmocom/core/timer.h>
 #include <openbsc/ipaccess.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
+#include <openbsc/abis_nm.h>
+#include <openbsc/signal.h>
+#include <openbsc/debug.h>
+#include <openbsc/network_listen.h>
+#include <osmocom/abis/ipaccess.h>
+#include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/signal.h>
 #include <openbsc/debug.h>
 #include <openbsc/network_listen.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/abis/abis.h>
 
 static struct gsm_network *gsmnet;
 
@@ -80,6 +87,86 @@
 static uint8_t unit_id_attr[] = { 0x91, 0x00, 9, '2', '3', '4', '2', '/' , '0', '/', '0', 0x00 };
 */
 
+extern int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what);
+extern struct e1inp_line_ops ipaccess_e1inp_line_ops;
+
+/* Actively connect to a BTS.  Currently used by ipaccess-config.c */
+static int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
+{
+	struct e1inp_ts *e1i_ts = &line->ts[0];
+	struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd;
+	int ret, on = 1;
+
+	bfd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	bfd->cb = ipaccess_fd_cb;
+	bfd->when = BSC_FD_READ | BSC_FD_WRITE;
+	bfd->data = line;
+	bfd->priv_nr = E1INP_SIGN_OML;
+
+	if (bfd->fd < 0) {
+		LOGP(DLINP, LOGL_ERROR, "could not create TCP socket.\n");
+		return -EIO;
+	}
+
+	setsockopt(bfd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+
+	ret = connect(bfd->fd, (struct sockaddr *) sa, sizeof(*sa));
+	if (ret < 0) {
+		LOGP(DLINP, LOGL_ERROR, "could not connect socket\n");
+		close(bfd->fd);
+		return ret;
+	}
+
+	ret = osmo_fd_register(bfd);
+	if (ret < 0) {
+		close(bfd->fd);
+		return ret;
+	}
+	return ret;
+	//return e1inp_line_register(line);
+}
+
+/* configure pseudo E1 line in ip.access style and connect to BTS */
+static int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin)
+{
+	struct e1inp_line *line;
+	struct e1inp_ts *sign_ts, *rsl_ts;
+	struct e1inp_sign_link *oml_link, *rsl_link;
+
+	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
+	if (!line)
+		return -ENOMEM;
+
+	line->driver = e1inp_driver_find("ipa");
+	if (!line->driver) {
+		fprintf(stderr, "cannot `ipa' driver, giving up.\n");
+		return -EINVAL;
+	}
+	line->ops = &ipaccess_e1inp_line_ops;
+
+	/* create E1 timeslots for signalling and TRAU frames */
+	e1inp_ts_config_sign(&line->ts[1-1], line);
+	e1inp_ts_config_sign(&line->ts[2-1], line);
+
+	/* create signalling links for TS1 */
+	sign_ts = &line->ts[1-1];
+	rsl_ts = &line->ts[2-1];
+	oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
+					  bts->c0, 0xff, 0);
+	rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL,
+					  bts->c0, 0, 0);
+
+	/* create back-links from bts/trx */
+	bts->oml_link = oml_link;
+	bts->c0->rsl_link = rsl_link;
+
+	/* default port at BTS for incoming connections is 3006 */
+	if (sin->sin_port == 0)
+		sin->sin_port = htons(3006);
+
+	return ipaccess_connect(line, sin);
+}
+
 /*
  * Callback function for NACK on the OML NM
  *
@@ -891,6 +978,7 @@
 			fprintf(stderr, "you have to specify the IP address of the BTS. Use --help for more information\n");
 		exit(2);
 	}
+	libosmo_abis_init(tall_ctx_config);
 
 	gsmnet = gsm_network_init(1, 1, NULL);
 	if (!gsmnet)
diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c
index 1dd5b84..0f03e4e 100644
--- a/openbsc/src/ipaccess/ipaccess-proxy.c
+++ b/openbsc/src/ipaccess/ipaccess-proxy.c
@@ -210,12 +210,12 @@
 	ret = recv(bfd->fd, msg->data, msg->data_len, 0);
 	if (ret < 0) {
 		if (errno != EAGAIN)
-			LOGP(DINP, LOGL_ERROR, "recv error  %s\n", strerror(errno));
+			LOGP(DLINP, LOGL_ERROR, "recv error  %s\n", strerror(errno));
 		msgb_free(msg);
 		return ret;
 	}
 	if (ret == 0) {
-		DEBUGP(DINP, "UDP peer disappeared, dead socket\n");
+		DEBUGP(DLINP, "UDP peer disappeared, dead socket\n");
 		osmo_fd_unregister(bfd);
 		close(bfd->fd);
 		bfd->fd = -1;
@@ -223,16 +223,16 @@
 		return -EIO;
 	}
 	if (ret < sizeof(*hh)) {
-		DEBUGP(DINP, "could not even read header!?!\n");
+		DEBUGP(DLINP, "could not even read header!?!\n");
 		msgb_free(msg);
 		return -EIO;
 	}
 	msgb_put(msg, ret);
 	msg->l2h = msg->data + sizeof(*hh);
-	DEBUGP(DMI, "UDP RX: %s\n", osmo_hexdump(msg->data, msg->len));
+	DEBUGP(DLMI, "UDP RX: %s\n", osmo_hexdump(msg->data, msg->len));
 
 	if (hh->len != msg->len - sizeof(*hh)) {
-		DEBUGP(DINP, "length (%u/%u) disagrees with header(%u)\n",
+		DEBUGP(DLINP, "length (%u/%u) disagrees with header(%u)\n",
 			msg->len, msg->len - 3, hh->len);
 		msgb_free(msg);
 		return -EIO;
@@ -247,7 +247,7 @@
 			other_conn = ipbc->rsl_conn[0];
 			break;
 		default:
-			DEBUGP(DINP, "Unknown protocol 0x%02x, sending to "
+			DEBUGP(DLINP, "Unknown protocol 0x%02x, sending to "
 				"OML FD\n", hh->proto);
 			/* fall through */
 		case IPAC_PROTO_IPACCESS:
@@ -264,7 +264,7 @@
 			other_conn = ipbc->bsc_rsl_conn[0];
 			break;
 		default:
-			DEBUGP(DINP, "Unknown protocol 0x%02x, sending to "
+			DEBUGP(DLINP, "Unknown protocol 0x%02x, sending to "
 				"OML FD\n", hh->proto);
 		case IPAC_PROTO_IPACCESS:
 		case IPAC_PROTO_OML:
@@ -273,7 +273,7 @@
 		}
 		break;
 	default:
-		DEBUGP(DINP, "Unknown filedescriptor priv_nr=%04x\n", bfd->priv_nr);
+		DEBUGP(DLINP, "Unknown filedescriptor priv_nr=%04x\n", bfd->priv_nr);
 		break;
 	}
 
@@ -323,12 +323,12 @@
 	sin.sin_family = AF_INET;
 	inet_aton(bsc_ipaddr, &sin.sin_addr);
 
-	DEBUGP(DINP, "(%u/%u/%u) New BTS connection: ",
+	DEBUGP(DLINP, "(%u/%u/%u) New BTS connection: ",
 		site_id, bts_id, trx_id);
 
 	/* OML needs to be established before RSL */
 	if ((bfd->priv_nr & 0xff) != OML_FROM_BTS) {
-		DEBUGPC(DINP, "Not a OML connection ?!?\n");
+		DEBUGPC(DLINP, "Not a OML connection ?!?\n");
 		return -EIO;
 	}
 
@@ -339,7 +339,7 @@
 		goto err_out;
 	}
 
-	DEBUGPC(DINP, "Created BTS Conn data structure\n");
+	DEBUGPC(DLINP, "Created BTS Conn data structure\n");
 	ipbc->ipp = ipp;
 	ipbc->unit_id.site_id = site_id;
 	ipbc->unit_id.bts_id = bts_id;
@@ -360,7 +360,7 @@
 		goto err_bsc_conn;
 	}
 
-	DEBUGP(DINP, "(%u/%u/%u) OML Connected to BSC\n",
+	DEBUGP(DLINP, "(%u/%u/%u) OML Connected to BSC\n",
 		site_id, bts_id, trx_id);
 
 	/* Create UDP socket for BTS packet injection */
@@ -369,7 +369,7 @@
 			UDP_TO_BTS, udp_fd_cb, ipbc);
 	if (ret < 0)
 		goto err_udp_bts;
-	DEBUGP(DINP, "(%u/%u/%u) Created UDP socket for injection "
+	DEBUGP(DLINP, "(%u/%u/%u) Created UDP socket for injection "
 		"towards BTS at port %u\n", site_id, bts_id, trx_id, udp_port);
 
 	/* Create UDP socket for BSC packet injection */
@@ -378,7 +378,7 @@
 			UDP_TO_BSC, udp_fd_cb, ipbc);
 	if (ret < 0)
 		goto err_udp_bsc;
-	DEBUGP(DINP, "(%u/%u/%u) Created UDP socket for injection "
+	DEBUGP(DLINP, "(%u/%u/%u) Created UDP socket for injection "
 		"towards BSC at port %u\n", site_id, bts_id, trx_id, udp_port);
 
 
@@ -394,13 +394,13 @@
 		ret = make_sock(&ipbc->gprs_ns_fd, IPPROTO_UDP, ip, 0, 0,
 				gprs_ns_cb, ipbc);
 		if (ret < 0) {
-			LOGP(DINP, LOGL_ERROR, "Creating the GPRS socket failed.\n");
+			LOGP(DLINP, LOGL_ERROR, "Creating the GPRS socket failed.\n");
 			goto err_udp_bsc;
 		}
 
 		ret = getsockname(ipbc->gprs_ns_fd.fd, (struct sockaddr* ) &sock, &len);
 		ipbc->gprs_local_port = ntohs(sock.sin_port);
-		LOGP(DINP, LOGL_NOTICE,
+		LOGP(DLINP, LOGL_NOTICE,
 			"Created GPRS NS Socket. Listening on: %s:%d\n",
 			inet_ntoa(sock.sin_addr), ipbc->gprs_local_port);
 
@@ -445,17 +445,17 @@
 		ret = ipaccess_send_pong(bfd->fd);
 		break;
 	case IPAC_MSGT_PONG:
-		DEBUGP(DMI, "PONG!\n");
+		DEBUGP(DLMI, "PONG!\n");
 		break;
 	case IPAC_MSGT_ID_RESP:
-		DEBUGP(DMI, "ID_RESP ");
+		DEBUGP(DLMI, "ID_RESP ");
 		/* parse tags, search for Unit ID */
 		ipaccess_idtag_parse(&tlvp, (uint8_t *)msg->l2h + 2,
 				     msgb_l2len(msg)-2);
-		DEBUGP(DMI, "\n");
+		DEBUGP(DLMI, "\n");
 
 		if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT)) {
-			LOGP(DINP, LOGL_ERROR, "No Unit ID in ID RESPONSE !?!\n");
+			LOGP(DLINP, LOGL_ERROR, "No Unit ID in ID RESPONSE !?!\n");
 			return -EIO;
 		}
 
@@ -479,17 +479,17 @@
 			sin.sin_family = AF_INET;
 			inet_aton(bsc_ipaddr, &sin.sin_addr);
 
-			DEBUGP(DINP, "Identified BTS %u/%u/%u\n",
+			DEBUGP(DLINP, "Identified BTS %u/%u/%u\n",
 				site_id, bts_id, trx_id);
 
 			if ((bfd->priv_nr & 0xff) != RSL_FROM_BTS) {
-				LOGP(DINP, LOGL_ERROR, "Second OML connection from "
+				LOGP(DLINP, LOGL_ERROR, "Second OML connection from "
 				     "same BTS ?!?\n");
 				return 0;
 			}
 
 			if (trx_id >= MAX_TRX) {
-				LOGP(DINP, LOGL_ERROR, "We don't support more "
+				LOGP(DLINP, LOGL_ERROR, "We don't support more "
 				     "than %u TRX\n", MAX_TRX);
 				return -EINVAL;
 			}
@@ -505,30 +505,30 @@
 				connect_bsc(&sin, RSL_TO_BSC | (trx_id << 8), ipbc);
 			if (!ipbc->bsc_oml_conn)
 				return -EIO;
-			DEBUGP(DINP, "(%u/%u/%u) Connected RSL to BSC\n",
+			DEBUGP(DLINP, "(%u/%u/%u) Connected RSL to BSC\n",
 				site_id, bts_id, trx_id);
 		}
 		break;
 	case IPAC_MSGT_ID_GET:
-		DEBUGP(DMI, "ID_GET\n");
+		DEBUGP(DLMI, "ID_GET\n");
 		if ((bfd->priv_nr & 0xff) != OML_TO_BSC &&
 		    (bfd->priv_nr & 0xff) != RSL_TO_BSC) {
-			DEBUGP(DINP, "IDentity REQuest from BTS ?!?\n");
+			DEBUGP(DLINP, "IDentity REQuest from BTS ?!?\n");
 			return -EIO;
 		}
 		ipbc = ipc->bts_conn;
 		if (!ipbc) {
-			DEBUGP(DINP, "ID_GET from BSC before we have ID_RESP from BTS\n");
+			DEBUGP(DLINP, "ID_GET from BSC before we have ID_RESP from BTS\n");
 			return -EIO;
 		}
 		ret = write(bfd->fd, ipbc->id_resp, ipbc->id_resp_len);
 		break;
 	case IPAC_MSGT_ID_ACK:
-		DEBUGP(DMI, "ID_ACK? -> ACK!\n");
+		DEBUGP(DLMI, "ID_ACK? -> ACK!\n");
 		ret = ipaccess_send_id_ack(bfd->fd);
 		break;
 	default:
-		LOGP(DMI, LOGL_ERROR, "Unhandled IPA type; %d\n", msg_type);
+		LOGP(DLMI, LOGL_ERROR, "Unhandled IPA type; %d\n", msg_type);
 		return 1;
 		break;
 	}
@@ -551,7 +551,7 @@
 	ret = recv(bfd->fd, msg->data, 3, 0);
 	if (ret < 0) {
 		if (errno != EAGAIN)
-			LOGP(DINP, LOGL_ERROR, "recv error: %s\n", strerror(errno));
+			LOGP(DLINP, LOGL_ERROR, "recv error: %s\n", strerror(errno));
 		msgb_free(msg);
 		*error = ret;
 		return NULL;
@@ -568,7 +568,7 @@
 	len = ntohs(hh->len);
 	ret = recv(bfd->fd, msg->l2h, len, 0);
 	if (ret < len) {
-		LOGP(DINP, LOGL_ERROR, "short read!\n");
+		LOGP(DLINP, LOGL_ERROR, "short read!\n");
 		msgb_free(msg);
 		*error = -EIO;
 		return NULL;
@@ -611,7 +611,7 @@
 	struct sockaddr_in sin;
 	int i;
 
-	DEBUGP(DINP, "Running reconnect timer\n");
+	DEBUGP(DLINP, "Running reconnect timer\n");
 
 	memset(&sin, 0, sizeof(sin));
 	sin.sin_family = AF_INET;
@@ -621,13 +621,13 @@
 		/* if OML to BSC is dead, try to restore it */
 		if (ipbc->oml_conn && !ipbc->bsc_oml_conn) {
 			sin.sin_port = htons(IPA_TCP_PORT_OML);
-			logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, 0);
-			LOGPC(DINP, LOGL_NOTICE, "OML Trying to reconnect\n");
+			logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, 0);
+			LOGPC(DLINP, LOGL_NOTICE, "OML Trying to reconnect\n");
 			ipbc->bsc_oml_conn = connect_bsc(&sin, OML_TO_BSC, ipbc);
 			if (!ipbc->bsc_oml_conn)
 				goto reschedule;
-			logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, 0);
-			LOGPC(DINP, LOGL_NOTICE, "OML Reconnected\n");
+			logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, 0);
+			LOGPC(DLINP, LOGL_NOTICE, "OML Reconnected\n");
 		}
 		/* if we (still) don't have a OML connection, skip RSL */
 		if (!ipbc->oml_conn || !ipbc->bsc_oml_conn)
@@ -644,13 +644,13 @@
 			priv_nr &= ~0xff;
 			priv_nr |= RSL_TO_BSC;
 			sin.sin_port = htons(IPA_TCP_PORT_RSL);
-			logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, priv_nr >> 8);
-			LOGPC(DINP, LOGL_NOTICE, "RSL Trying to reconnect\n");
+			logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, priv_nr >> 8);
+			LOGPC(DLINP, LOGL_NOTICE, "RSL Trying to reconnect\n");
 			ipbc->bsc_rsl_conn[i] = connect_bsc(&sin, priv_nr, ipbc);
 			if (!ipbc->bsc_rsl_conn)
 				goto reschedule;
-			logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, priv_nr >> 8);
-			LOGPC(DINP, LOGL_NOTICE, "RSL Reconnected\n");
+			logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, priv_nr >> 8);
+			LOGPC(DLINP, LOGL_NOTICE, "RSL Reconnected\n");
 		}
 	}
 	return;
@@ -778,8 +778,8 @@
 	msg = ipaccess_proxy_read_msg(bfd, &ret);
 	if (!msg) {
 		if (ret == 0) {
-			logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, bfd->priv_nr >> 8);
-			LOGPC(DINP, LOGL_NOTICE, "%s disappeared, "
+			logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, bfd->priv_nr >> 8);
+			LOGPC(DLINP, LOGL_NOTICE, "%s disappeared, "
 			     "dead socket\n", btsbsc);
 			handle_dead_socket(bfd);
 		}
@@ -787,8 +787,8 @@
 	}
 
 	msgb_put(msg, ret);
-	logp_ipbc_uid(DMI, LOGL_DEBUG, ipbc, bfd->priv_nr >> 8);
-	DEBUGPC(DMI, "RX<-%s: %s\n", btsbsc, osmo_hexdump(msg->data, msg->len));
+	logp_ipbc_uid(DLMI, LOGL_DEBUG, ipbc, bfd->priv_nr >> 8);
+	DEBUGPC(DLMI, "RX<-%s: %s\n", btsbsc, osmo_hexdump(msg->data, msg->len));
 
 	hh = (struct ipaccess_head *) msg->data;
 	if (hh->proto == IPAC_PROTO_IPACCESS) {
@@ -809,7 +809,7 @@
 	}
 
 	if (!ipbc) {
-		LOGP(DINP, LOGL_ERROR,
+		LOGP(DLINP, LOGL_ERROR,
 		     "received %s packet but no ipc->bts_conn?!?\n", btsbsc);
 		msgb_free(msg);
 		return -EIO;
@@ -824,8 +824,8 @@
 		/* mark respective filedescriptor as 'we want to write' */
 		bsc_conn->fd.when |= BSC_FD_WRITE;
 	} else {
-		logp_ipbc_uid(DINP, LOGL_INFO, ipbc, bfd->priv_nr >> 8);
-		LOGPC(DINP, LOGL_INFO, "Dropping packet from %s, "
+		logp_ipbc_uid(DLINP, LOGL_INFO, ipbc, bfd->priv_nr >> 8);
+		LOGPC(DLINP, LOGL_INFO, "Dropping packet from %s, "
 		     "since remote connection is dead\n", btsbsc);
 		msgb_free(msg);
 	}
@@ -858,16 +858,16 @@
 	llist_del(lh);
 	msg = llist_entry(lh, struct msgb, list);
 
-	logp_ipbc_uid(DMI, LOGL_DEBUG, ipbc, bfd->priv_nr >> 8);
-	DEBUGPC(DMI, "TX %04x: %s\n", bfd->priv_nr,
+	logp_ipbc_uid(DLMI, LOGL_DEBUG, ipbc, bfd->priv_nr >> 8);
+	DEBUGPC(DLMI, "TX %04x: %s\n", bfd->priv_nr,
 		osmo_hexdump(msg->data, msg->len));
 
 	ret = send(bfd->fd, msg->data, msg->len, 0);
 	msgb_free(msg);
 
 	if (ret == 0) {
-		logp_ipbc_uid(DINP, LOGL_NOTICE, ipbc, bfd->priv_nr >> 8);
-		LOGP(DINP, LOGL_NOTICE, "%s disappeared, dead socket\n", btsbsc);
+		logp_ipbc_uid(DLINP, LOGL_NOTICE, ipbc, bfd->priv_nr >> 8);
+		LOGP(DLINP, LOGL_NOTICE, "%s disappeared, dead socket\n", btsbsc);
 		handle_dead_socket(bfd);
 	}
 
@@ -907,7 +907,7 @@
 		perror("accept");
 		return ret;
 	}
-	DEBUGP(DINP, "accept()ed new %s link from %s\n",
+	DEBUGP(DLINP, "accept()ed new %s link from %s\n",
 		(listen_bfd->priv_nr & 0xff) == OML_FROM_BTS ? "OML" : "RSL",
 		inet_ntoa(sa.sin_addr));
 
@@ -925,7 +925,7 @@
 	bfd->when = BSC_FD_READ;
 	ret = osmo_fd_register(bfd);
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not register FD\n");
+		LOGP(DLINP, LOGL_ERROR, "could not register FD\n");
 		close(bfd->fd);
 		talloc_free(ipc);
 		return ret;
@@ -950,7 +950,7 @@
 
 	ret = sendto(fd, buf, size, 0, (struct sockaddr *) &addr, len);
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to forward GPRS message.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to forward GPRS message.\n");
 	}
 }
 
@@ -965,7 +965,7 @@
 	/* 1. get the data... */
 	ret = recvfrom(bfd->fd, buf, sizeof(buf), 0, (struct sockaddr *) &sock, &len);
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to recv GPRS NS msg: %s.\n", strerror(errno));
+		LOGP(DLINP, LOGL_ERROR, "Failed to recv GPRS NS msg: %s.\n", strerror(errno));
 		return -1;
 	}
 
@@ -973,13 +973,13 @@
 
 	/* 2. figure out where to send it to */
 	if (memcmp(&sock.sin_addr, &ipp->gprs_addr, sizeof(sock.sin_addr)) == 0) {
-		LOGP(DINP, LOGL_DEBUG, "GPRS NS msg from network.\n");
+		LOGP(DLINP, LOGL_DEBUG, "GPRS NS msg from network.\n");
 		send_ns(bfd->fd, buf, ret, bts->bts_addr, 23000);
 	} else if (memcmp(&sock.sin_addr, &bts->bts_addr, sizeof(sock.sin_addr)) == 0) {
-		LOGP(DINP, LOGL_DEBUG, "GPRS NS msg from BTS.\n");
+		LOGP(DLINP, LOGL_DEBUG, "GPRS NS msg from BTS.\n");
 		send_ns(bfd->fd, buf, ret, ipp->gprs_addr, 23000);
 	} else {
-		LOGP(DINP, LOGL_ERROR, "Unknown GPRS source: %s\n", inet_ntoa(sock.sin_addr));
+		LOGP(DLINP, LOGL_ERROR, "Unknown GPRS source: %s\n", inet_ntoa(sock.sin_addr));
 	}
 
 	return 0;
@@ -1009,7 +1009,7 @@
 
 	ret = connect(bfd->fd, (struct sockaddr *) sa, sizeof(*sa));
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "Could not connect socket: %s\n",
+		LOGP(DLINP, LOGL_ERROR, "Could not connect socket: %s\n",
 		     inet_ntoa(sa->sin_addr));
 		close(bfd->fd);
 		talloc_free(ipc);
@@ -1184,7 +1184,7 @@
 	tall_bsc_ctx = talloc_named_const(NULL, 1, "ipaccess-proxy");
 
 	osmo_init_logging(&log_info);
-	log_parse_category_mask(osmo_stderr_target, "DINP:DMI");
+	log_parse_category_mask(osmo_stderr_target, "DLINP:DLMI");
 
 	handle_options(argc, argv);
 
diff --git a/openbsc/src/ipaccess/network_listen.c b/openbsc/src/ipaccess/network_listen.c
index 71b49ea..6749c4a 100644
--- a/openbsc/src/ipaccess/network_listen.c
+++ b/openbsc/src/ipaccess/network_listen.c
@@ -37,7 +37,7 @@
 #include <openbsc/abis_nm.h>
 #include <openbsc/signal.h>
 #include <openbsc/debug.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 
 #define WHITELIST_MAX_SIZE ((NUM_ARFCNS*2)+2+1)
 
diff --git a/openbsc/src/libabis/Makefile.am b/openbsc/src/libabis/Makefile.am
deleted file mode 100644
index ffaa201..0000000
--- a/openbsc/src/libabis/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
-
-noinst_LIBRARIES = libabis.a
-
-libabis_a_SOURCES = e1_input.c e1_input_vty.c \
-			input/misdn.c		\
-			input/ipaccess.c	\
-			input/hsl.c		\
-			input/dahdi.c		\
-			input/lapd.c
-
-EXTRA_DIST = input/lapd.h
diff --git a/openbsc/src/libabis/e1_input.c b/openbsc/src/libabis/e1_input.c
deleted file mode 100644
index eab418a..0000000
--- a/openbsc/src/libabis/e1_input.c
+++ /dev/null
@@ -1,689 +0,0 @@
-/* OpenBSC Abis interface to E1 */
-
-/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <mISDNif.h>
-
-//#define AF_COMPATIBILITY_FUNC
-//#include <compat_af_isdn.h>
-#ifndef AF_ISDN
-#define AF_ISDN 34
-#define PF_ISDN AF_ISDN
-#endif
-
-#include <osmocom/core/select.h>
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/rate_ctr.h>
-
-#include <openbsc/debug.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/e1_input.h>
-#include <openbsc/abis_nm.h>
-#include <openbsc/abis_rsl.h>
-#include <openbsc/subchan_demux.h>
-#include <openbsc/trau_frame.h>
-#include <openbsc/trau_mux.h>
-#include <openbsc/signal.h>
-#include <openbsc/misdn.h>
-
-#include "../../bscconfig.h"
-
-#define NUM_E1_TS	32
-
-/* list of all E1 drivers */
-LLIST_HEAD(e1inp_driver_list);
-
-/* list of all E1 lines */
-LLIST_HEAD(e1inp_line_list);
-
-static void *tall_sigl_ctx;
-
-static const struct rate_ctr_desc e1inp_ctr_d[] = {
-	[E1I_CTR_HDLC_ABORT]  = {
-		"hdlc.abort", 	"HDLC abort"
-	},
-	[E1I_CTR_HDLC_BADFCS] = {
-		"hdlc.bad_fcs",	"HLDC Bad FCS"
-	},
-	[E1I_CTR_HDLC_OVERR]  = {
-		"hdlc.overrun",	"HDLC Overrun"
-	},
-	[E1I_CTR_ALARM] = {
-		"alarm", 	"Alarm"
-	},
-	[E1I_CTR_REMOVED] = {
-		"removed", 	"Line removed"
-	},
-};
-
-static const struct rate_ctr_group_desc e1inp_ctr_g_d = {
-	.group_name_prefix = "e1inp",
-	.group_description = "E1 Input subsystem",
-	.num_ctr = ARRAY_SIZE(e1inp_ctr_d),
-	.ctr_desc = e1inp_ctr_d,
-};
-
-/*
- * pcap writing of the misdn load
- * pcap format is from http://wiki.wireshark.org/Development/LibpcapFileFormat
- */
-#define DLT_LINUX_LAPD		177
-#define PCAP_INPUT		0
-#define PCAP_OUTPUT		1
-
-struct pcap_hdr {
-	uint32_t magic_number;
-	uint16_t version_major;
-	uint16_t version_minor;
-	int32_t  thiszone;
-	uint32_t sigfigs;
-	uint32_t snaplen;
-	uint32_t network;
-} __attribute__((packed));
-
-struct pcaprec_hdr {
-	uint32_t ts_sec;
-	uint32_t ts_usec;
-	uint32_t incl_len;
-	uint32_t orig_len;
-} __attribute__((packed));
-
-struct fake_linux_lapd_header {
-        uint16_t pkttype;
-	uint16_t hatype;
-	uint16_t halen;
-	uint64_t addr;
-	int16_t protocol;
-} __attribute__((packed));
-
-struct lapd_header {
-	uint8_t ea1 : 1;
-	uint8_t cr : 1;
-	uint8_t sapi : 6;
-	uint8_t ea2 : 1;
-	uint8_t tei : 7;
-	uint8_t control_foo; /* fake UM's ... */
-} __attribute__((packed));
-
-osmo_static_assert(offsetof(struct fake_linux_lapd_header, hatype) == 2,    hatype_offset);
-osmo_static_assert(offsetof(struct fake_linux_lapd_header, halen) == 4,     halen_offset);
-osmo_static_assert(offsetof(struct fake_linux_lapd_header, addr) == 6,      addr_offset);
-osmo_static_assert(offsetof(struct fake_linux_lapd_header, protocol) == 14, proto_offset);
-osmo_static_assert(sizeof(struct fake_linux_lapd_header) == 16,	       lapd_header_size);
-
-
-static int pcap_fd = -1;
-
-void e1_set_pcap_fd(int fd)
-{
-	int ret;
-	struct pcap_hdr header = {
-		.magic_number	= 0xa1b2c3d4,
-		.version_major	= 2,
-		.version_minor	= 4,
-		.thiszone	= 0,
-		.sigfigs	= 0,
-		.snaplen	= 65535,
-		.network	= DLT_LINUX_LAPD,
-	};
-
-	pcap_fd = fd;
-	ret = write(pcap_fd, &header, sizeof(header));
-}
-
-/* This currently only works for the D-Channel */
-static void write_pcap_packet(int direction, int sapi, int tei,
-			      struct msgb *msg) {
-	if (pcap_fd < 0)
-		return;
-
-	int ret;
-	time_t cur_time;
-	struct tm *tm;
-
-	struct fake_linux_lapd_header header = {
-		.pkttype	= 4,
-		.hatype		= 0,
-		.halen		= 0,
-		.addr		= direction == PCAP_OUTPUT ? 0x0 : 0x1,
-		.protocol	= ntohs(48),
-	};
-
-	struct lapd_header lapd_header = {
-		.ea1		= 0,
-		.cr		= direction == PCAP_OUTPUT ? 1 : 0,
-		.sapi		= sapi & 0x3F,
-		.ea2		= 1,
-		.tei		= tei & 0x7F,
-		.control_foo	= 0x03 /* UI */,
-	};	
-
-	struct pcaprec_hdr payload_header = {
-		.ts_sec	    = 0,
-		.ts_usec    = 0,
-		.incl_len   = msgb_l2len(msg) + sizeof(struct fake_linux_lapd_header)
-				+ sizeof(struct lapd_header),
-		.orig_len   = msgb_l2len(msg) + sizeof(struct fake_linux_lapd_header)
-				+ sizeof(struct lapd_header),
-	};
-
-
-	cur_time = time(NULL);
-	tm = localtime(&cur_time);
-	payload_header.ts_sec = mktime(tm);
-
-	ret = write(pcap_fd, &payload_header, sizeof(payload_header));
-	ret = write(pcap_fd, &header, sizeof(header));
-	ret = write(pcap_fd, &lapd_header, sizeof(lapd_header));
-	ret = write(pcap_fd, msg->l2h, msgb_l2len(msg));
-}
-
-static const char *sign_types[] = {
-	[E1INP_SIGN_NONE]	= "None",
-	[E1INP_SIGN_OML]	= "OML",
-	[E1INP_SIGN_RSL]	= "RSL",
-};
-const char *e1inp_signtype_name(enum e1inp_sign_type tp)
-{
-	if (tp >= ARRAY_SIZE(sign_types))
-		return "undefined";
-	return sign_types[tp];
-}
-
-static const char *ts_types[] = {
-	[E1INP_TS_TYPE_NONE]	= "None",
-	[E1INP_TS_TYPE_SIGN]	= "Signalling",
-	[E1INP_TS_TYPE_TRAU]	= "TRAU",
-};
-
-const char *e1inp_tstype_name(enum e1inp_ts_type tp)
-{
-	if (tp >= ARRAY_SIZE(ts_types))
-		return "undefined";
-	return ts_types[tp];
-}
-
-/* callback when a TRAU frame was received */
-static int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len,
-		    void *_priv)
-{
-	struct e1inp_ts *e1i_ts = _priv;
-	struct gsm_e1_subslot src_ss;
-
-	src_ss.e1_nr = e1i_ts->line->num;
-	src_ss.e1_ts = e1i_ts->num;
-	src_ss.e1_ts_ss = ch;
-
-	return trau_mux_input(&src_ss, data, len);
-}
-
-int abis_sendmsg(struct msgb *msg)
-{
-	struct e1inp_sign_link *sign_link = msg->dst;
-	struct e1inp_driver *e1inp_driver;
-	struct e1inp_ts *e1i_ts;
-
-	msg->l2h = msg->data;
-
-	/* don't know how to route this message. */
-	if (sign_link == NULL) {
-		LOGP(DLINP, LOGL_ERROR, "abis_sendmsg: msg->dst == NULL: %s\n",
-			osmo_hexdump(msg->data, msg->len));
-		talloc_free(msg);
-		return -EINVAL;
-	}
-	e1i_ts = sign_link->ts;
-	if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) {
-		/* notify the driver we have something to write */
-		e1inp_driver = sign_link->ts->line->driver;
-		e1inp_driver->want_write(e1i_ts);
-	}
-	msgb_enqueue(&sign_link->tx_list, msg);
-
-	/* dump it */
-	write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg);
-
-	return 0;
-}
-
-int abis_rsl_sendmsg(struct msgb *msg)
-{
-	struct e1inp_sign_link *sign_link = (struct e1inp_sign_link *)msg->dst;
-	struct e1inp_driver *e1inp_driver;
-	struct e1inp_ts *e1i_ts;
-
-	msg->l2h = msg->data;
-
-	if (!sign_link) {
-		LOGP(DRSL, LOGL_ERROR, "rsl_sendmsg: msg->dst == NULL: %s\n",
-			osmo_hexdump(msg->data, msg->len));
-		talloc_free(msg);
-		return -EINVAL;
-	}
-	e1i_ts = sign_link->ts;
-	if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) {
-		/* notify the driver we have something to write */
-		e1inp_driver = sign_link->ts->line->driver;
-		e1inp_driver->want_write(e1i_ts);
-	}
-	msgb_enqueue(&sign_link->tx_list, msg);
-
-	/* dump it */
-	write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg);
-
-	return 0;
-}
-
-int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml)
-{
-	struct e1inp_sign_link *sign_link = msg->dst;
-
-	msg->l2h = msg->data;
-
-	if (!msg->dst) {
-		LOGP(DNM, LOGL_ERROR, "_abis_nm_sendmsg: msg->dst == NULL\n");
-		return -EINVAL;
-	}
-
-	/* Check for TRX-specific OML link first */
-	if (to_trx_oml) {
-		if (!sign_link->trx->oml_link)
-			return -ENODEV;
-		msg->dst = sign_link->trx->oml_link;
-	}
-	return abis_sendmsg(msg);
-}
-
-/* Timeslot */
-
-/* configure and initialize one e1inp_ts */
-int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
-		    enum e1inp_ts_type type)
-{
-	if (ts->type == type && ts->line && line)
-		return 0;
-
-	ts->type = type;
-	ts->line = line;
-
-	switch (type) {
-	case E1INP_TS_TYPE_SIGN:
-		if (line && line->driver)
-			ts->sign.delay = line->driver->default_delay;
-		else
-			ts->sign.delay = 100000;
-		INIT_LLIST_HEAD(&ts->sign.sign_links);
-		break;
-	case E1INP_TS_TYPE_TRAU:
-		subchan_mux_init(&ts->trau.mux);
-		ts->trau.demux.out_cb = subch_cb;
-		ts->trau.demux.data = ts;
-		subch_demux_init(&ts->trau.demux);
-		break;
-	default:
-		LOGP(DMI, LOGL_ERROR, "unsupported E1 timeslot type %u\n",
-			ts->type);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-struct e1inp_line *e1inp_line_get(uint8_t e1_nr)
-{
-	struct e1inp_line *e1i_line;
-
-	/* iterate over global list of e1 lines */
-	llist_for_each_entry(e1i_line, &e1inp_line_list, list) {
-		if (e1i_line->num == e1_nr)
-			return e1i_line;
-	}
-	return NULL;
-}
-
-struct e1inp_line *e1inp_line_create(uint8_t e1_nr, const char *driver_name)
-{
-	struct e1inp_driver *driver;
-	struct e1inp_line *line;
-	int i;
-
-	line = e1inp_line_get(e1_nr);
-	if (line) {
-		LOGP(DINP, LOGL_ERROR, "E1 Line %u already exists\n",
-		     e1_nr);
-		return NULL;
-	}
-
-	driver = e1inp_driver_find(driver_name);
-	if (!driver) {
-		LOGP(DINP, LOGL_ERROR, "No such E1 driver '%s'\n",
-		     driver_name);
-		return NULL;
-	}
-
-	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
-	if (!line)
-		return NULL;
-
-	line->driver = driver;
-	line->num = e1_nr;
-
-	line->rate_ctr = rate_ctr_group_alloc(line, &e1inp_ctr_g_d, line->num);
-
-	for (i = 0; i < NUM_E1_TS; i++) {
-		line->ts[i].num = i+1;
-		line->ts[i].line = line;
-	}
-	llist_add_tail(&line->list, &e1inp_line_list);
-
-	return line;
-}
-
-#if 0
-struct e1inp_line *e1inp_line_get_create(uint8_t e1_nr)
-{
-	struct e1inp_line *line;
-	int i;
-
-	line = e1inp_line_get(e1_nr);
-	if (line)
-		return line;
-
-	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
-	if (!line)
-		return NULL;
-
-	line->num = e1_nr;
-	for (i = 0; i < NUM_E1_TS; i++) {
-		line->ts[i].num = i+1;
-		line->ts[i].line = line;
-	}
-	llist_add_tail(&line->list, &e1inp_line_list);
-
-	return line;
-}
-#endif
-
-static struct e1inp_ts *e1inp_ts_get(uint8_t e1_nr, uint8_t ts_nr)
-{
-	struct e1inp_line *e1i_line;
-
-	e1i_line = e1inp_line_get(e1_nr);
-	if (!e1i_line)
-		return NULL;
-
-	return &e1i_line->ts[ts_nr-1];
-}
-
-struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr)
-{
-	struct e1inp_ts *e1i_ts = e1inp_ts_get(e1_nr, ts_nr);
-
-	if (!e1i_ts)
-		return NULL;
-
-	return &e1i_ts->trau.mux;
-}
-
-/* Signalling Link */
-
-struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i,
-						uint8_t tei, uint8_t sapi)
-{
-	struct e1inp_sign_link *link;
-
-	llist_for_each_entry(link, &e1i->sign.sign_links, list) {
-		if (link->sapi == sapi && link->tei == tei)
-			return link;
-	}
-
-	return NULL;
-}
-
-/* create a new signalling link in a E1 timeslot */
-
-struct e1inp_sign_link *
-e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
-			struct gsm_bts_trx *trx, uint8_t tei,
-			uint8_t sapi)
-{
-	struct e1inp_sign_link *link;
-
-	if (ts->type != E1INP_TS_TYPE_SIGN)
-		return NULL;
-
-	link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link);
-	if (!link)
-		return NULL;
-
-	link->ts = ts;
-	link->type = type;
-	INIT_LLIST_HEAD(&link->tx_list);
-	link->trx = trx;
-	link->tei = tei;
-	link->sapi = sapi;
-
-	llist_add_tail(&link->list, &ts->sign.sign_links);
-
-	return link;
-}
-
-void e1inp_sign_link_destroy(struct e1inp_sign_link *link)
-{
-	struct msgb *msg;
-
-	llist_del(&link->list);
-	while (!llist_empty(&link->tx_list)) {
-		msg = msgb_dequeue(&link->tx_list);
-		msgb_free(msg);
-	}
-
-	if (link->ts->type == E1INP_TS_TYPE_SIGN)
-		osmo_timer_del(&link->ts->sign.tx_timer);
-
-	talloc_free(link);
-}
-
-/* the E1 driver tells us he has received something on a TS */
-int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
-		uint8_t tei, uint8_t sapi)
-{
-	struct e1inp_sign_link *link;
-	struct gsm_bts *bts;
-	int ret;
-
-	switch (ts->type) {
-	case E1INP_TS_TYPE_SIGN:
-		/* consult the list of signalling links */
-		write_pcap_packet(PCAP_INPUT, sapi, tei, msg);
-		link = e1inp_lookup_sign_link(ts, tei, sapi);
-		if (!link) {
-			LOGP(DMI, LOGL_ERROR, "didn't find signalling link for "
-				"tei %d, sapi %d\n", tei, sapi);
-			return -EINVAL;
-		}
-
-		log_set_context(BSC_CTX_BTS, link->trx->bts);
-		switch (link->type) {
-		case E1INP_SIGN_OML:
-			msg->dst = link;
-			bts = link->trx->bts;
-			ret = bts->model->oml_rcvmsg(msg);
-			break;
-		case E1INP_SIGN_RSL:
-			msg->dst = link;
-			ret = abis_rsl_rcvmsg(msg);
-			break;
-		default:
-			ret = -EINVAL;
-			LOGP(DMI, LOGL_ERROR, "unknown link type %u\n", link->type);
-			break;
-		}
-		break;
-	case E1INP_TS_TYPE_TRAU:
-		ret = subch_demux_in(&ts->trau.demux, msg->l2h, msgb_l2len(msg));
-		break;
-	default:
-		ret = -EINVAL;
-		LOGP(DMI, LOGL_ERROR, "unknown TS type %u\n", ts->type);
-		break;
-	}
-
-	return ret;
-}
-
-#define TSX_ALLOC_SIZE 4096
-
-/* called by driver if it wants to transmit on a given TS */
-struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
-			 struct e1inp_sign_link **sign_link)
-{
-	struct e1inp_sign_link *link;
-	struct msgb *msg = NULL;
-	int len;
-
-	switch (e1i_ts->type) {
-	case E1INP_TS_TYPE_SIGN:
-		/* FIXME: implement this round robin */
-		llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) {
-			msg = msgb_dequeue(&link->tx_list);
-			if (msg) {
-				if (sign_link)
-					*sign_link = link;
-				break;
-			}
-		}
-		break;
-	case E1INP_TS_TYPE_TRAU:
-		msg = msgb_alloc(TSX_ALLOC_SIZE, "TRAU_TX");
-		if (!msg)
-			return NULL;
-		len = subchan_mux_out(&e1i_ts->trau.mux, msg->data, 40);
-		msgb_put(msg, 40);
-		break;
-	default:
-		LOGP(DMI, LOGL_ERROR, "unsupported E1 TS type %u\n", e1i_ts->type);
-		return NULL;
-	}
-	return msg;
-}
-
-/* called by driver in case some kind of link state event */
-int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi)
-{
-	struct e1inp_sign_link *link;
-	struct input_signal_data isd;
-
-	link = e1inp_lookup_sign_link(ts, tei, sapi);
-	if (!link)
-		return -EINVAL;
-
-	isd.line = ts->line;
-	isd.link_type = link->type;
-	isd.trx = link->trx;
-	isd.tei = tei;
-	isd.sapi = sapi;
-
-	/* report further upwards */
-	osmo_signal_dispatch(SS_INPUT, evt, &isd);
-	return 0;
-}
-
-/* register a driver with the E1 core */
-int e1inp_driver_register(struct e1inp_driver *drv)
-{
-	llist_add_tail(&drv->list, &e1inp_driver_list);
-	return 0;
-}
-
-struct e1inp_driver *e1inp_driver_find(const char *name)
-{
-	struct e1inp_driver *drv;
-
-	llist_for_each_entry(drv, &e1inp_driver_list, list) {
-		if (!strcasecmp(name, drv->name))
-			return drv;
-	}
-	return NULL;
-}
-
-int e1inp_line_update(struct e1inp_line *line)
-{
-	struct input_signal_data isd;
-	int rc;
-
-	if (line->driver && line->driver->line_update)
-		rc = line->driver->line_update(line);
-	else
-		rc = 0;
-
-	/* Send a signal to anyone who is interested in new lines being
-	 * configured */
-	memset(&isd, 0, sizeof(isd));
-	isd.line = line;
-	osmo_signal_dispatch(SS_INPUT, S_INP_LINE_INIT, &isd);
-
-	return rc;
-}
-
-static int e1i_sig_cb(unsigned int subsys, unsigned int signal,
-		      void *handler_data, void *signal_data)
-{
-	if (subsys != SS_GLOBAL ||
-	    signal != S_GLOBAL_SHUTDOWN)
-		return 0;
-
-	if (pcap_fd) {
-		close(pcap_fd);
-		pcap_fd = -1;
-	}
-
-	return 0;
-}
-
-void e1inp_misdn_init(void);
-void e1inp_dahdi_init(void);
-void e1inp_ipaccess_init(void);
-void e1inp_hsl_init(void);
-
-void e1inp_init(void)
-{
-	tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
-					   "e1inp_sign_link");
-	osmo_signal_register_handler(SS_GLOBAL, e1i_sig_cb, NULL);
-
-	e1inp_misdn_init();
-#ifdef HAVE_DAHDI_USER_H
-	e1inp_dahdi_init();
-#endif
-	e1inp_ipaccess_init();
-	e1inp_hsl_init();
-}
diff --git a/openbsc/src/libabis/e1_input_vty.c b/openbsc/src/libabis/e1_input_vty.c
deleted file mode 100644
index eb34aa1..0000000
--- a/openbsc/src/libabis/e1_input_vty.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* OpenBSC E1 vty interface */
-/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/utils.h>
-#include <osmocom/gsm/gsm_utils.h>
-
-#include <osmocom/vty/command.h>
-#include <osmocom/vty/buffer.h>
-#include <osmocom/vty/vty.h>
-#include <osmocom/vty/logging.h>
-#include <osmocom/vty/misc.h>
-#include <osmocom/vty/telnet_interface.h>
-
-#include <openbsc/gsm_data.h>
-#include <openbsc/e1_input.h>
-#include <openbsc/vty.h>
-#include <openbsc/debug.h>
-
-#include "../../bscconfig.h"
-
-/* CONFIG */
-
-#define E1_DRIVER_NAMES		"(misdn|dahdi)"
-#define E1_DRIVER_HELP		"mISDN supported E1 Card\n" \
-				"DAHDI supported E1/T1/J1 Card\n"
-
-#define E1_LINE_HELP		"Configure E1/T1/J1 Line\n" "Line Number\n"
-
-DEFUN(cfg_e1line_driver, cfg_e1_line_driver_cmd,
-	"e1_line <0-255> driver " E1_DRIVER_NAMES,
-	E1_LINE_HELP "Set driver for this line\n"
-	E1_DRIVER_HELP)
-{
-	struct e1inp_line *line;
-	int e1_nr = atoi(argv[0]);
-
-	line = e1inp_line_get(e1_nr);
-	if (line) {
-		vty_out(vty, "%% Line %d already exists%s", e1_nr, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	line = e1inp_line_create(e1_nr, argv[1]);
-	if (!line) {
-		vty_out(vty, "%% Error creating line %d%s", e1_nr, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-
-	return CMD_SUCCESS;
-}
-
-DEFUN(cfg_e1line_name, cfg_e1_line_name_cmd,
-	"e1_line <0-255> name .LINE",
-	E1_LINE_HELP "Set name for this line\n" "Human readable name\n")
-{
-	struct e1inp_line *line;
-	int e1_nr = atoi(argv[0]);
-
-	line = e1inp_line_get(e1_nr);
-	if (!line) {
-		vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE);
-		return CMD_WARNING;
-	}
-	if (line->name) {
-		talloc_free((void *)line->name);
-		line->name = NULL;
-	}
-	line->name = talloc_strdup(line, argv[1]);
-
-	return CMD_SUCCESS;
-}
-
-DEFUN(cfg_e1inp, cfg_e1inp_cmd,
-	"e1_input",
-	"Configure E1/T1/J1 TDM input\n")
-{
-	vty->node = E1INP_NODE;
-
-	return CMD_SUCCESS;
-}
-
-static int e1inp_config_write(struct vty *vty)
-{
-	struct e1inp_line *line;
-
-	if (llist_empty(&e1inp_line_list))
-		return CMD_SUCCESS;
-
-	vty_out(vty, "e1_input%s", VTY_NEWLINE);
-
-	llist_for_each_entry(line, &e1inp_line_list, list) {
-		vty_out(vty, " e1_line %u driver %s%s", line->num,
-			line->driver->name, VTY_NEWLINE);
-		if (line->name)
-			vty_out(vty, " e1_line %u name %s%s", line->num,
-				line->name, VTY_NEWLINE);
-	}
-	return CMD_SUCCESS;
-}
-
-/* SHOW */
-
-static void e1drv_dump_vty(struct vty *vty, struct e1inp_driver *drv)
-{
-	vty_out(vty, "E1 Input Driver %s%s", drv->name, VTY_NEWLINE);
-}
-
-DEFUN(show_e1drv,
-      show_e1drv_cmd,
-      "show e1_driver",
-	SHOW_STR "Display information about available E1 drivers\n")
-{
-	struct e1inp_driver *drv;
-
-	llist_for_each_entry(drv, &e1inp_driver_list, list)
-		e1drv_dump_vty(vty, drv);
-
-	return CMD_SUCCESS;
-}
-
-static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line,
-			    int stats)
-{
-	vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s",
-		line->num, line->name ? line->name : "",
-		line->driver->name, VTY_NEWLINE);
-	if (stats)
-		vty_out_rate_ctr_group(vty, " ", line->rate_ctr);
-}
-
-DEFUN(show_e1line,
-      show_e1line_cmd,
-      "show e1_line [line_nr] [stats]",
-	SHOW_STR "Display information about a E1 line\n"
-	"E1 Line Number\n")
-{
-	struct e1inp_line *line;
-	int stats = 0;
-
-	if (argc >= 1 && strcmp(argv[0], "stats")) {
-		int num = atoi(argv[0]);
-		if (argc >= 2)
-			stats = 1;
-		llist_for_each_entry(line, &e1inp_line_list, list) {
-			if (line->num == num) {
-				e1line_dump_vty(vty, line, stats);
-				return CMD_SUCCESS;
-			}
-		}
-		return CMD_WARNING;
-	}
-
-	if (argc >= 1 && !strcmp(argv[0], "stats"))
-		stats = 1;
-
-	llist_for_each_entry(line, &e1inp_line_list, list)
-		e1line_dump_vty(vty, line, stats);
-
-	return CMD_SUCCESS;
-}
-
-static void e1ts_dump_vty(struct vty *vty, struct e1inp_ts *ts)
-{
-	if (ts->type == E1INP_TS_TYPE_NONE)
-		return;
-	vty_out(vty, "E1 Timeslot %2u of Line %u is Type %s%s",
-		ts->num, ts->line->num, e1inp_tstype_name(ts->type),
-		VTY_NEWLINE);
-}
-
-DEFUN(show_e1ts,
-      show_e1ts_cmd,
-      "show e1_timeslot [line_nr] [ts_nr]",
-	SHOW_STR "Display information about a E1 timeslot\n"
-	"E1 Line Number\n" "E1 Timeslot Number\n")
-{
-	struct e1inp_line *line = NULL;
-	struct e1inp_ts *ts;
-	int ts_nr;
-
-	if (argc == 0) {
-		llist_for_each_entry(line, &e1inp_line_list, list) {
-			for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
-				ts = &line->ts[ts_nr];
-				e1ts_dump_vty(vty, ts);
-			}
-		}
-		return CMD_SUCCESS;
-	}
-	if (argc >= 1) {
-		int num = atoi(argv[0]);
-		struct e1inp_line *l;
-		llist_for_each_entry(l, &e1inp_line_list, list) {
-			if (l->num == num) {
-				line = l;
-				break;
-			}
-		}
-		if (!line) {
-			vty_out(vty, "E1 line %s is invalid%s",
-				argv[0], VTY_NEWLINE);
-			return CMD_WARNING;
-		}
-	}
-	if (argc >= 2) {
-		ts_nr = atoi(argv[1]);
-		if (ts_nr >= NUM_E1_TS) {
-			vty_out(vty, "E1 timeslot %s is invalid%s",
-				argv[1], VTY_NEWLINE);
-			return CMD_WARNING;
-		}
-		ts = &line->ts[ts_nr];
-		e1ts_dump_vty(vty, ts);
-		return CMD_SUCCESS;
-	} else {
-		for (ts_nr = 0; ts_nr < NUM_E1_TS; ts_nr++) {
-			ts = &line->ts[ts_nr];
-			e1ts_dump_vty(vty, ts);
-		}
-		return CMD_SUCCESS;
-	}
-	return CMD_SUCCESS;
-}
-
-
-struct cmd_node e1inp_node = {
-	E1INP_NODE,
-	"%s(e1_input)#",
-	1,
-};
-
-int e1inp_vty_init(void)
-{
-	install_element(CONFIG_NODE, &cfg_e1inp_cmd);
-	install_node(&e1inp_node, e1inp_config_write);
-	install_element(E1INP_NODE, &cfg_e1_line_driver_cmd);
-	install_element(E1INP_NODE, &cfg_e1_line_name_cmd);
-
-	install_element_ve(&show_e1drv_cmd);
-	install_element_ve(&show_e1line_cmd);
-	install_element_ve(&show_e1ts_cmd);
-
-	return 0;
-}
diff --git a/openbsc/src/libabis/input/dahdi.c b/openbsc/src/libabis/input/dahdi.c
deleted file mode 100644
index 6802a1e..0000000
--- a/openbsc/src/libabis/input/dahdi.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/* OpenBSC Abis input driver for DAHDI */
-
-/* (C) 2008-2011 by Harald Welte <laforge@gnumonks.org>
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 by Digium and Matthew Fredrickson <creslin@digium.com>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include "../../../bscconfig.h"
-
-#ifdef HAVE_DAHDI_USER_H
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <dahdi/user.h>
-
-#include <osmocom/core/select.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/rate_ctr.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/signal.h>
-#include <osmocom/core/talloc.h>
-
-#include "lapd.h"
-
-#define TS1_ALLOC_SIZE	300
-
-/* Corresponds to dahdi/user.h, only PRI related events */
-static const struct value_string dahdi_evt_names[] = {
-	{ DAHDI_EVENT_NONE,		"NONE" },
-	{ DAHDI_EVENT_ALARM,		"ALARM" },
-	{ DAHDI_EVENT_NOALARM,		"NOALARM" },
-	{ DAHDI_EVENT_ABORT,		"HDLC ABORT" },
-	{ DAHDI_EVENT_OVERRUN,		"HDLC OVERRUN" },
-	{ DAHDI_EVENT_BADFCS,		"HDLC BAD FCS" },
-	{ DAHDI_EVENT_REMOVED,		"REMOVED" },
-	{ 0, NULL }
-};
-
-static void handle_dahdi_exception(struct e1inp_ts *ts)
-{
-	int rc, evt;
-	struct e1inp_line *line = ts->line;
-	struct input_signal_data isd;
-
-	rc = ioctl(ts->driver.dahdi.fd.fd, DAHDI_GETEVENT, &evt);
-	if (rc < 0)
-		return;
-
-	LOGP(DMI, LOGL_NOTICE, "Line %u(%s) / TS %u DAHDI EVENT %s\n",
-		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:
-		/* we should notify the code that the line is gone */
-		osmo_signal_dispatch(SS_INPUT, S_INP_LINE_ALARM, &isd);
-		rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_ALARM]);
-		break;
-	case DAHDI_EVENT_NOALARM:
-		/* alarm has gone, we should re-start the SABM requests */
-		osmo_signal_dispatch(SS_INPUT, S_INP_LINE_NOALARM, &isd);
-		break;
-	case DAHDI_EVENT_ABORT:
-		rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_ABORT]);
-		break;
-	case DAHDI_EVENT_OVERRUN:
-		rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_OVERR]);
-		break;
-	case DAHDI_EVENT_BADFCS:
-		rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_BADFCS]);
-		break;
-	case DAHDI_EVENT_REMOVED:
-		rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_REMOVED]);
-		break;
-	}
-}
-
-static int handle_ts1_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "DAHDI TS1");
-	lapd_mph_type prim;
-	unsigned int sapi, tei;
-	int ilen, ret, error = 0;
-	uint8_t *idata;
-
-	if (!msg)
-		return -ENOMEM;
-
-	ret = read(bfd->fd, msg->data, TS1_ALLOC_SIZE - 16);
-	if (ret == -1)
-		handle_dahdi_exception(e1i_ts);
-	else if (ret < 0) {
-		perror("read ");
-	}
-	msgb_put(msg, ret - 2);
-	if (ret <= 3) {
-		perror("read ");
-	}
-
-	sapi = msg->data[0] >> 2;
-	tei = msg->data[1] >> 1;
-
-	DEBUGP(DMI, "<= len = %d, sapi(%d) tei(%d)", ret, sapi, tei);
-
-	idata = lapd_receive(e1i_ts->driver.dahdi.lapd, msg->data, msg->len, &ilen, &prim, &error);
-	if (!idata) {
-		switch(error) {
-		case LAPD_ERR_UNKNOWN_TEI:
-			/* We don't know about this TEI, probably the BSC
-			 * lost local states (it crashed or it was stopped),
-			 * notify the driver to see if it can do anything to
-			 * recover the existing signalling links with the BTS.
-			 */
-			e1inp_event(e1i_ts, S_INP_TEI_UNKNOWN, tei, sapi);
-			return -EIO;
-		}
-		if (prim == 0)
-			return -EIO;
-	}
-
-	msgb_pull(msg, 2);
-
-	DEBUGP(DMI, "prim %08x\n", prim);
-
-	switch (prim) {
-	case 0:
-		break;
-	case LAPD_MPH_ACTIVATE_IND:
-		DEBUGP(DMI, "MPH_ACTIVATE_IND: sapi(%d) tei(%d)\n", sapi, tei);
-		ret = e1inp_event(e1i_ts, S_INP_TEI_UP, tei, sapi);
-		break;
-	case LAPD_MPH_DEACTIVATE_IND:
-		DEBUGP(DMI, "MPH_DEACTIVATE_IND: sapi(%d) tei(%d)\n", sapi, tei);
-		ret = e1inp_event(e1i_ts, S_INP_TEI_DN, tei, sapi);
-		break;
-	case LAPD_DL_DATA_IND:
-	case LAPD_DL_UNITDATA_IND:
-		if (prim == LAPD_DL_DATA_IND)
-			msg->l2h = msg->data + 2;
-		else
-			msg->l2h = msg->data + 1;
-		DEBUGP(DMI, "RX: %s\n", osmo_hexdump(msgb_l2(msg), ret));
-		ret = e1inp_rx_ts(e1i_ts, msg, tei, sapi);
-		break;
-	default:
-		printf("ERROR: unknown prim\n");
-		break;
-	}
-
-	DEBUGP(DMI, "Returned ok\n");
-	return ret;
-}
-
-static int ts_want_write(struct e1inp_ts *e1i_ts)
-{
-	/* We never include the DAHDI B-Channel FD into the
-	 * writeset, since it doesn't support poll() based
-	 * write flow control */
-	if (e1i_ts->type == E1INP_TS_TYPE_TRAU) {
-		fprintf(stderr, "Trying to write TRAU ts\n");
-		return 0;
-	}
-
-	e1i_ts->driver.dahdi.fd.when |= BSC_FD_WRITE;
-
-	return 0;
-}
-
-static void timeout_ts1_write(void *data)
-{
-	struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
-
-	/* trigger write of ts1, due to tx delay timer */
-	ts_want_write(e1i_ts);
-}
-
-static void dahdi_write_msg(uint8_t *data, int len, void *cbdata)
-{
-	struct osmo_fd *bfd = cbdata;
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	int ret;
-
-	ret = write(bfd->fd, data, len + 2);
-	if (ret == -1)
-		handle_dahdi_exception(e1i_ts);
-	else if (ret < 0)
-		LOGP(DMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret);
-}
-
-static int handle_ts1_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *sign_link;
-	struct msgb *msg;
-
-	bfd->when &= ~BSC_FD_WRITE;
-
-	/* get the next msg for this timeslot */
-	msg = e1inp_tx_ts(e1i_ts, &sign_link);
-	if (!msg) {
-		/* no message after tx delay timer */
-		return 0;
-	}
-
-	DEBUGP(DMI, "TX: %s\n", osmo_hexdump(msg->data, msg->len));
-	lapd_transmit(e1i_ts->driver.dahdi.lapd, sign_link->tei,
-		      sign_link->sapi, msg->data, msg->len);
-	msgb_free(msg);
-
-	/* set tx delay timer for next event */
-	e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
-	e1i_ts->sign.tx_timer.data = e1i_ts;
-	osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, 50000);
-
-	return 0;
-}
-
-
-static int invertbits = 1;
-
-static uint8_t flip_table[256];
-
-static void init_flip_bits(void)
-{
-        int i,k;
-
-        for (i = 0 ; i < 256 ; i++) {
-                uint8_t sample = 0 ;
-                for (k = 0; k<8; k++) {
-                        if ( i & 1 << k ) sample |= 0x80 >>  k;
-                }
-                flip_table[i] = sample;
-        }
-}
-
-static uint8_t * flip_buf_bits ( uint8_t * buf , int len)
-{
-        int i;
-        uint8_t * start = buf;
-
-        for (i = 0 ; i < len; i++) {
-                buf[i] = flip_table[(uint8_t)buf[i]];
-        }
-
-        return start;
-}
-
-#define D_BCHAN_TX_GRAN 160
-/* write to a B channel TS */
-static int handle_tsX_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	uint8_t tx_buf[D_BCHAN_TX_GRAN];
-	struct subch_mux *mx = &e1i_ts->trau.mux;
-	int ret;
-
-	ret = subchan_mux_out(mx, tx_buf, D_BCHAN_TX_GRAN);
-
-	if (ret != D_BCHAN_TX_GRAN) {
-		fprintf(stderr, "Huh, got ret of %d\n", ret);
-		if (ret < 0)
-			return ret;
-	}
-
-	DEBUGP(DMIB, "BCHAN TX: %s\n",
-		osmo_hexdump(tx_buf, D_BCHAN_TX_GRAN));
-
-	if (invertbits) {
-		flip_buf_bits(tx_buf, ret);
-	}
-
-	ret = write(bfd->fd, tx_buf, ret);
-	if (ret < D_BCHAN_TX_GRAN)
-		fprintf(stderr, "send returns %d instead of %d\n", ret,
-			D_BCHAN_TX_GRAN);
-
-	return ret;
-}
-
-#define D_TSX_ALLOC_SIZE (D_BCHAN_TX_GRAN)
-/* FIXME: read from a B channel TS */
-static int handle_tsX_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct msgb *msg = msgb_alloc(D_TSX_ALLOC_SIZE, "DAHDI TSx");
-	int ret;
-
-	if (!msg)
-		return -ENOMEM;
-
-	ret = read(bfd->fd, msg->data, D_TSX_ALLOC_SIZE);
-	if (ret < 0 || ret != D_TSX_ALLOC_SIZE) {
-		fprintf(stderr, "read error  %d %s\n", ret, strerror(errno));
-		return ret;
-	}
-
-	if (invertbits) {
-		flip_buf_bits(msg->data, ret);
-	}
-
-	msgb_put(msg, ret);
-
-	msg->l2h = msg->data;
-	DEBUGP(DMIB, "BCHAN RX: %s\n",
-		osmo_hexdump(msgb_l2(msg), ret));
-	ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
-	/* physical layer indicates that data has been sent,
-	 * we thus can send some more data */
-	ret = handle_tsX_write(bfd);
-	msgb_free(msg);
-
-	return ret;
-}
-
-/* callback from select.c in case one of the fd's can be read/written */
-static int dahdi_fd_cb(struct osmo_fd *bfd, unsigned int what)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	unsigned int idx = ts_nr-1;
-	struct e1inp_ts *e1i_ts = &line->ts[idx];
-	int rc = 0;
-
-	switch (e1i_ts->type) {
-	case E1INP_TS_TYPE_SIGN:
-		if (what & BSC_FD_EXCEPT)
-			handle_dahdi_exception(e1i_ts);
-		if (what & BSC_FD_READ)
-			rc = handle_ts1_read(bfd);
-		if (what & BSC_FD_WRITE)
-			rc = handle_ts1_write(bfd);
-		break;
-	case E1INP_TS_TYPE_TRAU:
-		if (what & BSC_FD_EXCEPT)
-			handle_dahdi_exception(e1i_ts);
-		if (what & BSC_FD_READ)
-			rc = handle_tsX_read(bfd);
-		if (what & BSC_FD_WRITE)
-			rc = handle_tsX_write(bfd);
-		/* We never include the DAHDI B-Channel FD into the
-		 * writeset, since it doesn't support poll() based
-		 * write flow control */
-		break;
-	default:
-		fprintf(stderr, "unknown E1 TS type %u\n", e1i_ts->type);
-		break;
-	}
-
-	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)
-{
-	struct dahdi_bufferinfo bi;
-	int x = 0;
-
-	if (ioctl(fd, DAHDI_GET_BUFINFO, &bi)) {
-		fprintf(stderr, "Error getting bufinfo\n");
-		exit(-1);
-	}
-
-	if (as_sigchan) {
-		bi.numbufs = 4;
-		bi.bufsize = 512;
-	} else {
-		bi.numbufs = 8;
-		bi.bufsize = D_BCHAN_TX_GRAN;
-		bi.txbufpolicy = DAHDI_POLICY_WHEN_FULL;
-	}
-
-	if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
-		fprintf(stderr, "Error setting bufinfo\n");
-		exit(-1);
-	}
-
-	if (!as_sigchan) {
-		if (ioctl(fd, DAHDI_AUDIOMODE, &x)) {
-			fprintf(stderr, "Error setting bufinfo\n");
-			exit(-1);
-		}
-	} else {
-		int one = 1;
-		ioctl(fd, DAHDI_HDLCFCSMODE, &one);
-		/* we cannot reliably check for the ioctl return value here
-		 * as this command will fail if the slot _already_ was a
-		 * signalling slot before :( */
-	}
-}
-
-static int dahdi_e1_setup(struct e1inp_line *line)
-{
-	int ts, ret;
-
-	/* TS0 is CRC4, don't need any fd for it */
-	for (ts = 1; ts < NUM_E1_TS; ts++) {
-		unsigned int idx = ts-1;
-		char openstr[128];
-		struct e1inp_ts *e1i_ts = &line->ts[idx];
-		struct osmo_fd *bfd = &e1i_ts->driver.dahdi.fd;
-		int dev_nr;
-
-		/* DAHDI device names/numbers just keep incrementing
-		 * even over multiple boards.  So TS1 of the second
-		 * board will be 32 */
-		dev_nr = line->num * (NUM_E1_TS-1) + ts;
-
-		bfd->data = line;
-		bfd->priv_nr = ts;
-		bfd->cb = dahdi_fd_cb;
-		snprintf(openstr, sizeof(openstr), "/dev/dahdi/%d", dev_nr);
-
-		switch (e1i_ts->type) {
-		case E1INP_TS_TYPE_NONE:
-			continue;
-			break;
-		case E1INP_TS_TYPE_SIGN:
-			bfd->fd = open(openstr, O_RDWR | O_NONBLOCK);
-			if (bfd->fd == -1) {
-				fprintf(stderr, "%s could not open %s %s\n",
-					__func__, openstr, strerror(errno));
-				exit(-1);
-			}
-			bfd->when = BSC_FD_READ | BSC_FD_EXCEPT;
-			dahdi_set_bufinfo(bfd->fd, 1);
-			e1i_ts->driver.dahdi.lapd = lapd_instance_alloc(1, dahdi_write_msg, bfd);
-			break;
-		case E1INP_TS_TYPE_TRAU:
-			bfd->fd = open(openstr, O_RDWR | O_NONBLOCK);
-			if (bfd->fd == -1) {
-				fprintf(stderr, "%s could not open %s %s\n",
-					__func__, openstr, strerror(errno));
-				exit(-1);
-			}
-			dahdi_set_bufinfo(bfd->fd, 0);
-			/* We never include the DAHDI B-Channel FD into the
-			 * writeset, since it doesn't support poll() based
-			 * write flow control */
-			bfd->when = BSC_FD_READ | BSC_FD_EXCEPT;// | BSC_FD_WRITE;
-			break;
-		}
-
-		if (bfd->fd < 0) {
-			fprintf(stderr, "%s could not open %s %s\n",
-				__func__, openstr, strerror(errno));
-			return bfd->fd;
-		}
-
-		ret = osmo_fd_register(bfd);
-		if (ret < 0) {
-			fprintf(stderr, "could not register FD: %s\n",
-				strerror(ret));
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int dahdi_e1_line_update(struct e1inp_line *line)
-{
-	if (line->driver != &dahdi_driver)
-		return -EINVAL;
-
-	return dahdi_e1_setup(line);
-}
-
-int e1inp_dahdi_init(void)
-{
-	init_flip_bits();
-
-	/* register the driver with the core */
-	return e1inp_driver_register(&dahdi_driver);
-}
-
-#endif /* HAVE_DAHDI_USER_H */
diff --git a/openbsc/src/libabis/input/hsl.c b/openbsc/src/libabis/input/hsl.c
deleted file mode 100644
index 7f2e75d..0000000
--- a/openbsc/src/libabis/input/hsl.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/* OpenBSC Abis input driver for HSL Femto */
-
-/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
- * (C) 2011 by On-Waves
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/* HSL uses a much more primitive/simplified version of the IPA multiplex.
- *
- * They have taken out the nice parts like the ID_GET / ID_RESP for resolving
- * the UNIT ID, as well as the keepalive ping/pong messages.  Furthermore, the
- * Stream Identifiers are fixed on the BTS side (RSL always 0, OML always 0xff)
- * and both OML+RSL share a single TCP connection.
- *
- * Other oddities include the encapsulation of BSSGP messages in the L3_INFO IE
- * of RSL
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-
-#include <osmocom/core/select.h>
-#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/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/ipaccess.h>
-#include <openbsc/socket.h>
-#include <openbsc/signal.h>
-#include <osmocom/core/talloc.h>
-
-#define HSL_TCP_PORT	2500
-#define HSL_PROTO_DEBUG	0xdd
-
-#define PRIV_OML 1
-#define PRIV_RSL 2
-
-/* data structure for one E1 interface with A-bis */
-struct hsl_e1_handle {
-	struct osmo_fd listen_fd;
-	struct gsm_network *gsmnet;
-};
-
-static struct hsl_e1_handle *e1h;
-
-
-#define TS1_ALLOC_SIZE	900
-
-#define OML_UP		0x0001
-#define RSL_UP		0x0002
-
-int hsl_drop_oml(struct gsm_bts *bts)
-{
-	struct gsm_bts_trx *trx;
-	struct e1inp_ts *ts;
-	struct e1inp_line *line;
-	struct osmo_fd *bfd;
-
-	if (!bts || !bts->oml_link)
-		return -1;
-
-	/* send OML down */
-	ts = bts->oml_link->ts;
-	line = ts->line;
-	e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi);
-
-	bfd = &ts->driver.ipaccess.fd;
-	osmo_fd_unregister(bfd);
-	close(bfd->fd);
-	bfd->fd = -1;
-
-	/* clean up OML and RSL */
-	e1inp_sign_link_destroy(bts->oml_link);
-	bts->oml_link = NULL;
-	e1inp_sign_link_destroy(bts->c0->rsl_link);
-	bts->c0->rsl_link = NULL;
-	bts->ip_access.flags = 0;
-
-	/* kill the E1 line now... as we have no one left to use it */
-	talloc_free(line);
-
-	return -1;
-}
-
-static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct osmo_fd *bfd)
-{
-	struct e1inp_sign_link *link, *link2;
-	int bts_nr = -1;
-
-	llist_for_each_entry_safe(link, link2, &ts->sign.sign_links, list) {
-		bts_nr = link->trx->bts->bts_nr;
-		e1inp_sign_link_destroy(link);
-	}
-
-	osmo_fd_unregister(bfd);
-	close(bfd->fd);
-	bfd->fd = -1;
-
-	talloc_free(ts->line);
-
-	return bts_nr;
-}
-
-struct gsm_bts *find_bts_by_serno(struct gsm_network *net, unsigned long serno)
-{
-	struct gsm_bts *bts;
-
-	llist_for_each_entry(bts, &net->bts_list, list) {
-		if (bts->type != GSM_BTS_TYPE_HSL_FEMTO)
-			continue;
-
-		if (serno == bts->hsl.serno)
-			return bts;
-	}
-
-	return NULL;
-}
-
-
-static int process_hsl_rsl(struct msgb *msg, struct e1inp_line *line)
-{
-	char serno_buf[16];
-	uint8_t serno_len;
-	unsigned long serno;
-	struct gsm_bts *bts;
-
-	switch (msg->l2h[1]) {
-	case 0x80:
-		/*, contains Serial Number + SW version */
-		if (msg->l2h[2] != 0xc0)
-			break;
-		serno_len = msg->l2h[3];
-		if (serno_len > sizeof(serno_buf)-1)
-			serno_len = sizeof(serno_buf)-1;
-		memcpy(serno_buf, msg->l2h+4, serno_len);
-		serno_buf[serno_len] = '\0';
-		serno = strtoul(serno_buf, NULL, 10);
-		bts = find_bts_by_serno(e1h->gsmnet, serno);
-		if (!bts) {
-			LOGP(DINP, LOGL_ERROR, "Unable to find BTS config for "
-				"serial number %lu(%s)\n", serno, serno_buf);
-			return -EIO;
-		}
-
-		DEBUGP(DINP, "Identified HSL BTS Serial Number %lu\n", serno);
-
-		/* we shouldn't hardcode it, but HSL femto also hardcodes it... */
-		bts->oml_tei = 255;
-		bts->c0->rsl_tei = 0;
-		bts->oml_link = e1inp_sign_link_create(&line->ts[PRIV_OML - 1],
-							E1INP_SIGN_OML, bts->c0,
-							bts->oml_tei, 0);
-		bts->c0->rsl_link = e1inp_sign_link_create(&line->ts[PRIV_OML - 1],
-							E1INP_SIGN_RSL, bts->c0,
-							bts->c0->rsl_tei, 0);
-		e1inp_event(&line->ts[PRIV_OML-1], S_INP_TEI_UP, 255, 0);
-		e1inp_event(&line->ts[PRIV_OML-1], S_INP_TEI_UP, 0, 0);
-		bts->ip_access.flags |= OML_UP;
-		bts->ip_access.flags |= (RSL_UP << 0);
-		msgb_free(msg);
-		return 1;	/* == we have taken over the msg */
-	case 0x82:
-		/* FIXME: do something with BSSGP, i.e. forward it over
-		 * NSIP to OsmoSGSN */
-		msgb_free(msg);
-		return 1;
-	}
-	return 0;
-}
-
-static int handle_ts1_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *link;
-	struct msgb *msg;
-	struct ipaccess_head *hh;
-	int ret = 0, error;
-
-	msg = ipaccess_read_msg(bfd, &error);
-	if (!msg) {
-		if (error == 0) {
-			int ret = hsl_drop_ts_fd(e1i_ts, bfd);
-			if (ret >= 0)
-				LOGP(DINP, LOGL_NOTICE, "BTS %u disappeared, dead socket\n",
-					ret);
-			else
-				LOGP(DINP, LOGL_NOTICE, "unknown BTS disappeared, dead socket\n");
-		}
-		return error;
-	}
-
-	DEBUGP(DMI, "RX %u: %s\n", ts_nr, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)));
-
-	hh = (struct ipaccess_head *) msg->data;
-	if (hh->proto == HSL_PROTO_DEBUG) {
-		LOGP(DINP, LOGL_NOTICE, "HSL debug: %s\n", msg->data + sizeof(*hh));
-		msgb_free(msg);
-		return ret;
-	}
-
-	/* HSL proprietary RSL extension */
-	if (hh->proto == 0 && (msg->l2h[0] == 0x81 || msg->l2h[0] == 0x80)) {
-		ret = process_hsl_rsl(msg, line);
-		if (ret < 0) {
-			/* FIXME: close connection */
-			hsl_drop_ts_fd(e1i_ts, bfd);
-			return ret;
-		} else if (ret == 1)
-			return 0;
-		/* else: continue... */
-	}
-#ifdef HSL_SR_1_0
-	/* HSL for whatever reason chose to use 0x81 instead of 0x80 for FOM */
-	if (hh->proto == 255 && msg->l2h[0] == (ABIS_OM_MDISC_FOM | 0x01))
-		msg->l2h[0] = ABIS_OM_MDISC_FOM;
-#endif
-	link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0);
-	if (!link) {
-		LOGP(DINP, LOGL_ERROR, "no matching signalling link for "
-			"hh->proto=0x%02x\n", hh->proto);
-		msgb_free(msg);
-		return -EIO;
-	}
-	msg->dst = link;
-
-	switch (link->type) {
-	case E1INP_SIGN_RSL:
-		if (!(link->trx->bts->ip_access.flags & (RSL_UP << link->trx->nr))) {
-			e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
-			link->trx->bts->ip_access.flags |= (RSL_UP << link->trx->nr);
-		}
-		ret = abis_rsl_rcvmsg(msg);
-		break;
-	case E1INP_SIGN_OML:
-		if (!(link->trx->bts->ip_access.flags & OML_UP)) {
-			e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
-			link->trx->bts->ip_access.flags |= OML_UP;
-		}
-		ret = abis_nm_rcvmsg(msg);
-		break;
-	default:
-		LOGP(DINP, LOGL_NOTICE, "Unknown HSL protocol class 0x%02x\n", hh->proto);
-		msgb_free(msg);
-		break;
-	}
-	return ret;
-}
-
-static int ts_want_write(struct e1inp_ts *e1i_ts)
-{
-	e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE;
-
-	return 0;
-}
-
-static void timeout_ts1_write(void *data)
-{
-	struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
-
-	/* trigger write of ts1, due to tx delay timer */
-	ts_want_write(e1i_ts);
-}
-
-static int handle_ts1_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *sign_link;
-	struct msgb *msg;
-	uint8_t proto;
-	int ret;
-
-	bfd->when &= ~BSC_FD_WRITE;
-
-	/* get the next msg for this timeslot */
-	msg = e1inp_tx_ts(e1i_ts, &sign_link);
-	if (!msg) {
-		/* no message after tx delay timer */
-		return 0;
-	}
-
-	switch (sign_link->type) {
-	case E1INP_SIGN_OML:
-		proto = IPAC_PROTO_OML;
-#ifdef HSL_SR_1_0
-		/* HSL uses 0x81 for FOM for some reason */
-		if (msg->data[0] == ABIS_OM_MDISC_FOM)
-			msg->data[0] = ABIS_OM_MDISC_FOM | 0x01;
-#endif
-		break;
-	case E1INP_SIGN_RSL:
-		proto = IPAC_PROTO_RSL;
-		break;
-	default:
-		msgb_free(msg);
-		bfd->when |= BSC_FD_WRITE; /* come back for more msg */
-		return -EINVAL;
-	}
-
-	msg->l2h = msg->data;
-	ipaccess_prepend_header(msg, sign_link->tei);
-
-	DEBUGP(DMI, "TX %u: %s\n", ts_nr, osmo_hexdump(msg->l2h, msgb_l2len(msg)));
-
-	ret = send(bfd->fd, msg->data, msg->len, 0);
-	msgb_free(msg);
-
-	/* set tx delay timer for next event */
-	e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
-	e1i_ts->sign.tx_timer.data = e1i_ts;
-
-	/* Reducing this might break the nanoBTS 900 init. */
-	osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
-
-	return ret;
-}
-
-/* callback from select.c in case one of the fd's can be read/written */
-static int hsl_fd_cb(struct osmo_fd *bfd, unsigned int what)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	unsigned int idx = ts_nr-1;
-	struct e1inp_ts *e1i_ts;
-	int rc = 0;
-
-	/* In case of early RSL we might not yet have a line */
-
-	if (line)
-		e1i_ts = &line->ts[idx];
-
-	if (!line || e1i_ts->type == E1INP_TS_TYPE_SIGN) {
-		if (what & BSC_FD_READ)
-			rc = handle_ts1_read(bfd);
-		if (what & BSC_FD_WRITE)
-			rc = handle_ts1_write(bfd);
-	} else
-		LOGP(DINP, LOGL_ERROR, "unknown E1 TS type %u\n", e1i_ts->type);
-
-	return rc;
-}
-
-struct e1inp_driver hsl_driver = {
-	.name = "HSL",
-	.want_write = ts_want_write,
-	.default_delay = 0,
-};
-
-/* callback of the OML listening filedescriptor */
-static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
-{
-	int ret;
-	int idx = 0;
-	int i;
-	struct e1inp_line *line;
-	struct e1inp_ts *e1i_ts;
-	struct osmo_fd *bfd;
-	struct sockaddr_in sa;
-	socklen_t sa_len = sizeof(sa);
-
-	if (!(what & BSC_FD_READ))
-		return 0;
-
-	ret = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len);
-	if (ret < 0) {
-		perror("accept");
-		return ret;
-	}
-	LOGP(DINP, LOGL_NOTICE, "accept()ed new HSL link from %s\n",
-		inet_ntoa(sa.sin_addr));
-
-	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
-	if (!line) {
-		close(ret);
-		return -ENOMEM;
-	}
-	line->driver = &hsl_driver;
-	//line->driver_data = e1h;
-	/* create virrtual E1 timeslots for signalling */
-	e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
-
-	/* initialize the fds */
-	for (i = 0; i < ARRAY_SIZE(line->ts); ++i)
-		line->ts[i].driver.ipaccess.fd.fd = -1;
-
-	e1i_ts = &line->ts[idx];
-
-	bfd = &e1i_ts->driver.ipaccess.fd;
-	bfd->fd = ret;
-	bfd->data = line;
-	bfd->priv_nr = PRIV_OML;
-	bfd->cb = hsl_fd_cb;
-	bfd->when = BSC_FD_READ;
-	ret = osmo_fd_register(bfd);
-	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not register FD\n");
-		close(bfd->fd);
-		talloc_free(line);
-		return ret;
-	}
-
-        return ret;
-	//return e1inp_line_register(line);
-}
-
-int hsl_setup(struct gsm_network *gsmnet)
-{
-	int ret;
-
-	e1h = talloc_zero(tall_bsc_ctx, struct hsl_e1_handle);
-	if (!e1h)
-		return -ENOMEM;
-
-	e1h->gsmnet = gsmnet;
-
-	/* Listen for connections */
-	ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY, HSL_TCP_PORT,
-			0, listen_fd_cb, NULL);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
-void e1inp_hsl_init(void)
-{
-	e1inp_driver_register(&hsl_driver);
-}
diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c
deleted file mode 100644
index 2d6764e..0000000
--- a/openbsc/src/libabis/input/ipaccess.c
+++ /dev/null
@@ -1,842 +0,0 @@
-/* OpenBSC Abis input driver for ip.access */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * (C) 2010 by Holger Hans Peter Freyther
- * (C) 2010 by On-Waves
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-
-#include <osmocom/core/select.h>
-#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.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/ipaccess.h>
-#include <openbsc/socket.h>
-#include <openbsc/signal.h>
-
-#define PRIV_OML 1
-#define PRIV_RSL 2
-
-/* data structure for one E1 interface with A-bis */
-struct ia_e1_handle {
-	struct osmo_fd listen_fd;
-	struct osmo_fd rsl_listen_fd;
-	struct gsm_network *gsmnet;
-};
-
-static struct ia_e1_handle *e1h;
-
-
-#define TS1_ALLOC_SIZE	900
-
-/*
- * Common propietary IPA messages:
- *	- PONG: in reply to PING.
- *	- ID_REQUEST: first messages once OML has been established.
- *	- ID_ACK: in reply to ID_ACK.
- */
-const uint8_t ipa_pong_msg[] = {
-        0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_PONG
-};
-
-const uint8_t ipa_id_ack_msg[] = {
-        0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_ACK
-};
-
-const uint8_t ipa_id_req_msg[] = {
-        0, 17, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_GET,
-        0x01, IPAC_IDTAG_UNIT,
-        0x01, IPAC_IDTAG_MACADDR,
-        0x01, IPAC_IDTAG_LOCATION1,
-        0x01, IPAC_IDTAG_LOCATION2,
-        0x01, IPAC_IDTAG_EQUIPVERS,
-        0x01, IPAC_IDTAG_SWVERSION,
-        0x01, IPAC_IDTAG_UNITNAME,
-        0x01, IPAC_IDTAG_SERNR,
-};
-
-static const char *idtag_names[] = {
-	[IPAC_IDTAG_SERNR]	= "Serial_Number",
-	[IPAC_IDTAG_UNITNAME]	= "Unit_Name",
-	[IPAC_IDTAG_LOCATION1]	= "Location_1",
-	[IPAC_IDTAG_LOCATION2]	= "Location_2",
-	[IPAC_IDTAG_EQUIPVERS]	= "Equipment_Version",
-	[IPAC_IDTAG_SWVERSION]	= "Software_Version",
-	[IPAC_IDTAG_IPADDR]	= "IP_Address",
-	[IPAC_IDTAG_MACADDR]	= "MAC_Address",
-	[IPAC_IDTAG_UNIT]	= "Unit_ID",
-};
-
-const char *ipaccess_idtag_name(uint8_t tag)
-{
-	if (tag >= ARRAY_SIZE(idtag_names))
-		return "unknown";
-
-	return idtag_names[tag];
-}
-
-int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
-{
-	uint8_t t_len;
-	uint8_t t_tag;
-	uint8_t *cur = buf;
-
-	memset(dec, 0, sizeof(*dec));
-
-	while (len >= 2) {
-		len -= 2;
-		t_len = *cur++;
-		t_tag = *cur++;
-
-		if (t_len > len + 1) {
-			LOGP(DMI, LOGL_ERROR, "The tag does not fit: %d\n", t_len);
-			return -EINVAL;
-		}
-
-		DEBUGPC(DMI, "%s='%s' ", ipaccess_idtag_name(t_tag), cur);
-
-		dec->lv[t_tag].len = t_len;
-		dec->lv[t_tag].val = cur;
-
-		cur += t_len;
-		len -= t_len;
-	}
-	return 0;
-}
-
-struct gsm_bts *find_bts_by_unitid(struct gsm_network *net,
-				   uint16_t site_id, uint16_t bts_id)
-{
-	struct gsm_bts *bts;
-
-	llist_for_each_entry(bts, &net->bts_list, list) {
-
-		if (!is_ipaccess_bts(bts))
-			continue;
-
-		if (bts->ip_access.site_id == site_id &&
-		    bts->ip_access.bts_id == bts_id)
-			return bts;
-	}
-
-	return NULL;
-}
-
-int ipaccess_parse_unitid(const char *str, uint16_t *site_id,
-			  uint16_t *bts_id, uint16_t *trx_id)
-{
-	unsigned long ul;
-	char *endptr;
-	const char *nptr;
-
-	nptr = str;
-	ul = strtoul(nptr, &endptr, 10);
-	if (endptr <= nptr)
-		return -EINVAL;
-	if (site_id)
-		*site_id = ul & 0xffff;
-
-	if (*endptr++ != '/')
-		return -EINVAL;
-
-	nptr = endptr;
-	ul = strtoul(nptr, &endptr, 10);
-	if (endptr <= nptr)
-		return -EINVAL;
-	if (bts_id)
-		*bts_id = ul & 0xffff;
-
-	if (*endptr++ != '/')
-		return -EINVAL;
-	
-	nptr = endptr;
-	ul = strtoul(nptr, &endptr, 10);
-	if (endptr <= nptr)
-		return -EINVAL;
-	if (trx_id)
-		*trx_id = ul & 0xffff;
-
-	return 0;
-}
-
-static int ipaccess_send(int fd, const void *msg, size_t msglen)
-{
-	int ret;
-
-	ret = write(fd, msg, msglen);
-	if (ret < 0)
-		return ret;
-	if (ret < msglen) {
-		LOGP(DINP, LOGL_ERROR, "ipaccess_send: short write\n");
-		return -EIO;
-	}
-	return ret;
-}
-
-int ipaccess_send_pong(int fd)
-{
-	return ipaccess_send(fd, ipa_pong_msg, sizeof(ipa_pong_msg));
-}
-
-int ipaccess_send_id_ack(int fd)
-{
-	return ipaccess_send(fd, ipa_id_ack_msg, sizeof(ipa_id_ack_msg));
-}
-
-int ipaccess_send_id_req(int fd)
-{
-	return ipaccess_send(fd, ipa_id_req_msg, sizeof(ipa_id_req_msg));
-}
-
-/* base handling of the ip.access protocol */
-int ipaccess_rcvmsg_base(struct msgb *msg,
-			 struct osmo_fd *bfd)
-{
-	uint8_t msg_type = *(msg->l2h);
-	int ret = 0;
-
-	switch (msg_type) {
-	case IPAC_MSGT_PING:
-		ret = ipaccess_send_pong(bfd->fd);
-		break;
-	case IPAC_MSGT_PONG:
-		DEBUGP(DMI, "PONG!\n");
-		break;
-	case IPAC_MSGT_ID_ACK:
-		DEBUGP(DMI, "ID_ACK? -> ACK!\n");
-		ret = ipaccess_send_id_ack(bfd->fd);
-		break;
-	}
-	return 0;
-}
-
-static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
-			   struct osmo_fd *bfd)
-{
-	struct tlv_parsed tlvp;
-	uint8_t msg_type = *(msg->l2h);
-	uint16_t site_id = 0, bts_id = 0, trx_id = 0;
-	struct gsm_bts *bts;
-	char *unitid;
-	int len, ret;
-
-	/* handle base messages */
-	ipaccess_rcvmsg_base(msg, bfd);
-
-	switch (msg_type) {
-	case IPAC_MSGT_ID_RESP:
-		DEBUGP(DMI, "ID_RESP ");
-		/* parse tags, search for Unit ID */
-		ret = ipaccess_idtag_parse(&tlvp, (uint8_t *)msg->l2h + 2,
-					   msgb_l2len(msg)-2);
-		DEBUGP(DMI, "\n");
-		if (ret < 0) {
-			LOGP(DINP, LOGL_ERROR, "ignoring IPA response message "
-					       "with malformed TLVs\n");
-			return ret;
-		}
-		if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT))
-			break;
-
-		len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT);
-		if (len < 1)
-			break;
-
-		/* lookup BTS, create sign_link, ... */
-		unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT);
-		unitid[len - 1] = '\0';
-		ipaccess_parse_unitid(unitid, &site_id, &bts_id, &trx_id);
-		bts = find_bts_by_unitid(e1h->gsmnet, site_id, bts_id);
-		if (!bts) {
-			LOGP(DINP, LOGL_ERROR, "Unable to find BTS configuration for "
-			       " %u/%u/%u, disconnecting\n", site_id, bts_id,
-				trx_id);
-			return -EIO;
-		}
-		DEBUGP(DINP, "Identified BTS %u/%u/%u\n", site_id, bts_id, trx_id);
-		if (bfd->priv_nr == PRIV_OML) {
-			/* drop any old oml connection */
-			ipaccess_drop_oml(bts);
-			bts->oml_link = e1inp_sign_link_create(&line->ts[PRIV_OML - 1],
-						  E1INP_SIGN_OML, bts->c0,
-						  bts->oml_tei, 0);
-		} else if (bfd->priv_nr == PRIV_RSL) {
-			struct e1inp_ts *e1i_ts;
-			struct osmo_fd *newbfd;
-			struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_id);
-
-			/* drop any old rsl connection */
-			ipaccess_drop_rsl(trx);
-
-			if (!bts->oml_link) {
-				osmo_fd_unregister(bfd);
-				close(bfd->fd);
-				bfd->fd = -1;
-				talloc_free(bfd);
-				return 0;
-			}
-
-			bfd->data = line = bts->oml_link->ts->line;
-			e1i_ts = &line->ts[PRIV_RSL + trx_id - 1];
-			newbfd = &e1i_ts->driver.ipaccess.fd;
-			e1inp_ts_config(e1i_ts, line, E1INP_TS_TYPE_SIGN);
-
-			trx->rsl_link = e1inp_sign_link_create(e1i_ts,
-							E1INP_SIGN_RSL, trx,
-							trx->rsl_tei, 0);
-			trx->rsl_link->ts->sign.delay = 0;
-
-			/* get rid of our old temporary bfd */
-			memcpy(newbfd, bfd, sizeof(*newbfd));
-			newbfd->priv_nr = PRIV_RSL + trx_id;
-			osmo_fd_unregister(bfd);
-			bfd->fd = -1;
-			talloc_free(bfd);
-			osmo_fd_register(newbfd);
-		}
-		break;
-	}
-	return 0;
-}
-
-#define OML_UP		0x0001
-#define RSL_UP		0x0002
-
-/*
- * read one ipa message from the socket
- * return NULL in case of error
- */
-struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error)
-{
-	struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP");
-	struct ipaccess_head *hh;
-	int len, ret = 0;
-
-	if (!msg) {
-		*error = -ENOMEM;
-		return NULL;
-	}
-
-	/* first read our 3-byte header */
-	hh = (struct ipaccess_head *) msg->data;
-	ret = recv(bfd->fd, msg->data, sizeof(*hh), 0);
-	if (ret == 0) {
-		msgb_free(msg);
-		*error = ret;
-		return NULL;
-	} else if (ret != sizeof(*hh)) {
-		if (errno != EAGAIN)
-			LOGP(DINP, LOGL_ERROR, "recv error %d %s\n", ret, strerror(errno));
-		msgb_free(msg);
-		*error = ret;
-		return NULL;
-	}
-
-	msgb_put(msg, ret);
-
-	/* then read te length as specified in header */
-	msg->l2h = msg->data + sizeof(*hh);
-	len = ntohs(hh->len);
-
-	if (len < 0 || TS1_ALLOC_SIZE < len + sizeof(*hh)) {
-		LOGP(DINP, LOGL_ERROR, "Can not read this packet. %d avail\n", len);
-		msgb_free(msg);
-		*error = -EIO;
-		return NULL;
-	}
-
-	ret = recv(bfd->fd, msg->l2h, len, 0);
-	if (ret < len) {
-		LOGP(DINP, LOGL_ERROR, "short read! Got %d from %d\n", ret, len);
-		msgb_free(msg);
-		*error = -EIO;
-		return NULL;
-	}
-	msgb_put(msg, ret);
-
-	return msg;
-}
-
-int ipaccess_drop_oml(struct gsm_bts *bts)
-{
-	struct gsm_bts_trx *trx;
-	struct e1inp_ts *ts;
-	struct e1inp_line *line;
-	struct osmo_fd *bfd;
-
-	if (!bts || !bts->oml_link)
-		return -1;
-
-	/* send OML down */
-	ts = bts->oml_link->ts;
-	line = ts->line;
-	e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi);
-
-	bfd = &ts->driver.ipaccess.fd;
-	osmo_fd_unregister(bfd);
-	close(bfd->fd);
-	bfd->fd = -1;
-
-	/* clean up OML and RSL */
-	e1inp_sign_link_destroy(bts->oml_link);
-	bts->oml_link = NULL;
-	bts->ip_access.flags = 0;
-
-	/* drop all RSL connections too */
-	llist_for_each_entry(trx, &bts->trx_list, list)
-		ipaccess_drop_rsl(trx);
-
-	/* kill the E1 line now... as we have no one left to use it */
-	talloc_free(line);
-
-	return -1;
-}
-
-static int ipaccess_drop(struct e1inp_ts *ts, struct osmo_fd *bfd)
-{
-	struct e1inp_sign_link *link;
-	int bts_nr;
-
-	if (!ts || !bfd->data) {
-		/*
-		 * If we don't have a TS this means that this is a RSL
-		 * connection but we are not past the authentication
-		 * handling yet. So we can safely delete this bfd and
-		 * wait for a reconnect.
-		 * If we don't have bfd->data this means that a RSL
-		 * connection was accept()ed, but nothing was recv()ed
-		 * and the connection gets close()ed.
-		 */
-		osmo_fd_unregister(bfd);
-		close(bfd->fd);
-		bfd->fd = -1;
-		talloc_free(bfd);
-		return -1;
-	}
-
-	/* attempt to find a signalling link */
-	if (ts->type == E1INP_TS_TYPE_SIGN) {
-		llist_for_each_entry(link, &ts->sign.sign_links, list) {
-			bts_nr = link->trx->bts->bts_nr;
-			/* we have issues just reconnecting RLS so we drop OML */
-			ipaccess_drop_oml(link->trx->bts);
-			return bts_nr;
-		}
-	}
-
-	/* error case */
-	LOGP(DINP, LOGL_ERROR, "Failed to find a signalling link for ts: %p\n", ts);
-	osmo_fd_unregister(bfd);
-	close(bfd->fd);
-	bfd->fd = -1;
-	return -1;
-}
-
-int ipaccess_drop_rsl(struct gsm_bts_trx *trx)
-{
-	struct osmo_fd *bfd;
-	struct e1inp_ts *ts;
-
-	if (!trx || !trx->rsl_link)
-		return -1;
-
-	/* send RSL down */
-	ts = trx->rsl_link->ts;
-	e1inp_event(ts, S_INP_TEI_DN, trx->rsl_link->tei, trx->rsl_link->sapi);
-
-	/* close the socket */
-	bfd = &ts->driver.ipaccess.fd;
-	osmo_fd_unregister(bfd);
-	close(bfd->fd);
-	bfd->fd = -1;
-
-	/* destroy */
-	e1inp_sign_link_destroy(trx->rsl_link);
-	trx->rsl_link = NULL;
-
-	return -1;
-}
-
-static int handle_ts1_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *link;
-	struct msgb *msg;
-	struct ipaccess_head *hh;
-	int ret = 0, error;
-
-	msg = ipaccess_read_msg(bfd, &error);
-	if (!msg) {
-		if (error == 0) {
-			int ret = ipaccess_drop(e1i_ts, bfd);
-			if (ret >= 0)
-				LOGP(DINP, LOGL_NOTICE, "BTS %u disappeared, dead socket\n",
-					ret);
-			else
-				LOGP(DINP, LOGL_NOTICE, "unknown BTS disappeared, dead socket\n");
-		}
-		return error;
-	}
-
-	DEBUGP(DMI, "RX %u: %s\n", ts_nr, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)));
-
-	hh = (struct ipaccess_head *) msg->data;
-	if (hh->proto == IPAC_PROTO_IPACCESS) {
-		ret = ipaccess_rcvmsg(line, msg, bfd);
-		if (ret < 0)
-			ipaccess_drop(e1i_ts, bfd);
-		msgb_free(msg);
-		return ret;
-	}
-	/* BIG FAT WARNING: bfd might no longer exist here, since ipaccess_rcvmsg()
-	 * might have free'd it !!! */
-
-	link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0);
-	if (!link) {
-		LOGP(DINP, LOGL_ERROR, "no matching signalling link for "
-			"hh->proto=0x%02x\n", hh->proto);
-		msgb_free(msg);
-		return -EIO;
-	}
-	msg->dst = link;
-
-	switch (link->type) {
-	case E1INP_SIGN_RSL:
-		if (!(link->trx->bts->ip_access.flags & (RSL_UP << link->trx->nr))) {
-			e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
-			link->trx->bts->ip_access.flags |= (RSL_UP << link->trx->nr);
-		}
-		ret = abis_rsl_rcvmsg(msg);
-		break;
-	case E1INP_SIGN_OML:
-		if (!(link->trx->bts->ip_access.flags & OML_UP)) {
-			e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
-			link->trx->bts->ip_access.flags |= OML_UP;
-		}
-		ret = abis_nm_rcvmsg(msg);
-		break;
-	default:
-		LOGP(DINP, LOGL_NOTICE, "Unknown IP.access protocol proto=0x%02x\n", hh->proto);
-		msgb_free(msg);
-		break;
-	}
-	return ret;
-}
-
-void ipaccess_prepend_header_ext(struct msgb *msg, int proto)
-{
-	struct ipaccess_head_ext *hh_ext;
-
-	/* prepend the osmo ip.access header extension */
-	hh_ext = (struct ipaccess_head_ext *) msgb_push(msg, sizeof(*hh_ext));
-	hh_ext->proto = proto;
-}
-
-void ipaccess_prepend_header(struct msgb *msg, int proto)
-{
-	struct ipaccess_head *hh;
-
-	/* prepend the ip.access header */
-	hh = (struct ipaccess_head *) msgb_push(msg, sizeof(*hh));
-	hh->len = htons(msg->len - sizeof(*hh));
-	hh->proto = proto;
-}
-
-static int ts_want_write(struct e1inp_ts *e1i_ts)
-{
-	e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE;
-
-	return 0;
-}
-
-static void timeout_ts1_write(void *data)
-{
-	struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
-
-	/* trigger write of ts1, due to tx delay timer */
-	ts_want_write(e1i_ts);
-}
-
-static int handle_ts1_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *sign_link;
-	struct msgb *msg;
-	uint8_t proto;
-	int ret;
-
-	bfd->when &= ~BSC_FD_WRITE;
-
-	/* get the next msg for this timeslot */
-	msg = e1inp_tx_ts(e1i_ts, &sign_link);
-	if (!msg) {
-		/* no message after tx delay timer */
-		return 0;
-	}
-
-	switch (sign_link->type) {
-	case E1INP_SIGN_OML:
-		proto = IPAC_PROTO_OML;
-		break;
-	case E1INP_SIGN_RSL:
-		proto = IPAC_PROTO_RSL;
-		break;
-	default:
-		msgb_free(msg);
-		bfd->when |= BSC_FD_WRITE; /* come back for more msg */
-		return -EINVAL;
-	}
-
-	msg->l2h = msg->data;
-	ipaccess_prepend_header(msg, sign_link->tei);
-
-	DEBUGP(DMI, "TX %u: %s\n", ts_nr, osmo_hexdump(msg->l2h, msgb_l2len(msg)));
-
-	ret = send(bfd->fd, msg->data, msg->len, 0);
-	msgb_free(msg);
-
-	/* set tx delay timer for next event */
-	e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
-	e1i_ts->sign.tx_timer.data = e1i_ts;
-
-	/* Reducing this might break the nanoBTS 900 init. */
-	osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
-
-	return ret;
-}
-
-/* callback from select.c in case one of the fd's can be read/written */
-static int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	unsigned int idx = ts_nr-1;
-	struct e1inp_ts *e1i_ts;
-	int rc = 0;
-
-	/* In case of early RSL we might not yet have a line */
-
-	if (line)
- 		e1i_ts = &line->ts[idx];
-
-	if (!line || e1i_ts->type == E1INP_TS_TYPE_SIGN) {
-		if (what & BSC_FD_READ)
-			rc = handle_ts1_read(bfd);
-		if (what & BSC_FD_WRITE)
-			rc = handle_ts1_write(bfd);
-	} else
-		LOGP(DINP, LOGL_ERROR, "unknown E1 TS type %u\n", e1i_ts->type);
-
-	return rc;
-}
-
-struct e1inp_driver ipaccess_driver = {
-	.name = "ip.access",
-	.want_write = ts_want_write,
-	.default_delay = 0,
-};
-
-/* callback of the OML listening filedescriptor */
-static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
-{
-	int ret;
-	int idx = 0;
-	int i;
-	struct e1inp_line *line;
-	struct e1inp_ts *e1i_ts;
-	struct osmo_fd *bfd;
-	struct sockaddr_in sa;
-	socklen_t sa_len = sizeof(sa);
-
-	if (!(what & BSC_FD_READ))
-		return 0;
-
-	ret = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len);
-	if (ret < 0) {
-		perror("accept");
-		return ret;
-	}
-	LOGP(DINP, LOGL_NOTICE, "accept()ed new OML link from %s\n",
-		inet_ntoa(sa.sin_addr));
-
-	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
-	if (!line) {
-		close(ret);
-		return -ENOMEM;
-	}
-	line->driver = &ipaccess_driver;
-	//line->driver_data = e1h;
-	/* create virrtual E1 timeslots for signalling */
-	e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
-
-	/* initialize the fds */
-	for (i = 0; i < ARRAY_SIZE(line->ts); ++i)
-		line->ts[i].driver.ipaccess.fd.fd = -1;
-
-	e1i_ts = &line->ts[idx];
-
-	bfd = &e1i_ts->driver.ipaccess.fd;
-	bfd->fd = ret;
-	bfd->data = line;
-	bfd->priv_nr = PRIV_OML;
-	bfd->cb = ipaccess_fd_cb;
-	bfd->when = BSC_FD_READ;
-	ret = osmo_fd_register(bfd);
-	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not register FD\n");
-		close(bfd->fd);
-		talloc_free(line);
-		return ret;
-	}
-
-	/* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
-	ret = ipaccess_send_id_req(bfd->fd);
-
-        return ret;
-	//return e1inp_line_register(line);
-}
-
-static int rsl_listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
-{
-	struct sockaddr_in sa;
-	socklen_t sa_len = sizeof(sa);
-	struct osmo_fd *bfd;
-	int ret;
-
-	if (!(what & BSC_FD_READ))
-		return 0;
-
-	bfd = talloc_zero(tall_bsc_ctx, struct osmo_fd);
-	if (!bfd)
-		return -ENOMEM;
-
-	/* Some BTS has connected to us, but we don't know yet which line
-	 * (as created by the OML link) to associate it with.  Thus, we
-	 * allocate a temporary bfd until we have received ID from BTS */
-
-	bfd->fd = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len);
-	if (bfd->fd < 0) {
-		perror("accept");
-		return bfd->fd;
-	}
-	LOGP(DINP, LOGL_NOTICE, "accept()ed new RSL link from %s\n", inet_ntoa(sa.sin_addr));
-	bfd->priv_nr = PRIV_RSL;
-	bfd->cb = ipaccess_fd_cb;
-	bfd->when = BSC_FD_READ;
-	ret = osmo_fd_register(bfd);
-	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not register FD\n");
-		close(bfd->fd);
-		talloc_free(bfd);
-		return ret;
-	}
-	/* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
-	ret = ipaccess_send_id_req(bfd->fd);
-
-	return 0;
-}
-
-/* Actively connect to a BTS.  Currently used by ipaccess-config.c */
-int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
-{
-	struct e1inp_ts *e1i_ts = &line->ts[0];
-	struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd;
-	int ret, on = 1;
-
-	bfd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-	bfd->cb = ipaccess_fd_cb;
-	bfd->when = BSC_FD_READ | BSC_FD_WRITE;
-	bfd->data = line;
-	bfd->priv_nr = PRIV_OML;
-
-	if (bfd->fd < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not create TCP socket.\n");
-		return -EIO;
-	}
-
-	setsockopt(bfd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
-
-	ret = connect(bfd->fd, (struct sockaddr *) sa, sizeof(*sa));
-	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not connect socket\n");
-		close(bfd->fd);
-		return ret;
-	}
-
-	ret = osmo_fd_register(bfd);
-	if (ret < 0) {
-		close(bfd->fd);
-		return ret;
-	}
-	
-	line->driver = &ipaccess_driver;
-
-        return ret;
-	//return e1inp_line_register(line);
-}
-
-int ipaccess_setup(struct gsm_network *gsmnet)
-{
-	int ret;
-
-	e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
-	if (!e1h)
-		return -ENOMEM;
-
-	e1h->gsmnet = gsmnet;
-
-	/* Listen for OML connections */
-	ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY,
-			IPA_TCP_PORT_OML, 0, listen_fd_cb, NULL);
-	if (ret < 0)
-		return ret;
-
-	/* Listen for RSL connections */
-	ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, INADDR_ANY,
-			IPA_TCP_PORT_RSL, 0, rsl_listen_fd_cb, NULL);
-	if (ret < 0)
-		return ret;
-
-	return ret;
-}
-
-void e1inp_ipaccess_init(void)
-{
-	e1inp_driver_register(&ipaccess_driver);
-}
diff --git a/openbsc/src/libabis/input/lapd.c b/openbsc/src/libabis/input/lapd.c
deleted file mode 100644
index 2934b58..0000000
--- a/openbsc/src/libabis/input/lapd.c
+++ /dev/null
@@ -1,730 +0,0 @@
-/* OpenBSC minimal LAPD implementation */
-
-/* (C) 2009 by oystein@homelien.no
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 by Digium and Matthew Fredrickson <creslin@digium.com>
- * (C) 2011 by Harald Welte <laforge@gnumonks.org>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-/* TODO:
-	* detect RR timeout and set SAP state back to SABM_RETRANSMIT
-	* use of value_string
-	* further code cleanup (spaghetti)
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include "lapd.h"
-
-#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/timer.h>
-#include <openbsc/debug.h>
-
-#define SABM_INTERVAL		0, 300000
-
-typedef enum {
-	LAPD_TEI_NONE = 0,
-	LAPD_TEI_ASSIGNED,
-	LAPD_TEI_ACTIVE,
-} lapd_tei_state;
-
-const char *lapd_tei_states[] = {
-	"NONE",
-	"ASSIGNED",
-	"ACTIVE",
-};
-
-typedef enum {
-	LAPD_TYPE_NONE = 0,
-
-	LAPD_TYPE_I,
-	LAPD_TYPE_S,
-	LAPD_TYPE_U,
-} lapd_msg_type;
-
-typedef enum {
-	/* commands/responses */
-	LAPD_CMD_NONE = 0,
-
-	LAPD_CMD_I,
-	LAPD_CMD_RR,
-	LAPD_CMD_RNR,
-	LAPD_CMD_REJ,
-
-	LAPD_CMD_SABME,
-	LAPD_CMD_DM,
-	LAPD_CMD_UI,
-	LAPD_CMD_DISC,
-	LAPD_CMD_UA,
-	LAPD_CMD_FRMR,
-	LAPD_CMD_XID,
-} lapd_cmd_type;
-
-const char *lapd_cmd_types[] = {
-	"NONE",
-
-	"I",
-	"RR",
-	"RNR",
-	"REJ",
-
-	"SABME",
-	"DM",
-	"UI",
-	"DISC",
-	"UA",
-	"FRMR",
-	"XID",
-
-};
-
-enum lapd_sap_state {
-	SAP_STATE_INACTIVE,
-	SAP_STATE_SABM_RETRANS,
-	SAP_STATE_ACTIVE,
-};
-
-const char *lapd_sap_states[] = {
-	"INACTIVE",
-	"SABM_RETRANS",
-	"ACTIVE",
-};
-
-const char *lapd_msg_types = "?ISU";
-
-/* structure representing an allocated TEI within a LAPD instance */
-struct lapd_tei {
-	struct llist_head list;
-	struct lapd_instance *li;
-	uint8_t tei;
-	lapd_tei_state state;
-
-	struct llist_head sap_list;
-};
-
-/* Structure representing a SAP within a TEI. We use this for TE-mode to
- * re-transmit SABM */
-struct lapd_sap {
-	struct llist_head list;
-	struct lapd_tei *tei;
-	uint8_t sapi;
-	enum lapd_sap_state state;
-
-	/* A valid N(R) value is one that is in the range V(A) ≤ N(R) ≤ V(S). */
-	int vs;			/* next to be transmitted */
-	int va;			/* last acked by peer */
-	int vr;			/* next expected to be received */
-
-	struct osmo_timer_list sabme_timer;	/* timer to re-transmit SABM message */
-};
-
-/* 3.5.2.2   Send state variable V(S)
- * Each point-to-point data link connection endpoint shall have an associated V(S) when using I frame
- * commands. V(S) denotes the sequence number of the next I frame to be transmitted. The V(S) can
- * take on the value 0 through n minus 1. The value of V(S) shall be incremented by 1 with each
- * successive I frame transmission, and shall not exceed V(A) by more than the maximum number of
- * outstanding I frames k. The value of k may be in the range of 1 ≤ k ≤ 127.
- *
- * 3.5.2.3   Acknowledge state variable V(A)
- * Each point-to-point data link connection endpoint shall have an associated V(A) when using I frame
- * commands and supervisory frame commands/responses. V(A) identifies the last I frame that has been
- * acknowledged by its peer [V(A) − 1 equals the N(S) of the last acknowledged I frame]. V(A) can
- * take on the value 0 through n minus 1. The value of V(A) shall be updated by the valid N(R) values
- * received from its peer (see 3.5.2.6). A valid N(R) value is one that is in the range V(A) ≤ N(R) ≤
- * V(S).
- *
- * 3.5.2.5    Receive state variable V(R)
- * Each point-to-point data link connection endpoint shall have an associated V(R) when using I frame
- * commands and supervisory frame commands/responses. V(R) denotes the sequence number of the
- * next in-sequence I frame expected to be received. V(R) can take on the value 0 through n minus 1.
- * The value of V(R) shall be incremented by one with the receipt of an error-free, in-sequence I frame
- * whose N(S) equals V(R).
- */
-#define	LAPD_NS(sap) (sap->vs)
-#define	LAPD_NR(sap) (sap->vr)
-
-/* 3.5.2.4    Send sequence number N(S)
- * Only I frames contain N(S), the send sequence number of transmitted I frames. At the time that an in-
- * sequence I frame is designated for transmission, the value of N(S) is set equal to V(S).
- *
- * 3.5.2.6    Receive sequence number N(R)
- * All I frames and supervisory frames contain N(R), the expected send sequence number of the next
- * received I frame. At the time that a frame of the above types is designated for transmission, the value
- * of N(R) is set equal to V(R). N(R) indicates that the data link layer entity transmitting the N(R) has
- * correctly received all I frames numbered up to and including N(R) − 1.
- */
-
-/* Resolve TEI structure from given numeric TEI */
-static struct lapd_tei *teip_from_tei(struct lapd_instance *li, uint8_t tei)
-{
-	struct lapd_tei *lt;
-
-	llist_for_each_entry(lt, &li->tei_list, list) {
-		if (lt->tei == tei)
-			return lt;
-	}
-	return NULL;
-};
-
-static void lapd_tei_set_state(struct lapd_tei *teip, int newstate)
-{
-	LOGP(DMI, LOGL_INFO, "LAPD state change on TEI %d: %s -> %s\n", teip->tei,
-		   lapd_tei_states[teip->state], lapd_tei_states[newstate]);
-	teip->state = newstate;
-};
-
-/* Allocate a new TEI */
-struct lapd_tei *lapd_tei_alloc(struct lapd_instance *li, uint8_t tei)
-{
-	struct lapd_tei *teip;
-
-	teip = talloc_zero(li, struct lapd_tei);
-	if (!teip)
-		return NULL;
-
-	teip->li = li;
-	teip->tei = tei;
-	llist_add(&teip->list, &li->tei_list);
-	INIT_LLIST_HEAD(&teip->sap_list);
-
-	lapd_tei_set_state(teip, LAPD_TEI_ASSIGNED);
-
-	return teip;
-}
-
-/* Find a SAP within a given TEI */
-static struct lapd_sap *lapd_sap_find(struct lapd_tei *teip, uint8_t sapi)
-{
-	struct lapd_sap *sap;
-
-	llist_for_each_entry(sap, &teip->sap_list, list) {
-		if (sap->sapi == sapi)
-			return sap;
-	}
-
-	return NULL;
-}
-
-static void sabme_timer_cb(void *_sap);
-
-/* Allocate a new SAP within a given TEI */
-static struct lapd_sap *lapd_sap_alloc(struct lapd_tei *teip, uint8_t sapi)
-{
-	struct lapd_sap *sap = talloc_zero(teip, struct lapd_sap);
-
-	LOGP(DMI, LOGL_INFO, "LAPD Allocating SAP for SAPI=%u / TEI=%u\n",
-		sapi, teip->tei);
-
-	sap->sapi = sapi;
-	sap->tei = teip;
-	sap->sabme_timer.cb = &sabme_timer_cb;
-	sap->sabme_timer.data = sap;
-
-	llist_add(&sap->list, &teip->sap_list);
-
-	return sap;
-}
-
-static void lapd_sap_set_state(struct lapd_tei *teip, uint8_t sapi,
-				enum lapd_sap_state newstate)
-{
-	struct lapd_sap *sap = lapd_sap_find(teip, sapi);
-	if (!sap)
-		return;
-
-	LOGP(DMI, LOGL_INFO, "LAPD state change on TEI %u / SAPI %u: "
-		"%s -> %s\n", teip->tei, sapi,
-		lapd_sap_states[sap->state], lapd_sap_states[newstate]);
-	switch (sap->state) {
-	case SAP_STATE_SABM_RETRANS:
-		if (newstate != SAP_STATE_SABM_RETRANS)
-			osmo_timer_del(&sap->sabme_timer);
-		break;
-	default:
-		if (newstate == SAP_STATE_SABM_RETRANS)
-			osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL);
-		break;
-	}
-
-	sap->state = newstate;
-};
-
-/* Input function into TEI manager */
-static void lapd_tei_receive(struct lapd_instance *li, uint8_t *data, int len)
-{
-	uint8_t entity = data[0];
-	uint8_t ref = data[1];
-	uint8_t mt = data[3];
-	uint8_t action = data[4] >> 1;
-	uint8_t e = data[4] & 1;
-	uint8_t resp[8];
-	struct lapd_tei *teip;
-
-	DEBUGP(DMI, "LAPD TEIMGR: entity %x, ref %x, mt %x, action %x, e %x\n",
-		entity, ref, mt, action, e);
-
-	switch (mt) {
-	case 0x01:	/* IDENTITY REQUEST */
-		DEBUGP(DMI, "LAPD TEIMGR: identity request for TEI %u\n", action);
-
-		teip = teip_from_tei(li, action);
-		if (!teip) {
-			LOGP(DMI, LOGL_INFO, "TEI MGR: New TEI %u\n", action);
-			teip = lapd_tei_alloc(li, action);
-		}
-
-		/* Send ACCEPT */
-		memmove(resp, "\xfe\xff\x03\x0f\x00\x00\x02\x00", 8);
-		resp[7] = (action << 1) | 1;
-		li->transmit_cb(resp, 8, li->cbdata);
-
-		if (teip->state == LAPD_TEI_NONE)
-			lapd_tei_set_state(teip, LAPD_TEI_ASSIGNED);
-		break;
-	default:
-		LOGP(DMI, LOGL_NOTICE, "LAPD TEIMGR: unknown mt %x action %x\n",
-		     mt, action);
-		break;
-	};
-};
-
-/* General input function for any data received for this LAPD instance */
-uint8_t *
-lapd_receive(struct lapd_instance *li, uint8_t * data, unsigned int len,
-	     int *ilen, lapd_mph_type *prim, int *error)
-{
-	uint8_t sapi, cr, tei, command;
-	int pf, ns, nr;
-	uint8_t *contents;
-	struct lapd_tei *teip;
-	struct lapd_sap *sap;
-
-	uint8_t resp[8];
-	int l = 0;
-
-	*ilen = 0;
-	*prim = 0;
-
-	if (len < 2) {
-		LOGP(DMI, LOGL_ERROR, "LAPD receive len %d < 2, ignoring\n", len);
-		*error = LAPD_ERR_BAD_LEN;
-		return NULL;
-	};
-
-	if ((data[0] & 1) != 0 || (data[1] & 1) != 1) {
-		LOGP(DMI, LOGL_ERROR, "LAPD address field %x/%x not well formed\n",
-			data[0], data[1]);
-		*error = LAPD_ERR_BAD_ADDR;
-		return NULL;
-	};
-
-	sapi = data[0] >> 2;
-	cr = (data[0] >> 1) & 1;
-	tei = data[1] >> 1;
-	command = li->network_side ^ cr;
-	//DEBUGP(DMI, "  address sapi %x tei %d cmd %d cr %d\n", sapi, tei, command, cr);
-
-	if (len < 3) {
-		LOGP(DMI, LOGL_ERROR, "LAPD receive len %d < 3, ignoring\n", len);
-		*error = LAPD_ERR_BAD_LEN;
-		return NULL;
-	};
-
-	lapd_msg_type typ = 0;
-	lapd_cmd_type cmd = 0;
-	pf = -1;
-	ns = -1;
-	nr = -1;
-	if ((data[2] & 1) == 0) {
-		typ = LAPD_TYPE_I;
-		if (len < 4) {
-			LOGP(DMI, LOGL_ERROR, "LAPD I frame, len %d < 4\n", len);
-			*error = LAPD_ERR_BAD_LEN;
-			return NULL;
-		}
-		ns = data[2] >> 1;
-		nr = data[3] >> 1;
-		pf = data[3] & 1;
-		cmd = LAPD_CMD_I;
-	} else if ((data[2] & 3) == 1) {
-		typ = LAPD_TYPE_S;
-		if (len < 4) {
-			LOGP(DMI, LOGL_ERROR, "LAPD S frame, len %d < 4\n", len);
-			*error = LAPD_ERR_BAD_LEN;
-			return NULL;
-		}
-		nr = data[3] >> 1;
-		pf = data[3] & 1;
-		switch (data[2]) {
-		case 0x1:
-			cmd = LAPD_CMD_RR;
-			break;
-		case 0x5:
-			cmd = LAPD_CMD_RNR;
-			break;
-		case 0x9:
-			cmd = LAPD_CMD_REJ;
-			break;
-		default:
-			LOGP(DMI, LOGL_ERROR, "LAPD unknown S cmd %x\n", data[2]);
-			*error = LAPD_ERR_UNKNOWN_S_CMD;
-			return NULL;
-		};
-	} else if ((data[2] & 3) == 3) {
-		typ = LAPD_TYPE_U;
-		pf = (data[2] >> 4) & 1;
-		int val = data[2] & ~(1 << 4);
-		switch (val) {
-		case 0x6f:
-			cmd = LAPD_CMD_SABME;
-			break;
-		case 0x0f:
-			cmd = LAPD_CMD_DM;
-			break;
-		case 0x03:
-			cmd = LAPD_CMD_UI;
-			break;
-		case 0x43:
-			cmd = LAPD_CMD_DISC;
-			break;
-		case 0x63:
-			cmd = LAPD_CMD_UA;
-			break;
-		case 0x87:
-			cmd = LAPD_CMD_FRMR;
-			break;
-		case 0xaf:
-			cmd = LAPD_CMD_XID;
-			break;
-
-		default:
-			LOGP(DMI, LOGL_ERROR, "LAPD unknown U cmd %x "
-			     "(pf %x data %x)\n", val, pf, data[2]);
-			*error = LAPD_ERR_UNKNOWN_U_CMD;
-			return NULL;
-		};
-	};
-
-	contents = &data[4];
-	if (typ == LAPD_TYPE_U)
-		contents--;
-	*ilen = len - (contents - data);
-
-	if (tei == 127)
-		lapd_tei_receive(li, contents, *ilen);
-
-	teip = teip_from_tei(li, tei);
-	if (!teip) {
-		LOGP(DMI, LOGL_NOTICE, "LAPD Unknown TEI %u\n", tei);
-		*error = LAPD_ERR_UNKNOWN_TEI;
-		return NULL;
-	}
-
-	sap = lapd_sap_find(teip, sapi);
-	if (!sap) {
-		LOGP(DMI, LOGL_INFO, "LAPD No SAP for TEI=%u / SAPI=%u, "
-			"allocating\n", tei, sapi);
-		sap = lapd_sap_alloc(teip, sapi);
-	}
-
-	DEBUGP(DMI, "<- %c %s sapi %x tei %3d cmd %x pf %x ns %3d nr %3d "
-	     "ilen %d teip %p vs %d va %d vr %d len %d\n",
-	     lapd_msg_types[typ], lapd_cmd_types[cmd], sapi, tei, command, pf,
-	     ns, nr, *ilen, teip, sap->vs, sap->va, sap->vr, len);
-
-	switch (cmd) {
-	case LAPD_CMD_I:
-		if (ns != sap->vr) {
-			DEBUGP(DMI, "LAPD ns %d != vr %d\n", ns, sap->vr);
-			if (ns == ((sap->vr - 1) & 0x7f)) {
-				LOGP(DMI, LOGL_NOTICE, "LAPD double frame, "
-					"ignoring\n");
-				cmd = 0;	// ignore
-			} else {
-				LOGP(DMI, LOGL_ERROR, "LAPD Out of order "
-					"ns %d != vr %d, ignoring\n", ns, sap->vr);
-				return NULL;
-			};
-		} else {
-			//printf("IN SEQUENCE\n");
-			sap->vr = (ns + 1) & 0x7f;	// FIXME: hack!
-		};
-
-		break;
-	case LAPD_CMD_UI:
-		break;
-	case LAPD_CMD_SABME:
-		sap->vs = 0;
-		sap->vr = 0;
-		sap->va = 0;
-
-		// ua
-		resp[l++] = data[0];
-		resp[l++] = (tei << 1) | 1;
-		resp[l++] = 0x73;
-		li->transmit_cb(resp, l, li->cbdata);
-		if (teip->state != LAPD_TEI_ACTIVE) {
-			if (teip->state == LAPD_TEI_ASSIGNED) {
-				lapd_tei_set_state(teip,
-						   LAPD_TEI_ACTIVE);
-				//printf("ASSIGNED and ACTIVE\n");
-			} else {
-#if 0
-				DEBUGP(DMI, "rr in strange state, send rej\n");
-
-				// rej
-				resp[l++] = (sap-> sapi << 2) | (li->network_side ? 0 : 2);
-				resp[l++] = (tei << 1) | 1;
-				resp[l++] = 0x09;	//rej
-				resp[l++] = ((sap->vr + 1) << 1) | 0;
-				li->transmit_cb(resp, l, li->cbdata);
-				pf = 0;	// dont reply
-#endif
-			};
-		};
-
-		*prim = LAPD_MPH_ACTIVATE_IND;
-		break;
-	case LAPD_CMD_UA:
-		sap->vs = 0;
-		sap->vr = 0;
-		sap->va = 0;
-		lapd_tei_set_state(teip, LAPD_TEI_ACTIVE);
-		lapd_sap_set_state(teip, sapi, SAP_STATE_ACTIVE);
-		*prim = LAPD_MPH_ACTIVATE_IND;
-		break;
-	case LAPD_CMD_RR:
-		sap->va = (nr & 0x7f);
-#if 0
-		if (teip->state != LAPD_TEI_ACTIVE) {
-			if (teip->state == LAPD_TEI_ASSIGNED) {
-				lapd_tei_set_state(teip, LAPD_TEI_ACTIVE);
-				*prim = LAPD_MPH_ACTIVATE_IND;
-				//printf("ASSIGNED and ACTIVE\n");
-			} else {
-#if 0
-				DEBUGP(DMI, "rr in strange " "state, send rej\n");
-
-				// rej
-				resp[l++] = (sap-> sapi << 2) | (li->network_side ? 0 : 2);
-				resp[l++] = (tei << 1) | 1;
-				resp[l++] = 0x09;	//rej
-				resp[l++] =
-				    ((sap->vr + 1) << 1) | 0;
-				li->transmit_cb(resp, l, li->cbdata);
-				pf = 0;	// dont reply
-#endif
-			};
-		};
-#endif
-		if (pf) {
-			// interrogating us, send rr
-			resp[l++] = data[0];
-			resp[l++] = (tei << 1) | 1;
-			resp[l++] = 0x01;	// rr
-			resp[l++] = (LAPD_NR(sap) << 1) | (data[3] & 1);	// pf bit from req
-
-			li->transmit_cb(resp, l, li->cbdata);
-
-		};
-		break;
-	case LAPD_CMD_FRMR:
-		// frame reject
-#if 0
-		if (teip->state == LAPD_TEI_ACTIVE)
-			*prim = LAPD_MPH_DEACTIVATE_IND;
-		lapd_tei_set_state(teip, LAPD_TEI_ASSIGNED);
-#endif
-		LOGP(DMI, LOGL_NOTICE, "frame reject, ignoring\n");
-		break;
-	case LAPD_CMD_DISC:
-		// disconnect
-		resp[l++] = data[0];
-		resp[l++] = (tei << 1) | 1;
-		resp[l++] = 0x73;
-		li->transmit_cb(resp, l, li->cbdata);
-		lapd_tei_set_state(teip, LAPD_TEI_NONE);
-		break;
-	default:
-		LOGP(DMI, LOGL_NOTICE, "unknown cmd for tei %d (cmd %x)\n",
-		     tei, cmd);
-		break;
-	}
-
-	if (typ == LAPD_TYPE_I) {
-		/* send rr
-		 * Thu Jan 22 19:17:13 2009 <4000> sangoma.c:340 read  (62/25)   4: fa 33 01 0a 
-		 * lapd <- S RR sapi 3e tei  25 cmd 0 pf 0 ns  -1 nr   5 ilen 0 teip 0x613800 vs 7 va 5 vr 2 len 4
-		 */
-
-		/* interrogating us, send rr */
-		DEBUGP(DMI, "LAPD Sending RR response\n");
-		resp[l++] = data[0];
-		resp[l++] = (tei << 1) | 1;
-		resp[l++] = 0x01;	// rr
-		resp[l++] = (LAPD_NR(sap) << 1) | (data[3] & 1);	// pf bit from req
-
-		li->transmit_cb(resp, l, li->cbdata);
-
-		if (cmd != 0) {
-			*prim = LAPD_DL_DATA_IND;
-			return contents;
-		}
-	} else if (tei != 127 && typ == LAPD_TYPE_U && cmd == LAPD_CMD_UI) {
-		*prim = LAPD_DL_UNITDATA_IND;
-		return contents;
-	}
-
-	*error = LAPD_ERR_BAD_CMD;
-	return NULL;
-};
-
-/* low-level function to send a single SABM message */
-static int lapd_send_sabm(struct lapd_instance *li, uint8_t tei, uint8_t sapi)
-{
-	struct msgb *msg = msgb_alloc_headroom(1024, 128, "LAPD SABM");
-	if (!msg)
-		return -ENOMEM;
-
-	LOGP(DMI, LOGL_INFO, "LAPD Sending SABM for TEI=%u, SAPI=%u\n", tei, sapi);
-
-	msgb_put_u8(msg, (sapi << 2) | (li->network_side ? 2 : 0));
-	msgb_put_u8(msg, (tei << 1) | 1);
-	msgb_put_u8(msg, 0x7F);
-
-	li->transmit_cb(msg->data, msg->len, li->cbdata);
-
-	msgb_free(msg);
-
-	return 0;
-}
-
-/* timer call-back function for SABM re-transmission */
-static void sabme_timer_cb(void *_sap)
-{
-	struct lapd_sap *sap = _sap;
-
-	lapd_send_sabm(sap->tei->li, sap->tei->tei, sap->sapi);
-
-	if (sap->state == SAP_STATE_SABM_RETRANS)
-		osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL);
-}
-
-/* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
-int lapd_sap_start(struct lapd_instance *li, uint8_t tei, uint8_t sapi)
-{
-	struct lapd_sap *sap;
-	struct lapd_tei *teip;
-
-	teip = teip_from_tei(li, tei);
-	if (!teip)
-		teip = lapd_tei_alloc(li, tei);
-
-	sap = lapd_sap_find(teip, sapi);
-	if (sap)
-		return -EEXIST;
-
-	sap = lapd_sap_alloc(teip, sapi);
-
-	lapd_sap_set_state(teip, sapi, SAP_STATE_SABM_RETRANS);
-
-	return 0;
-}
-
-/* Stop a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
-int lapd_sap_stop(struct lapd_instance *li, uint8_t tei, uint8_t sapi)
-{
-	struct lapd_tei *teip;
-	struct lapd_sap *sap;
-
-	teip = teip_from_tei(li, tei);
-	if (!teip)
-		return -ENODEV;
-
-	sap = lapd_sap_find(teip, sapi);
-	if (!sap)
-		return -ENODEV;
-
-	lapd_sap_set_state(teip, sapi, SAP_STATE_INACTIVE);
-
-	llist_del(&sap->list);
-	talloc_free(sap);
-
-	return 0;
-}
-
-/* Transmit Data (I-Frame) on the given LAPD Instance / TEI / SAPI */
-void lapd_transmit(struct lapd_instance *li, uint8_t tei, uint8_t sapi,
-		   uint8_t *data, unsigned int len)
-{
-	struct lapd_tei *teip = teip_from_tei(li, tei);
-	struct lapd_sap *sap;
-
-	if (!teip) {
-		LOGP(DMI, LOGL_ERROR, "LAPD Cannot transmit on "
-		     "non-existing TEI %u\n", tei);
-		return;
-	}
-
-	sap = lapd_sap_find(teip, sapi);
-	if (!sap) {
-		LOGP(DMI, LOGL_INFO, "LAPD Tx on unknown SAPI=%u "
-		     "in TEI=%u, allocating\n", sapi, tei);
-		sap = lapd_sap_alloc(teip, sapi);
-	}
-
-	/* prepend stuff */
-	uint8_t buf[10000];
-	memset(buf, 0, sizeof(buf));
-	memmove(buf + 4, data, len);
-	len += 4;
-
-	buf[0] = (sapi << 2) | (li->network_side ? 2 : 0);
-	buf[1] = (tei << 1) | 1;
-	buf[2] = (LAPD_NS(sap) << 1);
-	buf[3] = (LAPD_NR(sap) << 1) | 0;
-
-	sap->vs = (sap->vs + 1) & 0x7f;
-
-	li->transmit_cb(buf, len, li->cbdata);
-};
-
-/* Allocate a new LAPD instance */
-struct lapd_instance *lapd_instance_alloc(int network_side,
-					  void (*tx_cb)(uint8_t *data, int len,
-							void *cbdata), void *cbdata)
-{
-	struct lapd_instance *li;
-
-	li = talloc_zero(NULL, struct lapd_instance);
-	if (!li)
-		return NULL;
-
-	li->transmit_cb = tx_cb;
-	li->cbdata = cbdata;
-	li->network_side = network_side;
-	INIT_LLIST_HEAD(&li->tei_list);
-
-	return li;
-}
diff --git a/openbsc/src/libabis/input/lapd.h b/openbsc/src/libabis/input/lapd.h
deleted file mode 100644
index dd22028..0000000
--- a/openbsc/src/libabis/input/lapd.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef OPENBSC_LAPD_H
-#define OPENBSC_LAPD_H
-
-#include <stdint.h>
-
-#include <osmocom/core/linuxlist.h>
-
-typedef enum {
-	LAPD_MPH_NONE	= 0,
-
-	LAPD_MPH_ACTIVATE_IND,
-	LAPD_MPH_DEACTIVATE_IND,
-
-	LAPD_DL_DATA_IND,
-	LAPD_DL_UNITDATA_IND,
-
-} lapd_mph_type;
-
-struct lapd_instance {
-	struct llist_head list;		/* list of LAPD instances */
-	int network_side;
-
-	void (*transmit_cb)(uint8_t *data, int len, void *cbdata);
-	void *cbdata;
-
-	struct llist_head tei_list;	/* list of TEI in this LAPD instance */
-};
-
-enum lapd_recv_errors {
-	LAPD_ERR_NONE = 0,
-	LAPD_ERR_BAD_LEN,
-	LAPD_ERR_BAD_ADDR,
-	LAPD_ERR_UNKNOWN_S_CMD,
-	LAPD_ERR_UNKNOWN_U_CMD,
-	LAPD_ERR_UNKNOWN_TEI,
-	LAPD_ERR_BAD_CMD,
-	__LAPD_ERR_MAX
-};
-
-extern uint8_t *lapd_receive(struct lapd_instance *li, uint8_t *data,
-			     unsigned int len, int *ilen, lapd_mph_type *prim,
-			     int *error);
-
-extern void lapd_transmit(struct lapd_instance *li, uint8_t tei, uint8_t sapi,
-			  uint8_t *data, unsigned int len);
-
-struct lapd_instance *lapd_instance_alloc(int network_side,
-					  void (*tx_cb)(uint8_t *data, int len,
-							void *cbdata), void *cbdata);
-
-
-/* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
-int lapd_sap_start(struct lapd_instance *li, uint8_t tei, uint8_t sapi);
-
-/* Stop a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
-int lapd_sap_stop(struct lapd_instance *li, uint8_t tei, uint8_t sapi);
-
-#endif /* OPENBSC_LAPD_H */
diff --git a/openbsc/src/libabis/input/misdn.c b/openbsc/src/libabis/input/misdn.c
deleted file mode 100644
index ab92d61..0000000
--- a/openbsc/src/libabis/input/misdn.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/* OpenBSC Abis input driver for mISDNuser */
-
-/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <mISDNif.h>
-
-//#define AF_COMPATIBILITY_FUNC
-//#include <compat_af_isdn.h>
-#ifndef AF_ISDN
-#define AF_ISDN 34
-#define PF_ISDN AF_ISDN
-#endif
-
-#include <osmocom/core/select.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.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/signal.h>
-
-#define TS1_ALLOC_SIZE	300
-
-struct prim_name {
-	unsigned int prim;
-	const char *name;
-};
-
-const struct prim_name prim_names[] = {
-	{ PH_CONTROL_IND, "PH_CONTROL_IND" },
-	{ PH_DATA_IND, "PH_DATA_IND" },
-	{ PH_DATA_CNF, "PH_DATA_CNF" },
-	{ PH_ACTIVATE_IND, "PH_ACTIVATE_IND" },
-	{ DL_ESTABLISH_IND, "DL_ESTABLISH_IND" },
-	{ DL_ESTABLISH_CNF, "DL_ESTABLISH_CNF" },
-	{ DL_RELEASE_IND, "DL_RELEASE_IND" },
-	{ DL_RELEASE_CNF, "DL_RELEASE_CNF" },
-	{ DL_DATA_IND, "DL_DATA_IND" },
-	{ DL_UNITDATA_IND, "DL_UNITDATA_IND" },
-	{ DL_INFORMATION_IND, "DL_INFORMATION_IND" },
-	{ MPH_ACTIVATE_IND, "MPH_ACTIVATE_IND" },
-	{ MPH_DEACTIVATE_IND, "MPH_DEACTIVATE_IND" },
-};
-
-const char *get_prim_name(unsigned int prim)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(prim_names); i++) {
-		if (prim_names[i].prim == prim)
-			return prim_names[i].name;
-	}
-
-	return "UNKNOWN";
-}
-
-static int handle_ts1_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *link;
-	struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "mISDN TS1");
-	struct sockaddr_mISDN l2addr;
-	struct mISDNhead *hh;
-	socklen_t alen;
-	int ret;
-
-	if (!msg)
-		return -ENOMEM;
-
-	hh = (struct mISDNhead *) msg->data;
-
-	alen = sizeof(l2addr);
-	ret = recvfrom(bfd->fd, msg->data, 300, 0,
-		       (struct sockaddr *) &l2addr, &alen);
-	if (ret < 0) {
-		fprintf(stderr, "recvfrom error  %s\n", strerror(errno));
-		return ret;
-	}
-
-	if (alen != sizeof(l2addr)) {
-		fprintf(stderr, "%s error len\n", __func__);
-		return -EINVAL;
-	}
-
-	msgb_put(msg, ret);
-
-	DEBUGP(DMI, "alen =%d, dev(%d) channel(%d) sapi(%d) tei(%d)\n",
-		alen, l2addr.dev, l2addr.channel, l2addr.sapi, l2addr.tei);
-
-	DEBUGP(DMI, "<= len = %d, prim(0x%x) id(0x%x): %s\n",
-		ret, hh->prim, hh->id, get_prim_name(hh->prim));
-
-	switch (hh->prim) {
-	case DL_INFORMATION_IND:
-		/* mISDN tells us which channel number is allocated for this
-		 * tuple of (SAPI, TEI). */
-		DEBUGP(DMI, "DL_INFORMATION_IND: use channel(%d) sapi(%d) tei(%d) for now\n",
-			l2addr.channel, l2addr.sapi, l2addr.tei);
-		link = e1inp_lookup_sign_link(e1i_ts, l2addr.tei, l2addr.sapi);
-		if (!link) {
-			DEBUGPC(DMI, "mISDN message for unknown sign_link\n");
-			msgb_free(msg);
-			return -EINVAL;
-		}
-		/* save the channel number in the driver private struct */
-		link->driver.misdn.channel = l2addr.channel;
-		break;
-	case DL_ESTABLISH_IND:
-		DEBUGP(DMI, "DL_ESTABLISH_IND: channel(%d) sapi(%d) tei(%d)\n",
-			l2addr.channel, l2addr.sapi, l2addr.tei);
-		/* For some strange reason, sometimes the DL_INFORMATION_IND tells
-		 * us the wrong channel, and we only get the real channel number
-		 * during the DL_ESTABLISH_IND */
-		link = e1inp_lookup_sign_link(e1i_ts, l2addr.tei, l2addr.sapi);
-		if (!link) {
-			DEBUGPC(DMI, "mISDN message for unknown sign_link\n");
-			msgb_free(msg);
-			return -EINVAL;
-		}
-		/* save the channel number in the driver private struct */
-		link->driver.misdn.channel = l2addr.channel;
-		ret = e1inp_event(e1i_ts, S_INP_TEI_UP, l2addr.tei, l2addr.sapi);
-		break;
-	case DL_RELEASE_IND:
-		DEBUGP(DMI, "DL_RELEASE_IND: channel(%d) sapi(%d) tei(%d)\n",
-		l2addr.channel, l2addr.sapi, l2addr.tei);
-		ret = e1inp_event(e1i_ts, S_INP_TEI_DN, l2addr.tei, l2addr.sapi);
-		break;
-	case DL_DATA_IND:
-	case DL_UNITDATA_IND:
-		msg->l2h = msg->data + MISDN_HEADER_LEN;
-		DEBUGP(DMI, "RX: %s\n", osmo_hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
-		ret = e1inp_rx_ts(e1i_ts, msg, l2addr.tei, l2addr.sapi);
-		break;
-	case PH_ACTIVATE_IND:
-		DEBUGP(DMI, "PH_ACTIVATE_IND: channel(%d) sapi(%d) tei(%d)\n",
-		l2addr.channel, l2addr.sapi, l2addr.tei);
-		break;
-	case PH_DEACTIVATE_IND:
-		DEBUGP(DMI, "PH_DEACTIVATE_IND: channel(%d) sapi(%d) tei(%d)\n",
-		l2addr.channel, l2addr.sapi, l2addr.tei);
-		break;
-	default:
-		break;
-	}
-	return ret;
-}
-
-static int ts_want_write(struct e1inp_ts *e1i_ts)
-{
-	/* We never include the mISDN B-Channel FD into the
-	 * writeset, since it doesn't support poll() based
-	 * write flow control */		
-	if (e1i_ts->type == E1INP_TS_TYPE_TRAU)
-		return 0;
-
-	e1i_ts->driver.misdn.fd.when |= BSC_FD_WRITE;
-
-	return 0;
-}
-
-static void timeout_ts1_write(void *data)
-{
-	struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
-
-	/* trigger write of ts1, due to tx delay timer */
-	ts_want_write(e1i_ts);
-}
-
-static int handle_ts1_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct e1inp_sign_link *sign_link;
-	struct sockaddr_mISDN sa;
-	struct msgb *msg;
-	struct mISDNhead *hh;
-	uint8_t *l2_data;
-	int ret;
-
-	bfd->when &= ~BSC_FD_WRITE;
-
-	/* get the next msg for this timeslot */
-	msg = e1inp_tx_ts(e1i_ts, &sign_link);
-	if (!msg) {
-		/* no message after tx delay timer */
-		return 0;
-	}
-
-	l2_data = msg->data;
-
-	/* prepend the mISDNhead */
-	hh = (struct mISDNhead *) msgb_push(msg, sizeof(*hh));
-	hh->prim = DL_DATA_REQ;
-
-	DEBUGP(DMI, "TX channel(%d) TEI(%d) SAPI(%d): %s\n",
-		sign_link->driver.misdn.channel, sign_link->tei,
-		sign_link->sapi, osmo_hexdump(l2_data, msg->len - MISDN_HEADER_LEN));
-
-	/* construct the sockaddr */
-	sa.family = AF_ISDN;
-	sa.sapi = sign_link->sapi;
-	sa.dev = sign_link->tei;
-	sa.channel = sign_link->driver.misdn.channel;
-
-	ret = sendto(bfd->fd, msg->data, msg->len, 0,
-		     (struct sockaddr *)&sa, sizeof(sa));
-	if (ret < 0)
-		fprintf(stderr, "%s sendto failed %d\n", __func__, ret);
-	msgb_free(msg);
-
-	/* set tx delay timer for next event */
-	e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
-	e1i_ts->sign.tx_timer.data = e1i_ts;
-	osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
-
-	return ret;
-}
-
-#define BCHAN_TX_GRAN	160
-/* write to a B channel TS */
-static int handle_tsX_write(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct mISDNhead *hh;
-	uint8_t tx_buf[BCHAN_TX_GRAN + sizeof(*hh)];
-	struct subch_mux *mx = &e1i_ts->trau.mux;
-	int ret;
-
-	hh = (struct mISDNhead *) tx_buf;
-	hh->prim = PH_DATA_REQ;
-
-	subchan_mux_out(mx, tx_buf+sizeof(*hh), BCHAN_TX_GRAN);
-
-	DEBUGP(DMIB, "BCHAN TX: %s\n",
-		osmo_hexdump(tx_buf+sizeof(*hh), BCHAN_TX_GRAN));
-
-	ret = send(bfd->fd, tx_buf, sizeof(*hh) + BCHAN_TX_GRAN, 0);
-	if (ret < sizeof(*hh) + BCHAN_TX_GRAN)
-		DEBUGP(DMIB, "send returns %d instead of %zu\n", ret,
-			sizeof(*hh) + BCHAN_TX_GRAN);
-
-	return ret;
-}
-
-#define TSX_ALLOC_SIZE 4096
-/* FIXME: read from a B channel TS */
-static int handle_tsX_read(struct osmo_fd *bfd)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
-	struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE, "mISDN TSx");
-	struct mISDNhead *hh;
-	int ret;
-
-	if (!msg)
-		return -ENOMEM;
-
-	hh = (struct mISDNhead *) msg->data;
-
-	ret = recv(bfd->fd, msg->data, TSX_ALLOC_SIZE, 0);
-	if (ret < 0) {
-		fprintf(stderr, "recvfrom error  %s\n", strerror(errno));
-		return ret;
-	}
-
-	msgb_put(msg, ret);
-
-	if (hh->prim != PH_CONTROL_IND)
-		DEBUGP(DMIB, "<= BCHAN len = %d, prim(0x%x) id(0x%x): %s\n",
-			ret, hh->prim, hh->id, get_prim_name(hh->prim));
-
-	switch (hh->prim) {
-	case PH_DATA_IND:
-		msg->l2h = msg->data + MISDN_HEADER_LEN;
-		DEBUGP(DMIB, "BCHAN RX: %s\n",
-			osmo_hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
-		ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
-		break;
-	case PH_ACTIVATE_IND:
-	case PH_DATA_CNF:
-		/* physical layer indicates that data has been sent,
-		 * we thus can send some more data */
-		ret = handle_tsX_write(bfd);
-	default:
-		break;
-	}
-	/* FIXME: why do we free signalling msgs in the caller, and trau not? */
-	msgb_free(msg);
-
-	return ret;
-}
-
-/* callback from select.c in case one of the fd's can be read/written */
-static int misdn_fd_cb(struct osmo_fd *bfd, unsigned int what)
-{
-	struct e1inp_line *line = bfd->data;
-	unsigned int ts_nr = bfd->priv_nr;
-	unsigned int idx = ts_nr-1;
-	struct e1inp_ts *e1i_ts = &line->ts[idx];
-	int rc = 0;
-
-	switch (e1i_ts->type) {
-	case E1INP_TS_TYPE_SIGN:
-		if (what & BSC_FD_READ)
-			rc = handle_ts1_read(bfd);
-		if (what & BSC_FD_WRITE)
-			rc = handle_ts1_write(bfd);
-		break;
-	case E1INP_TS_TYPE_TRAU:
-		if (what & BSC_FD_READ)
-			rc = handle_tsX_read(bfd);
-		/* We never include the mISDN B-Channel FD into the
-		 * writeset, since it doesn't support poll() based
-		 * write flow control */		
-		break;
-	default:
-		fprintf(stderr, "unknown E1 TS type %u\n", e1i_ts->type);
-		break;
-	}
-
-	return rc;
-}
-
-static int activate_bchan(struct e1inp_line *line, int ts, int act)
-{
-	struct mISDNhead hh;
-	int ret;
-	unsigned int idx = ts-1;
-	struct e1inp_ts *e1i_ts = &line->ts[idx];
-	struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd;
-
-	fprintf(stdout, "activate bchan\n");
-	if (act)
-		hh.prim = PH_ACTIVATE_REQ;
-	else
-		hh.prim = PH_DEACTIVATE_REQ;
-
-	hh.id = MISDN_ID_ANY;
-	ret = sendto(bfd->fd, &hh, sizeof(hh), 0, NULL, 0);
-	if (ret < 0) {
-		fprintf(stdout, "could not send ACTIVATE_RQ %s\n",
-			strerror(errno));
-	}
-
-	return ret;
-}
-
-static int mi_e1_line_update(struct e1inp_line *line);
-
-struct e1inp_driver misdn_driver = {
-	.name = "misdn",
-	.want_write = ts_want_write,
-	.default_delay = 50000,
-	.line_update = &mi_e1_line_update,
-};
-
-static int mi_e1_setup(struct e1inp_line *line, int release_l2)
-{
-	int ts, ret;
-
-	/* TS0 is CRC4, don't need any fd for it */
-	for (ts = 1; ts < NUM_E1_TS; ts++) {
-		unsigned int idx = ts-1;
-		struct e1inp_ts *e1i_ts = &line->ts[idx];
-		struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd;
-		struct sockaddr_mISDN addr;
-
-		bfd->data = line;
-		bfd->priv_nr = ts;
-		bfd->cb = misdn_fd_cb;
-
-		switch (e1i_ts->type) {
-		case E1INP_TS_TYPE_NONE:
-			continue;
-			break;
-		case E1INP_TS_TYPE_SIGN:
-			bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_LAPD_NT);
-			bfd->when = BSC_FD_READ;
-			break;
-		case E1INP_TS_TYPE_TRAU:
-			bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_RAW);
-			/* We never include the mISDN B-Channel FD into the
-	 		* writeset, since it doesn't support poll() based
-	 		* write flow control */		
-			bfd->when = BSC_FD_READ;
-			break;
-		}
-
-		if (bfd->fd < 0) {
-			fprintf(stderr, "%s could not open socket %s\n",
-				__func__, strerror(errno));
-			return bfd->fd;
-		}
-
-		memset(&addr, 0, sizeof(addr));
-		addr.family = AF_ISDN;
-		addr.dev = line->num;
-		switch (e1i_ts->type) {
-		case E1INP_TS_TYPE_SIGN:
-			addr.channel = 0;
-			/* SAPI not supported yet in kernel */
-			//addr.sapi = e1inp_ts->sign.sapi;
-			addr.sapi = 0;
-			addr.tei = GROUP_TEI;
-			break;
-		case E1INP_TS_TYPE_TRAU:
-			addr.channel = ts;
-			break;
-		default:
-			DEBUGP(DMI, "unsupported E1 TS type: %u\n",
-				e1i_ts->type);
-			break;
-		}
-
-		ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
-		if (ret < 0) {
-			fprintf(stderr, "could not bind l2 socket %s\n",
-				strerror(errno));
-			return -EIO;
-		}
-
-		if (e1i_ts->type == E1INP_TS_TYPE_SIGN) {
-			ret = ioctl(bfd->fd, IMCLEAR_L2, &release_l2);
-			if (ret < 0) {
-				fprintf(stderr, "could not send IOCTL IMCLEAN_L2 %s\n", strerror(errno));
-				return -EIO;
-			}
-		}
-
-		/* FIXME: only activate B-Channels once we start to
-		 * use them to conserve CPU power */
-		if (e1i_ts->type == E1INP_TS_TYPE_TRAU)
-			activate_bchan(line, ts, 1);
-
-		ret = osmo_fd_register(bfd);
-		if (ret < 0) {
-			fprintf(stderr, "could not register FD: %s\n",
-				strerror(ret));
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int mi_e1_line_update(struct e1inp_line *line)
-{
-	struct mISDN_devinfo devinfo;
-	int sk, ret, cnt;
-
-	if (line->driver != &misdn_driver)
-		return -EINVAL;
-
-	/* open the ISDN card device */
-	sk = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
-	if (sk < 0) {
-		fprintf(stderr, "%s could not open socket %s\n",
-			__func__, strerror(errno));
-		return sk;
-	}
-
-	ret = ioctl(sk, IMGETCOUNT, &cnt);
-	if (ret) {
-		fprintf(stderr, "%s error getting interf count: %s\n",
-			__func__, strerror(errno));
-		close(sk);
-		return -ENODEV;
-	}
-	//DEBUGP(DMI,"%d device%s found\n", cnt, (cnt==1)?"":"s");
-	printf("%d device%s found\n", cnt, (cnt==1)?"":"s");
-#if 1
-	devinfo.id = line->num;
-	ret = ioctl(sk, IMGETDEVINFO, &devinfo);
-	if (ret < 0) {
-		fprintf(stdout, "error getting info for device %d: %s\n",
-			line->num, strerror(errno));
-		return -ENODEV;
-	}
-	fprintf(stdout, "        id:             %d\n", devinfo.id);
-	fprintf(stdout, "        Dprotocols:     %08x\n", devinfo.Dprotocols);
-	fprintf(stdout, "        Bprotocols:     %08x\n", devinfo.Bprotocols);
-	fprintf(stdout, "        protocol:       %d\n", devinfo.protocol);
-	fprintf(stdout, "        nrbchan:        %d\n", devinfo.nrbchan);
-	fprintf(stdout, "        name:           %s\n", devinfo.name);
-#endif
-
-	if (!(devinfo.Dprotocols & (1 << ISDN_P_NT_E1))) {
-		fprintf(stderr, "error: card is not of type E1 (NT-mode)\n");
-		return -EINVAL;
-	}
-
-	ret = mi_e1_setup(line, 1);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-void e1inp_misdn_init(void)
-{
-	/* register the driver with the core */
-	e1inp_driver_register(&misdn_driver);
-}
diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c
index a41414a..027a263 100644
--- a/openbsc/src/libbsc/abis_nm.c
+++ b/openbsc/src/libbsc/abis_nm.c
@@ -43,7 +43,7 @@
 #include <openbsc/abis_nm.h>
 #include <openbsc/misdn.h>
 #include <openbsc/signal.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 
 #define OM_ALLOC_SIZE		1024
 #define OM_HEADROOM_SIZE	128
@@ -114,6 +114,26 @@
 				   "OML");
 }
 
+int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml)
+{
+	struct e1inp_sign_link *sign_link = msg->dst;
+
+	msg->l2h = msg->data;
+
+	if (!msg->dst) {
+		LOGP(DNM, LOGL_ERROR, "%s: msg->dst == NULL\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Check for TRX-specific OML link first */
+	if (to_trx_oml) {
+		if (!sign_link->trx->oml_link)
+			return -ENODEV;
+		msg->dst = sign_link->trx->oml_link;
+	}
+	return abis_sendmsg(msg);
+}
+
 /* Send a OML NM Message from BSC to BTS */
 static int abis_nm_queue_msg(struct gsm_bts *bts, struct msgb *msg)
 {
@@ -480,7 +500,7 @@
 	return 0;
 }
 
-static void abis_nm_queue_send_next(struct gsm_bts *bts)
+void abis_nm_queue_send_next(struct gsm_bts *bts)
 {
 	int wait = 0;
 	struct msgb *msg;
diff --git a/openbsc/src/libbsc/abis_om2000.c b/openbsc/src/libbsc/abis_om2000.c
index a4a3f23..2216462 100644
--- a/openbsc/src/libbsc/abis_om2000.c
+++ b/openbsc/src/libbsc/abis_om2000.c
@@ -40,7 +40,7 @@
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_om2000.h>
 #include <openbsc/signal.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 
 #define OM_ALLOC_SIZE		1024
 #define OM_HEADROOM_SIZE	128
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 8645268..b4babc3 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -38,7 +38,7 @@
 #include <openbsc/signal.h>
 #include <openbsc/meas_rep.h>
 #include <openbsc/rtp_proxy.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <osmocom/gsm/rsl.h>
 #include <osmocom/core/talloc.h>
 
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 1d885db..84dfa6e 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -82,7 +82,7 @@
 
 	llist_for_each_entry(bts, &net->bts_list, list) {
 		LOGP(DNM, LOGL_NOTICE, "shutting down OML for BTS %u\n", bts->nr);
-		osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_BTS_CLOSE_OM, bts);
+		osmo_signal_dispatch(SS_L_GLOBAL, S_GLOBAL_BTS_CLOSE_OM, bts);
 	}
 
 	return 0;
@@ -274,11 +274,11 @@
 	struct gsm_bts_trx *trx = isd->trx;
 	int ts_no, lchan_no;
 
-	if (subsys != SS_INPUT)
+	if (subsys != SS_L_INPUT)
 		return -EINVAL;
 
 	switch (signal) {
-	case S_INP_TEI_UP:
+	case S_L_INP_TEI_UP:
 		if (isd->link_type == E1INP_SIGN_OML) {
 			/* TODO: this is required for the Nokia BTS, hopping is configured
 			   during OML, other MA is not set.  */
@@ -300,8 +300,8 @@
 		if (isd->link_type == E1INP_SIGN_RSL)
 			bootstrap_rsl(trx);
 		break;
-	case S_INP_TEI_DN:
-		LOGP(DMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", isd->link_type, trx);
+	case S_L_INP_TEI_DN:
+		LOGP(DLMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", isd->link_type, trx);
 
 		if (isd->link_type == E1INP_SIGN_OML)
 			osmo_counter_inc(trx->bts->network->stats.bts.oml_fail);
@@ -469,7 +469,7 @@
 		return rc;
 
 	osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
-	osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
 
 	llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
 		rc = bootstrap_bts(bts);
@@ -477,14 +477,7 @@
 			LOGP(DNM, LOGL_FATAL, "Error bootstrapping BTS\n");
 			return rc;
 		}
-		switch (bts->type) {
-		case GSM_BTS_TYPE_NANOBTS:
-		case GSM_BTS_TYPE_HSL_FEMTO:
-			break;
-		default:
-			rc = e1_reconfig_bts(bts);
-			break;
-		}
+		rc = e1_reconfig_bts(bts);
 		if (rc < 0) {
 			LOGP(DNM, LOGL_FATAL, "Error enabling E1 input driver\n");
 			return rc;
diff --git a/openbsc/src/libbsc/bsc_msc.c b/openbsc/src/libbsc/bsc_msc.c
index e9ffce3..66288a3 100644
--- a/openbsc/src/libbsc/bsc_msc.c
+++ b/openbsc/src/libbsc/bsc_msc.c
@@ -21,11 +21,13 @@
 
 #include <openbsc/bsc_msc.h>
 #include <openbsc/debug.h>
-#include <openbsc/ipaccess.h>
+#include <osmocom/abis/ipaccess.h>
 
 #include <osmocom/core/write_queue.h>
 #include <osmocom/core/talloc.h>
 
+#include <osmocom/gsm/tlv.h>
+
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <errno.h>
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 8a5c7fd..a98779d 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -30,7 +30,7 @@
 
 #include <osmocom/core/linuxlist.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_om2000.h>
 #include <osmocom/core/utils.h>
@@ -506,10 +506,13 @@
 	case GSM_BTS_TYPE_NANOBTS:
 		vty_out(vty, "  ip.access unit_id %u %u%s",
 			bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
-		vty_out(vty, "  oml ip.access stream_id %u%s", bts->oml_tei, VTY_NEWLINE);
+		vty_out(vty, "  oml ip.access stream_id %u line %u%s",
+			bts->oml_tei, bts->oml_e1_link.e1_nr, VTY_NEWLINE);
 		break;
 	case GSM_BTS_TYPE_HSL_FEMTO:
 		vty_out(vty, "  hsl serial-number %lu%s", bts->hsl.serno, VTY_NEWLINE);
+		vty_out(vty, "  oml hsl line %u%s",
+			bts->oml_e1_link.e1_nr, VTY_NEWLINE);
 		break;
 	default:
 		config_write_e1_link(vty, &bts->oml_e1_link, "  oml ");
@@ -1507,12 +1510,12 @@
 
 DEFUN(cfg_bts_stream_id,
       cfg_bts_stream_id_cmd,
-      "oml ip.access stream_id <0-255>",
+      "oml ip.access stream_id <0-255> line E1_LINE",
 	OML_STR IPA_STR
       "Set the ip.access Stream ID of the OML link of this BTS\n")
 {
 	struct gsm_bts *bts = vty->index;
-	int stream_id = atoi(argv[0]);
+	int stream_id = atoi(argv[0]), linenr = atoi(argv[1]);
 
 	if (!is_ipaccess_bts(bts)) {
 		vty_out(vty, "%% BTS is not of ip.access type%s", VTY_NEWLINE);
@@ -1520,6 +1523,27 @@
 	}
 
 	bts->oml_tei = stream_id;
+	/* This is used by e1inp_bind_ops callback for each BTS model. */
+	bts->oml_e1_link.e1_nr = linenr;
+
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bts_hsl_oml,
+      cfg_bts_hsl_oml_cmd,
+      "oml hsl line E1_LINE",
+      OML_STR "HSL femto Specific Options"
+      "Set OML link of this HSL femto BTS\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int linenr = atoi(argv[0]);
+
+	if (!(bts->type == GSM_BTS_TYPE_HSL_FEMTO)) {
+		vty_out(vty, "%% BTS is not of HSL type%s", VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	bts->oml_e1_link.e1_nr = linenr;
 
 	return CMD_SUCCESS;
 }
@@ -2624,6 +2648,7 @@
 	install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
 	install_element(BTS_NODE, &cfg_bts_serno_cmd);
 	install_element(BTS_NODE, &cfg_bts_stream_id_cmd);
+	install_element(BTS_NODE, &cfg_bts_hsl_oml_cmd);
 	install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
 	install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
 	install_element(BTS_NODE, &cfg_bts_challoc_cmd);
diff --git a/openbsc/src/libbsc/bts_ericsson_rbs2000.c b/openbsc/src/libbsc/bts_ericsson_rbs2000.c
index 9c98a9f..28e7df4 100644
--- a/openbsc/src/libbsc/bts_ericsson_rbs2000.c
+++ b/openbsc/src/libbsc/bts_ericsson_rbs2000.c
@@ -26,10 +26,10 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_om2000.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/signal.h>
 
-#include "../libabis/input/lapd.h"
+#include <osmocom/abis/lapd.h>
 
 static void bootstrap_om_bts(struct gsm_bts *bts)
 {
@@ -83,7 +83,7 @@
 {
 	struct gsm_bts *bts;
 
-	if (subsys != SS_GLOBAL)
+	if (subsys != SS_L_GLOBAL)
 		return 0;
 
 	switch (signal) {
@@ -103,11 +103,11 @@
 {
 	struct input_signal_data *isd = signal_data;
 
-	if (subsys != SS_INPUT)
+	if (subsys != SS_L_INPUT)
 		return 0;
 
 	switch (signal) {
-	case S_INP_TEI_UP:
+	case S_L_INP_TEI_UP:
 		switch (isd->link_type) {
 		case E1INP_SIGN_OML:
 			if (isd->trx->bts->type != GSM_BTS_TYPE_RBS2000)
@@ -119,18 +119,18 @@
 			break;
 		}
 		break;
-	case S_INP_LINE_INIT:
+	case S_L_INP_LINE_INIT:
 		/* Right now Ericsson RBS are only supported on DAHDI */
 		if (strcasecmp(isd->line->driver->name, "DAHDI"))
 			break;
 		start_sabm_in_line(isd->line, 1);
 		break;
-	case S_INP_LINE_ALARM:
+	case S_L_INP_LINE_ALARM:
 		if (strcasecmp(isd->line->driver->name, "DAHDI"))
 			break;
 		start_sabm_in_line(isd->line, 0);
 		break;
-	case S_INP_LINE_NOALARM:
+	case S_L_INP_LINE_NOALARM:
 		if (strcasecmp(isd->line->driver->name, "DAHDI"))
 			break;
 		start_sabm_in_line(isd->line, 1);
@@ -244,12 +244,18 @@
 
 static int bts_model_rbs2k_start(struct gsm_network *net);
 
+static void bts_model_rbs2k_e1line_bind_ops(struct e1inp_line *line)
+{
+	e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
+}
+
 static struct gsm_bts_model model_rbs2k = {
 	.type = GSM_BTS_TYPE_RBS2000,
 	.name = "rbs2000",
 	.start = bts_model_rbs2k_start,
 	.oml_rcvmsg = &abis_om2k_rcvmsg,
 	.config_write_bts = &config_write_bts,
+	.e1line_bind_ops = &bts_model_rbs2k_e1line_bind_ops,
 };
 
 static int bts_model_rbs2k_start(struct gsm_network *net)
@@ -260,8 +266,8 @@
 	gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
 	gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
 
-	osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
-	osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
 	osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
 
 	return 0;
diff --git a/openbsc/src/libbsc/bts_hsl_femtocell.c b/openbsc/src/libbsc/bts_hsl_femtocell.c
index 8463202..ebab34a 100644
--- a/openbsc/src/libbsc/bts_hsl_femtocell.c
+++ b/openbsc/src/libbsc/bts_hsl_femtocell.c
@@ -28,13 +28,18 @@
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/signal.h>
-#include <openbsc/e1_input.h>
+#include <openbsc/debug.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/abis/ipaccess.h>
 
 static int bts_model_hslfemto_start(struct gsm_network *net);
+static void bts_model_hslfemto_e1line_bind_ops(struct e1inp_line *line);
 
 static struct gsm_bts_model model_hslfemto = {
 	.type = GSM_BTS_TYPE_HSL_FEMTO,
 	.start = bts_model_hslfemto_start,
+	.e1line_bind_ops = &bts_model_hslfemto_e1line_bind_ops,
 	.nm_att_tlvdef = {
 		.def = {
 			/* no HSL specific OML attributes that we know of */
@@ -121,7 +126,7 @@
 	cur = msgb_put(msg, sizeof(oml_arfcn_bsic));
 	memcpy(msg->data, oml_arfcn_bsic, sizeof(oml_arfcn_bsic));
 	msg->dst = bts->c0->rsl_link;
-	_abis_nm_sendmsg(msg, 0);
+	abis_sendmsg(msg);
 
 	/* Delay the OPSTART until after SI have been set via RSL */
 	//abis_nm_opstart(bts, NM_OC_BTS, 255, 255, 255);
@@ -135,11 +140,11 @@
 {
 	struct input_signal_data *isd = signal_data;
 
-	if (subsys != SS_INPUT)
+	if (subsys != SS_L_INPUT)
 		return 0;
 
 	switch (signal) {
-	case S_INP_TEI_UP:
+	case S_L_INP_TEI_UP:
 		switch (isd->link_type) {
 		case E1INP_SIGN_OML:
 			if (isd->trx->bts->type == GSM_BTS_TYPE_HSL_FEMTO)
@@ -151,6 +156,8 @@
 	return 0;
 }
 
+static struct gsm_network *hsl_gsmnet;
+
 static int bts_model_hslfemto_start(struct gsm_network *net)
 {
 	model_hslfemto.features.data = &model_hslfemto._features_data[0];
@@ -159,13 +166,147 @@
 	gsm_btsmodel_set_feature(&model_hslfemto, BTS_FEAT_GPRS);
 	gsm_btsmodel_set_feature(&model_hslfemto, BTS_FEAT_EGPRS);
 
-	osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
 
-	/* Call A-bis input driver, start socket for OML and RSL. */
-	return hsl_setup(net);
+	hsl_gsmnet = net;
+	return 0;
 }
 
 int bts_model_hslfemto_init(void)
 {
 	return gsm_bts_model_register(&model_hslfemto);
 }
+
+#define OML_UP		0x0001
+#define RSL_UP		0x0002
+
+struct gsm_bts *find_bts_by_serno(struct gsm_network *net, uint64_t serno)
+{
+	struct gsm_bts *bts;
+
+	llist_for_each_entry(bts, &net->bts_list, list) {
+		if (bts->type != GSM_BTS_TYPE_HSL_FEMTO)
+			continue;
+
+		if (serno == bts->hsl.serno)
+			return bts;
+	}
+	return NULL;
+}
+
+/* This function is called once the OML/RSL link becomes up. */
+static struct e1inp_sign_link *
+hsl_sign_link_up(void *unit_data, struct e1inp_line *line,
+		 enum e1inp_sign_type type)
+{
+	struct hsl_unit *dev = unit_data;
+	struct gsm_bts *bts;
+
+	bts = find_bts_by_serno(hsl_gsmnet, dev->serno);
+	if (!bts) {
+		LOGP(DLINP, LOGL_ERROR, "Unable to find BTS config for "
+				"serial number %lx\n", dev->serno);
+		return NULL;
+	}
+	DEBUGP(DLINP, "Identified HSL BTS Serial Number %lx\n", dev->serno);
+
+	/* we shouldn't hardcode it, but HSL femto also hardcodes it... */
+	bts->oml_tei = 255;
+	bts->c0->rsl_tei = 0;
+	bts->oml_link = e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML-1],
+					       E1INP_SIGN_OML, bts->c0,
+					       bts->oml_tei, 0);
+	bts->c0->rsl_link = e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML-1],
+						   E1INP_SIGN_RSL, bts->c0,
+						   bts->c0->rsl_tei, 0);
+	e1inp_event(&line->ts[E1INP_SIGN_OML-1], S_L_INP_TEI_UP, 255, 0);
+	e1inp_event(&line->ts[E1INP_SIGN_OML-1], S_L_INP_TEI_UP, 0, 0);
+	bts->ip_access.flags |= OML_UP;
+	bts->ip_access.flags |= (RSL_UP << 0);
+
+	return bts->oml_link;
+}
+
+void hsl_drop_oml(struct gsm_bts *bts)
+{
+	struct e1inp_line *line;
+
+	if (!bts->oml_link)
+		return;
+
+	line = bts->oml_link->ts->line;
+	e1inp_sign_link_destroy(bts->oml_link);
+	bts->oml_link = NULL;
+
+	e1inp_sign_link_destroy(bts->c0->rsl_link);
+	bts->c0->rsl_link = NULL;
+
+	bts->ip_access.flags = 0;
+}
+
+static void hsl_sign_link_down(struct e1inp_line *line)
+{
+	/* No matter what link went down, we close both signal links. */
+	struct e1inp_ts *ts = &line->ts[E1INP_SIGN_OML-1];
+	struct e1inp_sign_link *link;
+
+	llist_for_each_entry(link, &ts->sign.sign_links, list) {
+		struct gsm_bts *bts = link->trx->bts;
+
+		hsl_drop_oml(bts);
+		/* Yes, we only use the first element of the list. */
+		break;
+       }
+}
+
+/* This function is called if we receive one OML/RSL message. */
+static int hsl_sign_link(struct msgb *msg)
+{
+	int ret = 0;
+	struct e1inp_sign_link *link = msg->dst;
+	struct e1inp_ts *e1i_ts = link->ts;
+
+	switch (link->type) {
+	case E1INP_SIGN_OML:
+		if (!(link->trx->bts->ip_access.flags & OML_UP)) {
+			e1inp_event(e1i_ts, S_L_INP_TEI_UP,
+					link->tei, link->sapi);
+			link->trx->bts->ip_access.flags |= OML_UP;
+		}
+		ret = abis_nm_rcvmsg(msg);
+		break;
+	case E1INP_SIGN_RSL:
+		if (!(link->trx->bts->ip_access.flags &
+			(RSL_UP << link->trx->nr))) {
+			e1inp_event(e1i_ts, S_L_INP_TEI_UP,
+					link->tei, link->sapi);
+			link->trx->bts->ip_access.flags |=
+					(RSL_UP << link->trx->nr);
+		}
+		ret = abis_rsl_rcvmsg(msg);
+		break;
+	default:
+		LOGP(DLINP, LOGL_ERROR, "Unknown signal link type %d\n",
+			link->type);
+		msgb_free(msg);
+	break;
+	}
+	return ret;
+}
+
+static struct e1inp_line_ops hsl_e1inp_line_ops = {
+	.cfg = {
+		.ipa = {
+			.addr	= "0.0.0.0",
+			.role	= E1INP_LINE_R_BSC,
+		},
+	},
+       .sign_link_up	= hsl_sign_link_up,
+       .sign_link_down	= hsl_sign_link_down,
+       .sign_link	= hsl_sign_link,
+};
+
+static void bts_model_hslfemto_e1line_bind_ops(struct e1inp_line *line)
+{
+	e1inp_line_bind_ops(line, &hsl_e1inp_line_ops);
+}
diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
index c86b1e1..42ac6b4 100644
--- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c
+++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
@@ -26,15 +26,27 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/signal.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/e1_input.h> /* for ipaccess_setup() */
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/talloc.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/abis_nm.h>
+#include <openbsc/abis_rsl.h>
+#include <openbsc/debug.h>
+#include <osmocom/abis/subchan_demux.h>
+#include <osmocom/abis/ipaccess.h>
+#include <osmocom/core/logging.h>
 
 static int bts_model_nanobts_start(struct gsm_network *net);
+static void bts_model_nanobts_e1line_bind_ops(struct e1inp_line *line);
 
 static struct gsm_bts_model model_nanobts = {
 	.type = GSM_BTS_TYPE_NANOBTS,
 	.name = "nanobts",
 	.start = bts_model_nanobts_start,
 	.oml_rcvmsg = &abis_nm_rcvmsg,
+	.e1line_bind_ops = bts_model_nanobts_e1line_bind_ops, 
 	.nm_att_tlvdef = {
 		.def = {
 			/* ip.access specifics */
@@ -440,6 +452,8 @@
 	return 0;
 }
 
+static struct gsm_network *ipaccess_gsmnet;
+
 static int bts_model_nanobts_start(struct gsm_network *net)
 {
 	model_nanobts.features.data = &model_nanobts._features_data[0];
@@ -450,11 +464,185 @@
 
 	osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
 
-	/* Call A-bis input driver, start server sockets for OML and RSL. */
-	return ipaccess_setup(net);
+	ipaccess_gsmnet = net;
+	return 0;
 }
 
 int bts_model_nanobts_init(void)
 {
 	return gsm_bts_model_register(&model_nanobts);
 }
+
+#define OML_UP         0x0001
+#define RSL_UP         0x0002
+
+static struct gsm_bts *
+find_bts_by_unitid(struct gsm_network *net, uint16_t site_id, uint16_t bts_id)
+{
+	struct gsm_bts *bts;
+
+	llist_for_each_entry(bts, &net->bts_list, list) {
+		if (!is_ipaccess_bts(bts))
+			continue;
+
+		if (bts->ip_access.site_id == site_id &&
+		    bts->ip_access.bts_id == bts_id)
+			return bts;
+	}
+	return NULL;
+}
+
+/* These are exported because they are used by the VTY interface. */
+void ipaccess_drop_rsl(struct gsm_bts_trx *trx)
+{
+	if (!trx->rsl_link)
+		return;
+
+	e1inp_sign_link_destroy(trx->rsl_link);
+	trx->rsl_link = NULL;
+}
+
+void ipaccess_drop_oml(struct gsm_bts *bts)
+{
+	struct gsm_bts_trx *trx;
+	struct e1inp_line *line;
+
+	if (!bts->oml_link)
+		return;
+
+	line = bts->oml_link->ts->line;
+
+	e1inp_sign_link_destroy(bts->oml_link);
+	bts->oml_link = NULL;
+
+	/* we have issues reconnecting RSL, drop everything. */
+	llist_for_each_entry(trx, &bts->trx_list, list)
+		ipaccess_drop_rsl(trx);
+
+	bts->ip_access.flags = 0;
+}
+
+/* This function is called once the OML/RSL link becomes up. */
+static struct e1inp_sign_link *
+ipaccess_sign_link_up(void *unit_data, struct e1inp_line *line,
+		      enum e1inp_sign_type type)
+{
+	struct gsm_bts *bts;
+	struct ipaccess_unit *dev = unit_data;
+	struct e1inp_sign_link *sign_link = NULL;
+
+	bts = find_bts_by_unitid(ipaccess_gsmnet, dev->site_id, dev->bts_id);
+	if (!bts) {
+		LOGP(DLINP, LOGL_ERROR, "Unable to find BTS configuration for "
+			" %u/%u/%u, disconnecting\n", dev->site_id,
+			dev->bts_id, dev->trx_id);
+		return NULL;
+	}
+	DEBUGP(DLINP, "Identified BTS %u/%u/%u\n",
+			dev->site_id, dev->bts_id, dev->trx_id);
+
+	switch(type) {
+	case E1INP_SIGN_OML:
+		/* remove old OML signal link for this BTS. */
+		ipaccess_drop_oml(bts);
+
+		/* create new OML link. */
+		sign_link = bts->oml_link =
+			e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML - 1],
+						E1INP_SIGN_OML, bts->c0,
+						bts->oml_tei, 0);
+		break;
+	case E1INP_SIGN_RSL: {
+		struct e1inp_ts *ts;
+		struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, dev->trx_id);
+
+		/* no OML link set yet? give up. */
+		if (!bts->oml_link)
+			return NULL;
+
+		/* remove old RSL link for this TRX. */
+		ipaccess_drop_rsl(trx);
+
+		/* set new RSL link for this TRX. */
+		line = bts->oml_link->ts->line;
+		ts = &line->ts[E1INP_SIGN_RSL + dev->trx_id - 1];
+		e1inp_ts_config_sign(ts, line);
+		sign_link = trx->rsl_link =
+				e1inp_sign_link_create(ts, E1INP_SIGN_RSL,
+						       trx, trx->rsl_tei, 0);
+		trx->rsl_link->ts->sign.delay = 0;
+		break;
+	}
+	default:
+		break;
+	}
+	return sign_link;
+}
+
+static void ipaccess_sign_link_down(struct e1inp_line *line)
+{
+	/* No matter what link went down, we close both signal links. */
+	struct e1inp_ts *ts = &line->ts[E1INP_SIGN_OML-1];
+	struct e1inp_sign_link *link;
+
+	llist_for_each_entry(link, &ts->sign.sign_links, list) {
+		struct gsm_bts *bts = link->trx->bts;
+
+		ipaccess_drop_oml(bts);
+		/* Yes, we only use the first element of the list. */
+		break;
+	}
+}
+
+/* This function is called if we receive one OML/RSL message. */
+static int ipaccess_sign_link(struct msgb *msg)
+{
+	int ret = 0;
+	struct e1inp_sign_link *link = msg->dst;
+	struct e1inp_ts *e1i_ts = link->ts;
+
+	switch (link->type) {
+	case E1INP_SIGN_RSL:
+		if (!(link->trx->bts->ip_access.flags &
+					(RSL_UP << link->trx->nr))) {
+			e1inp_event(e1i_ts, S_L_INP_TEI_UP,
+					link->tei, link->sapi);
+			link->trx->bts->ip_access.flags |=
+					(RSL_UP << link->trx->nr);
+		}
+	        ret = abis_rsl_rcvmsg(msg);
+	        break;
+	case E1INP_SIGN_OML:
+		if (!(link->trx->bts->ip_access.flags & OML_UP)) {
+			e1inp_event(e1i_ts, S_L_INP_TEI_UP,
+					link->tei, link->sapi);
+			link->trx->bts->ip_access.flags |= OML_UP;
+		}
+	        ret = abis_nm_rcvmsg(msg);
+	        break;
+	default:
+		LOGP(DLINP, LOGL_ERROR, "Unknown signal link type %d\n",
+			link->type);
+		msgb_free(msg);
+		break;
+	}
+	return ret;
+}
+
+/* not static, ipaccess-config needs it. */
+struct e1inp_line_ops ipaccess_e1inp_line_ops = {
+	.cfg = {
+		.ipa = {
+			.addr = "0.0.0.0",
+			.role = E1INP_LINE_R_BSC,
+		},
+	},
+	.sign_link_up	= ipaccess_sign_link_up,
+	.sign_link_down	= ipaccess_sign_link_down,
+	.sign_link	= ipaccess_sign_link,
+};
+
+static void bts_model_nanobts_e1line_bind_ops(struct e1inp_line *line)
+{
+        e1inp_line_bind_ops(line, &ipaccess_e1inp_line_ops);
+}
diff --git a/openbsc/src/libbsc/bts_nokia_site.c b/openbsc/src/libbsc/bts_nokia_site.c
index 8ba01d0..fa8f43e 100644
--- a/openbsc/src/libbsc/bts_nokia_site.c
+++ b/openbsc/src/libbsc/bts_nokia_site.c
@@ -33,12 +33,12 @@
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/signal.h>
 
 #include <osmocom/core/timer.h>
 
-#include "../libabis/input/lapd.h"
+#include <osmocom/abis/lapd.h>
 
 /* TODO: put in a separate file ? */
 
@@ -48,7 +48,7 @@
 /* was static in system_information.c */
 extern int generate_cell_chan_list(uint8_t * chan_list, struct gsm_bts *bts);
 
-static void abis_nm_queue_send_next(struct gsm_bts *bts);
+static void nokia_abis_nm_queue_send_next(struct gsm_bts *bts);
 static void reset_timer_cb(void *_bts);
 static int abis_nm_reset(struct gsm_bts *bts, uint16_t ref);
 static int dump_elements(uint8_t * data, int len);
@@ -120,7 +120,7 @@
 {
 	struct gsm_bts *bts;
 
-	if (subsys != SS_GLOBAL)
+	if (subsys != SS_L_GLOBAL)
 		return 0;
 
 	switch (signal) {
@@ -140,16 +140,16 @@
 {
 	struct input_signal_data *isd = signal_data;
 
-	if (subsys != SS_INPUT)
+	if (subsys != SS_L_INPUT)
 		return 0;
 
 	switch (signal) {
-	case S_INP_LINE_INIT:
+	case S_L_INP_LINE_INIT:
 		start_sabm_in_line(isd->line, 1, SAPI_OML);	/* start only OML */
 		break;
-	case S_INP_TEI_DN:
+	case S_L_INP_TEI_DN:
 		break;
-	case S_INP_TEI_UP:
+	case S_L_INP_TEI_UP:
 		switch (isd->link_type) {
 		case E1INP_SIGN_OML:
 			if (isd->trx->bts->type != GSM_BTS_TYPE_NOKIA_SITE)
@@ -162,7 +162,7 @@
 			break;
 		}
 		break;
-	case S_INP_TEI_UNKNOWN:
+	case S_L_INP_TEI_UNKNOWN:
 		/* We are receiving LAPD frames with one TEI that we do not
 		 * seem to know, likely that we (the BSC) stopped working
 		 * and lost our local states. However, the BTS is already
@@ -1235,7 +1235,7 @@
 		if (ret < 0)
 			return ret;
 
-		abis_nm_queue_send_next(bts);
+		nokia_abis_nm_queue_send_next(bts);
 
 		/* next segment */
 		len_remain -= len_to_send;
@@ -1415,7 +1415,7 @@
 
 /* taken from abis_nm.c */
 
-static void abis_nm_queue_send_next(struct gsm_bts *bts)
+static void nokia_abis_nm_queue_send_next(struct gsm_bts *bts)
 {
 	int wait = 0;
 	struct msgb *msg;
@@ -1423,7 +1423,7 @@
 	while (!llist_empty(&bts->abis_queue)) {
 		msg = msgb_dequeue(&bts->abis_queue);
 		wait = OBSC_NM_W_ACK_CB(msg);
-		_abis_nm_sendmsg(msg, 0);
+		abis_sendmsg(msg);
 
 		if (wait)
 			break;
@@ -1445,9 +1445,9 @@
 	bts->nokia.wait_reset = 0;
 
 	/* OML link */
-	line = e1inp_line_get(e1_link->e1_nr);
+	line = e1inp_line_find(e1_link->e1_nr);
 	if (!line) {
-		LOGP(DINP, LOGL_ERROR, "BTS %u OML link referring to "
+		LOGP(DLINP, LOGL_ERROR, "BTS %u OML link referring to "
 		     "non-existing E1 line %u\n", bts->nr, e1_link->e1_nr);
 		return;
 	}
@@ -1522,7 +1522,7 @@
 	case NOKIA_MSG_CONF_REQ:
 		/* send ACK */
 		abis_nm_ack(bts, ref);
-		abis_nm_queue_send_next(bts);
+		nokia_abis_nm_queue_send_next(bts);
 		/* send CONF_DATA */
 		abis_nm_send_config(bts, bts->nokia.bts_type);
 		bts->nokia.configured = 1;
@@ -1564,9 +1564,9 @@
 			struct gsm_e1_subslot *e1_link = &bts->oml_e1_link;
 			struct e1inp_line *line;
 			/* OML link */
-			line = e1inp_line_get(e1_link->e1_nr);
+			line = e1inp_line_find(e1_link->e1_nr);
 			if (!line) {
-				LOGP(DINP, LOGL_ERROR,
+				LOGP(DLINP, LOGL_ERROR,
 				     "BTS %u OML link referring to "
 				     "non-existing E1 line %u\n", bts->nr,
 				     e1_link->e1_nr);
@@ -1587,9 +1587,9 @@
 			bts->nokia.configured = 0;
 
 			/* RSL Link */
-			line = e1inp_line_get(e1_link->e1_nr);
+			line = e1inp_line_find(e1_link->e1_nr);
 			if (!line) {
-				LOGP(DINP, LOGL_ERROR,
+				LOGP(DLINP, LOGL_ERROR,
 				     "TRX (%u/%u) RSL link referring "
 				     "to non-existing E1 line %u\n",
 				     sign_link->trx->bts->nr, sign_link->trx->nr,
@@ -1643,7 +1643,7 @@
 		break;
 	}
 
-	abis_nm_queue_send_next(bts);
+	nokia_abis_nm_queue_send_next(bts);
 
 	return ret;
 }
@@ -1696,11 +1696,17 @@
 
 static int bts_model_nokia_site_start(struct gsm_network *net);
 
+static void bts_model_nokia_site_e1line_bind_ops(struct e1inp_line *line)
+{
+	e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
+}
+
 static struct gsm_bts_model model_nokia_site = {
 	.type = GSM_BTS_TYPE_NOKIA_SITE,
 	.name = "nokia_site",
 	.start = bts_model_nokia_site_start,
-	.oml_rcvmsg = &abis_nokia_rcvmsg
+	.oml_rcvmsg = &abis_nokia_rcvmsg,
+	.e1line_bind_ops = &bts_model_nokia_site_e1line_bind_ops,
 };
 
 static struct gsm_network *my_net;
@@ -1714,8 +1720,8 @@
 	gsm_btsmodel_set_feature(&model_nokia_site, BTS_FEAT_HOPPING);
 	gsm_btsmodel_set_feature(&model_nokia_site, BTS_FEAT_HSCSD);
 
-	osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
-	osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
 	osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
 
 	my_net = net;
diff --git a/openbsc/src/libbsc/bts_siemens_bs11.c b/openbsc/src/libbsc/bts_siemens_bs11.c
index df4a1dc..2514d99 100644
--- a/openbsc/src/libbsc/bts_siemens_bs11.c
+++ b/openbsc/src/libbsc/bts_siemens_bs11.c
@@ -25,16 +25,22 @@
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/signal.h>
 
 static int bts_model_bs11_start(struct gsm_network *net);
 
+static void bts_model_bs11_e1line_bind_ops(struct e1inp_line *line)
+{
+	e1inp_line_bind_ops(line, &bts_isdn_e1inp_line_ops);
+}
+
 static struct gsm_bts_model model_bs11 = {
 	.type = GSM_BTS_TYPE_BS11,
 	.name = "bs11",
 	.start = bts_model_bs11_start,
 	.oml_rcvmsg = &abis_nm_rcvmsg,
+	.e1line_bind_ops = bts_model_bs11_e1line_bind_ops,
 	.nm_att_tlvdef = {
 		.def = {
 			[NM_ATT_AVAIL_STATUS] =		{ TLV_TYPE_TLV },
@@ -542,7 +548,7 @@
 {
 	struct gsm_bts *bts;
 
-	if (subsys != SS_GLOBAL)
+	if (subsys != SS_L_GLOBAL)
 		return 0;
 
 	switch (signal) {
@@ -562,11 +568,11 @@
 {
 	struct input_signal_data *isd = signal_data;
 
-	if (subsys != SS_INPUT)
+	if (subsys != SS_L_INPUT)
 		return 0;
 
 	switch (signal) {
-	case S_INP_TEI_UP:
+	case S_L_INP_TEI_UP:
 		switch (isd->link_type) {
 		case E1INP_SIGN_OML:
 			if (isd->trx->bts->type == GSM_BTS_TYPE_BS11)
@@ -586,8 +592,8 @@
 	gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HOPPING);
 	gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HSCSD);
 
-	osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
-	osmo_signal_register_handler(SS_GLOBAL, gbl_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
+	osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
 
 	return 0;
 }
diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c
index bd6ebba..cda1318 100644
--- a/openbsc/src/libbsc/e1_config.c
+++ b/openbsc/src/libbsc/e1_config.c
@@ -24,13 +24,14 @@
 #include <netinet/in.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/e1_input.h>
-#include <openbsc/trau_frame.h>
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/abis/trau_frame.h>
 #include <openbsc/trau_mux.h>
 #include <openbsc/misdn.h>
-#include <openbsc/ipaccess.h>
+#include <osmocom/abis/ipaccess.h>
 #include <osmocom/core/talloc.h>
 #include <openbsc/debug.h>
+#include <openbsc/abis_rsl.h>
 
 #define SAPI_L2ML	0
 #define SAPI_OML	62
@@ -46,17 +47,17 @@
 	struct e1inp_line *line;
 	struct e1inp_ts *e1_ts;
 
-	DEBUGP(DMI, "e1_reconfig_ts(%u,%u,%u)\n", ts->trx->bts->nr, ts->trx->nr, ts->nr);
+	DEBUGP(DLMI, "e1_reconfig_ts(%u,%u,%u)\n", ts->trx->bts->nr, ts->trx->nr, ts->nr);
 
 	if (!e1_link->e1_ts) {
-		LOGP(DINP, LOGL_ERROR, "TS (%u/%u/%u) without E1 timeslot?\n",
+		LOGP(DLINP, LOGL_ERROR, "TS (%u/%u/%u) without E1 timeslot?\n",
 		     ts->nr, ts->trx->nr, ts->trx->bts->nr);
 		return 0;
 	}
 
-	line = e1inp_line_get(e1_link->e1_nr);
+	line = e1inp_line_find(e1_link->e1_nr);
 	if (!line) {
-		LOGP(DINP, LOGL_ERROR, "TS (%u/%u/%u) referring to "
+		LOGP(DLINP, LOGL_ERROR, "TS (%u/%u/%u) referring to "
 		     "non-existing E1 line %u\n", ts->nr, ts->trx->nr,
 		     ts->trx->bts->nr, e1_link->e1_nr);
 		return -ENOMEM;
@@ -66,7 +67,7 @@
 	case GSM_PCHAN_TCH_F:
 	case GSM_PCHAN_TCH_H:
 		e1_ts = &line->ts[e1_link->e1_ts-1];
-		e1inp_ts_config(e1_ts, line, E1INP_TS_TYPE_TRAU);
+		e1inp_ts_config_trau(e1_ts, line, subch_cb);
 		subch_demux_activate(&e1_ts->trau.demux, e1_link->e1_ts_ss);
 		break;
 	default:
@@ -85,28 +86,28 @@
 	int i;
 
 	if (!e1_link->e1_ts) {
-		LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link without "
+		LOGP(DLINP, LOGL_ERROR, "TRX (%u/%u) RSL link without "
 		     "timeslot?\n", trx->bts->nr, trx->nr);
 		return -EINVAL;
 	}
 
 	/* RSL Link */
-	line = e1inp_line_get(e1_link->e1_nr);
+	line = e1inp_line_find(e1_link->e1_nr);
 	if (!line) {
-		LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link referring "
+		LOGP(DLINP, LOGL_ERROR, "TRX (%u/%u) RSL link referring "
 		     "to non-existing E1 line %u\n", trx->bts->nr,
 		     trx->nr, e1_link->e1_nr);
 		return -ENOMEM;
 	}
 	sign_ts = &line->ts[e1_link->e1_ts-1];
-	e1inp_ts_config(sign_ts, line, E1INP_TS_TYPE_SIGN);
+	e1inp_ts_config_sign(sign_ts, line);
 	/* Ericsson RBS have a per-TRX OML link in parallel to RSL */
 	if (trx->bts->type == GSM_BTS_TYPE_RBS2000) {
 		struct e1inp_sign_link *oml_link;
 		oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML, trx,
 						  trx->rsl_tei, SAPI_OML);
 		if (!oml_link) {
-			LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) OML link creation "
+			LOGP(DLINP, LOGL_ERROR, "TRX (%u/%u) OML link creation "
 				"failed\n", trx->bts->nr, trx->nr);
 			return -ENOMEM;
 		}
@@ -117,7 +118,7 @@
 	rsl_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_RSL,
 					  trx, trx->rsl_tei, SAPI_RSL);
 	if (!rsl_link) {
-		LOGP(DINP, LOGL_ERROR, "TRX (%u/%u) RSL link creation "
+		LOGP(DLINP, LOGL_ERROR, "TRX (%u/%u) RSL link creation "
 		     "failed\n", trx->bts->nr, trx->nr);
 		return -ENOMEM;
 	}
@@ -131,6 +132,33 @@
 	return 0;
 }
 
+/* this is the generic callback for all ISDN-based BTS. */
+static int bts_isdn_sign_link(struct msgb *msg)
+{
+	int ret = -EINVAL;
+	struct e1inp_sign_link *link = msg->dst;
+	struct gsm_bts *bts;
+
+	log_set_context(BSC_CTX_BTS, link->trx->bts);
+	switch (link->type) {
+	case E1INP_SIGN_OML:
+		bts = link->trx->bts;
+		ret = bts->model->oml_rcvmsg(msg);
+		break;
+	case E1INP_SIGN_RSL:
+		ret = abis_rsl_rcvmsg(msg);
+		break;
+	default:
+		LOGP(DLMI, LOGL_ERROR, "unknown link type %u\n", link->type);
+		break;
+	}
+	return ret;
+}
+
+struct e1inp_line_ops bts_isdn_e1inp_line_ops = {
+	.sign_link	= bts_isdn_sign_link,
+};
+
 int e1_reconfig_bts(struct gsm_bts *bts)
 {
 	struct gsm_e1_subslot *e1_link = &bts->oml_e1_link;
@@ -139,27 +167,40 @@
 	struct e1inp_sign_link *oml_link;
 	struct gsm_bts_trx *trx;
 
-	DEBUGP(DMI, "e1_reconfig_bts(%u)\n", bts->nr);
+	DEBUGP(DLMI, "e1_reconfig_bts(%u)\n", bts->nr);
 
+	line = e1inp_line_find(e1_link->e1_nr);
+	if (!line) {
+		LOGP(DLINP, LOGL_ERROR, "BTS %u OML link referring to "
+		     "non-existing E1 line %u\n", bts->nr, e1_link->e1_nr);
+		return -ENOMEM;
+	}
+
+	if (!bts->model->e1line_bind_ops) {
+		LOGP(DLINP, LOGL_ERROR, "no callback to bind E1 line operations\n");
+		return -EINVAL;
+	}
+	if (!line->ops)
+		bts->model->e1line_bind_ops(line);
+
+	/* skip signal link initialization, this is done later for these BTS. */
+	if (bts->type == GSM_BTS_TYPE_NANOBTS ||
+	    bts->type == GSM_BTS_TYPE_HSL_FEMTO)
+		return e1inp_line_update(line);
+
+	/* OML link */
 	if (!e1_link->e1_ts) {
-		LOGP(DINP, LOGL_ERROR, "BTS %u OML link without timeslot?\n",
+		LOGP(DLINP, LOGL_ERROR, "BTS %u OML link without timeslot?\n",
 		     bts->nr);
 		return -EINVAL;
 	}
 
-	/* OML link */
-	line = e1inp_line_get(e1_link->e1_nr);
-	if (!line) {
-		LOGP(DINP, LOGL_ERROR, "BTS %u OML link referring to "
-		     "non-existing E1 line %u\n", bts->nr, e1_link->e1_nr);
-		return -ENOMEM;
-	}
 	sign_ts = &line->ts[e1_link->e1_ts-1];
-	e1inp_ts_config(sign_ts, line, E1INP_TS_TYPE_SIGN);
+	e1inp_ts_config_sign(sign_ts, line);
 	oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
 					  bts->c0, bts->oml_tei, SAPI_OML);
 	if (!oml_link) {
-		LOGP(DINP, LOGL_ERROR, "BTS %u OML link creation failed\n",
+		LOGP(DLINP, LOGL_ERROR, "BTS %u OML link creation failed\n",
 		     bts->nr);
 		return -ENOMEM;
 	}
@@ -260,37 +301,3 @@
 	return mi_setup(cardnr, line, release_l2);
 }
 #endif
-
-/* configure pseudo E1 line in ip.access style and connect to BTS */
-int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin)
-{
-	struct e1inp_line *line;
-	struct e1inp_ts *sign_ts, *rsl_ts;
-	struct e1inp_sign_link *oml_link, *rsl_link;
-
-	line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
-	if (!line)
-		return -ENOMEM;
-
-	/* create E1 timeslots for signalling and TRAU frames */
-	e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
-	e1inp_ts_config(&line->ts[2-1], line, E1INP_TS_TYPE_SIGN);
-
-	/* create signalling links for TS1 */
-	sign_ts = &line->ts[1-1];
-	rsl_ts = &line->ts[2-1];
-	oml_link = e1inp_sign_link_create(sign_ts, E1INP_SIGN_OML,
-					  bts->c0, 0xff, 0);
-	rsl_link = e1inp_sign_link_create(rsl_ts, E1INP_SIGN_RSL,
-					  bts->c0, 0, 0);
-
-	/* create back-links from bts/trx */
-	bts->oml_link = oml_link;
-	bts->c0->rsl_link = rsl_link;
-
-	/* default port at BTS for incoming connections is 3006 */
-	if (sin->sin_port == 0)
-		sin->sin_port = htons(3006);
-
-	return ipaccess_connect(line, sin);
-}
diff --git a/openbsc/src/libcommon/debug.c b/openbsc/src/libcommon/debug.c
index 479390c..e15342b 100644
--- a/openbsc/src/libcommon/debug.c
+++ b/openbsc/src/libcommon/debug.c
@@ -95,26 +95,6 @@
 		.description = "Radio Measurement Processing",
 		.enabled = 0, .loglevel = LOGL_NOTICE,
 	},
-	[DMI] = {
-		.name = "DMI",
-		.description = "A-bis Input Driver for Signalling",
-		.enabled = 0, .loglevel = LOGL_NOTICE,
-	},
-	[DMIB] = {
-		.name = "DMIB",
-		.description = "A-bis Input Driver for B-Channels (voice)",
-		.enabled = 0, .loglevel = LOGL_NOTICE,
-	},
-	[DMUX] = {
-		.name = "DMUX",
-		.description = "A-bis B-Subchannel TRAU Frame Multiplex",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DINP] = {
-		.name = "DINP",
-		.description = "A-bis Intput Subsystem",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
 	[DSCCP] = {
 		.name = "DSCCP",
 		.description = "SCCP Protocol",
diff --git a/openbsc/src/libcommon/socket.c b/openbsc/src/libcommon/socket.c
index ff846aa..6c47a8d 100644
--- a/openbsc/src/libcommon/socket.c
+++ b/openbsc/src/libcommon/socket.c
@@ -68,7 +68,7 @@
 	bfd->priv_nr = priv_nr;
 
 	if (bfd->fd < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not create socket.\n");
+		LOGP(DLINP, LOGL_ERROR, "could not create socket.\n");
 		return -EIO;
 	}
 
@@ -84,7 +84,7 @@
 
 	ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "could not bind socket %s\n",
+		LOGP(DLINP, LOGL_ERROR, "could not bind socket %s\n",
 			strerror(errno));
 		close(bfd->fd);
 		return -EIO;
diff --git a/openbsc/src/libctrl/Makefile.am b/openbsc/src/libctrl/Makefile.am
index 286929b..6a0be69 100644
--- a/openbsc/src/libctrl/Makefile.am
+++ b/openbsc/src/libctrl/Makefile.am
@@ -1,6 +1,6 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 noinst_LIBRARIES = libctrl.a
 
diff --git a/openbsc/src/libctrl/control_cmd.c b/openbsc/src/libctrl/control_cmd.c
index b5cff68..1320030 100644
--- a/openbsc/src/libctrl/control_cmd.c
+++ b/openbsc/src/libctrl/control_cmd.c
@@ -141,7 +141,7 @@
 				goto out;
 			}
 		} else if (cmd_el->param) {
-			LOGP(DINP, LOGL_NOTICE, "Parameter verification unimplemented, continuing without\n");
+			LOGP(DLINP, LOGL_NOTICE, "Parameter verification unimplemented, continuing without\n");
 		}
 		ret =  cmd_el->set(command, data);
 		goto out;
@@ -190,7 +190,7 @@
 	for (cur = name, word = NULL; cur[0] != '\0'; ++cur) {
 		/* warn about optionals */
 		if (cur[0] == '(' || cur[0] == ')' || cur[0] == '|') {
-			LOGP(DINP, LOGL_ERROR,
+			LOGP(DLINP, LOGL_ERROR,
 			     "Optionals are not supported in '%s'\n", name);
 			goto failure;
 		}
@@ -225,7 +225,7 @@
 	if (!cmds_vec) {
 		cmds_vec = vector_init(5);
 		if (!cmds_vec) {
-			LOGP(DINP, LOGL_ERROR, "vector_init failed.\n");
+			LOGP(DLINP, LOGL_ERROR, "vector_init failed.\n");
 			return -ENOMEM;
 		}
 		vector_set_index(ctrl_node_vec, node, cmds_vec);
@@ -281,7 +281,7 @@
 
 	cmd = talloc_zero(ctx, struct ctrl_cmd);
 	if (!cmd) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate.\n");
 		return NULL;
 	}
 
@@ -323,11 +323,11 @@
 			if (!var) {
 				cmd->type = CTRL_TYPE_ERROR;
 				cmd->reply = "GET incomplete";
-				LOGP(DINP, LOGL_NOTICE, "GET Command incomplete\n");
+				LOGP(DLINP, LOGL_NOTICE, "GET Command incomplete\n");
 				goto err;
 			}
 			cmd->variable = talloc_strdup(cmd, var);
-			LOGP(DINP, LOGL_DEBUG, "Command: GET %s\n", cmd->variable);
+			LOGP(DLINP, LOGL_DEBUG, "Command: GET %s\n", cmd->variable);
 			break;
 		case CTRL_TYPE_SET:
 			var = strtok_r(NULL, " ", &saveptr);
@@ -335,14 +335,14 @@
 			if (!var || !val) {
 				cmd->type = CTRL_TYPE_ERROR;
 				cmd->reply = "SET incomplete";
-				LOGP(DINP, LOGL_NOTICE, "SET Command incomplete\n");
+				LOGP(DLINP, LOGL_NOTICE, "SET Command incomplete\n");
 				goto err;
 			}
 			cmd->variable = talloc_strdup(cmd, var);
 			cmd->value = talloc_strdup(cmd, val);
 			if (!cmd->variable || !cmd->value)
 				goto oom;
-			LOGP(DINP, LOGL_DEBUG, "Command: SET %s = %s\n", cmd->variable, cmd->value);
+			LOGP(DLINP, LOGL_DEBUG, "Command: SET %s = %s\n", cmd->variable, cmd->value);
 			break;
 		case CTRL_TYPE_GET_REPLY:
 		case CTRL_TYPE_SET_REPLY:
@@ -352,14 +352,14 @@
 			if (!var || !val) {
 				cmd->type = CTRL_TYPE_ERROR;
 				cmd->reply = "Trap/Reply incomplete";
-				LOGP(DINP, LOGL_NOTICE, "Trap/Reply incomplete\n");
+				LOGP(DLINP, LOGL_NOTICE, "Trap/Reply incomplete\n");
 				goto err;
 			}
 			cmd->variable = talloc_strdup(cmd, var);
 			cmd->reply = talloc_strdup(cmd, val);
 			if (!cmd->variable || !cmd->reply)
 				goto oom;
-			LOGP(DINP, LOGL_DEBUG, "Command: TRAP/REPLY %s: %s\n", cmd->variable, cmd->reply);
+			LOGP(DLINP, LOGL_DEBUG, "Command: TRAP/REPLY %s: %s\n", cmd->variable, cmd->reply);
 			break;
 		case CTRL_TYPE_ERROR:
 			var = strtok_r(NULL, "\0", &saveptr);
@@ -370,7 +370,7 @@
 			cmd->reply = talloc_strdup(cmd, var);
 			if (!cmd->reply)
 				goto oom;
-			LOGP(DINP, LOGL_DEBUG, "Command: ERROR %s\n", cmd->reply);
+			LOGP(DLINP, LOGL_DEBUG, "Command: ERROR %s\n", cmd->reply);
 			break;
 		case CTRL_TYPE_UNKNOWN:
 		default:
@@ -410,7 +410,7 @@
 
 		tmp = talloc_asprintf(cmd, "%s %s %s", type, cmd->id, cmd->variable);
 		if (!tmp) {
-			LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n");
+			LOGP(DLINP, LOGL_ERROR, "Failed to allocate cmd.\n");
 			goto err;
 		}
 
@@ -425,7 +425,7 @@
 		tmp = talloc_asprintf(cmd, "%s %s %s %s", type, cmd->id, cmd->variable,
 				cmd->value);
 		if (!tmp) {
-			LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n");
+			LOGP(DLINP, LOGL_ERROR, "Failed to allocate cmd.\n");
 			goto err;
 		}
 
@@ -442,7 +442,7 @@
 		tmp = talloc_asprintf(cmd, "%s %s %s %s", type, cmd->id, cmd->variable,
 				cmd->reply);
 		if (!tmp) {
-			LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n");
+			LOGP(DLINP, LOGL_ERROR, "Failed to allocate cmd.\n");
 			goto err;
 		}
 
@@ -457,7 +457,7 @@
 		tmp = talloc_asprintf(cmd, "%s %s %s", type, cmd->id,
 				cmd->reply);
 		if (!tmp) {
-			LOGP(DINP, LOGL_ERROR, "Failed to allocate cmd.\n");
+			LOGP(DLINP, LOGL_ERROR, "Failed to allocate cmd.\n");
 			goto err;
 		}
 
@@ -466,7 +466,7 @@
 		talloc_free(tmp);
 		break;
 	default:
-		LOGP(DINP, LOGL_NOTICE, "Unknown command type %i\n", cmd->type);
+		LOGP(DLINP, LOGL_NOTICE, "Unknown command type %i\n", cmd->type);
 		goto err;
 		break;
 	}
diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index 91c69e0..d1a3c1c 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -40,11 +40,10 @@
 
 #include <openbsc/control_cmd.h>
 #include <openbsc/debug.h>
-#include <openbsc/e1_input.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/ipaccess.h>
 #include <openbsc/socket.h>
-#include <openbsc/subchan_demux.h>
+#include <osmocom/abis/subchan_demux.h>
 
 #include <openbsc/abis_rsl.h>
 #include <openbsc/abis_nm.h>
@@ -60,6 +59,9 @@
 #include <osmocom/vty/command.h>
 #include <osmocom/vty/vector.h>
 
+#include <osmocom/abis/e1_input.h>
+#include <osmocom/abis/ipa.h>
+
 struct ctrl_handle {
 	struct osmo_fd listen_fd;
 	struct gsm_network *gsmnet;
@@ -74,7 +76,7 @@
 
 	msg = ctrl_cmd_make(cmd);
 	if (!msg) {
-		LOGP(DINP, LOGL_ERROR, "Could not generate msg\n");
+		LOGP(DLINP, LOGL_ERROR, "Could not generate msg\n");
 		return -1;
 	}
 
@@ -83,7 +85,7 @@
 
 	ret = osmo_wqueue_enqueue(queue, msg);
 	if (ret != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to enqueue the command.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the command.\n");
 		msgb_free(msg);
 	}
 	return ret;
@@ -201,7 +203,7 @@
 
 static int handle_control_read(struct osmo_fd * bfd)
 {
-	int ret = -1, error;
+	int ret = -1;
 	struct osmo_wqueue *queue;
 	struct ctrl_connection *ccon;
 	struct ipaccess_head *iph;
@@ -213,31 +215,30 @@
 	queue = container_of(bfd, struct osmo_wqueue, bfd);
 	ccon = container_of(queue, struct ctrl_connection, write_queue);
 
-	msg = ipaccess_read_msg(bfd, &error);
-
-	if (!msg) {
-		if (error == 0)
-			LOGP(DINP, LOGL_INFO, "The control connection was closed\n");
+	ret = ipa_msg_recv(bfd->fd, &msg);
+	if (ret <= 0) {
+		if (ret == 0)
+			LOGP(DLINP, LOGL_INFO, "The control connection was closed\n");
 		else
-			LOGP(DINP, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
+			LOGP(DLINP, LOGL_ERROR, "Failed to parse ip access message: %d\n", ret);
 
 		goto err;
 	}
 
 	if (msg->len < sizeof(*iph) + sizeof(*iph_ext)) {
-		LOGP(DINP, LOGL_ERROR, "The message is too short.\n");
+		LOGP(DLINP, LOGL_ERROR, "The message is too short.\n");
 		goto err;
 	}
 
 	iph = (struct ipaccess_head *) msg->data;
 	if (iph->proto != IPAC_PROTO_OSMO) {
-		LOGP(DINP, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto);
+		LOGP(DLINP, LOGL_ERROR, "Protocol mismatch. We got 0x%x\n", iph->proto);
 		goto err;
 	}
 
 	iph_ext = (struct ipaccess_head_ext *) iph->data;
 	if (iph_ext->proto != IPAC_PROTO_EXT_CTRL) {
-		LOGP(DINP, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto);
+		LOGP(DLINP, LOGL_ERROR, "Extended protocol mismatch. We got 0x%x\n", iph_ext->proto);
 		goto err;
 	}
 
@@ -255,7 +256,7 @@
 		cmd = talloc_zero(ccon, struct ctrl_cmd);
 		if (!cmd)
 			goto err;
-		LOGP(DINP, LOGL_ERROR, "Command parser error.\n");
+		LOGP(DLINP, LOGL_ERROR, "Command parser error.\n");
 		cmd->type = CTRL_TYPE_ERROR;
 		cmd->id = "err";
 		cmd->reply = "Command parser error.";
@@ -278,7 +279,7 @@
 
 	rc = write(bfd->fd, msg->data, msg->len);
 	if (rc != msg->len)
-		LOGP(DINP, LOGL_ERROR, "Failed to write message to the control connection.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to write message to the control connection.\n");
 
 	return rc;
 }
@@ -312,7 +313,7 @@
 		perror("accept");
 		return fd;
 	}
-	LOGP(DINP, LOGL_INFO, "accept()ed new control connection from %s\n",
+	LOGP(DLINP, LOGL_INFO, "accept()ed new control connection from %s\n",
 		inet_ntoa(sa.sin_addr));
 
 	on = 1;
@@ -324,7 +325,7 @@
 	}
 	ccon = ctrl_connection_alloc(listen_bfd->data);
 	if (!ccon) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate.\n");
 		close(fd);
 		return -1;
 	}
@@ -337,7 +338,7 @@
 
 	ret = osmo_fd_register(&ccon->write_queue.bfd);
 	if (ret < 0) {
-		LOGP(DINP, LOGL_ERROR, "Could not register FD.\n");
+		LOGP(DLINP, LOGL_ERROR, "Could not register FD.\n");
 		close(ccon->write_queue.bfd.fd);
 		talloc_free(ccon);
 	}
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 59baa5a..dcb6e11 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -41,7 +41,7 @@
 #include <openbsc/chan_alloc.h>
 #include <openbsc/paging.h>
 #include <openbsc/signal.h>
-#include <openbsc/trau_frame.h>
+#include <osmocom/abis/trau_frame.h>
 #include <openbsc/trau_mux.h>
 #include <openbsc/rtp_proxy.h>
 #include <openbsc/transaction.h>
@@ -49,7 +49,7 @@
 #include <openbsc/silent_call.h>
 #include <openbsc/bsc_api.h>
 #include <openbsc/osmo_msc.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <osmocom/core/bitvec.h>
 
 #include <osmocom/gsm/gsm48.h>
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index f31f05b..1d3ffe9 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -33,7 +33,7 @@
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/silent_call.h>
 #include <openbsc/gsm_04_11.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/abis_nm.h>
 #include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/core/utils.h>
diff --git a/openbsc/src/libtrau/Makefile.am b/openbsc/src/libtrau/Makefile.am
index 6b70a9a..802c455 100644
--- a/openbsc/src/libtrau/Makefile.am
+++ b/openbsc/src/libtrau/Makefile.am
@@ -1,7 +1,7 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 noinst_LIBRARIES = libtrau.a
 
-libtrau_a_SOURCES = rtp_proxy.c subchan_demux.c trau_frame.c trau_mux.c trau_upqueue.c
+libtrau_a_SOURCES = rtp_proxy.c trau_mux.c trau_upqueue.c
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index 4c5f12e..2aa3a1e 100644
--- a/openbsc/src/libtrau/rtp_proxy.c
+++ b/openbsc/src/libtrau/rtp_proxy.c
@@ -111,25 +111,25 @@
 	int x_len;
 
 	if (msg->len < 12) {
-		DEBUGPC(DMUX, "received RTP frame too short (len = %d)\n",
+		DEBUGPC(DLMUX, "received RTP frame too short (len = %d)\n",
 			msg->len);
 		return -EINVAL;
 	}
 	if (rtph->version != RTP_VERSION) {
-		DEBUGPC(DMUX, "received RTP version %d not supported.\n",
+		DEBUGPC(DLMUX, "received RTP version %d not supported.\n",
 			rtph->version);
 		return -EINVAL;
 	}
 	payload = msg->data + sizeof(struct rtp_hdr) + (rtph->csrc_count << 2);
 	payload_len = msg->len - sizeof(struct rtp_hdr) - (rtph->csrc_count << 2);
 	if (payload_len < 0) {
-		DEBUGPC(DMUX, "received RTP frame too short (len = %d, "
+		DEBUGPC(DLMUX, "received RTP frame too short (len = %d, "
 			"csrc count = %d)\n", msg->len, rtph->csrc_count);
 		return -EINVAL;
 	}
 	if (rtph->extension) {
 		if (payload_len < sizeof(struct rtp_x_hdr)) {
-			DEBUGPC(DMUX, "received RTP frame too short for "
+			DEBUGPC(DLMUX, "received RTP frame too short for "
 				"extension header\n");
 			return -EINVAL;
 		}
@@ -138,20 +138,20 @@
 		payload += x_len;
 		payload_len -= x_len;
 		if (payload_len < 0) {
-			DEBUGPC(DMUX, "received RTP frame too short, "
+			DEBUGPC(DLMUX, "received RTP frame too short, "
 				"extension header exceeds frame length\n");
 			return -EINVAL;
 		}
 	}
 	if (rtph->padding) {
 		if (payload_len < 0) {
-			DEBUGPC(DMUX, "received RTP frame too short for "
+			DEBUGPC(DLMUX, "received RTP frame too short for "
 				"padding length\n");
 			return -EINVAL;
 		}
 		payload_len -= payload[payload_len - 1];
 		if (payload_len < 0) {
-			DEBUGPC(DMUX, "received RTP frame with padding "
+			DEBUGPC(DLMUX, "received RTP frame with padding "
 				"greater than payload\n");
 			return -EINVAL;
 		}
@@ -161,7 +161,7 @@
 	case RTP_PT_GSM_FULL:
 		msg_type = GSM_TCHF_FRAME;
 		if (payload_len != 33) {
-			DEBUGPC(DMUX, "received RTP full rate frame with "
+			DEBUGPC(DLMUX, "received RTP full rate frame with "
 				"payload length != 32 (len = %d)\n",
 				payload_len);
 			return -EINVAL;
@@ -171,7 +171,7 @@
 		msg_type = GSM_TCHF_FRAME_EFR;
 		break;
 	default:
-		DEBUGPC(DMUX, "received RTP frame with unknown payload "
+		DEBUGPC(DLMUX, "received RTP frame with unknown payload "
 			"type %d\n", rtph->payload_type);
 		return -EINVAL;
 	}
@@ -235,7 +235,7 @@
 		duration = 160;
 		break;
 	default:
-		DEBUGPC(DMUX, "unsupported message type %d\n",
+		DEBUGPC(DLMUX, "unsupported message type %d\n",
 			frame->msg_type);
 		return -EINVAL;
 	}
@@ -254,7 +254,7 @@
 		if (abs(frame_diff) > 1) {
 			long int frame_diff_excess = frame_diff - 1;
 
-			LOGP(DMUX, LOGL_NOTICE,
+			LOGP(DLMUX, LOGL_NOTICE,
 				"Correcting frame difference of %ld frames\n", frame_diff_excess);
 			rs->transmit.sequence += frame_diff_excess;
 			rs->transmit.timestamp += frame_diff_excess * duration;
@@ -355,7 +355,7 @@
 	while ((void *)rtph + sizeof(*rtph) <= (void *)msg->data + msg->len) {
 		old_len = (ntohs(rtph->length) + 1) * 4;
 		if ((void *)rtph + old_len > (void *)msg->data + msg->len) {
-			DEBUGPC(DMUX, "received RTCP packet too short for "
+			DEBUGPC(DLMUX, "received RTCP packet too short for "
 				"length element\n");
 			return -EINVAL;
 		}
@@ -471,7 +471,7 @@
 
 	written = write(rss->bfd.fd, msg->data, msg->len);
 	if (written < msg->len) {
-		LOGP(DMIB, LOGL_ERROR, "short write");
+		LOGP(DLMIB, LOGL_ERROR, "short write");
 		msgb_free(msg);
 		return -EIO;
 	}
@@ -523,7 +523,7 @@
 	int rc;
 	struct rtp_socket *rs;
 
-	DEBUGP(DMUX, "rtp_socket_create(): ");
+	DEBUGP(DLMUX, "rtp_socket_create(): ");
 
 	rs = talloc_zero(tall_bsc_ctx, struct rtp_socket);
 	if (!rs)
@@ -550,7 +550,7 @@
 	if (rc < 0)
 		goto out_rtcp_socket;
 
-	DEBUGPC(DMUX, "success\n");
+	DEBUGPC(DLMUX, "success\n");
 
 	rc = rtp_socket_bind(rs, INADDR_ANY);
 	if (rc < 0)
@@ -568,7 +568,7 @@
 	close(rs->rtp.bfd.fd);
 out_free:
 	talloc_free(rs);
-	DEBUGPC(DMUX, "failed\n");
+	DEBUGPC(DLMUX, "failed\n");
 	return NULL;
 }
 
@@ -604,7 +604,7 @@
 	struct in_addr ia;
 
 	ia.s_addr = htonl(ip);
-	DEBUGP(DMUX, "rtp_socket_bind(rs=%p, IP=%s): ", rs,
+	DEBUGP(DLMUX, "rtp_socket_bind(rs=%p, IP=%s): ", rs,
 		inet_ntoa(ia));
 
 	/* try to bind to a consecutive pair of ports */
@@ -619,12 +619,12 @@
 			break;
 	}
 	if (rc < 0) {
-		DEBUGPC(DMUX, "failed\n");
+		DEBUGPC(DLMUX, "failed\n");
 		return rc;
 	}
 
 	ia.s_addr = rs->rtp.sin_local.sin_addr.s_addr;
-	DEBUGPC(DMUX, "BOUND_IP=%s, BOUND_PORT=%u\n",
+	DEBUGPC(DLMUX, "BOUND_IP=%s, BOUND_PORT=%u\n",
 		inet_ntoa(ia), ntohs(rs->rtp.sin_local.sin_port));
 	return ntohs(rs->rtp.sin_local.sin_port);
 }
@@ -655,7 +655,7 @@
 	struct in_addr ia;
 
 	ia.s_addr = htonl(ip);
-	DEBUGP(DMUX, "rtp_socket_connect(rs=%p, ip=%s, port=%u)\n",
+	DEBUGP(DLMUX, "rtp_socket_connect(rs=%p, ip=%s, port=%u)\n",
 		rs, inet_ntoa(ia), port);
 
 	rc = rtp_sub_socket_connect(&rs->rtp, ip, port);
@@ -668,7 +668,7 @@
 /* bind two RTP/RTCP sockets together */
 int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other)
 {
-	DEBUGP(DMUX, "rtp_socket_proxy(this=%p, other=%p)\n",
+	DEBUGP(DLMUX, "rtp_socket_proxy(this=%p, other=%p)\n",
 		this, other);
 
 	this->rx_action = RTP_PROXY;
@@ -684,7 +684,7 @@
 int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net,
 			uint32_t callref)
 {
-	DEBUGP(DMUX, "rtp_socket_proxy(this=%p, callref=%u)\n",
+	DEBUGP(DLMUX, "rtp_socket_proxy(this=%p, callref=%u)\n",
 		this, callref);
 
 	if (callref) {
@@ -707,7 +707,7 @@
 
 int rtp_socket_free(struct rtp_socket *rs)
 {
-	DEBUGP(DMUX, "rtp_socket_free(rs=%p)\n", rs);
+	DEBUGP(DLMUX, "rtp_socket_free(rs=%p)\n", rs);
 
 	/* make sure we don't leave references dangling to us */
 	if (rs->rx_action == RTP_PROXY &&
diff --git a/openbsc/src/libtrau/subchan_demux.c b/openbsc/src/libtrau/subchan_demux.c
deleted file mode 100644
index 740d2ca..0000000
--- a/openbsc/src/libtrau/subchan_demux.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/* A E1 sub-channel (de)multiplexer with TRAU frame sync */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <openbsc/subchan_demux.h>
-#include <openbsc/trau_frame.h>
-#include <openbsc/debug.h>
-#include <osmocom/core/talloc.h>
-#include <openbsc/gsm_data.h>
-
-void *tall_tqe_ctx;
-
-static inline void append_bit(struct demux_subch *sch, uint8_t bit)
-{
-	sch->out_bitbuf[sch->out_idx++] = bit;
-}
-
-#define SYNC_HDR_BITS	16
-static const uint8_t nullbytes[SYNC_HDR_BITS];
-
-/* check if we have just completed the 16 bit zero sync header,
- * in accordance with GSM TS 08.60 Chapter 4.8.1 */
-static int sync_hdr_complete(struct demux_subch *sch, uint8_t bit)
-{
-	if (bit == 0)
-		sch->consecutive_zeros++;
-	else
-		sch->consecutive_zeros = 0;
-
-	if (sch->consecutive_zeros >= SYNC_HDR_BITS) {
-		sch->consecutive_zeros = 0;
-		return 1;
-	}
-
-	return 0;
-}
-
-/* resynchronize to current location */
-static void resync_to_here(struct demux_subch *sch)
-{
-	memset(sch->out_bitbuf, 0, SYNC_HDR_BITS);
-
-	/* set index in a way that we can continue receiving bits after
-	 * the end of the SYNC header */
-	sch->out_idx = SYNC_HDR_BITS;
-	sch->in_sync = 1;
-}
-
-int subch_demux_init(struct subch_demux *dmx)
-{
-	int i;
-
-	dmx->chan_activ = 0;
-	for (i = 0; i < NR_SUBCH; i++) {
-		struct demux_subch *sch = &dmx->subch[i];
-		sch->out_idx = 0;
-		memset(sch->out_bitbuf, 0xff, sizeof(sch->out_bitbuf));
-	}
-	return 0;
-}
-
-/* input some arbitrary (modulo 4) number of bytes of a 64k E1 channel,
- * split it into the 16k subchannels */
-int subch_demux_in(struct subch_demux *dmx, uint8_t *data, int len)
-{
-	int i, c;
-
-	/* we avoid partially filled bytes in outbuf */
-	if (len % 4)
-		return -EINVAL;
-
-	for (i = 0; i < len; i++) {
-		uint8_t inbyte = data[i];
-
-		for (c = 0; c < NR_SUBCH; c++) {
-			struct demux_subch *sch = &dmx->subch[c];
-			uint8_t inbits;
-			uint8_t bit;
-
-			/* ignore inactive subchannels */
-			if (!(dmx->chan_activ & (1 << c)))
-				continue;
-
-			inbits = inbyte >> (c << 1);
-
-			/* two bits for each subchannel */
-			if (inbits & 0x01)
-				bit = 1;
-			else
-				bit = 0;
-			append_bit(sch, bit);
-
-			if (sync_hdr_complete(sch, bit))
-				resync_to_here(sch);
-
-			if (inbits & 0x02)
-				bit = 1;
-			else
-				bit = 0;
-			append_bit(sch, bit);
-
-			if (sync_hdr_complete(sch, bit))
-				resync_to_here(sch);
-
-			/* FIXME: verify the first bit in octet 2, 4, 6, ...
-			 * according to TS 08.60 4.8.1 */
-
-			/* once we have reached TRAU_FRAME_BITS, call
-			 * the TRAU frame handler callback function */
-			if (sch->out_idx >= TRAU_FRAME_BITS) {
-				if (sch->in_sync) {
-					dmx->out_cb(dmx, c, sch->out_bitbuf,
-					    sch->out_idx, dmx->data);
-					sch->in_sync = 0;
-				}
-				sch->out_idx = 0;
-			}
-		}
-	}
-	return i;
-}
-
-int subch_demux_activate(struct subch_demux *dmx, int subch)
-{
-	if (subch >= NR_SUBCH)
-		return -EINVAL;
-
-	dmx->chan_activ |= (1 << subch);
-	return 0;
-}
-
-int subch_demux_deactivate(struct subch_demux *dmx, int subch)
-{
-	if (subch >= NR_SUBCH)
-		return -EINVAL;
-
-	dmx->chan_activ &= ~(1 << subch);
-	return 0;
-}
-
-/* MULTIPLEXER */
-
-static int alloc_add_idle_frame(struct subch_mux *mx, int sch_nr)
-{
-	/* allocate and initialize with idle pattern */
-	return subchan_mux_enqueue(mx, sch_nr, trau_idle_frame(),
-				   TRAU_FRAME_BITS);
-}
-
-/* return the requested number of bits from the specified subchannel */
-static int get_subch_bits(struct subch_mux *mx, int subch,
-			  uint8_t *bits, int num_requested)
-{
-	struct mux_subch *sch = &mx->subch[subch];
-	int num_bits = 0;
-
-	while (num_bits < num_requested) {
-		struct subch_txq_entry *txe;
-		int num_bits_left;
-		int num_bits_thistime;
-
-		/* make sure we have a valid entry at top of tx queue.
-		 * if not, add an idle frame */
-		if (llist_empty(&sch->tx_queue))
-			alloc_add_idle_frame(mx, subch);
-	
-		if (llist_empty(&sch->tx_queue))
-			return -EIO;
-
-		txe = llist_entry(sch->tx_queue.next, struct subch_txq_entry, list);
-		num_bits_left = txe->bit_len - txe->next_bit;
-
-		if (num_bits_left < num_requested)
-			num_bits_thistime = num_bits_left;
-		else
-			num_bits_thistime = num_requested;
-
-		/* pull the bits from the txe */
-		memcpy(bits + num_bits, txe->bits + txe->next_bit, num_bits_thistime);
-		txe->next_bit += num_bits_thistime;
-
-		/* free the tx_queue entry if it is fully consumed */
-		if (txe->next_bit >= txe->bit_len) {
-			llist_del(&txe->list);
-			talloc_free(txe);
-		}
-
-		/* increment global number of bits dequeued */
-		num_bits += num_bits_thistime;
-	}
-
-	return num_requested;
-}
-
-/* compact an array of 8 single-bit bytes into one byte of 8 bits */
-static uint8_t compact_bits(const uint8_t *bits)
-{
-	uint8_t ret = 0;
-	int i;
-
-	for (i = 0; i < 8; i++)
-		ret |= (bits[i] ? 1 : 0) << i;
-
-	return ret;
-}
-
-/* obtain a single output byte from the subchannel muxer */
-static int mux_output_byte(struct subch_mux *mx, uint8_t *byte)
-{
-	uint8_t bits[8];
-	int rc;
-
-	/* combine two bits of every subchan */
-	rc = get_subch_bits(mx, 0, &bits[0], 2);
-	rc = get_subch_bits(mx, 1, &bits[2], 2);
-	rc = get_subch_bits(mx, 2, &bits[4], 2);
-	rc = get_subch_bits(mx, 3, &bits[6], 2);
-
-	*byte = compact_bits(bits);
-
-	return rc;
-}
-
-/* Request the output of some muxed bytes from the subchan muxer */
-int subchan_mux_out(struct subch_mux *mx, uint8_t *data, int len)
-{
-	int i;
-
-	for (i = 0; i < len; i++) {
-		int rc;
-		rc = mux_output_byte(mx, &data[i]);
-		if (rc < 0)
-			break;
-	}
-	return i;
-}
-
-static int llist_len(struct llist_head *head)
-{
-	struct llist_head *entry;
-	int i = 0;
-
-	llist_for_each(entry, head)
-		i++;
-
-	return i;
-}
-
-/* evict the 'num_evict' number of oldest entries in the queue */
-static void tx_queue_evict(struct mux_subch *sch, int num_evict)
-{
-	struct subch_txq_entry *tqe;
-	int i;
-
-	for (i = 0; i < num_evict; i++) {
-		if (llist_empty(&sch->tx_queue))
-			return;
-
-		tqe = llist_entry(sch->tx_queue.next, struct subch_txq_entry, list);
-		llist_del(&tqe->list);
-		talloc_free(tqe);
-	}
-}
-
-/* enqueue some data into the tx_queue of a given subchannel */
-int subchan_mux_enqueue(struct subch_mux *mx, int s_nr, const uint8_t *data,
-			int len)
-{
-	struct mux_subch *sch = &mx->subch[s_nr];
-	int list_len = llist_len(&sch->tx_queue);
-	struct subch_txq_entry *tqe = talloc_zero_size(tall_tqe_ctx,
-							sizeof(*tqe) + len);
-	if (!tqe)
-		return -ENOMEM;
-
-	tqe->bit_len = len;
-	memcpy(tqe->bits, data, len);
-
-	if (list_len > 2)
-		tx_queue_evict(sch, list_len-2);
-
-	llist_add_tail(&tqe->list, &sch->tx_queue);
-
-	return 0;
-}
-
-/* initialize one subchannel muxer instance */
-int subchan_mux_init(struct subch_mux *mx)
-{
-	int i;
-
-	memset(mx, 0, sizeof(*mx));
-	for (i = 0; i < NR_SUBCH; i++) {
-		struct mux_subch *sch = &mx->subch[i];
-		INIT_LLIST_HEAD(&sch->tx_queue);
-	}
-
-	return 0;
-}
diff --git a/openbsc/src/libtrau/trau_frame.c b/openbsc/src/libtrau/trau_frame.c
deleted file mode 100644
index 8fbaf86..0000000
--- a/openbsc/src/libtrau/trau_frame.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* TRAU frame handling according to GSM TS 08.60 */
-
-/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include <openbsc/trau_frame.h>
-#include <openbsc/subchan_demux.h>
-#include <openbsc/debug.h>
-
-static uint32_t get_bits(const uint8_t *bitbuf, int offset, int num)
-{
-	int i;
-	uint32_t ret = 0;
-
-	for (i = offset; i < offset + num; i++) {
-		ret = ret << 1;
-		if (bitbuf[i])
-			ret |= 1;
-	}
-	return ret;
-}
-
-/* Decode according to 3.1.1 */
-static void decode_fr(struct decoded_trau_frame *fr, const uint8_t *trau_bits)
-{
-	int i;
-	int d_idx = 0;
-
-	/* C1 .. C15 */
-	memcpy(fr->c_bits+0, trau_bits+17, 15);
-	/* C16 .. C21 */
-	memcpy(fr->c_bits+15, trau_bits+310, 6);
-	/* T1 .. T4 */
-	memcpy(fr->t_bits+0, trau_bits+316, 4);
-	/* D1 .. D255 */
-	for (i = 32; i < 304; i+= 16) {
-		memcpy(fr->d_bits + d_idx, trau_bits+i+1, 15);
-		d_idx += 15;
-	}
-	/* D256 .. D260 */
-	memcpy(fr->d_bits + d_idx, trau_bits + 305, 5);
-}
-
-/* Decode according to 3.1.2 */
-static void decode_amr(struct decoded_trau_frame *fr, const uint8_t *trau_bits)
-{
-	int i;
-	int d_idx = 0;
-
-	/* C1 .. C15 */
-	memcpy(fr->c_bits+0, trau_bits+17, 15);
-	/* C16 .. C25 */
-	memcpy(fr->c_bits+15, trau_bits+33, 10);
-	/* T1 .. T4 */
-	memcpy(fr->t_bits+0, trau_bits+316, 4);
-	/* D1 .. D5 */
-	memcpy(fr->d_bits, trau_bits+43, 5);
-	/* D6 .. D245 */
-	for (i = 48; i < 304; i += 16) {
-		memcpy(fr->d_bits + d_idx, trau_bits+i+1, 15);
-		d_idx += 15;
-	}
-	/* D246 .. D256 */
-	memcpy(fr->d_bits + d_idx, trau_bits + 305, 11);
-}
-
-int decode_trau_frame(struct decoded_trau_frame *fr, const uint8_t *trau_bits)
-{
-	uint8_t cbits5 = get_bits(trau_bits, 17, 5);
-
-	switch (cbits5) {
-	case TRAU_FT_FR_UP:
-	case TRAU_FT_FR_DOWN:
-	case TRAU_FT_IDLE_UP:
-	case TRAU_FT_IDLE_DOWN:
-	case TRAU_FT_EFR:
-		decode_fr(fr, trau_bits);
-		break;
-	case TRAU_FT_AMR:
-		decode_amr(fr, trau_bits);
-		break;
-	case TRAU_FT_OM_UP:
-	case TRAU_FT_OM_DOWN:
-	case TRAU_FT_DATA_UP:
-	case TRAU_FT_DATA_DOWN:
-	case TRAU_FT_D145_SYNC:
-	case TRAU_FT_EDATA:
-		LOGP(DMUX, LOGL_NOTICE, "can't decode unimplemented TRAU "
-			"Frame Type 0x%02x\n", cbits5);
-		return -1;
-		break;
-	default:
-		LOGP(DMUX, LOGL_NOTICE, "can't decode unknown TRAU "
-			"Frame Type 0x%02x\n", cbits5);
-		return -1;
-		break;
-	}
-
-	return 0;
-}
-
-const uint8_t ft_fr_down_bits[] = { 1, 1, 1, 0, 0 };
-const uint8_t ft_idle_down_bits[] = { 0, 1, 1, 1, 0 };
-
-/* modify an uplink TRAU frame so we can send it downlink */
-int trau_frame_up2down(struct decoded_trau_frame *fr)
-{
-	uint8_t cbits5 = get_bits(fr->c_bits, 0, 5);
-
-	switch (cbits5) {
-	case TRAU_FT_FR_UP:
-		memcpy(fr->c_bits, ft_fr_down_bits, 5);
-		/* clear time alignment */
-		memset(fr->c_bits+5, 0, 6);
-		/* FIXME: SP / BFI in case of DTx */
-		/* C12 .. C21 are spare and coded as '1' */
-		memset(fr->c_bits+11, 0x01, 10);
-		break;
-	case TRAU_FT_EFR:
-		/* clear time alignment */
-		memset(fr->c_bits+5, 0, 6);
-		/* set UFE appropriately */
-		fr->c_bits[11] = 1; /* C12 (UFE), good frame (TODO) */
-		/* C13 .. C15 are spare and coded as '1' */
-		memset(fr->c_bits+12, 0x01, 3);
-		/* SP / BFI in case of DTx */
-		fr->c_bits[15] = 1; /* C16 (SP), no DTX (TODO) */
-		/* C17 .. C21 are spare and coded as '1' */
-		memset(fr->c_bits+16, 0x01, 5);
-		break;
-	case TRAU_FT_IDLE_UP:
-		memcpy(fr->c_bits, ft_idle_down_bits, 5);
-		/* clear time alignment */
-		memset(fr->c_bits+5, 0, 6);
-		/* FIXME: SP / BFI in case of DTx */
-		/* C12 .. C21 are spare and coded as '1' */
-		memset(fr->c_bits+11, 0x01, 10);
-		break;
-	case TRAU_FT_FR_DOWN:
-	case TRAU_FT_IDLE_DOWN:
-	case TRAU_FT_OM_DOWN:
-	case TRAU_FT_DATA_DOWN:
-		/* we cannot convert a downlink to a downlink frame */
-		return -EINVAL;
-		break;
-	case TRAU_FT_AMR:
-	case TRAU_FT_OM_UP:
-	case TRAU_FT_DATA_UP:
-	case TRAU_FT_D145_SYNC:
-	case TRAU_FT_EDATA:
-		LOGP(DMUX, LOGL_NOTICE, "unimplemented TRAU Frame Type "
-			"0x%02x\n", cbits5);
-		return -1;
-		break;
-	default:
-		LOGP(DMUX, LOGL_NOTICE, "unknown TRAU Frame Type "
-			"0x%02x\n", cbits5);
-		return -1;
-		break;
-	}
-
-	return 0;
-
-}
-
-static void encode_fr(uint8_t *trau_bits, const struct decoded_trau_frame *fr)
-{
-	int i;
-	int d_idx = 0;
-
-	trau_bits[16] = 1;
-	/* C1 .. C15 */
-	memcpy(trau_bits+17, fr->c_bits+0, 15);
-	/* D1 .. D255 */
-	for (i = 32; i < 304; i+= 16) {
-		trau_bits[i] = 1;
-		memcpy(trau_bits+i+1, fr->d_bits + d_idx, 15);
-		d_idx += 15;
-	}
-	/* D256 .. D260 */
-	trau_bits[304] = 1;
-	memcpy(trau_bits + 305, fr->d_bits + d_idx, 5);
-	/* C16 .. C21 */
-	memcpy(trau_bits+310, fr->c_bits+15, 6);
-
-	/* FIXME: handle timing adjustment */
-
-	/* T1 .. T4 */
-	memcpy(trau_bits+316, fr->t_bits+0, 4);
-}
-
-
-int encode_trau_frame(uint8_t *trau_bits, const struct decoded_trau_frame *fr)
-{
-	uint8_t cbits5 = get_bits(fr->c_bits, 0, 5);
-	
-	/* 16 bits of sync header */
-	memset(trau_bits, 0, 16);
-
-	switch (cbits5) {
-	case TRAU_FT_FR_UP:
-	case TRAU_FT_FR_DOWN:
-	case TRAU_FT_IDLE_UP:
-	case TRAU_FT_IDLE_DOWN:
-	case TRAU_FT_EFR:
-		encode_fr(trau_bits, fr);
-		break;
-	case TRAU_FT_AMR:
-	case TRAU_FT_OM_UP:
-	case TRAU_FT_OM_DOWN:
-	case TRAU_FT_DATA_UP:
-	case TRAU_FT_DATA_DOWN:
-	case TRAU_FT_D145_SYNC:
-	case TRAU_FT_EDATA:
-		LOGP(DMUX, LOGL_NOTICE, "unimplemented TRAU Frame Type "
-			"0x%02x\n", cbits5);
-		return -1;
-		break;
-	default:
-		LOGP(DMUX, LOGL_NOTICE, "unknown TRAU Frame Type "
-			"0x%02x\n", cbits5);
-		return -1;
-		break;
-	}
-
-	return 0;
-}
-
-static struct decoded_trau_frame fr_idle_frame = {
-	.c_bits = { 0, 1, 1, 1, 0 },	/* IDLE DOWNLINK 3.5.5 */
-	.t_bits = { 1, 1, 1, 1 },
-};
-static uint8_t encoded_idle_frame[TRAU_FRAME_BITS];
-static int dbits_initted = 0;
-
-uint8_t *trau_idle_frame(void)
-{
-	/* only initialize during the first call */
-	if (!dbits_initted) {
-		/* set all D-bits to 1 */
-		memset(&fr_idle_frame.d_bits, 0x01, 260);
-
-		memset(&fr_idle_frame.c_bits, 0x01, 25); /* spare are set to 1 */
-		/* set Downlink Idle Speech Frame pattern */
-		fr_idle_frame.c_bits[0] = 0; /* C1 */
-		fr_idle_frame.c_bits[1] = 1; /* C2 */
-		fr_idle_frame.c_bits[2] = 1; /* C3 */
-		fr_idle_frame.c_bits[3] = 1; /* C4 */
-		fr_idle_frame.c_bits[4] = 0; /* C5 */
-		/* set no Time Alignment pattern */
-		fr_idle_frame.c_bits[5] = 0; /* C6 */
-		fr_idle_frame.c_bits[6] = 0; /* C7 */
-		fr_idle_frame.c_bits[7] = 0; /* C8 */
-		fr_idle_frame.c_bits[8] = 0; /* C9 */
-		fr_idle_frame.c_bits[9] = 0; /* C10 */
-		fr_idle_frame.c_bits[10] = 0; /* C11 */
-		/* already set to 1, but maybe we need to modify it in the future */
-		fr_idle_frame.c_bits[11] = 1; /* C12 (UFE), good frame */
-		fr_idle_frame.c_bits[15] = 1; /* C16 (SP), no DTX */
-
-		encode_fr(encoded_idle_frame, &fr_idle_frame);
-		dbits_initted = 1; /* set it to 1 to not call it again */
-	}
-	return encoded_idle_frame;
-}
diff --git a/openbsc/src/libtrau/trau_mux.c b/openbsc/src/libtrau/trau_mux.c
index ab27879..6a6b7c5 100644
--- a/openbsc/src/libtrau/trau_mux.c
+++ b/openbsc/src/libtrau/trau_mux.c
@@ -23,10 +23,10 @@
 #include <string.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/trau_frame.h>
+#include <osmocom/abis/trau_frame.h>
 #include <openbsc/trau_mux.h>
-#include <openbsc/subchan_demux.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/subchan_demux.h>
+#include <osmocom/abis/e1_input.h>
 #include <openbsc/debug.h>
 #include <osmocom/core/talloc.h>
 
@@ -70,7 +70,7 @@
 
 	me = talloc(tall_map_ctx, struct map_entry);
 	if (!me) {
-		LOGP(DMIB, LOGL_FATAL, "Out of memory\n");
+		LOGP(DLMIB, LOGL_FATAL, "Out of memory\n");
 		return -ENOMEM;
 	}
 
@@ -186,7 +186,7 @@
 		if (!ue->callref)
 			return -EINVAL;
 		if (memcmp(tf.c_bits, c_bits_check, sizeof(c_bits_check)))
-			DEBUGPC(DMUX, "illegal trau (C1-C5) %s\n",
+			DEBUGPC(DLMUX, "illegal trau (C1-C5) %s\n",
 				osmo_hexdump(tf.c_bits, sizeof(c_bits_check)));
 		msg = msgb_alloc(sizeof(struct gsm_data_frame) + 33,
 				 "GSM-DATA");
@@ -232,6 +232,20 @@
 				   TRAU_FRAME_BITS);
 }
 
+/* callback when a TRAU frame was received */
+int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len,
+	     void *_priv)
+{
+	struct e1inp_ts *e1i_ts = _priv;
+	struct gsm_e1_subslot src_ss;
+
+	src_ss.e1_nr = e1i_ts->line->num;
+	src_ss.e1_ts = e1i_ts->num;
+	src_ss.e1_ts_ss = ch;
+
+	return trau_mux_input(&src_ss, data, len);
+}
+
 /* add receiver instance for lchan and callref */
 int trau_recv_lchan(struct gsm_lchan *lchan, uint32_t callref)
 {
@@ -301,7 +315,7 @@
 		}
 		break;
 	default:
-		DEBUGPC(DMUX, "unsupported message type %d\n",
+		DEBUGPC(DLMUX, "unsupported message type %d\n",
 			frame->msg_type);
 		return -EINVAL;
 	}
diff --git a/openbsc/src/osmo-bsc/Makefile.am b/openbsc/src/osmo-bsc/Makefile.am
index f32705c..b59ea16 100644
--- a/openbsc/src/osmo-bsc/Makefile.am
+++ b/openbsc/src/osmo-bsc/Makefile.am
@@ -1,6 +1,6 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS) $(LIBOSMOABIS_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS) $(LIBOSMOABIS_LIBS)
 
 bin_PROGRAMS = osmo-bsc
 
@@ -12,8 +12,8 @@
 osmo_bsc_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
 		 $(top_builddir)/src/libmsc/libmsc.a \
 		 $(top_builddir)/src/libbsc/libbsc.a \
-		 $(top_builddir)/src/libabis/libabis.a \
 		 $(top_builddir)/src/libtrau/libtrau.a \
 		 $(top_builddir)/src/libcommon/libcommon.a \
 		 $(top_builddir)/src/libctrl/libctrl.a \
+		 $(top_builddir)/src/libcommon/libcommon.a \
 		 $(LIBOSMOSCCP_LIBS)
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 7d376ef..d8950da 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -146,7 +146,7 @@
 	switch (signal) {
 	case SIGINT:
 		bsc_shutdown_net(bsc_gsmnet);
-		osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+		osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
 		sleep(3);
 		exit(0);
 		break;
@@ -396,7 +396,7 @@
 	osmo_init_logging(&log_info);
 
 	bts_init();
-	e1inp_init();
+	libosmo_abis_init(tall_bsc_ctx);
 
 	/* enable filters */
 
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
index f4d6cf2..04cfb99 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
@@ -34,6 +34,8 @@
 
 #include <osmocom/sccp/sccp.h>
 
+#include <osmocom/abis/ipa.h>
+
 #include <sys/socket.h>
 #include <netinet/tcp.h>
 #include <unistd.h>
@@ -183,7 +185,7 @@
 	int ret;
 
 	LOGP(DMSC, LOGL_DEBUG, "Sending SCCP to MSC: %u\n", msgb_l2len(msg));
-	LOGP(DMI, LOGL_DEBUG, "MSC TX %s\n", osmo_hexdump(msg->data, msg->len));
+	LOGP(DLMI, LOGL_DEBUG, "MSC TX %s\n", osmo_hexdump(msg->data, msg->len));
 
 	ret = write(fd->fd, msg->data, msg->len);
 	if (ret < msg->len)
@@ -244,23 +246,24 @@
 
 static int ipaccess_a_fd_cb(struct osmo_fd *bfd)
 {
-	int error;
-	struct msgb *msg = ipaccess_read_msg(bfd, &error);
+	struct msgb *msg;
 	struct ipaccess_head *hh;
 	struct osmo_msc_data *data = (struct osmo_msc_data *) bfd->data;
+	int ret;
 
-	if (!msg) {
-		if (error == 0) {
+	ret = ipa_msg_recv(bfd->fd, &msg);
+	if (ret <= 0) {
+		if (ret == 0) {
 			LOGP(DMSC, LOGL_ERROR, "The connection to the MSC was lost.\n");
 			bsc_msc_lost(data->msc_con);
 			return -1;
 		}
 
-		LOGP(DMSC, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
+		LOGP(DMSC, LOGL_ERROR, "Failed to parse ip access message: %d\n", ret);
 		return -1;
 	}
 
-	LOGP(DMI, LOGL_DEBUG, "From MSC: %s proto: %d\n", osmo_hexdump(msg->data, msg->len), msg->l2h[0]);
+	LOGP(DLMI, LOGL_DEBUG, "From MSC: %s proto: %d\n", osmo_hexdump(msg->data, msg->len), msg->l2h[0]);
 
 	/* handle base message handling */
 	hh = (struct ipaccess_head *) msg->data;
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c
index 6e9e027..6288fbf 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c
@@ -62,7 +62,7 @@
 
 	msg = msgb_alloc(10, "RF Query");
 	if (!msg) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate response msg.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate response msg.\n");
 		return;
 	}
 
@@ -70,7 +70,7 @@
 	msg->l2h[0] = send;
 
 	if (osmo_wqueue_enqueue(&conn->queue, msg) != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to enqueue the answer.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the answer.\n");
 		msgb_free(msg);
 		return;
 	}
@@ -152,7 +152,7 @@
 {
 	struct osmo_bsc_rf *rf = (struct osmo_bsc_rf *) _data;
 
-	LOGP(DINP, LOGL_NOTICE, "Grace timeout. Disabling the TRX.\n");
+	LOGP(DLINP, LOGL_NOTICE, "Grace timeout. Disabling the TRX.\n");
 	switch_rf_off(rf);
 }
 
@@ -161,7 +161,7 @@
 	rf->grace_timeout.cb = grace_timeout;
 	rf->grace_timeout.data = rf;
 	osmo_timer_schedule(&rf->grace_timeout, rf->gsm_network->msc_data->mid_call_timeout, 0);
-	LOGP(DINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n",
+	LOGP(DLINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n",
 	     rf->gsm_network->msc_data->mid_call_timeout);
 
 	send_signal(rf, S_RF_GRACE);
@@ -202,7 +202,7 @@
 
 	rc = read(fd->fd, buf, sizeof(buf));
 	if (rc != sizeof(buf)) {
-		LOGP(DINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno));
+		LOGP(DLINP, LOGL_ERROR, "Short read %d/%s\n", errno, strerror(errno));
 		osmo_fd_unregister(fd);
 		close(fd->fd);
 		osmo_wqueue_clear(&conn->queue);
@@ -223,7 +223,7 @@
 		break;
 	default:
 		conn->rf->last_state_command = "Unknown command";
-		LOGP(DINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);
+		LOGP(DLINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);
 		break;
 	}
 
@@ -236,7 +236,7 @@
 
 	rc = write(fd->fd, msg->data, msg->len);
 	if (rc != msg->len) {
-		LOGP(DINP, LOGL_ERROR, "Short write %d/%s\n", errno, strerror(errno));
+		LOGP(DLINP, LOGL_ERROR, "Short write %d/%s\n", errno, strerror(errno));
 		return -1;
 	}
 
@@ -253,14 +253,14 @@
 
 	fd = accept(bfd->fd, (struct sockaddr *) &addr, &len);
 	if (fd < 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to accept. errno: %d/%s\n",
+		LOGP(DLINP, LOGL_ERROR, "Failed to accept. errno: %d/%s\n",
 		     errno, strerror(errno));
 		return -1;
 	}
 
 	conn = talloc_zero(rf, struct osmo_bsc_rf_conn);
 	if (!conn) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate mem.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate mem.\n");
 		close(fd);
 		return -1;
 	}
@@ -292,14 +292,14 @@
 
 	rf = talloc_zero(NULL, struct osmo_bsc_rf);
 	if (!rf) {
-		LOGP(DINP, LOGL_ERROR, "Failed to create osmo_bsc_rf.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to create osmo_bsc_rf.\n");
 		return NULL;
 	}
 
 	bfd = &rf->listen;
 	bfd->fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (bfd->fd < 0) {
-		LOGP(DINP, LOGL_ERROR, "Can not create socket. %d/%s\n",
+		LOGP(DLINP, LOGL_ERROR, "Can not create socket. %d/%s\n",
 		     errno, strerror(errno));
 		return NULL;
 	}
@@ -323,7 +323,7 @@
 
 	rc = bind(bfd->fd, (struct sockaddr *) &local, namelen);
 	if (rc != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to bind '%s' errno: %d/%s\n",
+		LOGP(DLINP, LOGL_ERROR, "Failed to bind '%s' errno: %d/%s\n",
 		     local.sun_path, errno, strerror(errno));
 		close(bfd->fd);
 		talloc_free(rf);
@@ -331,7 +331,7 @@
 	}
 
 	if (listen(bfd->fd, 0) != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to listen: %d/%s\n", errno, strerror(errno));
+		LOGP(DLINP, LOGL_ERROR, "Failed to listen: %d/%s\n", errno, strerror(errno));
 		close(bfd->fd);
 		talloc_free(rf);
 		return NULL;
@@ -342,7 +342,7 @@
 	bfd->data = rf;
 
 	if (osmo_fd_register(bfd) != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to register bfd.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to register bfd.\n");
 		close(bfd->fd);
 		talloc_free(rf);
 		return NULL;
diff --git a/openbsc/src/osmo-bsc_nat/Makefile.am b/openbsc/src/osmo-bsc_nat/Makefile.am
index eea720e..2554000 100644
--- a/openbsc/src/osmo-bsc_nat/Makefile.am
+++ b/openbsc/src/osmo-bsc_nat/Makefile.am
@@ -1,6 +1,6 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 bin_PROGRAMS = osmo-bsc_nat
 
@@ -10,7 +10,6 @@
 osmo_bsc_nat_LDADD = $(top_builddir)/src/libcommon/libcommon.a \
 		$(top_builddir)/src/libmgcp/libmgcp.a \
 		$(top_builddir)/src/libbsc/libbsc.a \
-		$(top_builddir)/src/libabis/libabis.a \
 		$(top_builddir)/src/libtrau/libtrau.a \
 		$(top_builddir)/src/libctrl/libctrl.a \
 		-lrt $(LIBOSMOSCCP_LIBS)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_filter.c b/openbsc/src/osmo-bsc_nat/bsc_filter.c
index 74a5d19..bbbba69 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_filter.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_filter.c
@@ -98,7 +98,7 @@
 
 	/* do a size check on the input */
 	if (ntohs(hh->len) != msgb_l2len(msg)) {
-		LOGP(DINP, LOGL_ERROR, "Wrong input length?\n");
+		LOGP(DLINP, LOGL_ERROR, "Wrong input length?\n");
 		talloc_free(parsed);
 		return NULL;
 	}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 445f459..c42061b 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -48,6 +48,7 @@
 #include <osmocom/core/application.h>
 #include <osmocom/core/talloc.h>
 
+#include <osmocom/gsm/tlv.h>
 #include <osmocom/gsm/gsm0808.h>
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 
@@ -57,6 +58,8 @@
 
 #include <osmocom/sccp/sccp.h>
 
+#include <osmocom/abis/ipa.h>
+
 #include "../../bscconfig.h"
 
 #define SCCP_CLOSE_TIME 20
@@ -95,14 +98,14 @@
 static void queue_for_msc(struct bsc_msc_connection *con, struct msgb *msg)
 {
 	if (!con) {
-		LOGP(DINP, LOGL_ERROR, "No MSC Connection assigned. Check your code.\n");
+		LOGP(DLINP, LOGL_ERROR, "No MSC Connection assigned. Check your code.\n");
 		msgb_free(msg);
 		return;
 	}
 
 
 	if (osmo_wqueue_enqueue(&con->write_queue, msg) != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the write.\n");
 		msgb_free(msg);
 	}
 }
@@ -361,13 +364,13 @@
 	struct msgb *msg;
 
 	if (length > 4096 - 128) {
-		LOGP(DINP, LOGL_ERROR, "Can not send message of that size.\n");
+		LOGP(DLINP, LOGL_ERROR, "Can not send message of that size.\n");
 		return;
 	}
 
 	msg = msgb_alloc_headroom(4096, 128, "to-bsc");
 	if (!msg) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n");
 		return;
 	}
 
@@ -783,18 +786,19 @@
 
 static int ipaccess_msc_read_cb(struct osmo_fd *bfd)
 {
-	int error;
 	struct bsc_msc_connection *msc_con;
-	struct msgb *msg = ipaccess_read_msg(bfd, &error);
+	struct msgb *msg;
 	struct ipaccess_head *hh;
+	int ret;
 
 	msc_con = (struct bsc_msc_connection *) bfd->data;
 
-	if (!msg) {
-		if (error == 0)
+	ret = ipa_msg_recv(bfd->fd, &msg);
+	if (ret <= 0) {
+		if (ret == 0)
 			LOGP(DNAT, LOGL_FATAL, "The connection the MSC was lost, exiting\n");
 		else
-			LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", error);
+			LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", ret);
 
 		bsc_msc_lost(msc_con);
 		return -1;
@@ -1252,21 +1256,22 @@
 
 static int ipaccess_bsc_read_cb(struct osmo_fd *bfd)
 {
-	int error;
 	struct bsc_connection *bsc = bfd->data;
-	struct msgb *msg = ipaccess_read_msg(bfd, &error);
+	struct msgb *msg;
 	struct ipaccess_head *hh;
 	struct ipaccess_head_ext *hh_ext;
+	int ret;
 
-	if (!msg) {
-		if (error == 0)
+	ret = ipa_msg_recv(bfd->fd, &msg);
+	if (ret <= 0) {
+		if (ret == 0)
 			LOGP(DNAT, LOGL_ERROR,
 			     "The connection to the BSC Nr: %d was lost. Cleaning it\n",
 			     bsc->cfg ? bsc->cfg->nr : -1);
 		else
 			LOGP(DNAT, LOGL_ERROR,
 			     "Stream error on BSC Nr: %d. Failed to parse ip access message: %d\n",
-			     bsc->cfg ? bsc->cfg->nr : -1, error);
+			     bsc->cfg ? bsc->cfg->nr : -1, ret);
 
 		bsc_close_connection(bsc);
 		return -1;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 8658c3d..84b23d1 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -318,13 +318,13 @@
 	struct msgb *msg;
 
 	if (length > 4096 - 128) {
-		LOGP(DINP, LOGL_ERROR, "Can not send message of that size.\n");
+		LOGP(DLINP, LOGL_ERROR, "Can not send message of that size.\n");
 		return -1;
 	}
 
 	msg = msgb_alloc_headroom(4096, 128, "to-bsc");
 	if (!msg) {
-		LOGP(DINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n");
 		return -1;
 	}
 
@@ -350,7 +350,7 @@
 int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg)
 {
 	if (osmo_wqueue_enqueue(queue, msg) != 0) {
-		LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n");
+		LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the write.\n");
 		msgb_free(msg);
 		return -1;
 	}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index bbbeead..80d6e77 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -32,6 +32,8 @@
 
 #include <osmocom/sccp/sccp.h>
 
+#include <osmocom/abis/ipa.h>
+
 #include <sys/socket.h>
 #include <string.h>
 #include <unistd.h>
@@ -97,12 +99,13 @@
 
 static int ussd_read_cb(struct osmo_fd *bfd)
 {
-	int error;
 	struct bsc_nat_ussd_con *conn = bfd->data;
-	struct msgb *msg = ipaccess_read_msg(bfd, &error);
+	struct msgb *msg;
 	struct ipaccess_head *hh;
+	int ret;
 
-	if (!msg) {
+	ret = ipa_msg_recv(bfd->fd, &msg);
+	if (ret <= 0) {
 		LOGP(DNAT, LOGL_ERROR, "USSD Connection was lost.\n");
 		bsc_nat_ussd_destroy(conn);
 		return -1;
diff --git a/openbsc/src/osmo-nitb/Makefile.am b/openbsc/src/osmo-nitb/Makefile.am
index 1b813a2..d912abd 100644
--- a/openbsc/src/osmo-nitb/Makefile.am
+++ b/openbsc/src/osmo-nitb/Makefile.am
@@ -1,16 +1,16 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 bin_PROGRAMS = osmo-nitb
 
 osmo_nitb_SOURCES = bsc_hack.c
-osmo_nitb_LDADD = -ldl $(LIBCRYPT) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
+osmo_nitb_LDADD = -ldl $(LIBCRYPT) $(LIBOSMOGSM_LIBS) \
+		$(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) \
 		$(top_builddir)/src/libbsc/libbsc.a \
 		$(top_builddir)/src/libmsc/libmsc.a \
 		$(top_builddir)/src/libbsc/libbsc.a \
 		$(top_builddir)/src/libtrau/libtrau.a \
-		$(top_builddir)/src/libabis/libabis.a \
-		$(top_builddir)/src/libcommon/libcommon.a \
 		$(top_builddir)/src/libctrl/libctrl.a \
+		$(top_builddir)/src/libcommon/libcommon.a \
 		-ldbi
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index 9693dc4..b41b808 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -33,7 +33,8 @@
 #include <osmocom/core/application.h>
 #include <osmocom/core/select.h>
 #include <openbsc/debug.h>
-#include <openbsc/e1_input.h>
+#include <osmocom/abis/abis.h>
+#include <osmocom/abis/e1_input.h>
 #include <osmocom/core/talloc.h>
 #include <openbsc/signal.h>
 #include <openbsc/osmo_msc.h>
@@ -172,7 +173,7 @@
 	switch (signal) {
 	case SIGINT:
 		bsc_shutdown_net(bsc_gsmnet);
-		osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
+		osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
 		sleep(3);
 		exit(0);
 		break;
@@ -227,10 +228,9 @@
 	on_dso_load_rrlp();
 	on_dso_load_ho_dec();
 
+	libosmo_abis_init(tall_bsc_ctx);
 	osmo_init_logging(&log_info);
-
 	bts_init();
-	e1inp_init();
 
 	/* This needs to precede handle_options() */
 	vty_init(&vty_info);
diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am
index c2d2085..a7882ed 100644
--- a/openbsc/src/utils/Makefile.am
+++ b/openbsc/src/utils/Makefile.am
@@ -1,12 +1,12 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS)
 
 bin_PROGRAMS = bs11_config isdnsync
 
-bs11_config_SOURCES = bs11_config.c rs232.c
+bs11_config_SOURCES = bs11_config.c
 bs11_config_LDADD = $(top_builddir)/src/libcommon/libcommon.a \
-		    $(top_builddir)/src/libabis/libabis.a \
-		    $(top_builddir)/src/libbsc/libbsc.a
+		    $(top_builddir)/src/libbsc/libbsc.a \
+		    $(top_builddir)/src/libtrau/libtrau.a
 
 isdnsync_SOURCES = isdnsync.c
diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c
index ef01072..e8acb46 100644
--- a/openbsc/src/utils/bs11_config.c
+++ b/openbsc/src/utils/bs11_config.c
@@ -41,6 +41,12 @@
 #include <osmocom/core/select.h>
 #include <openbsc/rs232.h>
 #include <osmocom/core/application.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/abis/abis.h>
+#include <osmocom/abis/e1_input.h>
+
+static void *tall_bs11cfg_ctx;
+static struct e1inp_sign_link *oml_link;
 
 /* state of our bs11_config application */
 enum bs11cfg_state {
@@ -638,8 +644,9 @@
 }
 
 /* handle a fully-received message/packet from the RS232 port */
-int handle_serial_msg(struct msgb *rx_msg)
+static int abis_nm_bs11cfg_rcvmsg(struct msgb *rx_msg)
 {
+	struct e1inp_sign_link *link = rx_msg->dst;
 	struct abis_om_hdr *oh;
 	struct abis_om_fom_hdr *foh;
 	struct tlv_parsed tp;
@@ -719,6 +726,8 @@
 		perror("ERROR in main loop");
 		//break;
 	}
+	/* flush the queue of pending messages to be sent. */
+	abis_nm_queue_send_next(link->trx->bts);
 	if (rc == 1)
 		return rc;
 
@@ -864,11 +873,21 @@
 	}
 }
 
+static int bs11cfg_sign_link(struct msgb *msg)
+{
+	msg->dst = oml_link;
+	return abis_nm_bs11cfg_rcvmsg(msg);
+}
+
+struct e1inp_line_ops bs11cfg_e1inp_line_ops = {
+	.sign_link	= bs11cfg_sign_link,
+};
+
 extern int bts_model_bs11_init(void);
 int main(int argc, char **argv)
 {
 	struct gsm_network *gsmnet;
-	int rc;
+	struct e1inp_line *line;
 
 	osmo_init_logging(&log_info);
 	handle_options(argc, argv);
@@ -882,11 +901,35 @@
 	g_bts = gsm_bts_alloc_register(gsmnet, GSM_BTS_TYPE_BS11, HARDCODED_TSC,
 					HARDCODED_BSIC);
 
-	rc = rs232_setup(serial_port, delay_ms, g_bts);
-	if (rc < 0) {
-		fprintf(stderr, "Problem setting up serial port\n");
+	/* Override existing OML callback handler to set our own. */
+	g_bts->model->oml_rcvmsg = abis_nm_bs11cfg_rcvmsg;
+
+	libosmo_abis_init(tall_bs11cfg_ctx);
+
+	/* Initialize virtual E1 line over rs232. */
+	line = talloc_zero(tall_bs11cfg_ctx, struct e1inp_line);
+	if (!line) {
+		fprintf(stderr, "Unable to allocate memory for virtual E1 line\n");
 		exit(1);
 	}
+	/* set the serial port. */
+	bs11cfg_e1inp_line_ops.cfg.rs232.port = serial_port;
+	bs11cfg_e1inp_line_ops.cfg.rs232.delay = delay_ms;
+
+	line->driver = e1inp_driver_find("rs232");
+	if (!line->driver) {
+		fprintf(stderr, "cannot find `rs232' driver, giving up.\n");
+		exit(1);
+	}
+	e1inp_line_bind_ops(line, &bs11cfg_e1inp_line_ops);
+
+	/* configure and create signalling link for OML. */
+	e1inp_ts_config_sign(&line->ts[0], line);
+	g_bts->oml_link = oml_link =
+		e1inp_sign_link_create(&line->ts[0], E1INP_SIGN_OML,
+					g_bts->c0, TEI_OML, 0);
+
+	e1inp_line_update(line);
 
 	signal(SIGINT, &signal_handler);
 
@@ -904,8 +947,3 @@
 
 	exit(0);
 }
-
-/* dummy to be able to compile */
-void gsm_net_update_ctype(struct gsm_network *net)
-{
-}
diff --git a/openbsc/src/utils/rs232.c b/openbsc/src/utils/rs232.c
deleted file mode 100644
index 01b8c7e..0000000
--- a/openbsc/src/utils/rs232.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* OpenBSC BS-11 T-Link interface using POSIX serial port */
-
-/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <termios.h>
-#include <fcntl.h>
-
-#include <osmocom/core/select.h>
-#include <osmocom/core/msgb.h>
-#include <openbsc/debug.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/rs232.h>
-
-/* adaption layer from GSM 08.59 + 12.21 to RS232 */
-
-struct serial_handle {
-	struct osmo_fd fd;
-	struct llist_head tx_queue;
-
-	struct msgb *rx_msg;
-	unsigned int rxmsg_bytes_missing;
-
-	unsigned int delay_ms;
-	struct gsm_bts *bts;
-};
-
-/* FIXME: this needs to go */
-static struct serial_handle _ser_handle, *ser_handle = &_ser_handle;
-
-#define LAPD_HDR_LEN	10
-
-static int handle_ser_write(struct osmo_fd *bfd);
-
-/* callback from abis_nm */
-int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml)
-{
-	struct serial_handle *sh = ser_handle;
-	uint8_t *lapd;
-	unsigned int len;
-
-	msg->l2h = msg->data;
-
-	/* prepend LAPD header */
-	lapd = msgb_push(msg, LAPD_HDR_LEN);
-
-	len = msg->len - 2;
-
-	lapd[0] = (len >> 8) & 0xff;
-	lapd[1] = len & 0xff; /* length of bytes startign at lapd[2] */
-	lapd[2] = 0x00;
-	lapd[3] = 0x07;
-	lapd[4] = 0x01;
-	lapd[5] = 0x3e;
-	lapd[6] = 0x00;
-	lapd[7] = 0x00;
-	lapd[8] = msg->len - 10; /* length of bytes starting at lapd[10] */
-	lapd[9] = lapd[8] ^ 0x38;
-
-	msgb_enqueue(&sh->tx_queue, msg);
-	sh->fd.when |= BSC_FD_WRITE;
-
-	/* we try to immediately send */
-	handle_ser_write(&sh->fd);
-
-	return 0;
-}
-
-/* select.c callback in case we can write to the RS232 */
-static int handle_ser_write(struct osmo_fd *bfd)
-{
-	struct serial_handle *sh = bfd->data;
-	struct msgb *msg;
-	int written;
-
-	msg = msgb_dequeue(&sh->tx_queue);
-	if (!msg) {
-		bfd->when &= ~BSC_FD_WRITE;
-		return 0;
-	}
-
-	DEBUGP(DMI, "RS232 TX: %s\n", osmo_hexdump(msg->data, msg->len));
-
-	/* send over serial line */
-	written = write(bfd->fd, msg->data, msg->len);
-	if (written < msg->len) {
-		perror("short write:");
-		msgb_free(msg);
-		return -1;
-	}
-
-	msgb_free(msg);
-	usleep(sh->delay_ms*1000);
-
-	return 0;
-}
-
-#define SERIAL_ALLOC_SIZE	300
-
-/* select.c callback in case we can read from the RS232 */
-static int handle_ser_read(struct osmo_fd *bfd)
-{
-	struct serial_handle *sh = bfd->data;
-	struct msgb *msg;
-	int rc = 0;
-
-	if (!sh->rx_msg) {
-		sh->rx_msg = msgb_alloc(SERIAL_ALLOC_SIZE, "RS232 Rx");
-		sh->rx_msg->l2h = NULL;
-		sh->rx_msg->dst = sh->bts->c0->rsl_link;
-	}
-	msg = sh->rx_msg;
-
-	/* first read two byes to obtain length */
-	if (msg->len < 2) {
-		rc = read(sh->fd.fd, msg->tail, 2 - msg->len);
-		if (rc < 0) {
-			perror("ERROR reading from serial port");
-			msgb_free(msg);
-			return rc;
-		}
-		msgb_put(msg, rc);
-
-		if (msg->len >= 2) {
-			/* parse LAPD payload length */
-			if (msg->data[0] != 0)
-				fprintf(stderr, "Suspicious header byte 0: 0x%02x\n",
-					msg->data[0]);
-
-			sh->rxmsg_bytes_missing = msg->data[0] << 8;
-			sh->rxmsg_bytes_missing += msg->data[1];
-
-			if (sh->rxmsg_bytes_missing < LAPD_HDR_LEN -2)
-				fprintf(stderr, "Invalid length in hdr: %u\n",
-					sh->rxmsg_bytes_missing);
-		}
-	} else {
-		/* try to read as many of the missing bytes as are available */
-		rc = read(sh->fd.fd, msg->tail, sh->rxmsg_bytes_missing);
-		if (rc < 0) {
-			perror("ERROR reading from serial port");
-			msgb_free(msg);
-			return rc;
-		}
-		msgb_put(msg, rc);
-		sh->rxmsg_bytes_missing -= rc;
-
-		if (sh->rxmsg_bytes_missing == 0) {
-			/* we have one complete message now */
-			sh->rx_msg = NULL;
-
-			if (msg->len > LAPD_HDR_LEN)
-				msg->l2h = msg->data + LAPD_HDR_LEN;
-
-			DEBUGP(DMI, "RS232 RX: %s\n", osmo_hexdump(msg->data, msg->len));
-			rc = handle_serial_msg(msg);
-		}
-	}
-
-	return rc;
-}
-
-/* select.c callback */
-static int serial_fd_cb(struct osmo_fd *bfd, unsigned int what)
-{
-	int rc = 0;
-
-	if (what & BSC_FD_READ)
-		rc = handle_ser_read(bfd);
-
-	if (rc < 0)
-		return rc;
-
-	if (what & BSC_FD_WRITE)
-		rc = handle_ser_write(bfd);
-
-	return rc;
-}
-
-int rs232_setup(const char *serial_port, unsigned int delay_ms,
-		struct gsm_bts *bts)
-{
-	int rc, serial_fd;
-	struct termios tio;
-
-	serial_fd = open(serial_port, O_RDWR);
-	if (serial_fd < 0) {
-		perror("cannot open serial port:");
-		return serial_fd;
-	}
-
-	/* set baudrate */
-	rc = tcgetattr(serial_fd, &tio);
-	if (rc < 0) {
-		perror("tcgetattr()");
-		return rc;
-	}
-	cfsetispeed(&tio, B19200);
-	cfsetospeed(&tio, B19200);
-	tio.c_cflag |=  (CREAD | CLOCAL | CS8);
-	tio.c_cflag &= ~(PARENB | CSTOPB | CSIZE | CRTSCTS);
-	tio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
-	tio.c_iflag |=  (INPCK | ISTRIP);
-	tio.c_iflag &= ~(ISTRIP | IXON | IXOFF | IGNBRK | INLCR | ICRNL | IGNCR);
-	tio.c_oflag &= ~(OPOST);
-	rc = tcsetattr(serial_fd, TCSADRAIN, &tio);
-	if (rc < 0) {
-		perror("tcsetattr()");
-		return rc;
-	}
-
-	INIT_LLIST_HEAD(&ser_handle->tx_queue);
-	ser_handle->fd.fd = serial_fd;
-	ser_handle->fd.when = BSC_FD_READ;
-	ser_handle->fd.cb = serial_fd_cb;
-	ser_handle->fd.data = ser_handle;
-	ser_handle->delay_ms = delay_ms;
-	ser_handle->bts = bts;
-	rc = osmo_fd_register(&ser_handle->fd);
-	if (rc < 0) {
-		fprintf(stderr, "could not register FD: %s\n",
-			strerror(rc));
-		return rc;
-	}
-
-	return 0;
-}
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index 4785098..5a68984 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -1,5 +1,5 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS)
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
 AM_LDFLAGS = $(COVERAGE_LDFLAGS)
 
 EXTRA_DIST = bsc_data.c
@@ -13,7 +13,8 @@
 			$(top_srcdir)/src/osmo-bsc_nat/bsc_mgcp_utils.c
 bsc_nat_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
 			$(top_srcdir)/src/libmgcp/libmgcp.a \
-			$(top_srcdir)/src/libabis/libabis.a \
 			$(top_srcdir)/src/libtrau/libtrau.a \
 			$(top_srcdir)/src/libcommon/libcommon.a \
-			$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -lrt $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
+			$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -lrt \
+			$(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) \
+			$(LIBOSMOABIS_LIBS)
diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am
index 98fdccc..aab2cd6 100644
--- a/openbsc/tests/db/Makefile.am
+++ b/openbsc/tests/db/Makefile.am
@@ -1,5 +1,5 @@
 INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS)
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS)
 AM_LDFLAGS = $(COVERAGE_LDFLAGS)
 
 noinst_PROGRAMS = db_test
@@ -8,8 +8,8 @@
 db_test_LDADD =	$(top_builddir)/src/libbsc/libbsc.a \
 		$(top_builddir)/src/libmsc/libmsc.a \
 		$(top_builddir)/src/libbsc/libbsc.a \
-		$(top_builddir)/src/libabis/libabis.a \
 		$(top_builddir)/src/libtrau/libtrau.a \
 		$(top_builddir)/src/libcommon/libcommon.a \
-		$(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -ldl -ldbi
+		$(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS) \
+		$(LIBOSMOGSM_LIBS) -ldl -ldbi