libosmocore
0.12.0
Osmocom core library
|
Go to the source code of this file.
Routines for helping with the osmocom application setup.
◆ osmo_daemonize()
int osmo_daemonize |
( |
void |
| ) |
|
Turn the current process into a background daemon.
This function will fork the process, exit the parent and set umask, create a new session, close stdin/stdout/stderr and chdir to /tmp
References pid.
◆ osmo_init_ignore_signals()
void osmo_init_ignore_signals |
( |
void |
| ) |
|
Ignore SIGPIPE, SIGALRM, SIGHUP and SIGIO.
References sighup_hdlr().
◆ osmo_init_logging()
int osmo_init_logging |
( |
const struct log_info * |
log_info | ) |
|
Initialize the osmocom logging framework.
- Parameters
-
[in] | log_info | Array of available logging sub-systems |
- Returns
- 0 on success, -1 in case of error
This function initializes the osmocom logging systems. It also creates the default (stderr) logging target.
References osmo_init_logging2().
◆ osmo_init_logging2()
int osmo_init_logging2 |
( |
void * |
ctx, |
|
|
const struct log_info * |
log_info |
|
) |
| |
◆ osmo_stderr_target
struct llist_head list
linked list header
Definition: msgb.h:36
@ HDLC_SEND_DATA
Definition: isdnhdlc.c:39
int osmo_plugin_load_all(const char *directory)
Load all plugins available in given directory.
Definition: plugin.c:46
@ OSMO_FSM_TERM_ERROR
erroneous termination of process
Definition: fsm.h:28
void osmo_generate_backtrace(void)
Generate and print a call back-trace.
Definition: backtrace.c:67
int osmo_sock_mcast_loop_set(int fd, bool enable)
Activate or de-activate local loop-back of transmitted multicast packets.
Definition: socket.c:731
int osmo_sercomm_drv_rx_char(struct osmo_sercomm_inst *sercomm, uint8_t ch)
the driver has received one byte, pass it into sercomm layer
Definition: sercomm.c:276
static uint64_t timer_ticks
Definition: rate_ctr.c:294
int ofd_wq_mode
wait queue mode?
Definition: gsmtap_util.h:24
unsigned int have_net_config
Definition: stats.h:67
int osmo_isdnhdlc_decode(struct osmo_isdnhdlc_vars *hdlc, const uint8_t *src, int slen, int *count, uint8_t *dst, int dsize)
decodes HDLC frames from a transparent bit stream.
Definition: isdnhdlc.c:121
const struct osmo_prbs * prbs
Definition: prbs.h:14
size_t osmo_strrb_elements(const struct osmo_strrb *rb)
Count the number of log messages in an osmo_strrb.
Definition: strrb.c:136
int osmo_gettimeofday(struct timeval *tv, struct timezone *tz)
shim around gettimeofday to be able to set the time manually.
Definition: timer_gettimeofday.c:60
char ** buffer
storage for messages
Definition: strrb.h:42
const char * name
human-readable name
Definition: prbs.h:7
int osmo_counter_difference(struct osmo_counter *ctr)
Compute difference between current and previous counter value.
Definition: counter.c:106
A structure representing a single instance of a timer.
Definition: timer.h:55
static void flush_all_reporters()
Definition: stats.c:701
int osmo_macaddr_parse(uint8_t *out, const char *in)
Parse a MAC address from human-readable notation This function parses an ethernet MAC address in the ...
Definition: macaddr.c:45
single entry in a SAP/PRIM/OP -> EVENT map
Definition: prim.h:82
struct osmo_sercomm_inst::@16 tx
transmit side
int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep)
Disable the given stats_reporter.
Definition: stats.c:372
bool _osmo_strrb_is_bufindex_valid(const struct osmo_strrb *rb, unsigned int bufi)
Definition: strrb.c:119
uint16_t start
index of the first slot
Definition: strrb.h:39
@ OSMO_STATS_CLASS_GLOBAL
global counter/stat_item
Definition: stats.h:49
#define HDLC_ESCAPE
Definition: sercomm.c:58
int rate_ctr_for_each_counter(struct rate_ctr_group *ctrg, rate_ctr_handler_t handle_counter, void *data)
Iterate over all counters.
Definition: rate_ctr.c:389
int dest_port
destination (UDP) port
Definition: stats.h:74
unsigned char * l3h
pointer to Layer 3 header.
Definition: msgb.h:49
#define OSMO_SOCK_F_CONNECT
connect the socket to a remote peer
Definition: socket.h:18
void osmo_stats_reporter_free(struct osmo_stats_reporter *srep)
Destroy a given stats_reporter.
Definition: stats.c:182
#define GSMTAP_UDP_PORT
Definition: gsmtap.h:164
@ RATE_CTR_INTV_HOUR
last hour
Definition: rate_ctr.h:18
#define timerclear(tvp)
Definition: timer_compat.h:39
int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, uint8_t snr, const uint8_t *data, unsigned int len)
send an arbitrary type through GSMTAP.
Definition: gsmtap_util.c:300
struct log_target::@7::@12 tgt_rb
const struct rate_ctr_desc * ctr_desc
Pointer to array of counter names.
Definition: rate_ctr.h:53
uint32_t frame_number
GSM Frame Number (FN)
Definition: gsmtap.h:260
static osmo_panic_handler_t osmo_panic_handler
Definition: panic.c:37
rate counter description
Definition: rate_ctr.h:37
static struct osmo_timer_list rate_ctr_timer
Definition: rate_ctr.c:293
void * tall_ctr_ctx
Global talloc context for all osmo_counter allocations.
Definition: counter.c:35
struct llist_head list
Definition: msgfile.h:31
void log_add_target(struct log_target *target)
Register a new log target with the logging core.
Definition: logging.c:567
const char * log_category_name(int subsys)
Definition: logging.c:323
bool osmo_is_hexstr(const char *str, int min_digits, int max_digits, bool require_even)
Validate that a given string is a hex string within given size limits.
Definition: utils.c:406
static void osmo_panic_default(const char *fmt, va_list args)
Definition: panic.c:45
int osmo_strrb_add(struct osmo_strrb *rb, const char *data)
Add a string to the osmo_strrb.
Definition: strrb.c:152
void * priv
some private data of this instance
Definition: fsm.h:96
@ HDLC_FAST_FLAG
Definition: isdnhdlc.c:35
static const char * color(int subsys)
Definition: logging.c:298
struct osmo_stats_reporter * osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type, const char *name)
Definition: stats.c:164
const struct osmo_prbs osmo_prbs11
PRBS-11 according ITU-T O.150.
Definition: prbs.c:30
uint8_t enabled
is this category enabled or not
Definition: logging.h:139
description of a rule in the FSM
Definition: fsm.h:41
#define OSMO_HDLC_CRC_ERROR
Definition: isdnhdlc.h:71
static void osmo_stats_reporter_sanitize_name(char *buf)
Replace all illegal ':' in the stats name, but not when used as value seperator.
Definition: stats_statsd.c:74
static void _output(struct log_target *target, unsigned int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap)
Definition: logging.c:339
int osmo_fd_disp_fds(void *readset, void *writeset, void *exceptset)
Definition: select.c:189
int rate_ctr_init(void *tall_ctx)
Initialize the counter module.
Definition: rate_ctr.c:331
static void assert_loginfo(const char *src)
Definition: logging.c:190
void log_set_print_filename2(struct log_target *target, enum log_filename_type lft)
Enable or disable printing of the filename while logging.
Definition: logging.c:675
uint8_t osmo_char2bcd(char c)
Convert number in ASCII to BCD value.
Definition: utils.c:120
struct log_target::@7::@10 tgt_syslog
#define timeradd(a, b, result)
Definition: timer_compat.h:50
#define LOGL_FATAL
fatal, program aborted
Definition: logging.h:104
int running
is this reporter running
Definition: stats.h:82
int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data, const char *file, int line)
dispatch an event to an osmocom finite state machine instance
Definition: fsm.c:546
unsigned int current_length
current length of write queue
Definition: write_queue.h:40
int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, const char *host, uint16_t port, unsigned int flags)
Initialize a socket (including bind/connect)
Definition: socket.c:310
const char * color
color string for cateyory
Definition: logging.h:136
void osmo_str2lower(char *out, const char *in)
Convert an entire string to lower case.
Definition: utils.c:288
int log_parse_level(const char *lvl) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
Parse a human-readable log level into a numeric value.
Definition: logging.c:209
int(* osmo_stat_item_handler_t)(struct osmo_stat_item_group *, struct osmo_stat_item *, void *)
Definition: stat_item.h:101
@ OSMO_FSM_TERM_REGULAR
regular termination of process
Definition: fsm.h:26
char * mnc
Definition: msgfile.h:38
uint8_t loglevel
currently selected log-level
Definition: logging.h:138
int bind_addr_len
length of bind_addr in bytes
Definition: stats.h:86
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:55
unsigned int sap
SAP to match.
Definition: prim.h:83
void rate_ctr_add(struct rate_ctr *ctr, int inc)
Increment the counter by inc.
Definition: rate_ctr.c:263
@ SC_DLCI_ECHO
Definition: sercomm.h:21
static int sockaddr_equal(const struct sockaddr *a, const struct sockaddr *b, unsigned int len)
Definition: socket.c:501
int osmo_serial_set_custom_baudrate(int fd, int baudrate)
Change current baudrate to a custom one using OS specific method.
Definition: serial.c:171
static struct osmo_config_entry * alloc_entry(struct osmo_config_list *entries, const char *mcc, const char *mnc, const char *option, const char *text)
Definition: msgfile.c:38
#define GSMTAP_TYPE_LTE_MAC_FRAMED
Definition: gsmtap.h:47
#define osmo_fsm_inst_term(fi, cause, data)
Terminate FSM instance with given cause.
Definition: fsm.h:218
const struct rate_ctr_group_desc * desc
Pointer to the counter group class.
Definition: rate_ctr.h:61
struct log_target * log_target_find(int type, const char *fname)
Find a registered log target.
Definition: logging.c:842
const char * name
human readable name
Definition: fsm.h:63
static bool rate_ctrl_group_desc_validate(const struct rate_ctr_group_desc *desc)
Definition: rate_ctr.c:76
struct sockaddr dest_addr
destination address of socket
Definition: stats.h:83
void osmo_timer_add(struct osmo_timer_list *timer)
add a new timer to the timer management
Definition: timer.c:84
Configuration of single log category / sub-system.
Definition: logging.h:128
unsigned int priv_nr
private number, extending data
Definition: select.h:37
@ OSMO_STATS_REPORTER_LOG
libosmocore logging
Definition: stats.h:56
structure describing a given CRC code of max 64 bits
Definition: crc64gen.h:34
static int osmo_stats_reporter_statsd_send_counter(struct osmo_stats_reporter *srep, const struct rate_ctr_group *ctrg, const struct rate_ctr_desc *desc, int64_t value, int64_t delta)
Definition: stats_statsd.c:167
uint8_t level
logging level
Definition: gsmtap.h:277
static unsigned int rate_ctr_get_unused_name_idx(const char *name)
Find an unused index for this rate counter group.
Definition: rate_ctr.c:190
@ LOG_FILENAME_PATH
Definition: logging.h:227
@ HDLC_SENDFLAG_B0
Definition: isdnhdlc.c:41
void rate_ctr_group_free(struct rate_ctr_group *grp)
Free the memory for the specified group of counters.
Definition: rate_ctr.c:256
const struct osmo_stat_item_desc * item_desc
Pointer to array of value names, length as per num_items.
Definition: stat_item.h:54
#define OSMO_ASSERT(exp)
Helper macro to terminate when an assertion failes.
Definition: utils.h:79
osmo_stats_class
Statistics Class definitions.
Definition: stats.h:47
const struct osmo_stat_item * osmo_stat_item_get_by_name(const struct osmo_stat_item_group *statg, const char *name)
Search for item based on group + item name.
Definition: stat_item.c:277
#define DEBUGP(ss, fmt, args...)
Log a debug message through the Osmocom logging framework.
Definition: logging.h:27
static int osmo_stats_reporter_log_send_item(struct osmo_stats_reporter *srep, const struct osmo_stat_item_group *statg, const struct osmo_stat_item_desc *desc, int64_t value)
Definition: stats.c:544
void log_parse_category_mask(struct log_target *target, const char *mask)
parse the log category mask
Definition: logging.c:250
One instance of a counter group class.
Definition: stat_item.h:58
Osmocom primitive header.
Definition: prim.h:43
#define DEFAULT_RX_MSG_SIZE
Definition: sercomm.c:41
@ LOG_FILENAME_BASENAME
Definition: logging.h:228
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:186
static void __add_timer(struct osmo_timer_list *timer)
Definition: timer.c:48
void osmo_stat_item_group_free(struct osmo_stat_item_group *statg)
Free the memory for the specified group of stat items.
Definition: stat_item.c:147
unsigned int num_values
number of values to store in FIFO
Definition: stat_item.h:39
struct log_target * log_target_create(void)
Create a new log target skeleton.
Definition: logging.c:751
int class_id
The class to which this group belongs.
Definition: rate_ctr.h:49
static int rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_)
Definition: stats.c:605
#define OSMO_NO_EVENT
magic value to be used as final record of osmo_prim_event_map
Definition: prim.h:79
char subsys[16]
logging sub-system
Definition: gsmtap.h:11
ubit_t osmo_prbs_get_ubit(struct osmo_prbs_state *state)
Get the next bit out of given PRBS instance.
Definition: prbs.c:61
void osmo_isdnhdlc_rcv_init(struct osmo_isdnhdlc_vars *hdlc, uint32_t features)
Definition: isdnhdlc.c:47
unsigned int idx
The index of this value group within its class.
Definition: stat_item.h:64
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:38
void osmo_sercomm_init(struct osmo_sercomm_inst *sercomm)
Initialize an Osmocom sercomm instance.
Definition: sercomm.c:78
unsigned char * data
start of message in buffer
Definition: msgb.h:59
uint16_t size
max number of messages to store
Definition: strrb.h:41
char alias("osmo_hexdump_nospc")))
int(* osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *)
Definition: stat_item.h:104
uint16_t arfcn
ARFCN (frequency)
Definition: gsmtap.h:256
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:48
int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
static void _rb_output(struct log_target *target, unsigned int level, const char *log)
Definition: loggingrb.c:40
void osmo_log_backtrace(int subsys, int level)
Generate and log a call back-trace.
Definition: backtrace.c:79
size_t osmo_strrb_elements(const struct osmo_strrb *rb)
Count the number of log messages in an osmo_strrb.
Definition: strrb.c:136
log_filter * filter_fn
Definition: logging.h:199
struct osmo_config_list * osmo_config_list_parse(void *ctx, const char *filename)
Definition: msgfile.c:101
int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr)
uint64_t rate
counter rate
Definition: rate_ctr.h:25
@ LOG_TGT_TYPE_STDERR
stderr logging
Definition: logging.h:219
data we keep for each actual item
Definition: stat_item.h:23
@ HDLC_SENDFLAG_B7
Definition: isdnhdlc.c:42
int osmo_fd_register(struct osmo_fd *fd)
Register a new file descriptor with select loop abstraction.
Definition: select.c:93
int32_t default_value
default value
Definition: stat_item.h:40
uint16_t osmo_crc16_ccitt(uint16_t crc, const uint8_t *buffer, size_t len)
Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.
Definition: crc16.c:108
int gsmtap_source_init_fd(const char *host, uint16_t port)
Create a new (sending) GSMTAP source socket.
Definition: gsmtap_util.c:222
Definition: isdnhdlc.h:34
const char * osmo_escape_str(const char *str, int len)
Return the string with all non-printable characters escaped.
Definition: utils.c:552
int osmo_fsm_inst_update_id_f(struct osmo_fsm_inst *fi, const char *fmt,...)
Change id of the FSM instance using a string format.
Definition: fsm.c:244
struct llist_head children
a list of children processes
Definition: fsm.h:114
int(* cb)(struct osmo_fd *fd, unsigned int what)
call-back function to be called once file descriptor becomes available
Definition: select.h:33
static char * _osmo_hexdump(const unsigned char *buf, int len, char *delim)
Definition: utils.c:181
int(* send_item)(struct osmo_stats_reporter *srep, const struct osmo_stat_item_group *statg, const struct osmo_stat_item_desc *desc, int64_t value)
Definition: stats.h:99
#define STATS_DEFAULT_BUFLEN
Definition: stats.c:93
uint8_t ffvalue
Definition: isdnhdlc.h:46
static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, struct rb_root *root)
Definition: rbtree.c:139
const unsigned int num_items
The number of values in this group (size of item_desc)
Definition: stat_item.h:52
#define rb_set_black(r)
Definition: linuxrbtree.h:120
@ PRIM_OP_INDICATION
indication
Definition: prim.h:29
const char * log_target_rb_get(struct log_target const *target, size_t logindex)
Return the nth log entry in a target.
Definition: loggingrb.c:75
void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root)
Definition: rbtree.c:365
#define GSMTAP_VERSION
Definition: gsmtap.h:31
Individual entry in value FIFO.
Definition: stat_item.h:17
static char * mangle_identifier_ifneeded(const void *ctx, const char *in)
Definition: rate_ctr.c:109
const char * name
name of category
Definition: logging.h:135
static const struct value_string level_colors[]
Definition: logging.c:306
struct llist_head dlci_queues[_SC_DLCI_MAX]
per-DLC queue of pending transmit msgbs
Definition: sercomm.h:42
void log_set_print_category_hex(struct log_target *target, int)
Enable or disable printing of the category number in hex ('<000b>').
Definition: logging.c:695
Information regarding one logging category.
Definition: logging.h:134
uint64_t osmo_decode_big_endian(const uint8_t *data, size_t data_len)
Generic retrieval of 1..8 bytes as big-endian uint64_t.
Definition: utils.c:343
int osmo_clock_gettime(clockid_t clk_id, struct timespec *tp)
int fd
file descriptor of socket
Definition: stats.h:87
bool osmo_separated_identifiers_valid(const char *str, const char *sep_chars)
Determine if a given identifier is valid, i.e.
Definition: utils.c:434
#define RB_ROOT
Definition: linuxrbtree.h:131
struct osmo_fsm_inst * osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void *priv, int log_level, const char *id)
allocate a new instance of a specified FSM
Definition: fsm.c:280
Logging configuration, passed to log_init.
Definition: logging.h:197
int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_secs, int T, const char *file, int line)
perform a state change of the given FSM instance
Definition: fsm.c:497
#define llist_for_each_entry_safe(pos, n, head, member)
iterate over llist of given type, safe against removal of non-consecutive(!) llist entries
Definition: linuxlist.h:328
osmo_static_assert(_LOG_CTX_COUNT<=ARRAY_SIZE(((struct log_context *) NULL) ->ctx), enum_logging_ctx_items_fit_in_struct_log_context)
char subsys[16]
logging sub-system
Definition: gsmtap.h:280
#define GSMTAP_CHANNEL_TCH_F
Definition: gsmtap.h:85
struct log_target * log_target_create_stderr(void)
Create the STDERR log target.
Definition: logging.c:792
static void _syslog_output(struct log_target *target, unsigned int level, const char *log)
Definition: logging_syslog.c:61
@ PRIM_OP_REQUEST
request
Definition: prim.h:27
int gsmtap_source_add_sink_fd(int gsmtap_fd)
Add a local sink to an existing GSMTAP source and return fd.
Definition: gsmtap_util.c:245
struct osmo_fsm_inst::@0 proc
support for fsm-based procedures
#define llist_for_each(pos, head)
Iterate over a linked list.
Definition: linuxlist.h:251
struct llist_head child
llist_head linked to parent->proc.children
Definition: fsm.h:116
int get_string_value(const struct value_string *vs, const char *str)
get numeric value for given human-readable string
Definition: utils.c:91
struct gsmtap_inst * gsmtap_source_init(const char *host, uint16_t port, int ofd_wq_mode)
Open GSMTAP source socket, connect and register osmo_fd.
Definition: gsmtap_util.c:420
@ RATE_CTR_INTV_MIN
last minute
Definition: rate_ctr.h:17
struct llist_head * next
Pointer to next and previous item.
Definition: linuxlist.h:48
void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when, int(*cb)(struct osmo_fd *fd, unsigned int what), void *data, unsigned int priv_nr)
Set up an osmo-fd.
Definition: select.c:62
#define DLLAPD
LAPD implementation.
Definition: logging.h:108
#define GSMTAP_TYPE_ABIS
Definition: gsmtap.h:34
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:157
void log_set_print_category(struct log_target *target, int)
Enable or disable printing of the category name.
Definition: logging.c:686
unsigned long cb[5]
control buffer
Definition: msgb.h:52
LLIST_HEAD(osmo_log_target_list)
const char * get_value_string_or_null(const struct value_string *vs, uint32_t val)
get human-readable string or NULL for given value
Definition: utils.c:71
#define HDLC_FLAG
Definition: sercomm.c:57
const char * osmo_strrb_get_nth(const struct osmo_strrb *rb, unsigned int string_index)
Return a pointer to the Nth string in the osmo_strrb.
Definition: strrb.c:106
void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use msgb_talloc_ctx_init() instead")
Set the talloc context for msgb_alloc Deprecated, use msgb_talloc_ctx_init() instead.
Definition: msgb.c:189
Description of a statistics item group.
Definition: stat_item.h:44
static int osmo_stats_reporter_statsd_send(struct osmo_stats_reporter *srep, const char *name1, unsigned int index1, const char *name2, int64_t value, const char *unit)
Definition: stats_statsd.c:90
#define GSMTAP_CHANNEL_SDCCH4
Definition: gsmtap.h:83
static int osmo_stat_item_handler(struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_)
Definition: stats.c:625
static bool should_log_to_target(struct log_target *tar, int subsys, int level)
Definition: logging.c:466
uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id)
convert RSL channel number to GSMTAP channel type
Definition: gsmtap_util.c:59
void osmo_fd_unregister(struct osmo_fd *fd)
Unregister a file descriptor from select loop abstraction.
Definition: select.c:134
int osmo_timers_update(void)
fire all timers...
Definition: timer.c:221
#define DLOAP
Osmocom Authentication Protocol.
Definition: logging.h:118
void log_set_print_timestamp(struct log_target *target, int)
Enable or disable printing of timestamps while logging.
Definition: logging.c:636
enum osmo_stats_reporter_type type
Type of the reporter (log, statsd)
Definition: stats.h:63
enum log_filename_type print_filename2
Definition: logging.h:315
osmo_fsm_term_cause
Definition: fsm.h:20
static void llist_del_init(struct llist_head *entry)
Delete entry from linked list and reinitialize it.
Definition: linuxlist.h:134
int8_t signal_dbm
signal level in dBm
Definition: gsmtap.h:8
int hdlc_bits1
Definition: isdnhdlc.h:36
#define OSMO_NUM_DLIB
Number of logging sub-systems in libraries.
Definition: logging.h:125
uint32_t do_adapt56
Definition: isdnhdlc.h:53
@ HDLC_SEND_CRC2
Definition: isdnhdlc.c:40
struct log_target::@7::@9 tgt_file
unsigned int print_filename
DEPRECATED: use print_filename2 instead.
Definition: logging.h:250
struct rb_node * rb_prev(const struct rb_node *node)
Definition: rbtree.c:341
bool osmo_fd_is_registered(struct osmo_fd *fd)
Check if a file descriptor is already registered.
Definition: select.c:77
@ HDLC_SEND_FAST_IDLE
Definition: isdnhdlc.c:41
#define INIT_LLIST_HEAD(ptr)
initialize a llist_head to point back to self
Definition: linuxlist.h:62
void osmo_gettimeofday_override_add(time_t secs, suseconds_t usecs)
convenience function to advance the fake time.
Definition: timer_gettimeofday.c:72
struct osmo_stats_reporter * osmo_stats_reporter_create_statsd(const char *name)
Create a stats_reporter reporting to statsd.
Definition: stats_statsd.c:56
size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
Copy a C-string into a sized buffer.
Definition: utils.c:382
const char * osmo_fsm_event_name(struct osmo_fsm *fsm, uint32_t event)
get human-readable name of FSM event
Definition: fsm.c:392
static struct osmo_config_list * alloc_entries(void *ctx)
Definition: msgfile.c:56
static void update_nearest(struct timeval *cand, struct timeval *current)
Definition: timer.c:187
@ OSMO_STATS_REPORTER_STATSD
statsd backend
Definition: stats.h:57
#define rb_color(r)
Definition: linuxrbtree.h:116
#define GSMTAP_CHANNEL_SDCCH8
Definition: gsmtap.h:84
static void * tall_rate_ctr_ctx
Definition: rate_ctr.c:73
uint32_t allstate_event_mask
bit-mask of events permitted in all states
Definition: fsm.h:69
@ LOG_FILENAME_NONE
Definition: logging.h:226
const char * log_vty_command_description() OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
Generates the logging command description for VTY.
Definition: logging.c:1011
One statistics reporter instance.
Definition: stats.h:61
#define container_of(ptr, type, member)
cast a member of a structure out to the containing structure
Definition: linuxlist.h:32
osmo_signal_cbfn * cbfn
Definition: signal.c:45
int(* close)(struct osmo_stats_reporter *srep)
Definition: stats.h:94
#define GSMTAP_LOG_MAX_SIZE
Definition: logging_gsmtap.c:54
int osmo_sock_unix_init(uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags)
Initialize a unix domain socket (including bind/connect)
Definition: socket.c:587
struct osmo_fd sink_ofd
file descriptor
Definition: gsmtap_util.h:26
@ RX_ST_ADDR
Definition: sercomm.c:66
uint16_t poly
Polynom (normal representation, MSB omitted.
Definition: crc16gen.h:36
uint16_t len
length of bytes used in msgb
Definition: msgb.h:55
int initialized
Has this instance been initialized?
Definition: sercomm.h:35
#define timersub(a, b, result)
Definition: timer_compat.h:63
#define GSMTAP_TYPE_QC_DIAG
Definition: gsmtap.h:49
struct rb_node * rb_left
Definition: linuxrbtree.h:6
struct log_target * log_target_create_gsmtap(const char *host, uint16_t port, const char *ident, bool ofd_wq_mode, bool add_sink)
Create a new logging target for GSMTAP logging.
Definition: logging_gsmtap.c:117
struct log_target * log_target_create_file(const char *fname)
Create a new file-based log target.
Definition: logging.c:816
int osmo_sock_mcast_all_set(int fd, bool enable)
Enable/disable receiving all multicast packets, even for non-subscribed groups.
Definition: socket.c:778
@ STOPPED
Definition: isdnhdlc.c:42
struct log_target * log_target_create_syslog(const char *ident, int option, int facility)
Create a new logging target for syslog logging.
Definition: logging_syslog.c:73
const char * osmo_quote_str(const char *str, int in_len)
Definition: utils.c:590
uint32_t data_received
Definition: isdnhdlc.h:49
void osmo_fsm_log_addr(bool log_addr)
specify if FSM instance addresses should be logged or not
Definition: fsm.c:102
struct log_target * log_target_create_rb(size_t size)
Create a new logging target for ringbuffer-backed logging.
Definition: loggingrb.c:84
a single instanceof an osmocom finite state machine
Definition: fsm.h:86
#define RB_BLACK
Definition: linuxrbtree.h:4
void log_set_print_filename(struct log_target *target, int)
Use log_set_print_filename2() instead.
Definition: logging.c:663
void * msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size)
Initialize a msgb talloc context for msgb_alloc.
Definition: msgb.c:202
unsigned long previous
previous value
Definition: counter.h:12
struct rb_node * rb_first(const struct rb_root *root)
Definition: rbtree.c:289
struct llist_head list
Linked list of all value groups in the system.
Definition: stat_item.h:60
@ LOG_TGT_TYPE_SYSLOG
syslog based logging
Definition: logging.h:217
uint8_t poly
Polynom (normal representation, MSB omitted.
Definition: crc8gen.h:36
static int rate_ctr_handler(struct rate_ctr_group *ctrg, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *sctx_)
Definition: stats.c:578
struct llist_head entry
linked list
Definition: logging.h:233
uint8_t loglevel
configured log-level
Definition: logging.h:129
void(* onleave)(struct osmo_fsm_inst *fi, uint32_t next_state)
function to be called just before leaving the state
Definition: fsm.h:53
const char * description
description of the counter
Definition: rate_ctr.h:39
void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data)
Unregister signal handler.
Definition: signal.c:83
unsigned int use_color
should color be used when printing log messages?
Definition: logging.h:246
uint64_t init
Initialization value of the CRC state.
Definition: crc64gen.h:37
int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch)
fetch one octet of to-be-transmitted serial data
Definition: sercomm.c:183
int osmo_stat_item_get_next(const struct osmo_stat_item *item, int32_t *idx, int32_t *value)
Retrieve the next value from the osmo_stat_item object.
Definition: stat_item.c:189
Structure representing a single counter.
Definition: counter.h:7
@ HDLC_SEND_FAST_FLAG
Definition: isdnhdlc.c:39
struct osmo_stat_item_value values[0]
value FIFO
Definition: stat_item.h:31
const struct osmo_prbs osmo_prbs9
PRBS-9 according ITU-T O.150.
Definition: prbs.c:22
a description of an osmocom finite state machine
Definition: fsm.h:57
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:180
#define LOGPFSM(fi, fmt, args...)
Definition: fsm.h:128
int log_targets_reopen(void)
close and re-open all log files (for log file rotation)
Definition: logging.c:908
int osmo_serial_set_baudrate(int fd, speed_t baudrate)
Change current baudrate.
Definition: serial.c:157
static void llist_del(struct llist_head *entry)
Delete entry from linked list.
Definition: linuxlist.h:124
#define DLM3UA
Osmocom M3UA.
Definition: logging.h:122
struct osmo_stats_reporter * osmo_stats_reporter_find(enum osmo_stats_reporter_type type, const char *name)
Find a stats_reporter of given type and name.
Definition: stats.c:204
unsigned int value
numeric value
Definition: utils.h:39
int osmo_get_macaddr(uint8_t *mac_out, const char *dev_name)
Obtain the MAC address of a given network device.
Definition: macaddr.c:123
uint8_t level
logging level
Definition: gsmtap.h:8
static void handle_line(struct osmo_config_list *entries, char *line)
Definition: msgfile.c:71
int force_single_flush
Definition: stats.h:90
int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags)
Initialize a unix domain socket and fill osmo_fd.
Definition: socket.c:660
#define INT2IDX(x)
Definition: logging.c:79
int8_t signal_dbm
signal level in dBm
Definition: gsmtap.h:257
uint16_t osmo_crc16gen_compute_bits(const struct osmo_crc16gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc16gen.c:44
static void * tall_log_ctx
Definition: logging.c:64
#define GSMTAP_CHANNEL_PTCCH
Definition: gsmtap.h:92
@ HDLC_GETFLAG_B7
Definition: isdnhdlc.c:34
struct timeval timeout
expiration time
Definition: timer.h:58
enum osmo_prim_operation operation
Definition: prim.h:46
void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value)
Set the a given stat_item to the given value.
Definition: stat_item.c:159
#define OSMO_SOCK_F_NONBLOCK
switch socket to non-blocking mode
Definition: socket.h:22
static void rate_ctr_timer_cb(void *data)
Definition: rate_ctr.c:314
#define GSMTAP_TYPE_UM
Definition: gsmtap.h:33
static int subsys_lib2index(int subsys)
Definition: logging.c:200
static const struct value_string loglevel_strs[LOGLEVEL_DEFS+1]
Definition: logging.c:69
void log_set_print_level(struct log_target *target, int)
Enable or disable printing of the log level name.
Definition: logging.c:706
unsigned int print_ext_timestamp
should log messages be prefixed with an extended timestamp?
Definition: logging.h:254
uint8_t loglevel
global log level
Definition: logging.h:244
int sercomm_drv_baudrate_chg(struct osmo_sercomm_inst *sercomm, uint32_t bdrt)
low-level driver routine to execute baud-rate change
static void dispatch_rx_msg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
Definition: sercomm.c:262
uint8_t sub_type
Type of burst/channel, see above.
Definition: gsmtap.h:262
static LLIST_HEAD(counters)
int log_set_context(uint8_t ctx, void *value)
Set the logging context.
Definition: logging.c:597
#define GSMTAP_CHANNEL_AGCH
Definition: gsmtap.h:80
int osmo_stat_item_discard_all(int32_t *idx)
Skip all values of all items and update idx accordingly.
Definition: stat_item.c:236
void(* allstate_action)(struct osmo_fsm_inst *fi, uint32_t event, void *data)
function pointer to be called for allstate events
Definition: fsm.h:71
void osmo_crc32gen_set_bits(const struct osmo_crc32gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
Computes and writes the CRC value of a given array of bits.
Definition: crc32gen.c:104
#define BACKSLASH_CASE(c, repr)
#define GSMTAP_CHANNEL_SDCCH
Definition: gsmtap.h:82
char name[32]
source file name
Definition: gsmtap.h:13
uint8_t * next_char
next to-be-transmitted char in msg
Definition: sercomm.h:48
const struct value_string gsmtap_type_names[]
Definition: gsmtap_util.c:477
int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *host, uint16_t port, unsigned int flags)
Initialize a socket and fill osmo_fd.
Definition: socket.c:426
unsigned int num_cat_user
total number of user categories (not library)
Definition: logging.h:206
int osmo_sock_mcast_ttl_set(int fd, uint8_t ttl)
Set the TTL of outbound multicast packets.
Definition: socket.c:756
#define BSC_FD_READ
Indicate interest in reading from the file descriptor.
Definition: select.h:16
int osmo_crc32gen_check_bits(const struct osmo_crc32gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
Checks the CRC value of a given array of hard-bits.
Definition: crc32gen.c:79
int32_t last_value_index
the index of the freshest value
Definition: stat_item.h:27
Osmocom message buffer.
Definition: msgb.h:35
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition: msgb.h:283
void rb_insert_color(struct rb_node *, struct rb_root *)
Definition: rbtree.c:74
void osmo_clock_override_add(clockid_t clk_id, time_t secs, long nsecs)
#define GSMTAP_CHANNEL_PDCH
Definition: gsmtap.h:91
const struct osmo_prbs osmo_prbs7
PRBS-7 according ITU-T O.150.
Definition: prbs.c:14
static int osmo_stats_reporter_send_counter(struct osmo_stats_reporter *srep, const struct rate_ctr_group *ctrg, const struct rate_ctr_desc *desc, int64_t value, int64_t delta)
Definition: stats.c:567
#define LOGL_INFO
general information
Definition: logging.h:101
int osmo_stat_item_discard(const struct osmo_stat_item *item, int32_t *idx)
Skip/discard all values of this item and update idx accordingly.
Definition: stat_item.c:227
#define DLMI
ISDN-layer below input sub-system.
Definition: logging.h:111
structure representing a logging target
Definition: logging.h:232
uint64_t poly
Polynom (normal representation, MSB omitted.
Definition: crc64gen.h:36
void osmo_prbs_state_init(struct osmo_prbs_state *st, const struct osmo_prbs *prbs)
Initialize the given caller-allocated PRBS state.
Definition: prbs.c:46
const struct log_info_cat * cat
per-category information
Definition: logging.h:202
int osmo_strrb_add(struct osmo_strrb *rb, const char *data)
Add a string to the osmo_strrb.
Definition: strrb.c:152
int bits
Actual number of bits of the CRC.
Definition: crc8gen.h:35
uint8_t ctrl
CTRL of currently received msgb.
Definition: sercomm.h:64
const struct rate_ctr * rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name)
Search for counter based on group + name.
Definition: rate_ctr.c:365
static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:28
Definition: linuxrbtree.h:109
int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data)
Register a new signal handler.
Definition: signal.c:56
one gsmtap instance
Definition: gsmtap_util.h:23
static int _osmo_serial_set_baudrate(int fd, speed_t baudrate)
Definition: serial.c:129
static void * osmo_stats_ctx
Definition: stats.c:96
int bits
Actual number of bits of the CRC.
Definition: crc32gen.h:35
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:46
uint8_t type
see GSMTAP_TYPE_*
Definition: gsmtap.h:253
struct llist_head list
linked list for internal management
Definition: select.h:25
void(* raw_output)(struct log_target *target, int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap)
alternative call-back function to which the logging framework passes the unfortmatted input arguments...
Definition: logging.h:306
void osmo_fsm_inst_free(struct osmo_fsm_inst *fi)
delete a given instance of a FSM
Definition: fsm.c:379
int msgb_resize_area(struct msgb *msg, uint8_t *area, int old_size, int new_size)
Resize an area within an msgb.
Definition: msgb.c:262
int dest_addr_len
length of dest_addr in bytes
Definition: stats.h:84
@ HDLC_GETFLAG_B1A6
Definition: isdnhdlc.c:34
struct gsm_bts_trx * trx
Definition: msgb.h:43
@ HDLC_GET_FLAG_B0
Definition: isdnhdlc.c:34
struct rb_node * rb_next(const struct rb_node *node)
Definition: rbtree.c:313
int facility
Definition: logging.h:267
int osmo_counters_count()
Counts the registered counter.
Definition: counter.c:82
unsigned char * l1h
pointer to Layer1 header (if any)
Definition: msgb.h:47
bool print_level
Definition: logging.h:311
const uint16_t osmo_crc16_ccitt_table[256]
CRC table for the CCITT CRC-6.
Definition: crc16.c:67
#define BSC_FD_WRITE
Indicate interest in writing to the file descriptor.
Definition: select.h:18
void osmo_fsm_unregister(struct osmo_fsm *fsm)
unregister a FSM from the core
Definition: fsm.c:177
struct osmo_fsm * osmo_fsm_find_by_name(const char *name)
Definition: fsm.c:107
const char * unit
unit of a value
Definition: stat_item.h:38
#define GSMTAP_CHANNEL_RACH
Definition: gsmtap.h:79
#define GSMTAP_TYPE_LTE_MAC
Definition: gsmtap.h:46
#define osmo_fsm_inst_dispatch(fi, event, data)
dispatch an event to an osmocom finite state machine instance
Definition: fsm.h:207
const struct osmo_stat_item_desc * desc
back-reference to the item description
Definition: stat_item.h:25
#define rb_set_red(r)
Definition: linuxrbtree.h:119
char * dest_addr_str
destination IP address
Definition: stats.h:72
static int sock_get_domain(int fd)
Definition: socket.c:707
#define OSMO_STRLCPY_ARRAY(array, src)
Copy a C-string into a sized buffer using sizeof to detect buffer's size.
Definition: utils.h:31
const struct osmo_fsm_state * states
table of state transition rules
Definition: fsm.h:65
struct log_target::@7::@13 tgt_gsmtap
void osmo_crc8gen_set_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
Computes and writes the CRC value of a given array of bits.
Definition: crc8gen.c:104
unsigned int num_cat
total number of categories
Definition: logging.h:204
One instance of a counter group class.
Definition: rate_ctr.h:57
void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause, void *data, const char *file, int line)
Terminate all child FSM instances of an FSM instance.
Definition: fsm.c:653
const char * osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize)
Return the string with all non-printable characters escaped.
Definition: utils.c:477
const char * group_description
The human-readable description of the group.
Definition: rate_ctr.h:47
#define GSMTAP_TYPE_UMTS_RLC_MAC
Definition: gsmtap.h:43
struct rb_node * rb_left
Definition: linuxrbtree.h:105
static int map_subsys(int subsys)
Definition: logging.c:448
static LLIST_HEAD(osmo_stats_reporter_list)
int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, uint8_t snr, const uint8_t *data, unsigned int len)
send a message from L1/L2 through GSMTAP.
Definition: gsmtap_util.c:325
static int osmo_stats_reporter_send_item(struct osmo_stats_reporter *srep, const struct osmo_stat_item_group *statg, const struct osmo_stat_item_desc *desc, int32_t value)
Definition: stats.c:614
static struct osmo_stats_config s_stats_config
Definition: stats.c:100
struct rb_node * rb_first(const struct rb_root *)
Definition: rbtree.c:289
void osmo_panic(const char *fmt,...) __attribute__((noreturn))
Terminate the current program with a panic.
Definition: panic.c:75
int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep)
static int unregistered_count
Definition: select.c:52
static struct rate_ctr_group_desc * rate_ctr_group_desc_mangle(void *ctx, const struct rate_ctr_group_desc *desc)
Definition: rate_ctr.c:140
int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_state, const char *file, int line)
perform a state change while keeping the current timer running.
Definition: fsm.c:523
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:104
uint32_t event
event as result if above match
Definition: prim.h:86
int osmo_sock_mcast_subscribe(int fd, const char *grp_addr)
Subscribe to the given IP multicast group.
Definition: socket.c:810
int osmo_sercomm_initialized(struct osmo_sercomm_inst *sercomm)
Determine if a given Osmocom sercomm instance has been initialized.
Definition: sercomm.c:96
static char hexd_buff[4096]
Definition: utils.c:178
void log_set_use_color(struct log_target *target, int)
Enable or disable the use of colored output.
Definition: logging.c:627
static struct osmo_timer_list osmo_stats_timer
Definition: stats.c:105
@ HDLC_SEND_IDLE1
Definition: isdnhdlc.c:41
static bool fsm_log_addr
Definition: fsm.c:92
#define GSMTAP_TYPE_TETRA_I1_BURST
Definition: gsmtap.h:38
@ OSMO_FSM_TERM_PARENT
terminate because parent terminated
Definition: fsm.h:22
void rb_insert_color(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:74
void osmo_fd_close(struct osmo_fd *fd)
Close a file descriptor, mark it as closed + unregister from select loop abstraction.
Definition: select.c:149
struct rate_ctr_group * rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx)
Search for counter group based on group name and index.
Definition: rate_ctr.c:344
static int osmo_stats_reporter_statsd_send_item(struct osmo_stats_reporter *srep, const struct osmo_stat_item_group *statg, const struct osmo_stat_item_desc *desc, int64_t value)
Definition: stats_statsd.c:183
#define GSMTAP_TYPE_OSMOCORE_LOG
Definition: gsmtap.h:48
static int osmo_sock_init_tail(int fd, uint16_t type, unsigned int flags)
Definition: socket.c:113
static struct timeval nearest
Definition: timer.c:43
static char namebuf[255]
Definition: utils.c:44
void log_del_target(struct log_target *target)
Unregister a log target from the logging core.
Definition: logging.c:575
static void _gsmtap_raw_output(struct log_target *target, int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap)
Definition: logging_gsmtap.c:56
#define LOGPFSMSRC(fi, caller_file, caller_line, fmt, args...)
Definition: fsm.h:139
void * data
user data for callback
Definition: timer.h:62
void * tall_sigh_ctx
Definition: signal.c:39
uint32_t remainder
Remainder of the CRC (final XOR)
Definition: crc32gen.h:38
#define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...)
Definition: fsm.h:131
char * osmo_ubit_dump(const uint8_t *bits, unsigned int len)
Convert a sequence of unpacked bits to ASCII string.
Definition: utils.c:211
uint8_t cbin
Definition: isdnhdlc.h:44
int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep, enum osmo_stats_class class_id)
Definition: stats.c:318
const char * str
human-readable string
Definition: utils.h:40
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue.
Definition: write_queue.c:108
#define DLCTRL
Control Interface.
Definition: logging.h:114
struct osmo_fsm_inst * parent
the parent FSM that has created us
Definition: fsm.h:110
#define LOGLEVEL_DEFS
Definition: logging.c:67
struct llist_head list
Linked list of all counter groups in the system.
Definition: rate_ctr.h:59
int(* rate_ctr_handler_t)(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *)
Definition: rate_ctr.h:108
void osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds)
schedule a timer at a given future relative time
Definition: timer.c:103
static void interval_expired(struct rate_ctr *ctr, enum rate_ctr_intv intv)
Definition: rate_ctr.c:280
void logp(int subsys, const char *file, int line, int cont, const char *format,...) OSMO_DEPRECATED("Use DEBUGP* macros instead")
logging function used by DEBUGP() macro
Definition: logging.c:538
int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen)
Determine if the given address is a local address.
Definition: socket.c:534
uint32_t osmo_crc32gen_compute_bits(const struct osmo_crc32gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc32gen.c:44
dlci_cb_t dlci_handler[_SC_DLCI_MAX]
per-DLC handler call-back functions
Definition: sercomm.h:54
void osmo_clock_override_enable(clockid_t clk_id, bool enable)
#define GSMTAP_CHANNEL_BCCH
Definition: gsmtap.h:77
static void rate_ctr_group_intv(struct rate_ctr_group *grp)
Definition: rate_ctr.c:297
#define osmo_htonl(x)
Definition: byteswap.h:43
write queue instance
Definition: write_queue.h:34
void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data)
dispatch (deliver) a new signal to all registered handlers
Definition: signal.c:103
const struct value_string osmo_fsm_term_cause_names[]
Definition: fsm.c:684
struct rb_root __attribute__
Definition: conv_acc_generic.c:140
bool osmo_gettimeofday_override
Definition: timer_gettimeofday.c:48
int data_bits
Definition: isdnhdlc.h:37
unsigned int num_ctr
The number of counters in this group.
Definition: rate_ctr.h:51
uint8_t sub_slot
sub-slot within timeslot
Definition: gsmtap.h:264
int osmo_sock_init2(uint16_t family, uint16_t type, uint8_t proto, const char *local_host, uint16_t local_port, const char *remote_host, uint16_t remote_port, unsigned int flags)
Initialize a socket (including bind and/or connect)
Definition: socket.c:182
static int osmo_stats_reporter_log_send_counter(struct osmo_stats_reporter *srep, const struct rate_ctr_group *ctrg, const struct rate_ctr_desc *desc, int64_t value, int64_t delta)
Definition: stats.c:528
void osmo_timers_prepare(void)
Find the nearest time and update nearest_p.
Definition: timer.c:203
static LLIST_HEAD(signal_handler_list)
int(* rate_ctr_group_handler_t)(struct rate_ctr_group *, void *)
Definition: rate_ctr.h:111
int bit_shift
Definition: isdnhdlc.h:35
unsigned int when
bit-mask or of BSC_FD_READ, BSC_FD_WRITE and/or BSC_FD_EXCEPT
Definition: select.h:30
#define DLMIB
ISDN layer B-channel.
Definition: logging.h:112
uint16_t crc
Definition: isdnhdlc.h:42
int(* send_counter)(struct osmo_stats_reporter *srep, const struct rate_ctr_group *ctrg, const struct rate_ctr_desc *desc, int64_t value, int64_t delta)
Definition: stats.h:95
int gsmtap_source_add_sink(struct gsmtap_inst *gti)
Add a local sink to an existing GSMTAP source and return fd.
Definition: gsmtap_util.c:383
int(* open)(struct osmo_stats_reporter *srep)
Definition: stats.h:93
unsigned char * tail
end of message in buffer
Definition: msgb.h:58
void osmo_fsm_inst_unlink_parent(struct osmo_fsm_inst *fi, void *ctx)
unlink child FSM from its parent FSM.
Definition: fsm.c:343
void(* cleanup)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
clean-up function, called during termination
Definition: fsm.h:73
const char * log_vty_command_string() OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
Generates the logging command string for VTY.
Definition: logging.c:931
static void osmo_prbs_process_bit(struct osmo_prbs_state *state, ubit_t bit)
Definition: prbs.c:53
const struct osmo_prbs osmo_prbs15
PRBS-15 according ITU-T O.150.
Definition: prbs.c:38
int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, void *data)
Iterate over all stat_item groups in system, call user-supplied function on each.
Definition: stat_item.c:321
int bits
Actual number of bits of the CRC.
Definition: crc16gen.h:35
int osmo_stats_reporter_udp_close(struct osmo_stats_reporter *srep)
struct timeval * osmo_timers_nearest(void)
Determine time between now and the nearest timer.
Definition: timer.c:179
struct msgb * msg
msgb currently being transmitted
Definition: sercomm.h:44
#define OSMO_HDLC_LENGTH_ERROR
Definition: isdnhdlc.h:72
int osmo_serial_init(const char *dev, speed_t baudrate)
Open serial device and does base init.
Definition: serial.c:58
void(* osmo_panic_handler_t)(const char *fmt, va_list args)
panic handler callback function type
Definition: panic.h:10
@ HDLC_SEND_CRC1
Definition: isdnhdlc.c:39
int osmo_counters_for_each(int(*handle_counter)(struct osmo_counter *, void *), void *data)
Iterate over all counters; call handle_cunter call-back for each.
Definition: counter.c:65
unsigned char * l4h
pointer to layer 4 header
Definition: msgb.h:50
const char * name
human readable fully-qualified name
Definition: fsm.h:94
struct rate_ctr ctr[0]
Actual counter structures below.
Definition: rate_ctr.h:65
definition of a PRBS sequence
Definition: prbs.h:6
struct rate_ctr_group * rate_ctr_group_alloc(void *ctx, const struct rate_ctr_group_desc *desc, unsigned int idx)
Allocate a new group of counters according to description.
Definition: rate_ctr.c:213
uint32_t state
current state of the FSM
Definition: fsm.h:100
One message in the list.
Definition: msgfile.h:30
unsigned int print_category
should log messages be prefixed with a category name?
Definition: logging.h:252
struct msgb * gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, uint8_t snr, const uint8_t *data, unsigned int len)
create an arbitrary type GSMTAP message
Definition: gsmtap_util.c:152
static int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
Get the last (freshest) value.
Definition: stat_item.h:111
void osmo_set_panic_handler(osmo_panic_handler_t h)
Set the panic handler.
Definition: panic.c:102
#define GSMTAP_CHANNEL_TCH_H
Definition: gsmtap.h:86
int16_t last_offs
offset to the freshest value in the value FIFO
Definition: stat_item.h:29
const char * name
name of the counter
Definition: rate_ctr.h:38
struct osmo_strrb * osmo_strrb_create(TALLOC_CTX *ctx, size_t rb_size)
Create an empty, initialized osmo_strrb.
Definition: strrb.c:59
int(* timer_cb)(struct osmo_fsm_inst *fi)
timer call-back for states with time-out.
Definition: fsm.h:76
#define OSMO_STAT_ITEM_NOVALUE_ID
Definition: stat_item.h:13
static int update_srep_config(struct osmo_stats_reporter *srep)
Definition: stats.c:115
struct rb_node * rb_next(const struct rb_node *)
Definition: rbtree.c:313
uint8_t res
reserved for future use (RFU)
Definition: gsmtap.h:16
char * bind_addr_str
local bind IP address
Definition: stats.h:73
unsigned int osmo_sockaddr_to_str_and_uint(char *addr, unsigned int addr_len, uint16_t *port, const struct sockaddr *sa)
Convert sockaddr to IP address as char string and port as uint16_t.
Definition: socket.c:564
@ _LOG_CTX_COUNT
Definition: logging.h:154
uint32_t osmo_revbytebits_8(uint8_t x)
reverse the bit order in a byte
Definition: bits.c:271
const char * osmo_quote_str_buf(const char *str, int in_len, char *buf, size_t bufsize)
Like osmo_escape_str(), but returns double-quotes around a string, or "NULL" for a NULL string.
Definition: utils.c:563
@ RX_ST_ESCAPE
Definition: sercomm.c:69
uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph, const struct osmo_prim_event_map *maps)
resolve the (fsm) event for a given primitive using a map
Definition: prim.c:28
int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg)
Send a Message buffers through a GSMTAP source.
Definition: gsmtap_util.c:273
#define timercmp(a, b, CMP)
Definition: timer_compat.h:43
bool osmo_identifier_valid(const char *str)
Determine if a given identifier is valid, i.e.
Definition: utils.c:465
void * data
Definition: signal.c:46
int osmo_timerfd_disable(struct osmo_fd *ofd)
disable the osmocom-wrapped timerfd
Definition: select.c:278
char osmo_bcd2char(uint8_t bcd)
Convert BCD-encoded digit into printable character.
Definition: utils.c:108
enum log_target_type type
the type of this log taget
Definition: logging.h:257
bool print_category_hex
Definition: logging.h:313
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:50
#define OSMO_HDLC_F_BITREVERSE
Definition: isdnhdlc.h:63
@ HDLC_GET_DATA
Definition: isdnhdlc.c:35
(double) linked list header structure
Definition: linuxlist.h:46
int state
Definition: isdnhdlc.h:39
#define GSMTAP_CHANNEL_CBCH51
Definition: gsmtap.h:93
int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
int osmo_crc8gen_check_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
Checks the CRC value of a given array of hard-bits.
Definition: crc8gen.c:79
static int osmo_fd_init_ofd(struct osmo_fd *ofd, int sfd)
fill osmo_fd for a give sfd
Definition: socket.c:394
static void * tall_stat_item_ctx
talloc context from which we allocate
Definition: stat_item.c:70
struct osmo_wqueue wq
the wait queue
Definition: gsmtap_util.h:25
struct sockaddr bind_addr
local bind address of socket
Definition: stats.h:85
unsigned long rb_parent_color
Definition: linuxrbtree.h:101
#define GSMTAP_TYPE_WMX_BURST
Definition: gsmtap.h:39
const struct value_string osmo_prim_op_names[5]
human-readable string mapping for osmo_prim_operation
Definition: prim.c:16
int log_target_file_reopen(struct log_target *tgt)
close and re-open a log file (for log file rotation)
Definition: logging.c:893
int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data)
signal callback function type
Definition: signal.h:33
struct osmo_stat_item_group * osmo_stat_item_group_alloc(void *ctx, const struct osmo_stat_item_group_desc *desc, unsigned int idx)
Allocate a new group of counters according to description.
Definition: stat_item.c:79
struct llist_head list
internal list header
Definition: timer.h:57
enum osmo_stats_class max_class
Maximum class/index to report.
Definition: stats.h:78
static LLIST_HEAD(osmo_stat_item_groups)
global list of stat_item groups
@ LOG_TGT_TYPE_FILE
text file logging
Definition: logging.h:218
void log_reset_context(void)
Reset (clear) the logging context.
Definition: logging.c:581
#define OSMO_SOCK_F_NO_MCAST_LOOP
disable multiast loop (IP_MULTICAST_LOOP)
Definition: socket.h:24
static void _file_output(struct log_target *target, unsigned int level, const char *log)
Definition: logging.c:737
struct gsmtap_osmocore_log_hdr::@3 ts
int osmo_hexparse(const char *str, uint8_t *b, int max_len)
Parse a string containing hexadecimal digits.
Definition: utils.c:138
int T
timer number for states with time-out
Definition: fsm.h:103
void osmo_isdnhdlc_out_init(struct osmo_isdnhdlc_vars *hdlc, uint32_t features)
Definition: isdnhdlc.c:57
int osmo_timer_pending(struct osmo_timer_list *timer)
check if given timer is still pending
Definition: timer.c:138
void log_set_print_extended_timestamp(struct log_target *target, int)
Enable or disable printing of extended timestamps while logging.
Definition: logging.c:649
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:423
struct llist_head list
Definition: stats.h:92
#define DLMUX
Osmocom Multiplex (Osmux)
Definition: logging.h:110
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:92
void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t *link_id)
convert GSMTAP channel type to RSL channel number + Link ID
Definition: gsmtap_util.c:102
struct llist_head entry
Definition: msgfile.h:44
#define DLSUA
Osmocom SUA.
Definition: logging.h:121
struct rb_node node
rb-tree node header
Definition: timer.h:56
uint8_t timeslot
timeslot (0..7 on Um)
Definition: gsmtap.h:254
enum osmo_prim_operation operation
operation to match
Definition: prim.h:85
rx_state
Definition: sercomm.c:64
void osmo_timer_setup(struct osmo_timer_list *timer, void(*cb)(void *data), void *data)
set up timer callback and data
Definition: timer.c:74
@ OSMO_FSM_TERM_REQUEST
terminate on explicit user request
Definition: fsm.h:24
@ LOG_TGT_TYPE_GSMTAP
GSMTAP network logging.
Definition: logging.h:221
int osmo_stats_reporter_set_name_prefix(struct osmo_stats_reporter *srep, const char *prefix)
Set the name prefix of a given stats_reporter.
Definition: stats.c:349
#define GSMTAP_CHANNEL_ACCH
Definition: gsmtap.h:102
uint64_t coeff
coefficients
Definition: prbs.h:9
#define handle_fast_flag(h)
#define OSMO_VALUE_STRING(x)
Make a value_string entry from an enum value name.
Definition: utils.h:26
static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:51
int osmo_isdnhdlc_encode(struct osmo_isdnhdlc_vars *hdlc, const uint8_t *src, uint16_t slen, int *count, uint8_t *dst, int dsize)
encodes HDLC frames to a transparent bit stream.
Definition: isdnhdlc.c:342
int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep)
Enable the given stats_reporter.
Definition: stats.c:362
uint32_t dchannel
Definition: isdnhdlc.h:51
uint16_t osmo_crc16(uint16_t crc, const uint8_t *buffer, size_t len)
Compute 16bit CCITT polynome 0x8408 (x^0 + x^5 + x^12) over given buffer.
Definition: crc16.c:59
@ HDLC_SEND_CLOSING_FLAG
Definition: isdnhdlc.c:40
static const char * loglevel_descriptions[LOGLEVEL_DEFS+1]
descriptive string for each log level
Definition: logging.c:180
struct rb_node * rb_node
Definition: linuxrbtree.h:111
unsigned int num_states
number of entries in states
Definition: fsm.h:67
#define HDLC_C_UI
Definition: sercomm.c:60
#define STATS_DEFAULT_INTERVAL
Definition: stats.c:92
uint32_t osmo_isqrt32(uint32_t x)
perform an integer square root operation on unsigned 32bit integer.
Definition: utils.c:598
int osmo_timerfd_setup(struct osmo_fd *ofd, int(*cb)(struct osmo_fd *, unsigned int), void *data)
setup osmocom-wrapped timerfd
Definition: select.c:320
#define OSMO_HDLC_F_56KBIT
Definition: isdnhdlc.h:61
void(* action)(struct osmo_fsm_inst *fi, uint32_t event, void *data)
function to be called for events arriving in this state
Definition: fsm.h:49
int osmo_fd_fill_fds(void *readset, void *writeset, void *exceptset)
Populate the fd_sets and return the highest fd number.
Definition: select.c:166
void sercomm_drv_start_tx(struct osmo_sercomm_inst *sercomm)
low-level driver routine to request start of transmission The Sercomm code calls this function to inf...
struct gsmtap_osmocore_log_hdr::@4 src_file
int osmo_sock_local_ip(char *local_ip, const char *remote_ip)
Determine the matching local IP-address for a given remote IP-Address.
Definition: socket.c:850
int mtu
Maximum Transmission Unit.
Definition: stats.h:75
const char * fname
Definition: logging.h:262
static void osmo_stats_timer_cb(void *data)
Definition: stats.c:143
int dstpos
Definition: isdnhdlc.h:40
int32_t value
actual value
Definition: stat_item.h:19
const char * group_name_prefix
The prefix to the name of all counters in this group.
Definition: rate_ctr.h:45
int64_t rate_ctr_difference(struct rate_ctr *ctr)
Return the counter difference since the last call to this function.
Definition: rate_ctr.c:269
void log_set_log_level(struct log_target *target, int log_level)
Set the global log level for a given log target.
Definition: logging.c:715
struct msgb * buffer
message buffer for log output
Definition: stats.h:88
#define llist_for_each_entry(pos, head, member)
Iterate over llist of given type.
Definition: linuxlist.h:289
static void update_name(struct osmo_fsm_inst *fi)
Definition: fsm.c:220
#define dbg_perror(x)
Definition: serial.c:49
uint8_t dlci
DLCI of currently received msgb.
Definition: sercomm.h:62
uint8_t * osmo_encode_big_endian(uint64_t value, size_t data_len)
Generic big-endian encoding of big endian number up to 64bit.
Definition: utils.c:364
int bits
Actual number of bits of the CRC.
Definition: crc64gen.h:35
const struct osmo_stat_item_group_desc * desc
Pointer to the counter group class.
Definition: stat_item.h:62
int osmo_sock_init2_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *local_host, uint16_t local_port, const char *remote_host, uint16_t remote_port, unsigned int flags)
Initialize a socket and fill osmo_fd.
Definition: socket.c:447
const char * id
human readable identifier
Definition: fsm.h:92
static const char * osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause)
Definition: fsm.h:34
int osmo_counters_for_each(int(*handle_counter)(struct osmo_counter *, void *), void *data)
Iterate over all counters; call handle_cunter call-back for each.
Definition: counter.c:65
@ OSMO_FSM_TERM_TIMEOUT
termination due to time-out
Definition: fsm.h:30
int agg_enabled
is aggregation enabled?
Definition: stats.h:89
struct osmo_stat_item_group * osmo_stat_item_get_group_by_name_idx(const char *name, const unsigned int idx)
Search for item group based on group name and index.
Definition: stat_item.c:257
#define LOGL_NOTICE
abnormal/unexpected condition
Definition: logging.h:102
@ _LOG_FLT_COUNT
Definition: logging.h:166
rate_ctr_intv
Rate counter interval.
Definition: rate_ctr.h:15
@ RX_ST_DATA
Definition: sercomm.c:68
uint32_t sec
Definition: gsmtap.h:272
char * mcc
Definition: msgfile.h:37
struct timeval osmo_gettimeofday_override_time
Definition: timer_gettimeofday.c:49
void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags)
Protect against IRQ context.
Definition: sercomm.c:43
unsigned int osmo_sercomm_tx_queue_depth(struct osmo_sercomm_inst *sercomm, uint8_t dlci)
How deep is the Tx queue for a given DLCI?
Definition: sercomm.c:130
void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags)
Release protection against IRQ context.
Definition: sercomm.c:45
static void llist_add(struct llist_head *_new, struct llist_head *head)
add a new entry into a linked list (at head)
Definition: linuxlist.h:88
const char * name
name of the item
Definition: stat_item.h:36
char * option
Definition: msgfile.h:39
A mapping between human-readable string and numeric value.
Definition: utils.h:38
static int handle_counter(struct osmo_counter *counter, void *sctx_)
Definition: stats.c:672
const char * osmo_fsm_inst_name(struct osmo_fsm_inst *fi)
get human-readable name of FSM instance
Definition: fsm.c:406
struct msgb * msgb_copy(const struct msgb *msg, const char *name)
Copy an msgb.
Definition: msgb.c:220
int32_t id
identifier of value
Definition: stat_item.h:18
@ HDLC_SEND_FIRST_FLAG
Definition: isdnhdlc.c:40
int state
transmit state
Definition: sercomm.h:46
void osmo_counter_free(struct osmo_counter *ctr)
Release/Destroy a given counter.
Definition: counter.c:55
static int32_t current_stat_item_index
Definition: stats.c:98
osmo_stats_reporter_type
Statistics Reporter Type.
Definition: stats.h:55
void log_set_category_filter(struct log_target *target, int category, int enable, int level)
Set a category filter on a given log target.
Definition: logging.c:726
void msgb_reset(struct msgb *m)
Re-set all message buffer pointers.
Definition: msgb.c:151
#define OSMO_STAT_ITEM_NO_UNIT
Definition: stat_item.h:14
const char * msgb_hexdump(const struct msgb *msg)
Return a (static) buffer containing a hexdump of the msg.
Definition: msgb.c:307
#define GSMTAP_TYPE_SIM
Definition: gsmtap.h:36
int osmo_stats_report()
Definition: stats.c:714
const char * osmo_strrb_get_nth(const struct osmo_strrb *rb, unsigned int string_index)
Return a pointer to the Nth string in the osmo_strrb.
Definition: strrb.c:106
int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval)
schedule the osmcoom-wrapped timerfd to occur first at first, then periodically at interval
Definition: select.c:292
one instance of a sercomm multiplex/demultiplex
Definition: sercomm.h:33
uint32_t line_nr
line number
Definition: gsmtap.h:283
struct osmo_fsm * fsm
back-pointer to the FSM of which we are an instance
Definition: fsm.h:90
#define GSMTAP_CHANNEL_PACCH
Definition: gsmtap.h:87
#define GSMTAP_CHANNEL_CCCH
Definition: gsmtap.h:78
size_t log_target_rb_used_size(struct log_target const *target)
Return the number of log strings in the osmo_strrb-backed target.
Definition: loggingrb.c:51
struct timespec * osmo_clock_override_gettimespec(clockid_t clk_id)
__attribute__((weak))
Definition: sercomm.c:51
void logp2(int subsys, unsigned int level, const char *file, int line, int cont, const char *format,...) __attribute__((format(printf
logging function used by LOGP() macro
Definition: logging.c:555
void(* pre_term)(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
graceful exit function, called at the beginning of termination
Definition: fsm.h:82
struct gsm_lchan * lchan
logical channel
Definition: msgb.h:45
int osmo_prbs_get_ubits(ubit_t *out, unsigned int out_len, struct osmo_prbs_state *state)
Fill buffer of unpacked bits with next bits out of given PRBS instance.
Definition: prbs.c:70
void log_target_destroy(struct log_target *target)
Unregister, close and delete a log target.
Definition: logging.c:867
static void llist_add_tail(struct llist_head *_new, struct llist_head *head)
add a new entry into a linked list (at tail)
Definition: linuxlist.h:100
uint8_t ubit_t
unpacked bit (0 or 1): 1 bit per byte
Definition: bits.h:24
#define timespecadd(a, b, result)
Definition: timer_compat.h:93
static int check_frame(struct osmo_isdnhdlc_vars *hdlc)
Definition: isdnhdlc.c:79
#define ARRAY_SIZE(x)
Determine number of elements in an array of static size.
Definition: utils.h:14
void(* onenter)(struct osmo_fsm_inst *fi, uint32_t prev_state)
function to be called just after entering the state
Definition: fsm.h:51
uint8_t type
see GSMTAP_TYPE_*
Definition: gsmtap.h:4
struct rb_node * rb_right
Definition: linuxrbtree.h:104
int log_check_level(int subsys, unsigned int level)
Check whether a log entry will be generated.
Definition: logging.c:1135
struct llist_head instances
list of instances of this FSM
Definition: fsm.h:61
@ OSMO_STATS_CLASS_UNKNOWN
unknown class
Definition: stats.h:48
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:36
uint64_t previous
previous value, used for delta
Definition: rate_ctr.h:31
Structure of the GTMTAP libosmocore logging header.
Definition: gsmtap.h:270
#define DLJIBUF
Osmocom Jitter Buffer.
Definition: logging.h:124
unsigned int msg_size
msgb allocation size for rx msgs
Definition: sercomm.h:56
static struct rb_root timer_root
Definition: timer.c:46
const char * group_name_prefix
The prefix to the name of all values in this group.
Definition: stat_item.h:46
int osmo_sercomm_change_speed(struct osmo_sercomm_inst *sercomm, uint32_t bdrt)
wait until everything has been transmitted, then grab the lock and change the baud rate as requested
Definition: sercomm.c:148
void(* cb)(void *)
call-back called at timeout
Definition: timer.h:61
void osmo_fsm_inst_change_parent(struct osmo_fsm_inst *fi, struct osmo_fsm_inst *new_parent, uint32_t new_parent_term_event)
change parent instance of an FSM.
Definition: fsm.c:360
static int is_initialised
Definition: stats.c:97
const struct value_string gsmtap_gsm_channel_names[]
Definition: gsmtap_util.c:451
void(* output)(struct log_target *target, unsigned int level, const char *string)
call-back function to be called when the logging framework wants to log a fully formatted string
Definition: logging.h:291
static int logp2syslog_level(unsigned int level)
Definition: logging_syslog.c:47
#define RB_MAX_MESSAGE_SIZE
A structure representing an osmocom string ringbuffer.
Definition: strrb.h:37
struct log_category * categories
logging categories
Definition: logging.h:241
void osmo_timer_del(struct osmo_timer_list *timer)
delete a timer from timer management
Definition: timer.c:120
int osmo_fsm_register(struct osmo_fsm *fsm)
register a FSM with the core
Definition: fsm.c:154
#define GSMTAP_CHANNEL_CBCH52
Definition: gsmtap.h:88
struct llist_head osmo_log_target_list
const char * name
human-readable name
Definition: counter.h:9
#define llist_entry(ptr, type, member)
Get the struct containing this list entry.
Definition: linuxlist.h:214
#define LOGPSRC(ss, level, caller_file, caller_line, fmt, args...)
Log through the Osmocom logging framework with explicit source.
Definition: logging.h:73
unsigned char * l2h
pointer to A-bis layer 2 header: OML, RSL(RLL), NS
Definition: msgb.h:48
#define GSMTAP_CHANNEL_UNKNOWN
Definition: gsmtap.h:76
char * name
Human-readable name of this reporter.
Definition: stats.h:65
int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
uint16_t remainder
Remainder of the CRC (final XOR)
Definition: crc16gen.h:38
uint16_t end
index of the last slot
Definition: strrb.h:40
structure describing a given CRC code of max 16 bits
Definition: crc16gen.h:34
int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id)
Change id of the FSM instance.
Definition: fsm.c:212
#define DLSTATS
Statistics.
Definition: logging.h:116
struct rb_node * rb_last(const struct rb_root *root)
Definition: rbtree.c:301
struct osmo_counter * osmo_counter_alloc(const char *name)
Allocate a new counter with given name.
Definition: counter.c:40
uint16_t data_len
length of underlying data array
Definition: msgb.h:54
uint64_t current
current value
Definition: rate_ctr.h:30
#define GSMTAP_TYPE_GMR1_UM
Definition: gsmtap.h:42
#define crc_ccitt_byte
Definition: isdnhdlc.c:45
int osmo_counter_difference(struct osmo_counter *ctr)
Compute difference between current and previous counter value.
Definition: counter.c:106
struct osmo_strrb * osmo_strrb_create(TALLOC_CTX *ctx, size_t rb_size)
Create an empty, initialized osmo_strrb.
Definition: strrb.c:59
static int osmo_stats_reporter_log_send(struct osmo_stats_reporter *srep, const char *type, const char *name1, unsigned int index1, const char *name2, int value, const char *unit)
Definition: stats.c:513
@ HDLC_SENDFLAG_B1A6
Definition: isdnhdlc.c:42
#define GSMTAP_CHANNEL_PCH
Definition: gsmtap.h:81
const char * ident
Definition: logging.h:280
const char * osmo_fsm_state_name(struct osmo_fsm *fsm, uint32_t state)
get human-readable name of FSM instance
Definition: fsm.c:422
int osmo_serial_clear_custom_baudrate(int fd)
Clear any custom baudrate.
Definition: serial.c:219
static void rb_set_parent(struct rb_node *rb, struct rb_node *p)
Definition: linuxrbtree.h:122
struct rate_ctr_per_intv intv[RATE_CTR_INTV_NUM]
per-interval data
Definition: rate_ctr.h:33
int8_t snr_db
signal/noise ratio in dB
Definition: gsmtap.h:258
size_t log_target_rb_avail_size(struct log_target const *target)
Return the capacity of the osmo_strrb-backed target.
Definition: loggingrb.c:63
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:171
#define MSGB_ABORT(msg, fmt, args ...)
Definition: msgb.h:86
struct osmo_fsm_inst * osmo_fsm_inst_alloc_child(struct osmo_fsm *fsm, struct osmo_fsm_inst *parent, uint32_t parent_term_event)
allocate a new instance of a specified FSM as child of other FSM instance
Definition: fsm.c:315
uint32_t parent_term_event
the event we should send upon termination
Definition: fsm.h:112
Definition: linuxrbtree.h:99
static const char * const_basename(const char *path)
Definition: logging.c:331
unsigned int active
is it active?
Definition: timer.h:59
#define DLGLOBAL
global logging
Definition: logging.h:107
uint32_t do_bitreverse
Definition: isdnhdlc.h:57
static struct addrinfo * addrinfo_helper(uint16_t family, uint16_t type, uint8_t proto, const char *host, uint16_t port, bool passive)
Definition: socket.c:56
struct osmo_fsm_inst * osmo_fsm_inst_find_by_name(const struct osmo_fsm *fsm, const char *name)
Definition: fsm.c:117
struct osmo_stats_reporter * osmo_stats_reporter_create_log(const char *name)
Create a stats_reporter that logs via libosmocore logging.
Definition: stats.c:500
uint8_t shift_reg
Definition: isdnhdlc.h:45
#define OSMO_HDLC_FRAMING_ERROR
Definition: isdnhdlc.h:70
Structure of the GTMTAP pseudo-header.
Definition: gsmtap.h:250
uint8_t init
Initialization value of the CRC state.
Definition: crc8gen.h:37
Structure representing a file dsecriptor.
Definition: select.h:23
const char * log_level_str(unsigned int lvl) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
convert a numeric log level into human-readable string
Definition: logging.c:218
uint32_t in_event_mask
bit-mask of permitted input events for this state
Definition: fsm.h:43
int log_parse_category(const char *category)
parse a human-readable log category into numeric form
Definition: logging.c:227
void int log_init(const struct log_info *inf, void *talloc_ctx)
Initialize the Osmocom logging core.
Definition: logging.c:1075
char * text
Definition: msgfile.h:40
struct osmo_counter * osmo_counter_get_by_name(const char *name)
Find a counter by its name.
Definition: counter.c:90
uint32_t usec
Definition: gsmtap.h:273
static const char * level_color(int level)
Definition: logging.c:315
int osmo_sercomm_register_rx_cb(struct osmo_sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb)
Register a handler for a given DLCI.
Definition: sercomm.c:249
uint8_t enabled
is logging enabled?
Definition: logging.h:130
#define LOG_MAX_CTX
Maximum number of logging contexts.
Definition: logging.h:15
#define LOGP(ss, level, fmt, args...)
Log a new message through the Osmocom logging framework.
Definition: logging.h:46
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer.
Definition: msgb.c:78
static int llist_empty(const struct llist_head *head)
Test whether a linked list is empty.
Definition: linuxlist.h:165
#define rb_is_red(r)
Definition: linuxrbtree.h:117
int osmo_timers_check(void)
Check how many timers we have in the system.
Definition: timer.c:267
#define rb_parent(r)
Definition: linuxrbtree.h:115
#define BSC_FD_EXCEPT
Indicate interest in exceptions from the file descriptor.
Definition: select.h:20
uint8_t osmo_crc8gen_compute_bits(const struct osmo_crc8gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc8gen.c:44
void osmo_sercomm_sendmsg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
User interface for transmitting messages for a given DLCI.
Definition: sercomm.c:106
void * tall_msgb_ctx
Definition: msgb.c:67
uint64_t state
Definition: prbs.h:15
unsigned int print_timestamp
should log messages be prefixed with a timestamp?
Definition: logging.h:248
#define OSMO_HDLC_F_DCHANNEL
Definition: isdnhdlc.h:62
int enabled
is this reporter enabled
Definition: stats.h:70
#define rb_is_black(r)
Definition: linuxrbtree.h:118
structure describing a given CRC code of max 32 bits
Definition: crc32gen.h:34
char * osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) __attribute__((__deprecated__))
static struct msgb * osmo_sercomm_alloc_msgb(unsigned int len)
Sercomm msgb allocator function.
Definition: sercomm.h:107
static int start_timer()
Definition: stats.c:153
char * osmo_hexdump_nospc(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:268
const char * description
humn-readable description
Definition: counter.h:10
@ HDLC_SENDFLAG_ONE
Definition: isdnhdlc.c:42
const struct value_string * event_names
human-readable names of events
Definition: fsm.h:80
struct osmo_fd * osmo_fd_get_by_fd(int fd)
find an osmo_fd based on the integer fd
Definition: select.c:263
#define DLSS7
Osmocom SS7.
Definition: logging.h:119
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:43
uint32_t out_state_mask
bit-mask to which other states this state may transiton
Definition: fsm.h:45
uint8_t remainder
Remainder of the CRC (final XOR)
Definition: crc8gen.h:38
#define osmo_htons(x)
Definition: byteswap.h:44
char * osmo_hexdump(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:252
unsigned int subsys
Definition: signal.c:44
description of a rate counter group
Definition: rate_ctr.h:43
void rb_erase(struct rb_node *, struct rb_root *)
Definition: rbtree.c:219
uint8_t hdr_len
length in number of 32bit words
Definition: gsmtap.h:252
struct osmo_stat_item * items[0]
Actual counter structures below.
Definition: stat_item.h:66
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition: msgb.h:201
int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port)
const char * description
description text
Definition: logging.h:137
char * osmo_sock_get_name(void *ctx, int fd)
Get address/port information on soocket in dyn-alloc string.
Definition: socket.c:671
@ OSMO_STATS_CLASS_SUBSCRIBER
subscriber
Definition: stats.h:51
int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data)
Iterate over all counter groups.
Definition: rate_ctr.c:411
#define DLGSUP
Generic Subscriber Update Protocol.
Definition: logging.h:117
int interval
Definition: stats.h:106
static int gsmtap_inst_fd(struct gsmtap_inst *gti)
obtain the file descriptor associated with a gsmtap instance
Definition: gsmtap_util.h:32
static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags)
Definition: gsmtap_util.c:351
static int osmo_stats_reporter_check_config(struct osmo_stats_reporter *srep, unsigned int index, int class_id)
Definition: stats.c:555
Statistics item description.
Definition: stat_item.h:35
static void rb_set_color(struct rb_node *rb, int color)
Definition: linuxrbtree.h:126
void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause, void *data, const char *file, int line)
Terminate FSM instance with given cause.
Definition: fsm.c:601
const char * name
human-readable name of this state
Definition: fsm.h:47
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:128
struct llist_head entry
Definition: signal.c:43
char * name_prefix
prefix for counter names
Definition: stats.h:71
static LLIST_HEAD(osmo_fds)
uint64_t last
counter value in last interval
Definition: rate_ctr.h:24
int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, uint8_t proto, unsigned int flags)
Initialize a socket and fill sockaddr.
Definition: socket.c:465
Log context information, passed to filter.
Definition: logging.h:143
uint16_t arfcn
ARFCN (frequency)
Definition: gsmtap.h:7
#define DLSCCP
Osmocom SCCP.
Definition: logging.h:120
#define GSMTAP_TYPE_UM_BURST
Definition: gsmtap.h:35
int filter_map
Internal data for filtering.
Definition: logging.h:236
static int32_t global_value_id
counter for assigning globally unique value identifiers
Definition: stat_item.c:67
@ RATE_CTR_INTV_DAY
last day
Definition: rate_ctr.h:19
static const struct log_info_cat internal_cat[OSMO_NUM_DLIB]
Definition: logging.c:80
int osmo_timer_remaining(const struct osmo_timer_list *timer, const struct timeval *now, struct timeval *remaining)
compute the remaining time of a timer
Definition: timer.c:152
static uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data)
CRC-16 polynome 0x8005 (x^16 + x^15 + x^2 + 1)
Definition: crc16.h:32
#define GSMTAP_TYPE_LTE_RRC
Definition: gsmtap.h:45
#define OSMO_SNPRINTF_RET(ret, rem, offset, len)
Definition: utils.h:65
int class_id
The class to which this group belongs.
Definition: stat_item.h:50
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:43
void * ctx[LOG_MAX_CTX+1]
Definition: logging.h:144
struct msgb * gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type, uint8_t ss, uint32_t fn, int8_t signal_dbm, uint8_t snr, const uint8_t *data, unsigned int len)
create L1/L2 data and put it into GSMTAP
Definition: gsmtap_util.c:199
void osmo_crc64gen_set_bits(const struct osmo_crc64gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
Computes and writes the CRC value of a given array of bits.
Definition: crc64gen.c:104
static const char hex_chars[]
Definition: utils.c:179
static unsigned int llist_count(struct llist_head *head)
count nr of llist items by iterating.
Definition: linuxlist.h:390
static int gsmtap_wq_w_cb(struct osmo_fd *ofd, struct msgb *msg)
Definition: gsmtap_util.c:335
int fd
actual operating-system level file decriptor
Definition: select.h:27
void osmo_stats_init(void *ctx)
Initilize the stats reporting module; call this once in your program.
Definition: stats.c:191
state of a given PRBS sequence generator
Definition: prbs.h:13
#define GSMTAP_TYPE_UMTS_RRC
Definition: gsmtap.h:44
int osmo_stat_item_for_each_item(struct osmo_stat_item_group *statg, osmo_stat_item_handler_t handle_item, void *data)
Iterate over all items in group, call user-supplied function on each.
Definition: stat_item.c:301
#define OSMO_MIN(a, b)
Return the minimum of two specified values.
Definition: utils.h:18
uint32_t poly
Polynom (normal representation, MSB omitted.
Definition: crc32gen.h:36
unsigned long value
current value
Definition: counter.h:11
static int state_chg(struct osmo_fsm_inst *fi, uint32_t new_state, bool keep_timer, unsigned long timeout_secs, int T, const char *file, int line)
Definition: fsm.c:432
uint8_t antenna_nr
Antenna Number.
Definition: gsmtap.h:263
#define DLGTP
GTP (GPRS Tunneling Protocol.
Definition: logging.h:115
char name[32]
source file name
Definition: gsmtap.h:282
static int osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
Definition: stats.c:663
bool osmo_strrb_is_empty(const struct osmo_strrb *rb)
Check if an osmo_strrb is empty.
Definition: strrb.c:92
#define LOGL_DEBUG
different log levels
Definition: logging.h:100
void osmo_crc16gen_set_bits(const struct osmo_crc16gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
Computes and writes the CRC value of a given array of bits.
Definition: crc16gen.c:104
unsigned char * head
start of underlying memory buffer
Definition: msgb.h:57
@ RX_ST_CTRL
Definition: sercomm.c:67
#define OSMO_SOCK_F_BIND
bind the socket to a local address/port
Definition: socket.h:20
uint64_t remainder
Remainder of the CRC (final XOR)
Definition: crc64gen.h:38
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition: msgb.c:116
void osmo_vlogp(int subsys, int level, const char *file, int line, int cont, const char *format, va_list ap)
vararg version of logging function
Definition: logging.c:507
int osmo_stat_item_init(void *tall_ctx)
Initialize the stat item module.
Definition: stat_item.c:246
void * data
data pointer passed through to call-back function
Definition: select.h:35
unsigned int primitive
Primitive number.
Definition: prim.h:45
static void fsm_tmr_cb(void *data)
Definition: fsm.c:183
unsigned int primitive
primtiive to match
Definition: prim.h:84
#define LOGL_ERROR
error condition, requires user action
Definition: logging.h:103
@ RATE_CTR_INTV_SEC
last second
Definition: rate_ctr.h:16
uint8_t version
version, set to 0x01 currently
Definition: gsmtap.h:251
int osmo_stats_set_interval(int interval)
Set the reporting interval of a given stats_reporter (in seconds).
Definition: stats.c:333
static LLIST_HEAD(rate_ctr_groups)
int msgb_printf(struct msgb *msgb, const char *format,...)
Print a string to the end of message buffer.
Definition: msgb.c:402
#define GSMTAP_TYPE_TETRA_I1
Definition: gsmtap.h:37
static void osmo_store64be_ext(uint64_t x, void *p, uint8_t n)
store unaligned n-byte integer (big-endian encoding) from uint64_t
Definition: bit64gen.h:71
@ LOG_TGT_TYPE_STRRB
osmo_strrb-backed logging
Definition: logging.h:220
int osmo_crc64gen_check_bits(const struct osmo_crc64gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
Checks the CRC value of a given array of hard-bits.
Definition: crc64gen.c:79
char proc_name[16]
name of process
Definition: gsmtap.h:275
int osmo_select_main(int polling)
select main loop integration
Definition: select.c:234
int osmo_constant_time_cmp(const uint8_t *exp, const uint8_t *rel, const int count)
Wishful thinking to generate a constant time compare.
Definition: utils.c:321
data we keep for each actual value
Definition: rate_ctr.h:29
void log_set_all_filter(struct log_target *target, int)
Enable the LOG_FLT_ALL log filter.
Definition: logging.c:615
static int maxfd
Definition: select.c:50
struct osmo_timer_list timer
timer back-end for states with time-out
Definition: fsm.h:105
struct llist_head list
global list
Definition: fsm.h:59
int ffbit_shift
Definition: isdnhdlc.h:38
unsigned char _data[0]
optional immediate data array
Definition: msgb.h:60
struct osmo_fsm_inst * osmo_fsm_inst_find_by_id(const struct osmo_fsm *fsm, const char *id)
Definition: fsm.c:134
@ LOG_FLT_ALL
Definition: logging.h:161
void(* dlci_cb_t)(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
call-back function for per-DLC receive handler
Definition: sercomm.h:30
static uint16_t osmo_crc16_ccitt_byte(uint16_t crc, const uint8_t data)
CCITT polynome 0x8408 (x^0 + x^5 + x^12)
Definition: crc16.h:44
const uint16_t osmo_crc16_table[256]
CRC table for the CRC-16.
Definition: crc16.c:18
log_filename_type
Whether/how to log the source filename (and line number).
Definition: logging.h:225
#define OSMO_SOCK_F_NO_MCAST_ALL
disable receiving all multiast even for non-subscribed groups
Definition: socket.h:26
@ PRIM_OP_CONFIRM
confirm
Definition: prim.h:30
void rb_erase(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:219
unsigned int sap
Service Access Point Identifier.
Definition: prim.h:44
uint16_t init
Initialization value of the CRC state.
Definition: crc16gen.h:37
uint64_t osmo_crc64gen_compute_bits(const struct osmo_crc64gen_code *code, const ubit_t *in, int len)
Compute the CRC value of a given array of hard-bits.
Definition: crc64gen.c:44
void log_fini(void)
Definition: logging.c:1120
static int socket_helper(const struct addrinfo *rp, unsigned int flags)
Definition: socket.c:90
int log_level
logging level for this FSM
Definition: fsm.h:98
@ PRIM_OP_RESPONSE
response
Definition: prim.h:28
int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data, int data_len)
#define DLMGCP
Osmocom MGCP.
Definition: logging.h:123
uint32_t do_closing
Definition: isdnhdlc.h:55
struct osmo_sercomm_inst::@17 rx
receive side
int osmo_crc16gen_check_bits(const struct osmo_crc16gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
Checks the CRC value of a given array of hard-bits.
Definition: crc16gen.c:79
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:128
#define DLSMS
SMS sub-system.
Definition: logging.h:113
@ RX_ST_WAIT_START
Definition: sercomm.c:65
struct llist_head list
internal list head
Definition: counter.h:8
struct llist_head list
member in the fsm->instances list
Definition: fsm.h:88
struct log_info * osmo_log_info
Definition: logging.c:61
void osmo_str2upper(char *out, const char *in)
Convert an entire string to upper case.
Definition: utils.c:301
static void rb_link_node(struct rb_node *node, struct rb_node *parent, struct rb_node **rb_link)
Definition: linuxrbtree.h:151
static struct timeval * nearest_p
Definition: timer.c:44
uint32_t init
Initialization value of the CRC state.
Definition: crc32gen.h:37
unsigned int idx
The index of this ctr_group within its class.
Definition: rate_ctr.h:63
#define DLINP
(A-bis) Input sub-system
Definition: logging.h:109
@ HDLC_FAST_IDLE
Definition: isdnhdlc.c:34
structure describing a given CRC code of max 8 bits
Definition: crc8gen.h:34