\doxysection{src/gsm/gsm23236.c File Reference}
\label{gsm23236_8c}\index{src/gsm/gsm23236.c@{src/gsm/gsm23236.c}}


Utility function implementations related to 3GPP TS 23.\+236.  


{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/gsm23236.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+validate} (int16\+\_\+t nri\+\_\+v, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Validate that the given NRI is valid for a given nri\+\_\+bitlen range. \end{DoxyCompactList}\item 
static bool \textbf{ nri\+\_\+v\+\_\+matches\+\_\+range} (const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$range, int16\+\_\+t nri\+\_\+v)
\begin{DoxyCompactList}\small\item\em Match NRI value against a list NRI ranges. \end{DoxyCompactList}\item 
static bool \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range} (const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$a, const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$b)
\begin{DoxyCompactList}\small\item\em Return true if the ranges overlap, i.\+e. \end{DoxyCompactList}\item 
static bool \textbf{ nri\+\_\+range\+\_\+touches} (const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$a, const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$b)
\begin{DoxyCompactList}\small\item\em Return true if the ranges overlap or are directly adjacent to each other. \end{DoxyCompactList}\item 
static void \textbf{ nri\+\_\+range\+\_\+extend} (struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$target, const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$add)
\begin{DoxyCompactList}\small\item\em Grow target range to also span range \textquotesingle{}add\textquotesingle{}. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+matches\+\_\+ranges} (int16\+\_\+t nri\+\_\+v, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges)
\begin{DoxyCompactList}\small\item\em Return true when the given NRI value appears in the list of NRI ranges. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges} (int16\+\_\+t $\ast$nri\+\_\+v, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, uint32\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Modulo and shift the given NRI value so that it becomes a value present in a list of NRI ranges. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+get} (int16\+\_\+t $\ast$nri\+\_\+v, uint32\+\_\+t tmsi, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Retrieve the Network Resource Indicator bits from a TMSI or p-\/\+TMSI. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+set} (uint32\+\_\+t $\ast$tmsi, int16\+\_\+t nri\+\_\+v, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Write Network Resource Indicator bits into a TMSI or p-\/\+TMSI. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges} (uint32\+\_\+t $\ast$tmsi, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Apply \doxyref{osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}{p.}{gsm23236_8c_a58aa2e811837ad9fb904cdd4e223a8c7} in-\/place on the NRI value included in a TMSI. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate} (const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$range, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em Validate that the given NRI range is valid for a given nri\+\_\+bitlen range. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+overlaps\+\_\+ranges} (const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$range, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges)
\begin{DoxyCompactList}\small\item\em Return true when the given NRI range has at least one NRI value that appears in a list of other NRI ranges. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$ \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+alloc} (void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Allocate an empty struct \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges} (list of struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range}). \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+free} (struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges)
\begin{DoxyCompactList}\small\item\em Free a struct \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges}. \end{DoxyCompactList}\item 
static void \textbf{ nri\+\_\+ranges\+\_\+add\+\_\+entry\+\_\+sorted} (struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$add)
\begin{DoxyCompactList}\small\item\em Insert a new struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range} in an \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges} list, so that it remains sorted by \textquotesingle{}first\textquotesingle{} values. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add} (struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$add)
\begin{DoxyCompactList}\small\item\em Add a range of NRI values to a list of nri\+\_\+range structs. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+del} (struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$del)
\begin{DoxyCompactList}\small\item\em Remove a range of NRI values from a list of nri\+\_\+range structs. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+buf} (char $\ast$buf, size\+\_\+t buflen, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges)
\begin{DoxyCompactList}\small\item\em Compose a human readable representation of a list of NRI ranges in a buffer, like \char`\"{}23..\+42,123..\+142\char`\"{}. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+c} (void $\ast$ctx, const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges)
\begin{DoxyCompactList}\small\item\em Compose a human readable representation of a list of NRI ranges in a talloc buffer, like \char`\"{}23..\+42,123..\+142\char`\"{}. \end{DoxyCompactList}\item 
static int \textbf{ osmo\+\_\+nri\+\_\+parse} (int16\+\_\+t $\ast$dst, const char $\ast$str)
\begin{DoxyCompactList}\small\item\em Parse a string to an NRI value, allowing both decimal and hexadecimal formats; useful for VTY config implementations. \end{DoxyCompactList}\item 
static int \textbf{ osmo\+\_\+nri\+\_\+parse\+\_\+range} (struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$nri\+\_\+range, const char $\ast$first\+\_\+str, const char $\ast$last\+\_\+str)
\begin{DoxyCompactList}\small\item\em Parse string arguments to a struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range}; useful for VTY config implementations. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+add} (const char $\ast$$\ast$message, struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$added\+\_\+range, struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, int \textbf{ argc}, const char $\ast$$\ast$\textbf{ argv}, uint8\+\_\+t nri\+\_\+bitlen)
\begin{DoxyCompactList}\small\item\em VTY implementation for adding an NRI range to a list of ranges. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+del} (const char $\ast$$\ast$message, struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$removed\+\_\+range, struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$nri\+\_\+ranges, int \textbf{ argc}, const char $\ast$$\ast$\textbf{ argv})
\begin{DoxyCompactList}\small\item\em VTY implementation for removing an NRI range from a list of ranges. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Utility function implementations related to 3GPP TS 23.\+236. 



