\doxysection{Osmocom Stream Server}
\label{group__stream__srv}\index{Osmocom Stream Server@{Osmocom Stream Server}}


This code is intended to abstract any server-\/side use of stream-\/type sockets, such as TCP and SCTP.  


\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__stream__srv_gaa0667ad7da5a382c3ea67d27b6cbb6bf}} 
typedef int($\ast$ {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+accept\+\_\+cb\+\_\+t}) (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int fd)
\item 
\mbox{\label{group__stream__srv_ga4eb2206ab18a857eb725c829be3eb054}} 
typedef int($\ast$ {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb\+\_\+t}) (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\item 
\mbox{\label{group__stream__srv_gaf81e6c2c7fe32dea58c3140864a4caef}} 
typedef int($\ast$ {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+closed\+\_\+cb\+\_\+t}) (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\item 
typedef int($\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb2\+\_\+t}) (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, int res, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Completion call-\/back function when something was read from from the stream client socket. \end{DoxyCompactList}\item 
\mbox{\label{group__stream__srv_ga77f9cb6ee99e9c92643edfb7e019d7e4}} 
typedef int($\ast$ {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb\+\_\+t}) (struct msgb $\ast$msg)
\item 
\mbox{\label{group__stream__srv_ga9492a686d7124c384be2b2fcc7925095}} 
typedef int($\ast$ {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb2\+\_\+t}) (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, struct msgb $\ast$msg)
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{group__stream__srv_ga4448bfb5af99a9b949c0fe2a23e0806c}} 
enum {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+param} \{ {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+LINK\+\_\+\+PAR\+\_\+\+SCTP\+\_\+\+SOCKOPT\+\_\+\+AUTH\+\_\+\+SUPPORTED}
, {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+LINK\+\_\+\+PAR\+\_\+\+SCTP\+\_\+\+SOCKOPT\+\_\+\+ASCONF\+\_\+\+SUPPORTED}
, {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+LINK\+\_\+\+PAR\+\_\+\+SCTP\+\_\+\+INIT\+\_\+\+NUM\+\_\+\+OSTREAMS}
, {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+LINK\+\_\+\+PAR\+\_\+\+SCTP\+\_\+\+INIT\+\_\+\+MAX\+\_\+\+INSTREAMS}
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct 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. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+destroy} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Destroy the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+name} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Set a name on the srv\+\_\+link object (used during logging). \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+name} (const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Retrieve name previously set on the srv\+\_\+link object (see \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+name()}{p.}{group__stream__srv_gadef998825a4739660b198151fcee4201}). \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+nodelay} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, bool nodelay)
\begin{DoxyCompactList}\small\item\em Set the NODELAY socket option to avoid Nagle-\/like behavior. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+priority} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int sk\+\_\+prio)
\begin{DoxyCompactList}\small\item\em Set the priority value of the stream socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+ip\+\_\+dscp} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, uint8\+\_\+t ip\+\_\+dscp)
\begin{DoxyCompactList}\small\item\em Set the DSCP (differentiated services code point) of the stream socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addr} (struct 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 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. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+port} (struct 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 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 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 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\+\_\+accept\+\_\+cb} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int($\ast$accept\+\_\+cb)(struct 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\+\_\+set\+\_\+data} (struct 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 osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Retrieve application private data of the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+tx\+\_\+queue\+\_\+max\+\_\+length} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, unsigned int size)
\begin{DoxyCompactList}\small\item\em Set the maximum length queue of the stream servers accepted and allocated from this server link. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+sockname} (const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Retrieve description of the stream server link e. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+ofd} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Retrieve Osmocom File Descriptor of the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+fd} (const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Retrieve File Descriptor of the stream server link. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+msgb\+\_\+alloc\+\_\+info} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, unsigned int size, unsigned int headroom)
\begin{DoxyCompactList}\small\item\em Set the msgb allocation parameters on child osmo\+\_\+stream\+\_\+srv objects. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+is\+\_\+opened} (const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Check whether the stream server link is opened. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+open} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Open the stream server link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+close} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link)
\begin{DoxyCompactList}\small\item\em Close the stream server link and unregister from select loop. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+param} (struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, enum osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+param par, void $\ast$val, size\+\_\+t val\+\_\+len)
\begin{DoxyCompactList}\small\item\em Set given parameter of stream\+\_\+srv\+\_\+link to given value. \end{DoxyCompactList}\item 
struct osmo\+\_\+stream\+\_\+srv $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+create} (void $\ast$ctx, struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int fd, osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb\+\_\+t read\+\_\+cb, osmo\+\_\+stream\+\_\+srv\+\_\+closed\+\_\+cb\+\_\+t closed\+\_\+cb, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Create a legacy osmo\+\_\+fd mode Stream Server inside the specified link. \end{DoxyCompactList}\item 
struct osmo\+\_\+stream\+\_\+srv $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+create2} (void $\ast$ctx, struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int fd, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Create an osmo\+\_\+iofd mode Stream Server inside the specified link. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+name} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Set a name on the srv object (used during logging). \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+name} (const struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve name previously set on the srv object (see \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+name()}{p.}{group__stream__srv_ga196834d254fd94922d6be91b7b5b1ed3}). \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+read\+\_\+cb} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb2\+\_\+t} read\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set the call-\/back function for incoming data on an osmo\+\_\+io stream\+\_\+srv. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+closed\+\_\+cb} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, osmo\+\_\+stream\+\_\+srv\+\_\+closed\+\_\+cb\+\_\+t closed\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set the call-\/back function called when the stream server socket was closed. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+data} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve application private data of the stream server. \end{DoxyCompactList}\item 
struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+master} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve the master (Link) from a Stream Server. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+sockname} (const struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve the stream server socket description. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+ofd} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve Osmocom File Descriptor of a stream server in osmo\+\_\+fd mode. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+fd} (const struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Retrieve File Descriptor of the stream server. \end{DoxyCompactList}\item 
struct osmo\+\_\+io\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+iofd} (const struct osmo\+\_\+stream\+\_\+srv $\ast$srv)
\begin{DoxyCompactList}\small\item\em Retrieve osmo\+\_\+io descriptor of the stream server socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+destroy} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Destroy given Stream Server. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+flush\+\_\+and\+\_\+destroy} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\begin{DoxyCompactList}\small\item\em Prepare to send out all pending messages on the connection\textquotesingle{}s Tx queue. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+data} (struct 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 \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+segmentation\+\_\+cb} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb\+\_\+t segmentation\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set the segmentation callback for target osmo\+\_\+stream\+\_\+srv structure. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+segmentation\+\_\+cb2} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb2\+\_\+t segmentation\+\_\+cb2)
\begin{DoxyCompactList}\small\item\em Set the segmentation callback for target osmo\+\_\+stream\+\_\+srv structure. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+send} (struct 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 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+recv} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Receive data via an Osmocom stream server in osmo\+\_\+fd mode. \end{DoxyCompactList}\item 
\mbox{\label{group__stream__srv_ga4a830f1d9990deb5b9b58f68927cefeb}} 
void {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+clear\+\_\+tx\+\_\+queue} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This code is intended to abstract any server-\/side use of stream-\/type sockets, such as TCP and SCTP. 

