\doxysection{include/osmocom/ctrl/control\+\_\+if.h File Reference}
\label{control__if_8h}\index{include/osmocom/ctrl/control\_if.h@{include/osmocom/ctrl/control\_if.h}}
{\ttfamily \#include $<$osmocom/core/write\+\_\+queue.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/ctrl/control\+\_\+cmd.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ ctrl\+\_\+handle}
\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef int($\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+lookup}) (void $\ast$\textbf{ data}, \textbf{ vector} vline, int $\ast$\textbf{ node\+\_\+type}, void $\ast$$\ast$node\+\_\+data, int $\ast$i)
\item 
typedef void($\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+reply\+\_\+cb}) (struct \textbf{ ctrl\+\_\+handle} $\ast$ctrl, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd, void $\ast$\textbf{ data})
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ ctrl\+\_\+parse\+\_\+get\+\_\+num} (\textbf{ vector} vline, int i, long $\ast$num)
\begin{DoxyCompactList}\small\item\em Parse ascii-\/encoded decimal number at vline[i]. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+send} (struct \textbf{ osmo\+\_\+wqueue} $\ast$queue, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd) \textbf{ OSMO\+\_\+\+DEPRECATED}(\char`\"{}Use \textbf{ ctrl\+\_\+cmd\+\_\+send2}() instead.\char`\"{})
\begin{DoxyCompactList}\small\item\em Encode a CTRL command and append it to the given \doxyref{ctrl\+\_\+connection}{p.}{structctrl__connection}. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+send2} (struct \textbf{ ctrl\+\_\+connection} $\ast$ccon, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd)
\begin{DoxyCompactList}\small\item\em Encode a CTRL command and append it to the given \doxyref{ctrl\+\_\+connection}{p.}{structctrl__connection}. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+send\+\_\+trap} (struct \textbf{ ctrl\+\_\+handle} $\ast$ctrl, const char $\ast$\textbf{ name}, char $\ast$value)
\begin{DoxyCompactList}\small\item\em Send TRAP over given Control Interface. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+handle\+\_\+alloc} (void $\ast$ctx, void $\ast$\textbf{ data}, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup)
\begin{DoxyCompactList}\small\item\em Allocate a CTRL interface handle. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+handle\+\_\+alloc2} (void $\ast$ctx, void $\ast$\textbf{ data}, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup, unsigned int node\+\_\+count)
\begin{DoxyCompactList}\small\item\em Allocate a CTRL interface handle. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+interface\+\_\+setup} (void $\ast$\textbf{ data}, uint16\+\_\+t port, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup)
\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+interface\+\_\+setup2} (void $\ast$\textbf{ data}, uint16\+\_\+t default\+\_\+port, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup, unsigned int node\+\_\+count)
\begin{DoxyCompactList}\small\item\em Initializes CTRL interface using the configured bind addr/port. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip} (void $\ast$\textbf{ data}, const char $\ast$bind\+\_\+addr, uint16\+\_\+t port, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup) \textbf{ OSMO\+\_\+\+DEPRECATED\+\_\+\+OUTSIDE\+\_\+\+LIBOSMOCORE}
\begin{DoxyCompactList}\small\item\em Setup CTRL interface on a given address. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+handle} $\ast$ \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2} (void $\ast$\textbf{ data}, const char $\ast$bind\+\_\+addr, uint16\+\_\+t port, \textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup, unsigned int node\+\_\+count) \textbf{ OSMO\+\_\+\+DEPRECATED\+\_\+\+OUTSIDE\+\_\+\+LIBOSMOCORE}
\begin{DoxyCompactList}\small\item\em Setup CTRL interface on a given address. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+connection} $\ast$ \textbf{ osmo\+\_\+ctrl\+\_\+conn\+\_\+alloc} (void $\ast$ctx, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Allocate CTRL connection. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+handle} (struct \textbf{ ctrl\+\_\+handle} $\ast$ctrl, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd, void $\ast$\textbf{ data})
\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+exec\+\_\+from\+\_\+string} (struct \textbf{ ctrl\+\_\+handle} $\ast$ch, const char $\ast$cmdstr)
\begin{DoxyCompactList}\small\item\em Helper for \char`\"{}local execution\char`\"{} of a CTRL command from a string The function will parse + execute the given control command string and return a corresponding \doxyref{ctrl\+\_\+cmd}{p.}{structctrl__cmd}. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+lookup\+\_\+register} (\textbf{ ctrl\+\_\+cmd\+\_\+lookup} lookup)
\begin{DoxyCompactList}\small\item\em Install a lookup helper function for control nodes This function is used by e.\+g. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+handle\+\_\+msg} (struct \textbf{ ctrl\+\_\+handle} $\ast$ctrl, struct \textbf{ ctrl\+\_\+connection} $\ast$ccon, struct \textbf{ msgb} $\ast$\textbf{ msg})
\begin{DoxyCompactList}\small\item\em Handle a received CTRL command contained in a \textbf{ Message buffers}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Typedef Documentation}
\mbox{\label{control__if_8h_a9cf93dcc7af6485216ff332966dd9c09}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_lookup@{ctrl\_cmd\_lookup}}
\index{ctrl\_cmd\_lookup@{ctrl\_cmd\_lookup}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_lookup}
{\footnotesize\ttfamily typedef int($\ast$ ctrl\+\_\+cmd\+\_\+lookup) (void $\ast$\textbf{ data}, \textbf{ vector} vline, int $\ast$\textbf{ node\+\_\+type}, void $\ast$$\ast$node\+\_\+data, int $\ast$i)}