\doxysubsection{Function Documentation}
\mbox{\label{gsm23236_8c_a5b03b4a80f7e8509760f5a8e2ea8ac6f}} 
\index{gsm23236.c@{gsm23236.c}!nri\_range\_extend@{nri\_range\_extend}}
\index{nri\_range\_extend@{nri\_range\_extend}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{nri\_range\_extend()}
{\footnotesize\ttfamily static void nri\+\_\+range\+\_\+extend (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{target,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{add }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Grow target range to also span range \textquotesingle{}add\textquotesingle{}. 

Only useful for touching ranges, since all values between the two ranges are also included. 

References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, \textbf{ OSMO\+\_\+\+MAX}, and \textbf{ OSMO\+\_\+\+MIN}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add()}.

\mbox{\label{gsm23236_8c_afa909bdb46e1c5d80b6ebf9a5ec5c3b8}} 
\index{gsm23236.c@{gsm23236.c}!nri\_range\_overlaps\_range@{nri\_range\_overlaps\_range}}
\index{nri\_range\_overlaps\_range@{nri\_range\_overlaps\_range}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{nri\_range\_overlaps\_range()}
{\footnotesize\ttfamily static bool nri\+\_\+range\+\_\+overlaps\+\_\+range (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{a,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Return true if the ranges overlap, i.\+e. 

one or more NRI values appear in both ranges. 

References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, and \textbf{ nri\+\_\+v\+\_\+matches\+\_\+range()}.



Referenced by \textbf{ nri\+\_\+range\+\_\+touches()}, \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+overlaps\+\_\+ranges()}, and \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+del()}.

\mbox{\label{gsm23236_8c_a193924af31ab0e7c9e5681642cede1cc}} 
\index{gsm23236.c@{gsm23236.c}!nri\_range\_touches@{nri\_range\_touches}}
\index{nri\_range\_touches@{nri\_range\_touches}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{nri\_range\_touches()}
{\footnotesize\ttfamily static bool nri\+\_\+range\+\_\+touches (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{a,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Return true if the ranges overlap or are directly adjacent to each other. 



References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, and \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add()}.

\mbox{\label{gsm23236_8c_a0f4344a990d5394e6c6980c1d28ef4c6}} 
\index{gsm23236.c@{gsm23236.c}!nri\_ranges\_add\_entry\_sorted@{nri\_ranges\_add\_entry\_sorted}}
\index{nri\_ranges\_add\_entry\_sorted@{nri\_ranges\_add\_entry\_sorted}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{nri\_ranges\_add\_entry\_sorted()}
{\footnotesize\ttfamily static void nri\+\_\+ranges\+\_\+add\+\_\+entry\+\_\+sorted (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{add }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Insert a new struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range} in an \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges} list, so that it remains sorted by \textquotesingle{}first\textquotesingle{} values. 



References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ llist\+\_\+add()}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ OSMO\+\_\+\+ASSERT}, and \textbf{ llist\+\_\+head\+::prev}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add()}.

\mbox{\label{gsm23236_8c_aad1659444ad4eeb2585cec2fa8cde4cc}} 
\index{gsm23236.c@{gsm23236.c}!nri\_v\_matches\_range@{nri\_v\_matches\_range}}
\index{nri\_v\_matches\_range@{nri\_v\_matches\_range}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{nri\_v\_matches\_range()}
{\footnotesize\ttfamily static bool nri\+\_\+v\+\_\+matches\+\_\+range (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{range,  }\item[{int16\+\_\+t}]{nri\+\_\+v }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Match NRI value against a list NRI ranges. 



References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, and \textbf{ osmo\+\_\+nri\+\_\+range\+::last}.



Referenced by \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range()}, \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+del()}, and \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+matches\+\_\+ranges()}.

\mbox{\label{gsm23236_8c_a5e682eebf46fd08d619cad4ecd05bdd8}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_parse@{osmo\_nri\_parse}}
\index{osmo\_nri\_parse@{osmo\_nri\_parse}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_parse()}
{\footnotesize\ttfamily static int osmo\+\_\+nri\+\_\+parse (\begin{DoxyParamCaption}\item[{int16\+\_\+t $\ast$}]{dst,  }\item[{const char $\ast$}]{str }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Parse a string to an NRI value, allowing both decimal and hexadecimal formats; useful for VTY config implementations. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em dst} & Write the resulting NRI value to this location. \\
\hline
\mbox{\texttt{ in}}  & {\em str} & Decimal \char`\"{}511\char`\"{} or hex \char`\"{}0x1ff\char`\"{} string to parse. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+str\+\_\+startswith()}, and \textbf{ osmo\+\_\+str\+\_\+to\+\_\+int()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+parse\+\_\+range()}.

\mbox{\label{gsm23236_8c_a06fc7566101418c02c6ed8ad121becd6}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_parse\_range@{osmo\_nri\_parse\_range}}
\index{osmo\_nri\_parse\_range@{osmo\_nri\_parse\_range}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_parse\_range()}
{\footnotesize\ttfamily static int osmo\+\_\+nri\+\_\+parse\+\_\+range (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{nri\+\_\+range,  }\item[{const char $\ast$}]{first\+\_\+str,  }\item[{const char $\ast$}]{last\+\_\+str }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Parse string arguments to a struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range}; useful for VTY config implementations. 

Validate and parse \textquotesingle{}first\textquotesingle{} and optional \textquotesingle{}last\textquotesingle{} string arguments into struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range} values. The strings may be in decimal format (\char`\"{}511\char`\"{}) or hexadecimal with leading \char`\"{}0x\char`\"{} (\char`\"{}0x1ff\char`\"{}). If only one of \textquotesingle{}first\textquotesingle{}/\textquotesingle{}last\textquotesingle{} is provided, the resulting range will have only that value (first == last). 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em nri\+\_\+range} & Target for parsed values. \\
\hline
\mbox{\texttt{ in}}  & {\em first\+\_\+str} & Decimal or hex string, representing the first value in the range, or NULL if omitted. \\
\hline
\mbox{\texttt{ in}}  & {\em last\+\_\+str} & Decimal or hex string, representing the last value in the range, or NULL if omitted. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, and \textbf{ osmo\+\_\+nri\+\_\+parse()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+add()}, and \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+del()}.

\mbox{\label{gsm23236_8c_ab6dd4caf3147f415ddb072b6f412c226}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_range\_overlaps\_ranges@{osmo\_nri\_range\_overlaps\_ranges}}
\index{osmo\_nri\_range\_overlaps\_ranges@{osmo\_nri\_range\_overlaps\_ranges}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_range\_overlaps\_ranges()}
{\footnotesize\ttfamily bool osmo\+\_\+nri\+\_\+range\+\_\+overlaps\+\_\+ranges (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{range,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges }\end{DoxyParamCaption})}



Return true when the given NRI range has at least one NRI value that appears in a list of other NRI ranges. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em range} & NRI range to look for. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List NRI ranges. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true iff any NRI value from \textquotesingle{}range\textquotesingle{} appears anywhere in nri\+\_\+ranges. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range()}.

\mbox{\label{gsm23236_8c_a4524a76b894d3129cf94ef016cc13e6d}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_range\_validate@{osmo\_nri\_range\_validate}}
\index{osmo\_nri\_range\_validate@{osmo\_nri\_range\_validate}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_range\_validate()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+range\+\_\+validate (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{range,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Validate that the given NRI range is valid for a given nri\+\_\+bitlen range. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nri\+\_\+range} & NRI value range to validate. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Valid NRI range in nr of bits used. If nri\+\_\+bitlen $>$ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX, the NRI range is only validated to be first $<$= last and non-\/negative, not checked to fit a bit length range, \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if valid, -\/1 or 1 if range-\/$>$first is invalid, -\/2 or 2 if range-\/$>$last is invalid, -\/3 if first $>$ last. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, and \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+validate()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add()}, \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+del()}, \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+add()}, and \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}.

\mbox{\label{gsm23236_8c_a605dcaa480dba2b8135bff334819d453}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_add@{osmo\_nri\_ranges\_add}}
\index{osmo\_nri\_ranges\_add@{osmo\_nri\_ranges\_add}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_add()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+ranges\+\_\+add (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{add }\end{DoxyParamCaption})}



Add a range of NRI values to a list of nri\+\_\+range structs. 

Intelligently add and/or combine the entries in a list of NRI ranges to also include the NRI range given in \textquotesingle{}add\textquotesingle{}. The list remains sorted by \textquotesingle{}first\textquotesingle{} values. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em nri\+\_\+ranges} & List of talloc allocated struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range} entries to add the new range to. \\
\hline
\mbox{\texttt{ in}}  & {\em add} & NRI range to add to \textquotesingle{}nri\+\_\+ranges\textquotesingle{}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error (if the range in \textquotesingle{}add\textquotesingle{} is invalid). 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::entry}, \textbf{ llist\+\_\+del()}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry\+\_\+safe}, \textbf{ nri\+\_\+range\+\_\+extend()}, \textbf{ nri\+\_\+range\+\_\+touches()}, \textbf{ nri\+\_\+ranges\+\_\+add\+\_\+entry\+\_\+sorted()}, \textbf{ OSMO\+\_\+\+ASSERT}, and \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+add()}.

