\doxysection{Tnnn timer configuration}
\label{group__Tdef}\index{Tnnn timer configuration@{Tnnn timer configuration}}


Implementation to define Tnnn timers globally and use for FSM state changes.  


\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ tdef.\+h}
\begin{DoxyCompactList}\small\item\em API to define Tnnn timers globally and use for FSM state changes. \end{DoxyCompactList}\item 
file \textbf{ tdef.\+c}
\begin{DoxyCompactList}\small\item\em Implementation to define Tnnn timers globally and use for FSM state changes. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+tdef}
\begin{DoxyCompactList}\small\item\em Define a GSM timer of the form Tnnn, with unit, default value and doc string. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout}
\begin{DoxyCompactList}\small\item\em Using \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} for \doxyref{osmo\+\_\+fsm\+\_\+inst}{p.}{structosmo__fsm__inst}\+: array entry for a mapping of state numbers to timeout definitions. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+tdef\+\_\+group}
\begin{DoxyCompactList}\small\item\em Manage timer definitions in named groups. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ osmo\+\_\+tdef\+\_\+for\+\_\+each}(t,  \textbf{ tdefs})~ \textbf{ for} (t = \textbf{ tdefs}; t \&\& (t-\/$>$T $\vert$$\vert$ t-\/$>$default\+\_\+val $\vert$$\vert$ t-\/$>$\textbf{ desc}); t++)
\begin{DoxyCompactList}\small\item\em Iterate an array of struct \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef}, the last item should be fully zero, i.\+e. \end{DoxyCompactList}\item 
\#define \textbf{ osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg}(fi,  state,  timeouts\+\_\+array,  \textbf{ tdefs},  default\+\_\+timeout)
\begin{DoxyCompactList}\small\item\em Call osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg[\+\_\+ms]() or osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+keep\+\_\+timer[\+\_\+ms](), depending on the timeouts\+\_\+array, tdefs and default\+\_\+timeout. \end{DoxyCompactList}\item 
\#define \textbf{ osmo\+\_\+tdef\+\_\+groups\+\_\+for\+\_\+each}(\textbf{ g},  tdef\+\_\+groups)~ \textbf{ for} (\textbf{ g} = tdef\+\_\+groups; \textbf{ g} \&\& \textbf{ g}-\/$>$\textbf{ tdefs}; \textbf{ g}++)
\begin{DoxyCompactList}\small\item\em Iterate an array of struct \doxyref{osmo\+\_\+tdef\+\_\+group}{p.}{structosmo__tdef__group}, the last item should be fully zero, i.\+e. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ osmo\+\_\+tdef\+\_\+unit} \{ \newline
\textbf{ OSMO\+\_\+\+TDEF\+\_\+S} = 0
, \newline
\textbf{ OSMO\+\_\+\+TDEF\+\_\+\+MS}
, \newline
\textbf{ OSMO\+\_\+\+TDEF\+\_\+M}
, \newline
\textbf{ OSMO\+\_\+\+TDEF\+\_\+\+CUSTOM}
, \newline
\textbf{ OSMO\+\_\+\+TDEF\+\_\+\+US}
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static const char $\ast$ \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+name} (enum \textbf{ osmo\+\_\+tdef\+\_\+unit} val)
\item 
void \textbf{ osmo\+\_\+tdefs\+\_\+reset} (struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs})
\begin{DoxyCompactList}\small\item\em Set all \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} values to the default\+\_\+val. \end{DoxyCompactList}\item 
unsigned long \textbf{ osmo\+\_\+tdef\+\_\+get} (const struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs}, int T, enum \textbf{ osmo\+\_\+tdef\+\_\+unit} as\+\_\+unit, long val\+\_\+if\+\_\+not\+\_\+present)
\begin{DoxyCompactList}\small\item\em Return the value of a T timer from a list of \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef}, in the given unit. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+tdef} $\ast$ \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+entry} (struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs}, int T)
\begin{DoxyCompactList}\small\item\em Find tdef entry matching T. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tdef\+\_\+set} (struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs}, int T, unsigned long val, enum \textbf{ osmo\+\_\+tdef\+\_\+unit} val\+\_\+unit)
\begin{DoxyCompactList}\small\item\em Set value in entry matching T, converting val from val\+\_\+unit to unit of T. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+tdef\+\_\+val\+\_\+in\+\_\+range} (struct \textbf{ osmo\+\_\+tdef} $\ast$tdef, unsigned long new\+\_\+val)
\begin{DoxyCompactList}\small\item\em Check if value new\+\_\+val is in range of valid possible values for timer entry tdef. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tdef\+\_\+range\+\_\+str\+\_\+buf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, struct \textbf{ osmo\+\_\+tdef} $\ast$t)
\begin{DoxyCompactList}\small\item\em Write string representation of \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} range into buf. \end{DoxyCompactList}\item 
const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$ \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+state\+\_\+timeout} (uint32\+\_\+t state, const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$timeouts\+\_\+array)
\begin{DoxyCompactList}\small\item\em Using \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} for \doxyref{osmo\+\_\+fsm\+\_\+inst}{p.}{structosmo__fsm__inst}\+: find a given state\textquotesingle{}s \doxyref{osmo\+\_\+tdef\+\_\+state\+\_\+timeout}{p.}{structosmo__tdef__state__timeout} entry. \end{DoxyCompactList}\item 
int \textbf{ \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg} (struct \textbf{ osmo\+\_\+fsm\+\_\+inst} $\ast$fi, uint32\+\_\+t state, const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$timeouts\+\_\+array, const struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs}, signed long default\+\_\+timeout, const char $\ast$\textbf{ file}, int line)
\item 
static unsigned long \textbf{ osmo\+\_\+tdef\+\_\+factor} (enum \textbf{ osmo\+\_\+tdef\+\_\+unit} a, enum \textbf{ osmo\+\_\+tdef\+\_\+unit} b)
\begin{DoxyCompactList}\small\item\em a = return\+\_\+val $\ast$ b. \end{DoxyCompactList}\item 
static unsigned long \textbf{ osmo\+\_\+tdef\+\_\+round} (unsigned long val, enum \textbf{ osmo\+\_\+tdef\+\_\+unit} from\+\_\+unit, enum \textbf{ osmo\+\_\+tdef\+\_\+unit} to\+\_\+unit)
\item 
int \textbf{ \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg} (struct \textbf{ osmo\+\_\+fsm\+\_\+inst} $\ast$fi, uint32\+\_\+t state, const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$timeouts\+\_\+array, const struct \textbf{ osmo\+\_\+tdef} $\ast$\textbf{ tdefs}, long default\+\_\+timeout, const char $\ast$\textbf{ file}, int line)
\begin{DoxyCompactList}\small\item\em See invocation macro \doxyref{osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}{p.}{group__Tdef_ga62ef360585a2162bcac01c588025ce97} instead. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+names} [$\,$]
\item 
const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+names} [$\,$]
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Implementation to define Tnnn timers globally and use for FSM state changes. 

