\doxysection{src/gsm/gsm48\+\_\+arfcn\+\_\+range\+\_\+encode.c File Reference}
\label{gsm48__arfcn__range__encode_8c}\index{src/gsm/gsm48\_arfcn\_range\_encode.c@{src/gsm/gsm48\_arfcn\_range\_encode.c}}
{\ttfamily \#include $<$osmocom/gsm/protocol/gsm\+\_\+04\+\_\+08.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/gsm48\+\_\+arfcn\+\_\+range\+\_\+encode.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ greatest\+\_\+power\+\_\+of\+\_\+2\+\_\+lesser\+\_\+or\+\_\+equal\+\_\+to} (int index)
\item 
static int \textbf{ mod} (int \textbf{ data}, int range)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index} (enum \textbf{ osmo\+\_\+gsm48\+\_\+range} range, const int $\ast$freqs, const int size)
\begin{DoxyCompactList}\small\item\em Determine at which index to split the ARFCNs to create an equally size partition for the given range. \end{DoxyCompactList}\item 
static int \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns} (enum \textbf{ osmo\+\_\+gsm48\+\_\+range} range, const int $\ast$arfcns, int size, int $\ast$out, const int index)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns} (enum \textbf{ osmo\+\_\+gsm48\+\_\+range} range, const int $\ast$arfcns, int size, int $\ast$out, const int index)
\begin{DoxyCompactList}\small\item\em Range encode the ARFCN list. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+determine\+\_\+range} (const int $\ast$arfcns, const int size, int $\ast$f0)
\begin{DoxyCompactList}\small\item\em This implements the range determination as described in GSM 04.\+08 J4. \end{DoxyCompactList}\item 
static void \textbf{ write\+\_\+orig\+\_\+arfcn} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0)
\item 
static void \textbf{ write\+\_\+all\+\_\+wn} (uint8\+\_\+t $\ast$chan\+\_\+list, int bit\+\_\+offs, int $\ast$w, int w\+\_\+size, int w1\+\_\+len)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+1024} (uint8\+\_\+t $\ast$chan\+\_\+list, int f0, int f0\+\_\+included, int $\ast$w)
\item 
int \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+filter\+\_\+arfcns} (int $\ast$arfcns, const int size, const int f0, int $\ast$f0\+\_\+included)
\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\label{gsm48__arfcn__range__encode_8c_a4f9bf9deb6ebd5feffaecadc9b5ad12e}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!\_range\_enc\_arfcns@{\_range\_enc\_arfcns}}
\index{\_range\_enc\_arfcns@{\_range\_enc\_arfcns}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{\_range\_enc\_arfcns()}
{\footnotesize\ttfamily static int \+\_\+range\+\_\+enc\+\_\+arfcns (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}]{range,  }\item[{const int $\ast$}]{arfcns,  }\item[{int}]{size,  }\item[{int $\ast$}]{out,  }\item[{const int}]{index }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ greatest\+\_\+power\+\_\+of\+\_\+2\+\_\+lesser\+\_\+or\+\_\+equal\+\_\+to()}, \textbf{ mod()}, \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns()}, and \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index()}.



Referenced by \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_ac9d5fb05564ac60b1fc73624db876460}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!greatest\_power\_of\_2\_lesser\_or\_equal\_to@{greatest\_power\_of\_2\_lesser\_or\_equal\_to}}
\index{greatest\_power\_of\_2\_lesser\_or\_equal\_to@{greatest\_power\_of\_2\_lesser\_or\_equal\_to}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{greatest\_power\_of\_2\_lesser\_or\_equal\_to()}
{\footnotesize\ttfamily static int greatest\+\_\+power\+\_\+of\+\_\+2\+\_\+lesser\+\_\+or\+\_\+equal\+\_\+to (\begin{DoxyParamCaption}\item[{int}]{index }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a61fb110268d20f5b787b5c291c585257}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!mod@{mod}}
\index{mod@{mod}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{mod()}
{\footnotesize\ttfamily static int mod (\begin{DoxyParamCaption}\item[{int}]{data,  }\item[{int}]{range }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ data}, and \textbf{ res}.



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}, \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+filter\+\_\+arfcns()}, and \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_ad5c908fde30a9225b9b135f9f20e4861}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_1024@{osmo\_gsm48\_range\_enc\_1024}}
\index{osmo\_gsm48\_range\_enc\_1024@{osmo\_gsm48\_range\_enc\_1024}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_1024()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+1024 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int}]{f0\+\_\+included,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a6d9a7c982386b4ee5c6d35a7024f190c}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_128@{osmo\_gsm48\_range\_enc\_128}}
\index{osmo\_gsm48\_range\_enc\_128@{osmo\_gsm48\_range\_enc\_128}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_128()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_aed2cdbc388075b6ccb28a621d18b9a3c}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_256@{osmo\_gsm48\_range\_enc\_256}}
\index{osmo\_gsm48\_range\_enc\_256@{osmo\_gsm48\_range\_enc\_256}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_256()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a4f830c03682612b8245be84fb1e11832}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_512@{osmo\_gsm48\_range\_enc\_512}}
\index{osmo\_gsm48\_range\_enc\_512@{osmo\_gsm48\_range\_enc\_512}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_512()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512 (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0,  }\item[{int $\ast$}]{w }\end{DoxyParamCaption})}



