\doxysection{src/ctrl/control\+\_\+cmd.c File Reference}
\label{control__cmd_8c}\index{src/ctrl/control\_cmd.c@{src/ctrl/control\_cmd.c}}


SNMP-\/like status interface.  


{\ttfamily \#include $<$ctype.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$time.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/ctrl/control\+\_\+cmd.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/ctrl/control\+\_\+if.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/command.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/vector.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ REPLY\+\_\+\+CASE}(TYPE,  NAME)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ vector} \textbf{ cmd\+\_\+make\+\_\+descvec} (const char $\ast$string, const char $\ast$descstr)
\item 
static struct \textbf{ ctrl\+\_\+cmd\+\_\+element} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+get\+\_\+element\+\_\+match} (\textbf{ vector} vline, \textbf{ vector} \textbf{ node})
\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+exec} (\textbf{ vector} vline, struct \textbf{ ctrl\+\_\+cmd} $\ast$command, \textbf{ vector} \textbf{ node}, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Execute a given received command. \end{DoxyCompactList}\item 
static void \textbf{ add\+\_\+word} (struct \textbf{ ctrl\+\_\+cmd\+\_\+struct} $\ast$cmd, const char $\ast$\textbf{ start}, const char $\ast$end)
\item 
static void \textbf{ create\+\_\+cmd\+\_\+struct} (struct \textbf{ ctrl\+\_\+cmd\+\_\+struct} $\ast$cmd, const char $\ast$\textbf{ name})
\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+install} (enum \textbf{ ctrl\+\_\+node\+\_\+type} \textbf{ node}, struct \textbf{ ctrl\+\_\+cmd\+\_\+element} $\ast$cmd)
\begin{DoxyCompactList}\small\item\em Install a given command definition at a given CTRL node. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+create} (void $\ast$ctx, enum \textbf{ ctrl\+\_\+type} \textbf{ type})
\begin{DoxyCompactList}\small\item\em Allocate a control command of given {\itshape type}. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+cpy} (void $\ast$ctx, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd)
\begin{DoxyCompactList}\small\item\em Perform a deepl copy of the given {\itshape cmd}, allocating memory from {\itshape ctx}. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+parse} (void $\ast$ctx, struct \textbf{ msgb} $\ast$\textbf{ msg})
\begin{DoxyCompactList}\small\item\em Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. \end{DoxyCompactList}\item 
static bool \textbf{ id\+\_\+str\+\_\+valid} (const char $\ast$str)
\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+parse2} (void $\ast$ctx, struct \textbf{ msgb} $\ast$\textbf{ msg})
\begin{DoxyCompactList}\small\item\em Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+cmd} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+parse3} (void $\ast$ctx, struct \textbf{ msgb} $\ast$\textbf{ msg}, bool $\ast$parse\+\_\+failed)
\begin{DoxyCompactList}\small\item\em Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. \end{DoxyCompactList}\item 
struct \textbf{ msgb} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+make} (struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd)
\begin{DoxyCompactList}\small\item\em Encode a given CTRL command from its parsed form into a message buffer. \end{DoxyCompactList}\item 
struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$ \textbf{ ctrl\+\_\+cmd\+\_\+def\+\_\+make} (const void $\ast$ctx, struct \textbf{ ctrl\+\_\+cmd} $\ast$cmd, void $\ast$\textbf{ data}, unsigned int secs)
\begin{DoxyCompactList}\small\item\em Build a deferred control command state and keep it the per-\/connection list of deferred commands. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+def\+\_\+is\+\_\+zombie} (struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$cd)
\begin{DoxyCompactList}\small\item\em Determine if the given deferred control command is still alive or a zombie. \end{DoxyCompactList}\item 
int \textbf{ ctrl\+\_\+cmd\+\_\+def\+\_\+send} (struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$cd)
\begin{DoxyCompactList}\small\item\em Send the response to a deferred ctrl command. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\textbf{ vector} \textbf{ ctrl\+\_\+node\+\_\+vec}
\item 
const struct \textbf{ value\+\_\+string} \textbf{ ctrl\+\_\+type\+\_\+vals} [$\,$]
\begin{DoxyCompactList}\small\item\em human-\/readable string names for \doxyref{ctrl\+\_\+type}{p.}{control__cmd_8h_a009b994cda9bda0f88e892ba1234794c} \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
SNMP-\/like status interface. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{control__cmd_8c_ac66b4d7f9c5bcdc8ba5d204c7a465722}} 
\index{control\_cmd.c@{control\_cmd.c}!REPLY\_CASE@{REPLY\_CASE}}
\index{REPLY\_CASE@{REPLY\_CASE}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{REPLY\_CASE}
{\footnotesize\ttfamily \#define REPLY\+\_\+\+CASE(\begin{DoxyParamCaption}\item[{}]{TYPE,  }\item[{}]{NAME }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{                \textcolor{keywordflow}{case} TYPE: \(\backslash\)}
\DoxyCodeLine{                        var = strtok\_r(NULL, \textcolor{stringliteral}{"{} "{}}, \&saveptr); \(\backslash\)}
\DoxyCodeLine{                        val = strtok\_r(NULL, \textcolor{stringliteral}{"{}"{}}, \&saveptr); \(\backslash\)}
\DoxyCodeLine{                        if (!var) \{ \(\backslash\)}
\DoxyCodeLine{                                cmd-\/>type = CTRL\_TYPE\_ERROR; \(\backslash\)}
\DoxyCodeLine{                                cmd-\/>reply = NAME \textcolor{stringliteral}{"{} incomplete"{}}; \(\backslash\)}
\DoxyCodeLine{                                LOGP(DLCTRL, LOGL\_NOTICE, NAME \textcolor{stringliteral}{"{} incomplete\(\backslash\)n"{}}); \(\backslash\)}
\DoxyCodeLine{                                goto err; \(\backslash\)}
\DoxyCodeLine{                        \} \(\backslash\)}
\DoxyCodeLine{                        if (!osmo\_separated\_identifiers\_valid(var, \textcolor{stringliteral}{"{}."{}})) \{ \(\backslash\)}
\DoxyCodeLine{                                cmd-\/>type = CTRL\_TYPE\_ERROR; \(\backslash\)}
\DoxyCodeLine{                                cmd-\/>reply = NAME \textcolor{stringliteral}{"{} variable contains invalid characters"{}}; \(\backslash\)}
\DoxyCodeLine{                                LOGP(DLCTRL, LOGL\_NOTICE, NAME \textcolor{stringliteral}{"{} variable contains invalid characters: \(\backslash\)"{}\%s\(\backslash\)"{}\(\backslash\)n"{}}, \(\backslash\)}
\DoxyCodeLine{                                     osmo\_escape\_str(var, -\/1)); \(\backslash\)}
\DoxyCodeLine{                                goto err; \(\backslash\)}
\DoxyCodeLine{                        \} \(\backslash\)}
\DoxyCodeLine{                        cmd-\/>variable = talloc\_strdup(cmd, var); \(\backslash\)}
\DoxyCodeLine{                        cmd-\/>reply = talloc\_strdup(cmd, val); \(\backslash\)}
\DoxyCodeLine{                        if (!cmd-\/>variable || !cmd-\/>reply) \(\backslash\)}
\DoxyCodeLine{                                goto oom; \(\backslash\)}
\DoxyCodeLine{                        LOGP(DLCTRL, LOGL\_DEBUG, \textcolor{stringliteral}{"{}Command: "{}} NAME \textcolor{stringliteral}{"{} \%s: \%s\(\backslash\)n"{}}, cmd-\/>variable, \(\backslash\)}
\DoxyCodeLine{                             osmo\_escape\_str(cmd-\/>reply, -\/1)); \(\backslash\)}
\DoxyCodeLine{                        break}

\end{DoxyCode}


\doxysubsection{Function Documentation}
\mbox{\label{control__cmd_8c_a61e0a0917fc4d246e537a88d5b60b9bc}} 
\index{control\_cmd.c@{control\_cmd.c}!add\_word@{add\_word}}
\index{add\_word@{add\_word}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{add\_word()}
{\footnotesize\ttfamily static void add\+\_\+word (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+cmd\+\_\+struct} $\ast$}]{cmd,  }\item[{const char $\ast$}]{start,  }\item[{const char $\ast$}]{end }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::command}, \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::nr\+\_\+commands}, \textbf{ start}, and \textbf{ tall\+\_\+vty\+\_\+vec\+\_\+ctx}.



