libosmocore
1.9.2
Osmocom core library
|
void osmo_select_init(void)
int osmo_plugin_load_all(const char *directory)
Definition: plugin.c:65
void osmo_generate_backtrace(void)
Generate and print a call back-trace.
Definition: backtrace.c:63
int osmo_sock_mcast_loop_set(int fd, bool enable)
int osmo_sercomm_drv_rx_char(struct osmo_sercomm_inst *sercomm, uint8_t ch)
the driver has received one byte, pass it into sercomm layer
Definition: sercomm.c:272
static uint64_t timer_ticks
Definition: rate_ctr.c:312
@ IOFD_ACT_WRITE
Definition: osmo_io_internal.h:107
const struct osmo_prbs * prbs
Definition: prbs.h:14
int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
Get the last (freshest) value.
Definition: stat_item.c:429
const char * name
human-readable name
Definition: prbs.h:7
single entry in a SAP/PRIM/OP -> EVENT map
Definition: prim.h:86
#define HDLC_ESCAPE
Definition: sercomm.c:54
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
struct osmo_sockaddr osa
Definition: osmo_io_internal.h:119
#define OSMO_SOCK_F_CONNECT
connect the socket to a remote peer
Definition: socket.h:88
static int rate_ctr_timer_cb(struct osmo_fd *ofd, unsigned int what)
Definition: rate_ctr.c:332
struct sockaddr sa
Definition: socket.h:28
@ RATE_CTR_INTV_HOUR
last hour
Definition: rate_ctr.h:18
#define LOGPIO(iofd, level, fmt, args...)
Definition: osmo_io.h:14
int osmo_sockaddr_str_to_32(const struct osmo_sockaddr_str *sockaddr_str, uint32_t *ip)
const struct rate_ctr_desc * ctr_desc
Pointer to array of counter names.
Definition: rate_ctr.h:53
static osmo_panic_handler_t osmo_panic_handler
Definition: panic.c:33
rate counter description
Definition: rate_ctr.h:37
bool osmo_sockaddr_str_is_set(const struct osmo_sockaddr_str *sockaddr_str)
static struct msgb * msgb_alloc_headroom(uint16_t size, uint16_t headroom, const char *name)
Allocate message buffer with specified headroom.
Definition: msgb.h:551
#define OSMO_SOCK_MAX_ADDRS
maximum number of local or remote addresses supported by an osmo_sock instance
Definition: socket.h:110
struct iovec iov[1]
Definition: osmo_io_internal.h:120
static void osmo_panic_default(const char *fmt, va_list args)
Definition: panic.c:41
int osmo_sockaddr_cmp(const struct osmo_sockaddr *a, const struct osmo_sockaddr *b)
static const char * color(int subsys)
Definition: logging.c:432
int osmo_sock_init_osa(uint16_t type, uint8_t proto, const struct osmo_sockaddr *local, const struct osmo_sockaddr *remote, unsigned int flags)
const struct osmo_prbs osmo_prbs11
PRBS-11 according ITU-T O.150.
Definition: prbs.c:30
int osmo_serial_speed_t(unsigned int baudrate, speed_t *speed)
Convert unsigned integer value to speed_t.
Definition: serial.c:250
struct osmo_stat_item_period reported
The results of the previous reporting period.
Definition: stat_item_internal.h:32
int osmo_fd_disp_fds(void *readset, void *writeset, void *exceptset)
#define OSMO_SOCK_NAME_MAXLEN
maximum length of a socket name ("r=1.2.3.4:123<->l=5.6.7.8:987")
Definition: socket.h:20
int rate_ctr_init(void *tall_ctx)
Initialize the counter module.
Definition: rate_ctr.c:366
char * osmo_sock_get_name2_c(const void *ctx, int fd)
int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, const char *host, uint16_t port, unsigned int flags)
struct iofd_msghdr * iofd_txqueue_dequeue(struct osmo_io_fd *iofd)
int(* osmo_stat_item_handler_t)(struct osmo_stat_item_group *, struct osmo_stat_item *, void *)
Definition: stat_item.h:89
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
void(* write_disable)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:31
int osmo_sock_init2_multiaddr2(uint16_t family, uint16_t type, uint8_t proto, const char **local_hosts, size_t local_hosts_cnt, uint16_t local_port, const char **remote_hosts, size_t remote_hosts_cnt, uint16_t remote_port, unsigned int flags, struct osmo_sock_init2_multiaddr_pars *pars)
unsigned int sap
SAP to match.
Definition: prim.h:87
void rate_ctr_add(struct rate_ctr *ctr, int inc)
Increment the counter by inc.
Definition: rate_ctr.c:286
@ SC_DLCI_ECHO
Definition: sercomm.h:20
int osmo_serial_set_custom_baudrate(int fd, int baudrate)
Change current baudrate to a custom one using OS specific method.
Definition: serial.c:172
const struct rate_ctr_group_desc * desc
Pointer to the counter group class.
Definition: rate_ctr.h:61
void osmo_stat_item_reset(struct osmo_stat_item *item)
Remove all values of a stat item.
Definition: stat_item.c:437
static size_t len(const char *str)
int osmo_sock_init_osa_ofd(struct osmo_fd *ofd, int type, int proto, const struct osmo_sockaddr *local, const struct osmo_sockaddr *remote, unsigned int flags)
static bool rate_ctrl_group_desc_validate(const struct rate_ctr_group_desc *desc)
Definition: rate_ctr.c:75
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
int64_t sum
Sum of all values passed to osmo_stat_item_set() in the reporting period.
Definition: stat_item_internal.h:19
unsigned int priv_nr
private number, extending data
Definition: select.h:45
static unsigned int rate_ctr_get_unused_name_idx(const char *name)
Find an unused index for this rate counter group.
Definition: rate_ctr.c:189
int osmo_sockaddr_str_from_sockaddr_in(struct osmo_sockaddr_str *sockaddr_str, const struct sockaddr_in *src)
void rate_ctr_group_free(struct rate_ctr_group *grp)
Free the memory for the specified group of counters.
Definition: rate_ctr.c:255
const struct osmo_stat_item_desc * item_desc
Pointer to array of value names, length as per num_items.
Definition: stat_item.h:41
#define OSMO_ASSERT(exp)
Helper macro to terminate when an assertion fails.
Definition: utils.h:113
const char * osmo_sock_get_name2(int fd)
Definition: stat_item_internal.h:9
const struct osmo_stat_item * osmo_stat_item_get_by_name(const struct osmo_stat_item_group *statg, const char *name)
Search for item based on group + item name.
Definition: stat_item.c:370
#define DEBUGP(ss, fmt, args...)
Log a debug message through the Osmocom logging framework.
Definition: logging.h:30
One instance of a counter group class.
Definition: stat_item.h:45
Osmocom primitive header.
Definition: prim.h:47
#define DEFAULT_RX_MSG_SIZE
Definition: sercomm.c:37
static unsigned char * msgb_put(struct msgb *msgb, unsigned int len)
append data to end of message buffer
Definition: msgb.h:240
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
#define OSMO_NO_EVENT
magic value to be used as final record of osmo_prim_event_map
Definition: prim.h:83
char subsys[16]
logging sub-system
Definition: gsmtap.h:11
ubit_t osmo_prbs_get_ubit(struct osmo_prbs_state *state)
Get the next bit out of given PRBS instance.
Definition: prbs.c:61
unsigned int idx
The index of this value group within its class.
Definition: stat_item.h:51
void osmo_sercomm_init(struct osmo_sercomm_inst *sercomm)
Initialize an Osmocom sercomm instance.
Definition: sercomm.c:74
unsigned char * data
start of message in buffer
Definition: msgb.h:55
int(* osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *)
Definition: stat_item.h:92
const struct osmo_stat_item_desc * osmo_stat_item_get_desc(struct osmo_stat_item *item)
Return the description for an osmo_stat_item.
Definition: stat_item.c:458
struct osmo_io_fd * iofd
Definition: osmo_io_internal.h:124
struct msgb * msg
Definition: osmo_io_internal.h:123
uint64_t rate
counter rate
Definition: rate_ctr.h:25
data we keep for each actual item
Definition: stat_item_internal.h:23
int osmo_fd_register(struct osmo_fd *fd)
int32_t default_value
default value
Definition: stat_item.h:27
int osmo_sock_set_priority(int fd, int prio)
void rate_ctr_group_set_name(struct rate_ctr_group *grp, const char *name)
Set a name for the group of counters be used instead of index value at report time.
Definition: rate_ctr.c:280
int(* cb)(struct osmo_fd *fd, unsigned int what)
call-back function to be called once file descriptor becomes available
Definition: select.h:41
sigset_t sigset
Definition: select.h:100
static void __rb_erase_color(struct rb_node *node, struct rb_node *parent, struct rb_root *root)
Definition: rbtree.c:134
const unsigned int num_items
The number of values in this group (size of item_desc)
Definition: stat_item.h:39
#define rb_set_black(r)
Definition: linuxrbtree.h:115
int fd
actual operating-system level file decriptor
Definition: osmo_io_internal.h:53
@ PRIM_OP_INDICATION
indication
Definition: prim.h:29
void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root)
Definition: rbtree.c:360
static char * mangle_identifier_ifneeded(const void *ctx, const char *in)
Definition: rate_ctr.c:108
void osmo_stat_item_group_reset(struct osmo_stat_item_group *statg)
Reset all osmo stat items in a group.
Definition: stat_item.c:447
struct llist_head dlci_queues[_SC_DLCI_MAX]
per-DLC queue of pending transmit msgbs
Definition: sercomm.h:41
uint16_t osmo_sockaddr_port(const struct sockaddr *sa)
int osmo_sockaddr_str_to_in6_addr(const struct osmo_sockaddr_str *sockaddr_str, struct in6_addr *dst)
int osmo_timers_nearest_ms(void)
Determine time between now and the nearest timer in milliseconds.
Definition: timer.c:186
void osmo_stat_item_inc(struct osmo_stat_item *item, int32_t value)
Increase the stat_item to the given value.
Definition: stat_item.c:260
#define llist_for_each_entry_safe(pos, n, head, member)
Iterate over llist of given type, safe against removal of llist entry.
Definition: linuxlist.h:337
int osmo_sockaddr_str_to_sockaddr_in6(const struct osmo_sockaddr_str *sockaddr_str, struct sockaddr_in6 *dst)
@ PRIM_OP_REQUEST
request
Definition: prim.h:27
#define llist_for_each(pos, head)
Iterate over a linked list.
Definition: linuxlist.h:261
@ RATE_CTR_INTV_MIN
last minute
Definition: rate_ctr.h:17
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)
char * osmo_sock_get_name(const void *ctx, int fd)
static int msgb_tailroom(const struct msgb *msgb)
determine how much tail room is left in msgb
Definition: msgb.h:211
#define HDLC_FLAG
Definition: sercomm.c:53
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
struct osmo_stat_item_period value
Current reporting period / current value.
Definition: stat_item_internal.h:28
bool osmo_sockaddr_str_is_nonzero(const struct osmo_sockaddr_str *sockaddr_str)
void(* write_cb)(struct osmo_io_fd *iofd, int res, struct msgb *msg)
call-back function when write has completed on fd
Definition: osmo_io.h:44
#define OSMO_FD_READ
Indicate interest in reading from the file descriptor.
Definition: select.h:17
struct rb_node * rb_prev(const struct rb_node *node)
Definition: rbtree.c:336
bool osmo_fd_is_registered(struct osmo_fd *fd)
char ip[INET6_ADDRSTRLEN]
NUL terminated string of the IPv4 or IPv6 address.
Definition: sockaddr_str.h:49
Definition: osmo_io_internal.h:26
#define INIT_LLIST_HEAD(ptr)
Initialize a llist_head to point back to itself.
Definition: linuxlist.h:65
size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
Copy a C-string into a sized buffer.
Definition: utils.c:565
void * data
Definition: select.h:102
#define osmo_ntohs(x)
Definition: byteswap.h:42
#define IOFD_FLAG_TO_FREE
Definition: osmo_io_internal.h:38
@ IOFD_ACT_READ
Definition: osmo_io_internal.h:106
#define rb_color(r)
Definition: linuxrbtree.h:111
static void * tall_rate_ctr_ctx
Definition: rate_ctr.c:72
struct sockaddr_in6 sin6
Definition: socket.h:31
#define OTC_GLOBAL
Definition: talloc.h:26
static socklen_t osmo_sockaddr_size(const struct osmo_sockaddr *addr)
Return the size of the variant used in the address NOTE: This does not return the size of the in{,...
Definition: socket.h:46
osmo_signal_cbfn * cbfn
Definition: signal.c:41
int osmo_sock_unix_init(uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags)
@ RX_ST_ADDR
Definition: sercomm.c:62
const struct iofd_backend_ops iofd_poll_ops
int osmo_sockaddr_str_from_32n(struct osmo_sockaddr_str *sockaddr_str, uint32_t ip, uint16_t port) OSMO_DEPRECATED("osmo_sockaddr_str_from_32n() actually uses *host* byte order. Use osmo_sockaddr_str_from_32h() instead")
int initialized
Has this instance been initialized?
Definition: sercomm.h:34
struct rb_node * rb_left
Definition: linuxrbtree.h:6
int osmo_sock_mcast_all_set(int fd, bool enable)
struct osmo_io_fd::@40::@41 poll
#define RB_BLACK
Definition: linuxrbtree.h:4
struct rb_node * rb_first(const struct rb_root *root)
Definition: rbtree.c:284
struct llist_head list
Linked list of all value groups in the system.
Definition: stat_item.h:47
#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
const char * description
description of the counter
Definition: rate_ctr.h:39
void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data)
Unregister signal handler.
Definition: signal.c:86
union osmo_sockaddr::@28 u
int osmo_sercomm_drv_pull(struct osmo_sercomm_inst *sercomm, uint8_t *ch)
fetch one octet of to-be-transmitted serial data
Definition: sercomm.c:179
char * osmo_sockaddr_to_str_buf(char *buf, size_t buf_len, const struct osmo_sockaddr *sockaddr)
const struct osmo_prbs osmo_prbs9
PRBS-9 according ITU-T O.150.
Definition: prbs.c:22
uint16_t msgb_length(const struct msgb *msg)
get length of message buffer
Definition: msgb.c:285
int osmo_sock_get_local_ip_port(int fd, char *port, size_t len)
int osmo_serial_set_baudrate(int fd, speed_t baudrate)
Change current baudrate.
Definition: serial.c:158
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
#define IOFD_FLAG_ISSET(iofd, flag)
Definition: osmo_io_internal.h:47
__thread struct osmo_talloc_contexts * osmo_ctx
Definition: context.c:24
int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags)
int osmo_fd_fill_fds(void *readset, void *writeset, void *exceptset)
enum osmo_prim_operation operation
Definition: prim.h:50
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 OSMO_SOCK_F_NONBLOCK
switch socket to non-blocking mode
Definition: socket.h:92
#define osmo_ntohl(x)
Definition: byteswap.h:41
@ OSMO_IO_FD_MODE_SCTP_RECVMSG_SENDMSG
emulate sctp_recvmsg() and sctp_sendmsg()
Definition: osmo_io.h:25
struct osmo_io_ops io_ops
send/recv (msg) callback functions
Definition: osmo_io_internal.h:64
static void osmo_fd_read_enable(struct osmo_fd *ofd)
Definition: select.h:54
struct osmo_sercomm_inst::@24 tx
transmit side
uint32_t n
Number of osmo_stat_item_set() that occurred during the reporting period, zero if none.
Definition: stat_item_internal.h:11
int sercomm_drv_baudrate_chg(struct osmo_sercomm_inst *sercomm, uint32_t bdrt)
low-level driver routine to execute baud-rate change
static void dispatch_rx_msg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
Definition: sercomm.c:258
@ IOFD_ACT_RECVFROM
Definition: osmo_io_internal.h:108
uint8_t * next_char
next to-be-transmitted char in msg
Definition: sercomm.h:47
int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *host, uint16_t port, unsigned int flags)
int osmo_sock_mcast_ttl_set(int fd, uint8_t ttl)
int osmo_select_shutdown_requested(void)
Osmocom message buffer.
Definition: msgb.h:31
static unsigned char * msgb_push(struct msgb *msgb, unsigned int len)
prepend (push) some data to start of message
Definition: msgb.h:341
static void osmo_fd_read_disable(struct osmo_fd *ofd)
Definition: select.h:58
const struct osmo_prbs osmo_prbs7
PRBS-7 according ITU-T O.150.
Definition: prbs.c:14
#define LOGL_INFO
general information
Definition: logging.h:123
void osmo_prbs_state_init(struct osmo_prbs_state *st, const struct osmo_prbs *prbs)
Initialize the given caller-allocated PRBS state.
Definition: prbs.c:46
uint8_t ctrl
CTRL of currently received msgb.
Definition: sercomm.h:63
const struct rate_ctr * rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name)
Search for counter based on group + name.
Definition: rate_ctr.c:418
static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:23
Definition: linuxrbtree.h:104
int osmo_signal_register_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void *data)
Register a new signal handler.
Definition: signal.c:61
static int _osmo_serial_set_baudrate(int fd, speed_t baudrate)
Definition: serial.c:127
#define OSMO_CMP(a, b)
Return a typical cmp result for comparable entities a and b.
Definition: utils.h:26
int osmo_sockaddr_str_to_sockaddr_in(const struct osmo_sockaddr_str *sockaddr_str, struct sockaddr_in *dst)
struct llist_head list
linked list for internal management
Definition: select.h:33
int osmo_sockaddr_to_octets(uint8_t *dst, size_t dst_maxlen, const struct osmo_sockaddr *os)
#define IOFD_FLAG_CLOSED
Definition: osmo_io_internal.h:36
struct rb_node * rb_next(const struct rb_node *node)
Definition: rbtree.c:308
void osmo_fd_update_when(struct osmo_fd *ofd, unsigned int when_mask, unsigned int when)
const struct osmo_stat_item_desc * desc
back-reference to the item description
Definition: stat_item_internal.h:25
#define rb_set_red(r)
Definition: linuxrbtree.h:114
int osmo_sockaddr_str_from_in6_addr(struct osmo_sockaddr_str *sockaddr_str, const struct in6_addr *addr, uint16_t port)
One instance of a counter group class.
Definition: rate_ctr.h:57
const char * group_description
The human-readable description of the group.
Definition: rate_ctr.h:47
struct rb_node * rb_left
Definition: linuxrbtree.h:100
void osmo_sockaddr_set_port(struct sockaddr *sa, uint16_t port)
unsigned int osmo_iofd_txqueue_len(struct osmo_io_fd *iofd)
void osmo_panic(const char *fmt,...) __attribute__((noreturn))
Terminate the current program with a panic.
Definition: panic.c:71
struct msghdr hdr
Definition: osmo_io_internal.h:118
static struct rate_ctr_group_desc * rate_ctr_group_desc_mangle(void *ctx, const struct rate_ctr_group_desc *desc)
Definition: rate_ctr.c:139
void msgb_free(struct msgb *m)
Release given message buffer.
Definition: msgb.c:117
uint32_t event
event as result if above match
Definition: prim.h:90
int osmo_sock_mcast_subscribe(int fd, const char *grp_addr)
int osmo_sercomm_initialized(struct osmo_sercomm_inst *sercomm)
Determine if a given Osmocom sercomm instance has been initialized.
Definition: sercomm.c:92
void * osmo_signal_talloc_ctx_init(void *root_ctx)
Initialize a signal_handler talloc context for osmo_signal_register_handler.
Definition: signal.c:50
int osmo_sockaddr_to_str_buf2(char *buf, size_t buf_len, const struct osmo_sockaddr *sockaddr)
void rb_insert_color(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:69
void osmo_fd_close(struct osmo_fd *fd)
struct rate_ctr_group * rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx)
Search for counter group based on group name and index.
Definition: rate_ctr.c:397
void * tall_sigh_ctx
Definition: signal.c:35
provider libosmocore
Definition: probes.d:1
size_t osmo_sockaddr_in_to_str_and_uint(char *addr, unsigned int addr_len, uint16_t *port, const struct sockaddr_in *sin)
int osmo_sockaddr_from_octets(struct osmo_sockaddr *os, const void *src, size_t src_len)
struct llist_head list
Linked list of all counter groups in the system.
Definition: rate_ctr.h:59
int(* rate_ctr_handler_t)(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *)
Definition: rate_ctr.h:122
static void interval_expired(struct rate_ctr *ctr, enum rate_ctr_intv intv)
Definition: rate_ctr.c:303
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: stat_item.h:53
int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen)
@ OSMO_IO_FD_MODE_READ_WRITE
use read() / write() calls
Definition: osmo_io.h:21
dlci_cb_t dlci_handler[_SC_DLCI_MAX]
per-DLC handler call-back functions
Definition: sercomm.h:53
int osmo_sockaddr_str_from_str2(struct osmo_sockaddr_str *sockaddr_str, const char *ip)
#define OSMO_SOCKADDR_STR_FMT_ARGS(R)
Definition: sockaddr_str.h:67
int osmo_select_main_ctx(int polling)
static void rate_ctr_group_intv(struct rate_ctr_group *grp)
Definition: rate_ctr.c:315
#define osmo_htonl(x)
Definition: byteswap.h:43
void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data)
dispatch (deliver) a new signal to all registered handlers
Definition: signal.c:106
unsigned int num_ctr
The number of counters in this group.
Definition: rate_ctr.h:51
void(* sendto_cb)(struct osmo_io_fd *iofd, int res, struct msgb *msg, const struct osmo_sockaddr *daddr)
call-back function emulating sendto
Definition: osmo_io.h:65
int osmo_sock_init2(uint16_t family, uint16_t type, uint8_t proto, const char *local_host, uint16_t local_port, const char *remote_host, uint16_t remote_port, unsigned int flags)
int osmo_sock_init2_multiaddr(uint16_t family, uint16_t type, uint8_t proto, const char **local_hosts, size_t local_hosts_cnt, uint16_t local_port, const char **remote_hosts, size_t remote_hosts_cnt, uint16_t remote_port, unsigned int flags) OSMO_DEPRECATED_OUTSIDE("Use osmo_sock_init2_multiaddr2() instead")
void osmo_timers_prepare(void)
Find the nearest time and update nearest_p.
Definition: timer.c:215
static LLIST_HEAD(signal_handler_list)
int(* rate_ctr_group_handler_t)(struct rate_ctr_group *, void *)
Definition: rate_ctr.h:125
unsigned int when
bit-mask or of OSMO_FD_READ, OSMO_FD_WRITE and/or OSMO_FD_EXCEPT
Definition: select.h:38
unsigned char * tail
end of message in buffer
Definition: msgb.h:54
#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
static void osmo_prbs_process_bit(struct osmo_prbs_state *state, ubit_t bit)
Definition: prbs.c:53
const struct osmo_prbs osmo_prbs15
PRBS-15 according ITU-T O.150.
Definition: prbs.c:38
int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, void *data)
Iterate over all stat_item groups in system, call user-supplied function on each.
Definition: stat_item.c:414
void osmo_stat_item_dec(struct osmo_stat_item *item, int32_t value)
Descrease the stat_item to the given value.
Definition: stat_item.c:271
struct timeval * osmo_timers_nearest(void)
Determine time between now and the nearest timer.
Definition: timer.c:175
struct msgb * msg
msgb currently being transmitted
Definition: sercomm.h:43
int osmo_serial_init(const char *dev, speed_t baudrate)
Open serial device and does base init.
Definition: serial.c:54
void(* osmo_panic_handler_t)(const char *fmt, va_list args)
panic handler callback function type
Definition: panic.h:10
struct rate_ctr ctr[0]
Actual counter structures below.
Definition: rate_ctr.h:67
definition of a PRBS sequence
Definition: prbs.h:6
struct rate_ctr_group * rate_ctr_group_alloc(void *ctx, const struct rate_ctr_group_desc *desc, unsigned int idx)
Allocate a new group of counters according to description.
Definition: rate_ctr.c:212
#define IOFD_FLAG_UNSET(iofd, flag)
Definition: osmo_io_internal.h:44
void osmo_set_panic_handler(osmo_panic_handler_t h)
Set the panic handler.
Definition: panic.c:98
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
const char * name
name of the counter
Definition: rate_ctr.h:38
void iofd_txqueue_enqueue_front(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
unsigned int osmo_sockaddr_to_str_and_uint(char *addr, unsigned int addr_len, uint16_t *port, const struct sockaddr *sa)
#define IOFD_FLAG_SET(iofd, flag)
Definition: osmo_io_internal.h:41
struct rate_ctr * rate_ctr_group_get_ctr(struct rate_ctr_group *grp, unsigned int idx)
Get rate counter from group, identified by index idx.
Definition: rate_ctr.c:270
@ RX_ST_ESCAPE
Definition: sercomm.c:65
uint32_t osmo_event_for_prim(const struct osmo_prim_hdr *oph, const struct osmo_prim_event_map *maps)
resolve the (fsm) event for a given primitive using a map
Definition: prim.c:28
bool osmo_identifier_valid(const char *str)
Determine if a given identifier is valid, i.e.
Definition: utils.c:671
int32_t last
Most recent value passed to osmo_stat_item_set(), or the item->desc->default_value if none.
Definition: stat_item_internal.h:15
void * data
Definition: signal.c:42
int osmo_timerfd_disable(struct osmo_fd *ofd)
int osmo_sockaddr_str_from_32h(struct osmo_sockaddr_str *sockaddr_str, uint32_t ip, uint16_t port)
(double) linked list header structure
Definition: linuxlist.h:46
@ OSMO_IO_FD_MODE_RECVFROM_SENDTO
use recvfrom() / sendto() calls
Definition: osmo_io.h:23
int osmo_sockaddr_str_from_sockaddr_in6(struct osmo_sockaddr_str *sockaddr_str, const struct sockaddr_in6 *src)
if(vty->type==VTY_SHELL_SERV)
static void * tall_stat_item_ctx
talloc context from which we allocate
Definition: stat_item.c:170
unsigned long rb_parent_color
Definition: linuxrbtree.h:96
int osmo_sock_get_ip_and_port(int fd, char *ip, size_t ip_len, char *port, size_t port_len, bool local)
const struct value_string osmo_prim_op_names[5]
human-readable string mapping for osmo_prim_operation
Definition: prim.c:16
int osmo_signal_cbfn(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data)
signal callback function type
Definition: signal.h:33
static LLIST_HEAD(osmo_stat_item_groups)
global list of stat_item groups
void log_reset_context(void)
Reset (clear) the logging context.
Definition: logging.c:808
#define OSMO_SOCK_F_NO_MCAST_LOOP
disable multiast loop (IP_MULTICAST_LOOP)
Definition: socket.h:94
#define DLIO
Osmocom IO sub-system.
Definition: logging.h:157
struct osmo_io_fd::@40::@42 uring
enum osmo_prim_operation operation
operation to match
Definition: prim.h:89
rx_state
Definition: sercomm.c:60
uint64_t coeff
coefficients
Definition: prbs.h:9
int osmo_sockaddr_str_from_in_addr(struct osmo_sockaddr_str *sockaddr_str, const struct in_addr *addr, uint16_t port)
static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:46
#define OSMO_SOCK_F_UDP_REUSEADDR
use SO_REUSEADDR on UDP ports (required for multicast)
Definition: socket.h:98
int af
AF_INET for IPv4 address, or AF_INET6 for IPv6 address.
Definition: sockaddr_str.h:47
struct rb_node * rb_node
Definition: linuxrbtree.h:106
static void osmo_fd_write_disable(struct osmo_fd *ofd)
Definition: select.h:66
#define HDLC_C_UI
Definition: sercomm.c:56
int osmo_timerfd_setup(struct osmo_fd *ofd, int(*cb)(struct osmo_fd *, unsigned int), void *data)
void sercomm_drv_start_tx(struct osmo_sercomm_inst *sercomm)
low-level driver routine to request start of transmission The Sercomm code calls this function to inf...
int osmo_sock_local_ip(char *local_ip, const char *remote_ip)
struct osmo_fd ofd
Definition: osmo_io_internal.h:93
void rate_ctr_group_reset(struct rate_ctr_group *ctrg)
Reset all counters in a group.
Definition: rate_ctr.c:489
int osmo_sockaddr_str_from_str(struct osmo_sockaddr_str *sockaddr_str, const char *ip, uint16_t port)
int osmo_sockaddr_str_to_32h(const struct osmo_sockaddr_str *sockaddr_str, uint32_t *ip)
const char * group_name_prefix
The prefix to the name of all counters in this group.
Definition: rate_ctr.h:45
static struct osmo_fd rate_ctr_timer
Definition: rate_ctr.c:311
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
int osmo_sockaddr_str_from_32(struct osmo_sockaddr_str *sockaddr_str, uint32_t ip, uint16_t port)
struct osmo_signalfd * osmo_signalfd_setup(void *ctx, sigset_t set, osmo_signalfd_cb *cb, void *data)
#define llist_for_each_entry(pos, head, member)
Iterate over a linked list of a given type.
Definition: linuxlist.h:299
#define dbg_perror(x)
Definition: serial.c:45
uint8_t dlci
DLCI of currently received msgb.
Definition: sercomm.h:61
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
int osmo_sock_init2_ofd(struct osmo_fd *ofd, int family, int type, int proto, const char *local_host, uint16_t local_port, const char *remote_host, uint16_t remote_port, unsigned int flags)
static void osmo_fd_write_enable(struct osmo_fd *ofd)
Definition: select.h:62
char * buf
Point to the start of a string buffer.
Definition: utils.h:202
struct osmo_stat_item_group * osmo_stat_item_get_group_by_name_idx(const char *name, const unsigned int idx)
Search for item group based on group name and index.
Definition: stat_item.c:330
bool osmo_select_shutdown_done(void)
#define LOGL_NOTICE
abnormal/unexpected condition
Definition: logging.h:124
rate_ctr_intv
Rate counter interval.
Definition: rate_ctr.h:15
@ RX_ST_DATA
Definition: sercomm.c:64
int osmo_sockaddr_netmask_to_prefixlen(const struct osmo_sockaddr *addr)
void sercomm_drv_lock(unsigned long __attribute__((unused)) *flags)
Protect against IRQ context.
Definition: sercomm.c:39
unsigned int osmo_sercomm_tx_queue_depth(struct osmo_sercomm_inst *sercomm, uint8_t dlci)
How deep is the Tx queue for a given DLCI?
Definition: sercomm.c:126
void sercomm_drv_unlock(unsigned long __attribute__((unused)) *flags)
Release protection against IRQ context.
Definition: sercomm.c:41
void iofd_handle_recv(struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *msghdr)
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
struct sockaddr_in sin
Definition: socket.h:30
const char * name
name of the item
Definition: stat_item.h:23
struct osmo_fd ofd
Definition: select.h:99
A mapping between human-readable string and numeric value.
Definition: utils.h:51
int state
transmit state
Definition: sercomm.h:45
osmo_signalfd_cb * cb
Definition: select.h:101
struct osmo_sercomm_inst::@25 rx
receive side
struct osmo_fd * osmo_fd_get_by_fd(int fd)
iofd_msg_action
Definition: osmo_io_internal.h:105
int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval)
one instance of a sercomm multiplex/demultiplex
Definition: sercomm.h:32
int osmo_sockaddr_str_to_in_addr(const struct osmo_sockaddr_str *sockaddr_str, struct in_addr *dst)
void osmo_signalfd_cb(struct osmo_signalfd *osfd, const struct signalfd_siginfo *fdsi)
Definition: select.h:96
__attribute__((weak))
Definition: sercomm.c:47
int osmo_prbs_get_ubits(ubit_t *out, unsigned int out_len, struct osmo_prbs_state *state)
Fill buffer of unpacked bits with next bits out of given PRBS instance.
Definition: prbs.c:70
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
int osmo_sock_set_dscp(int fd, uint8_t dscp)
uint8_t ubit_t
unpacked bit (0 or 1): 1 bit per byte
Definition: bits.h:24
enum iofd_msg_action action
Definition: osmo_io_internal.h:117
#define ARRAY_SIZE(x)
Determine number of elements in an array of static size.
Definition: utils.h:19
struct rb_node * rb_right
Definition: linuxrbtree.h:99
int osmo_sock_get_name_buf(char *str, size_t str_len, int fd)
uint64_t previous
previous value, used for delta
Definition: rate_ctr.h:31
unsigned int msg_size
msgb allocation size for rx msgs
Definition: sercomm.h:55
const char * group_name_prefix
The prefix to the name of all values in this group.
Definition: stat_item.h:33
#define OSMO_UNLIKELY(exp)
Definition: utils.h:47
int osmo_sercomm_change_speed(struct osmo_sercomm_inst *sercomm, uint32_t bdrt)
wait until everything has been transmitted, then grab the lock and change the baud rate as requested
Definition: sercomm.c:144
#define OSMO_SOCKADDR_STR_FMT
Format string to print an osmo_sockaddr_str.
Definition: sockaddr_str.h:61
int osmo_sock_get_remote_ip_port(int fd, char *port, size_t len)
#define IOFD_FLAG_IN_CALLBACK
Definition: osmo_io_internal.h:37
int osmo_sockaddr_str_from_sockaddr(struct osmo_sockaddr_str *sockaddr_str, const struct sockaddr_storage *src)
State for OSMO_STRBUF_APPEND() and OSMO_STRBUF_PRINTF().
Definition: utils.h:200
struct rb_node * rb_last(const struct rb_root *root)
Definition: rbtree.c:296
struct osmo_sock_init2_multiaddr_pars::@29::@31 sctp
#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
int32_t min
Smallest value seen in a reporting period.
Definition: stat_item_internal.h:13
int flags
Definition: osmo_io_internal.h:121
int osmo_serial_clear_custom_baudrate(int fd)
Clear any custom baudrate.
Definition: serial.c:220
int(* register_fd)(struct osmo_io_fd *iofd)
Definition: osmo_io_internal.h:27
static unsigned char * msgb_pull(struct msgb *msgb, unsigned int len)
remove (pull) a header from the front of the message buffer
Definition: msgb.h:404
static void rb_set_parent(struct rb_node *rb, struct rb_node *p)
Definition: linuxrbtree.h:117
struct rate_ctr_per_intv intv[RATE_CTR_INTV_NUM]
per-interval data
Definition: rate_ctr.h:33
uint8_t * msgb_data(const struct msgb *msg)
get pointer to data section of message buffer
Definition: msgb.c:184
Definition: linuxrbtree.h:94
int osmo_ip_str_type(const char *ip)
#define DLGLOBAL
global logging
Definition: logging.h:129
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
Definition: osmo_io_internal.h:49
Structure representing a file dsecriptor.
Definition: select.h:31
int osmo_sercomm_register_rx_cb(struct osmo_sercomm_inst *sercomm, uint8_t dlci, dlci_cb_t cb)
Register a handler for a given DLCI.
Definition: sercomm.c:245
#define LOGP(ss, level, fmt, args...)
Log a new message through the Osmocom logging framework.
Definition: logging.h:49
static int llist_empty(const struct llist_head *head)
Test whether a linked list is empty.
Definition: linuxlist.h:169
#define rb_is_red(r)
Definition: linuxrbtree.h:112
#define rb_parent(r)
Definition: linuxrbtree.h:110
int osmo_sock_get_remote_ip(int fd, char *host, size_t len)
struct msgb * iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd)
#define OSMO_STRBUF_PRINTF(STRBUF, fmt, args...)
Shortcut for OSMO_STRBUF_APPEND() invocation using snprintf().
Definition: utils.h:281
int osmo_sock_get_local_ip(int fd, char *host, size_t len)
enum osmo_sub_auth_type type
void osmo_sercomm_sendmsg(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
User interface for transmitting messages for a given DLCI.
Definition: sercomm.c:102
uint64_t state
Definition: prbs.h:15
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
#define rb_is_black(r)
Definition: linuxrbtree.h:113
#define GET_OSMO_SOCK_F_PRIO(f)
Definition: socket.h:106
void * select
volatile select-dispatch context.
Definition: talloc.h:19
struct iofd_msghdr * iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg)
static struct msgb * osmo_sercomm_alloc_msgb(unsigned int len)
Sercomm msgb allocator function.
Definition: sercomm.h:106
Definition: osmo_io_internal.h:115
int osmo_sockaddr_local_ip(struct osmo_sockaddr *local_ip, const struct osmo_sockaddr *remote_ip)
#define osmo_htons(x)
Definition: byteswap.h:44
unsigned int subsys
Definition: signal.c:40
description of a rate counter group
Definition: rate_ctr.h:43
struct osmo_stat_item * items[0]
Actual counter structures below.
Definition: stat_item.h:55
void iofd_msghdr_free(struct iofd_msghdr *msghdr)
int osmo_sockaddr_str_cmp(const struct osmo_sockaddr_str *a, const struct osmo_sockaddr_str *b)
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
Statistics item description.
Definition: stat_item.h:22
static void rb_set_color(struct rb_node *rb, int color)
Definition: linuxrbtree.h:121
struct msgb * msgb_dequeue(struct llist_head *queue)
Dequeue message buffer from head of queue.
Definition: msgb.c:141
struct llist_head entry
Definition: signal.c:39
uint64_t last
counter value in last interval
Definition: rate_ctr.h:24
int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, uint8_t proto, unsigned int flags)
@ RATE_CTR_INTV_DAY
last day
Definition: rate_ctr.h:19
@ IOFD_ACT_SENDTO
Definition: osmo_io_internal.h:109
#define OSMO_SNPRINTF_RET(ret, rem, offset, len)
Definition: utils.h:99
void osmo_select_shutdown_request(void)
int osmo_sock_mcast_iface_set(int fd, const char *ifname)
int fd
actual operating-system level file decriptor
Definition: select.h:35
int osmo_sockaddr_str_to_sockaddr(const struct osmo_sockaddr_str *sockaddr_str, struct sockaddr_storage *dst)
state of a given PRBS sequence generator
Definition: prbs.h:13
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
#define GET_OSMO_SOCK_F_DSCP(f)
Definition: socket.h:102
#define LOGL_DEBUG
different log levels
Definition: logging.h:122
enum osmo_io_fd_mode mode
type of read/write mode to use
Definition: osmo_io_internal.h:55
@ RX_ST_CTRL
Definition: sercomm.c:63
#define OSMO_SOCK_F_BIND
bind the socket to a local address/port
Definition: socket.h:90
void msgb_enqueue(struct llist_head *queue, struct msgb *msg)
Enqueue message buffer to tail of a queue.
Definition: msgb.c:129
int osmo_stat_item_init(void *tall_ctx)
Initialize the stat item module.
Definition: stat_item.c:319
char * osmo_sockaddr_to_str_c(void *ctx, const struct osmo_sockaddr *sockaddr)
unsigned int primitive
Primitive number.
Definition: prim.h:49
void * data
data pointer passed through to call-back function
Definition: select.h:43
Definition: sockaddr_str.h:45
unsigned int primitive
primtiive to match
Definition: prim.h:88
#define LOGL_ERROR
error condition, requires user action
Definition: logging.h:125
@ RATE_CTR_INTV_SEC
last second
Definition: rate_ctr.h:16
void rate_ctr_reset(struct rate_ctr *ctr)
Reset a rate counter back to zero.
Definition: rate_ctr.c:481
struct osmo_stat_item_group * osmo_stat_item_get_group_by_name_idxname(const char *group_name, const char *idx_name)
Search for item group based on group name and index's name.
Definition: stat_item.c:350
uint16_t port
Port number.
Definition: sockaddr_str.h:51
static LLIST_HEAD(rate_ctr_groups)
int osmo_select_main(int polling)
data we keep for each actual value
Definition: rate_ctr.h:29
#define OSMO_FD_EXCEPT
Indicate interest in exceptions from the file descriptor.
Definition: select.h:21
int osmo_sockaddr_str_to_32n(const struct osmo_sockaddr_str *sockaddr_str, uint32_t *ip) OSMO_DEPRECATED("osmo_sockaddr_str_to_32n() actually uses *host* byte order. Use osmo_sockaddr_str_to_32h() instead")
#define OSMO_MAX(a, b)
Return the maximum of two specified values.
Definition: utils.h:22
void(* dlci_cb_t)(struct osmo_sercomm_inst *sercomm, uint8_t dlci, struct msgb *msg)
call-back function for per-DLC receive handler
Definition: sercomm.h:29
const char * osmo_sockaddr_ntop(const struct sockaddr *sa, char *dst)
#define OSMO_SOCK_F_NO_MCAST_ALL
disable receiving all multiast even for non-subscribed groups
Definition: socket.h:96
@ PRIM_OP_CONFIRM
confirm
Definition: prim.h:30
void rb_erase(struct rb_node *node, struct rb_root *root)
Definition: rbtree.c:214
unsigned int sap
Service Access Point Identifier.
Definition: prim.h:48
int osmo_sockaddr_is_any(const struct osmo_sockaddr *addr)
@ PRIM_OP_RESPONSE
response
Definition: prim.h:28
static int handle_counter(struct osmo_counter *counter, void *vctx_)
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: rate_ctr.h:65
@ RX_ST_WAIT_START
Definition: sercomm.c:61
const char * osmo_sockaddr_to_str(const struct osmo_sockaddr *sockaddr)
unsigned int idx
The index of this ctr_group within its class.
Definition: rate_ctr.h:63
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