\doxysection{osmo\+\_\+io\+\_\+ops Struct Reference}
\label{structosmo__io__ops}\index{osmo\_io\_ops@{osmo\_io\_ops}}


I/O operations (call-\/back functions) related to an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}.  




{\ttfamily \#include $<$osmo\+\_\+io.\+h$>$}

\doxysubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
\begin{tabbing}
xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=\kill
struct \{\\
\>void($\ast$ \textbf{ read\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})\\
\>\>{\em completion call-\/back function when something was read from fd. }\\
\>void($\ast$ \textbf{ write\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})\\
\>\>{\em completion call-\/back function when write issued via \doxyref{osmo\_iofd\_write\_msgb()}{p.}{group__osmo__io_ga0c3ca8f15e1c3382902c226e001e98ad} has completed on fd. }\\
\>int($\ast$ \textbf{ segmentation\_cb} )(struct \textbf{ msgb} $\ast$\textbf{ msg})\\
\>\>{\em optional call-\/back function to segment the data at message boundaries. }\\
\>int($\ast$ \textbf{ segmentation\_cb2} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd,\\
\>\> struct \textbf{ msgb} $\ast$\textbf{ msg})\\
\>\>{\em optional call-\/back function to segment the data at message boundaries. }\\
\}; \\

\end{tabbing}\item 
\begin{tabbing}
xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=\kill
struct \{\\
\>void($\ast$ \textbf{ recvfrom\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const \\
\>\>struct \textbf{ osmo\_sockaddr} $\ast$saddr)\\
\>\>{\em completion call-\/back function when recvfrom(2) has completed. }\\
\>void($\ast$ \textbf{ sendto\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const \\
\>\>struct \textbf{ osmo\_sockaddr} $\ast$daddr)\\
\>\>{\em completion call-\/back function when sendto() issued via \doxyref{osmo\_iofd\_sendto\_msgb()}{p.}{group__osmo__io_gaefb2721bf4d1f6fb443214d989a90e8c} has completed on fd. }\\
\}; \\

\end{tabbing}\item 
\begin{tabbing}
xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=xx\=\kill
struct \{\\
\>void($\ast$ \textbf{ recvmsg\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const \\
\>\>struct msghdr $\ast$msgh)\\
\>\>{\em completion call-\/back function when recvmsg(2) has completed. }\\
\>void($\ast$ \textbf{ sendmsg\_cb} )(struct \textbf{ osmo\_io\_fd} $\ast$iofd, int \\
\>\>\textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})\\
\>\>{\em completion call-\/back function when sendmsg() issued via \doxyref{osmo\_iofd\_sendmsg\_msgb()}{p.}{group__osmo__io_gabab40e7a5478bf4195dd8b79752bc1b2} has completed on fd. }\\
\}; \\

\end{tabbing}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
I/O operations (call-\/back functions) related to an \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd}. 

\doxysubsection{Field Documentation}
\mbox{\label{structosmo__io__ops_a89cd4db689b7a714f878c5fbea82bbb1}} 
\doxysubsubsection{}
{\footnotesize\ttfamily struct  \{ ... \}  osmo\+\_\+io\+\_\+ops\+::@19}

\mbox{\label{structosmo__io__ops_a01da468df39be18126d2ca6ad95fd569}} 
\doxysubsubsection{}
{\footnotesize\ttfamily struct  \{ ... \}  osmo\+\_\+io\+\_\+ops\+::@21}

\mbox{\label{structosmo__io__ops_a369838283412db01d84b3e044ec8935d}} 
\doxysubsubsection{}
{\footnotesize\ttfamily struct  \{ ... \}  osmo\+\_\+io\+\_\+ops\+::@23}

\mbox{\label{structosmo__io__ops_a0d6ea2f2d5398d1c81f4195be3f1ee13}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!read\_cb@{read\_cb}}
\index{read\_cb@{read\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{read\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::read\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})}



completion call-\/back function when something was read from fd. 

Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+READ\+\_\+\+WRITE. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} for which read() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the read() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing the read data. Ownership is transferred to the call-\/back, and it must make sure to \doxyref{msgb\+\_\+free()}{p.}{group__msgb_gae48b55f6f4529aafb069eaa3fa1998f0} it eventually! \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+segmented\+\_\+read()}, \textbf{ osmo\+\_\+iofd\+\_\+register()}, and \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+ioops()}.