The Osmocom stream socket helper is an abstraction layer for connected SOCK\+\_\+\+STREAM/\+SOCK\+\_\+\+SEQPACKET sockets. It encapsulates common functionality like binding, accepting client connections, etc.

osmo\+\_\+stream\+\_\+srv can operate in two different modes\+:
\begin{DoxyEnumerate}
\item The legacy mode using osmo\+\_\+fd (from libosmocore)
\item The modern (2023) mode using osmo\+\_\+io (from libosmocore)
\end{DoxyEnumerate}

For any new applications, you definitely should use the modern mode, as it provides you with a higher layer of abstraction and allows you to perform efficient I/O using the io\+\_\+uring backend of osmo\+\_\+io.

The modern mode is chosen by invoking \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+create2()}{p.}{group__stream__srv_ga8be283e1a143e346b4d6ccf33cbb9b98}. The legacy mode is chosen by invoking the older \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+create()}{p.}{group__stream__srv_ga136b426790b6322f58f89059b88aaa0b}.

The two main objects are osmo\+\_\+stream\+\_\+srv\+\_\+link (main server accept()ing incoming connections) and osmo\+\_\+stream\+\_\+srv (a single given connection from a remote client).

A typical stream\+\_\+srv usage would look like this\+:


\begin{DoxyItemize}
\item create new osmo\+\_\+stream\+\_\+srv\+\_\+link using \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+create()}{p.}{group__stream__srv_gaad262988c7ac365566f03843c560f892}
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addr()}{p.}{group__stream__srv_gacece90116484e34540def69b05c66f57} to set local bind address/port
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+accept\+\_\+cb()}{p.}{group__stream__srv_ga1eea525d4e1e7a24c9c08881994ceb7e} to register the accept call-\/back
\item optionally call further osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+$\ast$() functions
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+open()}{p.}{group__stream__srv_ga603b89074d3e8c0fb44144ab1864f0d4} to create socket and start listening
\end{DoxyItemize}

Whenever a client connects to your listening socket, the connection will now be automatically accept()ed and the registered accept\+\_\+cb call-\/back called. From within that accept\+\_\+cb, you then
\begin{DoxyItemize}
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+create()}{p.}{group__stream__srv_ga136b426790b6322f58f89059b88aaa0b} to create a osmo\+\_\+stream\+\_\+srv for that specific connection
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+read\+\_\+cb()}{p.}{group__stream__srv_gad0d7b7e236826c52f10a7b4f50009d01} to register the read call-\/back for incoming data
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+closed\+\_\+cb()}{p.}{group__stream__srv_gaed83d9686289eee534d77a61b96fbd90} to register the closed call-\/back
\item call \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+data()}{p.}{group__stream__srv_ga9891663b20714d72f992e44ad1e92eea} to associate opaque application-\/layer state
\end{DoxyItemize}

Whenever data from a client arrives on a connection, your registered read\+\_\+cb will be called together with a message buffer containing the received data. Ownership of the message buffer is transferred into the call-\/back, i.\+e. in your application. It\textquotesingle{}s your responsibility to eventually msgb\+\_\+free() it after usage.

Whenever your application wants to transmit something to a given connection, it uses the \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+send()}{p.}{group__stream__srv_gaa1589994cf6eab27742cafee6b7fb491} function. 