\mbox{\label{control__if_8h_a06303a3dfb5debef99ecb539079e6db0}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_reply\_cb@{ctrl\_cmd\_reply\_cb}}
\index{ctrl\_cmd\_reply\_cb@{ctrl\_cmd\_reply\_cb}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_reply\_cb}
{\footnotesize\ttfamily typedef void($\ast$ ctrl\+\_\+cmd\+\_\+reply\+\_\+cb) (struct \textbf{ ctrl\+\_\+handle} $\ast$ctrl, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd, void $\ast$\textbf{ data})}



\doxysubsection{Function Documentation}
\mbox{\label{control__if_8h_affafcd805595604f1e164f5f7b96cfc5}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_exec\_from\_string@{ctrl\_cmd\_exec\_from\_string}}
\index{ctrl\_cmd\_exec\_from\_string@{ctrl\_cmd\_exec\_from\_string}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_exec\_from\_string()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+exec\+\_\+from\+\_\+string (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+handle} $\ast$}]{ch,  }\item[{const char $\ast$}]{cmdstr }\end{DoxyParamCaption})}



Helper for \char`\"{}local execution\char`\"{} of a CTRL command from a string The function will parse + execute the given control command string and return a corresponding \doxyref{ctrl\+\_\+cmd}{p.}{structctrl__cmd}. 

Caller is responsible to talloc\+\_\+free() the return value. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em Control} & Interface Command String \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
parsed command, including reply; NULL on error 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+handle()}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+HANDLED}, \textbf{ ctrl\+\_\+cmd\+\_\+parse2()}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ msg}, \textbf{ msgb\+\_\+alloc()}, \textbf{ msgb\+\_\+free()}, \textbf{ msgb\+\_\+put()}, \textbf{ msgb\+\_\+tailroom()}, \textbf{ osmo\+\_\+strlcpy()}, and \textbf{ ctrl\+\_\+cmd\+::type}.

\mbox{\label{control__if_8h_a8879414ec4d516079cedc58b39d2c990}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_handle@{ctrl\_cmd\_handle}}
\index{ctrl\_cmd\_handle@{ctrl\_cmd\_handle}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_handle()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+handle (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+handle} $\ast$}]{ctrl,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



References \textbf{ ctrl\+\_\+cmd\+\_\+def\+::cmd}, \textbf{ cmd\+\_\+free\+\_\+strvec()}, \textbf{ cmd\+\_\+make\+\_\+strvec()}, \textbf{ cmdvec}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+ERROR}, \textbf{ ctrl\+\_\+cmd\+\_\+exec()}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+HANDLED}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+NODE\+\_\+\+ROOT}, \textbf{ ctrl\+\_\+node\+\_\+vec}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET\+\_\+\+REPLY}, \textbf{ ctrl\+\_\+type\+\_\+vals}, \textbf{ data}, \textbf{ DLCTRL}, \textbf{ get\+\_\+value\+\_\+string()}, \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ LOGL\+\_\+\+DEBUG}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ ctrl\+\_\+handle\+::lookup}, \textbf{ lookup\+\_\+helper\+::lookup}, \textbf{ node}, \textbf{ ctrl\+\_\+cmd\+::node}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ ctrl\+\_\+handle\+::reply\+\_\+cb}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::variable}, \textbf{ vector\+\_\+active}, \textbf{ vector\+\_\+free()}, \textbf{ vector\+\_\+init()}, \textbf{ vector\+\_\+lookup()}, \textbf{ vector\+\_\+set()}, and \textbf{ vector\+\_\+slot}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+exec\+\_\+from\+\_\+string()}, and \textbf{ ctrl\+\_\+handle\+\_\+msg()}.