\mbox{\label{structosmo__io__ops_a164b855a40443b2b47463be771e58552}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!recvfrom\_cb@{recvfrom\_cb}}
\index{recvfrom\_cb@{recvfrom\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{recvfrom\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::recvfrom\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$saddr)}



completion call-\/back function when recvfrom(2) has completed. 

Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVFROM\+\_\+\+SENDTO. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} for which recvfrom() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the recvfrom() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing the read data. Ownership is transferred to the call-\/back, and it must make sure to \doxyref{msgb\+\_\+free()}{p.}{group__msgb_gae48b55f6f4529aafb069eaa3fa1998f0} it eventually! \\
\hline
\mbox{\texttt{ in}}  & {\em saddr} & socket-\/address of sender from which data was received. \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+recv()}, \textbf{ osmo\+\_\+iofd\+\_\+register()}, and \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+ioops()}.

\mbox{\label{structosmo__io__ops_aa66525cc7afa89a1112b0b79ea690c45}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!recvmsg\_cb@{recvmsg\_cb}}
\index{recvmsg\_cb@{recvmsg\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{recvmsg\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::recvmsg\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const struct msghdr $\ast$msgh)}



completion call-\/back function when recvmsg(2) has completed. 

Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVMSG\+\_\+\+SENDMSG. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & \doxyref{osmo\+\_\+io\+\_\+fd}{p.}{structosmo__io__fd} for which recvmsg() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the recvmsg() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing the read data. Ownership is transferred to the call-\/back, and it must make sure to \doxyref{msgb\+\_\+free()}{p.}{group__msgb_gae48b55f6f4529aafb069eaa3fa1998f0} it eventually! \\
\hline
\mbox{\texttt{ in}}  & {\em msgh} & msghdr containing metadata related to the recvmsg call. Only valid until call-\/back ends. \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+recv()}, \textbf{ osmo\+\_\+iofd\+\_\+register()}, and \textbf{ osmo\+\_\+iofd\+\_\+set\+\_\+ioops()}.

\mbox{\label{structosmo__io__ops_afbe74fab87f1f05e6fe55704b85e8dd9}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!segmentation\_cb@{segmentation\_cb}}
\index{segmentation\_cb@{segmentation\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{segmentation\_cb}
{\footnotesize\ttfamily int($\ast$ osmo\+\_\+io\+\_\+ops\+::segmentation\+\_\+cb) (struct \textbf{ msgb} $\ast$\textbf{ msg})}



optional call-\/back function to segment the data at message boundaries. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em msg} & message buffer whose data is to be segmented \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
See full function description.
\end{DoxyReturn}
This is useful when message boundaries are to be preserved over a SOCK\+\_\+\+STREAM transport socket like TCP. Can be NULL for any application not requiring de-\/segmentation of received data.

The call-\/back needs to return the size of the next message. If it returns -\/EAGAIN or a value larger than \doxyref{msgb\+\_\+length()}{p.}{group__msgb_ga036077cd924b90a798cb3b6c5541a492} (message is incomplete) osmo\+\_\+io will wait for more data to be read. Other negative values cause the msg to be discarded. If a full message was received (\doxyref{segmentation\+\_\+cb()}{p.}{structosmo__io__ops_afbe74fab87f1f05e6fe55704b85e8dd9} returns a value $<$= \doxyref{msgb\+\_\+length()}{p.}{group__msgb_ga036077cd924b90a798cb3b6c5541a492}) the msgb will be trimmed to size by osmo\+\_\+io and forwarded to the read call-\/back. Any parsing done to the msgb by \doxyref{segmentation\+\_\+cb()}{p.}{structosmo__io__ops_afbe74fab87f1f05e6fe55704b85e8dd9} will be preserved for the \doxyref{read\+\_\+cb()}{p.}{structosmo__io__ops_a0d6ea2f2d5398d1c81f4195be3f1ee13} (e.\+g. setting lxh or msgb-\/$>$cb).

Only one (or none) of both segmentation\+\_\+cb and segmentation\+\_\+cb2 shall be set. Having both set will be considered an error during iofd setup. 

Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, and \textbf{ iofd\+\_\+handle\+\_\+segmentation()}.

\mbox{\label{structosmo__io__ops_a31950886c96ed6f258661c2ffa03c5f4}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!segmentation\_cb2@{segmentation\_cb2}}
\index{segmentation\_cb2@{segmentation\_cb2}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{segmentation\_cb2}
{\footnotesize\ttfamily int($\ast$ osmo\+\_\+io\+\_\+ops\+::segmentation\+\_\+cb2) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, struct \textbf{ msgb} $\ast$\textbf{ msg})}



optional call-\/back function to segment the data at message boundaries. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & handling msg \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer whose data is to be segmented \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
See full function description.
\end{DoxyReturn}
Same as segmentation\+\_\+cb above, with an extra parameter to have access to the iofd and its related functionalities (eg data pointer). This is useful for users requiring to store global state or access external objects while segmenting.

The provided iofd shall not be freed by the user during the callback.

Only one (or none) of both segmentation\+\_\+cb and segmentation\+\_\+cb2 shall be set. Having both set will be considered an error during iofd setup. 

Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, and \textbf{ iofd\+\_\+handle\+\_\+segmentation()}.

\mbox{\label{structosmo__io__ops_a7b05599800d9117cfbaabed5674e42c6}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!sendmsg\_cb@{sendmsg\_cb}}
\index{sendmsg\_cb@{sendmsg\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{sendmsg\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::sendmsg\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})}



completion call-\/back function when sendmsg() issued via \doxyref{osmo\+\_\+iofd\+\_\+sendmsg\+\_\+msgb()}{p.}{group__osmo__io_gabab40e7a5478bf4195dd8b79752bc1b2} has completed on fd. 

Only valid in Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVMSG\+\_\+\+SENDMSG. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & on which a sendmsg() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the sendmsg() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer whose write has completed. Ownership is {\itshape not} transferred to the call-\/back; it is automatically freed after the call-\/back terminates! \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+send\+\_\+completion()}, and \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg()}.