\doxysubsection{Typedef Documentation}
\mbox{\label{group__stream__srv_ga5b6beeb3ec1effa8afa948deb7a4fc15}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_read\_cb2\_t@{osmo\_stream\_srv\_read\_cb2\_t}}
\index{osmo\_stream\_srv\_read\_cb2\_t@{osmo\_stream\_srv\_read\_cb2\_t}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_read\_cb2\_t}
{\footnotesize\ttfamily typedef int($\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb2\+\_\+t) (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, int res, struct msgb $\ast$msg)}



Completion call-\/back function when something was read from from the stream client socket. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server that got receive event. \\
\hline
\mbox{\texttt{ in}}  & {\em res} & return value of the read()/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 msgb\+\_\+free() it eventually! \\
\hline
\end{DoxyParams}


\doxysubsection{Function Documentation}
\mbox{\label{group__stream__srv_ga136b426790b6322f58f89059b88aaa0b}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_create@{osmo\_stream\_srv\_create}}
\index{osmo\_stream\_srv\_create@{osmo\_stream\_srv\_create}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_create()}
{\footnotesize\ttfamily struct osmo\+\_\+stream\+\_\+srv $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+create (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int}]{fd,  }\item[{osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb\+\_\+t}]{read\+\_\+cb,  }\item[{osmo\+\_\+stream\+\_\+srv\+\_\+closed\+\_\+cb\+\_\+t}]{closed\+\_\+cb,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Create a legacy osmo\+\_\+fd mode Stream Server inside the specified link. 

This is the function an application traditionally calls from within the accept\+\_\+cb call-\/back of the osmo\+\_\+stream\+\_\+srv\+\_\+link. It creates a new osmo\+\_\+stream\+\_\+srv within that link.

New users/programs should use osmo\+\_\+stream\+\_\+srv\+\_\+create2 to operate in osmo\+\_\+io mode instead.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc allocation context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to which we belong \\
\hline
\mbox{\texttt{ in}}  & {\em fd} & system file descriptor of the new connection \\
\hline
\mbox{\texttt{ in}}  & {\em read\+\_\+cb} & Call-\/back to call when the socket is readable \\
\hline
\mbox{\texttt{ in}}  & {\em closed\+\_\+cb} & Call-\/back to call when the connection is closed \\
\hline
\mbox{\texttt{ in}}  & {\em data} & User data to save in the new Stream Server struct \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Stream Server in case of success; NULL on error 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga8be283e1a143e346b4d6ccf33cbb9b98}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_create2@{osmo\_stream\_srv\_create2}}
\index{osmo\_stream\_srv\_create2@{osmo\_stream\_srv\_create2}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_create2()}
{\footnotesize\ttfamily struct osmo\+\_\+stream\+\_\+srv $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+create2 (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int}]{fd,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Create an osmo\+\_\+iofd mode Stream Server inside the specified link. 

This is the function an application typically calls from within the accept\+\_\+cb call-\/back of the osmo\+\_\+stream\+\_\+srv\+\_\+link. It creates a new osmo\+\_\+stream\+\_\+srv in osmo\+\_\+io mode within that link.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc allocation context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to which we belong \\
\hline
\mbox{\texttt{ in}}  & {\em fd} & system file descriptor of the new connection \\
\hline
\mbox{\texttt{ in}}  & {\em data} & User data to save in the new Stream Server struct \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Stream Server in case of success; NULL on error 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga47f18e063f64f22cb74d58d8b7243bed}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_destroy@{osmo\_stream\_srv\_destroy}}
\index{osmo\_stream\_srv\_destroy@{osmo\_stream\_srv\_destroy}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_destroy()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+destroy (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Destroy given Stream Server. 

This function closes the Stream Server socket, unregisters from the underlying I/O mechanism, invokes the connection\textquotesingle{}s closed\+\_\+cb() callback to allow API users to clean up any associated state they have for this connection, and then de-\/allocates associated memory. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server to be destroyed \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_gae2a0ef01097d964c71e38600b4c078d5}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_data@{osmo\_stream\_srv\_get\_data}}
\index{osmo\_stream\_srv\_get\_data@{osmo\_stream\_srv\_get\_data}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_data()}
{\footnotesize\ttfamily void $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+data (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve application private data of the stream server. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Application private data, as set by \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+data()}{p.}{group__stream__srv_ga9891663b20714d72f992e44ad1e92eea} 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga803c8ba415f66cc1029b3899cc53b807}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_fd@{osmo\_stream\_srv\_get\_fd}}
\index{osmo\_stream\_srv\_get\_fd@{osmo\_stream\_srv\_get\_fd}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_fd()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+fd (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve File Descriptor of the stream server. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
file descriptor or negative on error 
\end{DoxyReturn}


Referenced by \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+sockname()}.

\mbox{\label{group__stream__srv_ga9e00a9172d5b2708afa269d52c118eff}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_iofd@{osmo\_stream\_srv\_get\_iofd}}
\index{osmo\_stream\_srv\_get\_iofd@{osmo\_stream\_srv\_get\_iofd}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_iofd()}
{\footnotesize\ttfamily struct osmo\+\_\+io\+\_\+fd $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+iofd (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv $\ast$}]{srv }\end{DoxyParamCaption})}