\mbox{\label{control__if_8h_a30e330468442167276a894ed56867088}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_send@{ctrl\_cmd\_send}}
\index{ctrl\_cmd\_send@{ctrl\_cmd\_send}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_send()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+send (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+wqueue} $\ast$}]{queue,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd }\end{DoxyParamCaption})}



Encode a CTRL command and append it to the given \doxyref{ctrl\+\_\+connection}{p.}{structctrl__connection}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em queue} & write queue to which encoded {\itshape cmd} shall be appended \\
\hline
\mbox{\texttt{ in}}  & {\em cmd} & decoded command representation \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 in case of success; negative on error 
\end{DoxyReturn}
\mbox{\label{control__if_8h_a333b790a8ea3d108265bc8cb633634dc}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_send2@{ctrl\_cmd\_send2}}
\index{ctrl\_cmd\_send2@{ctrl\_cmd\_send2}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_send2()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+send2 (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+connection} $\ast$}]{ccon,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd }\end{DoxyParamCaption})}



Encode a CTRL command and append it to the given \doxyref{ctrl\+\_\+connection}{p.}{structctrl__connection}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em queue} & write queue to which encoded {\itshape cmd} shall be appended \\
\hline
\mbox{\texttt{ in}}  & {\em cmd} & decoded command representation \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 in case of success; negative on error 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+make()}, \textbf{ DLCTRL}, \textbf{ ipa\+\_\+prepend\+\_\+header()}, \textbf{ ipa\+\_\+prepend\+\_\+header\+\_\+ext()}, \textbf{ IPAC\+\_\+\+PROTO\+\_\+\+EXT\+\_\+\+CTRL}, \textbf{ IPAC\+\_\+\+PROTO\+\_\+\+OSMO}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msgb\+\_\+free()}, \textbf{ osmo\+\_\+wqueue\+\_\+enqueue()}, and \textbf{ ctrl\+\_\+connection\+::write\+\_\+queue}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+def\+\_\+send()}, \textbf{ ctrl\+\_\+cmd\+\_\+send()}, \textbf{ ctrl\+\_\+cmd\+\_\+send\+\_\+to\+\_\+all()}, and \textbf{ ctrl\+\_\+handle\+\_\+msg()}.

\mbox{\label{control__if_8h_ad0e8f381fedade3a380010189d574243}} 
\index{control\_if.h@{control\_if.h}!ctrl\_cmd\_send\_trap@{ctrl\_cmd\_send\_trap}}
\index{ctrl\_cmd\_send\_trap@{ctrl\_cmd\_send\_trap}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_cmd\_send\_trap()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+send\+\_\+trap (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+handle} $\ast$}]{ctrl,  }\item[{const char $\ast$}]{name,  }\item[{char $\ast$}]{value }\end{DoxyParamCaption})}



Send TRAP over given Control Interface. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctrl} & Control Interface over which TRAP will be sent \\
\hline
\mbox{\texttt{ in}}  & {\em name} & Name of the TRAP variable \\
\hline
\mbox{\texttt{ in}}  & {\em value} & Value of the TRAP variable \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Negative value on error, result of \doxyref{ctrl\+\_\+cmd\+\_\+send\+\_\+to\+\_\+all()}{p.}{control__if_8c_a68a762ce294f8c17c41fca2410df76b5} otherwise 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+create()}, \textbf{ ctrl\+\_\+cmd\+\_\+send\+\_\+to\+\_\+all()}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+TRAP\+\_\+\+ID}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+TRAP}, \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ name}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ ctrl\+\_\+cmd\+::value}, and \textbf{ ctrl\+\_\+cmd\+::variable}.