See also \textbf{ Tnnn timer VTY configuration}

\doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} provides\+:


\begin{DoxyItemize}
\item a list of Tnnnn (GSM) timers with description, unit and default value.
\item vty UI to allow users to configure non-\/default timeouts.
\item API to tie T timers to \doxyref{osmo\+\_\+fsm}{p.}{structosmo__fsm} states and set them on state transitions.
\item a few standard units (minute, second, millisecond) as well as a custom unit (which relies on the timer\textquotesingle{}s human readable description to indicate the meaning of the value).
\item conversion for standard units\+: for example, some GSM timers are defined in minutes, while our FSM definitions need timeouts in seconds. Conversion is for convenience only and can be easily avoided via the custom unit.
\end{DoxyItemize}

By keeping separate \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} arrays, several groups of timers can be kept separately. The VTY tests in tests/tdef/ showcase different schemes\+:


\begin{DoxyItemize}
\item tests/tdef/tdef\+\_\+vty\+\_\+config\+\_\+root\+\_\+test.\+c\+: Keep several timer definitions in separately named groups\+: showcase the osmo\+\_\+tdef\+\_\+vty\+\_\+groups$\ast$() API. Each timer group exists exactly once.
\item tests/tdef/tdef\+\_\+vty\+\_\+config\+\_\+subnode\+\_\+test.\+c\+: Keep a single list of timers without separate grouping. Put this list on a specific subnode below the CONFIG\+\_\+\+NODE. There could be several separate subnodes with timers like this, i.\+e. continuing from this example, sets of timers could be separated by placing timers in specific config subnodes instead of using the global group name.
\item tests/tdef/tdef\+\_\+vty\+\_\+dynamic\+\_\+test.\+c\+: Dynamically allocate timer definitions per each new created object. Thus there can be an arbitrary number of independent timer definitions, one per allocated object.
\end{DoxyItemize}

\doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} was introduced because\+:


\begin{DoxyItemize}
\item without \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef}, each invocation of \doxyref{osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}{p.}{group__fsm_gac2bc3009053763ca99356e824529a2e4} needs to be programmed with the right timeout value, for all code paths that invoke this state change. It is a likely source of errors to get one of them wrong. By defining a T timer exactly for an FSM state, the caller can merely invoke the state change and trust on the original state definition to apply the correct timeout.
\item it is helpful to have a standardized config file UI to provide user configurable timeouts, instead of inventing new VTY commands for each separate application of T timer numbers. See \textbf{ tdef\+\_\+vty.\+h}. 
\end{DoxyItemize}

\doxysubsection{Macro Definition Documentation}
\mbox{\label{group__Tdef_ga9bfa6d2933254ee56979be1f0230cf71}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_for\_each@{osmo\_tdef\_for\_each}}
\index{osmo\_tdef\_for\_each@{osmo\_tdef\_for\_each}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_for\_each}
{\footnotesize\ttfamily \#define osmo\+\_\+tdef\+\_\+for\+\_\+each(\begin{DoxyParamCaption}\item[{}]{t,  }\item[{}]{\textbf{ tdefs} }\end{DoxyParamCaption})~ \textbf{ for} (t = \textbf{ tdefs}; t \&\& (t-\/$>$T $\vert$$\vert$ t-\/$>$default\+\_\+val $\vert$$\vert$ t-\/$>$\textbf{ desc}); t++)}



Iterate an array of struct \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef}, the last item should be fully zero, i.\+e. 