Retrieve osmo\+\_\+io descriptor of the stream server socket. 

This function must not be called on a stream server in legacy osmo\+\_\+fd mode! 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em srv} & Stream Server of which we want to obtain the osmo\+\_\+io descriptor \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
osmo\+\_\+io\+\_\+fd of stream server. 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga9cf689935bf6ffac4f86f56219d73c8e}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_master@{osmo\_stream\_srv\_get\_master}}
\index{osmo\_stream\_srv\_get\_master@{osmo\_stream\_srv\_get\_master}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_master()}
{\footnotesize\ttfamily struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+master (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve the master (Link) from a Stream Server. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server of which we want to know the Link \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Link through which the given Stream Server is established 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_gad34dc0f7ebf7c84653514566e431a1d2}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_name@{osmo\_stream\_srv\_get\_name}}
\index{osmo\_stream\_srv\_get\_name@{osmo\_stream\_srv\_get\_name}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+name (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve name previously set on the srv object (see \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+name()}{p.}{group__stream__srv_ga196834d254fd94922d6be91b7b5b1ed3}). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & server whose name is to be retrieved \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The name to be set on conn; NULL if never set 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga47bbca4f12717db2e6158eefe6310b9b}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_ofd@{osmo\_stream\_srv\_get\_ofd}}
\index{osmo\_stream\_srv\_get\_ofd@{osmo\_stream\_srv\_get\_ofd}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_ofd()}
{\footnotesize\ttfamily struct osmo\+\_\+fd $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+ofd (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve Osmocom File Descriptor of a stream server in osmo\+\_\+fd mode. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to osmo\+\_\+fd 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga4f176a35751509dc741fbd2b52f45b22}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_get\_sockname@{osmo\_stream\_srv\_get\_sockname}}
\index{osmo\_stream\_srv\_get\_sockname@{osmo\_stream\_srv\_get\_sockname}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_get\_sockname()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+sockname (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



Retrieve the stream server socket description. 

The returned name is stored in a static buffer; it is hence not re-\/entrant or thread-\/safe! 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cli} & Stream Server to examine \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Socket description or NULL in case of error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+get\+\_\+fd()}.

\mbox{\label{group__stream__srv_gad325d97b09c724e830c98d76b890520d}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_close@{osmo\_stream\_srv\_link\_close}}
\index{osmo\_stream\_srv\_link\_close@{osmo\_stream\_srv\_link\_close}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_close()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+close (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Close the stream server link and unregister from select loop. 

Does not destroy the server link, merely closes it! 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to close \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+is\+\_\+opened()}.



Referenced by \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+destroy()}.

\mbox{\label{group__stream__srv_gaad262988c7ac365566f03843c560f892}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_create@{osmo\_stream\_srv\_link\_create}}
\index{osmo\_stream\_srv\_link\_create@{osmo\_stream\_srv\_link\_create}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_create()}
{\footnotesize\ttfamily struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+create (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



Create an Osmocom Stream Server Link. 

A Stream Server Link is the listen()+accept() \char`\"{}parent\char`\"{} to individual connections from remote clients. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc allocation context \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Stream Server Link with default values (AF\+\_\+\+UNSPEC, SOCK\+\_\+\+STREAM, IPPROTO\+\_\+\+TCP) 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga882acaaa5935422b0e09a2ce8c8019ec}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_destroy@{osmo\_stream\_srv\_link\_destroy}}
\index{osmo\_stream\_srv\_link\_destroy@{osmo\_stream\_srv\_link\_destroy}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_destroy()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+destroy (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Destroy the stream server link. 

Closes + Releases Memory. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+close()}.

\mbox{\label{group__stream__srv_gacb5d68c2a6a9663f99266c70747bce04}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_get\_data@{osmo\_stream\_srv\_link\_get\_data}}
\index{osmo\_stream\_srv\_link\_get\_data@{osmo\_stream\_srv\_link\_get\_data}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_get\_data()}
{\footnotesize\ttfamily void $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+data (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Retrieve application private data of the stream server link. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Application private data, as set by \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+data()}{p.}{group__stream__cli_ga5e94c511d537f63337912bb50fb2dc28} 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_gae2ef09bc8da55db30d967563dfc6561a}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_get\_fd@{osmo\_stream\_srv\_link\_get\_fd}}
\index{osmo\_stream\_srv\_link\_get\_fd@{osmo\_stream\_srv\_link\_get\_fd}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_get\_fd()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+fd (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Retrieve File Descriptor of the stream server link. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server Link \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
file descriptor or negative on error 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga67520942e5a404a0b3a6960b8a161de8}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_get\_name@{osmo\_stream\_srv\_link\_get\_name}}
\index{osmo\_stream\_srv\_link\_get\_name@{osmo\_stream\_srv\_link\_get\_name}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_get\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+name (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Retrieve name previously set on the srv\+\_\+link object (see \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+name()}{p.}{group__stream__srv_gadef998825a4739660b198151fcee4201}). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & server link whose name is to be retrieved \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The name to be set on link; NULL if never set 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga7b8981351a154c357fcefd39c31ad42a}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_get\_ofd@{osmo\_stream\_srv\_link\_get\_ofd}}
\index{osmo\_stream\_srv\_link\_get\_ofd@{osmo\_stream\_srv\_link\_get\_ofd}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_get\_ofd()}
{\footnotesize\ttfamily struct osmo\+\_\+fd $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+ofd (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Retrieve Osmocom File Descriptor of the stream server link. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to osmo\+\_\+fd 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga7d7b6af7df24e90dc758a088bae6316d}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_get\_sockname@{osmo\_stream\_srv\_link\_get\_sockname}}
\index{osmo\_stream\_srv\_link\_get\_sockname@{osmo\_stream\_srv\_link\_get\_sockname}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_get\_sockname()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+get\+\_\+sockname (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Retrieve description of the stream server link e. 

g. 127.\+0.\+0.\+1\+:1234. Calling this function will build a string that describes the socket in terms of its local/remote address/port. The returned name is stored in a static buffer; it is hence not re-\/entrant or thread-\/safe. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to examine \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Link description or NULL in case of error 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga28243be108ed0302b0f5a9d1dfc96b22}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_is\_opened@{osmo\_stream\_srv\_link\_is\_opened}}
\index{osmo\_stream\_srv\_link\_is\_opened@{osmo\_stream\_srv\_link\_is\_opened}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_is\_opened()}
{\footnotesize\ttfamily bool osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+is\+\_\+opened (\begin{DoxyParamCaption}\item[{const struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Check whether the stream server link is opened. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to check \\
\hline
\end{DoxyParams}


Referenced by \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+close()}.

\mbox{\label{group__stream__srv_ga603b89074d3e8c0fb44144ab1864f0d4}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_open@{osmo\_stream\_srv\_link\_open}}
\index{osmo\_stream\_srv\_link\_open@{osmo\_stream\_srv\_link\_open}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_open()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+open (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link }\end{DoxyParamCaption})}



Open the stream server link. 

This actually initializes the underlying socket and binds it to the configured ip/port. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to open \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
negative on error, 0 on success 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga1eea525d4e1e7a24c9c08881994ceb7e}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_accept\_cb@{osmo\_stream\_srv\_link\_set\_accept\_cb}}
\index{osmo\_stream\_srv\_link\_set\_accept\_cb@{osmo\_stream\_srv\_link\_set\_accept\_cb}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_accept\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+accept\+\_\+cb (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int($\ast$)(struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$link, int fd)}]{accept\+\_\+cb }\end{DoxyParamCaption})}



