split 'libosmocore' from openbsc codebase

This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB

The library currently includes the following modules:

bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist

msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
diff --git a/libosmocore/Makefile.am b/libosmocore/Makefile.am
new file mode 100644
index 0000000..6bda10a
--- /dev/null
+++ b/libosmocore/Makefile.am
@@ -0,0 +1,7 @@
+AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
+
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+SUBDIRS = include src
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libosmocore.pc
diff --git a/libosmocore/configure.in b/libosmocore/configure.in
new file mode 100644
index 0000000..8c0fe67
--- /dev/null
+++ b/libosmocore/configure.in
@@ -0,0 +1,37 @@
+AC_INIT
+
+AM_INIT_AUTOMAKE(libosmocore, 0.0alpha1)
+
+dnl kernel style compile messages
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+dnl checks for programs
+AC_PROG_MAKE_SET
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+
+dnl checks for header files
+AC_HEADER_STDC
+
+# The following test is taken from WebKit's webkit.m4
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fvisibility=hidden "
+AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
+AC_COMPILE_IFELSE([char foo;],
+      [ AC_MSG_RESULT([yes])
+        SYMBOL_VISIBILITY="-fvisibility=hidden"],
+        AC_MSG_RESULT([no]))
+CFLAGS="$saved_CFLAGS"
+AC_SUBST(SYMBOL_VISIBILITY)
+
+dnl Generate the output
+AM_CONFIG_HEADER(config.h)
+
+AC_OUTPUT(
+	libosmocore.pc
+	include/osmocore/Makefile
+	include/Makefile
+	src/Makefile
+	Makefile)
diff --git a/libosmocore/include/Makefile.am b/libosmocore/include/Makefile.am
new file mode 100644
index 0000000..f0015d5
--- /dev/null
+++ b/libosmocore/include/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = osmocore
diff --git a/libosmocore/include/osmocore/Makefile.am b/libosmocore/include/osmocore/Makefile.am
new file mode 100644
index 0000000..aec27d1
--- /dev/null
+++ b/libosmocore/include/osmocore/Makefile.am
@@ -0,0 +1,2 @@
+pkginclude_HEADERS = signal.h linuxlist.h timer.h talloc.h msgb.h select.h \
+		     tlv.h bitvec.h comp128.h statistics.h gsm_utils.h
diff --git a/openbsc/include/openbsc/bitvec.h b/libosmocore/include/osmocore/bitvec.h
similarity index 100%
rename from openbsc/include/openbsc/bitvec.h
rename to libosmocore/include/osmocore/bitvec.h
diff --git a/openbsc/include/openbsc/comp128.h b/libosmocore/include/osmocore/comp128.h
similarity index 100%
rename from openbsc/include/openbsc/comp128.h
rename to libosmocore/include/osmocore/comp128.h
diff --git a/openbsc/include/openbsc/gsm_utils.h b/libosmocore/include/osmocore/gsm_utils.h
similarity index 89%
rename from openbsc/include/openbsc/gsm_utils.h
rename to libosmocore/include/osmocore/gsm_utils.h
index 56a4120..c770cc9 100644
--- a/openbsc/include/openbsc/gsm_utils.h
+++ b/libosmocore/include/osmocore/gsm_utils.h
@@ -27,6 +27,17 @@
 
 #include <sys/types.h>
 
+enum gsm_band {
+	GSM_BAND_850	= 1,
+	GSM_BAND_900	= 2,
+	GSM_BAND_1800	= 4,
+	GSM_BAND_1900	= 8,
+	GSM_BAND_450	= 0x10,
+	GSM_BAND_480	= 0x20,
+	GSM_BAND_750	= 0x40,
+	GSM_BAND_810	= 0x80,
+};
+
 int gsm_7bit_decode(char *decoded, const u_int8_t *user_data, u_int8_t length);
 int gsm_7bit_encode(u_int8_t *result, const char *data);
 
diff --git a/openbsc/include/openbsc/linuxlist.h b/libosmocore/include/osmocore/linuxlist.h
similarity index 100%
rename from openbsc/include/openbsc/linuxlist.h
rename to libosmocore/include/osmocore/linuxlist.h
diff --git a/openbsc/include/openbsc/msgb.h b/libosmocore/include/osmocore/msgb.h
similarity index 100%
rename from openbsc/include/openbsc/msgb.h
rename to libosmocore/include/osmocore/msgb.h
diff --git a/openbsc/include/openbsc/select.h b/libosmocore/include/osmocore/select.h
similarity index 100%
rename from openbsc/include/openbsc/select.h
rename to libosmocore/include/osmocore/select.h
diff --git a/libosmocore/include/osmocore/signal.h b/libosmocore/include/osmocore/signal.h
new file mode 100644
index 0000000..02d83d2
--- /dev/null
+++ b/libosmocore/include/osmocore/signal.h
@@ -0,0 +1,15 @@
+#ifndef OSMOCORE_SIGNAL_H
+#define OSMOCORE_SIGNAL_H
+
+typedef int signal_cbfn(unsigned int subsys, unsigned int signal,
+			void *handler_data, void *signal_data);
+
+
+/* Management */
+int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
+void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
+
+/* Dispatch */
+void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data);
+
+#endif /* OSMOCORE_SIGNAL_H */
diff --git a/openbsc/include/openbsc/statistics.h b/libosmocore/include/osmocore/statistics.h
similarity index 100%
rename from openbsc/include/openbsc/statistics.h
rename to libosmocore/include/osmocore/statistics.h
diff --git a/openbsc/include/openbsc/talloc.h b/libosmocore/include/osmocore/talloc.h
similarity index 100%
rename from openbsc/include/openbsc/talloc.h
rename to libosmocore/include/osmocore/talloc.h
diff --git a/openbsc/include/openbsc/timer.h b/libosmocore/include/osmocore/timer.h
similarity index 100%
rename from openbsc/include/openbsc/timer.h
rename to libosmocore/include/osmocore/timer.h
diff --git a/openbsc/include/openbsc/tlv.h b/libosmocore/include/osmocore/tlv.h
similarity index 98%
rename from openbsc/include/openbsc/tlv.h
rename to libosmocore/include/osmocore/tlv.h
index 6141b1f..4ae9f6c 100644
--- a/openbsc/include/openbsc/tlv.h
+++ b/libosmocore/include/osmocore/tlv.h
@@ -4,7 +4,7 @@
 #include <sys/types.h>
 #include <string.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 
 /* Terminology / wording
 		tag	length		value	(in bits)
diff --git a/libosmocore/include/osmocore/utils.h b/libosmocore/include/osmocore/utils.h
new file mode 100644
index 0000000..198f45a
--- /dev/null
+++ b/libosmocore/include/osmocore/utils.h
@@ -0,0 +1,6 @@
+#ifndef OSMOCORE_UTIL_H
+#define OSMOCORE_UTIL_H
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+#endif
diff --git a/libosmocore/libosmocore.pc.in b/libosmocore/libosmocore.pc.in
new file mode 100644
index 0000000..0d09cb8
--- /dev/null
+++ b/libosmocore/libosmocore.pc.in
@@ -0,0 +1,10 @@
+prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Osmocom Core Library
+Description: C Utility Library
+Version: @VERSION@
+Libs: -L${libdir} -losmocore
+Cflags: -I${includedir}/
+
diff --git a/libosmocore/src/Makefile.am b/libosmocore/src/Makefile.am
new file mode 100644
index 0000000..b82b6fb
--- /dev/null
+++ b/libosmocore/src/Makefile.am
@@ -0,0 +1,11 @@
+# This is _NOT_ the library release version, it's an API version.
+# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
+LIBVERSION=0:0:0
+
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS = -fPIC -Wall
+
+lib_LTLIBRARIES = libosmocore.la
+
+libosmocore_la_SOURCES = msgb.c timer.c talloc.c select.c signal.c \
+			 tlv_parser.c bitvec.c comp128.c gsm_utils.c statistics.c
diff --git a/openbsc/src/bitvec.c b/libosmocore/src/bitvec.c
similarity index 98%
rename from openbsc/src/bitvec.c
rename to libosmocore/src/bitvec.c
index d6f5679..322f499 100644
--- a/openbsc/src/bitvec.c
+++ b/libosmocore/src/bitvec.c
@@ -24,7 +24,7 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#include <openbsc/bitvec.h>
+#include <osmocore/bitvec.h>
 
 #define BITNUM_FROM_COMP(byte, bit)	((byte*8)+bit)
 
diff --git a/openbsc/src/comp128.c b/libosmocore/src/comp128.c
similarity index 100%
rename from openbsc/src/comp128.c
rename to libosmocore/src/comp128.c
diff --git a/openbsc/src/gsm_utils.c b/libosmocore/src/gsm_utils.c
similarity index 93%
rename from openbsc/src/gsm_utils.c
rename to libosmocore/src/gsm_utils.c
index 9439993..aabd7b7 100644
--- a/openbsc/src/gsm_utils.c
+++ b/libosmocore/src/gsm_utils.c
@@ -21,9 +21,10 @@
  *
  */
 
