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