Referenced by \textbf{ create\+\_\+cmd\+\_\+struct()}.

\mbox{\label{control__cmd_8c_a85e741c2f1b7dc529d2569c12f1ef6b5}} 
\index{control\_cmd.c@{control\_cmd.c}!cmd\_make\_descvec@{cmd\_make\_descvec}}
\index{cmd\_make\_descvec@{cmd\_make\_descvec}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{cmd\_make\_descvec()}
{\footnotesize\ttfamily \textbf{ vector} cmd\+\_\+make\+\_\+descvec (\begin{DoxyParamCaption}\item[{const char $\ast$}]{string,  }\item[{const char $\ast$}]{descstr }\end{DoxyParamCaption})}

\mbox{\label{control__cmd_8c_aaca775cc80dff896b523247a294f11a1}} 
\index{control\_cmd.c@{control\_cmd.c}!create\_cmd\_struct@{create\_cmd\_struct}}
\index{create\_cmd\_struct@{create\_cmd\_struct}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{create\_cmd\_struct()}
{\footnotesize\ttfamily static void create\+\_\+cmd\+\_\+struct (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+cmd\+\_\+struct} $\ast$}]{cmd,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ add\+\_\+word()}, \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::command}, \textbf{ DLCTRL}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ name}, and \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::nr\+\_\+commands}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+install()}.