Set the accept() call-\/back of the stream server link. 

The provided call-\/back will be called whenever a new inbound connection is accept()ed. The call-\/back then typically creates a new osmo\+\_\+stream\+\_\+srv. If the call-\/back returns a negative value, the file descriptor will be closed. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link \\
\hline
\mbox{\texttt{ in}}  & {\em accept\+\_\+cb} & Call-\/back function executed upon accept() \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_gacece90116484e34540def69b05c66f57}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_addr@{osmo\_stream\_srv\_link\_set\_addr}}
\index{osmo\_stream\_srv\_link\_set\_addr@{osmo\_stream\_srv\_link\_set\_addr}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_addr()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addr (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{const char $\ast$}]{addr }\end{DoxyParamCaption})}



Set the local address to which we bind. 

Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em addr} & Local IP address \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addrs()}.

\mbox{\label{group__stream__srv_gaadabca7d23c52c39e291bf7e05f0055b}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_addrs@{osmo\_stream\_srv\_link\_set\_addrs}}
\index{osmo\_stream\_srv\_link\_set\_addrs@{osmo\_stream\_srv\_link\_set\_addrs}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_addrs()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addrs (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{const char $\ast$$\ast$}]{addr,  }\item[{size\+\_\+t}]{addrcnt }\end{DoxyParamCaption})}



Set the local address set to which we bind. 

Useful for protocols allowing bind on more than one address (such as SCTP) Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em addr} & Local IP address \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
negative on error, 0 on success 
\end{DoxyReturn}


Referenced by \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+addr()}.

\mbox{\label{group__stream__srv_ga5ef0f0c85a52c08e8c10d36a8f44e392}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_data@{osmo\_stream\_srv\_link\_set\_data}}
\index{osmo\_stream\_srv\_link\_set\_data@{osmo\_stream\_srv\_link\_set\_data}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_data()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+data (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Set application private data of the stream server link. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em data} & User-\/specific data (available in call-\/back functions) \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga9629b516297c31f34af48e4630973dab}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_domain@{osmo\_stream\_srv\_link\_set\_domain}}
\index{osmo\_stream\_srv\_link\_set\_domain@{osmo\_stream\_srv\_link\_set\_domain}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_domain()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+domain (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int}]{domain }\end{DoxyParamCaption})}



Set the socket type for the stream server link. 

Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em type} & Socket Domain (like AF\+\_\+\+UNSPEC (default for IP), AF\+\_\+\+UNIX, AF\+\_\+\+INET, ...) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
zero on success, negative on error. 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga53be410e4b8cf79e850b8cd5c01b4c78}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_ip\_dscp@{osmo\_stream\_srv\_link\_set\_ip\_dscp}}
\index{osmo\_stream\_srv\_link\_set\_ip\_dscp@{osmo\_stream\_srv\_link\_set\_ip\_dscp}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_ip\_dscp()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+ip\+\_\+dscp (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{uint8\+\_\+t}]{ip\+\_\+dscp }\end{DoxyParamCaption})}