\char`\"{}\{\}\char`\"{}. Example\+: \begin{DoxyVerb}struct osmo_tdef *t;
osmo_tdef_for_each(t, tdefs) {
        printf("%lu %s %s\n", t->val, osmo_tdef_unit_name(t->unit), t->desc);
}
\end{DoxyVerb}
 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em t} & A struct \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} $\ast$t used for iteration, will point at the current entry inside the loop scope. \\
\hline
\mbox{\texttt{ in}}  & {\em tdefs} & Array of struct \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} to iterate, zero-\/terminated. \\
\hline
\end{DoxyParams}
\mbox{\label{group__Tdef_ga62ef360585a2162bcac01c588025ce97}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_fsm\_inst\_state\_chg@{osmo\_tdef\_fsm\_inst\_state\_chg}}
\index{osmo\_tdef\_fsm\_inst\_state\_chg@{osmo\_tdef\_fsm\_inst\_state\_chg}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_fsm\_inst\_state\_chg}
{\footnotesize\ttfamily \#define osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg(\begin{DoxyParamCaption}\item[{}]{fi,  }\item[{}]{state,  }\item[{}]{timeouts\+\_\+array,  }\item[{}]{\textbf{ tdefs},  }\item[{}]{default\+\_\+timeout }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        \_osmo\_tdef\_fsm\_inst\_state\_chg(fi, state, timeouts\_array, tdefs, default\_timeout, \(\backslash\)}
\DoxyCodeLine{                                      \_\_FILE\_\_, \_\_LINE\_\_)}

\end{DoxyCode}


Call osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg[\+\_\+ms]() or osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+keep\+\_\+timer[\+\_\+ms](), depending on the timeouts\+\_\+array, tdefs and default\+\_\+timeout. 

A timer defined with sub-\/millisecond precision (e.\+g OSMO\+\_\+\+TDEF\+\_\+\+US) is rounded up to the next full millisecond. A timer value defined in units higher than millisecond (e.\+g. OSMO\+\_\+\+TDEF\+\_\+S, OSMO\+\_\+\+TDEF\+\_\+M) is converted to milliseconds. A timer in unit = OSMO\+\_\+\+TDEF\+\_\+\+CUSTOM is applied as if the unit is in seconds (i.\+e. this macro does not make sense for custom units!).

See \doxyref{osmo\+\_\+tdef\+\_\+get\+\_\+state\+\_\+timeout()}{p.}{group__Tdef_ga5a7532bad13a88526390b8f3c6db3374} and \doxyref{osmo\+\_\+tdef\+\_\+get()}{p.}{group__Tdef_ga1902036c8ce361a6ba043b90f3026ae7}.

If no T timer is defined for the given state (T == 0), invoke the state change without a timeout.

Should a T number be defined in timeouts\+\_\+array that is not defined in tdefs, use default\+\_\+timeout (in seconds). If default\+\_\+timeout is negative, a missing T definition in tdefs instead causes a program abort.

This is best used by wrapping this function call in a macro suitable for a specific FSM implementation, which can become as short as\+: my\+\_\+fsm\+\_\+state\+\_\+chg(fi, NEXT\+\_\+\+STATE)\+: \begin{DoxyVerb}#define my_fsm_state_chg(fi, NEXT_STATE) \
        osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, my_fsm_timeouts, global_T_defs, 5)

my_fsm_state_chg(fi, MY_FSM_STATE_1);
// -> No timeout configured, will enter state without timeout.

my_fsm_state_chg(fi, MY_FSM_STATE_3);
// T423 configured for this state, will look up T423 in tdefs, or use 5 seconds if unset.

my_fsm_state_chg(fi, MY_FSM_STATE_8);
// keep_timer == true for this state, will invoke osmo_fsm_inst_state_chg_keep_timer().
\end{DoxyVerb}
 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em fi} & \doxyref{osmo\+\_\+fsm\+\_\+inst}{p.}{structosmo__fsm__inst} to transition to another state. \\
