summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-04-26 00:28:18 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2011-04-26 00:28:18 +0200
commitf0059596a20bfa406a500ca5d6b34bf88d333ed3 (patch)
tree41bc483077171529e20084ede0784dd6af076056
parentd9639bb010d05a96a6cbced94668c5754a4f0de9 (diff)
parent28dbfe9bf7a799ab1da2563fd5e007d007b54168 (diff)
Merge commit '28dbfe9bf7a799ab1da2563fd5e007d007b54168'
-rw-r--r--src/shared/libosmocore/Makefile.am2
-rw-r--r--src/shared/libosmocore/configure.in9
-rw-r--r--src/shared/libosmocore/debian/changelog6
-rw-r--r--src/shared/libosmocore/debian/control4
-rwxr-xr-xsrc/shared/libosmocore/debian/rules2
-rw-r--r--src/shared/libosmocore/debian/source/format2
-rw-r--r--src/shared/libosmocore/include/Makefile.am2
-rw-r--r--src/shared/libosmocore/include/osmocom/Makefile.am4
-rw-r--r--src/shared/libosmocore/include/osmocom/core/Makefile.am12
-rw-r--r--src/shared/libosmocore/include/osmocom/core/backtrace.h6
-rw-r--r--src/shared/libosmocore/include/osmocom/core/bits.h45
-rw-r--r--src/shared/libosmocore/include/osmocom/core/bitvec.h (renamed from src/shared/libosmocore/include/osmocore/bitvec.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/crc16.h (renamed from src/shared/libosmocore/include/osmocore/crc16.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/gsmtap.h (renamed from src/shared/libosmocore/include/osmocore/gsmtap.h)16
-rw-r--r--src/shared/libosmocore/include/osmocom/core/gsmtap_util.h (renamed from src/shared/libosmocore/include/osmocore/gsmtap_util.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/linuxlist.h (renamed from src/shared/libosmocore/include/osmocore/linuxlist.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/logging.h (renamed from src/shared/libosmocore/include/osmocore/logging.h)27
-rw-r--r--src/shared/libosmocore/include/osmocom/core/msgb.h (renamed from src/shared/libosmocore/include/osmocore/msgb.h)7
-rw-r--r--src/shared/libosmocore/include/osmocom/core/msgfile.h (renamed from src/shared/libosmocore/include/osmocore/msgfile.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/panic.h (renamed from src/shared/libosmocore/include/osmocore/panic.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/plugin.h (renamed from src/shared/libosmocore/include/osmocore/plugin.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/process.h (renamed from src/shared/libosmocore/include/osmocore/process.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/rate_ctr.h (renamed from src/shared/libosmocore/include/osmocore/rate_ctr.h)7
-rw-r--r--src/shared/libosmocore/include/osmocom/core/select.h (renamed from src/shared/libosmocore/include/osmocore/select.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/signal.h (renamed from src/shared/libosmocore/include/osmocore/signal.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/statistics.h (renamed from src/shared/libosmocore/include/osmocore/statistics.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/talloc.h (renamed from src/shared/libosmocore/include/osmocore/talloc.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/core/timer.h (renamed from src/shared/libosmocore/include/osmocore/timer.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/utils.h (renamed from src/shared/libosmocore/include/osmocore/utils.h)15
-rw-r--r--src/shared/libosmocore/include/osmocom/core/write_queue.h (renamed from src/shared/libosmocore/include/osmocore/write_queue.h)4
-rw-r--r--src/shared/libosmocore/include/osmocom/crypt/gprs_cipher.h2
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/Makefile.am6
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/comp128.h (renamed from src/shared/libosmocore/include/osmocore/comp128.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/gsm0480.h (renamed from src/shared/libosmocore/include/osmocore/gsm0480.h)6
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/gsm0808.h (renamed from src/shared/libosmocore/include/osmocore/gsm0808.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/gsm48.h (renamed from src/shared/libosmocore/include/osmocore/gsm48.h)6
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/gsm48_ie.h (renamed from src/shared/libosmocore/include/osmocore/gsm48_ie.h)8
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h (renamed from src/shared/libosmocore/include/osmocore/gsm_utils.h)1
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/mncc.h (renamed from src/shared/libosmocore/include/osmocore/mncc.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/Makefile.am6
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_03_41.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_08.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_11.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_04_11.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_12.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_80.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_04_80.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_08.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_08_08.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_08_58.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_12_21.h (renamed from src/shared/libosmocore/include/osmocore/protocol/gsm_12_21.h)2
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/rsl.h (renamed from src/shared/libosmocore/include/osmocore/rsl.h)4
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/rxlev_stat.h (renamed from src/shared/libosmocore/include/osmocore/rxlev_stat.h)0
-rw-r--r--src/shared/libosmocore/include/osmocom/gsm/tlv.h (renamed from src/shared/libosmocore/include/osmocore/tlv.h)17
-rw-r--r--src/shared/libosmocore/include/osmocom/vty/Makefile.am2
-rw-r--r--src/shared/libosmocore/include/osmocom/vty/command.h1
-rw-r--r--src/shared/libosmocore/include/osmocom/vty/logging.h5
-rw-r--r--src/shared/libosmocore/include/osmocom/vty/misc.h10
-rw-r--r--src/shared/libosmocore/include/osmocom/vty/telnet_interface.h4
-rw-r--r--src/shared/libosmocore/include/osmocore/Makefile.am13
-rw-r--r--src/shared/libosmocore/include/osmocore/protocol/Makefile.am6
-rw-r--r--src/shared/libosmocore/libosmogsm.pc.in11
-rw-r--r--src/shared/libosmocore/src/Makefile.am13
-rw-r--r--src/shared/libosmocore/src/backtrace.c50
-rw-r--r--src/shared/libosmocore/src/bits.c98
-rw-r--r--src/shared/libosmocore/src/bitvec.c16
-rw-r--r--src/shared/libosmocore/src/crc16.c2
-rw-r--r--src/shared/libosmocore/src/gsm/Makefile.am13
-rw-r--r--src/shared/libosmocore/src/gsm/comp128.c (renamed from src/shared/libosmocore/src/comp128.c)0
-rw-r--r--src/shared/libosmocore/src/gsm/gprs_cipher_core.c (renamed from src/shared/libosmocore/src/gprs_cipher_core.c)6
-rw-r--r--src/shared/libosmocore/src/gsm/gsm0480.c (renamed from src/shared/libosmocore/src/gsm0480.c)10
-rw-r--r--src/shared/libosmocore/src/gsm/gsm0808.c (renamed from src/shared/libosmocore/src/gsm0808.c)6
-rw-r--r--src/shared/libosmocore/src/gsm/gsm48.c (renamed from src/shared/libosmocore/src/gsm48.c)8
-rw-r--r--src/shared/libosmocore/src/gsm/gsm48_ie.c (renamed from src/shared/libosmocore/src/gsm48_ie.c)12
-rw-r--r--src/shared/libosmocore/src/gsm/gsm_utils.c (renamed from src/shared/libosmocore/src/gsm_utils.c)29
-rw-r--r--src/shared/libosmocore/src/gsm/rsl.c (renamed from src/shared/libosmocore/src/rsl.c)4
-rw-r--r--src/shared/libosmocore/src/gsm/rxlev_stat.c (renamed from src/shared/libosmocore/src/rxlev_stat.c)18
-rw-r--r--src/shared/libosmocore/src/gsm/tlv_parser.c (renamed from src/shared/libosmocore/src/tlv_parser.c)4
-rw-r--r--src/shared/libosmocore/src/gsmtap_util.c14
-rw-r--r--src/shared/libosmocore/src/logging.c169
-rw-r--r--src/shared/libosmocore/src/logging_syslog.c78
-rw-r--r--src/shared/libosmocore/src/msgb.c5
-rw-r--r--src/shared/libosmocore/src/msgfile.c5
-rw-r--r--src/shared/libosmocore/src/panic.c5
-rw-r--r--src/shared/libosmocore/src/plugin.c3
-rw-r--r--src/shared/libosmocore/src/process.c1
-rw-r--r--src/shared/libosmocore/src/rate_ctr.c44
-rw-r--r--src/shared/libosmocore/src/select.c6
-rw-r--r--src/shared/libosmocore/src/signal.c6
-rw-r--r--src/shared/libosmocore/src/statistics.c19
-rw-r--r--src/shared/libosmocore/src/talloc.c3
-rw-r--r--src/shared/libosmocore/src/timer.c2
-rw-r--r--src/shared/libosmocore/src/utils.c54
-rw-r--r--src/shared/libosmocore/src/vty/buffer.c2
-rw-r--r--src/shared/libosmocore/src/vty/command.c6
-rw-r--r--src/shared/libosmocore/src/vty/logging_vty.c422
-rw-r--r--src/shared/libosmocore/src/vty/telnet_interface.c6
-rw-r--r--src/shared/libosmocore/src/vty/utils.c8
-rw-r--r--src/shared/libosmocore/src/vty/vector.c2
-rw-r--r--src/shared/libosmocore/src/vty/vty.c8
-rw-r--r--src/shared/libosmocore/src/write_queue.c20
-rw-r--r--src/shared/libosmocore/tests/msgfile/msgfile_test.c2
-rw-r--r--src/shared/libosmocore/tests/sms/Makefile.am2
-rw-r--r--src/shared/libosmocore/tests/sms/sms_test.c7
-rw-r--r--src/shared/libosmocore/tests/smscb/Makefile.am2
-rw-r--r--src/shared/libosmocore/tests/smscb/smscb_test.c2
-rw-r--r--src/shared/libosmocore/tests/timer/timer_test.c4
-rw-r--r--src/shared/libosmocore/tests/ussd/Makefile.am2
-rw-r--r--src/shared/libosmocore/tests/ussd/ussd_test.c2
106 files changed, 1153 insertions, 337 deletions
diff --git a/src/shared/libosmocore/Makefile.am b/src/shared/libosmocore/Makefile.am
index 93254e8..e391de8 100644
--- a/src/shared/libosmocore/Makefile.am
+++ b/src/shared/libosmocore/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
SUBDIRS = include src tests
pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc
+pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
diff --git a/src/shared/libosmocore/configure.in b/src/shared/libosmocore/configure.in
index 309aa03..ead18f0 100644
--- a/src/shared/libosmocore/configure.in
+++ b/src/shared/libosmocore/configure.in
@@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
dnl checks for header files
AC_HEADER_STDC
-AC_CHECK_HEADERS(execinfo.h sys/select.h)
+AC_CHECK_HEADERS(execinfo.h sys/select.h syslog.h ctype.h)
# The following test is taken from WebKit's webkit.m4
saved_CFLAGS="$CFLAGS"
@@ -101,16 +101,19 @@ AC_OUTPUT(
libosmocore.pc
libosmocodec.pc
libosmovty.pc
+ libosmogsm.pc
include/osmocom/Makefile
include/osmocom/vty/Makefile
include/osmocom/codec/Makefile
include/osmocom/crypt/Makefile
- include/osmocore/Makefile
- include/osmocore/protocol/Makefile
+ include/osmocom/gsm/Makefile
+ include/osmocom/gsm/protocol/Makefile
+ include/osmocom/core/Makefile
include/Makefile
src/Makefile
src/vty/Makefile
src/codec/Makefile
+ src/gsm/Makefile
tests/Makefile
tests/timer/Makefile
tests/sms/Makefile
diff --git a/src/shared/libosmocore/debian/changelog b/src/shared/libosmocore/debian/changelog
index 5783127..4c103cb 100644
--- a/src/shared/libosmocore/debian/changelog
+++ b/src/shared/libosmocore/debian/changelog
@@ -1,3 +1,9 @@
+libosmocore (0.1.27) natty; urgency=low
+
+ * New upstream version of libosmocore.
+
+ -- Holger Hans Peter Freyther <holger@freyther.de> Thu, 13 Jan 2011 18:07:36 +0800
+
libosmocore (0.1.17-1) unstable; urgency=low
* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
diff --git a/src/shared/libosmocore/debian/control b/src/shared/libosmocore/debian/control
index 1348ec3..3f92875 100644
--- a/src/shared/libosmocore/debian/control
+++ b/src/shared/libosmocore/debian/control
@@ -2,7 +2,7 @@ Source: libosmocore
Section: libs
Priority: optional
Maintainer: Harald Welte <laforge@gnumonks.org>
-Build-Depends: debhelper (>= 7.0.50~), autotools-dev
+Build-Depends: debhelper (>= 7.0.50~), autotools-dev, autoconf, automake, libtool, dh-autoreconf
Standards-Version: 3.8.4
Homepage: http://bb.osmocom.org/trac/wiki/libosmocore
Vcs-Git: git://git.osmocom.org/libosmocore.git
@@ -17,7 +17,7 @@ Description: Open Source MObile COMmunications CORE library
Package: libosmocore-dev
Section: libdevel
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, libosmocore
Description: Development headers for Open Source MObile COMmunications CORE library
#Package: libosmocore-dbg
diff --git a/src/shared/libosmocore/debian/rules b/src/shared/libosmocore/debian/rules
index a81850a..15f78f2 100755
--- a/src/shared/libosmocore/debian/rules
+++ b/src/shared/libosmocore/debian/rules
@@ -12,7 +12,7 @@
CFLAGS = -Wall -g
%:
- dh $@
+ dh --with autoreconf $@
#override_dh_strip:
# dh_strip --dbg-package=libosmocore-dbg
diff --git a/src/shared/libosmocore/debian/source/format b/src/shared/libosmocore/debian/source/format
index 163aaf8..af745b3 100644
--- a/src/shared/libosmocore/debian/source/format
+++ b/src/shared/libosmocore/debian/source/format
@@ -1 +1 @@
-3.0 (quilt)
+3.0 (git)
diff --git a/src/shared/libosmocore/include/Makefile.am b/src/shared/libosmocore/include/Makefile.am
index 185c696..3578a80 100644
--- a/src/shared/libosmocore/include/Makefile.am
+++ b/src/shared/libosmocore/include/Makefile.am
@@ -1 +1 @@
-SUBDIRS = osmocom osmocore
+SUBDIRS = osmocom
diff --git a/src/shared/libosmocore/include/osmocom/Makefile.am b/src/shared/libosmocore/include/osmocom/Makefile.am
index ec548fb..21f4f2d 100644
--- a/src/shared/libosmocore/include/osmocom/Makefile.am
+++ b/src/shared/libosmocore/include/osmocom/Makefile.am
@@ -1,5 +1,5 @@
if ENABLE_VTY
-SUBDIRS = vty codec crypt
+SUBDIRS = vty codec crypt gsm core
else
-SUBDIRS = codec crypt
+SUBDIRS = codec crypt gsm core
endif
diff --git a/src/shared/libosmocore/include/osmocom/core/Makefile.am b/src/shared/libosmocore/include/osmocom/core/Makefile.am
new file mode 100644
index 0000000..6109f47
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/Makefile.am
@@ -0,0 +1,12 @@
+osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h bits.h \
+ bitvec.h statistics.h utils.h \
+ gsmtap.h write_queue.h \
+ logging.h rate_ctr.h gsmtap_util.h \
+ plugin.h crc16.h panic.h process.h msgfile.h \
+ backtrace.h
+
+if ENABLE_TALLOC
+osmocore_HEADERS += talloc.h
+endif
+
+osmocoredir = $(includedir)/osmocom/core
diff --git a/src/shared/libosmocore/include/osmocom/core/backtrace.h b/src/shared/libosmocore/include/osmocom/core/backtrace.h
new file mode 100644
index 0000000..bbbb2c2
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/backtrace.h
@@ -0,0 +1,6 @@
+#ifndef _OSMO_BACKTRACE_H_
+#define _OSMO_BACKTRACE_H_
+
+void generate_backtrace();
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/bits.h b/src/shared/libosmocore/include/osmocom/core/bits.h
new file mode 100644
index 0000000..eb22d07
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/bits.h
@@ -0,0 +1,45 @@
+#ifndef _OSMO_BITS_H
+#define _OSMO_BITS_H
+
+#include <stdint.h>
+
+typedef int8_t sbit_t; /* soft bit (-127...127) */
+typedef uint8_t ubit_t; /* unpacked bit (0 or 1) */
+typedef uint8_t pbit_t; /* packed bis (8 bits in a byte) */
+
+/*
+ NOTE on the endianess of pbit_t:
+ Bits in a pbit_t are ordered MSB first, i.e. 0x80 is the first bit.
+ Bit i in a pbit_t array is array[i/8] & (1<<(7-i%8))
+*/
+
+/* determine how many bytes we would need for 'num_bits' packed bits */
+static inline unsigned int osmo_pbit_bytesize(unsigned int num_bits)
+{
+ unsigned int pbit_bytesize = num_bits / 8;
+
+ if (num_bits % 8)
+ pbit_bytesize++;
+
+ return pbit_bytesize;
+}
+
+/* convert unpacked bits to packed bits, return length in bytes */
+int osmo_ubit2pbit(pbit_t *out, const ubit_t *in, unsigned int num_bits);
+
+/* convert packed bits to unpacked bits, return length in bytes */
+int osmo_pbit2ubit(ubit_t *out, const pbit_t *in, unsigned int num_bits);
+
+/* convert unpacked bits to packed bits (extended options but slower),
+ * return length in bytes (max written ofs of output buffer + 1) */
+int osmo_ubit2pbit_ext(pbit_t *out, unsigned int out_ofs,
+ const ubit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode);
+
+/* convert packed bits to unpacked bits (extended options but slower),
+ * return length in bytes (max written ofs of output buffer + 1) */
+int osmo_pbit2ubit_ext(ubit_t *out, unsigned int out_ofs,
+ const pbit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode);
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocore/bitvec.h b/src/shared/libosmocore/include/osmocom/core/bitvec.h
index 42977fb..bbe1641 100644
--- a/src/shared/libosmocore/include/osmocore/bitvec.h
+++ b/src/shared/libosmocore/include/osmocom/core/bitvec.h
@@ -68,6 +68,8 @@ int bitvec_set_uint(struct bitvec *bv, unsigned int in, int count);
/* get multiple bits (based on numeric value) from current pos */
int bitvec_get_uint(struct bitvec *bv, int num_bits);
+/* find the first bit set in bit vector */
+int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val);
/* Pad the bit vector up to a certain bit position */
int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
diff --git a/src/shared/libosmocore/include/osmocore/crc16.h b/src/shared/libosmocore/include/osmocom/core/crc16.h
index 7a51249..7a51249 100644
--- a/src/shared/libosmocore/include/osmocore/crc16.h
+++ b/src/shared/libosmocore/include/osmocom/core/crc16.h
diff --git a/src/shared/libosmocore/include/osmocore/gsmtap.h b/src/shared/libosmocore/include/osmocom/core/gsmtap.h
index 3f384a4..236b25a 100644
--- a/src/shared/libosmocore/include/osmocore/gsmtap.h
+++ b/src/shared/libosmocore/include/osmocom/core/gsmtap.h
@@ -20,7 +20,10 @@
#define GSMTAP_TYPE_ABIS 0x02
#define GSMTAP_TYPE_UM_BURST 0x03 /* raw burst bits */
#define GSMTAP_TYPE_SIM 0x04
+#define GSMTAP_TYPE_TETRA_I1 0x05 /* tetra air interface */
+#define GSMTAP_TYPE_TETRA_I1_BURST 0x06 /* tetra air interface */
+/* sub-types for TYPE_UM_BURST */
#define GSMTAP_BURST_UNKNOWN 0x00
#define GSMTAP_BURST_FCCH 0x01
#define GSMTAP_BURST_PARTIAL_SCH 0x02
@@ -32,6 +35,7 @@
#define GSMTAP_BURST_ACCESS 0x08
#define GSMTAP_BURST_NONE 0x09
+/* sub-types for TYPE_UM */
#define GSMTAP_CHANNEL_UNKNOWN 0x00
#define GSMTAP_CHANNEL_BCCH 0x01
#define GSMTAP_CHANNEL_CCCH 0x02
@@ -45,10 +49,22 @@
#define GSMTAP_CHANNEL_TCH_H 0x0a
#define GSMTAP_CHANNEL_ACCH 0x80
+/* sub-types for TYPE_TETRA_AIR */
+#define GSMTAP_TETRA_BSCH 0x01
+#define GSMTAP_TETRA_AACH 0x02
+#define GSMTAP_TETRA_SCH_HU 0x03
+#define GSMTAP_TETRA_SCH_HD 0x04
+#define GSMTAP_TETRA_SCH_F 0x05
+#define GSMTAP_TETRA_BNCH 0x06
+#define GSMTAP_TETRA_STCH 0x07
+#define GSMTAP_TETRA_TCH_F 0x08
+
+/* flags for the ARFCN */
#define GSMTAP_ARFCN_F_PCS 0x8000
#define GSMTAP_ARFCN_F_UPLINK 0x4000
#define GSMTAP_ARFCN_MASK 0x3fff
+/* IANA-assigned well-known UDP port for GSMTAP messages */
#define GSMTAP_UDP_PORT 4729
struct gsmtap_hdr {
diff --git a/src/shared/libosmocore/include/osmocore/gsmtap_util.h b/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h
index 9644944..9644944 100644
--- a/src/shared/libosmocore/include/osmocore/gsmtap_util.h
+++ b/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h
diff --git a/src/shared/libosmocore/include/osmocore/linuxlist.h b/src/shared/libosmocore/include/osmocom/core/linuxlist.h
index fb99c5e..fb99c5e 100644
--- a/src/shared/libosmocore/include/osmocore/linuxlist.h
+++ b/src/shared/libosmocore/include/osmocom/core/linuxlist.h
diff --git a/src/shared/libosmocore/include/osmocore/logging.h b/src/shared/libosmocore/include/osmocom/core/logging.h
index 7f33155..db02940 100644
--- a/src/shared/libosmocore/include/osmocore/logging.h
+++ b/src/shared/libosmocore/include/osmocom/core/logging.h
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdint.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
#define LOG_MAX_CATEGORY 32
#define LOG_MAX_CTX 8
@@ -19,7 +19,6 @@
#define DEBUGPC(ss, fmt, args...)
#endif
-#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
void logp(unsigned int subsys, char *file, int line, int cont, const char *format, ...) __attribute__ ((format (printf, 5, 6)));
@@ -70,6 +69,13 @@ struct log_info {
unsigned int num_cat;
};
+enum log_target_type {
+ LOG_TGT_TYPE_VTY,
+ LOG_TGT_TYPE_SYSLOG,
+ LOG_TGT_TYPE_FILE,
+ LOG_TGT_TYPE_STDERR,
+};
+
struct log_target {
struct llist_head entry;
@@ -81,6 +87,8 @@ struct log_target {
int use_color:1;
int print_timestamp:1;
+ enum log_target_type type;
+
union {
struct {
FILE *out;
@@ -89,6 +97,7 @@ struct log_target {
struct {
int priority;
+ int facility;
} tgt_syslog;
struct {
@@ -96,7 +105,8 @@ struct log_target {
} tgt_vty;
};
- void (*output) (struct log_target *target, const char *string);
+ void (*output) (struct log_target *target, unsigned int level,
+ const char *string);
};
/* use the above macros */
@@ -127,13 +137,18 @@ struct log_target *log_target_create(void);
void log_target_destroy(struct log_target *target);
struct log_target *log_target_create_stderr(void);
struct log_target *log_target_create_file(const char *fname);
+struct log_target *log_target_create_syslog(const char *ident, int option,
+ int facility);
int log_target_file_reopen(struct log_target *tgt);
void log_add_target(struct log_target *target);
void log_del_target(struct log_target *target);
-/* Gernerate command argument strings for VTY use */
-const char *log_vty_category_string(struct log_info *info);
-const char *log_vty_level_string(struct log_info *info);
+/* Generate command string for VTY use */
+const char *log_vty_command_string(const struct log_info *info);
+const char *log_vty_command_description(const struct log_info *info);
+
+struct log_target *log_target_find(int type, const char *fname);
+extern struct llist_head osmo_log_target_list;
#endif /* _OSMOCORE_LOGGING_H */
diff --git a/src/shared/libosmocore/include/osmocore/msgb.h b/src/shared/libosmocore/include/osmocom/core/msgb.h
index 6fd24c7..57b5d7f 100644
--- a/src/shared/libosmocore/include/osmocore/msgb.h
+++ b/src/shared/libosmocore/include/osmocom/core/msgb.h
@@ -21,7 +21,8 @@
*/
#include <stdint.h>
-#include "linuxlist.h"
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/utils.h>
#define MSGB_DEBUG
@@ -61,7 +62,7 @@ extern struct msgb *msgb_dequeue(struct llist_head *queue);
extern void msgb_reset(struct msgb *m);
#ifdef MSGB_DEBUG
-#include <osmocore/panic.h>
+#include <osmocom/core/panic.h>
#define MSGB_ABORT(msg, fmt, args ...) do { \
osmo_panic("msgb(%p): " fmt, msg, ## args); \
} while(0)
@@ -180,6 +181,8 @@ static inline void msgb_reserve(struct msgb *msg, int len)
static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
const char *name)
{
+ static_assert(size > headroom, headroom_bigger);
+
struct msgb *msg = msgb_alloc(size, name);
if (msg)
msgb_reserve(msg, headroom);
diff --git a/src/shared/libosmocore/include/osmocore/msgfile.h b/src/shared/libosmocore/include/osmocom/core/msgfile.h
index 92caa9f..92caa9f 100644
--- a/src/shared/libosmocore/include/osmocore/msgfile.h
+++ b/src/shared/libosmocore/include/osmocom/core/msgfile.h
diff --git a/src/shared/libosmocore/include/osmocore/panic.h b/src/shared/libosmocore/include/osmocom/core/panic.h
index c5a8377..c5a8377 100644
--- a/src/shared/libosmocore/include/osmocore/panic.h
+++ b/src/shared/libosmocore/include/osmocom/core/panic.h
diff --git a/src/shared/libosmocore/include/osmocore/plugin.h b/src/shared/libosmocore/include/osmocom/core/plugin.h
index 98f9b56..98f9b56 100644
--- a/src/shared/libosmocore/include/osmocore/plugin.h
+++ b/src/shared/libosmocore/include/osmocom/core/plugin.h
diff --git a/src/shared/libosmocore/include/osmocore/process.h b/src/shared/libosmocore/include/osmocom/core/process.h
index 2d66382..2d66382 100644
--- a/src/shared/libosmocore/include/osmocore/process.h
+++ b/src/shared/libosmocore/include/osmocom/core/process.h
diff --git a/src/shared/libosmocore/include/osmocore/rate_ctr.h b/src/shared/libosmocore/include/osmocom/core/rate_ctr.h
index f887d9a..ebb8646 100644
--- a/src/shared/libosmocore/include/osmocore/rate_ctr.h
+++ b/src/shared/libosmocore/include/osmocom/core/rate_ctr.h
@@ -3,7 +3,7 @@
#include <stdint.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
#define RATE_CTR_INTV_NUM 4
@@ -75,7 +75,6 @@ static inline void rate_ctr_inc(struct rate_ctr *ctr)
/* Initialize the counter module */
int rate_ctr_init(void *tall_ctx);
-struct vty;
-void vty_out_rate_ctr_group(struct vty *vty, const char *prefix,
- struct rate_ctr_group *ctrg);
+struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx);
+const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name);
#endif /* RATE_CTR_H */
diff --git a/src/shared/libosmocore/include/osmocore/select.h b/src/shared/libosmocore/include/osmocom/core/select.h
index 2d8b3ec..5ca21c3 100644
--- a/src/shared/libosmocore/include/osmocore/select.h
+++ b/src/shared/libosmocore/include/osmocom/core/select.h
@@ -1,7 +1,7 @@
#ifndef _BSC_SELECT_H
#define _BSC_SELECT_H
-#include "linuxlist.h"
+#include <osmocom/core/linuxlist.h>
#define BSC_FD_READ 0x0001
#define BSC_FD_WRITE 0x0002
diff --git a/src/shared/libosmocore/include/osmocore/signal.h b/src/shared/libosmocore/include/osmocom/core/signal.h
index 02d83d2..02d83d2 100644
--- a/src/shared/libosmocore/include/osmocore/signal.h
+++ b/src/shared/libosmocore/include/osmocom/core/signal.h
diff --git a/src/shared/libosmocore/include/osmocore/statistics.h b/src/shared/libosmocore/include/osmocom/core/statistics.h
index 1d56054..2c15965 100644
--- a/src/shared/libosmocore/include/osmocore/statistics.h
+++ b/src/shared/libosmocore/include/osmocom/core/statistics.h
@@ -28,4 +28,6 @@ void counter_free(struct counter *ctr);
int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
+struct counter *counter_get_by_name(const char *name);
+
#endif /* _STATISTICS_H */
diff --git a/src/shared/libosmocore/include/osmocore/talloc.h b/src/shared/libosmocore/include/osmocom/core/talloc.h
index f7f7643..f7f7643 100644
--- a/src/shared/libosmocore/include/osmocore/talloc.h
+++ b/src/shared/libosmocore/include/osmocom/core/talloc.h
diff --git a/src/shared/libosmocore/include/osmocore/timer.h b/src/shared/libosmocore/include/osmocom/core/timer.h
index fee888b..1966478 100644
--- a/src/shared/libosmocore/include/osmocore/timer.h
+++ b/src/shared/libosmocore/include/osmocom/core/timer.h
@@ -23,7 +23,7 @@
#include <sys/time.h>
-#include "linuxlist.h"
+#include <osmocom/core/linuxlist.h>
/**
* Timer management:
diff --git a/src/shared/libosmocore/include/osmocore/utils.h b/src/shared/libosmocore/include/osmocom/core/utils.h
index 3574f7f..252228d 100644
--- a/src/shared/libosmocore/include/osmocore/utils.h
+++ b/src/shared/libosmocore/include/osmocom/core/utils.h
@@ -20,5 +20,20 @@ uint8_t char2bcd(char c);
int hexparse(const char *str, uint8_t *b, int max_len);
char *hexdump(const unsigned char *buf, int len);
char *hexdump_nospc(const unsigned char *buf, int len);
+char *ubit_dump(const uint8_t *bits, unsigned int len);
+
+#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
+
+void osmo_str2lower(char *out, const char *in);
+void osmo_str2upper(char *out, const char *in);
+
+#define OSMO_SNPRINTF_RET(ret, rem, offset, len) \
+do { \
+ len += ret; \
+ if (ret > rem) \
+ ret = rem; \
+ offset += ret; \
+ rem -= ret; \
+} while (0)
#endif
diff --git a/src/shared/libosmocore/include/osmocore/write_queue.h b/src/shared/libosmocore/include/osmocom/core/write_queue.h
index ef244c3..3b730c7 100644
--- a/src/shared/libosmocore/include/osmocore/write_queue.h
+++ b/src/shared/libosmocore/include/osmocom/core/write_queue.h
@@ -23,8 +23,8 @@
#ifndef write_queue_h
#define write_queue_h
-#include "select.h"
-#include "msgb.h"
+#include <osmocom/core/select.h>
+#include <osmocom/core/msgb.h>
struct write_queue {
struct bsc_fd bfd;
diff --git a/src/shared/libosmocore/include/osmocom/crypt/gprs_cipher.h b/src/shared/libosmocore/include/osmocom/crypt/gprs_cipher.h
index 3e514ec..3051071 100644
--- a/src/shared/libosmocore/include/osmocom/crypt/gprs_cipher.h
+++ b/src/shared/libosmocore/include/osmocom/crypt/gprs_cipher.h
@@ -1,7 +1,7 @@
#ifndef _GPRS_CIPHER_H
#define _GPRS_CIPHER_H
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
#define GSM0464_CIPH_MAX_BLOCK 1523
diff --git a/src/shared/libosmocore/include/osmocom/gsm/Makefile.am b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am
new file mode 100644
index 0000000..8685fc9
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am
@@ -0,0 +1,6 @@
+osmogsm_HEADERS = comp128.h gsm0808.h gsm48_ie.h mncc.h rxlev_stat.h \
+ gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h
+
+SUBDIRS = protocol
+
+osmogsmdir = $(includedir)/osmocom/gsm
diff --git a/src/shared/libosmocore/include/osmocore/comp128.h b/src/shared/libosmocore/include/osmocom/gsm/comp128.h
index c37808f..c37808f 100644
--- a/src/shared/libosmocore/include/osmocore/comp128.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/comp128.h
diff --git a/src/shared/libosmocore/include/osmocore/gsm0480.h b/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h
index b504332..d6626d6 100644
--- a/src/shared/libosmocore/include/osmocore/gsm0480.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h
@@ -1,9 +1,9 @@
#ifndef gsm0480_h
#define gsm0480_h
-#include "msgb.h"
-#include "protocol/gsm_04_08.h"
-#include "protocol/gsm_04_80.h"
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/protocol/gsm_04_80.h>
#define MAX_LEN_USSD_STRING 31
diff --git a/src/shared/libosmocore/include/osmocore/gsm0808.h b/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h
index 1d85377..1d85377 100644
--- a/src/shared/libosmocore/include/osmocore/gsm0808.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h
diff --git a/src/shared/libosmocore/include/osmocore/gsm48.h b/src/shared/libosmocore/include/osmocom/gsm/gsm48.h
index ffe0399..1e9403b 100644
--- a/src/shared/libosmocore/include/osmocore/gsm48.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/gsm48.h
@@ -1,9 +1,9 @@
#ifndef _OSMOCORE_GSM48_H
#define _OSMOCORE_GSM48_H
-#include <osmocore/tlv.h>
-#include <osmocore/protocol/gsm_04_08.h>
-#include <osmocore/gsm48_ie.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/gsm48_ie.h>
/* A parsed GPRS routing area */
struct gprs_ra_id {
diff --git a/src/shared/libosmocore/include/osmocore/gsm48_ie.h b/src/shared/libosmocore/include/osmocom/gsm/gsm48_ie.h
index fa66159..f4fce25 100644
--- a/src/shared/libosmocore/include/osmocore/gsm48_ie.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/gsm48_ie.h
@@ -5,10 +5,10 @@
#include <string.h>
#include <errno.h>
-#include <osmocore/msgb.h>
-#include <osmocore/tlv.h>
-#include <osmocore/mncc.h>
-#include <osmocore/protocol/gsm_04_08.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/mncc.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
/* decode a 'called/calling/connect party BCD number' as in 10.5.4.7 */
int gsm48_decode_bcd_number(char *output, int output_len,
diff --git a/src/shared/libosmocore/include/osmocore/gsm_utils.h b/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h
index 0aadd2e..19adb70 100644
--- a/src/shared/libosmocore/include/osmocore/gsm_utils.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h
@@ -114,5 +114,4 @@ int gprs_tlli_type(uint32_t tlli);
uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type);
-void generate_backtrace();
#endif
diff --git a/src/shared/libosmocore/include/osmocore/mncc.h b/src/shared/libosmocore/include/osmocom/gsm/mncc.h
index a094bb9..a094bb9 100644
--- a/src/shared/libosmocore/include/osmocore/mncc.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/mncc.h
diff --git a/src/shared/libosmocore/include/osmocom/gsm/protocol/Makefile.am b/src/shared/libosmocore/include/osmocom/gsm/protocol/Makefile.am
new file mode 100644
index 0000000..8483f10
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/Makefile.am
@@ -0,0 +1,6 @@
+osmogsm_proto_HEADERS = gsm_03_41.h \
+ gsm_04_08.h gsm_04_11.h gsm_04_12.h gsm_04_80.h \
+ gsm_08_08.h gsm_08_58.h \
+ gsm_12_21.h
+
+osmogsm_protodir = $(includedir)/osmocom/gsm/protocol
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_03_41.h
index 3b1b7c9..54365cb 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_03_41.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_03_41.h
@@ -40,7 +40,7 @@ struct gsm341_etws_message {
uint8_t data[0];
} __attribute__((packed));
-#define GSM341_MSG_CODE(ms) (ms->serial.code_lo | (msg->serial.code_hi << 4))
+#define GSM341_MSG_CODE(ms) ((ms)->serial.code_lo | ((ms)->serial.code_hi << 4))
/* Section 9.3.2.1 - Geographical Scope */
#define GSM341_GS_CELL_WIDE_IMMED 0
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_08.h
index 3ad7dfd..3ad7dfd 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_08.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_11.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_11.h
index c6a2b19..c6a2b19 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_11.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_11.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_12.h
index 9b1538a..9b1538a 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_12.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_12.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_80.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_80.h
index fa5c945..fa5c945 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_04_80.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_04_80.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_08_08.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_08.h
index 6b8f935..6b8f935 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_08_08.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_08.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_08_58.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h
index 74a4083..74a4083 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_08_58.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h
diff --git a/src/shared/libosmocore/include/osmocore/protocol/gsm_12_21.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_12_21.h
index 9cae45d..b8b00f3 100644
--- a/src/shared/libosmocore/include/osmocore/protocol/gsm_12_21.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_12_21.h
@@ -24,7 +24,7 @@
*/
#include <stdint.h>
-#include <osmocore/tlv.h>
+#include <osmocom/gsm/tlv.h>
/* generic header in front of every OML message according to TS 08.59 */
struct abis_om_hdr {
diff --git a/src/shared/libosmocore/include/osmocore/rsl.h b/src/shared/libosmocore/include/osmocom/gsm/rsl.h
index 54d6703..7e46330 100644
--- a/src/shared/libosmocore/include/osmocore/rsl.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/rsl.h
@@ -2,8 +2,8 @@
#define _OSMOCORE_RSL_H
#include <stdint.h>
-#include <osmocore/utils.h>
-#include <osmocore/protocol/gsm_08_58.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/protocol/gsm_08_58.h>
void rsl_init_rll_hdr(struct abis_rsl_rll_hdr *dh, uint8_t msg_type);
diff --git a/src/shared/libosmocore/include/osmocore/rxlev_stat.h b/src/shared/libosmocore/include/osmocom/gsm/rxlev_stat.h
index 415509d..415509d 100644
--- a/src/shared/libosmocore/include/osmocore/rxlev_stat.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/rxlev_stat.h
diff --git a/src/shared/libosmocore/include/osmocore/tlv.h b/src/shared/libosmocore/include/osmocom/gsm/tlv.h
index 4cfce87..552af2b 100644
--- a/src/shared/libosmocore/include/osmocore/tlv.h
+++ b/src/shared/libosmocore/include/osmocom/gsm/tlv.h
@@ -4,7 +4,7 @@
#include <stdint.h>
#include <string.h>
-#include <osmocore/msgb.h>
+#include <osmocom/core/msgb.h>
/* Terminology / wording
tag length value (in bits)
@@ -132,6 +132,14 @@ static inline uint8_t *tv_put(uint8_t *buf, uint8_t tag,
return buf;
}
+static inline uint8_t *tv_fixed_put(uint8_t *buf, uint8_t tag,
+ unsigned int len, const uint8_t *val)
+{
+ *buf++ = tag;
+ memcpy(buf, val, len);
+ return buf + len;
+}
+
/* 'val' is still in host byte order! */
static inline uint8_t *tv16_put(uint8_t *buf, uint8_t tag,
uint16_t val)
@@ -160,6 +168,13 @@ static inline uint8_t *msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val)
return tv_put(buf, tag, val);
}
+static inline uint8_t *msgb_tv_fixed_put(struct msgb *msg, uint8_t tag,
+ unsigned int len, const uint8_t *val)
+{
+ uint8_t *buf = msgb_put(msg, 1+len);
+ return tv_fixed_put(buf, tag, len, val);
+}
+
static inline uint8_t *msgb_v_put(struct msgb *msg, uint8_t val)
{
uint8_t *buf = msgb_put(msg, 1);
diff --git a/src/shared/libosmocore/include/osmocom/vty/Makefile.am b/src/shared/libosmocore/include/osmocom/vty/Makefile.am
index d2f0616..83d0010 100644
--- a/src/shared/libosmocore/include/osmocom/vty/Makefile.am
+++ b/src/shared/libosmocore/include/osmocom/vty/Makefile.am
@@ -1,4 +1,4 @@
osmovty_HEADERS = buffer.h command.h vector.h vty.h \
- telnet_interface.h logging.h
+ telnet_interface.h logging.h misc.h
osmovtydir = $(includedir)/osmocom/vty
diff --git a/src/shared/libosmocore/include/osmocom/vty/command.h b/src/shared/libosmocore/include/osmocom/vty/command.h
index 69e9e77..caf0414 100644
--- a/src/shared/libosmocore/include/osmocom/vty/command.h
+++ b/src/shared/libosmocore/include/osmocom/vty/command.h
@@ -70,6 +70,7 @@ enum node_type {
CONFIG_NODE, /* Config node. Default mode of config file. */
SERVICE_NODE, /* Service node. */
DEBUG_NODE, /* Debug node. */
+ CFG_LOG_NODE, /* Configure the logging */
VTY_NODE, /* Vty node. */
diff --git a/src/shared/libosmocore/include/osmocom/vty/logging.h b/src/shared/libosmocore/include/osmocom/vty/logging.h
index 45d74fd..e0011bf 100644
--- a/src/shared/libosmocore/include/osmocom/vty/logging.h
+++ b/src/shared/libosmocore/include/osmocom/vty/logging.h
@@ -4,6 +4,9 @@
#define LOGGING_STR "Configure log message to this terminal\n"
#define FILTER_STR "Filter log messages\n"
-void logging_vty_add_cmds(void);
+struct log_info;
+void logging_vty_add_cmds(const struct log_info *cat);
+struct vty;
+struct log_target *osmo_log_vty2tgt(struct vty *vty);
#endif /* _VTY_LOGGING_H */
diff --git a/src/shared/libosmocore/include/osmocom/vty/misc.h b/src/shared/libosmocore/include/osmocom/vty/misc.h
new file mode 100644
index 0000000..707f82f
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/vty/misc.h
@@ -0,0 +1,10 @@
+#ifndef OSMO_VTY_MISC_H
+#define OSMO_VTY_MISC_H
+
+#include <osmocom/vty/vty.h>
+#include <osmocom/core/rate_ctr.h>
+
+void vty_out_rate_ctr_group(struct vty *vty, const char *prefix,
+ struct rate_ctr_group *ctrg);
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocom/vty/telnet_interface.h b/src/shared/libosmocore/include/osmocom/vty/telnet_interface.h
index 444e649..0c034e4 100644
--- a/src/shared/libosmocore/include/osmocom/vty/telnet_interface.h
+++ b/src/shared/libosmocore/include/osmocom/vty/telnet_interface.h
@@ -21,8 +21,8 @@
#ifndef TELNET_INTERFACE_H
#define TELNET_INTERFACE_H
-#include <osmocore/logging.h>
-#include <osmocore/select.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/select.h>
#include <osmocom/vty/vty.h>
diff --git a/src/shared/libosmocore/include/osmocore/Makefile.am b/src/shared/libosmocore/include/osmocore/Makefile.am
deleted file mode 100644
index 2efaa96..0000000
--- a/src/shared/libosmocore/include/osmocore/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h \
- tlv.h bitvec.h comp128.h statistics.h gsm_utils.h utils.h \
- gsmtap.h write_queue.h rsl.h gsm48.h rxlev_stat.h mncc.h \
- gsm48_ie.h logging.h gsm0808.h rate_ctr.h gsmtap_util.h \
- plugin.h crc16.h panic.h process.h gsm0480.h msgfile.h
-
-if ENABLE_TALLOC
-osmocore_HEADERS += talloc.h
-endif
-
-osmocoredir = $(includedir)/osmocore
-
-SUBDIRS = protocol
diff --git a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am b/src/shared/libosmocore/include/osmocore/protocol/Makefile.am
deleted file mode 100644
index 03a4849..0000000
--- a/src/shared/libosmocore/include/osmocore/protocol/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-osmocore_proto_HEADERS = gsm_03_41.h \
- gsm_04_08.h gsm_04_11.h gsm_04_12.h gsm_04_80.h \
- gsm_08_08.h gsm_08_58.h \
- gsm_12_21.h
-
-osmocore_protodir = $(includedir)/osmocore/protocol
diff --git a/src/shared/libosmocore/libosmogsm.pc.in b/src/shared/libosmocore/libosmogsm.pc.in
new file mode 100644
index 0000000..753bb3a
--- /dev/null
+++ b/src/shared/libosmocore/libosmogsm.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Osmocom GSM Core Library
+Description: GSM Core Library
+Version: @VERSION@
+Libs: -L${libdir} -losmogsm
+Cflags: -I${includedir}/
+
diff --git a/src/shared/libosmocore/src/Makefile.am b/src/shared/libosmocore/src/Makefile.am
index 64310e0..c5c8a21 100644
--- a/src/shared/libosmocore/src/Makefile.am
+++ b/src/shared/libosmocore/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS=. vty codec
+SUBDIRS=. vty codec gsm
# 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
@@ -9,11 +9,12 @@ AM_CFLAGS = -fPIC -Wall
lib_LTLIBRARIES = libosmocore.la
-libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c rxlev_stat.c \
- tlv_parser.c bitvec.c comp128.c gsm_utils.c statistics.c \
- write_queue.c utils.c rsl.c gsm48.c gsm48_ie.c \
- logging.c gsm0808.c rate_ctr.c gsmtap_util.c \
- gprs_cipher_core.c crc16.c panic.c process.c gsm0480.c
+libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c bits.c \
+ bitvec.c statistics.c \
+ write_queue.c utils.c \
+ logging.c logging_syslog.c rate_ctr.c \
+ gsmtap_util.c crc16.c panic.c backtrace.c \
+ process.c
if ENABLE_PLUGIN
libosmocore_la_SOURCES += plugin.c
diff --git a/src/shared/libosmocore/src/backtrace.c b/src/shared/libosmocore/src/backtrace.c
new file mode 100644
index 0000000..ecd6b9c
--- /dev/null
+++ b/src/shared/libosmocore/src/backtrace.c
@@ -0,0 +1,50 @@
+/*
+ * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de>
+ * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2010 by Nico Golde <nico@ngolde.de>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <osmocom/core/utils.h>
+#include "config.h"
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+void generate_backtrace()
+{
+ int i, nptrs;
+ void *buffer[100];
+ char **strings;
+
+ nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
+ printf("backtrace() returned %d addresses\n", nptrs);
+
+ strings = backtrace_symbols(buffer, nptrs);
+ if (!strings)
+ return;
+
+ for (i = 1; i < nptrs; i++)
+ printf("%s\n", strings[i]);
+
+ free(strings);
+}
+#endif
diff --git a/src/shared/libosmocore/src/bits.c b/src/shared/libosmocore/src/bits.c
new file mode 100644
index 0000000..ff5d176
--- /dev/null
+++ b/src/shared/libosmocore/src/bits.c
@@ -0,0 +1,98 @@
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+
+/* convert unpacked bits to packed bits, return length in bytes */
+int osmo_ubit2pbit(pbit_t *out, const ubit_t *in, unsigned int num_bits)
+{
+ unsigned int i;
+ uint8_t curbyte = 0;
+ pbit_t *outptr = out;
+
+ for (i = 0; i < num_bits; i++) {
+ uint8_t bitnum = 7 - (i % 8);
+
+ curbyte |= (in[i] << bitnum);
+
+ if(i % 8 == 7){
+ *outptr++ = curbyte;
+ curbyte = 0;
+ }
+ }
+ /* we have a non-modulo-8 bitcount */
+ if (i % 8)
+ *outptr++ = curbyte;
+
+ return outptr - out;
+}
+
+/* convert packed bits to unpacked bits, return length in bytes */
+int osmo_pbit2ubit(ubit_t *out, const pbit_t *in, unsigned int num_bits)
+{
+ unsigned int i;
+ ubit_t *cur = out;
+ ubit_t *limit = out + num_bits;
+
+ for (i = 0; i < (num_bits/8)+1; i++) {
+ pbit_t byte = in[i];
+ *cur++ = (byte >> 7) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 6) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 5) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 4) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 3) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 2) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 1) & 1;
+ if (cur >= limit)
+ break;
+ *cur++ = (byte >> 0) & 1;
+ if (cur >= limit)
+ break;
+ }
+ return cur - out;
+}
+
+/* convert unpacked bits to packed bits (extended options but slower),
+ * return length in bytes (max written ofs of output buffer + 1) */
+int osmo_ubit2pbit_ext(pbit_t *out, unsigned int out_ofs,
+ const ubit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode)
+{
+ int i, op, bn;
+ for (i=0; i<num_bits; i++) {
+ op = out_ofs + i;
+ bn = lsb_mode ? (op&7) : (7-(op&7));
+ if (in[in_ofs+i])
+ out[op>>3] |= 1 << bn;
+ else
+ out[op>>3] &= ~(1 << bn);
+ }
+ return ((out_ofs + num_bits - 1) >> 3) + 1;
+}
+
+/* convert packed bits to unpacked bits (extended options but slower),
+ * return length in bytes (max written ofs of output buffer + 1) */
+int osmo_pbit2ubit_ext(ubit_t *out, unsigned int out_ofs,
+ const pbit_t *in, unsigned int in_ofs,
+ unsigned int num_bits, int lsb_mode)
+{
+ int i, ip, bn;
+ for (i=0; i<num_bits; i++) {
+ ip = in_ofs + i;
+ bn = lsb_mode ? (ip&7) : (7-(ip&7));
+ out[out_ofs+i] = !!(in[ip>>3] & (1<<bn));
+ }
+ return out_ofs + num_bits;
+}
diff --git a/src/shared/libosmocore/src/bitvec.c b/src/shared/libosmocore/src/bitvec.c
index 95d78a5..4fd3834 100644
--- a/src/shared/libosmocore/src/bitvec.c
+++ b/src/shared/libosmocore/src/bitvec.c
@@ -24,7 +24,7 @@
#include <errno.h>
#include <stdint.h>
-#include <osmocore/bitvec.h>
+#include <osmocom/core/bitvec.h>
#define BITNUM_FROM_COMP(byte, bit) ((byte*8)+bit)
@@ -217,3 +217,17 @@ int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit)
return 0;
}
+
+/* find first bit set in bit vector */
+int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n,
+ enum bit_value val)
+{
+ unsigned int i;
+
+ for (i = n; i < bv->data_len*8; i++) {
+ if (bitvec_get_bit_pos(bv, i) == val)
+ return i;
+ }
+
+ return -1;
+}
diff --git a/src/shared/libosmocore/src/crc16.c b/src/shared/libosmocore/src/crc16.c
index 8ac8031..3a0d0dd 100644
--- a/src/shared/libosmocore/src/crc16.c
+++ b/src/shared/libosmocore/src/crc16.c
@@ -8,7 +8,7 @@
* Version 2. See the file COPYING for more details.
*/
-#include <osmocore/crc16.h>
+#include <osmocom/core/crc16.h>
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
uint16_t const crc16_table[256] = {
diff --git a/src/shared/libosmocore/src/gsm/Makefile.am b/src/shared/libosmocore/src/gsm/Makefile.am
new file mode 100644
index 0000000..a8c2e56
--- /dev/null
+++ b/src/shared/libosmocore/src/gsm/Makefile.am
@@ -0,0 +1,13 @@
+# 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 = libosmogsm.la
+
+libosmogsm_la_SOURCES = rxlev_stat.c tlv_parser.c comp128.c gsm_utils.c \
+ rsl.c gsm48.c gsm48_ie.c gsm0808.c \
+ gprs_cipher_core.c gsm0480.c
+libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la
diff --git a/src/shared/libosmocore/src/comp128.c b/src/shared/libosmocore/src/gsm/comp128.c
index 5d5680c..5d5680c 100644
--- a/src/shared/libosmocore/src/comp128.c
+++ b/src/shared/libosmocore/src/gsm/comp128.c
diff --git a/src/shared/libosmocore/src/gprs_cipher_core.c b/src/shared/libosmocore/src/gsm/gprs_cipher_core.c
index 6174bd7..0ff85e2 100644
--- a/src/shared/libosmocore/src/gprs_cipher_core.c
+++ b/src/shared/libosmocore/src/gsm/gprs_cipher_core.c
@@ -23,9 +23,9 @@
#include <errno.h>
#include <stdint.h>
-#include <osmocore/utils.h>
-#include <osmocore/linuxlist.h>
-#include <osmocore/plugin.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/plugin.h>
#include <osmocom/crypt/gprs_cipher.h>
diff --git a/src/shared/libosmocore/src/gsm0480.c b/src/shared/libosmocore/src/gsm/gsm0480.c
index b6b345c..b9b3ed9 100644
--- a/src/shared/libosmocore/src/gsm0480.c
+++ b/src/shared/libosmocore/src/gsm/gsm0480.c
@@ -22,13 +22,13 @@
*
*/
-#include <osmocore/gsm0480.h>
-#include <osmocore/gsm_utils.h>
+#include <osmocom/gsm/gsm0480.h>
+#include <osmocom/gsm/gsm_utils.h>
-#include <osmocore/logging.h>
+#include <osmocom/core/logging.h>
-#include <osmocore/protocol/gsm_04_08.h>
-#include <osmocore/protocol/gsm_04_80.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/protocol/gsm_04_80.h>
#include <string.h>
diff --git a/src/shared/libosmocore/src/gsm0808.c b/src/shared/libosmocore/src/gsm/gsm0808.c
index dc450cc..1640adc 100644
--- a/src/shared/libosmocore/src/gsm0808.c
+++ b/src/shared/libosmocore/src/gsm/gsm0808.c
@@ -18,9 +18,9 @@
*
*/
-#include <osmocore/gsm0808.h>
-#include <osmocore/protocol/gsm_08_08.h>
-#include <osmocore/gsm48.h>
+#include <osmocom/gsm/gsm0808.h>
+#include <osmocom/gsm/protocol/gsm_08_08.h>
+#include <osmocom/gsm/gsm48.h>
#include <arpa/inet.h>
diff --git a/src/shared/libosmocore/src/gsm48.c b/src/shared/libosmocore/src/gsm/gsm48.c
index daec4f3..436bf14 100644
--- a/src/shared/libosmocore/src/gsm48.c
+++ b/src/shared/libosmocore/src/gsm/gsm48.c
@@ -28,11 +28,11 @@
#include <arpa/inet.h>
-#include <osmocore/utils.h>
-#include <osmocore/tlv.h>
-#include <osmocore/gsm48.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/gsm48.h>
-#include <osmocore/protocol/gsm_04_08.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
const struct tlv_definition gsm48_att_tlvdef = {
.def = {
diff --git a/src/shared/libosmocore/src/gsm48_ie.c b/src/shared/libosmocore/src/gsm/gsm48_ie.c
index 0e27088..efcf281 100644
--- a/src/shared/libosmocore/src/gsm48_ie.c
+++ b/src/shared/libosmocore/src/gsm/gsm48_ie.c
@@ -27,12 +27,12 @@
#include <string.h>
#include <errno.h>
-#include <osmocore/utils.h>
-#include <osmocore/msgb.h>
-#include <osmocore/tlv.h>
-#include <osmocore/mncc.h>
-#include <osmocore/protocol/gsm_04_08.h>
-#include <osmocore/gsm48_ie.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/mncc.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/gsm48_ie.h>
static const char bcd_num_digits[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
diff --git a/src/shared/libosmocore/src/gsm_utils.c b/src/shared/libosmocore/src/gsm/gsm_utils.c
index 31e3cd6..377705d 100644
--- a/src/shared/libosmocore/src/gsm_utils.c
+++ b/src/shared/libosmocore/src/gsm/gsm_utils.c
@@ -23,8 +23,8 @@
*/
//#include <openbsc/gsm_data.h>
-#include <osmocore/utils.h>
-#include <osmocore/gsm_utils.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/gsm_utils.h>
#include <stdlib.h>
#include <stdint.h>
@@ -33,7 +33,7 @@
#include <errno.h>
#include <ctype.h>
-#include "../config.h"
+#include "../../config.h"
/* ETSI GSM 03.38 6.2.1 and 6.2.1.1 default alphabet
* Greek symbols at hex positions 0x10 and 0x12-0x1a
@@ -334,29 +334,6 @@ enum gsm_band gsm_band_parse(const char* mhz)
}
}
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-void generate_backtrace()
-{
- int i, nptrs;
- void *buffer[100];
- char **strings;
-
- nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
- printf("backtrace() returned %d addresses\n", nptrs);
-
- strings = backtrace_symbols(buffer, nptrs);
- if (!strings)
- return;
-
- for (i = 1; i < nptrs; i++)
- printf("%s\n", strings[i]);
-
- free(strings);
-}
-#endif
-
enum gsm_band gsm_arfcn2band(uint16_t arfcn)
{
int is_pcs = arfcn & ARFCN_PCS;
diff --git a/src/shared/libosmocore/src/rsl.c b/src/shared/libosmocore/src/gsm/rsl.c
index 3bfeffb..12ac0cf 100644
--- a/src/shared/libosmocore/src/rsl.c
+++ b/src/shared/libosmocore/src/gsm/rsl.c
@@ -25,8 +25,8 @@
#include <stdio.h>
#include <errno.h>
-#include <osmocore/tlv.h>
-#include <osmocore/rsl.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/gsm/rsl.h>
#define RSL_ALLOC_SIZE 200
#define RSL_ALLOC_HEADROOM 56
diff --git a/src/shared/libosmocore/src/rxlev_stat.c b/src/shared/libosmocore/src/gsm/rxlev_stat.c
index 1bfd679..d226861 100644
--- a/src/shared/libosmocore/src/rxlev_stat.c
+++ b/src/shared/libosmocore/src/gsm/rxlev_stat.c
@@ -27,20 +27,8 @@
#include <errno.h>
#include <stdint.h>
-#include <osmocore/bitvec.h>
-#include <osmocore/rxlev_stat.h>
-
-int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val)
-{
- unsigned int i;
-
- for (i = n; i < bv->data_len*8; i++) {
- if (bitvec_get_bit_pos(bv, i) == val)
- return i;
- }
-
- return -1;
-}
+#include <osmocom/core/bitvec.h>
+#include <osmocom/gsm/rxlev_stat.h>
void rxlev_stat_input(struct rxlev_stats *st, uint16_t arfcn, uint8_t rxlev)
{
@@ -68,7 +56,7 @@ int16_t rxlev_stat_get_next(const struct rxlev_stats *st, uint8_t rxlev, int16_t
if (arfcn < 0)
arfcn = -1;
- bv.data = st->rxlev_buckets[rxlev];
+ bv.data = (uint8_t *) st->rxlev_buckets[rxlev];
return bitvec_find_bit_pos(&bv, arfcn+1, ONE);
}
diff --git a/src/shared/libosmocore/src/tlv_parser.c b/src/shared/libosmocore/src/gsm/tlv_parser.c
index bbef7a9..1e4c6b5 100644
--- a/src/shared/libosmocore/src/tlv_parser.c
+++ b/src/shared/libosmocore/src/gsm/tlv_parser.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdint.h>
-#include <osmocore/utils.h>
-#include <osmocore/tlv.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/tlv.h>
struct tlv_definition tvlv_att_def;
diff --git a/src/shared/libosmocore/src/gsmtap_util.c b/src/shared/libosmocore/src/gsmtap_util.c
index abee4da..6d02d58 100644
--- a/src/shared/libosmocore/src/gsmtap_util.c
+++ b/src/shared/libosmocore/src/gsmtap_util.c
@@ -24,13 +24,13 @@
#ifdef HAVE_SYS_SELECT_H
-#include <osmocore/gsmtap_util.h>
-#include <osmocore/logging.h>
-#include <osmocore/protocol/gsm_04_08.h>
-#include <osmocore/gsmtap.h>
-#include <osmocore/msgb.h>
-#include <osmocore/rsl.h>
-#include <osmocore/select.h>
+#include <osmocom/core/gsmtap_util.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/gsmtap.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
#include <arpa/inet.h>
#include <sys/socket.h>
diff --git a/src/shared/libosmocore/src/logging.c b/src/shared/libosmocore/src/logging.c
index b3b5cb6..77c8a50 100644
--- a/src/shared/libosmocore/src/logging.c
+++ b/src/shared/libosmocore/src/logging.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
@@ -33,17 +34,21 @@
#include <time.h>
#include <errno.h>
-#include <osmocore/talloc.h>
-#include <osmocore/utils.h>
-#include <osmocore/logging.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
+
+#include <osmocom/vty/logging.h> /* for LOGGING_STR. */
const struct log_info *osmo_log_info;
static struct log_context log_context;
static void *tall_log_ctx = NULL;
-static LLIST_HEAD(target_list);
+LLIST_HEAD(osmo_log_target_list);
+
+#define LOGLEVEL_DEFS 6 /* Number of loglevels.*/
-static const struct value_string loglevel_strs[] = {
+static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1] = {
{ 0, "EVERYTHING" },
{ LOGL_DEBUG, "DEBUG" },
{ LOGL_INFO, "INFO" },
@@ -53,6 +58,17 @@ static const struct value_string loglevel_strs[] = {
{ 0, NULL },
};
+/* You have to keep this in sync with the structure loglevel_strs. */
+const char *loglevel_descriptions[LOGLEVEL_DEFS+1] = {
+ "Log simply everything",
+ "Log debug messages and higher levels",
+ "Log informational messages and higher levels",
+ "Log noticable messages and higher levels",
+ "Log error messages and higher levels",
+ "Log only fatal messages",
+ NULL,
+};
+
int log_parse_level(const char *lvl)
{
return get_string_value(loglevel_strs, lvl);
@@ -124,8 +140,8 @@ static const char* color(int subsys)
}
static void _output(struct log_target *target, unsigned int subsys,
- char *file, int line, int cont, const char *format,
- va_list ap)
+ unsigned int level, char *file, int line, int cont,
+ const char *format, va_list ap)
{
char col[30];
char sub[30];
@@ -167,7 +183,7 @@ static void _output(struct log_target *target, unsigned int subsys,
snprintf(final, sizeof(final), "%s%s%s%s%s", col, tim, sub, buf,
target->use_color ? "\033[0;m" : "");
final[sizeof(final)-1] = '\0';
- target->output(target, final);
+ target->output(target, level, final);
}
@@ -176,7 +192,7 @@ static void _logp(unsigned int subsys, int level, char *file, int line,
{
struct log_target *tar;
- llist_for_each_entry(tar, &target_list, entry) {
+ llist_for_each_entry(tar, &osmo_log_target_list, entry) {
struct log_category *category;
int output = 0;
@@ -212,7 +228,7 @@ static void _logp(unsigned int subsys, int level, char *file, int line,
* with the same va_list will segfault */
va_list bp;
va_copy(bp, ap);
- _output(tar, subsys, file, line, cont, format, bp);
+ _output(tar, subsys, level, file, line, cont, format, bp);
va_end(bp);
}
}
@@ -239,7 +255,7 @@ void logp2(unsigned int subsys, unsigned int level, char *file, int line, int co
void log_add_target(struct log_target *target)
{
- llist_add_tail(&target->entry, &target_list);
+ llist_add_tail(&target->entry, &osmo_log_target_list);
}
void log_del_target(struct log_target *target)
@@ -294,7 +310,8 @@ void log_set_category_filter(struct log_target *target, int category,
target->categories[category].loglevel = level;
}
-static void _file_output(struct log_target *target, const char *log)
+static void _file_output(struct log_target *target, unsigned int level,
+ const char *log)
{
fprintf(target->tgt_file.out, "%s", log);
fflush(target->tgt_file.out);
@@ -337,6 +354,7 @@ struct log_target *log_target_create_stderr(void)
if (!target)
return NULL;
+ target->type = LOG_TGT_TYPE_STDERR;
target->tgt_file.out = stderr;
target->output = _file_output;
return target;
@@ -353,6 +371,7 @@ struct log_target *log_target_create_file(const char *fname)
if (!target)
return NULL;
+ target->type = LOG_TGT_TYPE_FILE;
target->tgt_file.out = fopen(fname, "a");
if (!target->tgt_file.out)
return NULL;
@@ -364,6 +383,22 @@ struct log_target *log_target_create_file(const char *fname)
return target;
}
+struct log_target *log_target_find(int type, const char *fname)
+{
+ struct log_target *tgt;
+
+ llist_for_each_entry(tgt, &osmo_log_target_list, entry) {
+ if (tgt->type != type)
+ continue;
+ if (tgt->type == LOG_TGT_TYPE_FILE) {
+ if (!strcmp(fname, tgt->tgt_file.fname))
+ return tgt;
+ } else
+ return tgt;
+ }
+ return NULL;
+}
+
void log_target_destroy(struct log_target *target)
{
@@ -399,49 +434,115 @@ int log_target_file_reopen(struct log_target *target)
return 0;
}
-const char *log_vty_level_string(struct log_info *info)
+/* This generates the logging command string for VTY. */
+const char *log_vty_command_string(const struct log_info *info)
{
- const struct value_string *vs;
- unsigned int len = 3; /* ()\0 */
+ int len = 0, offset = 0, ret, i, rem;
+ int size = strlen("logging level () ()") + 1;
char *str;
- for (vs = loglevel_strs; vs->value || vs->str; vs++)
- len += strlen(vs->str) + 1;
+ for (i = 0; i < info->num_cat; i++)
+ size += strlen(info->cat[i].name) + 1;
+
+ for (i = 0; i < LOGLEVEL_DEFS; i++)
+ size += strlen(loglevel_strs[i].str) + 1;
- str = talloc_zero_size(NULL, len);
+ rem = size;
+ str = talloc_zero_size(NULL, size);
if (!str)
return NULL;
- str[0] = '(';
- for (vs = loglevel_strs; vs->value || vs->str; vs++) {
- strcat(str, vs->str);
- strcat(str, "|");
- }
- str[strlen(str)-1] = ')';
+ ret = snprintf(str + offset, rem, "logging level (all|");
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+
+ for (i = 0; i < info->num_cat; i++) {
+ int j, name_len = strlen(info->cat[i].name)+1;
+ char name[name_len];
+
+ for (j = 0; j < name_len; j++)
+ name[j] = tolower(info->cat[i].name[j]);
+ name[name_len-1] = '\0';
+ ret = snprintf(str + offset, rem, "%s|", name+1);
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+ }
+ offset--; /* to remove the trailing | */
+ rem++;
+
+ ret = snprintf(str + offset, rem, ") (");
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+
+ for (i = 0; i < LOGLEVEL_DEFS; i++) {
+ int j, loglevel_str_len = strlen(loglevel_strs[i].str)+1;
+ char loglevel_str[loglevel_str_len];
+
+ for (j = 0; j < loglevel_str_len; j++)
+ loglevel_str[j] = tolower(loglevel_strs[i].str[j]);
+
+ loglevel_str[loglevel_str_len-1] = '\0';
+ ret = snprintf(str + offset, rem, "%s|", loglevel_str);
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+ }
+ offset--; /* to remove the trailing | */
+ rem++;
+
+ ret = snprintf(str + offset, rem, ")");
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+err:
return str;
}
-const char *log_vty_category_string(struct log_info *info)
+/* This generates the logging command description for VTY. */
+const char *log_vty_command_description(const struct log_info *info)
{
- unsigned int len = 3; /* "()\0" */
- unsigned int i;
char *str;
+ int i, ret, len = 0, offset = 0, rem;
+ unsigned int size =
+ strlen(LOGGING_STR
+ "Set the log level for a specified category\n") + 1;
for (i = 0; i < info->num_cat; i++)
- len += strlen(info->cat[i].name) + 1;
+ size += strlen(info->cat[i].description) + 1;
+
+ for (i = 0; i < LOGLEVEL_DEFS; i++)
+ size += strlen(loglevel_descriptions[i]) + 1;
- str = talloc_zero_size(NULL, len);
+ rem = size;
+ str = talloc_zero_size(NULL, size);
if (!str)
return NULL;
- str[0] = '(';
+ ret = snprintf(str + offset, rem, LOGGING_STR
+ "Set the log level for a specified category\n");
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+
for (i = 0; i < info->num_cat; i++) {
- strcat(str, info->cat[i].name+1);
- strcat(str, "|");
+ ret = snprintf(str + offset, rem, "%s\n",
+ info->cat[i].description);
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
}
- str[strlen(str)-1] = ')';
-
+ for (i = 0; i < LOGLEVEL_DEFS; i++) {
+ ret = snprintf(str + offset, rem, "%s\n",
+ loglevel_descriptions[i]);
+ if (ret < 0)
+ goto err;
+ OSMO_SNPRINTF_RET(ret, rem, offset, len);
+ }
+err:
return str;
}
diff --git a/src/shared/libosmocore/src/logging_syslog.c b/src/shared/libosmocore/src/logging_syslog.c
new file mode 100644
index 0000000..4f043b1
--- /dev/null
+++ b/src/shared/libosmocore/src/logging_syslog.c
@@ -0,0 +1,78 @@
+/* Syslog logging support code */
+
+/* (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.
+ *
+ */
+
+#include "../config.h"
+
+#ifdef HAVE_SYSLOG_H
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
+
+static const int logp2syslog_level(unsigned int level)
+{
+ if (level >= LOGL_FATAL)
+ return LOG_CRIT;
+ else if (level >= LOGL_ERROR)
+ return LOG_ERR;
+ else if (level >= LOGL_NOTICE)
+ return LOG_NOTICE;
+ else if (level >= LOGL_INFO)
+ return LOG_INFO;
+ else
+ return LOG_DEBUG;
+}
+
+static void _syslog_output(struct log_target *target,
+ unsigned int level, const char *log)
+{
+ syslog(logp2syslog_level(level), "%s", log);
+}
+
+struct log_target *log_target_create_syslog(const char *ident, int option,
+ int facility)
+{
+ struct log_target *target;
+
+ target = log_target_create();
+ if (!target)
+ return NULL;
+
+ target->tgt_syslog.facility = facility;
+ target->type = LOG_TGT_TYPE_SYSLOG;
+ target->output = _syslog_output;
+
+ openlog(ident, option, facility);
+
+ return target;
+}
+
+#endif /* HAVE_SYSLOG_H */
diff --git a/src/shared/libosmocore/src/msgb.c b/src/shared/libosmocore/src/msgb.c
index 12a839a..d2c167a 100644
--- a/src/shared/libosmocore/src/msgb.c
+++ b/src/shared/libosmocore/src/msgb.c
@@ -22,11 +22,10 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/types.h>
-#include <osmocore/msgb.h>
+#include <osmocom/core/msgb.h>
//#include <openbsc/gsm_data.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
//#include <openbsc/debug.h>
void *tall_msgb_ctx;
diff --git a/src/shared/libosmocore/src/msgfile.c b/src/shared/libosmocore/src/msgfile.c
index 68f0581..c13df51 100644
--- a/src/shared/libosmocore/src/msgfile.c
+++ b/src/shared/libosmocore/src/msgfile.c
@@ -21,10 +21,9 @@
*
*/
-#include <osmocore/msgfile.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/msgfile.h>
+#include <osmocom/core/talloc.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/src/shared/libosmocore/src/panic.c b/src/shared/libosmocore/src/panic.c
index 5fb7b56..588a5fe 100644
--- a/src/shared/libosmocore/src/panic.c
+++ b/src/shared/libosmocore/src/panic.c
@@ -20,8 +20,9 @@
*
*/
-#include <osmocore/gsm_utils.h>
-#include <osmocore/panic.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/core/panic.h>
+#include <osmocom/core/backtrace.h>
#include "../config.h"
diff --git a/src/shared/libosmocore/src/plugin.c b/src/shared/libosmocore/src/plugin.c
index 3ba2d43..4d9fd31 100644
--- a/src/shared/libosmocore/src/plugin.c
+++ b/src/shared/libosmocore/src/plugin.c
@@ -24,14 +24,13 @@
#if HAVE_DLFCN_H
-#include <sys/types.h>
#include <dirent.h>
#include <dlfcn.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
-#include <osmocore/plugin.h>
+#include <osmocom/core/plugin.h>
int plugin_load_all(const char *directory)
{
diff --git a/src/shared/libosmocore/src/process.c b/src/shared/libosmocore/src/process.c
index 180efa5..7f4f12c 100644
--- a/src/shared/libosmocore/src/process.c
+++ b/src/shared/libosmocore/src/process.c
@@ -23,7 +23,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/types.h>
#include <sys/stat.h>
int osmo_daemonize(void)
diff --git a/src/shared/libosmocore/src/rate_ctr.c b/src/shared/libosmocore/src/rate_ctr.c
index 80ef55b..a0e1814 100644
--- a/src/shared/libosmocore/src/rate_ctr.c
+++ b/src/shared/libosmocore/src/rate_ctr.c
@@ -23,11 +23,11 @@
#include <stdint.h>
#include <string.h>
-#include <osmocore/utils.h>
-#include <osmocore/linuxlist.h>
-#include <osmocore/talloc.h>
-#include <osmocore/timer.h>
-#include <osmocore/rate_ctr.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/rate_ctr.h>
static LLIST_HEAD(rate_ctr_groups);
@@ -125,3 +125,37 @@ int rate_ctr_init(void *tall_ctx)
return 0;
}
+
+struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx)
+{
+ struct rate_ctr_group *ctrg;
+
+ llist_for_each_entry(ctrg, &rate_ctr_groups, list) {
+ if (!ctrg->desc)
+ continue;
+
+ if (!strcmp(ctrg->desc->group_name_prefix, name) &&
+ ctrg->idx == idx) {
+ return ctrg;
+ }
+ }
+ return NULL;
+}
+
+const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name)
+{
+ int i;
+ const struct rate_ctr_desc *ctr_desc;
+
+ if (!ctrg->desc)
+ return NULL;
+
+ for (i = 0; i < ctrg->desc->num_ctr; i++) {
+ ctr_desc = &ctrg->desc->ctr_desc[i];
+
+ if (!strcmp(ctr_desc->name, name)) {
+ return &ctrg->ctr[i];
+ }
+ }
+ return NULL;
+}
diff --git a/src/shared/libosmocore/src/select.c b/src/shared/libosmocore/src/select.c
index 5aa2beb..adf3619 100644
--- a/src/shared/libosmocore/src/select.c
+++ b/src/shared/libosmocore/src/select.c
@@ -22,9 +22,9 @@
#include <fcntl.h>
#include <stdio.h>
-#include <osmocore/select.h>
-#include <osmocore/linuxlist.h>
-#include <osmocore/timer.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/timer.h>
#include "../config.h"
diff --git a/src/shared/libosmocore/src/signal.c b/src/shared/libosmocore/src/signal.c
index c7ca86c..bb5c38e 100644
--- a/src/shared/libosmocore/src/signal.c
+++ b/src/shared/libosmocore/src/signal.c
@@ -18,9 +18,9 @@
*
*/
-#include <osmocore/signal.h>
-#include <osmocore/talloc.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/linuxlist.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/src/shared/libosmocore/src/statistics.c b/src/shared/libosmocore/src/statistics.c
index 34e6a40..83bb6ed 100644
--- a/src/shared/libosmocore/src/statistics.c
+++ b/src/shared/libosmocore/src/statistics.c
@@ -20,12 +20,11 @@
*
*/
+#include <string.h>
-#include <sys/types.h>
-
-#include <osmocore/linuxlist.h>
-#include <osmocore/talloc.h>
-#include <osmocore/statistics.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/statistics.h>
static LLIST_HEAD(counters);
@@ -64,3 +63,13 @@ int counters_for_each(int (*handle_counter)(struct counter *, void *), void *dat
return rc;
}
+struct counter *counter_get_by_name(const char *name)
+{
+ struct counter *ctr;
+
+ llist_for_each_entry(ctr, &counters, list) {
+ if (!strcmp(ctr->name, name))
+ return ctr;
+ }
+ return NULL;
+}
diff --git a/src/shared/libosmocore/src/talloc.c b/src/shared/libosmocore/src/talloc.c
index 98c2ee0..d3a0690 100644
--- a/src/shared/libosmocore/src/talloc.c
+++ b/src/shared/libosmocore/src/talloc.c
@@ -48,14 +48,13 @@
#ifndef _TALLOC_SAMBA3
//#include "replace.h"
-#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdbool.h>
#define __USE_GNU
#include <string.h>
#undef __USE_GNU
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif /* not _TALLOC_SAMBA3 */
diff --git a/src/shared/libosmocore/src/timer.c b/src/shared/libosmocore/src/timer.c
index 37d7d16..9b2dd9e 100644
--- a/src/shared/libosmocore/src/timer.c
+++ b/src/shared/libosmocore/src/timer.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include <string.h>
-#include <osmocore/timer.h>
+#include <osmocom/core/timer.h>
static LLIST_HEAD(timer_list);
static struct timeval s_nearest_time;
diff --git a/src/shared/libosmocore/src/utils.c b/src/shared/libosmocore/src/utils.c
index 405039f..af1829c 100644
--- a/src/shared/libosmocore/src/utils.c
+++ b/src/shared/libosmocore/src/utils.c
@@ -4,7 +4,7 @@
#include <errno.h>
#include <stdio.h>
-#include <osmocore/utils.h>
+#include <osmocom/core/utils.h>
static char namebuf[255];
const char *get_value_string(const struct value_string *vs, uint32_t val)
@@ -95,6 +95,36 @@ static char *_hexdump(const unsigned char *buf, int len, char *delim)
return hexd_buff;
}
+char *ubit_dump(const uint8_t *bits, unsigned int len)
+{
+ int i;
+
+ if (len > sizeof(hexd_buff)-1)
+ len = sizeof(hexd_buff)-1;
+ memset(hexd_buff, 0, sizeof(hexd_buff));
+
+ for (i = 0; i < len; i++) {
+ char outch;
+ switch (bits[i]) {
+ case 0:
+ outch = '0';
+ break;
+ case 0xff:
+ outch = '?';
+ break;
+ case 1:
+ outch = '1';
+ break;
+ default:
+ outch = 'E';
+ break;
+ }
+ hexd_buff[i] = outch;
+ }
+ hexd_buff[sizeof(hexd_buff)-1] = 0;
+ return hexd_buff;
+}
+
char *hexdump(const unsigned char *buf, int len)
{
return _hexdump(buf, len, " ");
@@ -104,3 +134,25 @@ char *hexdump_nospc(const unsigned char *buf, int len)
{
return _hexdump(buf, len, "");
}
+
+#include "../config.h"
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+void osmo_str2lower(char *out, const char *in)
+{
+ unsigned int i;
+
+ for (i = 0; i < strlen(in); i++)
+ out[i] = tolower(in[i]);
+ out[strlen(in)] = '\0';
+}
+
+void osmo_str2upper(char *out, const char *in)
+{
+ unsigned int i;
+
+ for (i = 0; i < strlen(in); i++)
+ out[i] = toupper(in[i]);
+ out[strlen(in)] = '\0';
+}
+#endif /* HAVE_CTYPE_H */
diff --git a/src/shared/libosmocore/src/vty/buffer.c b/src/shared/libosmocore/src/vty/buffer.c
index a5655b9..e385f9f 100644
--- a/src/shared/libosmocore/src/vty/buffer.c
+++ b/src/shared/libosmocore/src/vty/buffer.c
@@ -28,7 +28,7 @@
#include <stddef.h>
#include <sys/uio.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/vty.h>
diff --git a/src/shared/libosmocore/src/vty/command.c b/src/shared/libosmocore/src/vty/command.c
index 7525df6..5dc1dd4 100644
--- a/src/shared/libosmocore/src/vty/command.c
+++ b/src/shared/libosmocore/src/vty/command.c
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#define CONFIGFILE_MASK 022
@@ -2180,6 +2180,9 @@ gDEFUN(config_exit,
case VTY_NODE:
vty->node = CONFIG_NODE;
break;
+ case CFG_LOG_NODE:
+ vty->node = CONFIG_NODE;
+ break;
default:
break;
}
@@ -2195,6 +2198,7 @@ gDEFUN(config_exit,
case ENABLE_NODE:
/* Nothing to do. */
break;
+ case CFG_LOG_NODE:
case CONFIG_NODE:
case VTY_NODE:
vty_config_unlock(vty);
diff --git a/src/shared/libosmocore/src/vty/logging_vty.c b/src/shared/libosmocore/src/vty/logging_vty.c
index 896d79a..b037a5b 100644
--- a/src/shared/libosmocore/src/vty/logging_vty.c
+++ b/src/shared/libosmocore/src/vty/logging_vty.c
@@ -22,8 +22,11 @@
#include <stdlib.h>
#include <string.h>
-#include <osmocore/talloc.h>
-#include <osmocore/logging.h>
+#include "../../config.h"
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/utils.h>
//#include <openbsc/vty.h>
@@ -33,9 +36,12 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
+#define LOG_STR "Configure logging sub-system\n"
+
extern const struct log_info *osmo_log_info;
-static void _vty_output(struct log_target *tgt, const char *line)
+static void _vty_output(struct log_target *tgt,
+ unsigned int level, const char *line)
{
struct vty *vty = tgt->tgt_vty.vty;
vty_out(vty, "%s", line);
@@ -79,6 +85,21 @@ DEFUN(enable_logging,
return CMD_SUCCESS;
}
+struct log_target *osmo_log_vty2tgt(struct vty *vty)
+{
+ struct telnet_connection *conn;
+
+ if (vty->node == CFG_LOG_NODE)
+ return vty->index;
+
+
+ conn = (struct telnet_connection *) vty->priv;
+ if (!conn->dbg)
+ vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+
+ return conn->dbg;
+}
+
DEFUN(logging_fltr_all,
logging_fltr_all_cmd,
"logging filter all (0|1)",
@@ -87,15 +108,12 @@ DEFUN(logging_fltr_all,
"Only print messages matched by other filters\n"
"Bypass filter and print all messages\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- log_set_all_filter(conn->dbg, atoi(argv[0]));
+ log_set_all_filter(tgt, atoi(argv[0]));
return CMD_SUCCESS;
}
@@ -106,15 +124,12 @@ DEFUN(logging_use_clr,
"Don't use color for printing messages\n"
"Use color for printing messages\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- log_set_use_color(conn->dbg, atoi(argv[0]));
+ log_set_use_color(tgt, atoi(argv[0]));
return CMD_SUCCESS;
}
@@ -125,73 +140,26 @@ DEFUN(logging_prnt_timestamp,
"Don't prefix each log message\n"
"Prefix each log message with current timestamp\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- log_set_print_timestamp(conn->dbg, atoi(argv[0]));
+ log_set_print_timestamp(tgt, atoi(argv[0]));
return CMD_SUCCESS;
}
-/* FIXME: those have to be kept in sync with the log levels and categories */
-#define VTY_DEBUG_CATEGORIES "(rll|cc|mm|rr|rsl|nm|sms|pag|mncc|inp|mi|mib|mux|meas|sccp|msc|mgcp|ho|db|ref|gprs|ns|bssgp|llc|sndcp|all)"
-#define CATEGORIES_HELP \
- "A-bis Radio Link Layer (RLL)\n" \
- "Layer3 Call Control (CC)\n" \
- "Layer3 Mobility Management (MM)\n" \
- "Layer3 Radio Resource (RR)\n" \
- "A-bis Radio Signalling Link (RSL)\n" \
- "A-bis Network Management / O&M (NM/OML)\n" \
- "Layer3 Short Messagaging Service (SMS)\n" \
- "Paging Subsystem\n" \
- "MNCC API for Call Control application\n" \
- "A-bis Input Subsystem\n" \
- "A-bis Input Driver for Signalling\n" \
- "A-bis Input Driver for B-Channel (voice data)\n" \
- "A-bis B-Channel / Sub-channel Multiplexer\n" \
- "Radio Measurements\n" \
- "SCCP\n" \
- "Mobile Switching Center\n" \
- "Media Gateway Control Protocol\n" \
- "Hand-over\n" \
- "Database Layer\n" \
- "Reference Counting\n" \
- "GPRS Core\n" \
- "GPRS Network Service (NS)\n" \
- "GPRS BSS Gateway Protocol (BSSGP)\n" \
- "GPRS Logical Link Control Protocol (LLC)\n" \
- "GPRS Sub-Network Dependent Control Protocol (SNDCP)\n" \
- "Global setting for all subsytems\n"
-
-#define VTY_DEBUG_LEVELS "(everything|debug|info|notice|error|fatal)"
-#define LEVELS_HELP \
- "Log simply everything\n" \
- "Log debug messages and higher levels\n" \
- "Log informational messages and higher levels\n" \
- "Log noticable messages and higher levels\n" \
- "Log error messages and higher levels\n" \
- "Log only fatal messages\n"
DEFUN(logging_level,
logging_level_cmd,
- "logging level " VTY_DEBUG_CATEGORIES " " VTY_DEBUG_LEVELS,
- LOGGING_STR
- "Set the log level for a specified category\n"
- CATEGORIES_HELP
- LEVELS_HELP)
+ NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
+ NULL) /* same thing for helpstr. */
{
- struct telnet_connection *conn;
int category = log_parse_category(argv[0]);
int level = log_parse_level(argv[1]);
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
if (level < 0) {
vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
@@ -200,7 +168,7 @@ DEFUN(logging_level,
/* Check for special case where we want to set global log level */
if (!strcmp(argv[0], "all")) {
- log_set_log_level(conn->dbg, level);
+ log_set_log_level(tgt, level);
return CMD_SUCCESS;
}
@@ -209,8 +177,8 @@ DEFUN(logging_level,
return CMD_WARNING;
}
- conn->dbg->categories[category].enabled = 1;
- conn->dbg->categories[category].loglevel = level;
+ tgt->categories[category].enabled = 1;
+ tgt->categories[category].loglevel = level;
return CMD_SUCCESS;
}
@@ -221,15 +189,12 @@ DEFUN(logging_set_category_mask,
LOGGING_STR
"Decide which categories to output.\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- log_parse_category_mask(conn->dbg, argv[0]);
+ log_parse_category_mask(tgt, argv[0]);
return CMD_SUCCESS;
}
@@ -239,17 +204,16 @@ DEFUN(diable_logging,
LOGGING_STR
"Disables logging to this vty\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
+ struct telnet_connection *conn = (struct telnet_connection *) vty->priv;
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- log_del_target(conn->dbg);
- talloc_free(conn->dbg);
+ log_del_target(tgt);
+ talloc_free(tgt);
conn->dbg = NULL;
+
return CMD_SUCCESS;
}
@@ -284,14 +248,12 @@ DEFUN(show_logging_vty,
SHOW_STR SHOW_LOG_STR
"Show current logging configuration for this vty\n")
{
- struct telnet_connection *conn;
+ struct log_target *tgt = osmo_log_vty2tgt(vty);
- conn = (struct telnet_connection *) vty->priv;
- if (!conn->dbg) {
- vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
+ if (!tgt)
return CMD_WARNING;
- }
- vty_print_logtarget(vty, osmo_log_info, conn->dbg);
+
+ vty_print_logtarget(vty, osmo_log_info, tgt);
return CMD_SUCCESS;
}
@@ -307,6 +269,8 @@ gDEFUN(cfg_description, cfg_description_cmd,
return CMD_WARNING;
}
+ if (*dptr)
+ talloc_free(*dptr);
*dptr = argv_concat(argv, argc, 0);
if (!dptr)
return CMD_WARNING;
@@ -334,7 +298,261 @@ gDEFUN(cfg_no_description, cfg_no_description_cmd,
return CMD_SUCCESS;
}
-void logging_vty_add_cmds()
+/* Support for configuration of log targets != the current vty */
+
+struct cmd_node cfg_log_node = {
+ CFG_LOG_NODE,
+ "%s(config-log)# ",
+ 1
+};
+
+#ifdef HAVE_SYSLOG_H
+
+#include <syslog.h>
+
+static const int local_sysl_map[] = {
+ [0] = LOG_LOCAL0,
+ [1] = LOG_LOCAL1,
+ [2] = LOG_LOCAL2,
+ [3] = LOG_LOCAL3,
+ [4] = LOG_LOCAL4,
+ [5] = LOG_LOCAL5,
+ [6] = LOG_LOCAL6,
+ [7] = LOG_LOCAL7
+};
+
+/* From VTY core code */
+extern struct host host;
+
+static int _cfg_log_syslog(struct vty *vty, int facility)
+{
+ struct log_target *tgt;
+
+ /* First delete the old syslog target, if any */
+ tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
+ if (tgt)
+ log_target_destroy(tgt);
+
+ tgt = log_target_create_syslog(host.app_info->name, 0, facility);
+ if (!tgt) {
+ vty_out(vty, "%% Unable to open syslog%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ log_add_target(tgt);
+
+ vty->index = tgt;
+ vty->node = CFG_LOG_NODE;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_log_syslog_local, cfg_log_syslog_local_cmd,
+ "log syslog local <0-7>",
+ LOG_STR "Logging via syslog\n" "Syslog LOCAL facility\n"
+ "Local facility number\n")
+{
+ int local = atoi(argv[0]);
+ int facility = local_sysl_map[local];
+
+ return _cfg_log_syslog(vty, facility);
+}
+
+static struct value_string sysl_level_names[] = {
+ { LOG_AUTHPRIV, "authpriv" },
+ { LOG_CRON, "cron" },
+ { LOG_DAEMON, "daemon" },
+ { LOG_FTP, "ftp" },
+ { LOG_LPR, "lpr" },
+ { LOG_MAIL, "mail" },
+ { LOG_NEWS, "news" },
+ { LOG_USER, "user" },
+ { LOG_UUCP, "uucp" },
+ /* only for value -> string conversion */
+ { LOG_LOCAL0, "local 0" },
+ { LOG_LOCAL1, "local 1" },
+ { LOG_LOCAL2, "local 2" },
+ { LOG_LOCAL3, "local 3" },
+ { LOG_LOCAL4, "local 4" },
+ { LOG_LOCAL5, "local 5" },
+ { LOG_LOCAL6, "local 6" },
+ { LOG_LOCAL7, "local 7" },
+ { 0, NULL }
+};
+
+DEFUN(cfg_log_syslog, cfg_log_syslog_cmd,
+ "log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)",
+ LOG_STR "Logging via syslog\n")
+{
+ int facility = get_string_value(sysl_level_names, argv[0]);
+
+ return _cfg_log_syslog(vty, facility);
+}
+
+DEFUN(cfg_no_log_syslog, cfg_no_log_syslog_cmd,
+ "no log syslog",
+ NO_STR LOG_STR "Logging via syslog\n")
+{
+ struct log_target *tgt;
+
+ tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
+ if (!tgt) {
+ vty_out(vty, "%% No syslog target found%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_target_destroy(tgt);
+
+ return CMD_SUCCESS;
+}
+#endif /* HAVE_SYSLOG_H */
+
+DEFUN(cfg_log_stderr, cfg_log_stderr_cmd,
+ "log stderr",
+ LOG_STR "Logging via STDERR of the process\n")
+{
+ struct log_target *tgt;
+
+ tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
+ if (!tgt) {
+ tgt = log_target_create_stderr();
+ if (!tgt) {
+ vty_out(vty, "%% Unable to create stderr log%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ log_add_target(tgt);
+ }
+
+ vty->index = tgt;
+ vty->node = CFG_LOG_NODE;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_log_stderr, cfg_no_log_stderr_cmd,
+ "no log stderr",
+ NO_STR LOG_STR "Logging via STDERR of the process\n")
+{
+ struct log_target *tgt;
+
+ tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
+ if (!tgt) {
+ vty_out(vty, "%% No stderr logging active%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_target_destroy(tgt);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_log_file, cfg_log_file_cmd,
+ "log file .FILENAME",
+ LOG_STR "Logging to text file\n" "Filename\n")
+{
+ const char *fname = argv[0];
+ struct log_target *tgt;
+
+ tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
+ if (!tgt) {
+ tgt = log_target_create_file(fname);
+ if (!tgt) {
+ vty_out(vty, "%% Unable to create file `%s'%s",
+ fname, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ log_add_target(tgt);
+ }
+
+ vty->index = tgt;
+ vty->node = CFG_LOG_NODE;
+
+ return CMD_SUCCESS;
+}
+
+
+DEFUN(cfg_no_log_file, cfg_no_log_file_cmd,
+ "no log file .FILENAME",
+ NO_STR LOG_STR "Logging to text file\n" "Filename\n")
+{
+ const char *fname = argv[0];
+ struct log_target *tgt;
+
+ tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
+ if (!tgt) {
+ vty_out(vty, "%% No such log file `%s'%s",
+ fname, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ log_target_destroy(tgt);
+
+ return CMD_SUCCESS;
+}
+
+static int config_write_log_single(struct vty *vty, struct log_target *tgt)
+{
+ int i;
+ char level_lower[32];
+
+ switch (tgt->type) {
+ case LOG_TGT_TYPE_VTY:
+ return 1;
+ break;
+ case LOG_TGT_TYPE_STDERR:
+ vty_out(vty, "log stderr%s", VTY_NEWLINE);
+ break;
+ case LOG_TGT_TYPE_SYSLOG:
+#ifdef HAVE_SYSLOG_H
+ vty_out(vty, "log syslog %s%s",
+ get_value_string(sysl_level_names,
+ tgt->tgt_syslog.facility),
+ VTY_NEWLINE);
+#endif
+ break;
+ case LOG_TGT_TYPE_FILE:
+ vty_out(vty, "log file %s%s", tgt->tgt_file.fname, VTY_NEWLINE);
+ break;
+ }
+
+ vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0,
+ VTY_NEWLINE);
+ vty_out(vty, " logging timestamp %u%s", tgt->print_timestamp ? 1 : 0,
+ VTY_NEWLINE);
+
+ /* stupid old osmo logging API uses uppercase strings... */
+ osmo_str2lower(level_lower, log_level_str(tgt->loglevel));
+ vty_out(vty, " logging level all %s%s", level_lower, VTY_NEWLINE);
+
+ for (i = 0; i < osmo_log_info->num_cat; i++) {
+ const struct log_category *cat = &tgt->categories[i];
+ char cat_lower[32];
+
+ /* stupid old osmo logging API uses uppercase strings... */
+ osmo_str2lower(cat_lower, osmo_log_info->cat[i].name+1);
+ osmo_str2lower(level_lower, log_level_str(cat->loglevel));
+
+ vty_out(vty, " logging level %s %s%s", cat_lower, level_lower,
+ VTY_NEWLINE);
+ }
+
+ /* FIXME: levels */
+
+ return 1;
+}
+
+static int config_write_log(struct vty *vty)
+{
+ struct log_target *dbg = vty->index;
+
+ llist_for_each_entry(dbg, &osmo_log_target_list, entry)
+ config_write_log_single(vty, dbg);
+
+ return 1;
+}
+
+void logging_vty_add_cmds(const struct log_info *cat)
{
install_element_ve(&enable_logging_cmd);
install_element_ve(&disable_logging_cmd);
@@ -342,6 +560,26 @@ void logging_vty_add_cmds()
install_element_ve(&logging_use_clr_cmd);
install_element_ve(&logging_prnt_timestamp_cmd);
install_element_ve(&logging_set_category_mask_cmd);
+
+ /* Logging level strings are generated dynamically. */
+ logging_level_cmd.string = log_vty_command_string(cat);
+ logging_level_cmd.doc = log_vty_command_description(cat);
install_element_ve(&logging_level_cmd);
install_element_ve(&show_logging_vty_cmd);
+
+ install_node(&cfg_log_node, config_write_log);
+ install_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
+ install_element(CFG_LOG_NODE, &logging_use_clr_cmd);
+ install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
+ install_element(CFG_LOG_NODE, &logging_level_cmd);
+
+ install_element(CONFIG_NODE, &cfg_log_stderr_cmd);
+ install_element(CONFIG_NODE, &cfg_no_log_stderr_cmd);
+ install_element(CONFIG_NODE, &cfg_log_file_cmd);
+ install_element(CONFIG_NODE, &cfg_no_log_file_cmd);
+#ifdef HAVE_SYSLOG_H
+ install_element(CONFIG_NODE, &cfg_log_syslog_cmd);
+ install_element(CONFIG_NODE, &cfg_log_syslog_local_cmd);
+ install_element(CONFIG_NODE, &cfg_no_log_syslog_cmd);
+#endif
}
diff --git a/src/shared/libosmocore/src/vty/telnet_interface.c b/src/shared/libosmocore/src/vty/telnet_interface.c
index 098fa2e..0d45d61 100644
--- a/src/shared/libosmocore/src/vty/telnet_interface.c
+++ b/src/shared/libosmocore/src/vty/telnet_interface.c
@@ -25,9 +25,9 @@
#include <string.h>
#include <unistd.h>
-#include <osmocore/msgb.h>
-#include <osmocore/talloc.h>
-#include <osmocore/logging.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/logging.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/buffer.h>
diff --git a/src/shared/libosmocore/src/vty/utils.c b/src/shared/libosmocore/src/vty/utils.c
index e163526..7797e62 100644
--- a/src/shared/libosmocore/src/vty/utils.c
+++ b/src/shared/libosmocore/src/vty/utils.c
@@ -23,10 +23,10 @@
#include <stdint.h>
#include <inttypes.h>
-#include <osmocore/linuxlist.h>
-#include <osmocore/talloc.h>
-#include <osmocore/timer.h>
-#include <osmocore/rate_ctr.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/rate_ctr.h>
#include <osmocom/vty/vty.h>
diff --git a/src/shared/libosmocore/src/vty/vector.c b/src/shared/libosmocore/src/vty/vector.c
index 0343163..4012f24 100644
--- a/src/shared/libosmocore/src/vty/vector.c
+++ b/src/shared/libosmocore/src/vty/vector.c
@@ -24,7 +24,7 @@
#include <osmocom/vty/vector.h>
#include <osmocom/vty/vty.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#include <memory.h>
void *tall_vty_vec_ctx;
diff --git a/src/shared/libosmocore/src/vty/vty.c b/src/shared/libosmocore/src/vty/vty.c
index a5b16dc..a1f0304 100644
--- a/src/shared/libosmocore/src/vty/vty.c
+++ b/src/shared/libosmocore/src/vty/vty.c
@@ -16,7 +16,7 @@
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#define SYSCONFDIR "/usr/local/etc"
@@ -765,6 +765,9 @@ static void vty_end_config(struct vty *vty)
vty_config_unlock(vty);
vty->node = ENABLE_NODE;
break;
+ case CFG_LOG_NODE:
+ vty->node = CONFIG_NODE;
+ break;
default:
/* Unknown node, we have to ignore it. */
break;
@@ -1129,6 +1132,9 @@ static void vty_stop_input(struct vty *vty)
vty_config_unlock(vty);
vty->node = ENABLE_NODE;
break;
+ case CFG_LOG_NODE:
+ vty->node = CONFIG_NODE;
+ break;
default:
/* Unknown node, we have to ignore it. */
break;
diff --git a/src/shared/libosmocore/src/write_queue.c b/src/shared/libosmocore/src/write_queue.c
index 618a8c0..0642aad 100644
--- a/src/shared/libosmocore/src/write_queue.c
+++ b/src/shared/libosmocore/src/write_queue.c
@@ -21,7 +21,7 @@
*
*/
-#include <osmocore/write_queue.h>
+#include <osmocom/core/write_queue.h>
int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what)
{
@@ -39,16 +39,18 @@ int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what)
struct msgb *msg;
fd->when &= ~BSC_FD_WRITE;
- msg = msgb_dequeue(&queue->msg_queue);
- if (!msg)
- return -1;
- --queue->current_length;
- queue->write_cb(fd, msg);
- msgb_free(msg);
+ /* the queue might have been emptied */
+ if (!llist_empty(&queue->msg_queue)) {
+ --queue->current_length;
+
+ msg = msgb_dequeue(&queue->msg_queue);
+ queue->write_cb(fd, msg);
+ msgb_free(msg);
- if (!llist_empty(&queue->msg_queue))
- fd->when |= BSC_FD_WRITE;
+ if (!llist_empty(&queue->msg_queue))
+ fd->when |= BSC_FD_WRITE;
+ }
}
return 0;
diff --git a/src/shared/libosmocore/tests/msgfile/msgfile_test.c b/src/shared/libosmocore/tests/msgfile/msgfile_test.c
index a82ac51..4637cea 100644
--- a/src/shared/libosmocore/tests/msgfile/msgfile_test.c
+++ b/src/shared/libosmocore/tests/msgfile/msgfile_test.c
@@ -19,7 +19,7 @@
*
*/
-#include <osmocore/msgfile.h>
+#include <osmocom/core/msgfile.h>
#include <stdio.h>
diff --git a/src/shared/libosmocore/tests/sms/Makefile.am b/src/shared/libosmocore/tests/sms/Makefile.am
index a8f1ff6..fa4e387 100644
--- a/src/shared/libosmocore/tests/sms/Makefile.am
+++ b/src/shared/libosmocore/tests/sms/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
noinst_PROGRAMS = sms_test
sms_test_SOURCES = sms_test.c
-sms_test_LDADD = $(top_builddir)/src/libosmocore.la
+sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/src/shared/libosmocore/tests/sms/sms_test.c b/src/shared/libosmocore/tests/sms/sms_test.c
index 9d87b5b..b4ed631 100644
--- a/src/shared/libosmocore/tests/sms/sms_test.c
+++ b/src/shared/libosmocore/tests/sms/sms_test.c
@@ -22,10 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <osmocore/msgb.h>
-#include <osmocore/gsm_utils.h>
-#include <osmocore/utils.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/core/utils.h>
struct test_case {
const uint8_t *input;
diff --git a/src/shared/libosmocore/tests/smscb/Makefile.am b/src/shared/libosmocore/tests/smscb/Makefile.am
index 1d0e538..9a6fb4f 100644
--- a/src/shared/libosmocore/tests/smscb/Makefile.am
+++ b/src/shared/libosmocore/tests/smscb/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
noinst_PROGRAMS = smscb_test
smscb_test_SOURCES = smscb_test.c
-smscb_test_LDADD = $(top_builddir)/src/libosmocore.la
+smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/src/shared/libosmocore/tests/smscb/smscb_test.c b/src/shared/libosmocore/tests/smscb/smscb_test.c
index 627d5a1..e10e12d 100644
--- a/src/shared/libosmocore/tests/smscb/smscb_test.c
+++ b/src/shared/libosmocore/tests/smscb/smscb_test.c
@@ -18,7 +18,7 @@
*
*/
-#include <osmocore/protocol/gsm_03_41.h>
+#include <osmocom/gsm/protocol/gsm_03_41.h>
#include <stdio.h>
diff --git a/src/shared/libosmocore/tests/timer/timer_test.c b/src/shared/libosmocore/tests/timer/timer_test.c
index 1b458d8..30b08ad 100644
--- a/src/shared/libosmocore/tests/timer/timer_test.c
+++ b/src/shared/libosmocore/tests/timer/timer_test.c
@@ -20,8 +20,8 @@
#include <stdio.h>
-#include <osmocore/timer.h>
-#include <osmocore/select.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/select.h>
#include "../../config.h"
diff --git a/src/shared/libosmocore/tests/ussd/Makefile.am b/src/shared/libosmocore/tests/ussd/Makefile.am
index d29506c..ef9aa49 100644
--- a/src/shared/libosmocore/tests/ussd/Makefile.am
+++ b/src/shared/libosmocore/tests/ussd/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
noinst_PROGRAMS = ussd_test
ussd_test_SOURCES = ussd_test.c
-ussd_test_LDADD = $(top_builddir)/src/libosmocore.la
+ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/src/shared/libosmocore/tests/ussd/ussd_test.c b/src/shared/libosmocore/tests/ussd/ussd_test.c
index bddbbcb..6d2a8c9 100644
--- a/src/shared/libosmocore/tests/ussd/ussd_test.c
+++ b/src/shared/libosmocore/tests/ussd/ussd_test.c
@@ -19,7 +19,7 @@
*
*/
-#include <osmocore/gsm0480.h>
+#include <osmocom/gsm/gsm0480.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>