\mbox{\label{gsm23236_8c_a25fc6a315a7c0479c71b19328f6698d3}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_alloc@{osmo\_nri\_ranges\_alloc}}
\index{osmo\_nri\_ranges\_alloc@{osmo\_nri\_ranges\_alloc}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_alloc()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$ osmo\+\_\+nri\+\_\+ranges\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



Allocate an empty struct \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges} (list of struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range}). 


\begin{DoxyParams}{Parameters}
{\em ctx} & Talloc context to allocate from. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
allocated empty list. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, and \textbf{ OSMO\+\_\+\+ASSERT}.

\mbox{\label{gsm23236_8c_a433f2867aba1e9f03dd407e30d7f0b65}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_del@{osmo\_nri\_ranges\_del}}
\index{osmo\_nri\_ranges\_del@{osmo\_nri\_ranges\_del}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_del()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+ranges\+\_\+del (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{del }\end{DoxyParamCaption})}



Remove a range of NRI values from a list of nri\+\_\+range structs. 

Intelligently drop and/or cut or split the entries in a list of NRI ranges to no longer include the NRI range given in \textquotesingle{}del\textquotesingle{}. Note that after this, the list may have more entries than before, if a range was split into two smaller ranges. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em nri\+\_\+ranges} & List of talloc allocated struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range} entries to remove values from. \\
\hline
\mbox{\texttt{ in}}  & {\em del} & NRI range to remove from \textquotesingle{}nri\+\_\+ranges\textquotesingle{}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error (if the range in \textquotesingle{}del\textquotesingle{} is invalid). 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, \textbf{ llist\+\_\+add()}, \textbf{ llist\+\_\+del()}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry\+\_\+safe}, \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range()}, \textbf{ nri\+\_\+v\+\_\+matches\+\_\+range()}, \textbf{ OSMO\+\_\+\+ASSERT}, and \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate()}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+del()}.