\mbox{\label{control__if_8h_a9c07f83fe1a90d038d3a0e65e2820880}} 
\index{control\_if.h@{control\_if.h}!ctrl\_handle\_alloc@{ctrl\_handle\_alloc}}
\index{ctrl\_handle\_alloc@{ctrl\_handle\_alloc}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_handle\_alloc()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+handle\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{void $\ast$}]{data,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup }\end{DoxyParamCaption})}



Allocate a CTRL interface handle. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & Talloc allocation context to be used \\
\hline
\mbox{\texttt{ in}}  & {\em data} & Pointer which will be made available to each set\+\_\+..() get\+\_\+..() verify\+\_\+..() control command function \\
\hline
\mbox{\texttt{ in}}  & {\em lookup} & Lookup function pointer, can be NULL \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{ctrl\+\_\+handle}{p.}{structctrl__handle} pointer or NULL in case of errors 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+handle\+\_\+alloc2()}, \textbf{ data}, and \textbf{ ctrl\+\_\+handle\+::lookup}.

\mbox{\label{control__if_8h_aaf1128fc2d419f0cefe229c71ebf6781}} 
\index{control\_if.h@{control\_if.h}!ctrl\_handle\_alloc2@{ctrl\_handle\_alloc2}}
\index{ctrl\_handle\_alloc2@{ctrl\_handle\_alloc2}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_handle\_alloc2()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+handle\+\_\+alloc2 (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{void $\ast$}]{data,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup,  }\item[{unsigned int}]{node\+\_\+count }\end{DoxyParamCaption})}



Allocate a CTRL interface handle. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & Talloc allocation context to be used \\
\hline
\mbox{\texttt{ in}}  & {\em data} & Pointer which will be made available to each set\+\_\+..() get\+\_\+..() verify\+\_\+..() control command function \\
\hline
\mbox{\texttt{ in}}  & {\em lookup} & Lookup function pointer, can be NULL \\
\hline
\mbox{\texttt{ in}}  & {\em node\+\_\+count} & Number of CTRL nodes to allocate, 0 for default. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{ctrl\+\_\+handle}{p.}{structctrl__handle} pointer or NULL in case of errors
\end{DoxyReturn}
Please see \doxyref{ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2()}{p.}{control__if_8c_a35786d463b20f1100beaa6a0bdd9d73e} for a detailed description of {\itshape node\+\_\+count} semantics. 

References \textbf{ ctrl\+\_\+handle\+::ccon\+\_\+list}, \textbf{ ctrl\+\_\+init()}, \textbf{ data}, \textbf{ ctrl\+\_\+handle\+::data}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, and \textbf{ ctrl\+\_\+handle\+::lookup}.



Referenced by \textbf{ ctrl\+\_\+handle\+\_\+alloc()}, and \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2()}.

\mbox{\label{control__if_8h_abebb5f7b19121559a493b6822036fe82}} 
\index{control\_if.h@{control\_if.h}!ctrl\_handle\_msg@{ctrl\_handle\_msg}}
\index{ctrl\_handle\_msg@{ctrl\_handle\_msg}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_handle\_msg()}
{\footnotesize\ttfamily int ctrl\+\_\+handle\+\_\+msg (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+handle} $\ast$}]{ctrl,  }\item[{struct \textbf{ ctrl\+\_\+connection} $\ast$}]{ccon,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})}