\hline
\mbox{\texttt{ in}}  & {\em state} & State number to transition to. \\
\hline
\mbox{\texttt{ in}}  & {\em timeouts\+\_\+array} & Array of struct \doxyref{osmo\+\_\+tdef\+\_\+state\+\_\+timeout}{p.}{structosmo__tdef__state__timeout}[32] to look up state in. \\
\hline
\mbox{\texttt{ in}}  & {\em tdefs} & Array of struct \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} (last entry zero initialized) to look up T in. \\
\hline
\mbox{\texttt{ in}}  & {\em default\+\_\+timeout} & If a T is set in timeouts\+\_\+array, but no timeout value is configured for T, then use this default timeout value (in seconds) as fallback, or pass a negative number to abort the program. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Return value from osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg[\+\_\+ms]() or osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+keep\+\_\+timer[\+\_\+ms](). 
\end{DoxyReturn}
\mbox{\label{group__Tdef_ga6b2e21ca953ab535e36f9b851d9558a5}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_groups\_for\_each@{osmo\_tdef\_groups\_for\_each}}
\index{osmo\_tdef\_groups\_for\_each@{osmo\_tdef\_groups\_for\_each}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_groups\_for\_each}
{\footnotesize\ttfamily \#define osmo\+\_\+tdef\+\_\+groups\+\_\+for\+\_\+each(\begin{DoxyParamCaption}\item[{}]{\textbf{ g},  }\item[{}]{tdef\+\_\+groups }\end{DoxyParamCaption})~ \textbf{ for} (\textbf{ g} = tdef\+\_\+groups; \textbf{ g} \&\& \textbf{ g}-\/$>$\textbf{ tdefs}; \textbf{ g}++)}



Iterate an array of struct \doxyref{osmo\+\_\+tdef\+\_\+group}{p.}{structosmo__tdef__group}, the last item should be fully zero, i.\+e. 

\char`\"{}\{\}\char`\"{}. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & A struct \doxyref{osmo\+\_\+tdef\+\_\+group}{p.}{structosmo__tdef__group} $\ast$g used for iteration, will point at the current entry inside the loop scope. \\
\hline
\mbox{\texttt{ in}}  & {\em tdefs} & Array of struct \doxyref{osmo\+\_\+tdef\+\_\+group}{p.}{structosmo__tdef__group} to iterate, zero-\/terminated. \\
\hline
\end{DoxyParams}


\doxysubsection{Enumeration Type Documentation}
\mbox{\label{group__Tdef_gaab870deed1871d59911bcd465b410f6a}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_unit@{osmo\_tdef\_unit}}
\index{osmo\_tdef\_unit@{osmo\_tdef\_unit}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_unit}
{\footnotesize\ttfamily enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_TDEF\_S@{OSMO\_TDEF\_S}!Tnnn timer configuration@{Tnnn timer configuration}}\index{Tnnn timer configuration@{Tnnn timer configuration}!OSMO\_TDEF\_S@{OSMO\_TDEF\_S}}}\mbox{\label{group__Tdef_ggaab870deed1871d59911bcd465b410f6aacd7acf38bfb806b297369d3967b8151d}} 
OSMO\+\_\+\+TDEF\+\_\+S&most T are in seconds, keep 0 as default. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_TDEF\_MS@{OSMO\_TDEF\_MS}!Tnnn timer configuration@{Tnnn timer configuration}}\index{Tnnn timer configuration@{Tnnn timer configuration}!OSMO\_TDEF\_MS@{OSMO\_TDEF\_MS}}}\mbox{\label{group__Tdef_ggaab870deed1871d59911bcd465b410f6aae9571204a5e1dc1b575f94c11bc47474}} 
OSMO\+\_\+\+TDEF\+\_\+\+MS&milliseconds \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_TDEF\_M@{OSMO\_TDEF\_M}!Tnnn timer configuration@{Tnnn timer configuration}}\index{Tnnn timer configuration@{Tnnn timer configuration}!OSMO\_TDEF\_M@{OSMO\_TDEF\_M}}}\mbox{\label{group__Tdef_ggaab870deed1871d59911bcd465b410f6aa757bb613b8f209d4d9e0c2d6622e06bc}} 
OSMO\+\_\+\+TDEF\+\_\+M&minutes \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_TDEF\_CUSTOM@{OSMO\_TDEF\_CUSTOM}!Tnnn timer configuration@{Tnnn timer configuration}}\index{Tnnn timer configuration@{Tnnn timer configuration}!OSMO\_TDEF\_CUSTOM@{OSMO\_TDEF\_CUSTOM}}}\mbox{\label{group__Tdef_ggaab870deed1871d59911bcd465b410f6aa12615b1124e5e25e0a0ad4e5b13adef5}} 
OSMO\+\_\+\+TDEF\+\_\+\+CUSTOM&unspecified unit, explained in \doxyref{osmo\+\_\+tdef.\+desc}{p.}{structosmo__tdef_aa5a127f1c816e6f053a8a7b48920b6e9}. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_TDEF\_US@{OSMO\_TDEF\_US}!Tnnn timer configuration@{Tnnn timer configuration}}\index{Tnnn timer configuration@{Tnnn timer configuration}!OSMO\_TDEF\_US@{OSMO\_TDEF\_US}}}\mbox{\label{group__Tdef_ggaab870deed1871d59911bcd465b410f6aa4cf1495f9310e61a17527be25486e4cc}} 
OSMO\+\_\+\+TDEF\+\_\+\+US&microseconds \\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\label{group__Tdef_ga0f528b78c3b8875971f0fcbbaa52e1c6}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!\_osmo\_tdef\_fsm\_inst\_state\_chg@{\_osmo\_tdef\_fsm\_inst\_state\_chg}}
\index{\_osmo\_tdef\_fsm\_inst\_state\_chg@{\_osmo\_tdef\_fsm\_inst\_state\_chg}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{\_osmo\_tdef\_fsm\_inst\_state\_chg()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily int \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fsm\+\_\+inst} $\ast$}]{fi,  }\item[{uint32\+\_\+t}]{state,  }\item[{const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$}]{timeouts\+\_\+array,  }\item[{const struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs,  }\item[{long}]{default\+\_\+timeout,  }\item[{const char $\ast$}]{file,  }\item[{int}]{line }\end{DoxyParamCaption})}