\mbox{\label{gsm23236_8c_a0177e18f2ed4b792210c59333f55af2e}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_free@{osmo\_nri\_ranges\_free}}
\index{osmo\_nri\_ranges\_free@{osmo\_nri\_ranges\_free}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_free()}
{\footnotesize\ttfamily void osmo\+\_\+nri\+\_\+ranges\+\_\+free (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges }\end{DoxyParamCaption})}



Free a struct \doxyref{osmo\+\_\+nri\+\_\+ranges}{p.}{structosmo__nri__ranges}. 


\begin{DoxyParams}{Parameters}
{\em nri\+\_\+ranges} & The list to discard. \\
\hline
\end{DoxyParams}
\mbox{\label{gsm23236_8c_aeb03020d6d17390122c1b913e86053c4}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_to\_str\_buf@{osmo\_nri\_ranges\_to\_str\_buf}}
\index{osmo\_nri\_ranges\_to\_str\_buf@{osmo\_nri\_ranges\_to\_str\_buf}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_to\_str\_buf()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buflen,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges }\end{DoxyParamCaption})}



Compose a human readable representation of a list of NRI ranges in a buffer, like \char`\"{}23..\+42,123..\+142\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em buf} & Target buffer. \\
\hline
\mbox{\texttt{ in}}  & {\em buflen} & sizeof(buf). \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List NRI ranges. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
strlen() of string that would be written if the buffer is large enough, like snprintf(). 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+strbuf\+::buf}, \textbf{ osmo\+\_\+strbuf\+::chars\+\_\+needed}, \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, \textbf{ llist\+\_\+empty()}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ OSMO\+\_\+\+STRBUF\+\_\+\+PRINTF}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+c()}.

\mbox{\label{gsm23236_8c_a06560b8d90d3904eabfdb5e1ca1a0ff2}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_to\_str\_c@{osmo\_nri\_ranges\_to\_str\_c}}
\index{osmo\_nri\_ranges\_to\_str\_c@{osmo\_nri\_ranges\_to\_str\_c}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_to\_str\_c()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+c (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges }\end{DoxyParamCaption})}



Compose a human readable representation of a list of NRI ranges in a talloc buffer, like \char`\"{}23..\+42,123..\+142\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & Talloc context. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List of NRI ranges. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a talloc allocated string. 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+NAME\+\_\+\+C\+\_\+\+IMPL}, and \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+to\+\_\+str\+\_\+buf()}.