Handle a received CTRL command contained in a \textbf{ Message buffers}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctrl} & CTRL interface handle \\
\hline
\mbox{\texttt{ in}}  & {\em ccon} & CTRL connection through which the command was received \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing CTRL command including IPA+\+IPA\+\_\+\+EXT headers \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ ctrl\+\_\+cmd\+::ccon}, \textbf{ ctrl\+\_\+cmd\+\_\+handle()}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+HANDLED}, \textbf{ ctrl\+\_\+cmd\+\_\+parse3()}, \textbf{ ctrl\+\_\+cmd\+\_\+send2()}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ ctrl\+\_\+type\+\_\+vals}, \textbf{ ipaccess\+\_\+head\+::data}, \textbf{ ipaccess\+\_\+head\+\_\+ext\+::data}, \textbf{ ctrl\+\_\+handle\+::data}, \textbf{ ctrl\+\_\+cmd\+::defer}, \textbf{ DLCTRL}, \textbf{ DLINP}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ get\+\_\+value\+\_\+string()}, \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ if()}, \textbf{ ipa\+\_\+ccm\+\_\+send\+\_\+id\+\_\+ack()}, \textbf{ ipa\+\_\+ccm\+\_\+send\+\_\+pong()}, \textbf{ IPAC\+\_\+\+MSGT\+\_\+\+ID\+\_\+\+ACK}, \textbf{ IPAC\+\_\+\+MSGT\+\_\+\+PING}, \textbf{ IPAC\+\_\+\+MSGT\+\_\+\+PONG}, \textbf{ IPAC\+\_\+\+PROTO\+\_\+\+EXT\+\_\+\+CTRL}, \textbf{ IPAC\+\_\+\+PROTO\+\_\+\+IPACCESS}, \textbf{ IPAC\+\_\+\+PROTO\+\_\+\+OSMO}, \textbf{ LOGL\+\_\+\+DEBUG}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msg\+\_\+type}, \textbf{ msgb\+\_\+hexdump()}, \textbf{ ipaccess\+\_\+head\+::proto}, \textbf{ ipaccess\+\_\+head\+\_\+ext\+::proto}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::variable}, and \textbf{ ctrl\+\_\+connection\+::write\+\_\+queue}.



Referenced by \textbf{ handle\+\_\+control\+\_\+read()}.

\mbox{\label{control__if_8h_ab887e2f076614ba799229a404f872d85}} 
\index{control\_if.h@{control\_if.h}!ctrl\_interface\_setup@{ctrl\_interface\_setup}}
\index{ctrl\_interface\_setup@{ctrl\_interface\_setup}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_interface\_setup()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+interface\+\_\+setup (\begin{DoxyParamCaption}\item[{void $\ast$}]{data,  }\item[{uint16\+\_\+t}]{port,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup }\end{DoxyParamCaption})}



References \textbf{ ctrl\+\_\+interface\+\_\+setup2()}, \textbf{ data}, and \textbf{ ctrl\+\_\+handle\+::lookup}.

\mbox{\label{control__if_8h_a06d01723e9d328b7dcf6dde2bf4824ad}} 
\index{control\_if.h@{control\_if.h}!ctrl\_interface\_setup2@{ctrl\_interface\_setup2}}
\index{ctrl\_interface\_setup2@{ctrl\_interface\_setup2}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_interface\_setup2()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+interface\+\_\+setup2 (\begin{DoxyParamCaption}\item[{void $\ast$}]{data,  }\item[{uint16\+\_\+t}]{default\+\_\+port,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup,  }\item[{unsigned int}]{node\+\_\+count }\end{DoxyParamCaption})}



Initializes CTRL interface using the configured bind addr/port. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em data} & Pointer which will be made available to each set\+\_\+..() get\+\_\+..() verify\+\_\+..() control command function \\
\hline
\mbox{\texttt{ in}}  & {\em default\+\_\+port} & TCP port number to bind to if not explicitly configured \\
\hline
\mbox{\texttt{ in}}  & {\em lookup} & Lookup function pointer, can be NULL \\
\hline
\mbox{\texttt{ in}}  & {\em node\+\_\+count} & Number of CTRL nodes to allocate, 0 for default. \\
\hline
\end{DoxyParams}


References \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2()}, \textbf{ ctrl\+\_\+vty\+\_\+get\+\_\+bind\+\_\+addr()}, \textbf{ ctrl\+\_\+vty\+\_\+get\+\_\+bind\+\_\+port()}, \textbf{ data}, and \textbf{ ctrl\+\_\+handle\+::lookup}.



Referenced by \textbf{ ctrl\+\_\+interface\+\_\+setup()}.

\mbox{\label{control__if_8h_a96ad50604586793baa3e83a16d6d2ae4}} 
\index{control\_if.h@{control\_if.h}!ctrl\_interface\_setup\_dynip@{ctrl\_interface\_setup\_dynip}}
\index{ctrl\_interface\_setup\_dynip@{ctrl\_interface\_setup\_dynip}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_interface\_setup\_dynip()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip (\begin{DoxyParamCaption}\item[{void $\ast$}]{data,  }\item[{const char $\ast$}]{bind\+\_\+addr,  }\item[{uint16\+\_\+t}]{port,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup }\end{DoxyParamCaption})}