See invocation macro \doxyref{osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}{p.}{group__Tdef_ga62ef360585a2162bcac01c588025ce97} instead. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em file} & Source file name, like {\bfseries{FILE}}. \\
\hline
\mbox{\texttt{ in}}  & {\em line} & Source file line number, like {\bfseries{LINE}}. \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}, \textbf{ \+\_\+osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+keep\+\_\+or\+\_\+start\+\_\+timer\+\_\+ms()}, \textbf{ \+\_\+osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+keep\+\_\+timer()}, \textbf{ \+\_\+osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+ms()}, \textbf{ file()}, \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout\+::keep\+\_\+timer}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ OSMO\+\_\+\+TDEF\+\_\+\+CUSTOM}, \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+entry()}, \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+state\+\_\+timeout()}, \textbf{ OSMO\+\_\+\+TDEF\+\_\+\+MS}, \textbf{ osmo\+\_\+tdef\+\_\+round()}, \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout\+::T}, \textbf{ tdefs}, \textbf{ osmo\+\_\+tdef\+::unit}, and \textbf{ osmo\+\_\+tdef\+::val}.

\mbox{\label{group__Tdef_ga0949811a3638747d3ba5fc2eeba9b94c}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!\_osmo\_tdef\_fsm\_inst\_state\_chg@{\_osmo\_tdef\_fsm\_inst\_state\_chg}}
\index{\_osmo\_tdef\_fsm\_inst\_state\_chg@{\_osmo\_tdef\_fsm\_inst\_state\_chg}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{\_osmo\_tdef\_fsm\_inst\_state\_chg()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily int \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fsm\+\_\+inst} $\ast$}]{fi,  }\item[{uint32\+\_\+t}]{state,  }\item[{const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$}]{timeouts\+\_\+array,  }\item[{const struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs,  }\item[{signed long}]{default\+\_\+timeout,  }\item[{const char $\ast$}]{file,  }\item[{int}]{line }\end{DoxyParamCaption})}

\mbox{\label{group__Tdef_gae2c06fad8c067d3ae2d6ebbaa133e070}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_factor@{osmo\_tdef\_factor}}
\index{osmo\_tdef\_factor@{osmo\_tdef\_factor}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_factor()}
{\footnotesize\ttfamily static unsigned long osmo\+\_\+tdef\+\_\+factor (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{a,  }\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



a = return\+\_\+val $\ast$ b. 

\begin{DoxyReturn}{Returns}
0 if factor is below 1. 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+TDEF\+\_\+\+CUSTOM}, \textbf{ OSMO\+\_\+\+TDEF\+\_\+M}, \textbf{ OSMO\+\_\+\+TDEF\+\_\+\+MS}, \textbf{ OSMO\+\_\+\+TDEF\+\_\+S}, and \textbf{ OSMO\+\_\+\+TDEF\+\_\+\+US}.



Referenced by \textbf{ osmo\+\_\+tdef\+\_\+round()}.

\mbox{\label{group__Tdef_ga1902036c8ce361a6ba043b90f3026ae7}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_get@{osmo\_tdef\_get}}
\index{osmo\_tdef\_get@{osmo\_tdef\_get}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_get()}
{\footnotesize\ttfamily unsigned long osmo\+\_\+tdef\+\_\+get (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs,  }\item[{int}]{T,  }\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{as\+\_\+unit,  }\item[{long}]{val\+\_\+if\+\_\+not\+\_\+present }\end{DoxyParamCaption})}



Return the value of a T timer from a list of \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef}, in the given unit. 

If no such timer is defined, return the default value passed, or abort the program if default $<$ 0.

Round up any value match as\+\_\+unit\+: 1100 ms as OSMO\+\_\+\+TDEF\+\_\+S becomes 2 seconds, as OSMO\+\_\+\+TDEF\+\_\+M becomes one minute. However, always return a value of zero as zero (0 ms as OSMO\+\_\+\+TDEF\+\_\+M still is 0 m).

Range\+: even though the value range is unsigned long here, in practice, using ULONG\+\_\+\+MAX as value for a timeout in seconds may actually wrap to negative or low timeout values (e.\+g. in struct timeval). It is recommended to stay below INT\+\_\+\+MAX seconds. See also \doxyref{osmo\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}{p.}{group__fsm_gac2bc3009053763ca99356e824529a2e4}.

Usage example\+: \begin{DoxyVerb}    struct osmo_tdef global_T_defs[] = {
            { .T=7, .default_val=50, .desc="Water Boiling Timeout" },  // default is .unit=OSMO_TDEF_S == 0
            { .T=8, .default_val=300, .desc="Tea brewing" },
            { .T=9, .default_val=5, .unit=OSMO_TDEF_M, .desc="Let tea cool down before drinking" },
            { .T=10, .default_val=20, .unit=OSMO_TDEF_M, .desc="Forgot to drink tea while it's warm" },
            {}  //  <-- important! last entry shall be zero
    };
    osmo_tdefs_reset(global_T_defs); // make all values the default
    osmo_tdef_vty_init(global_T_defs, CONFIG_NODE);

    val = osmo_tdef_get(global_T_defs, 7, OSMO_TDEF_S, -1); // -> 50
    sleep(val);

    val = osmo_tdef_get(global_T_defs, 7, OSMO_TDEF_M, -1); // 50 seconds becomes 1 minute -> 1
    sleep_minutes(val);

    val = osmo_tdef_get(global_T_defs, 99, OSMO_TDEF_S, 3); // not defined, returns 3

    val = osmo_tdef_get(global_T_defs, 99, OSMO_TDEF_S, -1); // not defined, program aborts!
