\doxysection{src/core/osmo\+\_\+io\+\_\+poll.c File Reference}
\label{osmo__io__poll_8c}\index{src/core/osmo\_io\_poll.c@{src/core/osmo\_io\_poll.c}}


New osmocom async I/O API.  


{\ttfamily \#include \char`\"{}../config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$talloc.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$sys/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/osmo\+\_\+io.\+h$>$}\newline
{\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/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include \char`\"{}osmo\+\_\+io\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg} (struct \textbf{ osmo\+\_\+fd} $\ast$ofd, unsigned int what)
\item 
static int \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+dispatch} (struct \textbf{ osmo\+\_\+fd} $\ast$ofd, unsigned int what)
\item 
static int \textbf{ iofd\+\_\+poll\+\_\+register} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static int \textbf{ iofd\+\_\+poll\+\_\+unregister} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static int \textbf{ iofd\+\_\+poll\+\_\+close} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+read\+\_\+enable} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+read\+\_\+disable} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+write\+\_\+enable} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+write\+\_\+disable} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\item 
static void \textbf{ iofd\+\_\+poll\+\_\+notify\+\_\+connected} (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ iofd\+\_\+backend\+\_\+ops} \textbf{ iofd\+\_\+poll\+\_\+ops}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
New osmocom async I/O API. 

(C) 2022 by Harald Welte {\texttt{ laforge@osmocom.\+org}} (C) 2022-\/2023 by sysmocom -\/ s.\+f.\+m.\+c. GmbH {\texttt{ info@sysmocom.\+de}} Author\+: Daniel Willmann {\texttt{ dwillmann@sysmocom.\+de}}

All Rights Reserved.

SPDX-\/\+License-\/\+Identifier\+: GPL-\/2.\+0+

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 

\doxysubsection{Function Documentation}
\mbox{\label{osmo__io__poll_8c_afca6e9cddc056b2cb72e7fe760c4511d}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_close@{iofd\_poll\_close}}
\index{iofd\_poll\_close@{iofd\_poll\_close}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_close()}
{\footnotesize\ttfamily static int iofd\+\_\+poll\+\_\+close (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ iofd\+\_\+poll\+\_\+unregister()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+close()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.

\mbox{\label{osmo__io__poll_8c_ac1be62e48b7eb9ce32ce7372735738c1}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_notify\_connected@{iofd\_poll\_notify\_connected}}
\index{iofd\_poll\_notify\_connected@{iofd\_poll\_notify\_connected}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_notify\_connected()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+notify\+\_\+connected (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ iofd\+\_\+poll\+\_\+register()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+write\+\_\+enable()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.

\mbox{\label{osmo__io__poll_8c_a0fa3663095ac7bd93b8ccf2c32823dfb}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_ofd\_cb\_dispatch@{iofd\_poll\_ofd\_cb\_dispatch}}
\index{iofd\_poll\_ofd\_cb\_dispatch@{iofd\_poll\_ofd\_cb\_dispatch}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_ofd\_cb\_dispatch()}
{\footnotesize\ttfamily static int iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+dispatch (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{ofd,  }\item[{unsigned int}]{what }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+IN\+\_\+\+CALLBACK}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+ISSET}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+SET}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+TO\+\_\+\+FREE}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+UNSET}, \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg()}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}.



Referenced by \textbf{ iofd\+\_\+poll\+\_\+register()}.

\mbox{\label{osmo__io__poll_8c_ab08e6361d882258babb942848af0b1fe}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_ofd\_cb\_recvmsg\_sendmsg@{iofd\_poll\_ofd\_cb\_recvmsg\_sendmsg}}
\index{iofd\_poll\_ofd\_cb\_recvmsg\_sendmsg@{iofd\_poll\_ofd\_cb\_recvmsg\_sendmsg}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_ofd\_cb\_recvmsg\_sendmsg()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{ofd,  }\item[{unsigned int}]{what }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::cmsg\+\_\+size}, \textbf{ osmo\+\_\+fd\+::data}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ flags}, \textbf{ iofd\+\_\+msghdr\+::flags}, \textbf{ hdr}, \textbf{ iofd\+\_\+msghdr\+::hdr}, \textbf{ osmo\+\_\+io\+\_\+fd\+::io\+\_\+ops}, \textbf{ iofd\+\_\+msghdr\+::iofd}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+CLOSED}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+ISSET}, \textbf{ iofd\+\_\+handle\+\_\+recv()}, \textbf{ iofd\+\_\+handle\+\_\+send\+\_\+completion()}, \textbf{ iofd\+\_\+msgb\+\_\+pending\+\_\+or\+\_\+alloc()}, \textbf{ iofd\+\_\+poll\+\_\+ops}, \textbf{ iofd\+\_\+txqueue\+\_\+dequeue()}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGPIO}, \textbf{ osmo\+\_\+io\+\_\+fd\+::mode}, \textbf{ msg}, \textbf{ iofd\+\_\+msghdr\+::msg}, \textbf{ msgb\+\_\+put()}, \textbf{ msgb\+\_\+tailroom()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+WRITE}, \textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+READ\+\_\+\+WRITE}, \textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVFROM\+\_\+\+SENDTO}, \textbf{ OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVMSG\+\_\+\+SENDMSG}, \textbf{ osmo\+\_\+iofd\+\_\+txqueue\+\_\+len()}, \textbf{ osmo\+\_\+io\+\_\+ops\+::sendmsg\+\_\+cb}, \textbf{ osmo\+\_\+io\+\_\+ops\+::sendto\+\_\+cb}, \textbf{ msgb\+::tail}, \textbf{ osmo\+\_\+io\+\_\+ops\+::write\+\_\+cb}, and \textbf{ iofd\+\_\+backend\+\_\+ops\+::write\+\_\+disable}.



Referenced by \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+dispatch()}.

\mbox{\label{osmo__io__poll_8c_aeae744d164f2c8be6da3aecfb351590a}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_read\_disable@{iofd\_poll\_read\_disable}}
\index{iofd\_poll\_read\_disable@{iofd\_poll\_read\_disable}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_read\_disable()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+read\+\_\+disable (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+read\+\_\+disable()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.

\mbox{\label{osmo__io__poll_8c_a0ab2537cb9d8dba1f00070d77fd0dbc9}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_read\_enable@{iofd\_poll\_read\_enable}}
\index{iofd\_poll\_read\_enable@{iofd\_poll\_read\_enable}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_read\_enable()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+read\+\_\+enable (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+read\+\_\+enable()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.

\mbox{\label{osmo__io__poll_8c_ad83795bf7dbb8d33f677eb356b9ebb43}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_register@{iofd\_poll\_register}}
\index{iofd\_poll\_register@{iofd\_poll\_register}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_register()}
{\footnotesize\ttfamily static int iofd\+\_\+poll\+\_\+register (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::fd}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+FD\+\_\+\+REGISTERED}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+ISSET}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+SET}, \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+dispatch()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+register()}, \textbf{ osmo\+\_\+fd\+\_\+setup()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.



Referenced by \textbf{ iofd\+\_\+poll\+\_\+notify\+\_\+connected()}.

\mbox{\label{osmo__io__poll_8c_a0800cd7655396d0d680ec91e5f313ce9}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_unregister@{iofd\_poll\_unregister}}
\index{iofd\_poll\_unregister@{iofd\_poll\_unregister}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_unregister()}
{\footnotesize\ttfamily static int iofd\+\_\+poll\+\_\+unregister (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+FD\+\_\+\+REGISTERED}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+ISSET}, \textbf{ IOFD\+\_\+\+FLAG\+\_\+\+UNSET}, \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+unregister()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.



Referenced by \textbf{ iofd\+\_\+poll\+\_\+close()}.

\mbox{\label{osmo__io__poll_8c_a26c5852d1ca8c6b37f5f2893e6d9402d}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_write\_disable@{iofd\_poll\_write\_disable}}
\index{iofd\_poll\_write\_disable@{iofd\_poll\_write\_disable}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_write\_disable()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+write\+\_\+disable (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+write\+\_\+disable()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.

\mbox{\label{osmo__io__poll_8c_a9ef6093c9f4ba2e12d4a6fadc19a6f16}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_write\_enable@{iofd\_poll\_write\_enable}}
\index{iofd\_poll\_write\_enable@{iofd\_poll\_write\_enable}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_write\_enable()}
{\footnotesize\ttfamily static void iofd\+\_\+poll\+\_\+write\+\_\+enable (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$}]{iofd }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+io\+\_\+fd\+::ofd}, \textbf{ osmo\+\_\+fd\+\_\+write\+\_\+enable()}, \textbf{ osmo\+\_\+io\+\_\+fd\+::poll}, and \textbf{ osmo\+\_\+io\+\_\+fd\+::u}.



\doxysubsection{Variable Documentation}
\mbox{\label{osmo__io__poll_8c_a9a3acf8b445e5edaa11e143fdecd3ad3}} 
\index{osmo\_io\_poll.c@{osmo\_io\_poll.c}!iofd\_poll\_ops@{iofd\_poll\_ops}}
\index{iofd\_poll\_ops@{iofd\_poll\_ops}!osmo\_io\_poll.c@{osmo\_io\_poll.c}}
\doxysubsubsection{iofd\_poll\_ops}
{\footnotesize\ttfamily const struct \textbf{ iofd\+\_\+backend\+\_\+ops} iofd\+\_\+poll\+\_\+ops}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        .register\_fd = iofd\_poll\_register,}
\DoxyCodeLine{        .unregister\_fd = iofd\_poll\_unregister,}
\DoxyCodeLine{        .close = iofd\_poll\_close,}
\DoxyCodeLine{        .write\_enable = iofd\_poll\_write\_enable,}
\DoxyCodeLine{        .write\_disable = iofd\_poll\_write\_disable,}
\DoxyCodeLine{        .read\_enable = iofd\_poll\_read\_enable,}
\DoxyCodeLine{        .read\_disable = iofd\_poll\_read\_disable,}
\DoxyCodeLine{        .notify\_connected = iofd\_poll\_notify\_connected,}
\DoxyCodeLine{\}}

\end{DoxyCode}


Referenced by \textbf{ \+\_\+\+\_\+attribute\+\_\+\+\_\+()}, and \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg()}.