Set the DSCP (differentiated services code point) of the stream socket. 

Setting this will automatically set the IP DSCP option on any socket on any socket established via this server link, before calling the accept\+\_\+cb(). 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & server link whose sockets are to be configured \\
\hline
\mbox{\texttt{ in}}  & {\em ip\+\_\+dscp} & DSCP value. Value range 0..63. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
negative on error, 0 on success 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga925981abcacca9f9a3375d511309cb32}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_msgb\_alloc\_info@{osmo\_stream\_srv\_link\_set\_msgb\_alloc\_info}}
\index{osmo\_stream\_srv\_link\_set\_msgb\_alloc\_info@{osmo\_stream\_srv\_link\_set\_msgb\_alloc\_info}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_msgb\_alloc\_info()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+msgb\+\_\+alloc\+\_\+info (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{unsigned int}]{size,  }\item[{unsigned int}]{headroom }\end{DoxyParamCaption})}



Set the msgb allocation parameters on child osmo\+\_\+stream\+\_\+srv objects. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link \\
\hline
\mbox{\texttt{ in}}  & {\em size} & Size of msgb to allocate (excluding headroom) \\
\hline
\mbox{\texttt{ in}}  & {\em headroom} & Headroom to allocate when allocating msgb\textquotesingle{}s\\
\hline
\end{DoxyParams}
The parameters are applied to osmo\+\_\+stream\+\_\+srv objects upon creation. Setting both to 0 leaves it as implementation default. \mbox{\label{group__stream__srv_gadef998825a4739660b198151fcee4201}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_name@{osmo\_stream\_srv\_link\_set\_name}}
\index{osmo\_stream\_srv\_link\_set\_name@{osmo\_stream\_srv\_link\_set\_name}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_name()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+name (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Set a name on the srv\+\_\+link object (used during logging). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & server link whose name is to be set. The name is copied into the osmo\+\_\+stream\+\_\+srv\+\_\+link, so the caller memory is not required to be valid beyond the call of this function. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & the name to be set on link \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga41e8ad2c761aaa00313aa11d1f29a3ed}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_nodelay@{osmo\_stream\_srv\_link\_set\_nodelay}}
\index{osmo\_stream\_srv\_link\_set\_nodelay@{osmo\_stream\_srv\_link\_set\_nodelay}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_nodelay()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+nodelay (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{bool}]{nodelay }\end{DoxyParamCaption})}



Set the NODELAY socket option to avoid Nagle-\/like behavior. 

Setting this to nodelay=true will automatically set the NODELAY socket option on any socket established via this server link, before calling the accept\+\_\+cb() 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & server link whose sockets are to be configured \\
\hline
\mbox{\texttt{ in}}  & {\em nodelay} & whether to set (true) NODELAY after accept \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga759bceb4ce155f88e3e7817ce4c9449d}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_param@{osmo\_stream\_srv\_link\_set\_param}}
\index{osmo\_stream\_srv\_link\_set\_param@{osmo\_stream\_srv\_link\_set\_param}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_param()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+param (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{enum osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+param}]{par,  }\item[{void $\ast$}]{val,  }\item[{size\+\_\+t}]{val\+\_\+len }\end{DoxyParamCaption})}



Set given parameter of stream\+\_\+srv\+\_\+link to given value. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cli} & stream client on which to set parameter. \\
\hline
\mbox{\texttt{ in}}  & {\em par} & identifier of the parameter to be set. \\
\hline
\mbox{\texttt{ in}}  & {\em val} & value of the parameter to be set. \\
\hline
\mbox{\texttt{ in}}  & {\em val\+\_\+len} & length of the parameter value. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 in success; negative -\/errno on error. 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga76bbbafd1d8dc9c9ebffd301503b6dd9}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_port@{osmo\_stream\_srv\_link\_set\_port}}
\index{osmo\_stream\_srv\_link\_set\_port@{osmo\_stream\_srv\_link\_set\_port}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_port()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+port (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{uint16\+\_\+t}]{port }\end{DoxyParamCaption})}



Set the local port number to which we bind. 

Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em port} & Local port number \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga3bfcfe6f09fa8f87dacb7ea215c64bae}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_priority@{osmo\_stream\_srv\_link\_set\_priority}}
\index{osmo\_stream\_srv\_link\_set\_priority@{osmo\_stream\_srv\_link\_set\_priority}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_priority()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+priority (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int}]{sk\+\_\+prio }\end{DoxyParamCaption})}



Set the priority value of the stream socket. 

Setting this will automatically set the socket priority option on any socket established via this server link, before calling the accept\+\_\+cb(). 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & server link whose sockets are to be configured \\
\hline
\mbox{\texttt{ in}}  & {\em sk\+\_\+prio} & priority value. Values outside 0..6 require CAP\+\_\+\+NET\+\_\+\+ADMIN. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
negative on error, 0 on success 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_ga2508987133a93863d2a50103004b0f36}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_proto@{osmo\_stream\_srv\_link\_set\_proto}}
\index{osmo\_stream\_srv\_link\_set\_proto@{osmo\_stream\_srv\_link\_set\_proto}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_proto()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+proto (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{uint16\+\_\+t}]{proto }\end{DoxyParamCaption})}