\mbox{\label{control__cmd_8c_aa976d38595380ba6259ca535b019fa65}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_cpy@{ctrl\_cmd\_cpy}}
\index{ctrl\_cmd\_cpy@{ctrl\_cmd\_cpy}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_cpy()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+cpy (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd }\end{DoxyParamCaption})}



Perform a deepl copy of the given {\itshape cmd}, allocating memory from {\itshape ctx}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
 & {\em \mbox{[}in} & cmd CTRL command to be copied \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
deep copy of {\itshape cmd} on success; NULL on error 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::value}, and \textbf{ ctrl\+\_\+cmd\+::variable}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+trap()}.

\mbox{\label{control__cmd_8c_a2218cc3a39b3f3a83e9cf6f57a7938b2}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_create@{ctrl\_cmd\_create}}
\index{ctrl\_cmd\_create@{ctrl\_cmd\_create}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_create()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+create (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{enum \textbf{ ctrl\+\_\+type}}]{type }\end{DoxyParamCaption})}



Allocate a control command of given {\itshape type}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em type} & command type to set after allocation \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated \doxyref{ctrl\+\_\+cmd}{p.}{structctrl__cmd}. Caller must talloc\+\_\+free() it. 
\end{DoxyReturn}


References \textbf{ type}, and \textbf{ ctrl\+\_\+cmd\+::type}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+send\+\_\+trap()}.

\mbox{\label{control__cmd_8c_a96d3c6021102409885ac6c4a294709ce}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_def\_is\_zombie@{ctrl\_cmd\_def\_is\_zombie}}
\index{ctrl\_cmd\_def\_is\_zombie@{ctrl\_cmd\_def\_is\_zombie}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_def\_is\_zombie()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+def\+\_\+is\+\_\+zombie (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$}]{cd }\end{DoxyParamCaption})}



Determine if the given deferred control command is still alive or a zombie. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cd} & deferred ctrl command state \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 is {\itshape cd} is still alive; 1 if it\textquotesingle{}s a zombie 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+def\+::cmd}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::list}, and \textbf{ llist\+\_\+del()}.

\mbox{\label{control__cmd_8c_a9e91e86808a88f4b16cc31a1a04e3420}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_def\_make@{ctrl\_cmd\_def\_make}}
\index{ctrl\_cmd\_def\_make@{ctrl\_cmd\_def\_make}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_def\_make()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$ ctrl\+\_\+cmd\+\_\+def\+\_\+make (\begin{DoxyParamCaption}\item[{const void $\ast$}]{ctx,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd,  }\item[{void $\ast$}]{data,  }\item[{unsigned int}]{secs }\end{DoxyParamCaption})}



Build a deferred control command state and keep it the per-\/connection list of deferred commands. 

This function is typically called by a ctrl command handler that wishes to defer returning a response. The reutnred state can later be used to check if the deferred command is still alive, and to respond to the specific command. This only works to defer the response to GET and SET. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from whihc to allocate the \doxyref{ctrl\+\_\+cmd\+\_\+def}{p.}{structctrl__cmd__def} \\
\hline
\mbox{\texttt{ in}}  & {\em cmd} & the control command whose response is deferred \\
\hline
\mbox{\texttt{ in}}  & {\em data} & opaque, user-\/defined pointer \\
\hline
\mbox{\texttt{ in}}  & {\em secs} & number of seconds until the command times out \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated \doxyref{ctrl\+\_\+cmd\+\_\+def}{p.}{structctrl__cmd__def} 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+::ccon}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::cmd}, \textbf{ data}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::data}, \textbf{ ctrl\+\_\+connection\+::def\+\_\+cmds}, \textbf{ ctrl\+\_\+cmd\+::defer}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::list}, and \textbf{ llist\+\_\+add()}.

