\section{src/stream.c File Reference}
\label{stream_8c}\index{src/stream.\+c@{src/stream.\+c}}


Osmocom stream socket helpers.  


{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$time.\+h$>$}\newline
{\ttfamily \#include $<$sys/fcntl.\+h$>$}\newline
{\ttfamily \#include $<$sys/socket.\+h$>$}\newline
{\ttfamily \#include $<$sys/ioctl.\+h$>$}\newline
{\ttfamily \#include $<$arpa/inet.\+h$>$}\newline
{\ttfamily \#include $<$netinet/in.\+h$>$}\newline
{\ttfamily \#include $<$netinet/tcp.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/timer.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/tlv.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/socket.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/netif/stream.\+h$>$}\newline
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$netinet/sctp.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/netif/sctp.\+h$>$}\newline
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+cli}
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link}
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+srv}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{stream_8c_a93406b98c0c2fa90d3d12b13d5bd63ac}} 
\#define {\bfseries L\+O\+G\+S\+C\+LI}(cli,  level,  fmt,  args...)~L\+O\+GP(D\+L\+I\+NP, level, \char`\"{}[\%s] \%s()\+: \char`\"{} fmt, get\+\_\+value\+\_\+string(stream\+\_\+cli\+\_\+state\+\_\+names, (cli)-\/$>$state), \+\_\+\+\_\+func\+\_\+\+\_\+, \#\# args)
\item 
\#define {\bfseries M\+S\+G\+\_\+\+N\+O\+S\+I\+G\+N\+AL}~0
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+F\+\_\+\+R\+E\+C\+O\+NF}~(1 $<$$<$ 0)
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+F\+\_\+\+N\+O\+D\+E\+L\+AY}~(1 $<$$<$ 1)
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+M\+A\+X\+\_\+\+A\+D\+D\+RS}~O\+S\+M\+O\+\_\+\+S\+O\+C\+K\+\_\+\+M\+A\+X\+\_\+\+A\+D\+D\+RS
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+S\+R\+V\+\_\+\+F\+\_\+\+R\+E\+C\+O\+NF}~(1 $<$$<$ 0)
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+S\+R\+V\+\_\+\+F\+\_\+\+N\+O\+D\+E\+L\+AY}~(1 $<$$<$ 1)
\item 
\#define {\bfseries O\+S\+M\+O\+\_\+\+S\+T\+R\+E\+A\+M\+\_\+\+S\+R\+V\+\_\+\+F\+\_\+\+F\+L\+U\+S\+H\+\_\+\+D\+E\+S\+T\+R\+OY}~(1 $<$$<$ 0)
\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__stream_gaefb240abea020971d9a384b5e39826e5}} 
enum {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+state} \{ \newline
{\bfseries S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+S\+T\+A\+T\+E\+\_\+\+C\+L\+O\+S\+ED}, 
{\bfseries S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+S\+T\+A\+T\+E\+\_\+\+W\+A\+I\+T\+\_\+\+R\+E\+C\+O\+N\+N\+E\+CT}, 
{\bfseries S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+S\+T\+A\+T\+E\+\_\+\+C\+O\+N\+N\+E\+C\+T\+I\+NG}, 
{\bfseries S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+S\+T\+A\+T\+E\+\_\+\+C\+O\+N\+N\+E\+C\+T\+ED}, 
\newline
{\bfseries S\+T\+R\+E\+A\+M\+\_\+\+C\+L\+I\+\_\+\+S\+T\+A\+T\+E\+\_\+\+M\+AX}
 \}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int {\bfseries byte\+\_\+nonzero} (const uint8\+\_\+t $\ast$u8, unsigned int offset, unsigned int u8\+\_\+size)
