\doxysection{include/osmocom/core/osmo\+\_\+io.h File Reference}
\label{osmo__io_8h}\index{include/osmocom/core/osmo\_io.h@{include/osmocom/core/osmo\_io.h}}


io(\+\_\+uring) abstraction osmo fd compatibility  


{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+io\+\_\+ops}
\begin{DoxyCompactList}\small\item\em I/O operations (call-\/back functions) related to an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ LOGPIO}(iofd,  \textbf{ level},  fmt,  args...)~ \textbf{ LOGP}(\textbf{ DLIO}, \textbf{ level}, \char`\"{}iofd(\%s) \char`\"{} fmt, iofd-\/$>$\textbf{ name}, \#\# args)
\begin{DoxyCompactList}\small\item\em log macro used for logging information related to the \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ osmo\+\_\+io\+\_\+fd\+\_\+mode} \{ \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+READ\+\_\+\+WRITE}
, \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVFROM\+\_\+\+SENDTO}
, \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVMSG\+\_\+\+SENDMSG}
 \}
\begin{DoxyCompactList}\small\item\em The {\itshape mode} of an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} determines if read/write, recvfrom/sendmsg or recvmsg/sendmsg semantics are used. \end{DoxyCompactList}\item 
enum \textbf{ osmo\+\_\+io\+\_\+op} \{ \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+OP\+\_\+\+READ}
, \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+OP\+\_\+\+WRITE}
 \}
\begin{DoxyCompactList}\small\item\em The {\itshape operation} of an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} determines if read or write operation are to be configured used. \end{DoxyCompactList}\item 
enum \textbf{ osmo\+\_\+io\+\_\+backend} \{ \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+BACKEND\+\_\+\+POLL}
, \newline
\textbf{ OSMO\+\_\+\+IO\+\_\+\+BACKEND\+\_\+\+IO\+\_\+\+URING}
 \}
\begin{DoxyCompactList}\small\item\em The back-\/end used by osmo\+\_\+io. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ osmo\+\_\+io\+\_\+backend} \textbf{ osmo\+\_\+io\+\_\+get\+\_\+backend} (void)
\begin{DoxyCompactList}\small\item\em Obtain the osmo\+\_\+io\+\_\+backend in use by the process. \end{DoxyCompactList}\item 
static const char $\ast$ \textbf{ osmo\+\_\+io\+\_\+backend\+\_\+name} (enum \textbf{ osmo\+\_\+io\+\_\+backend} val)
\begin{DoxyCompactList}\small\item\em return the string name of an osmo\+\_\+io\+\_\+backend \end{DoxyCompactList}\item 
static const char $\ast$ \textbf{ osmo\+\_\+iofd\+\_\+mode\+\_\+name} (enum \textbf{ osmo\+\_\+io\+\_\+fd\+\_\+mode} val)
\begin{DoxyCompactList}\small\item\em return the string name of an osmo\+\_\+io\+\_\+mode \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+init} (void)
\begin{DoxyCompactList}\small\item\em initialize osmo\+\_\+io for the current thread \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$ \textbf{ osmo\+\_\+iofd\+\_\+setup} (const void $\ast$ctx, int fd, const char $\ast$\textbf{ name}, enum \textbf{ osmo\+\_\+io\+\_\+fd\+\_\+mode} \textbf{ mode}, const struct \textbf{ osmo\+\_\+io\+\_\+ops} $\ast$ioops, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Allocate and setup a new iofd. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+cmsg\+\_\+size} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, size\+\_\+t cmsg\+\_\+size)
\begin{DoxyCompactList}\small\item\em Set the size of the control message buffer allocated when submitting recvmsg. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+io\+\_\+buffers} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, enum \textbf{ osmo\+\_\+io\+\_\+op} op, uint8\+\_\+t buffers)
\begin{DoxyCompactList}\small\item\em Set the number of buffers that can be used in a single read or write operation. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+sqes} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, enum \textbf{ osmo\+\_\+io\+\_\+op} op, uint8\+\_\+t sqes)
\begin{DoxyCompactList}\small\item\em Set the number of SQEs that are submitted to an io\+\_\+unring before completion is received. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+register} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int fd)
\begin{DoxyCompactList}\small\item\em Register the \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} for active I/O. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+unregister} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Unregister the given \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} from osmo\+\_\+io. \end{DoxyCompactList}\item 
unsigned int \textbf{ osmo\+\_\+iofd\+\_\+txqueue\+\_\+len} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Retrieve the number of messages pending in the transmit queue. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+txqueue\+\_\+clear} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Clear the transmit queue of the given \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+close} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Close the given \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+free} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Free the given \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+notify\+\_\+connected} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Request notification of the user if/when a client socket is connected. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+write\+\_\+msgb} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, struct \textbf{ msgb} $\ast$\textbf{ msg})
\begin{DoxyCompactList}\small\item\em Write a message to a file descriptor / connected socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+sendto\+\_\+msgb} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, struct \textbf{ msgb} $\ast$\textbf{ msg}, int sendto\+\_\+flags, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$dest)
\begin{DoxyCompactList}\small\item\em Send a message through an unconnected socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+sendmsg\+\_\+msgb} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, struct \textbf{ msgb} $\ast$\textbf{ msg}, int sendmsg\+\_\+flags, const struct msghdr $\ast$msgh)
\begin{DoxyCompactList}\small\item\em osmo\+\_\+io equivalent of the sendmsg(2) socket API call. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+alloc\+\_\+info} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, unsigned int size, unsigned int headroom)
\begin{DoxyCompactList}\small\item\em Set the size and headroom of the msgb allocated when receiving messages. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+txqueue\+\_\+max\+\_\+length} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, unsigned int max\+\_\+length)
\begin{DoxyCompactList}\small\item\em Set the maximum number of messages enqueued for sending. \end{DoxyCompactList}\item 
unsigned int \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+txqueue\+\_\+max\+\_\+length} (const struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Get the maximum number of messages enqueued for sending. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+data} (const struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Retrieve the associated user-\/data from an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+data} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Set the associated user-\/data from an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
unsigned int \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+priv\+\_\+nr} (const struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Retrieve the private number from an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+priv\+\_\+nr} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, unsigned int priv\+\_\+nr)
\begin{DoxyCompactList}\small\item\em Set the private number of an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+fd} (const struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Retrieve the underlying file descriptor from an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+name} (const struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\begin{DoxyCompactList}\small\item\em Retrieve the human-\/readable name of the given \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+name} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Set the human-\/readable name of the file descriptor. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+name\+\_\+f} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, const char $\ast$fmt,...)
\begin{DoxyCompactList}\small\item\em Set the human-\/readable name of the file descriptor using arguments like printf() \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+ioops} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, const struct \textbf{ osmo\+\_\+io\+\_\+ops} $\ast$ioops)
\begin{DoxyCompactList}\small\item\em Set the \doxyref{osmo\+\_\+io\+\_\+ops}{p.}{structosmo__io__ops} calbacks for an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+iofd\+\_\+get\+\_\+ioops} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, struct \textbf{ osmo\+\_\+io\+\_\+ops} $\ast$ioops)
\begin{DoxyCompactList}\small\item\em Retrieve the \doxyref{osmo\+\_\+io\+\_\+ops}{p.}{structosmo__io__ops} for an iofd. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+io\+\_\+backend\+\_\+names} [$\,$]
\item 
const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+iofd\+\_\+mode\+\_\+names} [$\,$]
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
io(\+\_\+uring) abstraction osmo fd compatibility 

