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/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);
-}