libosmocore
1.9.2
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
unsigned int have_net_config
Definition: stats.h:63
static void fill_stats(struct stats_tcp_entry *stats_tcp_entry)
Definition: stats_tcp.c:97
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
char ** buffer
storage for messages
Definition: strrb.h:36
int osmo_counter_difference(struct osmo_counter *ctr)
Compute difference between current and previous counter value.
Definition: counter.c:102
A structure representing a single instance of a timer.
Definition: timer.h:52
const struct value_string osmo_tdef_unit_names[]
Definition: tdef.c:362
@ STATS_TCP_REORD_SEEN
Definition: stats_tcp.c:74
int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep)
Disable the given stats_reporter.
Definition: stats.c:442
static void flush_all_reporters(void)
Definition: stats.c:767
static int tundev_write_cb(struct osmo_fd *fd, struct msgb *msg)
Definition: tun.c:173
bool _osmo_strrb_is_bufindex_valid(const struct osmo_strrb *rb, unsigned int bufi)
Definition: strrb.c:115
uint16_t start
index of the first slot
Definition: strrb.h:33
@ OSMO_STATS_CLASS_GLOBAL
global counter/stat_item
Definition: stats.h:45
uint64_t total_sum
Overall cumulative sum.
Definition: time_cc.h:165
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
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:442
int dest_port
destination (UDP) port
Definition: stats.h:70
#define TRACE(probe)
Definition: stats.c:97
int osmo_netdev_set_netns_name(struct osmo_netdev *netdev, const char *netns)
Set (specify) name of the network namespace where the network interface to manage is located.
Definition: netdev.c:831
void osmo_stats_reporter_free(struct osmo_stats_reporter *srep)
Destroy a given stats_reporter.
Definition: stats.c:232
#define timerclear(tvp)
Definition: timer_compat.h:39
void osmo_time_cc_init(struct osmo_time_cc *tc)
char * netns_name
Definition: tun.c:131
struct osmo_wqueue wqueue
Definition: tun.c:128
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
char * name
Definition: tun.c:113
rate counter description
Definition: rate_ctr.h:37
int batch_size
Definition: stats_tcp.h:10
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
int osmo_strrb_add(struct osmo_strrb *rb, const char *data)
Add a string to the osmo_strrb.
Definition: strrb.c:148
struct osmo_stats_reporter * osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type, const char *name)
Definition: stats.c:212
@ OSMO_TDEF_S
most T are in seconds, keep 0 as default.
Definition: tdef.h:39
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
struct osmo_stat_item_period reported
The results of the previous reporting period.
Definition: stat_item_internal.h:32
uint8_t osmo_char2bcd(char c)
Convert number in ASCII to BCD value.
Definition: utils.c:122
#define timeradd(a, b, result)
Definition: timer_compat.h:50
int running
is this reporter running
Definition: stats.h:79
unsigned int flush_period
period between regular flushes
Definition: stats.h:72
unsigned int current_length
current length of write queue
Definition: write_queue.h:36
int T_gran
Update gran_usec from this T timer value, or zero to not use any T timer.
Definition: time_cc.h:118
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
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
int osmo_netdev_set_ifindex(struct osmo_netdev *netdev, unsigned int ifindex)
Set (specify) interface index identifying the network interface to manage.
Definition: netdev.c:801
int osmo_netdev_unregister(struct osmo_netdev *netdev)
Unregister the netdev object (stop managing /moniutoring the interface)
Definition: netdev.c:714
int bind_addr_len
length of bind_addr in bytes
Definition: stats.h:83
const char * get_value_string(const struct value_string *vs, uint32_t val)
get human-readable string for given value
Definition: utils.c:54
void rate_ctr_add(struct rate_ctr *ctr, int inc)
Increment the counter by inc.
Definition: rate_ctr.c:286
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:320
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
void osmo_time_cc_set_flag(struct osmo_time_cc *tc, bool flag)
int osmo_tundev_close(struct osmo_tundev *tundev)
Close the tunnel device owned by the tundev object.
Definition: tun.c:427
const struct rate_ctr_group_desc * desc
Pointer to the counter group class.
Definition: rate_ctr.h:61
static size_t len(const char *str)
struct sockaddr dest_addr
destination address of socket
Definition: stats.h:80
static struct osmo_timer_list stats_tcp_poll_timer
Definition: stats_tcp.c:52
int32_t max
Largest value seen in a reporting period.
Definition: stat_item_internal.h:17
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
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
libosmocore logging
Definition: stats.h:52
struct osmo_time_cc_cfg cfg
Definition: time_cc.h:159
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
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
#define OSMO_ASSERT(exp)
Helper macro to terminate when an assertion fails.
Definition: utils.h:113
@ STATS_TCP_RETRANS
Definition: stats_tcp.c:68
const char * osmo_sock_get_name2(int fd)
osmo_stats_class
Statistics Class definitions.
Definition: stats.h:43
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
One instance of a counter group class.
Definition: stat_item.h:45
static int tundev_open_fd(struct osmo_tundev *tundev, int flags)
Open and configure fd of the tunnel device.
Definition: tun.c:273
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
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:240
static void __add_timer(struct osmo_timer_list *timer)
Definition: timer.c:44
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
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:679
static __thread struct rb_root timer_root
Definition: timer.c:42
void osmo_tundev_set_priv_data(struct osmo_tundev *tundev, void *priv_data)
Set private user data pointer on the tundev object.
Definition: tun.c:460
@ STATS_TCP_NOTSENT_BYTES
Definition: stats_tcp.c:71
unsigned int idx
The index of this value group within its class.
Definition: stat_item.h:51
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:34
void osmo_netdev_set_mtu_chg_cb(struct osmo_netdev *netdev, osmo_netdev_mtu_chg_cb_t mtu_chg_cb)
Set mtu_chg_cb callback, called when a change in the network name is detected.
Definition: netdev.c:775
uint16_t size
max number of messages to store
Definition: strrb.h:35
char alias("osmo_hexdump_nospc")))
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
struct llist_head entry
Definition: stats_tcp.c:59
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:44
unsigned long val
Currently active timeout value, e.g.
Definition: tdef.h:80
int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
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
size_t osmo_strrb_elements(const struct osmo_strrb *rb)
Count the number of log messages in an osmo_strrb.
Definition: strrb.c:132
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
int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr)
struct llist_head use_counts
List of use tokens.
Definition: use_count.h:175
data we keep for each actual item
Definition: stat_item_internal.h:23
const char * osmo_netdev_get_dev_name(const struct osmo_netdev *netdev)
Get name used to name the network interface created by the netdev object.
Definition: netdev.c:855
int osmo_fd_register(struct osmo_fd *fd)
struct llist_head osmo_stats_reporter_list
const char * osmo_escape_str(const char *str, int len)
Return the string with all non-printable characters escaped.
Definition: utils.c:855
int(* cb)(struct osmo_fd *fd, unsigned int what)
call-back function to be called once file descriptor becomes available
Definition: select.h:41
pthread_mutex_t stats_tcp_lock
Definition: stats_tcp.c:56
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
struct osmo_stat_item_group * stats_tcp
Definition: stats_tcp.c:61
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
#define STATS_DEFAULT_BUFLEN
Definition: stats.c:104
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
Report the cumulative counter of time for which a flag is true as rate counter.
Definition: time_cc.h:158
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:334
@ STATS_TCP_RTT
Definition: stats_tcp.c:69
uint64_t round_threshold_usec
Nr of microseconds above n * gran_usec at which to trigger a counter increment.
Definition: time_cc.h:111
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
int osmo_clock_gettime(clockid_t clk_id, struct timespec *tp)
int fd
file descriptor of socket
Definition: stats.h:84
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
#define RB_ROOT
Definition: linuxrbtree.h:126
int osmo_timers_nearest_ms(void)
Determine time between now and the nearest timer in milliseconds.
Definition: timer.c:186
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
int get_string_value(const struct value_string *vs, const char *str)
get numeric value for given human-readable string
Definition: utils.c:93
struct llist_head * next
Pointer to next and previous item.
Definition: linuxlist.h:48
static void osmo_talloc_replace_string(void *ctx, char **dst, const char *newstr)
duplicate a string using talloc and release its prior content (if any)
Definition: utils.h:124
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)
int osmo_netdev_register(struct osmo_netdev *netdev)
Start managing the network device referenced by the netdev object.
Definition: netdev.c:674
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
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:211
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
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
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
static bool is_tcp(const struct osmo_fd *fd)
Definition: stats_tcp.c:166
Description of a statistics item group.
Definition: stat_item.h:31
void osmo_fd_unregister(struct osmo_fd *fd)
int osmo_timers_update(void)
fire all timers...
Definition: timer.c:233
enum osmo_stats_reporter_type type
Type of the reporter (log, statsd)
Definition: stats.h:59
struct osmo_stat_item_period value
Current reporting period / current value.
Definition: stat_item_internal.h:28
static void llist_del_init(struct llist_head *entry)
Delete a single entry from a linked list and reinitialize it.
Definition: linuxlist.h:138
#define OSMO_FD_READ
Indicate interest in reading from the file descriptor.
Definition: select.h:17
struct osmo_netdev * osmo_tundev_get_netdev(struct osmo_tundev *tundev)
Get netdev managing the tunnel interface of tundev.
Definition: tun.c:551
static int tundev_ifupdown_ind_cb(struct osmo_netdev *netdev, bool ifupdown)
Definition: tun.c:187
void osmo_tdefs_reset(struct osmo_tdef *tdefs)
Set all osmo_tdef values to the default_val.
Definition: tdef.c:154
#define INIT_LLIST_HEAD(ptr)
Initialize a llist_head to point back to itself.
Definition: linuxlist.h:65
@ STATS_TCP_UNACKED
Definition: stats_tcp.c:66
void osmo_gettimeofday_override_add(time_t secs, suseconds_t usecs)
convenience function to advance the fake time.
Definition: timer_gettimeofday.c:68
const char * osmo_tundev_get_name(const struct osmo_tundev *tundev)
Get name used to identify the tundev object.
Definition: tun.c:487
struct osmo_stats_reporter * osmo_stats_reporter_create_statsd(const char *name)
Create a stats_reporter reporting to statsd.
Definition: stats_statsd.c:53
size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
Copy a C-string into a sized buffer.
Definition: utils.c:565
int osmo_stats_tcp_set_interval(int interval)
Set the polling interval (common for all sockets)
Definition: stats_tcp.c:305
unsigned int flush_period_counter
count sends between forced flushes
Definition: stats.h:88
static void update_nearest(struct timeval *cand, struct timeval *current)
Definition: timer.c:199
@ OSMO_STATS_REPORTER_STATSD
statsd backend
Definition: stats.h:53
Define a GSM timer of the form Tnnn, with unit, default value and doc string.
Definition: tdef.h:65
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
One statistics reporter instance.
Definition: stats.h:57
#define OTC_GLOBAL
Definition: talloc.h:26
Definition: stats_tcp.h:6
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.
Definition: linuxlist.h:32
LLIST_HEAD(osmo_stats_reporter_list)
int(* close)(struct osmo_stats_reporter *srep)
Definition: stats.h:92
uint64_t sum
Internal cumulative counter of time that flag_state was true.
Definition: time_cc.h:177
bool keep_timer
If true, call osmo_fsm_inst_state_chg_keep_timer().
Definition: tdef.h:118
#define timersub(a, b, result)
Definition: timer_compat.h:63
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
void osmo_netdev_set_dev_name_chg_cb(struct osmo_netdev *netdev, osmo_netdev_dev_name_chg_cb_t dev_name_chg_cb)
Set dev_name_chg_cb callback, called when a change in the network name is detected.
Definition: netdev.c:766
a single instanceof an osmocom finite state machine
Definition: fsm.h:87
#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:340
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
static int tundev_decaps(struct osmo_tundev *tundev)
Definition: tun.c:144
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
enum osmo_tdef_unit unit
Definition: tdef.h:74
Structure representing a single counter.
Definition: counter.h:9
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:285
static const char osmo_identifier_illegal_chars[]
Definition: utils.c:634
static void llist_del(struct llist_head *entry)
Delete a single entry from a linked list.
Definition: linuxlist.h:128
size_t chars_needed
After all OSMO_STRBUF_APPEND operations, reflects the total number of characters that would be writte...
Definition: utils.h:210
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
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
int force_single_flush
set to 1 to force a flush (send even unchanged stats values)
Definition: stats.h:87
static int osmo_stat_item_handler(struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_)
Definition: stats.c:699
struct timeval timeout
expiration time
Definition: timer.h:55
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
#define llist_first_entry(ptr, type, member)
Get the first element from a linked list.
Definition: linuxlist.h:228
Definition: stats_tcp.c:58
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
const char * use
Use token string that was passed to osmo_use_count_get_put().
Definition: use_count.h:196
#define BACKSLASH_CASE(c, repr)
Osmocom message buffer.
Definition: msgb.h:31
void rb_insert_color(struct rb_node *, struct rb_root *)
Definition: rbtree.c:69
void osmo_clock_override_add(clockid_t clk_id, time_t secs, long nsecs)
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
#define LOGL_INFO
general information
Definition: logging.h:123
int osmo_tundev_set_netns_name(struct osmo_tundev *tundev, const char *netns_name)
Set name of the network namespace to use when opening the tunnel interface.
Definition: tun.c:530
@ STATS_TCP_SNDBUF_LIMITED
Definition: stats_tcp.c:73
static __thread struct timeval * nearest_p
Definition: timer.c:40
int osmo_tundev_set_dev_name(struct osmo_tundev *tundev, const char *dev_name)
Set name used to name the tunnel interface created by the tundev object.
Definition: tun.c:503
Use counter state for one used object, managing N distinct named counters.
Definition: use_count.h:168
One named counter in the list managed by osmo_use_count.
Definition: use_count.h:190
Definition: linuxrbtree.h:104
static void * osmo_stats_ctx
Definition: stats.c:107
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:42
int(* osmo_tundev_data_ind_cb_t)(struct osmo_tundev *tun, struct msgb *msg)
Definition: tun.h:17
int dest_addr_len
length of dest_addr in bytes
Definition: stats.h:81
void osmo_netdev_set_ifupdown_ind_cb(struct osmo_netdev *netdev, osmo_netdev_ifupdown_ind_cb_t ifupdown_ind_cb)
Set data_ind_cb callback, called when a new packet is received on the network interface.
Definition: netdev.c:757
const struct osmo_stat_item_desc * desc
back-reference to the item description
Definition: stat_item_internal.h:25
char * dest_addr_str
destination IP address
Definition: stats.h:68
One instance of a counter group class.
Definition: rate_ctr.h:57
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
int T
Timer number to match struct osmo_tdef.T, and to pass to osmo_fsm_inst_state_chg().
Definition: tdef.h:115
#define TCP_STATS_DEFAULT_INTERVAL
Definition: stats_tcp.h:3
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:263
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
static struct osmo_stats_config s_stats_config
Definition: stats.c:110
struct rb_node * rb_first(const struct rb_root *)
Definition: rbtree.c:284
void osmo_panic(const char *fmt,...) __attribute__((noreturn))
Terminate the current program with a panic.
Definition: panic.c:71
int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep)
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
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:117
int osmo_tundev_open(struct osmo_tundev *tundev)
Open the tunnel device owned by the tundev object.
Definition: tun.c:345
@ OSMO_TDEF_M
minutes
Definition: tdef.h:41
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
Definition: tdef.h:38
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
char * osmo_hexdump_c(const void *ctx, const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:407
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
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
void * data
user data for callback
Definition: timer.h:59
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
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
#define TUN_DEV_PATH
Definition: tun.c:103
unsigned long min_val
Minimum timer value (in this tdef unit), checked if set (not zero).
Definition: tdef.h:82
int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep, enum osmo_stats_class class_id)
Definition: stats.c:370
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
const char * str
human-readable string
Definition: utils.h:53
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
struct rate_ctr * rate_ctr
Rate counter to report to, or NULL to not use it.
Definition: time_cc.h:115
struct osmo_netdev * netdev
Definition: tun.c:116
static struct osmo_stat_item_group_desc stats_tcp_desc
Definition: stats_tcp.c:89
void osmo_str2upper(char *out, const char *in) OSMO_DEPRECATED("Use osmo_str_toupper() or osmo_str_toupper_buf() instead
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
uint64_t reported_sum
The amount of time that already reported cfg.rate_ctr increments account for.
Definition: time_cc.h:180
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
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: stat_item.h:53
void osmo_clock_override_enable(clockid_t clk_id, bool enable)
static void next_stats_tcp_entry(void)
Definition: stats_tcp.c:219
write queue instance
Definition: write_queue.h:30
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
bool osmo_gettimeofday_override
Definition: timer_gettimeofday.c:44
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
int32_t count
Current use count amount for only this use token string.
Definition: use_count.h:199
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
const int T
T1234 or X1234 number, corresponding to struct osmo_fsm_inst::T.
Definition: tdef.h:70
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
void osmo_timers_prepare(void)
Find the nearest time and update nearest_p.
Definition: timer.c:215
unsigned int when
bit-mask or of OSMO_FD_READ, OSMO_FD_WRITE and/or OSMO_FD_EXCEPT
Definition: select.h:38
static struct osmo_fd osmo_stats_timer
Definition: stats.c:115
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
int(* open)(struct osmo_stats_reporter *srep)
Definition: stats.h:91
void osmo_netdev_free(struct osmo_netdev *netdev)
Free an allocated netdev object.
Definition: netdev.c:660
#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:249
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
Using osmo_tdef for osmo_fsm_inst: array entry for a mapping of state numbers to timeout definitions.
Definition: tdef.h:111
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:175
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
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:243
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
@ STATS_TCP_RCV_RTT
Definition: stats_tcp.c:70
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
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
void * osmo_tundev_get_priv_data(struct osmo_tundev *tundev)
Get private user data pointer from the tundev object.
Definition: tun.c:469
#define llist_last_entry(ptr, type, member)
Get the last element from a list.
Definition: linuxlist.h:238
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
static int update_srep_config(struct osmo_stats_reporter *srep)
Definition: stats.c:125
struct rb_node * rb_next(const struct rb_node *)
Definition: rbtree.c:308
const char * name
Definition: stats_tcp.c:62
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
char * bind_addr_str
local bind IP address
Definition: stats.h:69
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
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
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
#define timercmp(a, b, CMP)
Definition: timer_compat.h:43
static int start_timer(void)
Definition: stats.c:178
bool osmo_identifier_valid(const char *str)
Determine if a given identifier is valid, i.e.
Definition: utils.c:671
int osmo_timerfd_disable(struct osmo_fd *ofd)
char osmo_bcd2char(uint8_t bcd)
Convert BCD-encoded digit into printable character.
Definition: utils.c:110
static __attribute__((constructor))
Definition: stats_tcp.c:313
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
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:46
(double) linked list header structure
Definition: linuxlist.h:46
@ OSMO_TDEF_MS
milliseconds
Definition: tdef.h:40
void osmo_netdev_set_priv_data(struct osmo_netdev *netdev, void *priv_data)
Set private user data pointer on the netdev object.
Definition: netdev.c:739
int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
void osmo_time_cc_cleanup(struct osmo_time_cc *tc)
if(vty->type==VTY_SHELL_SERV)
struct abis_rsl_common_hdr c
struct sockaddr bind_addr
local bind address of socket
Definition: stats.h:82
int osmo_sock_get_ip_and_port(int fd, char *ip, size_t ip_len, char *port, size_t port_len, bool local)
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
struct llist_head list
internal list header
Definition: timer.h:54
enum osmo_stats_class max_class
Maximum class/index to report.
Definition: stats.h:75
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
static int msgb_trim(struct msgb *msg, int len)
Trim the msgb to a given absolute length.
Definition: msgb.h:495
struct llist_head list
Definition: stats.h:90
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:91
uint64_t forget_sum_usec
Forget counted sub-gran time after the flag was false for this long.
Definition: time_cc.h:113
struct rb_node node
rb-tree node header
Definition: timer.h:53
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
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
static __thread char namebuf[255]
Definition: utils.c:41
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
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:208
int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep)
Enable the given stats_reporter.
Definition: stats.c:432
bool dev_name_dynamic
Definition: tun.c:125
int osmo_tundev_send(struct osmo_tundev *tundev, struct msgb *msg)
Submit a packet to the tunnel device managed by the tundev object.
Definition: tun.c:563
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:276
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
void osmo_tundev_set_data_ind_cb(struct osmo_tundev *tundev, osmo_tundev_data_ind_cb_t data_ind_cb)
Set data_ind_cb callback, called when a new packet is received on the tun interface.
Definition: tun.c:478
struct rb_node * rb_node
Definition: linuxrbtree.h:106
int interval
Definition: stats_tcp.h:8
#define STATS_DEFAULT_INTERVAL
Definition: stats.c:103
uint32_t osmo_isqrt32(uint32_t x)
perform an integer square root operation on unsigned 32bit integer.
Definition: utils.c:1030
int osmo_timerfd_setup(struct osmo_fd *ofd, int(*cb)(struct osmo_fd *, unsigned int), void *data)
unsigned int ifindex
Definition: tun.c:119
static unsigned int llist_count(const struct llist_head *head)
Count number of llist items by iterating.
Definition: linuxlist.h:393
int mtu
Maximum Transmission Unit.
Definition: stats.h:71
const char * osmo_str_toupper(const char *src)
Convert a string to uppercase, using a static buffer.
Definition: utils.c:1161
void osmo_str2lower(char *out, const char *in) OSMO_DEPRECATED("Use osmo_str_tolower() or osmo_str_tolower_buf() instead
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:292
struct msgb * buffer
message buffer for log output
Definition: stats.h:85
struct osmo_netdev * osmo_netdev_alloc(void *ctx, const char *name)
Allocate a new netdev object.
Definition: netdev.c:643
#define llist_for_each_entry(pos, head, member)
Iterate over a linked list of a given type.
Definition: linuxlist.h:299
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
enum gsm0808_assignment_requirement __attribute__
fls64 - find last set bit in a 64-bit word @x: the word to search
Definition: log2.h:61
const struct osmo_stat_item_group_desc * desc
Pointer to the counter group class.
Definition: stat_item.h:49
void * osmo_netdev_get_priv_data(struct osmo_netdev *netdev)
Get private user data pointer from the netdev object.
Definition: netdev.c:748
char * buf
Point to the start of a string buffer.
Definition: utils.h:202
int agg_enabled
is aggregation enabled?
Definition: stats.h:86
#define LOGL_NOTICE
abnormal/unexpected condition
Definition: logging.h:124
static struct stats_tcp_entry * stats_tcp_entry_cur
Definition: stats_tcp.c:55
struct timeval osmo_gettimeofday_override_time
Definition: timer_gettimeofday.c:45
static int osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
Definition: stats.c:729
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
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
A mapping between human-readable string and numeric value.
Definition: utils.h:51
static int handle_counter(struct osmo_counter *counter, void *sctx_)
Definition: stats.c:738
const char * osmo_str_tolower(const char *src)
Convert a string to lowercase, using a static buffer.
Definition: utils.c:1103
#define OSMO_T_FMT_ARGS(T)
Definition: fsm.h:203
static int osmo_stats_timer_cb(struct osmo_fd *ofd, unsigned int what)
Definition: stats.c:153
osmo_stats_reporter_type
Statistics Reporter Type.
Definition: stats.h:51
@ STATS_TCP_RWND_LIMITED
Definition: stats_tcp.c:72
char osmo_luhn(const char *in, int in_len)
Calculate the Luhn checksum (as used for IMEIs).
Definition: utils.c:1188
#define LOGTUN(tun, lvl, fmt, args ...)
Definition: tun.c:106
int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval)
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
struct timespec * osmo_clock_override_gettimespec(clockid_t clk_id)
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
#define timespecadd(a, b, result)
Definition: timer_compat.h:93
#define ARRAY_SIZE(x)
Determine number of elements in an array of static size.
Definition: utils.h:19
static int tundev_read_cb(struct osmo_fd *fd)
Definition: tun.c:166
bool flag_state
Definition: time_cc.h:161
void osmo_tundev_free(struct osmo_tundev *tundev)
Free an allocated tundev object.
Definition: tun.c:259
#define TUN_PACKET_MAX
Definition: tun.c:104
struct llist_head entry
Entry in osmo_use_count->use_counts.
Definition: use_count.h:192
bool osmo_str_startswith(const char *str, const char *startswith_str)
Compare start of a string.
Definition: utils.c:1219
@ OSMO_STATS_CLASS_UNKNOWN
unknown class
Definition: stats.h:44
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:32
static void stats_tcp_poll_timer_cb(void *data)
Definition: stats_tcp.c:274
uint32_t value
numeric value
Definition: utils.h:52
const char * group_name_prefix
The prefix to the name of all values in this group.
Definition: stat_item.h:33
void(* cb)(void *)
call-back called at timeout
Definition: timer.h:58
static __thread char capsbuf[128]
Definition: utils.c:43
static int is_initialised
Definition: stats.c:108
static __thread struct timeval nearest
Definition: timer.c:39
static int tundev_dev_name_chg_cb(struct osmo_netdev *netdev, const char *new_dev_name)
Definition: tun.c:199
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
static struct osmo_stat_item_desc stats_tcp_item_desc[]
Definition: stats_tcp.c:77
int osmo_timer_pending(const struct osmo_timer_list *timer)
check if given timer is still pending
Definition: timer.c:134
const char * osmo_tundev_get_dev_name(const struct osmo_tundev *tundev)
Get name used to name the tunnel interface created by the tundev object.
Definition: tun.c:516
#define RB_MAX_MESSAGE_SIZE
A structure representing an osmocom string ringbuffer.
Definition: strrb.h:31
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
void osmo_timer_del(struct osmo_timer_list *timer)
delete a timer from timer management
Definition: timer.c:116
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
static struct osmo_tcp_stats_config s_tcp_stats_config
Definition: stats_tcp.c:46
#define TCP_STATS_DEFAULT_BATCH_SIZE
Definition: stats_tcp.h:4
const char * name
human-readable name
Definition: counter.h:11
struct osmo_use_count * use_count
Parent use count and backpointer to the talloc_object.
Definition: use_count.h:194
#define llist_entry(ptr, type, member)
Get the struct containing this list entry.
Definition: linuxlist.h:218
char * name
Human-readable name of this reporter.
Definition: stats.h:61
State for OSMO_STRBUF_APPEND() and OSMO_STRBUF_PRINTF().
Definition: utils.h:200
struct osmo_strrb * osmo_strrb_create(void *talloc_ctx, size_t rb_size)
Create an empty, initialized osmo_strrb.
Definition: strrb.c:55
int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
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
uint16_t end
index of the last slot
Definition: strrb.h:34
#define DLSTATS
Statistics.
Definition: logging.h:138
pid_t osmo_gettid(void)
Wrapper around Linux's gettid() to make it easily accessible on different system versions.
Definition: thread.c:46
#define OSMO_FD_WRITE
Indicate interest in writing to the file descriptor.
Definition: select.h:19
uint64_t current
current value
Definition: rate_ctr.h:30
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
unspecified unit, explained in osmo_tdef.desc.
Definition: tdef.h:42
bool opened
Definition: tun.c:140
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
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
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
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:184
Definition: linuxrbtree.h:94
#define DLGLOBAL
global logging
Definition: logging.h:129
unsigned int active
is it active?
Definition: timer.h:56
int osmo_hexparse(const char *str, uint8_t *b, unsigned int max_len)
Parse a string containing hexadecimal digits.
Definition: utils.c:240
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
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
Structure representing a file dsecriptor.
Definition: select.h:31
static int tundev_mtu_chg_cb(struct osmo_netdev *netdev, uint32_t new_mtu)
Definition: tun.c:216
osmo_use_count_cb_t use_cb
If not NULL, this is invoked for each use count change.
Definition: use_count.h:173
#define LOGP(ss, level, fmt, args...)
Log a new message through the Osmocom logging framework.
Definition: logging.h:49
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
unsigned long max_val
Maximum timer value (in this tdef unit), checked if set (not zero).
Definition: tdef.h:84
osmo_tundev_data_ind_cb_t data_ind_cb
Definition: tun.c:137
struct msgb * msgb_alloc(uint16_t size, const char *name)
Allocate a new message buffer from tall_msgb_ctx.
Definition: msgb.c:108
static int llist_empty(const struct llist_head *head)
Test whether a linked list is empty.
Definition: linuxlist.h:169
int osmo_timers_check(void)
Check how many timers we have in the system.
Definition: timer.c:279
#define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...)
Shortcut for OSMO_STRBUF_APPEND() invocation using snprintf().
Definition: utils.h:281
enum osmo_sub_auth_type type
@ OSMO_TDEF_US
microseconds
Definition: tdef.h:43
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
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
int enabled
is this reporter enabled
Definition: stats.h:66
char * osmo_osmo_hexdump_nospc(const unsigned char *buf, int len) __attribute__((__deprecated__))
static __thread char hexd_buff[4096]
Definition: utils.c:280
void osmo_use_count_free(struct osmo_use_count_entry *use_count_entry)
Deallocate a use count entry.
Definition: use_count.c:220
char * osmo_hexdump_nospc(const unsigned char *buf, int len)
Convert binary sequence to hexadecimal ASCII string.
Definition: utils.c:428
const char * description
humn-readable description
Definition: counter.h:12
@ STATS_TCP_LOST
Definition: stats_tcp.c:67
static LLIST_HEAD(stats_tcp)
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:39
#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:392
char * dev_name
Definition: tun.c:123
void rb_erase(struct rb_node *, struct rb_root *)
Definition: rbtree.c:214
struct osmo_use_count_entry * osmo_use_count_find(const struct osmo_use_count *uc, const char *use)
Definition: use_count.c:164
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
int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port)
#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
subscriber
Definition: stats.h:47
int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data)
Iterate over all counter groups.
Definition: rate_ctr.c:464
int interval
Definition: stats.h:104
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
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
static int osmo_stats_reporter_check_config(struct osmo_stats_reporter *srep, unsigned int index, int class_id)
Definition: stats.c:629
Statistics item description.
Definition: stat_item.h:22
#define OSMO_T_FMT
Definition: fsm.h:202
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:141
char * name_prefix
prefix for counter names
Definition: stats.h:67
const char * osmo_tundev_get_netns_name(const struct osmo_tundev *tundev)
Get name of network namespace used when opening the tunnel interface.
Definition: tun.c:542
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
#define OSMO_SNPRINTF_RET(ret, rem, offset, len)
Definition: utils.h:99
int class_id
The class to which this group belongs.
Definition: stat_item.h:37
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:39
static const char hex_chars[]
Definition: utils.c:281
int fd
actual operating-system level file decriptor
Definition: select.h:35
struct osmo_tdef * osmo_tdef_get_entry(struct osmo_tdef *tdefs, int T)
Find tdef entry matching T.
Definition: tdef.c:225
void osmo_stats_init(void *ctx)
Initialize the stats reporting module; call this once in your program.
Definition: stats.c:241
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
#define OSMO_MIN(a, b)
Return the minimum of two specified values.
Definition: utils.h:24
unsigned long value
current value
Definition: counter.h:13
bool osmo_strrb_is_empty(const struct osmo_strrb *rb)
Check if an osmo_strrb is empty.
Definition: strrb.c:88
void * data
data pointer passed through to call-back function
Definition: select.h:43
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
#define LOGL_ERROR
error condition, requires user action
Definition: logging.h:125
int osmo_stats_set_interval(int interval)
Set the reporting interval (common for all reporters)
Definition: stats.c:384
bool osmo_tundev_is_open(struct osmo_tundev *tundev)
Retrieve whether the tundev object is in "opened" state.
Definition: tun.c:452
struct osmo_tundev * osmo_tundev_alloc(void *ctx, const char *name)
Allocate a new tundev object.
Definition: tun.c:229
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
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
data we keep for each actual value
Definition: rate_ctr.h:29
struct osmo_timer_list timer
Definition: time_cc.h:167
#define OSMO_FD_EXCEPT
Indicate interest in exceptions from the file descriptor.
Definition: select.h:21
const struct osmo_fd * fd
Definition: stats_tcp.c:60
#define OSMO_MAX(a, b)
Return the maximum of two specified values.
Definition: utils.h:22
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
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
int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data, int data_len)
int osmo_stats_report(void)
Definition: stats.c:790
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
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:139
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: rate_ctr.h:65
void * priv_data
Definition: tun.c:134
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
static void rb_link_node(struct rb_node *node, struct rb_node *parent, struct rb_node **rb_link)
Definition: linuxrbtree.h:146
unsigned int idx
The index of this ctr_group within its class.
Definition: rate_ctr.h:63
uint64_t gran_usec
Granularity in microseconds: nr of microseconds that one rate_ctr increment represents.
Definition: time_cc.h:108
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
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