\mbox{\label{structosmo__io__ops_a76d3bb8b0f08a19a08c91e8a8949329f}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!sendto\_cb@{sendto\_cb}}
\index{sendto\_cb@{sendto\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{sendto\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::sendto\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg}, const struct \textbf{ osmo\+\_\+sockaddr} $\ast$daddr)}



completion call-\/back function when sendto() issued via \doxyref{osmo\+\_\+iofd\+\_\+sendto\+\_\+msgb()}{p.}{group__osmo__io_gaefb2721bf4d1f6fb443214d989a90e8c} has completed on fd. 

Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+RECVFROM\+\_\+\+SENDTO. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & on which a sendto() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the sendto() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer whose write has completed. Ownership is {\itshape not} transferred to the call-\/back; it is automatically freed after the call-\/back terminates! \\
\hline
\mbox{\texttt{ in}}  & {\em daddr} & socket-\/address of destination to which data was sent. \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+send\+\_\+completion()}, and \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg()}.

\mbox{\label{structosmo__io__ops_a667c25d83ee279b51562cd1b80794c10}} 
\index{osmo\_io\_ops@{osmo\_io\_ops}!write\_cb@{write\_cb}}
\index{write\_cb@{write\_cb}!osmo\_io\_ops@{osmo\_io\_ops}}
\doxysubsubsection{write\_cb}
{\footnotesize\ttfamily void($\ast$ osmo\+\_\+io\+\_\+ops\+::write\+\_\+cb) (struct \textbf{ osmo\+\_\+io\+\_\+fd} $\ast$iofd, int \textbf{ res}, struct \textbf{ msgb} $\ast$\textbf{ msg})}



completion call-\/back function when write issued via \doxyref{osmo\+\_\+iofd\+\_\+write\+\_\+msgb()}{p.}{group__osmo__io_ga0c3ca8f15e1c3382902c226e001e98ad} has completed on fd. 

Only valid in OSMO\+\_\+\+IO\+\_\+\+FD\+\_\+\+MODE\+\_\+\+READ\+\_\+\+WRITE. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em iofd} & on which a write() has completed. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the write() call, or -\/errno in case of error. \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer whose write has completed. Ownership is {\itshape not} transferred to the call-\/back; it is automatically freed after the call-\/back terminates! \\
\hline
\end{DoxyParams}


Referenced by \textbf{ check\+\_\+mode\+\_\+callback\+\_\+compat()}, \textbf{ iofd\+\_\+handle\+\_\+send\+\_\+completion()}, and \textbf{ iofd\+\_\+poll\+\_\+ofd\+\_\+cb\+\_\+recvmsg\+\_\+sendmsg()}.



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
include/osmocom/core/\textbf{ osmo\+\_\+io.\+h}\end{DoxyCompactItemize}