Setup CTRL interface on a given address. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em data} & Pointer which will be made available to each set\+\_\+..() get\+\_\+..() verify\+\_\+..() control command function \\
\hline
\mbox{\texttt{ in}}  & {\em bind\+\_\+addr} & Address on which CTRL socket shall listen \\
\hline
\mbox{\texttt{ in}}  & {\em port} & Port on which CTRL socket shall listen \\
\hline
\mbox{\texttt{ in}}  & {\em lookup} & Lookup function pointer, can be NULL \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{ctrl\+\_\+handle}{p.}{structctrl__handle} pointer or NULL in case of errors 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2()}, \textbf{ data}, and \textbf{ ctrl\+\_\+handle\+::lookup}.

\mbox{\label{control__if_8h_a06a35bf81632643d15bb70a18287566d}} 
\index{control\_if.h@{control\_if.h}!ctrl\_interface\_setup\_dynip2@{ctrl\_interface\_setup\_dynip2}}
\index{ctrl\_interface\_setup\_dynip2@{ctrl\_interface\_setup\_dynip2}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_interface\_setup\_dynip2()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+handle} $\ast$ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip2 (\begin{DoxyParamCaption}\item[{void $\ast$}]{data,  }\item[{const char $\ast$}]{bind\+\_\+addr,  }\item[{uint16\+\_\+t}]{port,  }\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup,  }\item[{unsigned int}]{node\+\_\+count }\end{DoxyParamCaption})}



Setup CTRL interface on a given address. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em data} & Pointer which will be made available to each set\+\_\+..() get\+\_\+..() verify\+\_\+..() control command function \\
\hline
\mbox{\texttt{ in}}  & {\em bind\+\_\+addr} & Address on which CTRL socket shall listen \\
\hline
\mbox{\texttt{ in}}  & {\em port} & Port on which CTRL socket shall listen \\
\hline
\mbox{\texttt{ in}}  & {\em lookup} & Lookup function pointer, can be NULL \\
\hline
\mbox{\texttt{ in}}  & {\em node\+\_\+count} & Number of CTRL nodes to allocate, 0 for default. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{ctrl\+\_\+handle}{p.}{structctrl__handle} pointer or NULL in case of errors
\end{DoxyReturn}
Control interface nodes are identified by a node handle; some of these are defined in enum ctrl\+\_\+node\+\_\+type, here in libosmocore. However, applications defining own nodes may add own control nodes without having to extend the enum in libosmocore. For example, in the calling application, define an enum like \char`\"{}enum more\+\_\+ctrl\+\_\+nodes \{ CTRL\+\_\+\+NODE\+\_\+\+FOO = \+\_\+\+LAST\+\_\+\+CTRL\+\_\+\+NODE, CTRL\+\_\+\+NODE\+\_\+\+BAR, \+\_\+\+LAST\+\_\+\+CTRL\+\_\+\+NODE\+\_\+\+EXTENDED \}\char`\"{}. In order to provide space for the additional control nodes, pass \+\_\+\+LAST\+\_\+\+CTRL\+\_\+\+NODE\+\_\+\+EXTENDED to the {\itshape node\+\_\+count} parameter. Passing 0 is identical to passing \+\_\+\+LAST\+\_\+\+CTRL\+\_\+\+NODE, i.\+e. to not define own control nodes apart from libosmocore ones. 

References \textbf{ osmo\+\_\+fd\+::cb}, \textbf{ ctrl\+\_\+handle\+\_\+alloc2()}, \textbf{ osmo\+\_\+fd\+::data}, \textbf{ data}, \textbf{ DLCTRL}, \textbf{ ctrl\+\_\+handle\+::listen\+\_\+fd}, \textbf{ listen\+\_\+fd\+\_\+cb()}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ ctrl\+\_\+handle\+::lookup}, \textbf{ OSMO\+\_\+\+SOCK\+\_\+\+F\+\_\+\+BIND}, and \textbf{ osmo\+\_\+sock\+\_\+init\+\_\+ofd()}.