-#include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
-#include <execinfo.h>
+//#include <openbsc/gsm_data.h>
+#include <osmocore/utils.h>
+#include <osmocore/gsm_utils.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -83,8 +84,11 @@
 int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm)
 {
 	switch (band) {
-	case GSM_BAND_400:
+	case GSM_BAND_450:
+	case GSM_BAND_480:
+	case GSM_BAND_750:
 	case GSM_BAND_900:
+	case GSM_BAND_810:
 	case GSM_BAND_850:
 		if (dbm >= 39)
 			return 0;
@@ -130,8 +134,11 @@
 	lvl &= 0x1f;
 
 	switch (band) {
-	case GSM_BAND_400:
+	case GSM_BAND_450:
+	case GSM_BAND_480:
+	case GSM_BAND_750:
 	case GSM_BAND_900:
+	case GSM_BAND_810:
 	case GSM_BAND_850:
 		if (lvl < 2)
 			return 39;
@@ -182,6 +189,7 @@
 	return rxlev;
 }
 
+#include <execinfo.h>
 void generate_backtrace()
 {
 	int i, nptrs;
diff --git a/openbsc/src/msgb.c b/libosmocore/src/msgb.c
similarity index 91%
rename from openbsc/src/msgb.c
rename to libosmocore/src/msgb.c
index 9f2fcfa..ab9b413 100644
--- a/openbsc/src/msgb.c
+++ b/libosmocore/src/msgb.c
@@ -23,10 +23,10 @@
 #include <stdlib.h>
 #include <sys/types.h>
 
-#include <openbsc/msgb.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/talloc.h>
-#include <openbsc/debug.h>
+#include <osmocore/msgb.h>
+//#include <openbsc/gsm_data.h>
+#include <osmocore/talloc.h>
+//#include <openbsc/debug.h>
 
 void *tall_msgb_ctx;
 
@@ -37,7 +37,7 @@
 	msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
 
 	if (!msg) {
-		LOGP(DRSL, LOGL_FATAL, "unable to allocate msgb\n");
+		//LOGP(DRSL, LOGL_FATAL, "unable to allocate msgb\n");
 		return NULL;
 	}
 
diff --git a/openbsc/src/select.c b/libosmocore/src/select.c
similarity index 96%
rename from openbsc/src/select.c
rename to libosmocore/src/select.c
index bed9649..46a0b96 100644
--- a/openbsc/src/select.c
+++ b/libosmocore/src/select.c
@@ -19,9 +19,9 @@
  */
 
 #include <fcntl.h>
-#include <openbsc/select.h>
-#include <openbsc/linuxlist.h>
-#include <openbsc/timer.h>
+#include <osmocore/select.h>
+#include <osmocore/linuxlist.h>
+#include <osmocore/timer.h>
 
 static int maxfd = 0;
 static LLIST_HEAD(bsc_fds);
diff --git a/openbsc/src/signal.c b/libosmocore/src/signal.c
similarity index 94%
rename from openbsc/src/signal.c
rename to libosmocore/src/signal.c
index e04cadf..c7ca86c 100644
--- a/openbsc/src/signal.c
+++ b/libosmocore/src/signal.c
@@ -18,11 +18,12 @@
  *
  */
 
-#include <openbsc/signal.h>
-#include <openbsc/talloc.h>
+#include <osmocore/signal.h>
+#include <osmocore/talloc.h>
+#include <osmocore/linuxlist.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include <errno.h>
 
 void *tall_sigh_ctx;
 static LLIST_HEAD(signal_handler_list);
diff --git a/openbsc/src/statistics.c b/libosmocore/src/statistics.c
similarity index 87%
rename from openbsc/src/statistics.c
rename to libosmocore/src/statistics.c
index 9452b16..34e6a40 100644
--- a/openbsc/src/statistics.c
+++ b/libosmocore/src/statistics.c
@@ -23,13 +23,9 @@
 
 #include <sys/types.h>
 
-#include <openbsc/gsm_data.h>
-#include <openbsc/signal.h>
-#include <openbsc/linuxlist.h>
-#include <openbsc/talloc.h>
-#include <openbsc/statistics.h>
-#include <openbsc/db.h>
-#include <openbsc/timer.h>
+#include <osmocore/linuxlist.h>
+#include <osmocore/talloc.h>
+#include <osmocore/statistics.h>
 
 static LLIST_HEAD(counters);
 
diff --git a/openbsc/src/talloc.c b/libosmocore/src/talloc.c
similarity index 99%
rename from openbsc/src/talloc.c
rename to libosmocore/src/talloc.c
index d821323..98c2ee0 100644
--- a/openbsc/src/talloc.c
+++ b/libosmocore/src/talloc.c
@@ -55,7 +55,7 @@
 #define __USE_GNU
 #include <string.h>
 #undef __USE_GNU
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #define MIN(x,y) ((x) < (y) ? (x) : (y))
 #endif /* not _TALLOC_SAMBA3 */
 
diff --git a/openbsc/src/timer.c b/libosmocore/src/timer.c
similarity index 99%
rename from openbsc/src/timer.c
rename to libosmocore/src/timer.c
index ffeb4ab..37d7d16 100644
--- a/openbsc/src/timer.c
+++ b/libosmocore/src/timer.c
@@ -20,7 +20,7 @@
 
 #include <assert.h>
 #include <string.h>
-#include <openbsc/timer.h>
+#include <osmocore/timer.h>
 
 static LLIST_HEAD(timer_list);
 static struct timeval s_nearest_time;
diff --git a/openbsc/src/tlv_parser.c b/libosmocore/src/tlv_parser.c
similarity index 98%
rename from openbsc/src/tlv_parser.c
rename to libosmocore/src/tlv_parser.c
index 13ca7b1..e9b1512 100644
--- a/openbsc/src/tlv_parser.c
+++ b/libosmocore/src/tlv_parser.c
@@ -1,6 +1,6 @@
 #include <stdio.h>
-#include <openbsc/tlv.h>
-#include <openbsc/gsm_data.h>
+#include <osmocore/utils.h>
+#include <osmocore/tlv.h>
 
 struct tlv_definition tvlv_att_def;
 
diff --git a/openbsc/Makefile.am b/openbsc/Makefile.am
index 7dcd956..7acae75 100644
--- a/openbsc/Makefile.am
+++ b/openbsc/Makefile.am
@@ -4,7 +4,7 @@
 SUBDIRS = include src tests
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = openbsc.pc liblaf0rge1.pc libsccp.pc
+pkgconfig_DATA = openbsc.pc libsccp.pc
 
 #dist-hook:
 #	rm -rf `find $(distdir) -name .svn`
diff --git a/openbsc/include/openbsc/abis_nm.h b/openbsc/include/openbsc/abis_nm.h
index 81b4eda..764e53b 100644
--- a/openbsc/include/openbsc/abis_nm.h
+++ b/openbsc/include/openbsc/abis_nm.h
@@ -25,7 +25,7 @@
 
 #include <sys/types.h>
 
-#include <openbsc/tlv.h>
+#include <osmocore/tlv.h>
 
 /* PRIVATE */
 
diff --git a/openbsc/include/openbsc/abis_rsl.h b/openbsc/include/openbsc/abis_rsl.h
index 797b2f3..3a10bf9 100644
--- a/openbsc/include/openbsc/abis_rsl.h
+++ b/openbsc/include/openbsc/abis_rsl.h
@@ -484,7 +484,7 @@
 	RSL_IPAC_RTP_CSD_IR_64k = 3,
 };
 
-#include "msgb.h"
+#include <osmocore/msgb.h>
 
 int rsl_bcch_info(struct gsm_bts_trx *trx, u_int8_t type,
 		  const u_int8_t *data, int len);
diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index c40eec3..4b67c61 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -2,7 +2,7 @@
 #define _DEBUG_H
 
 #include <stdio.h>
-#include "linuxlist.h"
+#include <osmocore/linuxlist.h>
 
 #define DEBUG
 
diff --git a/openbsc/include/openbsc/e1_input.h b/openbsc/include/openbsc/e1_input.h
index 64e0b4f..1a3d9d6 100644
--- a/openbsc/include/openbsc/e1_input.h
+++ b/openbsc/include/openbsc/e1_input.h
@@ -4,10 +4,10 @@
 #include <stdlib.h>
 #include <netinet/in.h>
 
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/msgb.h>
-#include <openbsc/select.h>
+#include <osmocore/msgb.h>
+#include <osmocore/select.h>
 #include <openbsc/subchan_demux.h>
 
 #define NUM_E1_TS   32
diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h
index c240bbe..266b5f7 100644
--- a/openbsc/include/openbsc/gsm_04_80.h
+++ b/openbsc/include/openbsc/gsm_04_80.h
@@ -123,7 +123,7 @@
 #define ASN1_IA5_STRING_TAG		0x16
 #define ASN1_UNICODE_STRING_TAG		0x1E
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 
 #define MAX_LEN_USSD_STRING	31
 
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 5567d89..eebe6ab 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -11,14 +11,6 @@
 const char *get_value_string(const struct value_string *vs, u_int32_t val);
 int get_string_value(const struct value_string *vs, const char *str);
 
-enum gsm_band {
-	GSM_BAND_400,
-	GSM_BAND_850,
-	GSM_BAND_900,
-	GSM_BAND_1800,
-	GSM_BAND_1900,
-};
-
 enum gsm_phys_chan_config {
 	GSM_PCHAN_NONE,
 	GSM_PCHAN_CCCH,
@@ -56,15 +48,15 @@
 	GSM_CHREQ_REASON_OTHER,
 };
 
-#include <openbsc/timer.h>
+#include <osmocore/timer.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/mncc.h>
-#include <openbsc/tlv.h>
-#include <openbsc/bitvec.h>
-#include <openbsc/statistics.h>
-
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#include <osmocore/tlv.h>
+#include <osmocore/bitvec.h>
+#include <osmocore/statistics.h>
+#include <osmocore/gsm_utils.h>
+#include <osmocore/utils.h>
 
 #define TRX_NR_TS	8
 #define TS_MAX_LCHAN	8
diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index c639f40..0653996 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -3,7 +3,7 @@
 
 #include <sys/types.h>
 #include "gsm_data.h"
-#include "linuxlist.h"
+#include <osmocore/linuxlist.h>
 
 #define GSM_IMEI_LENGTH 17
 #define GSM_IMSI_LENGTH 17
diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h
index e101428..904a962 100644
--- a/openbsc/include/openbsc/ipaccess.h
+++ b/openbsc/include/openbsc/ipaccess.h
@@ -2,7 +2,7 @@
 #define _IPACCESS_H
 
 #include "e1_input.h"
-#include "linuxlist.h"
+#include <osmocore/linuxlist.h>
 
 #define IPA_TCP_PORT_OML	3002
 #define IPA_TCP_PORT_RSL	3003
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 5b4aa3e..2416fad 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -24,7 +24,7 @@
 #ifndef OPENBSC_MGCP_H
 #define OPENBSC_MGCP_H
 
-#include "msgb.h"
+#include <osmocore/msgb.h>
 
 #define RTP_PORT_DEFAULT 4000
 extern unsigned int rtp_base_port;
diff --git a/openbsc/include/openbsc/mncc.h b/openbsc/include/openbsc/mncc.h
index fbf3cab..06d5942 100644
--- a/openbsc/include/openbsc/mncc.h
+++ b/openbsc/include/openbsc/mncc.h
@@ -25,7 +25,7 @@
 #ifndef _MNCC_H
 #define _MNCC_H
 
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 
 /* One end of a call */
 struct gsm_call {
diff --git a/openbsc/include/openbsc/paging.h b/openbsc/include/openbsc/paging.h
index ab6a274..6cbdca9 100644
--- a/openbsc/include/openbsc/paging.h
+++ b/openbsc/include/openbsc/paging.h
@@ -24,10 +24,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "linuxlist.h"
+#include <osmocore/linuxlist.h>
 #include "gsm_data.h"
 #include "gsm_subscriber.h"
-#include "timer.h"
+#include <osmocore/timer.h>
 
 /* call once for every gsm_bts... */
 void paging_init(struct gsm_bts *bts);
diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h
index d128e4f..f82711a 100644
--- a/openbsc/include/openbsc/rtp_proxy.h
+++ b/openbsc/include/openbsc/rtp_proxy.h
@@ -25,8 +25,8 @@
 
 #include <netinet/in.h>
 
-#include <openbsc/linuxlist.h>
-#include <openbsc/select.h>
+#include <osmocore/linuxlist.h>
+#include <osmocore/select.h>
 
 enum rtp_rx_action {
 	RTP_NONE,
diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h
index 07b4e39..0c22869 100644
--- a/openbsc/include/openbsc/signal.h
+++ b/openbsc/include/openbsc/signal.h
@@ -28,6 +28,7 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
 
+#include <osmocore/signal.h>
 
 /*
  * Signalling subsystems
@@ -110,9 +111,6 @@
 	S_GLOBAL_SHUTDOWN,
 };
 
-typedef int signal_cbfn(unsigned int subsys, unsigned int signal,
-			void *handler_data, void *signal_data);
-
 struct paging_signal_data {
 	struct gsm_subscriber *subscr;
 	struct gsm_bts *bts;
@@ -132,12 +130,4 @@
 	u_int8_t msg_type;	
 };
 
-/* Management */
-int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
-void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
-
-/* Dispatch */
-void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data);
-
-
 #endif
diff --git a/openbsc/include/openbsc/subchan_demux.h b/openbsc/include/openbsc/subchan_demux.h
index 9661b04..02fa023 100644
--- a/openbsc/include/openbsc/subchan_demux.h
+++ b/openbsc/include/openbsc/subchan_demux.h
@@ -22,7 +22,7 @@
  */
 
 #include <sys/types.h>
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 
 #define NR_SUBCH	4
 #define TRAU_FRAME_SIZE	40
diff --git a/openbsc/include/openbsc/telnet_interface.h b/openbsc/include/openbsc/telnet_interface.h
index 8e0e910..20e794b 100644
--- a/openbsc/include/openbsc/telnet_interface.h
+++ b/openbsc/include/openbsc/telnet_interface.h
@@ -23,7 +23,7 @@
 
 #include "gsm_data.h"
 #include "debug.h"
-#include "select.h"
+#include <osmocore/select.h>
 
 #include <vty/vty.h>
 
diff --git a/openbsc/include/openbsc/transaction.h b/openbsc/include/openbsc/transaction.h
index cf94100..50c3cc5 100644
--- a/openbsc/include/openbsc/transaction.h
+++ b/openbsc/include/openbsc/transaction.h
@@ -3,7 +3,7 @@
 
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/gsm_04_11.h>
 
 /* One transaction */
diff --git a/openbsc/include/openbsc/ussd.h b/openbsc/include/openbsc/ussd.h
index e7bd6d6..63ea31c 100644
--- a/openbsc/include/openbsc/ussd.h
+++ b/openbsc/include/openbsc/ussd.h
@@ -3,7 +3,7 @@
 
 /* Handler function for mobile-originated USSD messages */
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 
 int handle_rcv_ussd(struct msgb *msg);
 
diff --git a/openbsc/liblaf0rge1.pc.in b/openbsc/liblaf0rge1.pc.in
deleted file mode 100644
index 9539101..0000000
--- a/openbsc/liblaf0rge1.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: LaF0rge Lib
-Description: C Utility Library
-Version: @VERSION@
-Libs: -L${libdir} -llaf0rge1
-Cflags: -I${includedir}/
-
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index ba3d280..2edaf00 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -7,43 +7,43 @@
 noinst_HEADERS = vty/cardshell.h
 
 bscdir = $(libdir)
-bsc_LIBRARIES = liblaf0rge1.a libsccp.a
-
-liblaf0rge1_a_SOURCES = msgb.c timer.c talloc.c select.c signal.c debug.c
+bsc_LIBRARIES = libsccp.a
 
 libbsc_a_SOURCES = abis_rsl.c abis_nm.c gsm_data.c gsm_04_08_utils.c \
-		chan_alloc.c \
+		chan_alloc.c debug.c \
 		gsm_subscriber_base.c subchan_demux.c bsc_rll.c transaction.c \
-		trau_frame.c trau_mux.c paging.c e1_config.c e1_input.c tlv_parser.c \
-		input/misdn.c input/ipaccess.c signal.c gsm_utils.c \
-		talloc_ctx.c system_information.c bitvec.c rest_octets.c \
-		rtp_proxy.c statistics.c bts_siemens_bs11.c bts_ipaccess_nanobts.c \
+		trau_frame.c trau_mux.c paging.c e1_config.c e1_input.c \
+		input/misdn.c input/ipaccess.c \
+		talloc_ctx.c system_information.c rest_octets.c \
+		rtp_proxy.c bts_siemens_bs11.c bts_ipaccess_nanobts.c \
 		bts_unknown.c
 
 libmsc_a_SOURCES = gsm_subscriber.c db.c telnet_interface.c \
 		mncc.c gsm_04_08.c gsm_04_11.c transaction.c \
 		token_auth.c rrlp.c gsm_04_80.c ussd.c silent_call.c \
-		handover_logic.c handover_decision.c meas_rep.c comp128.c
+		handover_logic.c handover_decision.c meas_rep.c
 
 libvty_a_SOURCES = vty/buffer.c vty/command.c vty/vector.c vty/vty.c
 
 libsccp_a_SOURCES = sccp/sccp.c
 
 bsc_hack_SOURCES = bsc_hack.c bsc_init.c vty_interface.c vty_interface_layer3.c
-bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a liblaf0rge1.a -ldl -ldbi $(LIBCRYPT)
+bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -losmocore -ldl -ldbi $(LIBCRYPT)
 
-bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c msgb.c debug.c \
-		      select.c timer.c rs232.c tlv_parser.c signal.c talloc.c \
-		      bts_siemens_bs11.c
+bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c debug.c \
+		      rs232.c bts_siemens_bs11.c
+bs11_config_LDADD = -losmocore
 
-ipaccess_find_SOURCES = ipaccess/ipaccess-find.c select.c timer.c
+ipaccess_find_SOURCES = ipaccess/ipaccess-find.c
+ipaccess_find_LDADD = -losmocore
 
 ipaccess_config_SOURCES = ipaccess/ipaccess-config.c ipaccess/ipaccess-firmware.c
-ipaccess_config_LDADD = libbsc.a libmsc.a libbsc.a libvty.a liblaf0rge1.a -ldl -ldbi $(LIBCRYPT)
+ipaccess_config_LDADD = libbsc.a libmsc.a libbsc.a libvty.a -losmocore -ldl -ldbi $(LIBCRYPT)
 
 isdnsync_SOURCES = isdnsync.c
 
-bsc_mgcp_SOURCES = mgcp/mgcp_main.c mgcp/mgcp_protocol.c msgb.c talloc.c debug.c select.c timer.c telnet_interface.c
-bsc_mgcp_LDADD = libvty.a liblaf0rge1.a
+bsc_mgcp_SOURCES = mgcp/mgcp_main.c mgcp/mgcp_protocol.c debug.c telnet_interface.c
+bsc_mgcp_LDADD = libvty.a -losmocore
 
-ipaccess_proxy_SOURCES = ipaccess/ipaccess-proxy.c msgb.c select.c talloc.c debug.c timer.c
+ipaccess_proxy_SOURCES = ipaccess/ipaccess-proxy.c debug.c
+ipaccess_proxy_LDADD = -losmocore
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index 82d7b02..99d8dd6 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -38,12 +38,12 @@
 
 #include <openbsc/gsm_data.h>
 #include <openbsc/debug.h>
-#include <openbsc/msgb.h>
-#include <openbsc/tlv.h>
+#include <osmocore/msgb.h>
+#include <osmocore/tlv.h>
+#include <osmocore/talloc.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/misdn.h>
 #include <openbsc/signal.h>
-#include <openbsc/talloc.h>
 
 #define OM_ALLOC_SIZE		1024
 #define OM_HEADROOM_SIZE	128
diff --git a/openbsc/src/abis_rsl.c b/openbsc/src/abis_rsl.c
index 10ebd6d..aebd02c 100644
--- a/openbsc/src/abis_rsl.c
+++ b/openbsc/src/abis_rsl.c
@@ -30,12 +30,12 @@
 
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_04_08.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/chan_alloc.h>
 #include <openbsc/bsc_rll.h>
 #include <openbsc/debug.h>
-#include <openbsc/tlv.h>
+#include <osmocore/tlv.h>
 #include <openbsc/paging.h>
 #include <openbsc/signal.h>
 #include <openbsc/meas_rep.h>
diff --git a/openbsc/src/bs11_config.c b/openbsc/src/bs11_config.c
index 703591e..80f9ba9 100644
--- a/openbsc/src/bs11_config.c
+++ b/openbsc/src/bs11_config.c
@@ -36,10 +36,10 @@
 
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/msgb.h>
-#include <openbsc/tlv.h>
+#include <osmocore/msgb.h>
+#include <osmocore/tlv.h>
 #include <openbsc/debug.h>
-#include <openbsc/select.h>
+#include <osmocore/select.h>
 #include <openbsc/rs232.h>
 
 /* state of our bs11_config application */
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index 7755726..49c9d36 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -31,10 +31,10 @@
 #include <getopt.h>
 
 #include <openbsc/db.h>
-#include <openbsc/select.h>
+#include <osmocore/select.h>
 #include <openbsc/debug.h>
 #include <openbsc/e1_input.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/signal.h>
 
 /* MCC and MNC for the Location Area Identifier */
diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c
index 617d4ae..57fc4b3 100644
--- a/openbsc/src/bsc_init.c
+++ b/openbsc/src/bsc_init.c
@@ -21,7 +21,7 @@
  */
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/abis_nm.h>
@@ -31,7 +31,7 @@
 #include <openbsc/system_information.h>
 #include <openbsc/paging.h>
 #include <openbsc/signal.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 /* global pointer to the gsm network data structure */
 extern struct gsm_network *bsc_gsmnet;
diff --git a/openbsc/src/bsc_rll.c b/openbsc/src/bsc_rll.c
index 780a84e..e9d6f25 100644
--- a/openbsc/src/bsc_rll.c
+++ b/openbsc/src/bsc_rll.c
@@ -24,9 +24,9 @@
 #include <errno.h>
 
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
-#include <openbsc/timer.h>
-#include <openbsc/linuxlist.h>
+#include <osmocore/talloc.h>
+#include <osmocore/timer.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/bsc_rll.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/chan_alloc.h>
diff --git a/openbsc/src/bts_ipaccess_nanobts.c b/openbsc/src/bts_ipaccess_nanobts.c
index 6765517..cb48ea9 100644
--- a/openbsc/src/bts_ipaccess_nanobts.c
+++ b/openbsc/src/bts_ipaccess_nanobts.c
@@ -23,7 +23,7 @@
 #include <sys/types.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/tlv.h>
+#include <osmocore/tlv.h>
 #include <openbsc/abis_nm.h>
 
 static struct gsm_bts_model model_nanobts = {
diff --git a/openbsc/src/bts_siemens_bs11.c b/openbsc/src/bts_siemens_bs11.c
index 1c8f889..c966825 100644
--- a/openbsc/src/bts_siemens_bs11.c
+++ b/openbsc/src/bts_siemens_bs11.c
@@ -23,7 +23,7 @@
 #include <sys/types.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/tlv.h>
+#include <osmocore/tlv.h>
 #include <openbsc/abis_nm.h>
 
 static struct gsm_bts_model model_bs11 = {
diff --git a/openbsc/src/bts_unknown.c b/openbsc/src/bts_unknown.c
index 1e604a9..aac5d99 100644
--- a/openbsc/src/bts_unknown.c
+++ b/openbsc/src/bts_unknown.c
@@ -23,7 +23,7 @@
 #include <sys/types.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/tlv.h>
+#include <osmocore/tlv.h>
 #include <openbsc/abis_nm.h>
 
 static struct gsm_bts_model model_unknown = {
diff --git a/openbsc/src/db.c b/openbsc/src/db.c
index 5be47ff..10c1d6d 100644
--- a/openbsc/src/db.c
+++ b/openbsc/src/db.c
@@ -23,9 +23,9 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_04_11.h>
 #include <openbsc/db.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/debug.h>
-#include <openbsc/statistics.h>
+#include <osmocore/statistics.h>
 
 #include <libgen.h>
 #include <stdio.h>
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index 90a9fc7..7488cd6 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
 
diff --git a/openbsc/src/e1_config.c b/openbsc/src/e1_config.c
index 6a2abd8..50fbcec 100644
--- a/openbsc/src/e1_config.c
+++ b/openbsc/src/e1_config.c
@@ -9,7 +9,7 @@
 #include <openbsc/trau_mux.h>
 #include <openbsc/misdn.h>
 #include <openbsc/ipaccess.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/debug.h>
 
 #define SAPI_L2ML	0
diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c
index c894fe4..c20359c 100644
--- a/openbsc/src/e1_input.c
+++ b/openbsc/src/e1_input.c
@@ -40,18 +40,18 @@
 #define PF_ISDN AF_ISDN
 #endif
 
-#include <openbsc/select.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_rsl.h>
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/subchan_demux.h>
 #include <openbsc/trau_frame.h>
 #include <openbsc/trau_mux.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/signal.h>
 #include <openbsc/misdn.h>
 
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index 61eba2c..3aebd7f 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -31,12 +31,12 @@
 #include <netinet/in.h>
 
 #include <openbsc/db.h>
-#include <openbsc/msgb.h>
-#include <openbsc/bitvec.h>
-#include <openbsc/tlv.h>
+#include <osmocore/msgb.h>
+#include <osmocore/bitvec.h>
+#include <osmocore/tlv.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/gsm_04_11.h>
 #include <openbsc/gsm_04_08.h>
@@ -47,7 +47,7 @@
 #include <openbsc/trau_frame.h>
 #include <openbsc/trau_mux.h>
 #include <openbsc/rtp_proxy.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/transaction.h>
 #include <openbsc/ussd.h>
 #include <openbsc/silent_call.h>
diff --git a/openbsc/src/gsm_04_08_utils.c b/openbsc/src/gsm_04_08_utils.c
index 821bde2..53c57ca 100644
--- a/openbsc/src/gsm_04_08_utils.c
+++ b/openbsc/src/gsm_04_08_utils.c
@@ -28,7 +28,7 @@
 #include <errno.h>
 #include <netinet/in.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/transaction.h>
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index 7f570b8..f03c666 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -31,18 +31,18 @@
 #include <time.h>
 #include <netinet/in.h>
 
-#include <openbsc/msgb.h>
-#include <openbsc/tlv.h>
+#include <osmocore/msgb.h>
+#include <osmocore/tlv.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/gsm_04_11.h>
 #include <openbsc/gsm_04_08.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/signal.h>
 #include <openbsc/db.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/transaction.h>
 #include <openbsc/paging.h>
 #include <openbsc/bsc_rll.h>
diff --git a/openbsc/src/gsm_04_80.c b/openbsc/src/gsm_04_80.c
index d3b472f..8271274 100644
--- a/openbsc/src/gsm_04_80.c
+++ b/openbsc/src/gsm_04_80.c
@@ -29,11 +29,11 @@
 #include <string.h>
 #include <errno.h>
 
-#include <openbsc/msgb.h>
-#include <openbsc/tlv.h>
+#include <osmocore/msgb.h>
+#include <osmocore/tlv.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/gsm_04_80.h>
 
diff --git a/openbsc/src/gsm_data.c b/openbsc/src/gsm_data.c
index 1f2e1a1..a6b060c 100644
--- a/openbsc/src/gsm_data.c
+++ b/openbsc/src/gsm_data.c
@@ -26,9 +26,9 @@
 #include <ctype.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/statistics.h>
+#include <osmocore/statistics.h>
 
 void *tall_bsc_ctx;
 
@@ -438,8 +438,14 @@
 char *gsm_band_name(enum gsm_band band)
 {
 	switch (band) {
-	case GSM_BAND_400:
-		return "GSM400";
+	case GSM_BAND_450:
+		return "GSM450";
+	case GSM_BAND_480:
+		return "GSM450";
+	case GSM_BAND_750:
+		return "GSM750";
+	case GSM_BAND_810:
+		return "GSM810";
 	case GSM_BAND_850:
 		return "GSM850";
 	case GSM_BAND_900:
@@ -461,8 +467,14 @@
 		return -EINVAL;
 
 	switch (atoi(mhz)) {
-	case 400:
-		return GSM_BAND_400;
+	case 450:
+		return GSM_BAND_450;
+	case 480:
+		return GSM_BAND_480;
+	case 750:
+		return GSM_BAND_750;
+	case 810:
+		return GSM_BAND_810;
 	case 850:
 		return GSM_BAND_850;
 	case 900:
diff --git a/openbsc/src/gsm_subscriber_base.c b/openbsc/src/gsm_subscriber_base.c
index 0570061..dee89c0 100644
--- a/openbsc/src/gsm_subscriber_base.c
+++ b/openbsc/src/gsm_subscriber_base.c
@@ -27,11 +27,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/paging.h>
 #include <openbsc/debug.h>
-#include <openbsc/paging.h>
 
 LLIST_HEAD(active_subscribers);
 void *tall_subscr_ctx;
diff --git a/openbsc/src/handover_decision.c b/openbsc/src/handover_decision.c
index b37cecd..efafca6 100644
--- a/openbsc/src/handover_decision.c
+++ b/openbsc/src/handover_decision.c
@@ -25,14 +25,14 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/meas_rep.h>
 #include <openbsc/signal.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/handover.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 
 /* issue handover to a cell identified by ARFCN and BSIC */
 static int handover_to_arfcn_bsic(struct gsm_lchan *lchan,
diff --git a/openbsc/src/handover_logic.c b/openbsc/src/handover_logic.c
index 1bf048f..bd4c563 100644
--- a/openbsc/src/handover_logic.c
+++ b/openbsc/src/handover_logic.c
@@ -29,16 +29,16 @@
 #include <time.h>
 #include <netinet/in.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/chan_alloc.h>
 #include <openbsc/signal.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/transaction.h>
 #include <openbsc/rtp_proxy.h>
 
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c
index 73d798f..943a5e8 100644
--- a/openbsc/src/input/ipaccess.c
+++ b/openbsc/src/input/ipaccess.c
@@ -32,9 +32,9 @@
 #include <sys/ioctl.h>
 #include <arpa/inet.h>
 
-#include <openbsc/select.h>
-#include <openbsc/tlv.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/tlv.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
@@ -42,7 +42,7 @@
 #include <openbsc/subchan_demux.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/ipaccess.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 /* data structure for one E1 interface with A-bis */
 struct ia_e1_handle {
diff --git a/openbsc/src/input/misdn.c b/openbsc/src/input/misdn.c
index 135cfad..56930d4 100644
--- a/openbsc/src/input/misdn.c
+++ b/openbsc/src/input/misdn.c
@@ -41,15 +41,15 @@
 #define PF_ISDN AF_ISDN
 #endif
 
-#include <openbsc/select.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/subchan_demux.h>
 #include <openbsc/e1_input.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 #define TS1_ALLOC_SIZE	300
 
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 7d559b0..037ed60 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
+#include <errno.h>
 #include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -35,15 +36,15 @@
 #include <arpa/inet.h>
 
 
-#include <openbsc/select.h>
-#include <openbsc/timer.h>
+#include <osmocore/select.h>
+#include <osmocore/timer.h>
 #include <openbsc/ipaccess.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/abis_nm.h>
 #include <openbsc/signal.h>
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 static struct gsm_network *gsmnet;
 
diff --git a/openbsc/src/ipaccess/ipaccess-find.c b/openbsc/src/ipaccess/ipaccess-find.c
index f469b67..01f8a2d 100644
--- a/openbsc/src/ipaccess/ipaccess-find.c
+++ b/openbsc/src/ipaccess/ipaccess-find.c
@@ -8,8 +8,8 @@
 #include <arpa/inet.h>
 
 
-#include <openbsc/select.h>
-#include <openbsc/timer.h>
+#include <osmocore/select.h>
+#include <osmocore/timer.h>
 #include <openbsc/ipaccess.h>
 #include <openbsc/gsm_data.h>
 
diff --git a/openbsc/src/ipaccess/ipaccess-firmware.c b/openbsc/src/ipaccess/ipaccess-firmware.c
index ed4bc9a..8aba509 100644
--- a/openbsc/src/ipaccess/ipaccess-firmware.c
+++ b/openbsc/src/ipaccess/ipaccess-firmware.c
@@ -21,7 +21,7 @@
 
 #include <openbsc/debug.h>
 #include <openbsc/ipaccess.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/openbsc/src/ipaccess/ipaccess-proxy.c b/openbsc/src/ipaccess/ipaccess-proxy.c
index d018b6e..217e0bd 100644
--- a/openbsc/src/ipaccess/ipaccess-proxy.c
+++ b/openbsc/src/ipaccess/ipaccess-proxy.c
@@ -35,12 +35,12 @@
 #include <netinet/in.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/select.h>
-#include <openbsc/tlv.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/tlv.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/ipaccess.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 static struct debug_target *stderr_target;
 
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index 7d318b1..b8d892b 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -34,10 +34,10 @@
 #include <arpa/inet.h>
 
 #include <openbsc/debug.h>
-#include <openbsc/msgb.h>
-#include <openbsc/talloc.h>
+#include <osmocore/msgb.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/select.h>
+#include <osmocore/select.h>
 #include <openbsc/mgcp.h>
 #include <openbsc/telnet_interface.h>
 
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index 53573f3..1549202 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -34,10 +34,10 @@
 #include <arpa/inet.h>
 
 #include <openbsc/debug.h>
-#include <openbsc/msgb.h>
-#include <openbsc/talloc.h>
+#include <osmocore/msgb.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/select.h>
+#include <osmocore/select.h>
 #include <openbsc/mgcp.h>
 #include <openbsc/telnet_interface.h>
 
diff --git a/openbsc/src/mncc.c b/openbsc/src/mncc.c
index 15e2978..01d59aa 100644
--- a/openbsc/src/mncc.c
+++ b/openbsc/src/mncc.c
@@ -28,7 +28,7 @@
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/debug.h>
 #include <openbsc/mncc.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/transaction.h>
 #include <openbsc/rtp_proxy.h>
diff --git a/openbsc/src/paging.c b/openbsc/src/paging.c
index 91de702..7c3750d 100644
--- a/openbsc/src/paging.c
+++ b/openbsc/src/paging.c
@@ -40,7 +40,7 @@
 #include <assert.h>
 
 #include <openbsc/paging.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/debug.h>
 #include <openbsc/signal.h>
 #include <openbsc/abis_rsl.h>
diff --git a/openbsc/src/rest_octets.c b/openbsc/src/rest_octets.c
index 74874bd..a57e7df 100644
--- a/openbsc/src/rest_octets.c
+++ b/openbsc/src/rest_octets.c
@@ -27,7 +27,7 @@
 #include <errno.h>
 
 #include <openbsc/gsm_data.h>
-#include <openbsc/bitvec.h>
+#include <osmocore/bitvec.h>
 #include <openbsc/rest_octets.h>
 
 /* generate SI1 rest octets */
diff --git a/openbsc/src/rs232.c b/openbsc/src/rs232.c
index a584723..36af59c 100644
--- a/openbsc/src/rs232.c
+++ b/openbsc/src/rs232.c
@@ -28,8 +28,8 @@
 #include <termios.h>
 #include <fcntl.h>
 
-#include <openbsc/select.h>
-#include <openbsc/msgb.h>
+#include <osmocore/select.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/rs232.h>
diff --git a/openbsc/src/rtp_proxy.c b/openbsc/src/rtp_proxy.c
index 83b774f..9b1f4d9 100644
--- a/openbsc/src/rtp_proxy.c
+++ b/openbsc/src/rtp_proxy.c
@@ -29,10 +29,10 @@
 #include <time.h>        /* clock() */
 #include <sys/utsname.h> /* uname() */
 
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
-#include <openbsc/msgb.h>
-#include <openbsc/select.h>
+#include <osmocore/msgb.h>
+#include <osmocore/select.h>
 #include <openbsc/debug.h>
 #include <openbsc/rtp_proxy.h>
 
diff --git a/openbsc/src/sccp/sccp.c b/openbsc/src/sccp/sccp.c
index b0de239..9cd7c9c 100644
--- a/openbsc/src/sccp/sccp.c
+++ b/openbsc/src/sccp/sccp.c
@@ -24,9 +24,9 @@
 
 #include <string.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 #include <sccp/sccp.h>
 
diff --git a/openbsc/src/silent_call.c b/openbsc/src/silent_call.c
index a0c166e..cada24e 100644
--- a/openbsc/src/silent_call.c
+++ b/openbsc/src/silent_call.c
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/signal.h>
 #include <openbsc/debug.h>
 #include <openbsc/paging.h>
diff --git a/openbsc/src/subchan_demux.c b/openbsc/src/subchan_demux.c
index 63be533..0d6c1fe 100644
--- a/openbsc/src/subchan_demux.c
+++ b/openbsc/src/subchan_demux.c
@@ -28,7 +28,7 @@
 #include <openbsc/subchan_demux.h>
 #include <openbsc/trau_frame.h>
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
 
 void *tall_tqe_ctx;
diff --git a/openbsc/src/system_information.c b/openbsc/src/system_information.c
index 9bdf2c1..36dc6b9 100644
--- a/openbsc/src/system_information.c
+++ b/openbsc/src/system_information.c
@@ -31,7 +31,7 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/rest_octets.h>
-#include <openbsc/bitvec.h>
+#include <osmocore/bitvec.h>
 #include <openbsc/debug.h>
 
 #define GSM48_CELL_CHAN_DESC_SIZE	16
diff --git a/openbsc/src/talloc_ctx.c b/openbsc/src/talloc_ctx.c
index 5f0ee4d..6379e13 100644
--- a/openbsc/src/talloc_ctx.c
+++ b/openbsc/src/talloc_ctx.c
@@ -1,4 +1,4 @@
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_data.h>
 
 extern void *tall_msgb_ctx;
diff --git a/openbsc/src/telnet_interface.c b/openbsc/src/telnet_interface.c
index 6f452a5..805dd12 100644
--- a/openbsc/src/telnet_interface.c
+++ b/openbsc/src/telnet_interface.c
@@ -30,11 +30,11 @@
 #include <openbsc/chan_alloc.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/gsm_04_11.h>
-#include <openbsc/msgb.h>
+#include <osmocore/msgb.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/paging.h>
 #include <openbsc/signal.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/debug.h>
 
 #include <vty/buffer.h>
diff --git a/openbsc/src/token_auth.c b/openbsc/src/token_auth.c
index fd81f03..7fefea5 100644
--- a/openbsc/src/token_auth.c
+++ b/openbsc/src/token_auth.c
@@ -21,7 +21,7 @@
  */
 
 #include <stdio.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/signal.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_04_11.h>
diff --git a/openbsc/src/transaction.c b/openbsc/src/transaction.c
index c972037..75a279d 100644
--- a/openbsc/src/transaction.c
+++ b/openbsc/src/transaction.c
@@ -23,7 +23,7 @@
 #include <openbsc/gsm_data.h>
 #include <openbsc/mncc.h>
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/gsm_04_08.h>
 #include <openbsc/mncc.h>
diff --git a/openbsc/src/trau_mux.c b/openbsc/src/trau_mux.c
index 9930751..f2fa5c0 100644
--- a/openbsc/src/trau_mux.c
+++ b/openbsc/src/trau_mux.c
@@ -30,7 +30,7 @@
 #include <openbsc/subchan_demux.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/debug.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 u_int8_t gsm_fr_map[] = {
 	6, 6, 5, 5, 4, 4, 3, 3,
diff --git a/openbsc/src/vty/buffer.c b/openbsc/src/vty/buffer.c
index 8ab7311..195d062 100644
--- a/openbsc/src/vty/buffer.c
+++ b/openbsc/src/vty/buffer.c
@@ -28,7 +28,7 @@
 #include <stddef.h>
 #include <sys/uio.h>
 
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <vty/buffer.h>
 #include <vty/vty.h>
 
diff --git a/openbsc/src/vty/command.c b/openbsc/src/vty/command.c
index 5b1dcb9..2faed35 100644
--- a/openbsc/src/vty/command.c
+++ b/openbsc/src/vty/command.c
@@ -47,7 +47,7 @@
 
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 void *tall_vty_cmd_ctx;
 
diff --git a/openbsc/src/vty/vector.c b/openbsc/src/vty/vector.c
index 06e1aaa..db47ae5 100644
--- a/openbsc/src/vty/vector.c
+++ b/openbsc/src/vty/vector.c
@@ -24,7 +24,7 @@
 
 #include <vty/vector.h>
 #include <vty/vty.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <memory.h>
 
 void *tall_vty_vec_ctx;
diff --git a/openbsc/src/vty/vty.c b/openbsc/src/vty/vty.c
index 2339bbd..1260f38 100644
--- a/openbsc/src/vty/vty.c
+++ b/openbsc/src/vty/vty.c
@@ -17,7 +17,7 @@
 #include <vty/vty.h>
 #include <vty/command.h>
 #include <vty/buffer.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 
 /* our callback, located in telnet_interface.c */
 void vty_event(enum event event, int sock, struct vty *vty);
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c
index 76598d3..dc70e98 100644
--- a/openbsc/src/vty_interface.c
+++ b/openbsc/src/vty_interface.c
@@ -28,15 +28,15 @@
 
 #include <arpa/inet.h>
 
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/chan_alloc.h>
 #include <openbsc/meas_rep.h>
 #include <openbsc/db.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/telnet_interface.h>
 
 static struct gsm_network *gsmnet;
diff --git a/openbsc/src/vty_interface_layer3.c b/openbsc/src/vty_interface_layer3.c
index f2b5728..b824c3d 100644
--- a/openbsc/src/vty_interface_layer3.c
+++ b/openbsc/src/vty_interface_layer3.c
@@ -29,16 +29,16 @@
 
 #include <arpa/inet.h>
 
-#include <openbsc/linuxlist.h>
+#include <osmocore/linuxlist.h>
 #include <openbsc/gsm_data.h>
 #include <openbsc/gsm_subscriber.h>
 #include <openbsc/silent_call.h>
 #include <openbsc/gsm_04_11.h>
 #include <openbsc/e1_input.h>
 #include <openbsc/abis_nm.h>
-#include <openbsc/gsm_utils.h>
+#include <osmocore/gsm_utils.h>
 #include <openbsc/db.h>
-#include <openbsc/talloc.h>
+#include <osmocore/talloc.h>
 #include <openbsc/signal.h>
 #include <openbsc/debug.h>