\mbox{\label{control__cmd_8c_aa6ec2019f953a82284534fdc8d04dc46}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_def\_send@{ctrl\_cmd\_def\_send}}
\index{ctrl\_cmd\_def\_send@{ctrl\_cmd\_def\_send}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_def\_send()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+def\+\_\+send (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+cmd\+\_\+def} $\ast$}]{cd }\end{DoxyParamCaption})}



Send the response to a deferred ctrl command. 

The command can only be a resply to a SET or a GET operation. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cd} & deferred ctrl command state \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if command sent successfully; negative on error 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+::ccon}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::cmd}, \textbf{ ctrl\+\_\+cmd\+\_\+send2()}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET\+\_\+\+REPLY}, \textbf{ ctrl\+\_\+cmd\+\_\+def\+::list}, \textbf{ llist\+\_\+del()}, and \textbf{ ctrl\+\_\+cmd\+::type}.

\mbox{\label{control__cmd_8c_aea6cb8951a026d0689c3499de37dbdec}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_exec@{ctrl\_cmd\_exec}}
\index{ctrl\_cmd\_exec@{ctrl\_cmd\_exec}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_exec()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+exec (\begin{DoxyParamCaption}\item[{\textbf{ vector}}]{vline,  }\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{command,  }\item[{\textbf{ vector}}]{node,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})}



Execute a given received command. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em vline} & vector representing the available/registered commands \\
\hline
\mbox{\texttt{ in,out}}  & {\em command} & parsed received command to be executed \\
\hline
\mbox{\texttt{ in}}  & {\em node} & CTRL interface node \\
\hline
\mbox{\texttt{ in}}  & {\em data} & opaque data passed to verify(), get() and set() call-\/backs \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
CTRL\+\_\+\+CMD\+\_\+\+HANDLED or CTRL\+\_\+\+CMD\+\_\+\+REPLY; CTRL\+\_\+\+CMD\+\_\+\+ERROR on error 
\end{DoxyReturn}


References \textbf{ CTRL\+\_\+\+CMD\+\_\+\+ERROR}, \textbf{ ctrl\+\_\+cmd\+\_\+get\+\_\+element\+\_\+match()}, \textbf{ CTRL\+\_\+\+CMD\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET\+\_\+\+REPLY}, \textbf{ data}, \textbf{ ctrl\+\_\+cmd\+\_\+element\+::get}, \textbf{ node}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ ctrl\+\_\+cmd\+\_\+element\+::set}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::value}, and \textbf{ ctrl\+\_\+cmd\+\_\+element\+::verify}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+handle()}.

\mbox{\label{control__cmd_8c_ae385d2f657be281d42e77f5048bda232}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_get\_element\_match@{ctrl\_cmd\_get\_element\_match}}
\index{ctrl\_cmd\_get\_element\_match@{ctrl\_cmd\_get\_element\_match}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_get\_element\_match()}
{\footnotesize\ttfamily static struct \textbf{ ctrl\+\_\+cmd\+\_\+element} $\ast$ ctrl\+\_\+cmd\+\_\+get\+\_\+element\+\_\+match (\begin{DoxyParamCaption}\item[{\textbf{ vector}}]{vline,  }\item[{\textbf{ vector}}]{node }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::command}, \textbf{ node}, \textbf{ ctrl\+\_\+cmd\+\_\+struct\+::nr\+\_\+commands}, \textbf{ ctrl\+\_\+cmd\+\_\+element\+::strcmd}, \textbf{ vector\+\_\+active}, and \textbf{ vector\+\_\+slot}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+exec()}.

\mbox{\label{control__cmd_8c_ad7e673e111a7a19c6a2467674fd825b1}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_install@{ctrl\_cmd\_install}}
\index{ctrl\_cmd\_install@{ctrl\_cmd\_install}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_install()}
{\footnotesize\ttfamily int ctrl\+\_\+cmd\+\_\+install (\begin{DoxyParamCaption}\item[{enum \textbf{ ctrl\+\_\+node\+\_\+type}}]{node,  }\item[{struct \textbf{ ctrl\+\_\+cmd\+\_\+element} $\ast$}]{cmd }\end{DoxyParamCaption})}



