\doxysection{include/osmocom/gsm/gsm23236.h File Reference}
\label{gsm23236_8h}\index{include/osmocom/gsm/gsm23236.h@{include/osmocom/gsm/gsm23236.h}}


API to handle Network Resource Indicator (NRI) values and ranges for MSC pooling, as in 3GPP TS 23.\+236.  


{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+nri\+\_\+range}
\begin{DoxyCompactList}\small\item\em One range of NRI values. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+nri\+\_\+ranges}
\begin{DoxyCompactList}\small\item\em A list of struct \doxyref{osmo\+\_\+nri\+\_\+range}{p.}{structosmo__nri__range}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MIN}~1
\item 
\#define \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX}~15
\item 
\#define \textbf{ OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+DEFAULT}~10
\end{DoxyCompactItemize}
\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 
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 
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\+\_\+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}\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}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
API to handle Network Resource Indicator (NRI) values and ranges for MSC pooling, as in 3GPP TS 23.\+236. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{gsm23236_8h_a0dc1ab9d89f5d484d595a1aa4da5d825}} 
\index{gsm23236.h@{gsm23236.h}!OSMO\_NRI\_BITLEN\_DEFAULT@{OSMO\_NRI\_BITLEN\_DEFAULT}}
\index{OSMO\_NRI\_BITLEN\_DEFAULT@{OSMO\_NRI\_BITLEN\_DEFAULT}!gsm23236.h@{gsm23236.h}}
\doxysubsubsection{OSMO\_NRI\_BITLEN\_DEFAULT}
{\footnotesize\ttfamily \#define OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+DEFAULT~10}

\mbox{\label{gsm23236_8h_a55d55f0d24b5274fa14a32358bc301a1}} 
\index{gsm23236.h@{gsm23236.h}!OSMO\_NRI\_BITLEN\_MAX@{OSMO\_NRI\_BITLEN\_MAX}}
\index{OSMO\_NRI\_BITLEN\_MAX@{OSMO\_NRI\_BITLEN\_MAX}!gsm23236.h@{gsm23236.h}}
\doxysubsubsection{OSMO\_NRI\_BITLEN\_MAX}
{\footnotesize\ttfamily \#define OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MAX~15}

\mbox{\label{gsm23236_8h_a7ba0d3eaaa6f3eaff64b9f2a8ee60ddb}} 
\index{gsm23236.h@{gsm23236.h}!OSMO\_NRI\_BITLEN\_MIN@{OSMO\_NRI\_BITLEN\_MIN}}
\index{OSMO\_NRI\_BITLEN\_MIN@{OSMO\_NRI\_BITLEN\_MIN}!gsm23236.h@{gsm23236.h}}
\doxysubsubsection{OSMO\_NRI\_BITLEN\_MIN}
{\footnotesize\ttfamily \#define OSMO\+\_\+\+NRI\+\_\+\+BITLEN\+\_\+\+MIN~1}



\doxysubsection{Function Documentation}
\mbox{\label{gsm23236_8h_ab6dd4caf3147f415ddb072b6f412c226}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_range\_overlaps\_ranges@{osmo\_nri\_range\_overlaps\_ranges}}
\index{osmo\_nri\_range\_overlaps\_ranges@{osmo\_nri\_range\_overlaps\_ranges}!gsm23236.h@{gsm23236.h}}
\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{ osmo\+\_\+nri\+\_\+range\+::entry}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ nri\+\_\+range\+\_\+overlaps\+\_\+range()}.

\mbox{\label{gsm23236_8h_a4524a76b894d3129cf94ef016cc13e6d}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_range\_validate@{osmo\_nri\_range\_validate}}
\index{osmo\_nri\_range\_validate@{osmo\_nri\_range\_validate}!gsm23236.h@{gsm23236.h}}
\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_8h_a605dcaa480dba2b8135bff334819d453}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_add@{osmo\_nri\_ranges\_add}}
\index{osmo\_nri\_ranges\_add@{osmo\_nri\_ranges\_add}!gsm23236.h@{gsm23236.h}}
\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{ 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_8h_a25fc6a315a7c0479c71b19328f6698d3}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_alloc@{osmo\_nri\_ranges\_alloc}}
\index{osmo\_nri\_ranges\_alloc@{osmo\_nri\_ranges\_alloc}!gsm23236.h@{gsm23236.h}}
\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_8h_a433f2867aba1e9f03dd407e30d7f0b65}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_del@{osmo\_nri\_ranges\_del}}
\index{osmo\_nri\_ranges\_del@{osmo\_nri\_ranges\_del}!gsm23236.h@{gsm23236.h}}
\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{ 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_8h_a0177e18f2ed4b792210c59333f55af2e}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_free@{osmo\_nri\_ranges\_free}}
\index{osmo\_nri\_ranges\_free@{osmo\_nri\_ranges\_free}!gsm23236.h@{gsm23236.h}}
\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_8h_aeb03020d6d17390122c1b913e86053c4}} 
\index{gsm23236.h@{gsm23236.h}!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.h@{gsm23236.h}}
\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{ 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_8h_a06560b8d90d3904eabfdb5e1ca1a0ff2}} 
\index{gsm23236.h@{gsm23236.h}!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.h@{gsm23236.h}}
\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_8h_a4e0174de83a9cf340571419c755c339a}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_vty\_add@{osmo\_nri\_ranges\_vty\_add}}
\index{osmo\_nri\_ranges\_vty\_add@{osmo\_nri\_ranges\_vty\_add}!gsm23236.h@{gsm23236.h}}
\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_8h_a86c40de8e3ec5064b89c54f147c2b398}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_ranges\_vty\_del@{osmo\_nri\_ranges\_vty\_del}}
\index{osmo\_nri\_ranges\_vty\_del@{osmo\_nri\_ranges\_vty\_del}!gsm23236.h@{gsm23236.h}}
\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_8h_a58aa2e811837ad9fb904cdd4e223a8c7}} 
\index{gsm23236.h@{gsm23236.h}!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.h@{gsm23236.h}}
\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{ osmo\+\_\+nri\+\_\+range\+::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_8h_a1ff484c82f1ed8ee84d796ad9d7fd004}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_v\_matches\_ranges@{osmo\_nri\_v\_matches\_ranges}}
\index{osmo\_nri\_v\_matches\_ranges@{osmo\_nri\_v\_matches\_ranges}!gsm23236.h@{gsm23236.h}}
\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{ osmo\+\_\+nri\+\_\+range\+::entry}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ nri\+\_\+v\+\_\+matches\+\_\+range()}.

\mbox{\label{gsm23236_8h_a1df8435960195ebaaa8b67ad1d610a4a}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_nri\_v\_validate@{osmo\_nri\_v\_validate}}
\index{osmo\_nri\_v\_validate@{osmo\_nri\_v\_validate}!gsm23236.h@{gsm23236.h}}
\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_8h_a4de786786e11c95ff0a44264caf4a390}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_tmsi\_nri\_v\_get@{osmo\_tmsi\_nri\_v\_get}}
\index{osmo\_tmsi\_nri\_v\_get@{osmo\_tmsi\_nri\_v\_get}!gsm23236.h@{gsm23236.h}}
\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_8h_a2e354a0d091dd1836ab3243cf577bf9e}} 
\index{gsm23236.h@{gsm23236.h}!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.h@{gsm23236.h}}
\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_8h_ac3a197fdc119b7011edaa1dc04f0056f}} 
\index{gsm23236.h@{gsm23236.h}!osmo\_tmsi\_nri\_v\_set@{osmo\_tmsi\_nri\_v\_set}}
\index{osmo\_tmsi\_nri\_v\_set@{osmo\_tmsi\_nri\_v\_set}!gsm23236.h@{gsm23236.h}}
\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()}.