\mbox{\label{gsm23236_8c_a4e0174de83a9cf340571419c755c339a}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_vty\_add@{osmo\_nri\_ranges\_vty\_add}}
\index{osmo\_nri\_ranges\_vty\_add@{osmo\_nri\_ranges\_vty\_add}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_vty\_add()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+add (\begin{DoxyParamCaption}\item[{const char $\ast$$\ast$}]{message,  }\item[{struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{added\+\_\+range,  }\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{int}]{argc,  }\item[{const char $\ast$$\ast$}]{argv,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



VTY implementation for adding an NRI range to a list of ranges. 

Parse one or, if present, two argv arguments, which must be numbers representing the first and last value to add to the list of NRI ranges, in decimal format (\char`\"{}511\char`\"{}) or hexadecimal with leading \char`\"{}0x\char`\"{} (\char`\"{}0x1ff\char`\"{}). If the range values surpass the nri\+\_\+bitlen, return a warning in \textquotesingle{}message\textquotesingle{}, but still add the values to the list. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em message} & Returned string constant to alert the user with, or NULL if all is well. \\
\hline
\mbox{\texttt{ out}}  & {\em added\+\_\+range} & If not NULL, write the range parsing result to this location. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List NRI ranges to add to. \\
\hline
\mbox{\texttt{ in}}  & {\em argc} & Argument count. \\
\hline
\mbox{\texttt{ in}}  & {\em argv} & Argument list. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Valid NRI range in nr of bits used. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on error, 1 for a warning (if adding was successful but the added range surpasses nri\+\_\+bitlen). 
\end{DoxyReturn}


References \textbf{ argc}, \textbf{ argv}, \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX}, \textbf{ osmo\+\_\+nri\+\_\+parse\+\_\+range()}, \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate()}, and \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+add()}.

\mbox{\label{gsm23236_8c_a86c40de8e3ec5064b89c54f147c2b398}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_ranges\_vty\_del@{osmo\_nri\_ranges\_vty\_del}}
\index{osmo\_nri\_ranges\_vty\_del@{osmo\_nri\_ranges\_vty\_del}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_ranges\_vty\_del()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+ranges\+\_\+vty\+\_\+del (\begin{DoxyParamCaption}\item[{const char $\ast$$\ast$}]{message,  }\item[{struct \textbf{ osmo\+\_\+nri\+\_\+range} $\ast$}]{removed\+\_\+range,  }\item[{struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{int}]{argc,  }\item[{const char $\ast$$\ast$}]{argv }\end{DoxyParamCaption})}



VTY implementation for removing an NRI range from a list of ranges. 

Parse one or, if present, two argv arguments, which must be numbers representing the first and last value to remove from the list of NRI ranges, in decimal format (\char`\"{}511\char`\"{}) or hexadecimal with leading \char`\"{}0x\char`\"{} (\char`\"{}0x1ff\char`\"{}). 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em message} & Returned string constant to alert the user with, or NULL if all is well. \\
\hline
\mbox{\texttt{ out}}  & {\em removed\+\_\+range} & If not NULL, write the range parsing result to this location. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List of NRI ranges to remove from. \\
\hline
\mbox{\texttt{ in}}  & {\em argc} & Argument count. \\
\hline
\mbox{\texttt{ in}}  & {\em argv} & Argument list. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on error, 1 for a warning. 
\end{DoxyReturn}


References \textbf{ argc}, \textbf{ argv}, \textbf{ osmo\+\_\+nri\+\_\+parse\+\_\+range()}, and \textbf{ osmo\+\_\+nri\+\_\+ranges\+\_\+del()}.

\mbox{\label{gsm23236_8c_a58aa2e811837ad9fb904cdd4e223a8c7}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_v\_limit\_by\_ranges@{osmo\_nri\_v\_limit\_by\_ranges}}
\index{osmo\_nri\_v\_limit\_by\_ranges@{osmo\_nri\_v\_limit\_by\_ranges}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_v\_limit\_by\_ranges()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges (\begin{DoxyParamCaption}\item[{int16\+\_\+t $\ast$}]{nri\+\_\+v,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{uint32\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Modulo and shift the given NRI value so that it becomes a value present in a list of NRI ranges. 

Only range values within nri\+\_\+bitlen are used. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em nri\+\_\+v} & The NRI value to limit, e.\+g. random bits or an increment counter value. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List of NRI ranges indicating valid NRI values, where no entries may overlap in range values, and all entries must be valid (first $<$= last). \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ osmo\+\_\+nri\+\_\+range\+::first}, \textbf{ osmo\+\_\+nri\+\_\+range\+::last}, \textbf{ len}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ OSMO\+\_\+\+MIN}, and \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate()}.



Referenced by \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}.

\mbox{\label{gsm23236_8c_a1ff484c82f1ed8ee84d796ad9d7fd004}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_v\_matches\_ranges@{osmo\_nri\_v\_matches\_ranges}}
\index{osmo\_nri\_v\_matches\_ranges@{osmo\_nri\_v\_matches\_ranges}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_v\_matches\_ranges()}
{\footnotesize\ttfamily bool osmo\+\_\+nri\+\_\+v\+\_\+matches\+\_\+ranges (\begin{DoxyParamCaption}\item[{int16\+\_\+t}]{nri\+\_\+v,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges }\end{DoxyParamCaption})}



Return true when the given NRI value appears in the list of NRI ranges. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nri\+\_\+v} & NRI value to look for. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List NRI ranges. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true iff nri\+\_\+v appears anywhere in nri\+\_\+ranges. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+ranges\+::entries}, \textbf{ entry}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ nri\+\_\+v\+\_\+matches\+\_\+range()}.