\end{DoxyVerb}
 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tdefs} & Array of timer definitions, last entry must be fully zero initialized. \\
\hline
\mbox{\texttt{ in}}  & {\em T} & Timer number to get the value for. \\
\hline
\mbox{\texttt{ in}}  & {\em as\+\_\+unit} & Return timeout value in this unit. \\
\hline
\mbox{\texttt{ in}}  & {\em val\+\_\+if\+\_\+not\+\_\+present} & Fallback value to return if no timeout is defined; if this is a negative number, a missing T timer definition aborts the program via \doxyref{OSMO\+\_\+\+ASSERT()}{p.}{group__utils_ga0e15c1ca106fdf15e53b6b8cb30e87dd}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Timeout value in the unit given by as\+\_\+unit, rounded up if necessary, or val\+\_\+if\+\_\+not\+\_\+present. If val\+\_\+if\+\_\+not\+\_\+present is negative and no T timer is defined, trigger \doxyref{OSMO\+\_\+\+ASSERT()}{p.}{group__utils_ga0e15c1ca106fdf15e53b6b8cb30e87dd} and do not return. 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+entry()}, \textbf{ osmo\+\_\+tdef\+\_\+round()}, \textbf{ osmo\+\_\+tdef\+::T}, \textbf{ tdefs}, \textbf{ osmo\+\_\+tdef\+::unit}, and \textbf{ osmo\+\_\+tdef\+::val}.

\mbox{\label{group__Tdef_ga165520a7b18876662703753759941e00}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_get\_entry@{osmo\_tdef\_get\_entry}}
\index{osmo\_tdef\_get\_entry@{osmo\_tdef\_get\_entry}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_get\_entry()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+tdef} $\ast$ osmo\+\_\+tdef\+\_\+get\+\_\+entry (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs,  }\item[{int}]{T }\end{DoxyParamCaption})}



Find tdef entry matching T. 

This is useful for manipulation, which is usually limited to the VTY configuration. To retrieve a timeout value, most callers probably should use \doxyref{osmo\+\_\+tdef\+\_\+get()}{p.}{group__Tdef_ga1902036c8ce361a6ba043b90f3026ae7} instead. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tdefs} & Array of timer definitions, last entry being fully zero. \\
\hline
\mbox{\texttt{ in}}  & {\em T} & Timer number to get the entry for. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} entry matching T in given array, or NULL if no match is found. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tdef\+\_\+for\+\_\+each}, \textbf{ osmo\+\_\+tdef\+::T}, and \textbf{ tdefs}.



Referenced by \textbf{ \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}, \textbf{ osmo\+\_\+tdef\+\_\+get()}, and \textbf{ osmo\+\_\+tdef\+\_\+set()}.

\mbox{\label{group__Tdef_ga5a7532bad13a88526390b8f3c6db3374}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_get\_state\_timeout@{osmo\_tdef\_get\_state\_timeout}}
\index{osmo\_tdef\_get\_state\_timeout@{osmo\_tdef\_get\_state\_timeout}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_get\_state\_timeout()}
{\footnotesize\ttfamily const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$ osmo\+\_\+tdef\+\_\+get\+\_\+state\+\_\+timeout (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{state,  }\item[{const struct \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout} $\ast$}]{timeouts\+\_\+array }\end{DoxyParamCaption})}



Using \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} for \doxyref{osmo\+\_\+fsm\+\_\+inst}{p.}{structosmo__fsm__inst}\+: find a given state\textquotesingle{}s \doxyref{osmo\+\_\+tdef\+\_\+state\+\_\+timeout}{p.}{structosmo__tdef__state__timeout} entry. 

The timeouts\+\_\+array shall contain exactly 32 elements, regardless whether only some of them are actually populated with nonzero values. 32 corresponds to the number of states allowed by the osmo\+\_\+fsm\+\_\+$\ast$ API. Lookup is by array index. Not populated entries imply a state change invocation without timeout.

For example\+: \begin{DoxyVerb}    struct osmo_tdef_state_timeout my_fsm_timeouts[32] = {
            [MY_FSM_STATE_3] = { .T = 423 }, // look up timeout configured for T423
            [MY_FSM_STATE_7] = { .keep_timer = true, .T = 235 }, // keep previous timer if running, or start T235
            [MY_FSM_STATE_8] = { .keep_timer = true }, // keep previous state's T number, continue timeout.
            // any state that is omitted will remain zero == no timeout
 };
 osmo_tdef_get_state_timeout(MY_FSM_STATE_0, &my_fsm_timeouts) -> NULL,
 osmo_tdef_get_state_timeout(MY_FSM_STATE_7, &my_fsm_timeouts) -> { .T = 235 }
\end{DoxyVerb}
 The intention is then to obtain the timer like osmo\+\_\+tdef\+\_\+get(global\+\_\+\+T\+\_\+defs, T=235); see also fsm\+\_\+inst\+\_\+state\+\_\+chg\+\_\+\+T() below.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em state} & State constant to look up. \\
