summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/include/osmocom/core
diff options
context:
space:
mode:
authorPablo Neira Ayuso2011-05-15 14:39:08 +0200
committerPablo Neira Ayuso2011-05-15 14:39:08 +0200
commit6f9af5945e855dab4810641dc72eff6a24c30a77 (patch)
treeeb2336816be448ef94517f849987f6e74fd4c7b8 /src/shared/libosmocore/include/osmocom/core
parenttarget/boards: add infrastructure for loaders for Mediatek platforms (diff)
parentapp: Introduce some routines to help with application startup (diff)
downloadosmocom-6f9af5945e855dab4810641dc72eff6a24c30a77.tar.gz
osmocom-6f9af5945e855dab4810641dc72eff6a24c30a77.tar.xz
osmocom-6f9af5945e855dab4810641dc72eff6a24c30a77.zip
Merge commit 'ba01fa44feb6deb0f0359f381eafe866991c06c1' into pablo/namespace
Diffstat (limited to 'src/shared/libosmocore/include/osmocom/core')
-rw-r--r--src/shared/libosmocore/include/osmocom/core/Makefile.am2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/application.h16
-rw-r--r--src/shared/libosmocore/include/osmocom/core/backtrace.h2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/conv.h101
-rw-r--r--src/shared/libosmocore/include/osmocom/core/crc16.h8
-rw-r--r--src/shared/libosmocore/include/osmocom/core/gsmtap_util.h4
-rw-r--r--src/shared/libosmocore/include/osmocom/core/msgb.h2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/msgfile.h8
-rw-r--r--src/shared/libosmocore/include/osmocom/core/panic.h4
-rw-r--r--src/shared/libosmocore/include/osmocom/core/plugin.h2
-rw-r--r--src/shared/libosmocore/include/osmocom/core/select.h10
-rw-r--r--src/shared/libosmocore/include/osmocom/core/signal.h15
-rw-r--r--src/shared/libosmocore/include/osmocom/core/statistics.h16
-rw-r--r--src/shared/libosmocore/include/osmocom/core/timer.h20
-rw-r--r--src/shared/libosmocore/include/osmocom/core/utils.h14
-rw-r--r--src/shared/libosmocore/include/osmocom/core/write_queue.h22
16 files changed, 183 insertions, 63 deletions
diff --git a/src/shared/libosmocore/include/osmocom/core/Makefile.am b/src/shared/libosmocore/include/osmocom/core/Makefile.am
index 6109f47..3698873 100644
--- a/src/shared/libosmocore/include/osmocom/core/Makefile.am
+++ b/src/shared/libosmocore/include/osmocom/core/Makefile.am
@@ -3,7 +3,7 @@ osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h bits.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
+ backtrace.h conv.h application.h
if ENABLE_TALLOC
osmocore_HEADERS += talloc.h
diff --git a/src/shared/libosmocore/include/osmocom/core/application.h b/src/shared/libosmocore/include/osmocom/core/application.h
new file mode 100644
index 0000000..c1642ec
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/application.h
@@ -0,0 +1,16 @@
+#ifndef OSMO_APPLICATION_H
+#define OSMO_APPLICATION_H
+
+/**
+ * Routines for helping with the application setup.
+ */
+
+struct log_info;
+struct log_target;
+
+extern struct log_target *osmo_stderr_target;
+
+void osmo_init_ignore_signals(void);
+int osmo_init_logging(const struct log_info *);
+
+#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/backtrace.h b/src/shared/libosmocore/include/osmocom/core/backtrace.h
index bbbb2c2..5a8a816 100644
--- a/src/shared/libosmocore/include/osmocom/core/backtrace.h
+++ b/src/shared/libosmocore/include/osmocom/core/backtrace.h
@@ -1,6 +1,6 @@
#ifndef _OSMO_BACKTRACE_H_
#define _OSMO_BACKTRACE_H_
-void generate_backtrace();
+void osmo_generate_backtrace();
#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/conv.h b/src/shared/libosmocore/include/osmocom/core/conv.h
new file mode 100644
index 0000000..af676ee
--- /dev/null
+++ b/src/shared/libosmocore/include/osmocom/core/conv.h
@@ -0,0 +1,101 @@
+/*
+ * conv.h
+ *
+ * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
+ *
+ * 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.
+ */
+
+#ifndef __OSMO_CONV_H__
+#define __OSMO_CONV_H__
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+
+struct osmo_conv_code {
+ int N;
+ int K;
+ int len;
+
+ const uint8_t (*next_output)[2];
+ const uint8_t (*next_state)[2];
+
+ const uint8_t *next_term_output;
+ const uint8_t *next_term_state;
+
+ const int *puncture;
+};
+
+
+/* Encoding */
+
+ /* Low level API */
+struct osmo_conv_encoder {
+ const struct osmo_conv_code *code;
+ int i_idx; /* Next input bit index */
+ int p_idx; /* Current puncture index */
+ uint8_t state; /* Current state */
+};
+
+void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
+ const struct osmo_conv_code *code);
+int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
+ const ubit_t *input, ubit_t *output, int n);
+int osmo_conv_encode_finish(struct osmo_conv_encoder *encoder, ubit_t *output);
+
+ /* All-in-one */
+int osmo_conv_encode(const struct osmo_conv_code *code,
+ const ubit_t *input, ubit_t *output);
+
+
+/* Decoding */
+
+ /* Low level API */
+struct osmo_conv_decoder {
+ const struct osmo_conv_code *code;
+
+ int n_states;
+
+ int len; /* Max o_idx (excl. termination) */
+
+ int o_idx; /* output index */
+ int p_idx; /* puncture index */
+
+ unsigned int *ae; /* accumulater error */
+ unsigned int *ae_next; /* next accumulated error (tmp in scan) */
+ uint8_t *state_history; /* state history [len][n_states] */
+};
+
+void osmo_conv_decode_init(struct osmo_conv_decoder *decoder,
+ const struct osmo_conv_code *code, int len);
+void osmo_conv_decode_reset(struct osmo_conv_decoder *decoder);
+void osmo_conv_decode_deinit(struct osmo_conv_decoder *decoder);
+
+int osmo_conv_decode_scan(struct osmo_conv_decoder *decoder,
+ const sbit_t *input, int n);
+int osmo_conv_decode_finish(struct osmo_conv_decoder *decoder,
+ const sbit_t *input);
+int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder,
+ ubit_t *output, int has_finish);
+
+ /* All-in-one */
+int osmo_conv_decode(const struct osmo_conv_code *code,
+ const sbit_t *input, ubit_t *output);
+
+
+#endif /* __OSMO_CONV_H__ */
diff --git a/src/shared/libosmocore/include/osmocom/core/crc16.h b/src/shared/libosmocore/include/osmocom/core/crc16.h
index 7a51249..0e52417 100644
--- a/src/shared/libosmocore/include/osmocom/core/crc16.h
+++ b/src/shared/libosmocore/include/osmocom/core/crc16.h
@@ -22,13 +22,13 @@
#include <sys/types.h>
-extern uint16_t const crc16_table[256];
+extern uint16_t const osmo_crc16_table[256];
-extern uint16_t crc16(uint16_t crc, const uint8_t *buffer, size_t len);
+extern uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len);
-static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data)
+static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data)
{
- return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
+ return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff];
}
#endif /* __CRC16_H */
diff --git a/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h b/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h
index 9644944..785f5e5 100644
--- a/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h
+++ b/src/shared/libosmocore/include/osmocom/core/gsmtap_util.h
@@ -18,4 +18,8 @@ int gsmtap_sendmsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss,
int gsmtap_init(uint32_t dst_ip);
+/* Create a local 'gsmtap sink' avoiding the UDP packets being rejected
+ * with ICMP reject messages */
+int gsmtap_sink_init(uint32_t bind_ip);
+
#endif /* _GSMTAP_UTIL_H */
diff --git a/src/shared/libosmocore/include/osmocom/core/msgb.h b/src/shared/libosmocore/include/osmocom/core/msgb.h
index 57b5d7f..8665c2b 100644
--- a/src/shared/libosmocore/include/osmocom/core/msgb.h
+++ b/src/shared/libosmocore/include/osmocom/core/msgb.h
@@ -181,7 +181,7 @@ 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);
+ osmo_static_assert(size > headroom, headroom_bigger);
struct msgb *msg = msgb_alloc(size, name);
if (msg)
diff --git a/src/shared/libosmocore/include/osmocom/core/msgfile.h b/src/shared/libosmocore/include/osmocom/core/msgfile.h
index 92caa9f..c5e67a4 100644
--- a/src/shared/libosmocore/include/osmocom/core/msgfile.h
+++ b/src/shared/libosmocore/include/osmocom/core/msgfile.h
@@ -22,12 +22,12 @@
#ifndef MSG_FILE_H
#define MSG_FILE_H
-#include "linuxlist.h"
+#include <osmocom/core/linuxlist.h>
/**
* One message in the list.
*/
-struct msg_entry {
+struct osmo_config_entry {
struct llist_head list;
/* number for everyone to use */
@@ -40,10 +40,10 @@ struct msg_entry {
char *text;
};
-struct msg_entries {
+struct osmo_config_list {
struct llist_head entry;
};
-struct msg_entries *msg_entry_parse(void *ctx, const char *filename);
+struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename);
#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/panic.h b/src/shared/libosmocore/include/osmocom/core/panic.h
index c5a8377..c28a844 100644
--- a/src/shared/libosmocore/include/osmocom/core/panic.h
+++ b/src/shared/libosmocore/include/osmocom/core/panic.h
@@ -5,7 +5,7 @@
typedef void (*osmo_panic_handler_t)(const char *fmt, va_list args);
-void osmo_panic(const char *fmt, ...);
-void osmo_set_panic_handler(osmo_panic_handler_t h);
+extern void osmo_panic(const char *fmt, ...);
+extern void osmo_set_panic_handler(osmo_panic_handler_t h);
#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/plugin.h b/src/shared/libosmocore/include/osmocom/core/plugin.h
index 98f9b56..6c0eccc 100644
--- a/src/shared/libosmocore/include/osmocom/core/plugin.h
+++ b/src/shared/libosmocore/include/osmocom/core/plugin.h
@@ -1,6 +1,6 @@
#ifndef _OSMO_PLUGIN_H
#define _OSMO_PLUGIN_H
-int plugin_load_all(const char *directory);
+int osmo_plugin_load_all(const char *directory);
#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/select.h b/src/shared/libosmocore/include/osmocom/core/select.h
index 5ca21c3..476c564 100644
--- a/src/shared/libosmocore/include/osmocom/core/select.h
+++ b/src/shared/libosmocore/include/osmocom/core/select.h
@@ -7,16 +7,16 @@
#define BSC_FD_WRITE 0x0002
#define BSC_FD_EXCEPT 0x0004
-struct bsc_fd {
+struct osmo_fd {
struct llist_head list;
int fd;
unsigned int when;
- int (*cb)(struct bsc_fd *fd, unsigned int what);
+ int (*cb)(struct osmo_fd *fd, unsigned int what);
void *data;
unsigned int priv_nr;
};
-int bsc_register_fd(struct bsc_fd *fd);
-void bsc_unregister_fd(struct bsc_fd *fd);
-int bsc_select_main(int polling);
+int osmo_fd_register(struct osmo_fd *fd);
+void osmo_fd_unregister(struct osmo_fd *fd);
+int osmo_select_main(int polling);
#endif /* _BSC_SELECT_H */
diff --git a/src/shared/libosmocore/include/osmocom/core/signal.h b/src/shared/libosmocore/include/osmocom/core/signal.h
index 02d83d2..535fd18 100644
--- a/src/shared/libosmocore/include/osmocom/core/signal.h
+++ b/src/shared/libosmocore/include/osmocom/core/signal.h
@@ -1,15 +1,14 @@
-#ifndef OSMOCORE_SIGNAL_H
-#define OSMOCORE_SIGNAL_H
+#ifndef OSMO_SIGNAL_H
+#define OSMO_SIGNAL_H
-typedef int signal_cbfn(unsigned int subsys, unsigned int signal,
- void *handler_data, void *signal_data);
+typedef int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data);
/* Management */
-int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
-void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
+int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
+void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data);
/* Dispatch */
-void dispatch_signal(unsigned int subsys, unsigned int signal, void *signal_data);
+void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data);
-#endif /* OSMOCORE_SIGNAL_H */
+#endif /* OSMO_SIGNAL_H */
diff --git a/src/shared/libosmocore/include/osmocom/core/statistics.h b/src/shared/libosmocore/include/osmocom/core/statistics.h
index 2c15965..1849327 100644
--- a/src/shared/libosmocore/include/osmocom/core/statistics.h
+++ b/src/shared/libosmocore/include/osmocom/core/statistics.h
@@ -1,33 +1,33 @@
#ifndef _STATISTICS_H
#define _STATISTICS_H
-struct counter {
+struct osmo_counter {
struct llist_head list;
const char *name;
const char *description;
unsigned long value;
};
-static inline void counter_inc(struct counter *ctr)
+static inline void osmo_counter_inc(struct osmo_counter *ctr)
{
ctr->value++;
}
-static inline unsigned long counter_get(struct counter *ctr)
+static inline unsigned long osmo_counter_get(struct osmo_counter *ctr)
{
return ctr->value;
}
-static inline void counter_reset(struct counter *ctr)
+static inline void osmo_counter_reset(struct osmo_counter *ctr)
{
ctr->value = 0;
}
-struct counter *counter_alloc(const char *name);
-void counter_free(struct counter *ctr);
+struct osmo_counter *osmo_counter_alloc(const char *name);
+void osmo_counter_free(struct osmo_counter *ctr);
-int counters_for_each(int (*handle_counter)(struct counter *, void *), void *data);
+int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
-struct counter *counter_get_by_name(const char *name);
+struct osmo_counter *osmo_counter_get_by_name(const char *name);
#endif /* _STATISTICS_H */
diff --git a/src/shared/libosmocore/include/osmocom/core/timer.h b/src/shared/libosmocore/include/osmocom/core/timer.h
index 1966478..db2ecbf 100644
--- a/src/shared/libosmocore/include/osmocom/core/timer.h
+++ b/src/shared/libosmocore/include/osmocom/core/timer.h
@@ -27,7 +27,7 @@
/**
* Timer management:
- * - Create a struct timer_list
+ * - Create a struct osmo_timer_list
* - Fill out timeout and use add_timer or
* use schedule_timer to schedule a timer in
* x seconds and microseconds from now...
@@ -41,7 +41,7 @@
* the timers.
*
*/
-struct timer_list {
+struct osmo_timer_list {
struct llist_head entry;
struct timeval timeout;
unsigned int active : 1;
@@ -55,18 +55,18 @@ struct timer_list {
/**
* timer management
*/
-void bsc_add_timer(struct timer_list *timer);
-void bsc_schedule_timer(struct timer_list *timer, int seconds, int microseconds);
-void bsc_del_timer(struct timer_list *timer);
-int bsc_timer_pending(struct timer_list *timer);
+void osmo_timer_add(struct osmo_timer_list *timer);
+void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds);
+void osmo_timer_del(struct osmo_timer_list *timer);
+int osmo_timer_pending(struct osmo_timer_list *timer);
/**
* internal timer list management
*/
-struct timeval *bsc_nearest_timer();
-void bsc_prepare_timers();
-int bsc_update_timers();
-int bsc_timer_check(void);
+struct timeval *osmo_timers_nearest();
+void osmo_timers_prepare();
+int osmo_timers_update();
+int osmo_timers_check(void);
#endif
diff --git a/src/shared/libosmocore/include/osmocom/core/utils.h b/src/shared/libosmocore/include/osmocom/core/utils.h
index 252228d..0f1ea3b 100644
--- a/src/shared/libosmocore/include/osmocom/core/utils.h
+++ b/src/shared/libosmocore/include/osmocom/core/utils.h
@@ -13,16 +13,16 @@ struct value_string {
const char *get_value_string(const struct value_string *vs, uint32_t val);
int get_string_value(const struct value_string *vs, const char *str);
-char bcd2char(uint8_t bcd);
+char osmo_bcd2char(uint8_t bcd);
/* only works for numbers in ascci */
-uint8_t char2bcd(char c);
+uint8_t osmo_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);
+int osmo_hexparse(const char *str, uint8_t *b, int max_len);
+char *osmo_hexdump(const unsigned char *buf, int len);
+char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len);
+char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);
-#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
+#define osmo_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);
diff --git a/src/shared/libosmocore/include/osmocom/core/write_queue.h b/src/shared/libosmocore/include/osmocom/core/write_queue.h
index 3b730c7..41748d7 100644
--- a/src/shared/libosmocore/include/osmocom/core/write_queue.h
+++ b/src/shared/libosmocore/include/osmocom/core/write_queue.h
@@ -20,27 +20,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
-#ifndef write_queue_h
-#define write_queue_h
+#ifndef OSMO_WQUEUE_H
+#define OSMO_WQUEUE_H
#include <osmocom/core/select.h>
#include <osmocom/core/msgb.h>
-struct write_queue {
- struct bsc_fd bfd;
+struct osmo_wqueue {
+ struct osmo_fd bfd;
unsigned int max_length;
unsigned int current_length;
struct llist_head msg_queue;
- int (*read_cb)(struct bsc_fd *fd);
- int (*write_cb)(struct bsc_fd *fd, struct msgb *msg);
- int (*except_cb)(struct bsc_fd *fd);
+ int (*read_cb)(struct osmo_fd *fd);
+ int (*write_cb)(struct osmo_fd *fd, struct msgb *msg);
+ int (*except_cb)(struct osmo_fd *fd);
};
-void write_queue_init(struct write_queue *queue, int max_length);
-void write_queue_clear(struct write_queue *queue);
-int write_queue_enqueue(struct write_queue *queue, struct msgb *data);
-int write_queue_bfd_cb(struct bsc_fd *fd, unsigned int what);
+void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length);
+void osmo_wqueue_clear(struct osmo_wqueue *queue);
+int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data);
+int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what);
#endif