\item 
static int {\bfseries determine\+\_\+sctp\+\_\+sockopt\+\_\+event\+\_\+subscribe\+\_\+size} (void)
\item 
static int {\bfseries sctp\+\_\+setsockopt\+\_\+events\+\_\+linux\+\_\+workaround} (int fd, const struct sctp\+\_\+event\+\_\+subscribe $\ast$event)
\item 
static int {\bfseries sctp\+\_\+sock\+\_\+activate\+\_\+events} (int fd)
\item 
static int {\bfseries setsockopt\+\_\+nodelay} (int fd, int proto, int on)
\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+close} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Close an Osmocom Stream Client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+reconnect} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Re-\/connect an Osmocom Stream Client If re-\/connection is enabled for this client (which is the case unless negative timeout was explicitly set via \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout()}{p.}{group__stream_gade74792afe35f31dd2584c888db3dd62} call), we close any existing connection (if any) and schedule a re-\/connect timer. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+is\+\_\+connected} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Check if Osmocom Stream Client is in connected state. \end{DoxyCompactList}\item 
static void {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+read} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\item 
static int {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+write} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\item 
static int {\bfseries \+\_\+setsockopt\+\_\+nosigpipe} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\item 
static int {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+fd\+\_\+cb} (struct osmo\+\_\+fd $\ast$ofd, unsigned int what)
\item 
static void {\bfseries cli\+\_\+timer\+\_\+cb} (void $\ast$data)
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+create} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Create an Osmocom stream client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+addr} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, const char $\ast$addr)
\begin{DoxyCompactList}\small\item\em Set the remote address to which we connect. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+addrs} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, const char $\ast$$\ast$addr, size\+\_\+t addrcnt)
\begin{DoxyCompactList}\small\item\em Set the remote address set to which we connect. Useful for protocols allowing connecting to more than one address (such as S\+C\+TP) \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+port} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, uint16\+\_\+t port)
\begin{DoxyCompactList}\small\item\em Set the remote port number to which we connect. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+local\+\_\+port} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, uint16\+\_\+t port)
\begin{DoxyCompactList}\small\item\em Set the local port number for the socket (to be bound to) \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+local\+\_\+addr} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, const char $\ast$addr)
\begin{DoxyCompactList}\small\item\em Set the local address for the socket (to be bound to) \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+local\+\_\+addrs} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, const char $\ast$$\ast$addr, size\+\_\+t addrcnt)
\begin{DoxyCompactList}\small\item\em Set the local address set to which we connect. Useful for protocols allowing bind to more than one address (such as S\+C\+TP) \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+proto} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, uint16\+\_\+t proto)
\begin{DoxyCompactList}\small\item\em Set the protocol for the stream client socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+type} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int type)
\begin{DoxyCompactList}\small\item\em Set the socket type for the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+domain} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int domain)
\begin{DoxyCompactList}\small\item\em Set the socket type for the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int timeout)
\begin{DoxyCompactList}\small\item\em Set the reconnect time of the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Set application private data of the stream client socket. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Get application private data of the stream client socket. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+sockname} (const struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Get the stream client socket description. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+ofd} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Get Osmocom File Descriptor of the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+connect\+\_\+cb} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int($\ast$connect\+\_\+cb)(struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli))
\begin{DoxyCompactList}\small\item\em Set the call-\/back function called on connect of the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+disconnect\+\_\+cb} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int($\ast$disconnect\+\_\+cb)(struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli))
\begin{DoxyCompactList}\small\item\em Set the call-\/back function called on disconnect of the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+read\+\_\+cb} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int($\ast$read\+\_\+cb)(struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli))
\begin{DoxyCompactList}\small\item\em Set the call-\/back function called to read from the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+destroy} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Destroy a Osmocom stream client (includes close) \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+open2} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, int reconnect)
\begin{DoxyCompactList}\small\item\em D\+E\+P\+R\+E\+C\+A\+T\+ED\+: use \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout()}{p.}{group__stream_gade74792afe35f31dd2584c888db3dd62} or \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+reconnect()}{p.}{group__stream_ga11d2615f6197f33073ba7245e5ba95ee} instead! Open connection of an Osmocom stream client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+nodelay} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, bool nodelay)
\begin{DoxyCompactList}\small\item\em Set the N\+O\+D\+E\+L\+AY socket option to avoid Nagle-\/like behavior Setting this to nodelay=true will automatically set the N\+O\+D\+E\+L\+AY socket option on any socket established via \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+open}{p.}{group__stream_ga86b4b9c8e563f8426d3cdae803e3ec38} or any re-\/connect. You have to set this {\itshape before} opening the socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+open} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\begin{DoxyCompactList}\small\item\em Open connection of an Osmocom stream client By default the client will automatically reconnect after default timeout. To disable this, use \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout()}{p.}{group__stream_gade74792afe35f31dd2584c888db3dd62} before calling this function. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+send} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Enqueue data to be sent via an Osmocom stream client. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+recv} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Receive data via an Osmocom stream client. \end{DoxyCompactList}\item 
void {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+clear\+\_\+tx\+\_\+queue} (struct \textbf{ osmo\+\_\+stream\+\_\+cli} $\ast$cli)
\item 
static int {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+fd\+\_\+cb} (struct osmo\+\_\+fd $\ast$ofd, unsigned int what)
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+create} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Create an Osmocom Stream Server Link A Stream Server Link is the listen()+accept() \char`\"{}parent\char`\"{} to individual Stream Servers. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+nodelay} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, bool nodelay)
\begin{DoxyCompactList}\small\item\em Set the N\+O\+D\+E\+L\+AY socket option to avoid Nagle-\/like behavior Setting this to nodelay=true will automatically set the N\+O\+D\+E\+L\+AY socket option on any socket established via this server link, before calling the accept\+\_\+cb() \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addr} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, const char $\ast$addr)
\begin{DoxyCompactList}\small\item\em Set the local address to which we bind. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addrs} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, const char $\ast$$\ast$addr, size\+\_\+t addrcnt)
\begin{DoxyCompactList}\small\item\em Set the local address set to which we bind. Useful for protocols allowing bind on more than one address (such as S\+C\+TP) \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+port} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, uint16\+\_\+t port)
\begin{DoxyCompactList}\small\item\em Set the local port number to which we bind. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+proto} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, uint16\+\_\+t proto)
\begin{DoxyCompactList}\small\item\em Set the protocol for the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+type} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, int type)
\begin{DoxyCompactList}\small\item\em Set the socket type for the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+domain} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, int domain)
\begin{DoxyCompactList}\small\item\em Set the socket type for the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Set application private data of the stream server link. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Get application private data of the stream server link. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+sockname} (const struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Get description of the stream server link e. g. 127.\+0.\+0.\+1\+:1234. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+ofd} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Get Osmocom File Descriptor of the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+accept\+\_\+cb} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, int($\ast$accept\+\_\+cb)(struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, int fd))
\begin{DoxyCompactList}\small\item\em Set the accept() call-\/back of the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+destroy} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Destroy the stream server link. Closes + Releases Memory. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+open} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Open the stream server link. This actually initializes the underlying socket and binds it to the configured ip/port. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+close} (struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link)
\begin{DoxyCompactList}\small\item\em Close the stream server link and unregister from select loop Does not destroy the server link, merely closes it! \end{DoxyCompactList}\item 
static int {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+read} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\item 
static void {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+write} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\item 
static int {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+cb} (struct osmo\+\_\+fd $\ast$ofd, unsigned int what)
\item 
struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+create} (void $\ast$ctx, struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$link, int fd, int($\ast$cb)(struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn), int($\ast$closed\+\_\+cb)(struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn), void $\ast$data)
\begin{DoxyCompactList}\small\item\em Create a Stream Server inside the specified link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+flush\+\_\+and\+\_\+destroy} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\begin{DoxyCompactList}\small\item\em Prepare to send out all pending messages on the connection\textquotesingle{}s Tx queue and then automatically destroy the stream with \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+destroy()}{p.}{group__stream_ga47f18e063f64f22cb74d58d8b7243bed}. This function disables queuing of new messages on the connection and also disables reception of new messages on the connection. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Set application private data of the stream server. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+data} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\begin{DoxyCompactList}\small\item\em Get application private data of the stream server. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+ofd} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\begin{DoxyCompactList}\small\item\em Get Osmocom File Descriptor of the stream server. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link} $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+master} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\begin{DoxyCompactList}\small\item\em Get the master (Link) from a Stream Server. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+destroy} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\begin{DoxyCompactList}\small\item\em Destroy given Stream Server This function closes the Stream Server socket, unregisters from select loop, invokes the connection\textquotesingle{}s closed\+\_\+cb() callback to allow A\+PI users to clean up any associated state they have for this connection, and then de-\/allocates associated memory. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+send} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Enqueue data to be sent via an Osmocom stream server. \end{DoxyCompactList}\item 
static int {\bfseries \+\_\+sctp\+\_\+recvmsg\+\_\+wrapper} (int fd, struct msgb $\ast$msg)
\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+recv} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Receive data via Osmocom stream server. \end{DoxyCompactList}\item 
void {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+clear\+\_\+tx\+\_\+queue} (struct \textbf{ osmo\+\_\+stream\+\_\+srv} $\ast$conn)
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static unsigned int {\bfseries sctp\+\_\+sockopt\+\_\+event\+\_\+subscribe\+\_\+size} = 0
\item 
static const struct value\+\_\+string {\bfseries stream\+\_\+cli\+\_\+state\+\_\+names} [$\,$]
\end{DoxyCompactItemize}


\subsection{Detailed Description}
Osmocom stream socket helpers. 