\hline
\mbox{\texttt{ in}}  & {\em timeouts\+\_\+array} & Array[32] of struct \doxyref{osmo\+\_\+tdef\+\_\+state\+\_\+timeout}{p.}{structosmo__tdef__state__timeout} defining which timer number to use per state. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A struct \doxyref{osmo\+\_\+tdef\+\_\+state\+\_\+timeout}{p.}{structosmo__tdef__state__timeout} entry, or NULL if that entry is zero initialized. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout\+::keep\+\_\+timer}, \textbf{ OSMO\+\_\+\+ASSERT}, and \textbf{ osmo\+\_\+tdef\+\_\+state\+\_\+timeout\+::T}.



Referenced by \textbf{ \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}.

\mbox{\label{group__Tdef_ga88e3725d03ea8ab0edf8013333dfedad}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_range\_str\_buf@{osmo\_tdef\_range\_str\_buf}}
\index{osmo\_tdef\_range\_str\_buf@{osmo\_tdef\_range\_str\_buf}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_range\_str\_buf()}
{\footnotesize\ttfamily int osmo\+\_\+tdef\+\_\+range\+\_\+str\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len,  }\item[{struct \textbf{ osmo\+\_\+tdef} $\ast$}]{t }\end{DoxyParamCaption})}



Write string representation of \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} range into buf. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em buf} & The buffer where the string representation is stored. \\
\hline
\mbox{\texttt{ in}}  & {\em buf\+\_\+len} & Length of buffer in bytes. \\
\hline
\mbox{\texttt{ in}}  & {\em tdef} & Timer entry from a timer definition table. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of characters printed on success (or number of characters which would have been written to the final string if enough space had been available), negative on error. See snprintf(). 
\end{DoxyReturn}


References \textbf{ len()}, \textbf{ osmo\+\_\+tdef\+::max\+\_\+val}, \textbf{ osmo\+\_\+tdef\+::min\+\_\+val}, and \textbf{ OSMO\+\_\+\+SNPRINTF\+\_\+\+RET}.



Referenced by \textbf{ osmo\+\_\+tdefs\+\_\+reset()}.

\mbox{\label{group__Tdef_ga95e55c67fc577ce73009b70f1a3c432b}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_round@{osmo\_tdef\_round}}
\index{osmo\_tdef\_round@{osmo\_tdef\_round}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_round()}
{\footnotesize\ttfamily static unsigned long osmo\+\_\+tdef\+\_\+round (\begin{DoxyParamCaption}\item[{unsigned long}]{val,  }\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{from\+\_\+unit,  }\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{to\+\_\+unit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

\begin{DoxyReturn}{Returns}
val in unit to\+\_\+unit, rounded up to the next integer value and clamped to ULONG\+\_\+\+MAX, or 0 if val == 0. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tdef\+\_\+factor()}.



Referenced by \textbf{ \+\_\+osmo\+\_\+tdef\+\_\+fsm\+\_\+inst\+\_\+state\+\_\+chg()}, \textbf{ osmo\+\_\+tdef\+\_\+get()}, and \textbf{ osmo\+\_\+tdef\+\_\+set()}.

\mbox{\label{group__Tdef_gab2f59867f10a781019db1d52c991ce95}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_set@{osmo\_tdef\_set}}
\index{osmo\_tdef\_set@{osmo\_tdef\_set}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_set()}
{\footnotesize\ttfamily int osmo\+\_\+tdef\+\_\+set (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs,  }\item[{int}]{T,  }\item[{unsigned long}]{val,  }\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{val\+\_\+unit }\end{DoxyParamCaption})}



Set value in entry matching T, converting val from val\+\_\+unit to unit of T. 

The converted value is rounded up to the next integer value of T\textquotesingle{}s unit and clamped to ULONG\+\_\+\+MAX, or 0 if val == 0. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tdefs} & Array of timer definitions, last entry being fully zero. \\
\hline
\mbox{\texttt{ in}}  & {\em T} & Timer number to set the value for. \\
\hline
\mbox{\texttt{ in}}  & {\em val} & The new timer value to set. \\
\hline
\mbox{\texttt{ in}}  & {\em val\+\_\+unit} & Units of value in parameter val. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tdef\+\_\+get\+\_\+entry()}, \textbf{ osmo\+\_\+tdef\+\_\+round()}, \textbf{ osmo\+\_\+tdef\+\_\+val\+\_\+in\+\_\+range()}, \textbf{ osmo\+\_\+tdef\+::T}, \textbf{ tdefs}, \textbf{ osmo\+\_\+tdef\+::unit}, and \textbf{ osmo\+\_\+tdef\+::val}.

\mbox{\label{group__Tdef_ga0625620798fea884f7a63efbc58defd1}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_unit\_name@{osmo\_tdef\_unit\_name}}
\index{osmo\_tdef\_unit\_name@{osmo\_tdef\_unit\_name}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_unit\_name()}
{\footnotesize\ttfamily static const char $\ast$ osmo\+\_\+tdef\+\_\+unit\+\_\+name (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+tdef\+\_\+unit}}]{val }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}

