\doxysection{include/osmocom/core/rate\+\_\+ctr.h File Reference}
\label{rate__ctr_8h}\index{include/osmocom/core/rate\_ctr.h@{include/osmocom/core/rate\_ctr.h}}
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ rate\+\_\+ctr\+\_\+per\+\_\+intv}
\begin{DoxyCompactList}\small\item\em data we keep for each of the intervals \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr}
\begin{DoxyCompactList}\small\item\em data we keep for each actual value \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr\+\_\+desc}
\begin{DoxyCompactList}\small\item\em rate counter description \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+desc}
\begin{DoxyCompactList}\small\item\em description of a rate counter group \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr\+\_\+group}
\begin{DoxyCompactList}\small\item\em One instance of a counter group class. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ RATE\+\_\+\+CTR\+\_\+\+INTV\+\_\+\+NUM}~4
\begin{DoxyCompactList}\small\item\em Number of rate counter intervals. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef int($\ast$ \textbf{ rate\+\_\+ctr\+\_\+handler\+\_\+t}) (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$, struct \textbf{ rate\+\_\+ctr} $\ast$, const struct \textbf{ rate\+\_\+ctr\+\_\+desc} $\ast$, void $\ast$)
\item 
typedef int($\ast$ \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+handler\+\_\+t}) (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$, void $\ast$)
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ rate\+\_\+ctr\+\_\+intv} \{ \newline
\textbf{ RATE\+\_\+\+CTR\+\_\+\+INTV\+\_\+\+SEC}
, \newline
\textbf{ RATE\+\_\+\+CTR\+\_\+\+INTV\+\_\+\+MIN}
, \newline
\textbf{ RATE\+\_\+\+CTR\+\_\+\+INTV\+\_\+\+HOUR}
, \newline
\textbf{ RATE\+\_\+\+CTR\+\_\+\+INTV\+\_\+\+DAY}
 \}
\begin{DoxyCompactList}\small\item\em Rate counter interval. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+alloc} (void $\ast$ctx, const struct \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+desc} $\ast$\textbf{ desc}, unsigned int idx)
\begin{DoxyCompactList}\small\item\em Allocate a new group of counters according to description. \end{DoxyCompactList}\item 
static void \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+upd\+\_\+idx} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$grp, unsigned int idx)
\item 
void \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+set\+\_\+name} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$grp, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Set a name for the group of counters be used instead of index value at report time. \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr} $\ast$ \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+get\+\_\+ctr} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$grp, unsigned int idx)
\begin{DoxyCompactList}\small\item\em Get rate counter from group, identified by index idx. \end{DoxyCompactList}\item 
void \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+free} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$grp)
\begin{DoxyCompactList}\small\item\em Free the memory for the specified group of counters. \end{DoxyCompactList}\item 
void \textbf{ rate\+\_\+ctr\+\_\+add} (struct \textbf{ rate\+\_\+ctr} $\ast$ctr, int inc)
\begin{DoxyCompactList}\small\item\em Increment the counter by {\itshape inc}. \end{DoxyCompactList}\item 
static void \textbf{ rate\+\_\+ctr\+\_\+add2} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, unsigned int idx, int inc)
\begin{DoxyCompactList}\small\item\em Increment the counter by {\itshape inc}. \end{DoxyCompactList}\item 
static void \textbf{ rate\+\_\+ctr\+\_\+inc} (struct \textbf{ rate\+\_\+ctr} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Increment the counter by 1. \end{DoxyCompactList}\item 
static void \textbf{ rate\+\_\+ctr\+\_\+inc2} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, unsigned int idx)
\begin{DoxyCompactList}\small\item\em Increment the counter by 1. \end{DoxyCompactList}\item 
int64\+\_\+t \textbf{ rate\+\_\+ctr\+\_\+difference} (struct \textbf{ rate\+\_\+ctr} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Return the counter difference since the last call to this function. \end{DoxyCompactList}\item 
int \textbf{ rate\+\_\+ctr\+\_\+init} (void $\ast$tall\+\_\+ctx)
\begin{DoxyCompactList}\small\item\em Initialize the counter module. \end{DoxyCompactList}\item 
struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ \textbf{ rate\+\_\+ctr\+\_\+get\+\_\+group\+\_\+by\+\_\+name\+\_\+idx} (const char $\ast$\textbf{ name}, const unsigned int idx)
\begin{DoxyCompactList}\small\item\em Search for counter group based on group name and index. \end{DoxyCompactList}\item 
const struct \textbf{ rate\+\_\+ctr} $\ast$ \textbf{ rate\+\_\+ctr\+\_\+get\+\_\+by\+\_\+name} (const struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Search for counter based on group + name. \end{DoxyCompactList}\item 
int \textbf{ rate\+\_\+ctr\+\_\+for\+\_\+each\+\_\+counter} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg, \textbf{ rate\+\_\+ctr\+\_\+handler\+\_\+t} \textbf{ handle\+\_\+counter}, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Iterate over each counter in group and call function. \end{DoxyCompactList}\item 
int \textbf{ rate\+\_\+ctr\+\_\+for\+\_\+each\+\_\+group} (\textbf{ rate\+\_\+ctr\+\_\+group\+\_\+handler\+\_\+t} handle\+\_\+group, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Iterate over all counter groups. \end{DoxyCompactList}\item 
void \textbf{ rate\+\_\+ctr\+\_\+reset} (struct \textbf{ rate\+\_\+ctr} $\ast$ctr)
\begin{DoxyCompactList}\small\item\em Reset a rate counter back to zero. \end{DoxyCompactList}\item 
void \textbf{ rate\+\_\+ctr\+\_\+group\+\_\+reset} (struct \textbf{ rate\+\_\+ctr\+\_\+group} $\ast$ctrg)
\begin{DoxyCompactList}\small\item\em Reset all counters in a group. \end{DoxyCompactList}\end{DoxyCompactItemize}
