summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/include
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 /src/shared/libosmocore/include
parentd9639bb010d05a96a6cbced94668c5754a4f0de9 (diff)
parent28dbfe9bf7a799ab1da2563fd5e007d007b54168 (diff)
Merge commit '28dbfe9bf7a799ab1da2563fd5e007d007b54168'
Diffstat (limited to 'src/shared/libosmocore/include')
-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
52 files changed, 195 insertions, 59 deletions
diff --git a/src/shared/libosmocore/include/Makefile.am b/src/shared/libosmocore/include/Makefile.am
index 185c6968..3578a80e 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 ec548fbd..21f4f2d0 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 00000000..6109f478
--- /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 00000000..bbbb2c28
--- /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 00000000..eb22d07c
--- /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 42977fb2..bbe1641b 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 7a512490..7a512490 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 3f384a4f..236b25ac 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 96449443..96449443 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 fb99c5ec..fb99c5ec 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 7f33155a..db029402 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 6fd24c7f..57b5d7f4 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 92caa9fc..92caa9fc 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 c5a83778..c5a83778 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 98f9b56d..98f9b56d 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 2d663828..2d663828 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 f887d9a7..ebb8646c 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 2d8b3ec0..5ca21c3e 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 02d83d2e..02d83d2e 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 1d56054a..2c159657 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 f7f7643b..f7f7643b 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 fee888bf..19664781 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 3574f7f8..252228de 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 ef244c32..3b730c77 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 3e514ec7..30510711 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 00000000..8685fc9a
--- /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 c37808f0..c37808f0 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 b504332e..d6626d60 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 1d853775..1d853775 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 ffe0399b..1e9403bc 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 fa66159f..f4fce25c 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 0aadd2e4..19adb70a 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 a094bb9b..a094bb9b 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 00000000..8483f10a
--- /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 3b1b7c9f..54365cbc 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 3ad7dfdc..3ad7dfdc 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 c6a2b193..c6a2b193 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 9b1538a5..9b1538a5 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 fa5c9451..fa5c9451 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 6b8f9359..6b8f9359 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 74a4083b..74a4083b 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 9cae45da..b8b00f3f 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 54d67032..7e46330f 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 415509dc..415509dc 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 4cfce872..552af2bd 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 d2f0616d..83d00107 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 69e9e772..caf04142 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 45d74fdf..e0011bf9 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 00000000..707f82fa
--- /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 444e6497..0c034e41 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 2efaa96b..00000000
--- 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 03a4849d..00000000
--- 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