\mbox{\label{gsm23236_8c_a1df8435960195ebaaa8b67ad1d610a4a}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_nri\_v\_validate@{osmo\_nri\_v\_validate}}
\index{osmo\_nri\_v\_validate@{osmo\_nri\_v\_validate}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_nri\_v\_validate()}
{\footnotesize\ttfamily int osmo\+\_\+nri\+\_\+v\+\_\+validate (\begin{DoxyParamCaption}\item[{int16\+\_\+t}]{nri\+\_\+v,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Validate that the given NRI is valid for a given nri\+\_\+bitlen range. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nri\+\_\+v} & NRI value to validate. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Valid NRI range in nr of bits used; if nri\+\_\+bitlen $>$ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX, nri\+\_\+v is only checked to not be marked invalid. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if valid, $<$0 if the NRI is $<$0, $>$0 if the NRI surpasses the range. 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX}, and \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MIN}.



Referenced by \textbf{ osmo\+\_\+nri\+\_\+range\+\_\+validate()}.

\mbox{\label{gsm23236_8c_a4de786786e11c95ff0a44264caf4a390}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_tmsi\_nri\_v\_get@{osmo\_tmsi\_nri\_v\_get}}
\index{osmo\_tmsi\_nri\_v\_get@{osmo\_tmsi\_nri\_v\_get}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_tmsi\_nri\_v\_get()}
{\footnotesize\ttfamily int osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+get (\begin{DoxyParamCaption}\item[{int16\+\_\+t $\ast$}]{nri\+\_\+v,  }\item[{uint32\+\_\+t}]{tmsi,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Retrieve the Network Resource Indicator bits from a TMSI or p-\/\+TMSI. 

Useful for MSC pooling as described by 3GPP TS 23.\+236. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em nri\+\_\+v} & Write the extracted NRI value to this location (if non-\/\+NULL). If 0 is returned, it is guaranteed that nri\+\_\+v $>$= 0. On non-\/zero return code, nri\+\_\+v == -\/1. \\
\hline
\mbox{\texttt{ in}}  & {\em tmsi} & TMSI value containing NRI bits. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Length of the NRI value in number of bits, OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MIN $<$= nri\+\_\+bitlen $<$= $\ast$ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error (i.\+e. if nri\+\_\+bitlen is not in the valid range). 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX}.



Referenced by \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}.