Set the protocol for the stream server link. 

Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em proto} & Protocol (like IPPROTO\+\_\+\+TCP (default), IPPROTO\+\_\+\+SCTP, ...) \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_gad88e9249699c53894cb34c099b5e0c4b}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_tx\_queue\_max\_length@{osmo\_stream\_srv\_link\_set\_tx\_queue\_max\_length}}
\index{osmo\_stream\_srv\_link\_set\_tx\_queue\_max\_length@{osmo\_stream\_srv\_link\_set\_tx\_queue\_max\_length}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_tx\_queue\_max\_length()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+tx\+\_\+queue\+\_\+max\+\_\+length (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{unsigned int}]{size }\end{DoxyParamCaption})}



Set the maximum length queue of the stream servers accepted and allocated from this server link. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em size} & maximum amount of msgbs which can be queued in the internal tx queue. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error.
\end{DoxyReturn}
The maximum length queue default value is 1024 msgbs. \mbox{\label{group__stream__srv_ga1903f9aa2e6f9283ebcf20f573b1d970}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_link\_set\_type@{osmo\_stream\_srv\_link\_set\_type}}
\index{osmo\_stream\_srv\_link\_set\_type@{osmo\_stream\_srv\_link\_set\_type}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_link\_set\_type()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+link\+\_\+set\+\_\+type (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv\+\_\+link $\ast$}]{link,  }\item[{int}]{type }\end{DoxyParamCaption})}



Set the socket type for the stream server link. 

Any changes to this setting will only become active upon next (re)connect. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em link} & Stream Server Link to modify \\
\hline
\mbox{\texttt{ in}}  & {\em type} & Socket Type (like SOCK\+\_\+\+STREAM (default), SOCK\+\_\+\+SEQPACKET, ...) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
zero on success, negative on error. 
\end{DoxyReturn}
\mbox{\label{group__stream__srv_gac86242c41223c525c770ff7e7515d83e}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_recv@{osmo\_stream\_srv\_recv}}
\index{osmo\_stream\_srv\_recv@{osmo\_stream\_srv\_recv}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_recv()}
{\footnotesize\ttfamily int osmo\+\_\+stream\+\_\+srv\+\_\+recv (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{struct msgb $\ast$}]{msg }\end{DoxyParamCaption})}



Receive data via an Osmocom stream server in osmo\+\_\+fd mode. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server from which to receive \\
\hline
 & {\em msg} & pre-\/allocate message buffer to which received data is appended \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bytes read, negative on error.
\end{DoxyReturn}
Application programs using the legacy osmo\+\_\+fd mode of osmo\+\_\+stream\+\_\+srv will use this function to read/receive from a stream socket after they have been notified that it is readable (via select/poll).

If conn is an SCTP connection, additional specific considerations shall be taken\+:
\begin{DoxyItemize}
\item msg-\/$>$cb is always filled with SCTP ppid, and SCTP stream values, see msgb\+\_\+sctp\+\_\+$\ast$() APIs.
\item If an SCTP notification was received when reading from the SCTP socket, msgb\+\_\+sctp\+\_\+msg\+\_\+flags(msg) will contain bit flag OSMO\+\_\+\+STREAM\+\_\+\+SCTP\+\_\+\+MSG\+\_\+\+FLAGS\+\_\+\+NOTIFICATION set, and the msgb will contain a \char`\"{}union sctp\+\_\+notification\char`\"{} instead of user data. In this case the return code will be either 0 (if conn is considered dead after the notification) or -\/EAGAIN (if conn is considered still alive after the notification) resembling the standard recv() API. 
\end{DoxyItemize}\mbox{\label{group__stream__srv_gaa1589994cf6eab27742cafee6b7fb491}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_send@{osmo\_stream\_srv\_send}}
\index{osmo\_stream\_srv\_send@{osmo\_stream\_srv\_send}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_send()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+send (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{struct msgb $\ast$}]{msg }\end{DoxyParamCaption})}



Enqueue data to be sent via an Osmocom stream server. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server through which we want to send \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & Message buffer to enqueue in transmit queue \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_gaed83d9686289eee534d77a61b96fbd90}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_closed\_cb@{osmo\_stream\_srv\_set\_closed\_cb}}
\index{osmo\_stream\_srv\_set\_closed\_cb@{osmo\_stream\_srv\_set\_closed\_cb}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_closed\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+closed\+\_\+cb (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{osmo\+\_\+stream\+\_\+srv\+\_\+closed\+\_\+cb\+\_\+t}]{closed\+\_\+cb }\end{DoxyParamCaption})}



Set the call-\/back function called when the stream server socket was closed. 