References \textbf{ write\+\_\+all\+\_\+wn()}, and \textbf{ write\+\_\+orig\+\_\+arfcn()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_ad61574f6d42e7faac795f3dba29ff63f}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_arfcns@{osmo\_gsm48\_range\_enc\_arfcns}}
\index{osmo\_gsm48\_range\_enc\_arfcns@{osmo\_gsm48\_range\_enc\_arfcns}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_arfcns()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+arfcns (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}]{range,  }\item[{const int $\ast$}]{arfcns,  }\item[{int}]{size,  }\item[{int $\ast$}]{out,  }\item[{const int}]{index }\end{DoxyParamCaption})}



Range encode the ARFCN list. 


\begin{DoxyParams}{Parameters}
{\em range} & The range to use. \\
\hline
{\em arfcns} & The list of ARFCNs \\
\hline
{\em size} & The size of the list of ARFCNs \\
\hline
{\em out} & Place to store the W(i) output. \\
\hline
\end{DoxyParams}


References \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}.



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}, and \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a844b7ce3d3634401800acd1111a2d978}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_determine\_range@{osmo\_gsm48\_range\_enc\_determine\_range}}
\index{osmo\_gsm48\_range\_enc\_determine\_range@{osmo\_gsm48\_range\_enc\_determine\_range}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_determine\_range()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+determine\+\_\+range (\begin{DoxyParamCaption}\item[{const int $\ast$}]{arfcns,  }\item[{const int}]{size,  }\item[{int $\ast$}]{f0 }\end{DoxyParamCaption})}



This implements the range determination as described in GSM 04.\+08 J4. 

The result will be a base frequency f0 and the range to use. Note that for range 1024 encoding f0 always refers to ARFCN 0 even if it is not an element of the arfcns list.


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em arfcns} & The input frequencies, they must be sorted, lowest number first \\
\hline
\mbox{\texttt{ in}}  & {\em size} & The length of the array \\
\hline
\mbox{\texttt{ out}}  & {\em f0} & The selected F0 base frequency. It might not be inside the list \\
\hline
\end{DoxyParams}


References \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+1024}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+128}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+256}, \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+512}, and \textbf{ OSMO\+\_\+\+GSM48\+\_\+\+ARFCN\+\_\+\+RANGE\+\_\+\+INVALID}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a2973635a9b9e4b6a1367dc061d87391f}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_filter\_arfcns@{osmo\_gsm48\_range\_enc\_filter\_arfcns}}
\index{osmo\_gsm48\_range\_enc\_filter\_arfcns@{osmo\_gsm48\_range\_enc\_filter\_arfcns}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_filter\_arfcns()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+filter\+\_\+arfcns (\begin{DoxyParamCaption}\item[{int $\ast$}]{arfcns,  }\item[{const int}]{size,  }\item[{const int}]{f0,  }\item[{int $\ast$}]{f0\+\_\+included }\end{DoxyParamCaption})}



References \textbf{ mod()}.



Referenced by \textbf{ range\+\_\+encode()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a16b1233183e2440b804ef6be07eb2678}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!osmo\_gsm48\_range\_enc\_find\_index@{osmo\_gsm48\_range\_enc\_find\_index}}
\index{osmo\_gsm48\_range\_enc\_find\_index@{osmo\_gsm48\_range\_enc\_find\_index}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{osmo\_gsm48\_range\_enc\_find\_index()}
{\footnotesize\ttfamily int osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+find\+\_\+index (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+gsm48\+\_\+range}}]{range,  }\item[{const int $\ast$}]{freqs,  }\item[{const int}]{size }\end{DoxyParamCaption})}



Determine at which index to split the ARFCNs to create an equally size partition for the given range. 

Return -\/1 if no such partition exists. 

References \textbf{ mod()}, and \textbf{ n}.



Referenced by \textbf{ \+\_\+range\+\_\+enc\+\_\+arfcns()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_a656acc5f7ca911814c61de3bdaa3b778}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!write\_all\_wn@{write\_all\_wn}}
\index{write\_all\_wn@{write\_all\_wn}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{write\_all\_wn()}
{\footnotesize\ttfamily static void write\+\_\+all\+\_\+wn (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{bit\+\_\+offs,  }\item[{int $\ast$}]{w,  }\item[{int}]{w\+\_\+size,  }\item[{int}]{w1\+\_\+len }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ level}.



Referenced by \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+1024()}, \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128()}, \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256()}, and \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512()}.

\mbox{\label{gsm48__arfcn__range__encode_8c_ac17019adc23972a2e71598cee2397159}} 
\index{gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}!write\_orig\_arfcn@{write\_orig\_arfcn}}
\index{write\_orig\_arfcn@{write\_orig\_arfcn}!gsm48\_arfcn\_range\_encode.c@{gsm48\_arfcn\_range\_encode.c}}
\doxysubsubsection{write\_orig\_arfcn()}
{\footnotesize\ttfamily static void write\+\_\+orig\+\_\+arfcn (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{chan\+\_\+list,  }\item[{int}]{f0 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Referenced by \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+128()}, \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+256()}, and \textbf{ osmo\+\_\+gsm48\+\_\+range\+\_\+enc\+\_\+512()}.

