libosmocore  1.7.0.61-0d9b6.202211030053
Osmocom core library
application.h File Reference

Go to the source code of this file.

Functions

void osmo_init_ignore_signals (void)
 Ignore SIGPIPE, SIGALRM, SIGHUP and SIGIO. More...
 
int osmo_init_logging (const struct log_info *) OSMO_DEPRECATED("use osmo_init_logging2() instead to avoid a NULL talloc ctx")
 Initialize the osmocom logging framework. More...
 
int osmo_init_logging2 (void *ctx, const struct log_info *log_info)
 
int osmo_daemonize (void)
 Turn the current process into a background daemon. More...
 

Variables

struct log_targetosmo_stderr_target
 the default logging target, logging to stderr More...
 

Detailed Description

Routines for helping with the osmocom application setup.

Function Documentation

◆ 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_infoArray 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 
)

Variable Documentation

◆ osmo_stderr_target

struct log_target* osmo_stderr_target

the default logging target, logging to stderr

Referenced by osmo_init_logging2().

osmo_stats_reporter::have_net_config
unsigned int have_net_config
Definition: stats.h:63
fill_stats
static void fill_stats(struct stats_tcp_entry *stats_tcp_entry)
Definition: stats_tcp.c:97
osmo_gettimeofday
int osmo_gettimeofday(struct timeval *tv, struct timezone *tz)
shim around gettimeofday to be able to set the time manually.
Definition: timer_gettimeofday.c:56
osmo_strrb::buffer
char ** buffer
storage for messages
Definition: strrb.h:38
osmo_counter_difference
int osmo_counter_difference(struct osmo_counter *ctr)
Compute difference between current and previous counter value.
Definition: counter.c:102
osmo_timer_list
A structure representing a single instance of a timer.
Definition: timer.h:52
osmo_tdef_unit_names
const struct value_string osmo_tdef_unit_names[]
Definition: tdef.c:360
osmo_stats_reporter_disable
int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep)
Disable the given stats_reporter.
Definition: stats.c:442
flush_all_reporters
static void flush_all_reporters(void)
Definition: stats.c:767
_osmo_strrb_is_bufindex_valid
bool _osmo_strrb_is_bufindex_valid(const struct osmo_strrb *rb, unsigned int bufi)
Definition: strrb.c:115
osmo_strrb::start
uint16_t start
index of the first slot
Definition: strrb.h:35
OSMO_STATS_CLASS_GLOBAL
@ OSMO_STATS_CLASS_GLOBAL
global counter/stat_item
Definition: stats.h:45
osmo_time_cc::total_sum
uint64_t total_sum
Overall cumulative sum.
Definition: time_cc.h:165
osmo_use_count_repurpose_zero_entry
static struct osmo_use_count_entry * osmo_use_count_repurpose_zero_entry(struct osmo_use_count *uc, const char *use)
Find a use count entry that currently has zero count, and re-use that for this new use token.
Definition: use_count.c:177
rate_ctr_for_each_counter
int rate_ctr_for_each_counter(struct rate_ctr_group *ctrg, rate_ctr_handler_t handle_counter, void *data)
Iterate over each counter in group and call function.
Definition: rate_ctr.c:413
osmo_stats_reporter::dest_port
int dest_port
destination (UDP) port
Definition: stats.h:70
TRACE
#define TRACE(probe)
Definition: stats.c:97
osmo_stats_reporter_free
void osmo_stats_reporter_free(struct osmo_stats_reporter *srep)
Destroy a given stats_reporter.
Definition: stats.c:232
timerclear
#define timerclear(tvp)
Definition: timer_compat.h:39
osmo_time_cc_init
void osmo_time_cc_init(struct osmo_time_cc *tc)
osmo_quote_str_buf3
int osmo_quote_str_buf3(char *buf, size_t bufsize, const char *str, int in_len)
Like osmo_escape_str_buf3(), but returns double-quotes around a string, or "NULL" for a NULL string.
Definition: utils.c:907
rate_ctr_desc
rate counter description
Definition: rate_ctr.h:37
osmo_tcp_stats_config::batch_size
int batch_size
Definition: stats_tcp.h:10
osmo_is_hexstr
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:611
time
char time[12]
osmo_strrb_add
int osmo_strrb_add(struct osmo_strrb *rb, const char *data)
Add a string to the osmo_strrb.
Definition: strrb.c:148
osmo_stats_reporter_alloc
struct osmo_stats_reporter * osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type, const char *name)
Definition: stats.c:212
OSMO_TDEF_S
@ OSMO_TDEF_S
most T are in seconds, keep 0 as default.
Definition: tdef.h:39
osmo_stats_reporter_sanitize_name
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:73
osmo_stat_item::reported
struct osmo_stat_item_period reported
The results of the previous reporting period.
Definition: stat_item_internal.h:32
osmo_char2bcd
uint8_t osmo_char2bcd(char c)
Convert number in ASCII to BCD value.
Definition: utils.c:122
timeradd
#define timeradd(a, b, result)
Definition: timer_compat.h:50
STATS_TCP_REORD_SEEN
@ STATS_TCP_REORD_SEEN
Definition: stats_tcp.c:74
osmo_stats_reporter::running
int running
is this reporter running
Definition: stats.h:79
osmo_stats_reporter::flush_period
unsigned int flush_period
period between regular flushes
Definition: stats.h:72
osmo_wqueue::current_length
unsigned int current_length
current length of write queue
Definition: write_queue.h:36
osmo_str2lower
void osmo_str2lower(char *out, const char *in) OSMO_DEPRECATED("Use osmo_str_tolower() or osmo_str_tolower_buf() instead
Convert an entire string to lower case.
Definition: utils.c:469
osmo_time_cc_cfg::T_gran
int T_gran
Update gran_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:118
osmo_stat_item_group_set_name
void osmo_stat_item_group_set_name(struct osmo_stat_item_group *statg, const char *name)
Set a name for the statistics item group to be used instead of index value at report time.
Definition: stat_item.c:249
osmo_ubit_dump_buf
char * osmo_ubit_dump_buf(char *buf, size_t buf_len, const uint8_t *bits, unsigned int len)
Convert a sequence of unpacked bits to ASCII string, in user-supplied buffer.
Definition: utils.c:341
osmo_stats_reporter::bind_addr_len
int bind_addr_len
length of bind_addr in bytes
Definition: stats.h:83
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:54
rate_ctr_add
void rate_ctr_add(struct rate_ctr *ctr, int inc)
Increment the counter by inc.
Definition: rate_ctr.c:283
osmo_tdef_get_state_timeout
const struct osmo_tdef_state_timeout * osmo_tdef_get_state_timeout(uint32_t state, const struct osmo_tdef_state_timeout *timeouts_array)
Using osmo_tdef for osmo_fsm_inst: find a given state's osmo_tdef_state_timeout entry.
Definition: tdef.c:318
osmo_quote_cstr_buf
size_t osmo_quote_cstr_buf(char *buf, size_t bufsize, const char *str, int in_len)
Like osmo_escape_str_buf2(), but returns double-quotes around a string, or "NULL" for a NULL string.
Definition: utils.c:1008
node
uint16_t node
osmo_time_cc_set_flag
void osmo_time_cc_set_flag(struct osmo_time_cc *tc, bool flag)
rate_ctr_group::desc
const struct rate_ctr_group_desc * desc
Pointer to the counter group class.
Definition: rate_ctr.h:61
len
static size_t len(const char *str)
osmo_stats_reporter::dest_addr
struct sockaddr dest_addr
destination address of socket
Definition: stats.h:80
stats_tcp_poll_timer
static struct osmo_timer_list stats_tcp_poll_timer
Definition: stats_tcp.c:52
osmo_stat_item_period::max
int32_t max
Largest value seen in a reporting period.
Definition: stat_item_internal.h:17
n
write Write running configuration to or terminal n Write configuration to the copy running config startup Copy configuration n Copy running config to n Copy running config to startup write Write running configuration to or terminal n Write to terminal n
osmo_timer_add
void osmo_timer_add(struct osmo_timer_list *timer)
add a new timer to the timer management
Definition: timer.c:80
OSMO_STATS_REPORTER_LOG
@ OSMO_STATS_REPORTER_LOG
libosmocore logging
Definition: stats.h:52
osmo_time_cc::cfg
struct osmo_time_cc_cfg cfg
Definition: time_cc.h:159
osmo_stats_reporter_statsd_send_counter
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:158
osmo_quote_str_buf2
char * osmo_quote_str_buf2(char *buf, size_t bufsize, const char *str, int in_len)
Like osmo_escape_str_buf2(), but returns double-quotes around a string, or "NULL" for a NULL string.
Definition: utils.c:921
OSMO_ASSERT
#define OSMO_ASSERT(exp)
Helper macro to terminate when an assertion fails.
Definition: utils.h:113
osmo_stats_class
osmo_stats_class
Statistics Class definitions.
Definition: stats.h:43
osmo_stats_reporter_log_send_item
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:618
osmo_stat_item_group
One instance of a counter group class.
Definition: stat_item.h:45
write_queue.h
count_safe
static bool count_safe(int32_t *val_p, int32_t add)
Add two int32_t but make sure to min- and max-clamp at INT32_MIN and INT32_MAX, respectively.
Definition: use_count.c:43
msgb_put
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:240
__add_timer
static void __add_timer(struct osmo_timer_list *timer)
Definition: timer.c:44
osmo_stat_item_group_free
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:225
rate_ctr_group_desc::class_id
int class_id
The class to which this group belongs.
Definition: rate_ctr.h:49
rate_ctr_group_handler
static int rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_)
Definition: stats.c:679
timer_root
static __thread struct rb_root timer_root
Definition: timer.c:42
osmo_stat_item_group::idx
unsigned int idx
The index of this value group within its class.
Definition: stat_item.h:51
osmo_wqueue::max_length
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:34
osmo_strrb::size
uint16_t size
max number of messages to store
Definition: strrb.h:37
alias
char alias("osmo_hexdump_nospc")))
osmo_identifier_sanitize_buf
void osmo_identifier_sanitize_buf(char *str, const char *sep_chars, char replace_with)
Replace characters in the given string buffer so that it is guaranteed to pass osmo_separated_identif...
Definition: utils.c:683
stats_tcp_entry::entry
struct llist_head entry
Definition: stats_tcp.c:59
osmo_wqueue::write_cb
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:44
osmo_tdef::val
unsigned long val
Currently active timeout value, e.g.
Definition: tdef.h:80
osmo_stats_reporter_send_buffer
int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
osmo_escape_cstr_buf
size_t osmo_escape_cstr_buf(char *buf, size_t bufsize, const char *str, int in_len)
Return the string with all non-printable characters escaped.
Definition: utils.c:978
STATS_TCP_NOTSENT_BYTES
@ STATS_TCP_NOTSENT_BYTES
Definition: stats_tcp.c:71
osmo_strrb_elements
size_t osmo_strrb_elements(const struct osmo_strrb *rb)
Count the number of log messages in an osmo_strrb.
Definition: strrb.c:132
osmo_time_cc::last_counted_time
uint64_t last_counted_time
CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc last evaluated the flag st...
Definition: time_cc.h:173
osmo_stats_reporter_set_local_addr
int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr)
osmo_use_count::use_counts
struct llist_head use_counts
List of use tokens.
Definition: use_count.h:175
osmo_stat_item
data we keep for each actual item
Definition: stat_item_internal.h:23
osmo_stats_reporter_list
struct llist_head osmo_stats_reporter_list
osmo_escape_str
const char * osmo_escape_str(const char *str, int len)
Return the string with all non-printable characters escaped.
Definition: utils.c:855
osmo_fd::cb
int(* cb)(struct osmo_fd *fd, unsigned int what)
call-back function to be called once file descriptor becomes available
Definition: select.h:41
stats_tcp_lock
pthread_mutex_t stats_tcp_lock
Definition: stats_tcp.c:56
osmo_talloc_replace_string_fmt
void osmo_talloc_replace_string_fmt(void *ctx, char **dst, const char *fmt,...)
Replace a string using talloc and release its prior content (if any).
Definition: utils.c:1523
stats_tcp_entry::stats_tcp
struct osmo_stat_item_group * stats_tcp
Definition: stats_tcp.c:61
osmo_stats_reporter::send_item
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:97
STATS_DEFAULT_BUFLEN
#define STATS_DEFAULT_BUFLEN
Definition: stats.c:104
osmo_use_count_create
static struct osmo_use_count_entry * osmo_use_count_create(struct osmo_use_count *uc, const char *use)
Allocate a new use count entry, happens implicitly in osmo_use_count_get_put().
Definition: use_count.c:192
osmo_time_cc
Report the cumulative counter of time for which a flag is true as rate counter.
Definition: time_cc.h:158
_osmo_tdef_fsm_inst_state_chg
int _osmo_tdef_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t state, const struct osmo_tdef_state_timeout *timeouts_array, const struct osmo_tdef *tdefs, long default_timeout, const char *file, int line)
See invocation macro osmo_tdef_fsm_inst_state_chg() instead.
Definition: tdef.c:332
osmo_time_cc_cfg::round_threshold_usec
uint64_t round_threshold_usec
Nr of microseconds above n * gran_usec at which to trigger a counter increment.
Definition: time_cc.h:111
osmo_decode_big_endian
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:524
osmo_clock_gettime
int osmo_clock_gettime(clockid_t clk_id, struct timespec *tp)
osmo_stats_reporter::fd
int fd
file descriptor of socket
Definition: stats.h:84
__attribute__
struct gsm48_classmark3 __attribute__
fls64 - find last set bit in a 64-bit word @x: the word to search
Definition: log2.h:61
osmo_separated_identifiers_valid
bool osmo_separated_identifiers_valid(const char *str, const char *sep_chars)
Determine if a given identifier is valid, i.e.
Definition: utils.c:641
STATS_TCP_RETRANS
@ STATS_TCP_RETRANS
Definition: stats_tcp.c:68
RB_ROOT
#define RB_ROOT
Definition: linuxrbtree.h:126
osmo_timers_nearest_ms
int osmo_timers_nearest_ms(void)
Determine time between now and the nearest timer in milliseconds.
Definition: timer.c:186
msg
uint8_t msg[0]
_osmo_fsm_inst_state_chg
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:742
get_string_value
int get_string_value(const struct value_string *vs, const char *str)
get numeric value for given human-readable string
Definition: utils.c:93
llist_head::next
struct llist_head * next
Pointer to next and previous item.
Definition: linuxlist.h:48
osmo_str_tolower_c
char * osmo_str_tolower_c(const void *ctx, const char *src)
Convert a string to lowercase, dynamically allocating the output from given talloc context See also o...
Definition: utils.c:1115
msgb_tailroom
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:211
get_value_string_or_null
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:70
osmo_escape_cstr_c
char * osmo_escape_cstr_c(void *ctx, const char *str, int in_len)
Return the string with all non-printable characters escaped, in dynamically-allocated buffer.
Definition: utils.c:990
osmo_strrb_get_nth
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:102
is_tcp
static bool is_tcp(const struct osmo_fd *fd)
Definition: stats_tcp.c:166
osmo_stat_item_group_desc
Description of a statistics item group.
Definition: stat_item.h:31
name
const char * name
osmo_stat_item_handler
static int osmo_stat_item_handler(struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_)
Definition: stats.c:699
osmo_timers_update
int osmo_timers_update(void)
fire all timers...
Definition: timer.c:233
osmo_stats_reporter::type
enum osmo_stats_reporter_type type
Type of the reporter (log, statsd)
Definition: stats.h:59
osmo_stat_item::value
struct osmo_stat_item_period value
Current reporting period / current value.
Definition: stat_item_internal.h:28
llist_del_init
static void llist_del_init(struct llist_head *entry)
Delete a single entry from a linked list and reinitialize it.
Definition: linuxlist.h:138
OSMO_FD_READ
#define OSMO_FD_READ
Indicate interest in reading from the file descriptor.
Definition: select.h:17
osmo_tdefs_reset
void osmo_tdefs_reset(struct osmo_tdef *tdefs)
Set all osmo_tdef values to the default_val.
Definition: tdef.c:154
INIT_LLIST_HEAD
#define INIT_LLIST_HEAD(ptr)
Initialize a llist_head to point back to itself.
Definition: linuxlist.h:65
osmo_gettimeofday_override_add
void osmo_gettimeofday_override_add(time_t secs, suseconds_t usecs)
convenience function to advance the fake time.
Definition: timer_gettimeofday.c:68
osmo_stats_reporter_create_statsd
struct osmo_stats_reporter * osmo_stats_reporter_create_statsd(const char *name)
Create a stats_reporter reporting to statsd.
Definition: stats_statsd.c:53
osmo_strlcpy
size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
Copy a C-string into a sized buffer.
Definition: utils.c:565
osmo_stats_tcp_set_interval
int osmo_stats_tcp_set_interval(int interval)
Set the polling interval (common for all sockets)
Definition: stats_tcp.c:303
osmo_stats_reporter::flush_period_counter
unsigned int flush_period_counter
count sends between forced flushes
Definition: stats.h:88
STATS_TCP_SNDBUF_LIMITED
@ STATS_TCP_SNDBUF_LIMITED
Definition: stats_tcp.c:73
update_nearest
static void update_nearest(struct timeval *cand, struct timeval *current)
Definition: timer.c:199
OSMO_STATS_REPORTER_STATSD
@ OSMO_STATS_REPORTER_STATSD
statsd backend
Definition: stats.h:53
osmo_tdef
Define a GSM timer of the form Tnnn, with unit, default value and doc string.
Definition: tdef.h:65
osmo_use_count_total
int32_t osmo_use_count_total(const struct osmo_use_count *uc)
Return the sum of all use counts, min- and max-clamped at INT32_MIN and INT32_MAX.
Definition: use_count.c:67
osmo_stats_reporter
One statistics reporter instance.
Definition: stats.h:57
OTC_GLOBAL
#define OTC_GLOBAL
Definition: talloc.h:26
osmo_tcp_stats_config
Definition: stats_tcp.h:6
container_of
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.
Definition: linuxlist.h:32
LLIST_HEAD
LLIST_HEAD(osmo_stats_reporter_list)
osmo_stats_reporter::close
int(* close)(struct osmo_stats_reporter *srep)
Definition: stats.h:92
osmo_time_cc::sum
uint64_t sum
Internal cumulative counter of time that flag_state was true.
Definition: time_cc.h:177
osmo_tdef_state_timeout::keep_timer
bool keep_timer
If true, call osmo_fsm_inst_state_chg_keep_timer().
Definition: tdef.h:118
timersub
#define timersub(a, b, result)
Definition: timer_compat.h:63
osmo_quote_str
const char * osmo_quote_str(const char *str, int in_len)
Like osmo_quote_str_buf() but returns the result in a static buffer.
Definition: utils.c:951
osmo_fsm_inst
a single instanceof an osmocom finite state machine
Definition: fsm.h:87
OSMO_NAME_C_IMPL
#define OSMO_NAME_C_IMPL(CTX, INITIAL_BUFSIZE, ON_ERROR, FUNC_BUF, FUNC_BUF_ARGS...)
Translate a buffer function to a talloc context function.
Definition: utils.h:328
rate_ctr_handler
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:652
msgb_enqueue_count
static void msgb_enqueue_count(struct llist_head *queue, struct msgb *msg, unsigned int *count)
Enqueue message buffer to tail of a queue and increment queue size counter.
Definition: msgb.h:95
osmo_tdef::unit
enum osmo_tdef_unit unit
Definition: tdef.h:74
time_cc.h
osmo_counter
Structure representing a single counter.
Definition: counter.h:9
msgb_length
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:285
osmo_identifier_illegal_chars
static const char osmo_identifier_illegal_chars[]
Definition: utils.c:634
llist_del
static void llist_del(struct llist_head *entry)
Delete a single entry from a linked list.
Definition: linuxlist.h:128
osmo_strbuf::chars_needed
size_t chars_needed
After all OSMO_STRBUF_APPEND operations, reflects the total number of characters that would be writte...
Definition: utils.h:198
osmo_stats_reporter_find
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:256
osmo_tdef::default_val
const unsigned long default_val
Timeout duration (according to unit), default value; type corresponds to osmo_fsm_inst_state_chg()'s ...
Definition: tdef.h:73
osmo_stats_reporter::force_single_flush
int force_single_flush
set to 1 to force a flush (send even unchanged stats values)
Definition: stats.h:87
osmo_timer_list::timeout
struct timeval timeout
expiration time
Definition: timer.h:55
osmo_stat_item_set
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:282
llist_first_entry
#define llist_first_entry(ptr, type, member)
Get the first element from a linked list.
Definition: linuxlist.h:228
stats_tcp_entry
Definition: stats_tcp.c:58
osmo_time_cc_cfg::T_defs
struct osmo_tdef * T_defs
Look up T_gran and T_forget_sum in this list of timers, or NULL to not use any T timers.
Definition: time_cc.h:124
data
uint8_t data[0]
osmo_use_count_entry::use
const char * use
Use token string that was passed to osmo_use_count_get_put().
Definition: use_count.h:196
osmo_stats_config
Definition: stats.h:103
BACKSLASH_CASE
#define BACKSLASH_CASE(c, repr)
msgb
Osmocom message buffer.
Definition: msgb.h:31
rb_insert_color
void rb_insert_color(struct rb_node *, struct rb_root *)
Definition: rbtree.c:69
osmo_clock_override_add
void osmo_clock_override_add(clockid_t clk_id, time_t secs, long nsecs)
timer_compat.h
osmo_stats_reporter_send_counter
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:641
LOGL_INFO
#define LOGL_INFO
general information
Definition: logging.h:123
strrb.h
nearest_p
static __thread struct timeval * nearest_p
Definition: timer.c:40
osmo_use_count
Use counter state for one used object, managing N distinct named counters.
Definition: use_count.h:168
osmo_use_count_entry
One named counter in the list managed by osmo_use_count.
Definition: use_count.h:190
rb_root
Definition: linuxrbtree.h:104
osmo_stats_ctx
static void * osmo_stats_ctx
Definition: stats.c:107
osmo_wqueue::read_cb
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:42
STATS_TCP_RWND_LIMITED
@ STATS_TCP_RWND_LIMITED
Definition: stats_tcp.c:72
osmo_stats_reporter::dest_addr_len
int dest_addr_len
length of dest_addr in bytes
Definition: stats.h:81
stats.h
utils.h
osmo_stat_item::desc
const struct osmo_stat_item_desc * desc
back-reference to the item description
Definition: stat_item_internal.h:25
osmo_stats_reporter::dest_addr_str
char * dest_addr_str
destination IP address
Definition: stats.h:68
rate_ctr_group
One instance of a counter group class.
Definition: rate_ctr.h:57
osmo_escape_str_buf
const char * osmo_escape_str_buf(const char *str, int in_len, char *buf, size_t bufsize)
Like osmo_escape_str_buf2, but with unusual ordering of arguments, and may sometimes return string co...
Definition: utils.c:706
osmo_tdef_state_timeout::T
int T
Timer number to match struct osmo_tdef.T, and to pass to osmo_fsm_inst_state_chg().
Definition: tdef.h:115
TCP_STATS_DEFAULT_INTERVAL
#define TCP_STATS_DEFAULT_INTERVAL
Definition: stats_tcp.h:3
osmo_tdef_val_in_range
bool osmo_tdef_val_in_range(struct osmo_tdef *tdef, unsigned long new_val)
Check if value new_val is in range of valid possible values for timer entry tdef.
Definition: tdef.c:261
osmo_stats_reporter_send_item
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:688
s_stats_config
static struct osmo_stats_config s_stats_config
Definition: stats.c:110
rb_first
struct rb_node * rb_first(const struct rb_root *)
Definition: rbtree.c:284
osmo_panic
void osmo_panic(const char *fmt,...) __attribute__((noreturn))
Terminate the current program with a panic.
Definition: panic.c:71
osmo_stats_reporter_udp_open
int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep)
_osmo_fsm_inst_state_chg_keep_timer
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:774
msgb_free
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:117
OSMO_TDEF_M
@ OSMO_TDEF_M
minutes
Definition: tdef.h:41
osmo_time_cc_cfg::T_forget_sum
int T_forget_sum
Update forget_sum_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:122
osmo_tdef_unit
osmo_tdef_unit
Definition: tdef.h:38
stats_tcp.h
osmo_stats_reporter_statsd_send_item
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:181
osmo_hexdump_c
char * osmo_hexdump_c(const void *ctx, const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:407
osmo_wqueue_enqueue_quiet
int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue (without logging full queue events)
Definition: write_queue.c:107
osmo_use_count_to_str_buf
int osmo_use_count_to_str_buf(char *buf, size_t buf_len, const struct osmo_use_count *uc)
Write a comprehensive listing of use counts to a string buffer.
Definition: use_count.c:117
osmo_timer_list::data
void * data
user data for callback
Definition: timer.h:59
stat_item_internal.h
osmo_use_count_by
int32_t osmo_use_count_by(const struct osmo_use_count *uc, const char *use)
Return use count by a single use token.
Definition: use_count.c:86
osmo_ubit_dump
char * osmo_ubit_dump(const uint8_t *bits, unsigned int len)
Convert a sequence of unpacked bits to ASCII string, in static buffer.
Definition: utils.c:376
osmo_tdef::min_val
unsigned long min_val
Minimum timer value (in this tdef unit), checked if set (not zero).
Definition: tdef.h:82
osmo_stats_reporter_set_max_class
int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep, enum osmo_stats_class class_id)
Definition: stats.c:370
osmo_use_count_name_buf
const char * osmo_use_count_name_buf(char *buf, size_t buf_len, const struct osmo_use_count *uc)
Write a comprehensive listing of use counts to a string buffer.
Definition: use_count.c:104
value_string::str
const char * str
human-readable string
Definition: utils.h:53
osmo_wqueue_enqueue
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue.
Definition: write_queue.c:123
osmo_time_cc_cfg::rate_ctr
struct rate_ctr * rate_ctr
Rate counter to report to, or NULL to not use it.
Definition: time_cc.h:115
timer.h
stats_tcp_desc
static struct osmo_stat_item_group_desc stats_tcp_desc
Definition: stats_tcp.c:89
osmo_timer_schedule
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:99
osmo_time_cc::reported_sum
uint64_t reported_sum
The amount of time that already reported cfg.rate_ctr increments account for.
Definition: time_cc.h:180
osmo_tdef_round
static unsigned long osmo_tdef_round(unsigned long val, enum osmo_tdef_unit from_unit, enum osmo_tdef_unit to_unit)
Definition: tdef.c:129
osmo_stat_item_group::name
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: stat_item.h:53
tdefs
struct osmo_tdef * tdefs
osmo_clock_override_enable
void osmo_clock_override_enable(clockid_t clk_id, bool enable)
next_stats_tcp_entry
static void next_stats_tcp_entry(void)
Definition: stats_tcp.c:219
osmo_wqueue
write queue instance
Definition: write_queue.h:30
osmo_stats_tcp_osmo_fd_register
int osmo_stats_tcp_osmo_fd_register(const struct osmo_fd *fd, const char *name)
Register an osmo_fd for TCP stats monitoring.
Definition: stats_tcp.c:194
osmo_gettimeofday_override
bool osmo_gettimeofday_override
Definition: timer_gettimeofday.c:44
osmo_str_tolower_buf
size_t osmo_str_tolower_buf(char *dest, size_t dest_len, const char *src)
Convert a string to lowercase, while checking buffer size boundaries.
Definition: utils.c:1077
osmo_use_count_entry::count
int32_t count
Current use count amount for only this use token string.
Definition: use_count.h:199
osmo_int_to_float_str_buf
int osmo_int_to_float_str_buf(char *buf, size_t buflen, int64_t val, unsigned int precision)
Convert an integer to a floating point string using a decimal quotient (fixed-point precision).
Definition: utils.c:1365
osmo_tdef::T
const int T
T1234 or X1234 number, corresponding to struct osmo_fsm_inst::T.
Definition: tdef.h:70
osmo_stats_reporter_log_send_counter
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:602
osmo_timers_prepare
void osmo_timers_prepare(void)
Find the nearest time and update nearest_p.
Definition: timer.c:215
osmo_fd::when
unsigned int when
bit-mask or of OSMO_FD_READ, OSMO_FD_WRITE and/or OSMO_FD_EXCEPT
Definition: select.h:38
osmo_stats_timer
static struct osmo_fd osmo_stats_timer
Definition: stats.c:115
STATS_TCP_RTT
@ STATS_TCP_RTT
Definition: stats_tcp.c:69
osmo_stats_reporter::send_counter
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:93
osmo_stats_reporter::open
int(* open)(struct osmo_stats_reporter *srep)
Definition: stats.h:91
OSMO_STRBUF_APPEND
#define OSMO_STRBUF_APPEND(STRBUF, func, args...)
Append a string to a buffer, as printed by an snprintf()-like function and with similar bounds checki...
Definition: utils.h:237
osmo_stat_item_for_each_group
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:414
osmo_tdef_state_timeout
Using osmo_tdef for osmo_fsm_inst: array entry for a mapping of state numbers to timeout definitions.
Definition: tdef.h:111
osmo_stats_reporter_udp_close
int osmo_stats_reporter_udp_close(struct osmo_stats_reporter *srep)
osmo_timers_nearest
struct timeval * osmo_timers_nearest(void)
Determine time between now and the nearest timer.
Definition: timer.c:175
osmo_counters_for_each
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:61
osmo_tdef_set
int osmo_tdef_set(struct osmo_tdef *tdefs, int T, unsigned long val, enum osmo_tdef_unit val_unit)
Set value in entry matching T, converting val from val_unit to unit of T.
Definition: tdef.c:241
msgb_dequeue_count
static struct msgb * msgb_dequeue_count(struct llist_head *queue, unsigned int *count)
Dequeue message buffer from head of queue and decrement queue size counter.
Definition: msgb.h:111
osmo_stat_item_flush
void osmo_stat_item_flush(struct osmo_stat_item *item)
Indicate that a reporting period has elapsed, and prepare the stat item for a new period of collectin...
Definition: stat_item.c:302
osmo_int_to_float_str_c
char * osmo_int_to_float_str_c(void *ctx, int64_t val, unsigned int precision)
Convert an integer with a factor of a million to a floating point string.
Definition: utils.c:1419
llist_last_entry
#define llist_last_entry(ptr, type, member)
Get the last element from a list.
Definition: linuxlist.h:238
osmo_bcd2str
int osmo_bcd2str(char *dst, size_t dst_size, const uint8_t *bcd, int start_nibble, int end_nibble, bool allow_hex)
Convert BCD to string.
Definition: utils.c:148
update_srep_config
static int update_srep_config(struct osmo_stats_reporter *srep)
Definition: stats.c:125
rb_next
struct rb_node * rb_next(const struct rb_node *)
Definition: rbtree.c:308
stats_tcp_entry::name
const char * name
Definition: stats_tcp.c:62
osmo_hexdump_buf
const char * osmo_hexdump_buf(char *out_buf, size_t out_buf_size, const unsigned char *buf, int len, const char *delim, bool delim_after_last)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:299
osmo_stats_reporter::bind_addr_str
char * bind_addr_str
local bind IP address
Definition: stats.h:69
osmo_float_str_to_int
int osmo_float_str_to_int(int64_t *val, const char *str, unsigned int precision)
Convert a string of a floating point number to a signed int, with a decimal factor (fixed-point preci...
Definition: utils.c:1240
byteswap.h
osmo_quote_str_buf
const char * osmo_quote_str_buf(const char *str, int in_len, char *buf, size_t bufsize)
Like osmo_quote_str_buf2, but with unusual ordering of arguments, and may sometimes return string con...
Definition: utils.c:935
osmo_print_n
int osmo_print_n(char *buf, size_t bufsize, const char *str, size_t n)
Copy N characters to a buffer with a function signature useful for OSMO_STRBUF_APPEND().
Definition: utils.c:723
timercmp
#define timercmp(a, b, CMP)
Definition: timer_compat.h:43
start_timer
static int start_timer(void)
Definition: stats.c:178
osmo_identifier_valid
bool osmo_identifier_valid(const char *str)
Determine if a given identifier is valid, i.e.
Definition: utils.c:671
osmo_timerfd_disable
int osmo_timerfd_disable(struct osmo_fd *ofd)
disable the osmocom-wrapped timerfd
Definition: select.c:492
osmo_bcd2char
char osmo_bcd2char(uint8_t bcd)
Convert BCD-encoded digit into printable character.
Definition: utils.c:110
__attribute__
static __attribute__((constructor))
Definition: stats_tcp.c:311
talloc.h
_osmo_use_count_get_put
int _osmo_use_count_get_put(struct osmo_use_count *uc, const char *use, int32_t change, const char *file, int line)
Implementation for osmo_use_count_get_put(), which can also be directly invoked to pass source file i...
Definition: use_count.c:233
osmo_wqueue::except_cb
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:46
llist_head
(double) linked list header structure
Definition: linuxlist.h:46
OSMO_TDEF_MS
@ OSMO_TDEF_MS
milliseconds
Definition: tdef.h:40
osmo_stats_reporter_set_remote_addr
int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
osmo_time_cc_cleanup
void osmo_time_cc_cleanup(struct osmo_time_cc *tc)
if
if(vty->type==VTY_SHELL_SERV)
c
struct abis_rsl_common_hdr c
osmo_stats_reporter::bind_addr
struct sockaddr bind_addr
local bind address of socket
Definition: stats.h:82
osmo_sock_get_ip_and_port
int osmo_sock_get_ip_and_port(int fd, char *ip, size_t ip_len, char *port, size_t port_len, bool local)
Get the IP and/or port number on socket in separate string buffers.
Definition: socket.c:1394
osmo_stats_reporter_set_flush_period
int osmo_stats_reporter_set_flush_period(struct osmo_stats_reporter *srep, unsigned int period)
Set the regular flush period for a given stats_reporter.
Definition: stats.c:404
osmo_timer_list::list
struct llist_head list
internal list header
Definition: timer.h:54
osmo_stats_reporter::max_class
enum osmo_stats_class max_class
Maximum class/index to report.
Definition: stats.h:75
osmo_str_to_int64
int osmo_str_to_int64(int64_t *result, const char *str, int base, int64_t min_val, int64_t max_val)
Convert a string of a number to int64_t, including all common strtoll() validity checks.
Definition: utils.c:1438
msgb_trim
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:495
osmo_stats_reporter::list
struct llist_head list
Definition: stats.h:90
osmo_wqueue_init
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:91
osmo_time_cc_cfg::forget_sum_usec
uint64_t forget_sum_usec
Forget counted sub-gran time after the flag was false for this long.
Definition: time_cc.h:113
osmo_timer_list::node
struct rb_node node
rb-tree node header
Definition: timer.h:53
osmo_timer_setup
void osmo_timer_setup(struct osmo_timer_list *timer, void(*cb)(void *data), void *data)
set up timer callback and data
Definition: timer.c:70
tdef.h
msgb.h
osmo_escape_str_buf3
int osmo_escape_str_buf3(char *buf, size_t bufsize, const char *str, int in_len)
Return the string with all non-printable characters escaped.
Definition: utils.c:831
namebuf
static __thread char namebuf[255]
Definition: utils.c:41
stat_item.h
osmo_stats_reporter_set_name_prefix
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:419
osmo_tdef_get
unsigned long osmo_tdef_get(const struct osmo_tdef *tdefs, int T, enum osmo_tdef_unit as_unit, long val_if_not_present)
Return the value of a T timer from a list of osmo_tdef, in the given unit.
Definition: tdef.c:206
osmo_stats_reporter_enable
int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep)
Enable the given stats_reporter.
Definition: stats.c:432
osmo_tdef_range_str_buf
int osmo_tdef_range_str_buf(char *buf, size_t buf_len, struct osmo_tdef *t)
Write string representation of osmo_tdef range into buf.
Definition: tdef.c:274
_osmo_escape_str_buf
static int _osmo_escape_str_buf(char *buf, size_t bufsize, const char *str, int in_len, bool legacy_format)
Return the string with all non-printable characters escaped.
Definition: utils.c:757
rb_root::rb_node
struct rb_node * rb_node
Definition: linuxrbtree.h:106
osmo_tcp_stats_config::interval
int interval
Definition: stats_tcp.h:8
STATS_DEFAULT_INTERVAL
#define STATS_DEFAULT_INTERVAL
Definition: stats.c:103
osmo_isqrt32
uint32_t osmo_isqrt32(uint32_t x)
perform an integer square root operation on unsigned 32bit integer.
Definition: utils.c:1030
osmo_timerfd_setup
int osmo_timerfd_setup(struct osmo_fd *ofd, int(*cb)(struct osmo_fd *, unsigned int), void *data)
setup osmocom-wrapped timerfd
Definition: select.c:534
STATS_TCP_UNACKED
@ STATS_TCP_UNACKED
Definition: stats_tcp.c:66
llist_count
static unsigned int llist_count(const struct llist_head *head)
Count number of llist items by iterating.
Definition: linuxlist.h:393
osmo_stats_reporter::mtu
int mtu
Maximum Transmission Unit.
Definition: stats.h:71
osmo_str_toupper
const char * osmo_str_toupper(const char *src)
Convert a string to uppercase, using a static buffer.
Definition: utils.c:1161
rate_ctr_group_desc::group_name_prefix
const char * group_name_prefix
The prefix to the name of all counters in this group.
Definition: rate_ctr.h:45
rate_ctr_difference
int64_t rate_ctr_difference(struct rate_ctr *ctr)
Return the counter difference since the last call to this function.
Definition: rate_ctr.c:289
osmo_stats_reporter::buffer
struct msgb * buffer
message buffer for log output
Definition: stats.h:85
llist_for_each_entry
#define llist_for_each_entry(pos, head, member)
Iterate over a linked list of a given type.
Definition: linuxlist.h:299
osmo_encode_big_endian
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:545
osmo_stat_item_group::desc
const struct osmo_stat_item_group_desc * desc
Pointer to the counter group class.
Definition: stat_item.h:49
osmo_strbuf::buf
char * buf
Point to the start of a string buffer.
Definition: utils.h:190
osmo_stats_reporter::agg_enabled
int agg_enabled
is aggregation enabled?
Definition: stats.h:86
LOGL_NOTICE
#define LOGL_NOTICE
abnormal/unexpected condition
Definition: logging.h:124
stats_tcp_entry_cur
static struct stats_tcp_entry * stats_tcp_entry_cur
Definition: stats_tcp.c:55
osmo_gettimeofday_override_time
struct timeval osmo_gettimeofday_override_time
Definition: timer_gettimeofday.c:45
osmo_use_count_make_static_entries
void osmo_use_count_make_static_entries(struct osmo_use_count *uc, struct osmo_use_count_entry *buf, size_t buf_n_entries)
Add N static use token entries to avoid dynamic allocation of use count tokens.
Definition: use_count.c:291
llist_add
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:92
desc
value_string
A mapping between human-readable string and numeric value.
Definition: utils.h:51
handle_counter
static int handle_counter(struct osmo_counter *counter, void *sctx_)
Definition: stats.c:738
osmo_str_tolower
const char * osmo_str_tolower(const char *src)
Convert a string to lowercase, using a static buffer.
Definition: utils.c:1103
OSMO_T_FMT_ARGS
#define OSMO_T_FMT_ARGS(T)
Definition: fsm.h:203
osmo_stats_timer_cb
static int osmo_stats_timer_cb(struct osmo_fd *ofd, unsigned int what)
Definition: stats.c:153
osmo_stats_reporter_type
osmo_stats_reporter_type
Statistics Reporter Type.
Definition: stats.h:51
fsm.h
osmo_luhn
char osmo_luhn(const char *in, int in_len)
Calculate the Luhn checksum (as used for IMEIs).
Definition: utils.c:1188
osmo_timerfd_schedule
int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval)
schedule the osmocom-wrapped timerfd to occur first at first, then periodically at interval
Definition: select.c:506
osmo_time_cc_cfg::T_round_threshold
int T_round_threshold
Update round_threshold_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:120
osmo_clock_override_gettimespec
struct timespec * osmo_clock_override_gettimespec(clockid_t clk_id)
llist_add_tail
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:104
timespecadd
#define timespecadd(a, b, result)
Definition: timer_compat.h:93
type
enum osmo_sub_auth_type type
ARRAY_SIZE
#define ARRAY_SIZE(x)
Determine number of elements in an array of static size.
Definition: utils.h:19
osmo_time_cc::flag_state
bool flag_state
Definition: time_cc.h:161
osmo_use_count_entry::entry
struct llist_head entry
Entry in osmo_use_count->use_counts.
Definition: use_count.h:192
osmo_str_startswith
bool osmo_str_startswith(const char *str, const char *startswith_str)
Compare start of a string.
Definition: utils.c:1219
OSMO_STATS_CLASS_UNKNOWN
@ OSMO_STATS_CLASS_UNKNOWN
unknown class
Definition: stats.h:44
osmo_wqueue::bfd
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:32
stats_tcp_poll_timer_cb
static void stats_tcp_poll_timer_cb(void *data)
Definition: stats_tcp.c:272
value_string::value
uint32_t value
numeric value
Definition: utils.h:52
osmo_stat_item_group_desc::group_name_prefix
const char * group_name_prefix
The prefix to the name of all values in this group.
Definition: stat_item.h:33
osmo_timer_list::cb
void(* cb)(void *)
call-back called at timeout
Definition: timer.h:58
capsbuf
static __thread char capsbuf[128]
Definition: utils.c:43
is_initialised
static int is_initialised
Definition: stats.c:108
nearest
static __thread struct timeval nearest
Definition: timer.c:39
osmo_escape_str_buf2
char * osmo_escape_str_buf2(char *buf, size_t bufsize, const char *str, int in_len)
Return the string with all non-printable characters escaped.
Definition: utils.c:843
stats_tcp_item_desc
static struct osmo_stat_item_desc stats_tcp_item_desc[]
Definition: stats_tcp.c:77
use_count.h
osmo_timer_pending
int osmo_timer_pending(const struct osmo_timer_list *timer)
check if given timer is still pending
Definition: timer.c:134
RB_MAX_MESSAGE_SIZE
#define RB_MAX_MESSAGE_SIZE
A structure representing an osmocom string ringbuffer.
Definition: strrb.h:33
osmo_quote_str_c
char * osmo_quote_str_c(const void *ctx, const char *str, int in_len)
Like osmo_quote_str_buf() but returns the result in a dynamically-allocated buffer.
Definition: utils.c:962
osmo_timer_del
void osmo_timer_del(struct osmo_timer_list *timer)
delete a timer from timer management
Definition: timer.c:116
osmo_time_cc::start_time
uint64_t start_time
CLOCK_MONOTONIC reading in microseconds, at the time when the osmo_time_cc instance started counting.
Definition: time_cc.h:170
s_tcp_stats_config
static struct osmo_tcp_stats_config s_tcp_stats_config
Definition: stats_tcp.c:46
TCP_STATS_DEFAULT_BATCH_SIZE
#define TCP_STATS_DEFAULT_BATCH_SIZE
Definition: stats_tcp.h:4
osmo_counter::name
const char * name
human-readable name
Definition: counter.h:11
osmo_use_count_entry::use_count
struct osmo_use_count * use_count
Parent use count and backpointer to the talloc_object.
Definition: use_count.h:194
llist_entry
#define llist_entry(ptr, type, member)
Get the struct containing this list entry.
Definition: linuxlist.h:218
logging.h
osmo_stats_reporter::name
char * name
Human-readable name of this reporter.
Definition: stats.h:61
osmo_strbuf
State for OSMO_STRBUF_APPEND() and OSMO_STRBUF_PRINTF().
Definition: utils.h:188
osmo_stats_reporter_set_mtu
int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
osmo_quote_cstr_c
char * osmo_quote_cstr_c(void *ctx, const char *str, int in_len)
Return the string quoted and with all non-printable characters escaped, in dynamically-allocated buff...
Definition: utils.c:1020
osmo_strrb::end
uint16_t end
index of the last slot
Definition: strrb.h:36
DLSTATS
#define DLSTATS
Statistics.
Definition: logging.h:138
STATS_TCP_RCV_RTT
@ STATS_TCP_RCV_RTT
Definition: stats_tcp.c:70
osmo_gettid
pid_t osmo_gettid(void)
Wrapper around Linux's gettid() to make it easily accessible on different system versions.
Definition: thread.c:46
OSMO_FD_WRITE
#define OSMO_FD_WRITE
Indicate interest in writing to the file descriptor.
Definition: select.h:19
rate_ctr::current
uint64_t current
current value
Definition: rate_ctr.h:30
osmo_tdef_factor
static unsigned long osmo_tdef_factor(enum osmo_tdef_unit a, enum osmo_tdef_unit b)
a = return_val * b.
Definition: tdef.c:89
OSMO_TDEF_CUSTOM
@ OSMO_TDEF_CUSTOM
unspecified unit, explained in osmo_tdef.desc.
Definition: tdef.h:42
osmo_strrb_create
struct osmo_strrb * osmo_strrb_create(TALLOC_CTX *ctx, size_t rb_size)
Create an empty, initialized osmo_strrb.
Definition: strrb.c:55
osmo_stats_reporter_log_send
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:587
osmo_strnchr
const char * osmo_strnchr(const char *str, size_t str_size, char c)
Find first occurence of a char in a size limited string.
Definition: utils.c:585
osmo_use_count::talloc_object
void * talloc_object
Context to talloc-allocate use count entries from (if at all necessary); back-pointer to the owning o...
Definition: use_count.h:171
file
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
socket.h
msgb_data
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:184
select.h
rate_ctr.h
rb_node
Definition: linuxrbtree.h:94
DLGLOBAL
#define DLGLOBAL
global logging
Definition: logging.h:129
osmo_timer_list::active
unsigned int active
is it active?
Definition: timer.h:56
osmo_hexparse
int osmo_hexparse(const char *str, uint8_t *b, unsigned int max_len)
Parse a string containing hexadecimal digits.
Definition: utils.c:240
osmo_stats_reporter_create_log
struct osmo_stats_reporter * osmo_stats_reporter_create_log(const char *name)
Create a stats_reporter that logs via libosmocore logging.
Definition: stats.c:572
osmo_stat_item_group_alloc
struct osmo_stat_item_group * osmo_stat_item_group_alloc(void *ctx, const struct osmo_stat_item_group_desc *group_desc, unsigned int idx)
Allocate a new group of counters according to description.
Definition: stat_item.c:179
osmo_fd
Structure representing a file dsecriptor.
Definition: select.h:31
osmo_use_count::use_cb
osmo_use_count_cb_t use_cb
If not NULL, this is invoked for each use count change.
Definition: use_count.h:173
LOGP
#define LOGP(ss, level, fmt, args...)
Log a new message through the Osmocom logging framework.
Definition: logging.h:49
osmo_hexdump_nospc_c
char * osmo_hexdump_nospc_c(const void *ctx, const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:443
osmo_tdef::max_val
unsigned long max_val
Maximum timer value (in this tdef unit), checked if set (not zero).
Definition: tdef.h:84
digits
uint8_t digits[3]
msgb_alloc
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer from tall_msgb_ctx.
Definition: msgb.c:108
llist_empty
static int llist_empty(const struct llist_head *head)
Test whether a linked list is empty.
Definition: linuxlist.h:169
osmo_timers_check
int osmo_timers_check(void)
Check how many timers we have in the system.
Definition: timer.c:279
OSMO_STRBUF_PRINTF
#define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...)
Shortcut for OSMO_STRBUF_APPEND() invocation using snprintf().
Definition: utils.h:269
OSMO_TDEF_US
@ OSMO_TDEF_US
microseconds
Definition: tdef.h:43
osmo_stat_item_group_get_item
struct osmo_stat_item * osmo_stat_item_group_get_item(struct osmo_stat_item_group *grp, unsigned int idx)
Get statistics item from group, identified by index idx.
Definition: stat_item.c:239
osmo_str_toupper_buf
size_t osmo_str_toupper_buf(char *dest, size_t dest_len, const char *src)
Convert a string to uppercase, while checking buffer size boundaries.
Definition: utils.c:1135
osmo_stats_reporter::enabled
int enabled
is this reporter enabled
Definition: stats.h:66
osmo_osmo_hexdump_nospc
char * osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) __attribute__((__deprecated__))
hexd_buff
static __thread char hexd_buff[4096]
Definition: utils.c:280
osmo_use_count_free
void osmo_use_count_free(struct osmo_use_count_entry *use_count_entry)
Deallocate a use count entry.
Definition: use_count.c:220
osmo_hexdump_nospc
char * osmo_hexdump_nospc(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:428
osmo_counter::description
const char * description
humn-readable description
Definition: counter.h:12
LLIST_HEAD
static LLIST_HEAD(stats_tcp)
osmo_wqueue_bfd_cb
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:39
osmo_htons
#define osmo_htons(x)
Definition: byteswap.h:44
osmo_hexdump
char * osmo_hexdump(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:392
rb_erase
void rb_erase(struct rb_node *, struct rb_root *)
Definition: rbtree.c:214
counter.h
osmo_use_count_find
struct osmo_use_count_entry * osmo_use_count_find(const struct osmo_use_count *uc, const char *use)
Definition: use_count.c:164
msgb_put_u8
static void msgb_put_u8(struct msgb *msgb, uint8_t word)
append a uint8 value to the end of the message
Definition: msgb.h:259
osmo_stats_reporter_set_remote_port
int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port)
osmo_tdef_for_each
#define osmo_tdef_for_each(t, tdefs)
Iterate an array of struct osmo_tdef, the last item should be fully zero, i.e.
Definition: tdef.h:98
OSMO_STATS_CLASS_SUBSCRIBER
@ OSMO_STATS_CLASS_SUBSCRIBER
subscriber
Definition: stats.h:47
rate_ctr_for_each_group
int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data)
Iterate over all counter groups.
Definition: rate_ctr.c:435
osmo_stats_config::interval
int interval
Definition: stats.h:104
osmo_str_toupper_c
char * osmo_str_toupper_c(const void *ctx, const char *src)
Convert a string to uppercase, dynamically allocating the output from given talloc context See also o...
Definition: utils.c:1173
osmo_str2bcd
int osmo_str2bcd(uint8_t *dst, size_t dst_size, const char *digits, int start_nibble, int end_nibble, bool allow_hex)
Convert string to BCD.
Definition: utils.c:191
osmo_stats_reporter_check_config
static int osmo_stats_reporter_check_config(struct osmo_stats_reporter *srep, unsigned int index, int class_id)
Definition: stats.c:629
osmo_stat_item_desc
Statistics item description.
Definition: stat_item.h:22
OSMO_T_FMT
#define OSMO_T_FMT
Definition: fsm.h:202
msgb_dequeue
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:141
linuxlist.h
osmo_stats_reporter::name_prefix
char * name_prefix
prefix for counter names
Definition: stats.h:67
list
struct llist_head list
osmo_timer_remaining
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:148
OSMO_SNPRINTF_RET
#define OSMO_SNPRINTF_RET(ret, rem, offset, len)
Definition: utils.h:99
osmo_stat_item_group_desc::class_id
int class_id
The class to which this group belongs.
Definition: stat_item.h:37
osmo_wqueue::msg_queue
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:39
hex_chars
static const char hex_chars[]
Definition: utils.c:281
osmo_fd::fd
int fd
actual operating-system level file decriptor
Definition: select.h:35
osmo_tdef_get_entry
struct osmo_tdef * osmo_tdef_get_entry(struct osmo_tdef *tdefs, int T)
Find tdef entry matching T.
Definition: tdef.c:223
osmo_stats_init
void osmo_stats_init(void *ctx)
Initialize the stats reporting module; call this once in your program.
Definition: stats.c:241
thread.h
osmo_strrb
Definition: strrb.h:34
osmo_stat_item_for_each_item
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:394
OSMO_MIN
#define OSMO_MIN(a, b)
Return the minimum of two specified values.
Definition: utils.h:24
osmo_counter::value
unsigned long value
current value
Definition: counter.h:13
osmo_stat_item_group_handler
static int osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
Definition: stats.c:729
osmo_strrb_is_empty
bool osmo_strrb_is_empty(const struct osmo_strrb *rb)
Check if an osmo_strrb is empty.
Definition: strrb.c:88
point
struct @101 point[15]
osmo_escape_str_c
char * osmo_escape_str_c(const void *ctx, const char *str, int in_len)
Return the string with all non-printable characters escaped, in dynamically-allocated buffer.
Definition: utils.c:865
LOGL_ERROR
#define LOGL_ERROR
error condition, requires user action
Definition: logging.h:125
bit64gen.h
osmo_stats_set_interval
int osmo_stats_set_interval(int interval)
Set the reporting interval (common for all reporters)
Definition: stats.c:384
osmo_store64be_ext
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:89
osmo_constant_time_cmp
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:502
rate_ctr
data we keep for each actual value
Definition: rate_ctr.h:29
osmo_time_cc::timer
struct osmo_timer_list timer
Definition: time_cc.h:167
OSMO_FD_EXCEPT
#define OSMO_FD_EXCEPT
Indicate interest in exceptions from the file descriptor.
Definition: select.h:21
STATS_TCP_LOST
@ STATS_TCP_LOST
Definition: stats_tcp.c:67
osmo_sock_get_name2
const char * osmo_sock_get_name2(int fd)
Get address/port information on socket in static string, like "r=1.2.3.4:5<->l=6.7....
Definition: socket.c:1510
stats_tcp_entry::fd
const struct osmo_fd * fd
Definition: stats_tcp.c:60
OSMO_MAX
#define OSMO_MAX(a, b)
Return the maximum of two specified values.
Definition: utils.h:22
osmo_stats_reporter_statsd_send
static int osmo_stats_reporter_statsd_send(struct osmo_stats_reporter *srep, const char *name1, const char *index1, const char *name2, int64_t value, const char *unit)
Definition: stats_statsd.c:89
ENOTSUP
#define ENOTSUP
osmo_str_to_int
int osmo_str_to_int(int *result, const char *str, int base, int min_val, int max_val)
Convert a string of a number to int, including all common strtoll() validity checks.
Definition: utils.c:1497
osmo_stats_reporter_send
int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data, int data_len)
osmo_stats_report
int osmo_stats_report(void)
Definition: stats.c:790
osmo_use_count_to_str_c
char * osmo_use_count_to_str_c(void *ctx, const struct osmo_use_count *uc)
Write a comprehensive listing of use counts to a talloc allocated string buffer.
Definition: use_count.c:154
osmo_wqueue_clear
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:139
rate_ctr_group::name
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: rate_ctr.h:65
_osmo_quote_str_buf
static size_t _osmo_quote_str_buf(char *buf, size_t bufsize, const char *str, int in_len, bool legacy_format)
Return a quoted and escaped representation of the string.
Definition: utils.c:885
osmo_str2upper
void osmo_str2upper(char *out, const char *in) OSMO_DEPRECATED("Use osmo_str_toupper() or osmo_str_toupper_buf() instead
Convert an entire string to upper case.
Definition: utils.c:482
rb_link_node
static void rb_link_node(struct rb_node *node, struct rb_node *parent, struct rb_node **rb_link)
Definition: linuxrbtree.h:146
rate_ctr_group::idx
unsigned int idx
The index of this ctr_group within its class.
Definition: rate_ctr.h:63
osmo_time_cc_cfg::gran_usec
uint64_t gran_usec
Granularity in microseconds: nr of microseconds that one rate_ctr increment represents.
Definition: time_cc.h:108
osmo_stats_tcp_osmo_fd_unregister
int osmo_stats_tcp_osmo_fd_unregister(const struct osmo_fd *fd)
Register an osmo_fd for TCP stats monitoring.
Definition: stats_tcp.c:242
_osmo_fsm_inst_state_chg_keep_or_start_timer
int _osmo_fsm_inst_state_chg_keep_or_start_timer(struct osmo_fsm_inst *fi, uint32_t new_state, unsigned long timeout_secs, int T, const char *file, int line)
perform a state change while keeping the current timer if running, or starting a timer otherwise.
Definition: fsm.c:802