\doxysection{src/stream\+\_\+srv.c File Reference}
\label{stream__srv_8c}\index{src/stream\_srv.c@{src/stream\_srv.c}}
{\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/un.\+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/osmo\+\_\+io.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/panic.\+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 $<$osmocom/netif/stream\+\_\+private.\+h$>$}\newline
{\ttfamily \#include "{}config.\+h"{}}\newline
{\ttfamily \#include $<$osmocom/netif/sctp.\+h$>$}\newline
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ LOGSLNK}(link,  level,  fmt,  args...)
\item 
\#define \textbf{ LOGSSRV}(srv,  level,  fmt,  args...)
\item 
\label{stream__srv_8c_af1646f040c66d93634755e299dee3ec2} 
\#define {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+F\+\_\+\+RECONF}~(1 $<$$<$ 0)
\item 
\label{stream__srv_8c_aeec66e7d4031dc9606558e6692a805ba} 
\#define {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+F\+\_\+\+NODELAY}~(1 $<$$<$ 1)
\item 
\label{stream__srv_8c_a3ef7f446bbf20daa6188bdaade5b2e94} 
\#define {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+SRV\+\_\+\+F\+\_\+\+FLUSH\+\_\+\+DESTROY}~(1 $<$$<$ 0)
\end{DoxyCompactItemize}
\doxysubsubsection*{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\+\_\+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 domain for 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 
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 
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 
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 
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 
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 
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 
void \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+name\+\_\+f} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, const char $\ast$fmt,...)
\begin{DoxyCompactList}\small\item\em Set a name on the srv object using arguments like printf() (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 \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 $\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 
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 
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 
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\+\_\+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 
void {\bfseries osmo\+\_\+stream\+\_\+srv\+\_\+clear\+\_\+tx\+\_\+queue} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn)
\item 
int \textbf{ osmo\+\_\+stream\+\_\+srv\+\_\+set\+\_\+param} (struct osmo\+\_\+stream\+\_\+srv $\ast$conn, enum osmo\+\_\+stream\+\_\+srv\+\_\+param par, void $\ast$val, size\+\_\+t val\+\_\+len)
\begin{DoxyCompactList}\small\item\em Set given parameter of stream\+\_\+srv to given value. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Macro Definition Documentation}
\label{stream__srv_8c_a342e0d6b27c088873e909cf519a9b625} 
\index{stream\_srv.c@{stream\_srv.c}!LOGSLNK@{LOGSLNK}}
\index{LOGSLNK@{LOGSLNK}!stream\_srv.c@{stream\_srv.c}}
\doxysubsubsection{LOGSLNK}
{\footnotesize\ttfamily \#define LOGSLNK(\begin{DoxyParamCaption}\item[{}]{link,  }\item[{}]{level,  }\item[{}]{fmt,  }\item[{}]{args... }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{\ \ \ \ \ \ \ \ LOGP(DLINP,\ level,\ \textcolor{stringliteral}{"{}SRV(\%s,\%s)\ "{}}\ fmt,\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ link-\/>name\ ?\ :\ \textcolor{stringliteral}{"{}"{}},\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ link-\/>sockname,\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\ args)}

\end{DoxyCode}
\label{stream__srv_8c_a3f350c591ee22c0d8505b4f25d19b739} 
\index{stream\_srv.c@{stream\_srv.c}!LOGSSRV@{LOGSSRV}}
\index{LOGSSRV@{LOGSSRV}!stream\_srv.c@{stream\_srv.c}}
\doxysubsubsection{LOGSSRV}
{\footnotesize\ttfamily \#define LOGSSRV(\begin{DoxyParamCaption}\item[{}]{srv,  }\item[{}]{level,  }\item[{}]{fmt,  }\item[{}]{args... }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{\ \ \ \ \ \ \ \ LOGP(DLINP,\ level,\ \textcolor{stringliteral}{"{}SRVCONN(\%s,\%s)\ "{}}\ fmt,\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ srv-\/>name\ ?\ :\ \textcolor{stringliteral}{"{}"{}},\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ srv-\/>sockname,\ \(\backslash\)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \#\#\ args)}

\end{DoxyCode}