Install a given command definition at a given CTRL node. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em node} & CTRL node at which {\itshape cmd} is to be installed \\
\hline
\mbox{\texttt{ in}}  & {\em cmd} & command definition to be installed \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error 
\end{DoxyReturn}


References \textbf{ create\+\_\+cmd\+\_\+struct()}, \textbf{ ctrl\+\_\+node\+\_\+vec}, \textbf{ DLCTRL}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ ctrl\+\_\+cmd\+\_\+element\+::name}, \textbf{ node}, \textbf{ ctrl\+\_\+cmd\+\_\+element\+::strcmd}, \textbf{ vector\+\_\+init()}, \textbf{ vector\+\_\+lookup\+\_\+ensure()}, \textbf{ vector\+\_\+set()}, and \textbf{ vector\+\_\+set\+\_\+index()}.



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

\mbox{\label{control__cmd_8c_a3b1dd88cc91fb544488b6f4916130fab}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_make@{ctrl\_cmd\_make}}
\index{ctrl\_cmd\_make@{ctrl\_cmd\_make}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_make()}
{\footnotesize\ttfamily struct \textbf{ msgb} $\ast$ ctrl\+\_\+cmd\+\_\+make (\begin{DoxyParamCaption}\item[{struct \textbf{ ctrl\+\_\+cmd} $\ast$}]{cmd }\end{DoxyParamCaption})}



Encode a given CTRL command from its parsed form into a message buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cmd} & decoded/parsed form of to-\/be-\/encoded command \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated message buffer containing the encoded {\itshape cmd}; NULL on error 
\end{DoxyReturn}


References \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+TRAP}, \textbf{ ctrl\+\_\+type\+\_\+vals}, \textbf{ DLCTRL}, \textbf{ get\+\_\+value\+\_\+string()}, \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ len()}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msgb\+\_\+alloc\+\_\+headroom()}, \textbf{ msgb\+\_\+put()}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ type}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::value}, and \textbf{ ctrl\+\_\+cmd\+::variable}.



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+send2()}.

\mbox{\label{control__cmd_8c_a1fb1544dc2399710a88db9654e6978eb}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_parse@{ctrl\_cmd\_parse}}
\index{ctrl\_cmd\_parse@{ctrl\_cmd\_parse}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_parse()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+parse (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})}



Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing command to be decoded \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated decoded CTRL command; NULL on allocation or other failure The caller is responsible to talloc\+\_\+free() the returned struct pointer. 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+parse2()}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ msg}, and \textbf{ res}.

\mbox{\label{control__cmd_8c_aab5c1fbea4b0a20f82af32194d390e76}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_parse2@{ctrl\_cmd\_parse2}}
\index{ctrl\_cmd\_parse2@{ctrl\_cmd\_parse2}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_parse2()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+parse2 (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})}



Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing command to be decoded \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated decoded CTRL command; NULL on allocation failure, ctrl-\/$>$type == CTRL\+\_\+\+TYPE\+\_\+\+ERROR and an error message in ctrl-\/$>$reply on any error. The caller is responsible to talloc\+\_\+free() the returned struct pointer. If information of the origin of the ERROR cmd returned is required (received or local parsing failure), use \doxyref{ctrl\+\_\+cmd\+\_\+parse3}{p.}{control__cmd_8c_a52caa313b2ff6ffdce5392259dcf1125} instead. 
\end{DoxyReturn}


References \textbf{ ctrl\+\_\+cmd\+\_\+parse3()}, and \textbf{ msg}.



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

\mbox{\label{control__cmd_8c_a52caa313b2ff6ffdce5392259dcf1125}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_cmd\_parse3@{ctrl\_cmd\_parse3}}
\index{ctrl\_cmd\_parse3@{ctrl\_cmd\_parse3}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_cmd\_parse3()}
{\footnotesize\ttfamily struct \textbf{ ctrl\+\_\+cmd} $\ast$ ctrl\+\_\+cmd\+\_\+parse3 (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct \textbf{ msgb} $\ast$}]{msg,  }\item[{bool $\ast$}]{parse\+\_\+failed }\end{DoxyParamCaption})}