\begin{DoxyReturn}{Returns}
enum osmo\+\_\+tdef\+\_\+unit value as human readable unit letter, or \char`\"{}custom-\/unit\char`\"{}. 
\end{DoxyReturn}


References \textbf{ get\+\_\+value\+\_\+string()}, and \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+names}.

\mbox{\label{group__Tdef_ga4b9908c0c45f1226f4fae760141d54b4}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_val\_in\_range@{osmo\_tdef\_val\_in\_range}}
\index{osmo\_tdef\_val\_in\_range@{osmo\_tdef\_val\_in\_range}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_val\_in\_range()}
{\footnotesize\ttfamily bool osmo\+\_\+tdef\+\_\+val\+\_\+in\+\_\+range (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdef,  }\item[{unsigned long}]{new\+\_\+val }\end{DoxyParamCaption})}



Check if value new\+\_\+val is in range of valid possible values for timer entry tdef. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tdef} & Timer entry from a timer definition table. \\
\hline
\mbox{\texttt{ in}}  & {\em new\+\_\+val} & The value whose validity to check, in units as per this timer entry. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if inside range, false otherwise. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+tdef\+::max\+\_\+val}, and \textbf{ osmo\+\_\+tdef\+::min\+\_\+val}.



Referenced by \textbf{ osmo\+\_\+tdef\+\_\+set()}, and \textbf{ osmo\+\_\+tdefs\+\_\+reset()}.

\mbox{\label{group__Tdef_ga0a2cda1d30e23023cc179b68b8c624e6}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdefs\_reset@{osmo\_tdefs\_reset}}
\index{osmo\_tdefs\_reset@{osmo\_tdefs\_reset}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdefs\_reset()}
{\footnotesize\ttfamily void osmo\+\_\+tdefs\+\_\+reset (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+tdef} $\ast$}]{tdefs }\end{DoxyParamCaption})}



Set all \doxyref{osmo\+\_\+tdef}{p.}{structosmo__tdef} values to the default\+\_\+val. 

It is convenient to define a tdefs array by setting only the default\+\_\+val, and calling \doxyref{osmo\+\_\+tdefs\+\_\+reset()}{p.}{group__Tdef_ga0a2cda1d30e23023cc179b68b8c624e6} once for program startup. (See also osmo\+\_\+tdef\+\_\+vty\+\_\+init()). During call to this function, default values are verified to be inside valid range; process is aborted otherwise. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em tdefs} & Array of timer definitions, last entry being fully zero. \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+tdef\+::default\+\_\+val}, \textbf{ osmo\+\_\+panic()}, \textbf{ OSMO\+\_\+\+T\+\_\+\+FMT}, \textbf{ OSMO\+\_\+\+T\+\_\+\+FMT\+\_\+\+ARGS}, \textbf{ osmo\+\_\+tdef\+\_\+for\+\_\+each}, \textbf{ osmo\+\_\+tdef\+\_\+range\+\_\+str\+\_\+buf()}, \textbf{ osmo\+\_\+tdef\+\_\+val\+\_\+in\+\_\+range()}, \textbf{ osmo\+\_\+tdef\+::T}, \textbf{ tdefs}, and \textbf{ osmo\+\_\+tdef\+::val}.



\doxysubsection{Variable Documentation}
\mbox{\label{group__Tdef_ga4ad5be5f9d49274b4bce18320cf251b5}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_unit\_names@{osmo\_tdef\_unit\_names}}
\index{osmo\_tdef\_unit\_names@{osmo\_tdef\_unit\_names}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_unit\_names\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const struct \textbf{ value\+\_\+string} osmo\+\_\+tdef\+\_\+unit\+\_\+names[$\,$]\hspace{0.3cm}{\ttfamily [extern]}}



Referenced by \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+name()}.

\mbox{\label{group__Tdef_ga4ad5be5f9d49274b4bce18320cf251b5}} 
\index{Tnnn timer configuration@{Tnnn timer configuration}!osmo\_tdef\_unit\_names@{osmo\_tdef\_unit\_names}}
\index{osmo\_tdef\_unit\_names@{osmo\_tdef\_unit\_names}!Tnnn timer configuration@{Tnnn timer configuration}}
\doxysubsubsection{osmo\_tdef\_unit\_names\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily const struct \textbf{ value\+\_\+string} osmo\+\_\+tdef\+\_\+unit\+\_\+names[$\,$]}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        \{ OSMO\_TDEF\_S, \textcolor{stringliteral}{"{}s"{}} \},}
\DoxyCodeLine{        \{ OSMO\_TDEF\_MS, \textcolor{stringliteral}{"{}ms"{}} \},}
\DoxyCodeLine{        \{ OSMO\_TDEF\_M, \textcolor{stringliteral}{"{}m"{}} \},}
\DoxyCodeLine{        \{ OSMO\_TDEF\_CUSTOM, \textcolor{stringliteral}{"{}custom-\/unit"{}} \},}
\DoxyCodeLine{        \{ OSMO\_TDEF\_US, \textcolor{stringliteral}{"{}us"{}} \},}
\DoxyCodeLine{        \{\}}
\DoxyCodeLine{\}}

\end{DoxyCode}


Referenced by \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+name()}.

