\doxysection{src/stream\+\_\+cli.c File Reference}
\label{stream__cli_8c}\index{src/stream\_cli.c@{src/stream\_cli.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/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 \char`\"{}config.\+h\char`\"{}}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ LOGSCLI}(cli,  level,  fmt,  args...)
\item 
\mbox{\label{stream__cli_8c_ae24e1d7bb86fa7bd90b7f38e0c686119}} 
\#define {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+CLI\+\_\+\+F\+\_\+\+RECONF}~(1 $<$$<$ 0)
\item 
\mbox{\label{stream__cli_8c_accd8b711532f890d484fb9099f555855}} 
\#define {\bfseries OSMO\+\_\+\+STREAM\+\_\+\+CLI\+\_\+\+F\+\_\+\+NODELAY}~(1 $<$$<$ 1)
\item 
\mbox{\label{stream__cli_8c_a3abf34c81ff1b171b90ad13ba6db2cc9}} 
\#define {\bfseries IN\+\_\+\+CB\+\_\+\+MASK\+\_\+\+CONNECT\+\_\+\+CB}~(1 $<$$<$ 0)
\item 
\mbox{\label{stream__cli_8c_a50df9ebfa0dfeb506246cb9bdd3bbe6e}} 
\#define {\bfseries IN\+\_\+\+CB\+\_\+\+MASK\+\_\+\+DISCONNECT\+\_\+\+CB}~(1 $<$$<$ 1)
\item 
\mbox{\label{stream__cli_8c_a2bfc3235d512ff6ee0b107eb276d9374}} 
\#define {\bfseries IN\+\_\+\+CB\+\_\+\+MASK\+\_\+\+READ\+\_\+\+CB}~(1 $<$$<$ 2)
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{stream__cli_8c_aefb240abea020971d9a384b5e39826e5}} 
enum {\bfseries osmo\+\_\+stream\+\_\+cli\+\_\+state} \{ \newline
{\bfseries STREAM\+\_\+\+CLI\+\_\+\+STATE\+\_\+\+CLOSED}
, {\bfseries STREAM\+\_\+\+CLI\+\_\+\+STATE\+\_\+\+WAIT\+\_\+\+RECONNECT}
, {\bfseries STREAM\+\_\+\+CLI\+\_\+\+STATE\+\_\+\+CONNECTING}
, {\bfseries STREAM\+\_\+\+CLI\+\_\+\+STATE\+\_\+\+CONNECTED}
, \newline
{\bfseries STREAM\+\_\+\+CLI\+\_\+\+STATE\+\_\+\+MAX}
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+close} (struct 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 osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Re-\/connect an Osmocom Stream Client. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+is\+\_\+connected} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Check if Osmocom Stream Client is in connected state. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+fd} (const struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve file descriptor of the stream client socket. \end{DoxyCompactList}\item 
struct osmo\+\_\+io\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+iofd} (const struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve osmo\+\_\+io descriptor of the stream client socket. \end{DoxyCompactList}\item 
struct 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\+\_\+name} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Set a name on the cli object (used during logging). \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+name\+\_\+f} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, const char $\ast$fmt,...)
\begin{DoxyCompactList}\small\item\em Set a name on the cli object using arguments like printf() (used during logging). \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+name} (const struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve name previously set on the cli object (see \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+name()}{p.}{group__stream__cli_gaeb712dc553735736047f9b11d9583baa}). \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+addr} (struct 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 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. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+port} (struct 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 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 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 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 bind. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+proto} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, uint16\+\_\+t proto)
\begin{DoxyCompactList}\small\item\em Set the protocol for the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+segmentation\+\_\+cb} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, osmo\+\_\+stream\+\_\+cli\+\_\+segmentation\+\_\+cb\+\_\+t segmentation\+\_\+cb)
\begin{DoxyCompactList}\small\item\em Set the segmentation callback for the client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+segmentation\+\_\+cb2} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, osmo\+\_\+stream\+\_\+cli\+\_\+segmentation\+\_\+cb2\+\_\+t segmentation\+\_\+cb2)
\begin{DoxyCompactList}\small\item\em Set the segmentation callback for the client. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+type} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, int type)
\begin{DoxyCompactList}\small\item\em Set the socket type for the stream client. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+domain} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, int domain)
\begin{DoxyCompactList}\small\item\em Set the socket domain for the stream client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout} (struct 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 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 osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve application private data of the stream client socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+tx\+\_\+queue\+\_\+max\+\_\+length} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, unsigned int size)
\begin{DoxyCompactList}\small\item\em Set the maximum length queue of the stream client. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+sockname} (const struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve the stream client socket description. \end{DoxyCompactList}\item 
struct osmo\+\_\+fd $\ast$ \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+get\+\_\+ofd} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Retrieve Osmocom File Descriptor of the stream client socket. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+connect\+\_\+cb} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, osmo\+\_\+stream\+\_\+cli\+\_\+connect\+\_\+cb\+\_\+t connect\+\_\+cb)
\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 osmo\+\_\+stream\+\_\+cli $\ast$cli, osmo\+\_\+stream\+\_\+cli\+\_\+disconnect\+\_\+cb\+\_\+t disconnect\+\_\+cb)
\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 osmo\+\_\+stream\+\_\+cli $\ast$cli, osmo\+\_\+stream\+\_\+cli\+\_\+read\+\_\+cb\+\_\+t read\+\_\+cb)
\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\+\_\+set\+\_\+read\+\_\+cb2} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+read\+\_\+cb2\+\_\+t} read\+\_\+cb)
\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 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 osmo\+\_\+stream\+\_\+cli $\ast$cli, int reconnect)
\begin{DoxyCompactList}\small\item\em DEPRECATED\+: use \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+reconnect\+\_\+timeout()}{p.}{group__stream__cli_gade74792afe35f31dd2584c888db3dd62} or \doxyref{osmo\+\_\+stream\+\_\+cli\+\_\+reconnect()}{p.}{group__stream__cli_ga11d2615f6197f33073ba7245e5ba95ee} instead! Open connection of an Osmocom stream client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+nodelay} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, bool nodelay)
\begin{DoxyCompactList}\small\item\em Set the NODELAY socket option to avoid Nagle-\/like behavior. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+priority} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, int sk\+\_\+prio)
\begin{DoxyCompactList}\small\item\em Set the priority value of the stream socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+ip\+\_\+dscp} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, uint8\+\_\+t ip\+\_\+dscp)
\begin{DoxyCompactList}\small\item\em Set the DSCP (differentiated services code point) of the stream socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+open} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Open connection of an Osmocom stream client. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+send} (struct 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 osmo\+\_\+stream\+\_\+cli $\ast$cli, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Receive data via an Osmocom stream client in osmo\+\_\+fd mode. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+clear\+\_\+tx\+\_\+queue} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli)
\begin{DoxyCompactList}\small\item\em Clear the transmit queue of the stream client. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+stream\+\_\+cli\+\_\+set\+\_\+param} (struct osmo\+\_\+stream\+\_\+cli $\ast$cli, enum osmo\+\_\+stream\+\_\+cli\+\_\+param par, void $\ast$val, size\+\_\+t val\+\_\+len)
\begin{DoxyCompactList}\small\item\em Set given parameter of stream client to given value. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Macro Definition Documentation}
\mbox{\label{stream__cli_8c_a93406b98c0c2fa90d3d12b13d5bd63ac}} 
\index{stream\_cli.c@{stream\_cli.c}!LOGSCLI@{LOGSCLI}}
\index{LOGSCLI@{LOGSCLI}!stream\_cli.c@{stream\_cli.c}}
\doxysubsubsection{LOGSCLI}
{\footnotesize\ttfamily \#define LOGSCLI(\begin{DoxyParamCaption}\item[{}]{cli,  }\item[{}]{level,  }\item[{}]{fmt,  }\item[{}]{args... }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        LOGP(DLINP, level, \textcolor{stringliteral}{"{}CLICONN(\%s,\%s)\{\%s\} "{}} fmt, \(\backslash\)}
\DoxyCodeLine{             cli-\/>name ? : \textcolor{stringliteral}{"{}"{}}, \(\backslash\)}
\DoxyCodeLine{             cli-\/>sockname, \(\backslash\)}
\DoxyCodeLine{             get\_value\_string(stream\_cli\_state\_names, (cli)-\/>state), \(\backslash\)}
\DoxyCodeLine{             \#\# args)}

\end{DoxyCode}
