\doxysection{include/osmocom/core/tdef.h File Reference}
\label{tdef_8h}\index{include/osmocom/core/tdef.h@{include/osmocom/core/tdef.h}}


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


{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
\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)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+tdef\+\_\+unit\+\_\+names} [$\,$]
\end{DoxyCompactItemize}


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

