libosmocore 1.9.0.196-9975
Osmocom core library
osmo_io.h File Reference

io(_uring) abstraction osmo fd compatibility More...

#include <sys/socket.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/utils.h>

Go to the source code of this file.

Data Structures

struct  osmo_io_ops
 I/O operations (call-back functions) related to an osmo_io_fd. More...
 

Macros

#define LOGPIO(iofd, level, fmt, args...)    LOGP(DLIO, level, "iofd(%s)" fmt, iofd->name, ## args)
 log macro used for logging information related to the osmo_io_fd. More...
 

Enumerations

enum  osmo_io_fd_mode {
  OSMO_IO_FD_MODE_READ_WRITE ,
  OSMO_IO_FD_MODE_RECVFROM_SENDTO ,
  OSMO_IO_FD_MODE_RECVMSG_SENDMSG
}
 The mode of an osmo_io_fd determines if read/write, recvfrom/sendmsg or recvmsg/sendmsg semantics are used. More...
 
enum  osmo_io_backend {
  OSMO_IO_BACKEND_POLL ,
  OSMO_IO_BACKEND_IO_URING
}
 The back-end used by osmo_io. More...
 

Functions

static const char * osmo_io_backend_name (enum osmo_io_backend val)
 return the string name of an osmo_io_backend More...
 
static const char * osmo_iofd_mode_name (enum osmo_io_fd_mode val)
 return the string name of an osmo_io_mode More...
 
void osmo_iofd_init (void)
 initialize osmo_io for the current thread More...
 
struct osmo_io_fdosmo_iofd_setup (const void *ctx, int fd, const char *name, enum osmo_io_fd_mode mode, const struct osmo_io_ops *ioops, void *data)
 Allocate and setup a new iofd. More...
 
int osmo_iofd_set_cmsg_size (struct osmo_io_fd *iofd, size_t cmsg_size)
 Set the size of the control message buffer allocated when submitting recvmsg. More...
 
int osmo_iofd_register (struct osmo_io_fd *iofd, int fd)
 Register the osmo_io_fd for active I/O. More...
 
int osmo_iofd_unregister (struct osmo_io_fd *iofd)
 Unregister the given osmo_io_fd from osmo_io. More...
 
unsigned int osmo_iofd_txqueue_len (struct osmo_io_fd *iofd)
 Retrieve the number of messages pending in the transmit queue. More...
 
void osmo_iofd_txqueue_clear (struct osmo_io_fd *iofd)
 Clear the transmit queue of the given osmo_io_fd. More...
 
int osmo_iofd_close (struct osmo_io_fd *iofd)
 Close the given osmo_io_fd. More...
 
void osmo_iofd_free (struct osmo_io_fd *iofd)
 Free the given osmo_io_fd. More...
 
void osmo_iofd_notify_connected (struct osmo_io_fd *iofd)
 Request notification of the user if/when a client socket is connected. More...
 
int osmo_iofd_write_msgb (struct osmo_io_fd *iofd, struct msgb *msg)
 Write a message to a file descriptor / connected socket. More...
 
int osmo_iofd_sendto_msgb (struct osmo_io_fd *iofd, struct msgb *msg, int sendto_flags, const struct osmo_sockaddr *dest)
 Send a message through an unconnected socket. More...
 
int osmo_iofd_sendmsg_msgb (struct osmo_io_fd *iofd, struct msgb *msg, int sendmsg_flags, const struct msghdr *msgh)
 osmo_io equivalent of the sendmsg(2) socket API call. More...
 
void osmo_iofd_set_alloc_info (struct osmo_io_fd *iofd, unsigned int size, unsigned int headroom)
 Set the size and headroom of the msgb allocated when receiving messages. More...
 
void osmo_iofd_set_txqueue_max_length (struct osmo_io_fd *iofd, unsigned int max_length)
 Set the maximum number of messages enqueued for sending. More...
 
void * osmo_iofd_get_data (const struct osmo_io_fd *iofd)
 Retrieve the associated user-data from an osmo_io_fd. More...
 
void osmo_iofd_set_data (struct osmo_io_fd *iofd, void *data)
 Set the associated user-data from an osmo_io_fd. More...
 
unsigned int osmo_iofd_get_priv_nr (const struct osmo_io_fd *iofd)
 Retrieve the private number from an osmo_io_fd. More...
 
void osmo_iofd_set_priv_nr (struct osmo_io_fd *iofd, unsigned int priv_nr)
 Set the private number of an osmo_io_fd. More...
 
int osmo_iofd_get_fd (const struct osmo_io_fd *iofd)
 Retrieve the underlying file descriptor from an osmo_io_fd. More...
 
const char * osmo_iofd_get_name (const struct osmo_io_fd *iofd)
 Retrieve the human-readable name of the given osmo_io_fd. More...
 
void osmo_iofd_set_name (struct osmo_io_fd *iofd, const char *name)
 Set the human-readable name of the file descriptor. More...
 
int osmo_iofd_set_ioops (struct osmo_io_fd *iofd, const struct osmo_io_ops *ioops)
 Set the osmo_io_ops calbacks for an osmo_io_fd. More...
 
void osmo_iofd_get_ioops (struct osmo_io_fd *iofd, struct osmo_io_ops *ioops)
 Retrieve the osmo_io_ops for an iofd. More...
 

Variables

const struct value_string osmo_io_backend_names []
 
const struct value_string osmo_iofd_mode_names []
 

Detailed Description

io(_uring) abstraction osmo fd compatibility