Loading...
Searching...
No Matches
osmo_io.c File Reference
Osmocom I/O interface
`#include "../config.h"`
`#include <fcntl.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <talloc.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <stdbool.h>`
`#include <errno.h>`
`#include <inttypes.h>`
`#include <osmocom/core/osmo_io.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>`
`#include "osmo_io_internal.h"`

## Macros

#define | OSMO_IO_BACKEND_ENV "LIBOSMO_IO_BACKEND"
| This environment variable can be set to manually set the backend used in osmo_io.

## Functions

void | osmo_iofd_init (void)
| initialize osmo_io for the current thread
static | __attribute__ ((constructor(103)))
enum osmo_io_backend | osmo_io_get_backend (void)
| Obtain the osmo_io_backend in use by the process.
struct iofd_msghdr * | iofd_msghdr_alloc (struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg, size_t cmsg_size)
| Allocate the msghdr.
void | iofd_msghdr_free (struct iofd_msghdr *msghdr)
| Free the msghdr.
struct msgb * | iofd_msgb_alloc2 (struct osmo_io_fd *iofd, size_t size)
| convenience wrapper to call msgb_alloc with parameters from osmo_io_fd (of given size)
struct msgb * | iofd_msgb_alloc (struct osmo_io_fd *iofd)
| convenience wrapper to call msgb_alloc with parameters from osmo_io_fd
int | iofd_txqueue_enqueue (struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
| Enqueue a message to be sent.
void | iofd_txqueue_enqueue_front (struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
| Enqueue a message at the front.
struct iofd_msghdr * | iofd_txqueue_dequeue (struct osmo_io_fd *iofd)
| Dequeue a message from the front.
static enum iofd_seg_act | iofd_handle_segmentation (struct osmo_io_fd *iofd, struct msgb *msg, struct msgb **pending_out)
| Handle segmentation of the msg.
static void | _call_read_cb (struct osmo_io_fd *iofd, int rc, struct msgb *msg)
static uint16_t | iofd_msgb_length_max (const struct osmo_io_fd *iofd)
static struct msgb * | iofd_prepare_handle_segmentation (struct osmo_io_fd *iofd, struct msgb *in_msg)
static void | iofd_handle_segmented_read (struct osmo_io_fd *iofd, int rc, struct msgb *msg)
| Restore message boundaries on read() and pass individual messages to the read callback.
void | iofd_handle_recv (struct osmo_io_fd *iofd, struct msgb *msg, int rc, struct iofd_msghdr *hdr)
| completion handler: Internal function called by osmo_io_backend after a given I/O operation has completed
static void | iofd_send_completion_cb (struct osmo_io_fd *iofd, int rc, const struct iofd_msghdr *msghdr, struct msgb *msg)
void | iofd_handle_send_completion (struct osmo_io_fd *iofd, int rc, struct iofd_msghdr *msghdr)
| completion handler: Internal function called by osmo_io_backend after a given I/O operation has completed
int | osmo_iofd_write_msgb (struct osmo_io_fd *iofd, struct msgb *msg)
| Write a message to a file descriptor / connected socket.
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.
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.
static int | check_mode_callback_compat (enum osmo_io_fd_mode mode, const struct osmo_io_ops *ops)
struct osmo_io_fd * | osmo_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.
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.
int | osmo_iofd_set_io_buffers (struct osmo_io_fd *iofd, enum osmo_io_op op, uint8_t buffers)
| Set the number of buffers that can be used in a single read or write operation.
int | osmo_iofd_set_sqes (struct osmo_io_fd *iofd, enum osmo_io_op op, uint8_t sqes)
| Set the number of SQEs that are submitted to an io_unring before completion is received.
int | osmo_iofd_register (struct osmo_io_fd *iofd, int fd)
| Register the osmo_io_fd for active I/O.
int | osmo_iofd_unregister (struct osmo_io_fd *iofd)
| Unregister the given osmo_io_fd from osmo_io.
unsigned int | osmo_iofd_txqueue_len (struct osmo_io_fd *iofd)
| Retrieve the number of messages pending in the transmit queue.
void | osmo_iofd_txqueue_clear (struct osmo_io_fd *iofd)
| Clear the transmit queue of the given osmo_io_fd.
void | osmo_iofd_free (struct osmo_io_fd *iofd)
| Free the given osmo_io_fd.
int | osmo_iofd_close (struct osmo_io_fd *iofd)
| Close the given osmo_io_fd.
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.
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.
unsigned int | osmo_iofd_get_txqueue_max_length (const struct osmo_io_fd *iofd)
| Get the maximum number of messages enqueued for sending.
void * | osmo_iofd_get_data (const struct osmo_io_fd *iofd)
| Retrieve the associated user-data from an osmo_io_fd.
void | osmo_iofd_set_data (struct osmo_io_fd *iofd, void *data)
| Set the associated user-data from an osmo_io_fd.
unsigned int | osmo_iofd_get_priv_nr (const struct osmo_io_fd *iofd)
| Retrieve the private number from an osmo_io_fd.
void | osmo_iofd_set_priv_nr (struct osmo_io_fd *iofd, unsigned int priv_nr)
| Set the private number of an osmo_io_fd.
int | osmo_iofd_get_fd (const struct osmo_io_fd *iofd)
| Retrieve the underlying file descriptor from an osmo_io_fd.
const char * | osmo_iofd_get_name (const struct osmo_io_fd *iofd)
| Retrieve the human-readable name of the given osmo_io_fd.
void | osmo_iofd_set_name (struct osmo_io_fd *iofd, const char *name)
| Set the human-readable name of the file descriptor.
void | osmo_iofd_set_name_f (struct osmo_io_fd *iofd, const char *fmt,...)
| Set the human-readable name of the file descriptor using arguments like printf().
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.
void | osmo_iofd_get_ioops (struct osmo_io_fd *iofd, struct osmo_io_ops *ioops)
| Retrieve the osmo_io_ops for an iofd.
void | osmo_iofd_notify_connected (struct osmo_io_fd *iofd)
| Request notification of the user if/when a client socket is connected.

## Variables

const struct value_string | osmo_io_backend_names []
const struct value_string | osmo_iofd_mode_names []
static enum osmo_io_backend | g_io_backend
struct iofd_backend_ops | osmo_iofd_ops
static __thread bool | g_thread_initialized = false