\doxysection{osmo\+\_\+io.\+h}
\label{osmo__io_8h_source}\index{include/osmocom/core/osmo\_io.h@{include/osmocom/core/osmo\_io.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{5 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <sys/socket.h>}}
\DoxyCodeLine{8 }
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/core/logging.h>}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{12 \textcolor{preprocessor}{\#include <osmocom/core/socket.h>}}
\DoxyCodeLine{13 \textcolor{preprocessor}{\#include <osmocom/core/utils.h>}}
\DoxyCodeLine{14 }
\DoxyCodeLine{57 \textcolor{preprocessor}{\#define LOGPIO(iofd, level, fmt, args...) \(\backslash\)}}
\DoxyCodeLine{58 \textcolor{preprocessor}{        LOGP(DLIO, level, "{}iofd(\%s)"{}} fmt, iofd-\/>name, \#\# args)}
\DoxyCodeLine{59 }
\DoxyCodeLine{60 \textcolor{keyword}{struct }osmo\_io\_fd;}
\DoxyCodeLine{61 }
\DoxyCodeLine{64 \textcolor{keyword}{enum} osmo\_io\_fd\_mode \{}
\DoxyCodeLine{66         OSMO\_IO\_FD\_MODE\_READ\_WRITE,}
\DoxyCodeLine{68         OSMO\_IO\_FD\_MODE\_RECVFROM\_SENDTO,}
\DoxyCodeLine{70         OSMO\_IO\_FD\_MODE\_RECVMSG\_SENDMSG,}
\DoxyCodeLine{71 \};}
\DoxyCodeLine{72 }
\DoxyCodeLine{75 \textcolor{keyword}{enum} osmo\_io\_backend \{}
\DoxyCodeLine{77         OSMO\_IO\_BACKEND\_POLL,}
\DoxyCodeLine{79         OSMO\_IO\_BACKEND\_IO\_URING,}
\DoxyCodeLine{80 \};}
\DoxyCodeLine{81 }
\DoxyCodeLine{82 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string osmo\_io\_backend\_names[];}
\DoxyCodeLine{84 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_io\_backend\_name(\textcolor{keyword}{enum} osmo\_io\_backend val)}
\DoxyCodeLine{85 \{ \textcolor{keywordflow}{return} get\_value\_string(osmo\_io\_backend\_names, val); \}}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string osmo\_iofd\_mode\_names[];}
\DoxyCodeLine{89 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_iofd\_mode\_name(\textcolor{keyword}{enum} osmo\_io\_fd\_mode val)}
\DoxyCodeLine{90 \{ \textcolor{keywordflow}{return} get\_value\_string(osmo\_iofd\_mode\_names, val); \}}
\DoxyCodeLine{91 }
\DoxyCodeLine{93 \textcolor{keyword}{struct }osmo\_io\_ops \{}
\DoxyCodeLine{94         \textcolor{comment}{/* mode OSMO\_IO\_FD\_MODE\_READ\_WRITE: */}}
\DoxyCodeLine{95         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{102                 void (*read\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{103 }
\DoxyCodeLine{110                 void (*write\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res,}
\DoxyCodeLine{111                                  \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{112 }
\DoxyCodeLine{132                 int (*segmentation\_cb)(\textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{133 }
\DoxyCodeLine{147                 int (*segmentation\_cb2)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{148         \};}
\DoxyCodeLine{149 }
\DoxyCodeLine{150         \textcolor{comment}{/* mode OSMO\_IO\_FD\_MODE\_RECVFROM\_SENDTO: */}}
\DoxyCodeLine{151         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{159                 void (*recvfrom\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res,}
\DoxyCodeLine{160                                     \textcolor{keyword}{struct }msgb *msg,}
\DoxyCodeLine{161                                     \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_sockaddr *saddr);}
\DoxyCodeLine{169                 void (*sendto\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res,}
\DoxyCodeLine{170                                   \textcolor{keyword}{struct }msgb *msg,}
\DoxyCodeLine{171                                   \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_sockaddr *daddr);}
\DoxyCodeLine{172         \};}
\DoxyCodeLine{173 }
\DoxyCodeLine{174         \textcolor{comment}{/* mode OSMO\_IO\_FD\_MODE\_RECVMSG\_SENDMSG: */}}
\DoxyCodeLine{175         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{184                 void (*recvmsg\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res,}
\DoxyCodeLine{185                                    \textcolor{keyword}{struct }msgb *msg, \textcolor{keyword}{const} \textcolor{keyword}{struct }msghdr *msgh);}
\DoxyCodeLine{192                 void (*sendmsg\_cb)(\textcolor{keyword}{struct }osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} res, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{193         \};}
\DoxyCodeLine{194 \};}
\DoxyCodeLine{195 }
\DoxyCodeLine{196 \textcolor{keywordtype}{void} osmo\_iofd\_init(\textcolor{keywordtype}{void});}
\DoxyCodeLine{197 }
\DoxyCodeLine{198 \textcolor{keyword}{struct }osmo\_io\_fd *osmo\_iofd\_setup(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keywordtype}{int} fd, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name,}
\DoxyCodeLine{199                   \textcolor{keyword}{enum} osmo\_io\_fd\_mode mode, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_ops *ioops, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{200 \textcolor{keywordtype}{int} osmo\_iofd\_set\_cmsg\_size(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{size\_t} cmsg\_size);}
\DoxyCodeLine{201 \textcolor{keywordtype}{int} osmo\_iofd\_register(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{int} fd);}
\DoxyCodeLine{202 \textcolor{keywordtype}{int} osmo\_iofd\_unregister(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{203 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} osmo\_iofd\_txqueue\_len(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{204 \textcolor{keywordtype}{void} osmo\_iofd\_txqueue\_clear(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{205 \textcolor{keywordtype}{int} osmo\_iofd\_close(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{206 \textcolor{keywordtype}{void} osmo\_iofd\_free(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{207 }
\DoxyCodeLine{208 \textcolor{keywordtype}{void} osmo\_iofd\_notify\_connected(\textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{209 }
\DoxyCodeLine{210 \textcolor{keywordtype}{int} osmo\_iofd\_write\_msgb(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{211 \textcolor{keywordtype}{int} osmo\_iofd\_sendto\_msgb(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{struct} msgb *msg, \textcolor{keywordtype}{int} sendto\_flags,}
\DoxyCodeLine{212                           \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_sockaddr *dest);}
\DoxyCodeLine{213 \textcolor{keywordtype}{int} osmo\_iofd\_sendmsg\_msgb(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{struct} msgb *msg, \textcolor{keywordtype}{int} sendmsg\_flags,}
\DoxyCodeLine{214                            \textcolor{keyword}{const} \textcolor{keyword}{struct} msghdr *msgh);}
\DoxyCodeLine{215 }
\DoxyCodeLine{216 \textcolor{keywordtype}{void} osmo\_iofd\_set\_alloc\_info(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} size, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} headroom);}
\DoxyCodeLine{217 \textcolor{keywordtype}{void} osmo\_iofd\_set\_txqueue\_max\_length(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} size);}
\DoxyCodeLine{218 \textcolor{keywordtype}{void} *osmo\_iofd\_get\_data(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{219 \textcolor{keywordtype}{void} osmo\_iofd\_set\_data(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{220 }
\DoxyCodeLine{221 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} osmo\_iofd\_get\_priv\_nr(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{222 \textcolor{keywordtype}{void} osmo\_iofd\_set\_priv\_nr(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} priv\_nr);}
\DoxyCodeLine{223 }
\DoxyCodeLine{224 \textcolor{keywordtype}{int} osmo\_iofd\_get\_fd(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{225 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_iofd\_get\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_fd *iofd);}
\DoxyCodeLine{226 \textcolor{keywordtype}{void} osmo\_iofd\_set\_name(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{227 }
\DoxyCodeLine{228 \textcolor{keywordtype}{int} osmo\_iofd\_set\_ioops(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_io\_ops *ioops);}
\DoxyCodeLine{229 \textcolor{keywordtype}{void} osmo\_iofd\_get\_ioops(\textcolor{keyword}{struct} osmo\_io\_fd *iofd, \textcolor{keyword}{struct} osmo\_io\_ops *ioops);}
\DoxyCodeLine{230 }

\end{DoxyCode}