Whenever the socket was closed (network error, client disconnect, etc.), the user-\/provided call-\/back function given here is called. This is typically used by the application to clean up any of its internal state related to this specific client/connection. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server to modify \\
\hline
\mbox{\texttt{ in}}  & {\em closed\+\_\+cb} & Call-\/back function to be called when the connection was closed \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga9891663b20714d72f992e44ad1e92eea}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_data@{osmo\_stream\_srv\_set\_data}}
\index{osmo\_stream\_srv\_set\_data@{osmo\_stream\_srv\_set\_data}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_data()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+data (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Set application private data of the stream server. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server to modify \\
\hline
\mbox{\texttt{ in}}  & {\em data} & User-\/specific data (available in call-\/back functions) \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga8390ce6740e56eb22215e1c5805c95f1}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_flush\_and\_destroy@{osmo\_stream\_srv\_set\_flush\_and\_destroy}}
\index{osmo\_stream\_srv\_set\_flush\_and\_destroy@{osmo\_stream\_srv\_set\_flush\_and\_destroy}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_flush\_and\_destroy()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+flush\+\_\+and\+\_\+destroy (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn }\end{DoxyParamCaption})}



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__srv_ga47f18e063f64f22cb74d58d8b7243bed}. This function disables queuing of new messages on the connection and also disables reception of new messages on the connection. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server to modify \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga196834d254fd94922d6be91b7b5b1ed3}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_name@{osmo\_stream\_srv\_set\_name}}
\index{osmo\_stream\_srv\_set\_name@{osmo\_stream\_srv\_set\_name}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_name()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+name (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Set a name on the srv object (used during logging). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & server whose name is to be set. The name is copied into the osmo\+\_\+stream\+\_\+srv\+\_\+link, so the caller memory is not required to be valid beyond the call of this function. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & the name to be set on conn \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_gad0d7b7e236826c52f10a7b4f50009d01}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_read\_cb@{osmo\_stream\_srv\_set\_read\_cb}}
\index{osmo\_stream\_srv\_set\_read\_cb@{osmo\_stream\_srv\_set\_read\_cb}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_read\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+read\+\_\+cb (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{\textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+read\+\_\+cb2\+\_\+t}}]{read\+\_\+cb }\end{DoxyParamCaption})}



Set the call-\/back function for incoming data on an osmo\+\_\+io stream\+\_\+srv. 

This function only works with osmo\+\_\+stream\+\_\+srv in osmo\+\_\+io mode, created by \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+create2()}{p.}{group__stream__srv_ga8be283e1a143e346b4d6ccf33cbb9b98}!

Whenever data is received on the osmo\+\_\+stram\+\_\+srv, the read\+\_\+cb call-\/back function of the user application is called.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em conn} & Stream Server to modify \\
\hline
\mbox{\texttt{ in}}  & {\em read\+\_\+cb} & Call-\/back function to be called when data was read \\
\hline
\end{DoxyParams}
\mbox{\label{group__stream__srv_ga560a6d868bf95bf2f3a4b716bfd5cac9}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_segmentation\_cb@{osmo\_stream\_srv\_set\_segmentation\_cb}}
\index{osmo\_stream\_srv\_set\_segmentation\_cb@{osmo\_stream\_srv\_set\_segmentation\_cb}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_segmentation\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+segmentation\+\_\+cb (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb\+\_\+t}]{segmentation\+\_\+cb }\end{DoxyParamCaption})}



Set the segmentation callback for target osmo\+\_\+stream\+\_\+srv structure. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em conn} & Target Stream Server to modify \\
\hline
\mbox{\texttt{ in}}  & {\em segmentation\+\_\+cb} & Segmentation callback to be set\\
\hline
\end{DoxyParams}
A segmentation call-\/back can optionally be used when a packet based protocol (like TCP) is used within a STREAM style socket that does not preserve message boundaries within the stream. If a segmentation call-\/back is given, the osmo\+\_\+stream\+\_\+srv library code will makes sure that the read\+\_\+cb called only for complete single messages, and not arbitrary segments of the stream.

This function only works with osmo\+\_\+stream\+\_\+srv in osmo\+\_\+io mode, created by \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+create2()}{p.}{group__stream__srv_ga8be283e1a143e346b4d6ccf33cbb9b98}! The connection has to have been established prior to calling this function. \mbox{\label{group__stream__srv_ga348c4560f69403fc3a3dfcbe874c2593}} 
\index{Osmocom Stream Server@{Osmocom Stream Server}!osmo\_stream\_srv\_set\_segmentation\_cb2@{osmo\_stream\_srv\_set\_segmentation\_cb2}}
\index{osmo\_stream\_srv\_set\_segmentation\_cb2@{osmo\_stream\_srv\_set\_segmentation\_cb2}!Osmocom Stream Server@{Osmocom Stream Server}}
\doxysubsubsection{osmo\_stream\_srv\_set\_segmentation\_cb2()}
{\footnotesize\ttfamily void osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+segmentation\+\_\+cb2 (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+stream\+\_\+srv $\ast$}]{conn,  }\item[{osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb2\+\_\+t}]{segmentation\+\_\+cb2 }\end{DoxyParamCaption})}



Set the segmentation callback for target osmo\+\_\+stream\+\_\+srv structure. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em conn} & Target Stream Server to modify \\
\hline
\mbox{\texttt{ in}}  & {\em segmentation\+\_\+cb2} & Segmentation callback to be set\\
\hline
\end{DoxyParams}
Same as \doxyref{osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+segmentation\+\_\+cb()}{p.}{group__stream__srv_ga560a6d868bf95bf2f3a4b716bfd5cac9}, but a osmo\+\_\+stream\+\_\+srv\+\_\+segmentation\+\_\+cb2\+\_\+t is called instead which allows access to the related conn object. 