Parse/\+Decode CTRL from \textbf{ Message buffers} into command struct. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & message buffer containing command to be decoded \\
\hline
\mbox{\texttt{ out}}  & {\em parse\+\_\+failed} & Whether returned ERROR cmd was generatd locally (due to parse failure) or was received. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
callee-\/allocated decoded CTRL command; NULL on allocation failure, ctrl-\/$>$type == CTRL\+\_\+\+TYPE\+\_\+\+ERROR and an error message in ctrl-\/$>$reply on any error. The caller is responsible to talloc\+\_\+free() the returned struct pointer. 
\end{DoxyReturn}


References \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+ERROR}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+GET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+SET\+\_\+\+REPLY}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+TRAP}, \textbf{ CTRL\+\_\+\+TYPE\+\_\+\+UNKNOWN}, \textbf{ ctrl\+\_\+type\+\_\+vals}, \textbf{ DLCTRL}, \textbf{ get\+\_\+string\+\_\+value()}, \textbf{ get\+\_\+value\+\_\+string()}, \textbf{ ctrl\+\_\+cmd\+::id}, \textbf{ id\+\_\+str\+\_\+valid()}, \textbf{ LOGL\+\_\+\+DEBUG}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ msg}, \textbf{ msgb\+\_\+put\+\_\+u8()}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+escape\+\_\+str()}, \textbf{ osmo\+\_\+separated\+\_\+identifiers\+\_\+valid()}, \textbf{ ctrl\+\_\+cmd\+::reply}, \textbf{ REPLY\+\_\+\+CASE}, \textbf{ ctrl\+\_\+cmd\+::type}, \textbf{ ctrl\+\_\+cmd\+::value}, and \textbf{ ctrl\+\_\+cmd\+::variable}.



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

\mbox{\label{control__cmd_8c_a4d5c03939e1091a1952ae395b5e3040d}} 
\index{control\_cmd.c@{control\_cmd.c}!id\_str\_valid@{id\_str\_valid}}
\index{id\_str\_valid@{id\_str\_valid}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{id\_str\_valid()}
{\footnotesize\ttfamily static bool id\+\_\+str\+\_\+valid (\begin{DoxyParamCaption}\item[{const char $\ast$}]{str }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+parse3()}.



\doxysubsection{Variable Documentation}
\mbox{\label{control__cmd_8c_afedf4b1e97805a8b5ab60dea1ad77813}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_node\_vec@{ctrl\_node\_vec}}
\index{ctrl\_node\_vec@{ctrl\_node\_vec}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_node\_vec}
{\footnotesize\ttfamily \textbf{ vector} ctrl\+\_\+node\+\_\+vec\hspace{0.3cm}{\ttfamily [extern]}}



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+handle()}, \textbf{ ctrl\+\_\+cmd\+\_\+install()}, and \textbf{ ctrl\+\_\+init()}.

\mbox{\label{control__cmd_8c_a6795a9d1de9572b4a6de18b7ca3cdcc8}} 
\index{control\_cmd.c@{control\_cmd.c}!ctrl\_type\_vals@{ctrl\_type\_vals}}
\index{ctrl\_type\_vals@{ctrl\_type\_vals}!control\_cmd.c@{control\_cmd.c}}
\doxysubsubsection{ctrl\_type\_vals}
{\footnotesize\ttfamily const struct \textbf{ value\+\_\+string} ctrl\+\_\+type\+\_\+vals[$\,$]}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        \{ CTRL\_TYPE\_UNKNOWN,   \textcolor{stringliteral}{"{}(unknown)"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_GET,   \textcolor{stringliteral}{"{}GET"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_SET,   \textcolor{stringliteral}{"{}SET"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_GET\_REPLY,       \textcolor{stringliteral}{"{}GET\_REPLY"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_SET\_REPLY,       \textcolor{stringliteral}{"{}SET\_REPLY"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_TRAP, \textcolor{stringliteral}{"{}TRAP"{}} \},}
\DoxyCodeLine{        \{ CTRL\_TYPE\_ERROR,       \textcolor{stringliteral}{"{}ERROR"{}} \},}
\DoxyCodeLine{        \{ 0, NULL \}}
\DoxyCodeLine{\}}

\end{DoxyCode}


human-\/readable string names for \doxyref{ctrl\+\_\+type}{p.}{control__cmd_8h_a009b994cda9bda0f88e892ba1234794c} 



Referenced by \textbf{ ctrl\+\_\+cmd\+\_\+handle()}, \textbf{ ctrl\+\_\+cmd\+\_\+make()}, and \textbf{ ctrl\+\_\+cmd\+\_\+parse3()}.