\mbox{\label{gsm23236_8c_a2e354a0d091dd1836ab3243cf577bf9e}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_tmsi\_nri\_v\_limit\_by\_ranges@{osmo\_tmsi\_nri\_v\_limit\_by\_ranges}}
\index{osmo\_tmsi\_nri\_v\_limit\_by\_ranges@{osmo\_tmsi\_nri\_v\_limit\_by\_ranges}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_tmsi\_nri\_v\_limit\_by\_ranges()}
{\footnotesize\ttfamily int osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges (\begin{DoxyParamCaption}\item[{uint32\+\_\+t $\ast$}]{tmsi,  }\item[{const struct \textbf{ osmo\+\_\+nri\+\_\+ranges} $\ast$}]{nri\+\_\+ranges,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Apply \doxyref{osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}{p.}{gsm23236_8c_a58aa2e811837ad9fb904cdd4e223a8c7} in-\/place on the NRI value included in a TMSI. 

Extract the NRI value from the TMSI, limit that to be part of the ranges given in \textquotesingle{}nri\+\_\+ranges\textquotesingle{}, and place the resulting NRI value back in the TMSI. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em tmsi} & TMSI value of which to modify the NRI bits, e.\+g. fresh randomized bits. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+ranges} & List of NRI ranges indicating valid NRI values, where no entries may overlap in range values, and all entries must be valid (first $<$= last). \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Valid NRI range in nr of bits used. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}, \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+get()}, and \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+set()}.

\mbox{\label{gsm23236_8c_ac3a197fdc119b7011edaa1dc04f0056f}} 
\index{gsm23236.c@{gsm23236.c}!osmo\_tmsi\_nri\_v\_set@{osmo\_tmsi\_nri\_v\_set}}
\index{osmo\_tmsi\_nri\_v\_set@{osmo\_tmsi\_nri\_v\_set}!gsm23236.c@{gsm23236.c}}
\doxysubsubsection{osmo\_tmsi\_nri\_v\_set()}
{\footnotesize\ttfamily int osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+set (\begin{DoxyParamCaption}\item[{uint32\+\_\+t $\ast$}]{tmsi,  }\item[{int16\+\_\+t}]{nri\+\_\+v,  }\item[{uint8\+\_\+t}]{nri\+\_\+bitlen }\end{DoxyParamCaption})}



Write Network Resource Indicator bits into a TMSI or p-\/\+TMSI. 

Overwrite the NRI bits with a given NRI value in a TMSI or p-\/\+TMSI. Useful for MSC pooling as described by 3GPP TS 23.\+236. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em tmsi} & A base TMSI or p-\/\+TMSI to replace the NRI value in, result is written back to this location. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+v} & The NRI value to place in the tmsi. \\
\hline
\mbox{\texttt{ in}}  & {\em nri\+\_\+bitlen} & Length of the NRI value in number of bits, OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MIN $<$= nri\+\_\+bitlen $<$= $\ast$ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, negative on error (i.\+e. if nri\+\_\+bitlen is not in the valid range or if tmsi is NULL). 
\end{DoxyReturn}


References \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX}.



Referenced by \textbf{ osmo\+\_\+tmsi\+\_\+nri\+\_\+v\+\_\+limit\+\_\+by\+\_\+ranges()}.