Referenced by \textbf{ ctrl\+\_\+interface\+\_\+setup2()}, and \textbf{ ctrl\+\_\+interface\+\_\+setup\+\_\+dynip()}.

\mbox{\label{control__if_8h_a1247f66c7e761c0a4fd3dedf11f84e40}} 
\index{control\_if.h@{control\_if.h}!ctrl\_lookup\_register@{ctrl\_lookup\_register}}
\index{ctrl\_lookup\_register@{ctrl\_lookup\_register}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_lookup\_register()}
{\footnotesize\ttfamily int ctrl\+\_\+lookup\+\_\+register (\begin{DoxyParamCaption}\item[{\textbf{ ctrl\+\_\+cmd\+\_\+lookup}}]{lookup }\end{DoxyParamCaption})}



Install a lookup helper function for control nodes This function is used by e.\+g. 

library code to install lookup helpers for additional nodes in the control interface. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em lookup} & The lookup helper function \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
-\/ on success; negative on error. 
\end{DoxyReturn}


References \textbf{ list}, \textbf{ lookup\+\_\+helper\+::list}, \textbf{ llist\+\_\+add\+\_\+tail()}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ lookup\+\_\+helper\+::lookup}.



Referenced by \textbf{ osmo\+\_\+fsm\+\_\+ctrl\+\_\+cmds\+\_\+install()}.

\mbox{\label{control__if_8h_a525af25e0b2344b8b1286c388f721679}} 
\index{control\_if.h@{control\_if.h}!ctrl\_parse\_get\_num@{ctrl\_parse\_get\_num}}
\index{ctrl\_parse\_get\_num@{ctrl\_parse\_get\_num}!control\_if.h@{control\_if.h}}
\doxysubsubsection{ctrl\_parse\_get\_num()}
{\footnotesize\ttfamily int ctrl\+\_\+parse\+\_\+get\+\_\+num (\begin{DoxyParamCaption}\item[{\textbf{ vector}}]{vline,  }\item[{int}]{i,  }\item[{long $\ast$}]{num }\end{DoxyParamCaption})}



Parse ascii-\/encoded decimal number at vline[i]. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em vline} & vector containing a tokenized line \\
\hline
\mbox{\texttt{ in}}  & {\em i} & index into the vector {\itshape vline} \\
\hline
\mbox{\texttt{ out}}  & {\em num} & parsed decimal integer number at vline[i] \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 on success; 0 in case of error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+str\+\_\+to\+\_\+int64()}, \textbf{ vector\+\_\+active}, and \textbf{ vector\+\_\+slot}.

\mbox{\label{control__if_8h_a7b2022943b045830f488d101c9253e80}} 
\index{control\_if.h@{control\_if.h}!osmo\_ctrl\_conn\_alloc@{osmo\_ctrl\_conn\_alloc}}
\index{osmo\_ctrl\_conn\_alloc@{osmo\_ctrl\_conn\_alloc}!control\_if.h@{control\_if.h}}
\doxysubsubsection{osmo\_ctrl\_conn\_alloc()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+connection} $\ast$ osmo\+\_\+ctrl\+\_\+conn\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Allocate CTRL connection. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & Context from which talloc should allocate it \\
\hline
\mbox{\texttt{ in}}  & {\em data} & caller\textquotesingle{}s private data parameter which should assigned to write queue\textquotesingle{}s file descriptor data parameter. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Allocated CTRL connection structure or NULL in case of errors 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+wqueue\+::bfd}, \textbf{ ctrl\+\_\+connection\+::cmds}, \textbf{ control\+\_\+write\+\_\+cb()}, \textbf{ osmo\+\_\+fd\+::data}, \textbf{ data}, \textbf{ ctrl\+\_\+connection\+::def\+\_\+cmds}, \textbf{ osmo\+\_\+fd\+::fd}, \textbf{ handle\+\_\+control\+\_\+read()}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, \textbf{ osmo\+\_\+wqueue\+\_\+init()}, \textbf{ osmo\+\_\+wqueue\+::read\+\_\+cb}, \textbf{ osmo\+\_\+wqueue\+::write\+\_\+cb}, and \textbf{ ctrl\+\_\+connection\+::write\+\_\+queue}.



Referenced by \textbf{ listen\+\_\+fd\+\_\+cb()}.

