\doxysection{src/gsm/apn.c File Reference}
\label{apn_8c}\index{src/gsm/apn.c@{src/gsm/apn.c}}


(C) 2014 by Harald Welte {\texttt{ laforge@gnumonks.\+org}} (C) 2015,2017 by sysmocom -\/ s.\+f.\+m.\+c.  


{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/gsm/apn.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ APN\+\_\+\+OI\+\_\+\+GPRS\+\_\+\+FMT}~\char`\"{}mnc\%03u.\+mcc\%03u.\+gprs\char`\"{}
\item 
\#define \textbf{ APN\+\_\+\+GPRS\+\_\+\+FMT}~\char`\"{}\%s.\+mnc\%03u.\+mcc\%03u.\+gprs\char`\"{}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+buf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, unsigned int mcc, unsigned int mnc, const char $\ast$ni)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify} (unsigned int mcc, unsigned int mnc, const char $\ast$ni)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+c} (const void $\ast$ctx, unsigned int mcc, unsigned int mnc, const char $\ast$ni)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+buf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, const char $\ast$imsi, const char $\ast$ni, int have\+\_\+3dig\+\_\+mnc)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi} (const char $\ast$imsi, const char $\ast$ni, int have\+\_\+3dig\+\_\+mnc)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+c} (const void $\ast$ctx, const char $\ast$imsi, const char $\ast$ni, int have\+\_\+3dig\+\_\+mnc)
\item 
char $\ast$ \textbf{ osmo\+\_\+apn\+\_\+to\+\_\+str} (char $\ast$out\+\_\+str, const uint8\+\_\+t $\ast$apn\+\_\+enc, size\+\_\+t apn\+\_\+enc\+\_\+len)
\begin{DoxyCompactList}\small\item\em Convert an encoded APN into a dot-\/separated string. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+apn\+\_\+from\+\_\+str} (uint8\+\_\+t $\ast$apn\+\_\+enc, size\+\_\+t max\+\_\+apn\+\_\+enc\+\_\+len, const char $\ast$str)
\begin{DoxyCompactList}\small\item\em Convert a dot-\/separated string into an encoded APN. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static \+\_\+\+\_\+thread char \textbf{ apn\+\_\+strbuf} [\textbf{ APN\+\_\+\+MAXLEN}+1]
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
(C) 2014 by Harald Welte {\texttt{ laforge@gnumonks.\+org}} (C) 2015,2017 by sysmocom -\/ s.\+f.\+m.\+c. 

GmbH All Rights Reserved.

SPDX-\/\+License-\/\+Identifier\+: GPL-\/2.\+0+

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see {\texttt{ http\+://www.\+gnu.\+org/licenses/}}. 

\doxysubsection{Macro Definition Documentation}
\mbox{\label{apn_8c_a96474d4b7a94472d67f1f8e6628c6fa3}} 
\index{apn.c@{apn.c}!APN\_GPRS\_FMT@{APN\_GPRS\_FMT}}
\index{APN\_GPRS\_FMT@{APN\_GPRS\_FMT}!apn.c@{apn.c}}
\doxysubsubsection{APN\_GPRS\_FMT}
{\footnotesize\ttfamily \#define APN\+\_\+\+GPRS\+\_\+\+FMT~\char`\"{}\%s.\+mnc\%03u.\+mcc\%03u.\+gprs\char`\"{}}

\mbox{\label{apn_8c_ae06c2612f9256d5574f0853e6888b6c2}} 
\index{apn.c@{apn.c}!APN\_OI\_GPRS\_FMT@{APN\_OI\_GPRS\_FMT}}
\index{APN\_OI\_GPRS\_FMT@{APN\_OI\_GPRS\_FMT}!apn.c@{apn.c}}
\doxysubsubsection{APN\_OI\_GPRS\_FMT}
{\footnotesize\ttfamily \#define APN\+\_\+\+OI\+\_\+\+GPRS\+\_\+\+FMT~\char`\"{}mnc\%03u.\+mcc\%03u.\+gprs\char`\"{}}



\doxysubsection{Function Documentation}
\mbox{\label{apn_8c_a81077716204680020995012aaff14701}} 
\index{apn.c@{apn.c}!osmo\_apn\_from\_str@{osmo\_apn\_from\_str}}
\index{osmo\_apn\_from\_str@{osmo\_apn\_from\_str}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_from\_str()}
{\footnotesize\ttfamily int osmo\+\_\+apn\+\_\+from\+\_\+str (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{apn\+\_\+enc,  }\item[{size\+\_\+t}]{max\+\_\+apn\+\_\+enc\+\_\+len,  }\item[{const char $\ast$}]{str }\end{DoxyParamCaption})}



Convert a dot-\/separated string into an encoded APN. 


\begin{DoxyParams}{Parameters}
{\em apn\+\_\+enc} & the encoded APN \\
\hline
{\em max\+\_\+apn\+\_\+enc\+\_\+len} & the size of the apn\+\_\+enc buffer \\
\hline
{\em str} & the source string\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
out\+\_\+str on success and NULL otherwise 
\end{DoxyReturn}


References \textbf{ len}.



Referenced by \textbf{ msgb\+\_\+sgsap\+\_\+name\+\_\+put()}.

\mbox{\label{apn_8c_a23cd8e247ea70ab10d7fa353a5f33cbd}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify@{osmo\_apn\_qualify}}
\index{osmo\_apn\_qualify@{osmo\_apn\_qualify}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify (\begin{DoxyParamCaption}\item[{unsigned int}]{mcc,  }\item[{unsigned int}]{mnc,  }\item[{const char $\ast$}]{ni }\end{DoxyParamCaption})}



References \textbf{ apn\+\_\+strbuf}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+buf()}.

\mbox{\label{apn_8c_a7abad7fd6a1a9e69e4dc0bf3137f325b}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify\_buf@{osmo\_apn\_qualify\_buf}}
\index{osmo\_apn\_qualify\_buf@{osmo\_apn\_qualify\_buf}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify\_buf()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len,  }\item[{unsigned int}]{mcc,  }\item[{unsigned int}]{mnc,  }\item[{const char $\ast$}]{ni }\end{DoxyParamCaption})}



References \textbf{ APN\+\_\+\+GPRS\+\_\+\+FMT}.



Referenced by \textbf{ osmo\+\_\+apn\+\_\+qualify()}, \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+c()}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+buf()}.

\mbox{\label{apn_8c_a193fd496451dd011b5b3b771751a5eb2}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify\_c@{osmo\_apn\_qualify\_c}}
\index{osmo\_apn\_qualify\_c@{osmo\_apn\_qualify\_c}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify\_c()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify\+\_\+c (\begin{DoxyParamCaption}\item[{const void $\ast$}]{ctx,  }\item[{unsigned int}]{mcc,  }\item[{unsigned int}]{mnc,  }\item[{const char $\ast$}]{ni }\end{DoxyParamCaption})}



References \textbf{ APN\+\_\+\+MAXLEN}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+buf()}.

\mbox{\label{apn_8c_a2548cfc66eb8b32f53ee1eb61113d6c7}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify\_from\_imsi@{osmo\_apn\_qualify\_from\_imsi}}
\index{osmo\_apn\_qualify\_from\_imsi@{osmo\_apn\_qualify\_from\_imsi}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify\_from\_imsi()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi (\begin{DoxyParamCaption}\item[{const char $\ast$}]{imsi,  }\item[{const char $\ast$}]{ni,  }\item[{int}]{have\+\_\+3dig\+\_\+mnc }\end{DoxyParamCaption})}



References \textbf{ apn\+\_\+strbuf}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+buf()}.

\mbox{\label{apn_8c_a302e2b5dd95237db7cf2bb9ca0896fad}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify\_from\_imsi\_buf@{osmo\_apn\_qualify\_from\_imsi\_buf}}
\index{osmo\_apn\_qualify\_from\_imsi\_buf@{osmo\_apn\_qualify\_from\_imsi\_buf}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify\_from\_imsi\_buf()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len,  }\item[{const char $\ast$}]{imsi,  }\item[{const char $\ast$}]{ni,  }\item[{int}]{have\+\_\+3dig\+\_\+mnc }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+buf()}.



Referenced by \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi()}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+c()}.

\mbox{\label{apn_8c_a363a56411d9507ad14d863c0b098df6d}} 
\index{apn.c@{apn.c}!osmo\_apn\_qualify\_from\_imsi\_c@{osmo\_apn\_qualify\_from\_imsi\_c}}
\index{osmo\_apn\_qualify\_from\_imsi\_c@{osmo\_apn\_qualify\_from\_imsi\_c}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_qualify\_from\_imsi\_c()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+c (\begin{DoxyParamCaption}\item[{const void $\ast$}]{ctx,  }\item[{const char $\ast$}]{imsi,  }\item[{const char $\ast$}]{ni,  }\item[{int}]{have\+\_\+3dig\+\_\+mnc }\end{DoxyParamCaption})}



References \textbf{ APN\+\_\+\+MAXLEN}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi\+\_\+buf()}.

\mbox{\label{apn_8c_a3067d001dd50c2b3ea720117d596f46d}} 
\index{apn.c@{apn.c}!osmo\_apn\_to\_str@{osmo\_apn\_to\_str}}
\index{osmo\_apn\_to\_str@{osmo\_apn\_to\_str}!apn.c@{apn.c}}
\doxysubsubsection{osmo\_apn\_to\_str()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+apn\+\_\+to\+\_\+str (\begin{DoxyParamCaption}\item[{char $\ast$}]{out\+\_\+str,  }\item[{const uint8\+\_\+t $\ast$}]{apn\+\_\+enc,  }\item[{size\+\_\+t}]{apn\+\_\+enc\+\_\+len }\end{DoxyParamCaption})}



Convert an encoded APN into a dot-\/separated string. 


\begin{DoxyParams}{Parameters}
{\em out\+\_\+str} & the destination buffer (size must be $>$= max(app\+\_\+enc\+\_\+len,1)) \\
\hline
{\em apn\+\_\+enc} & the encoded APN \\
\hline
{\em apn\+\_\+enc\+\_\+len} & the length of the encoded APN\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
out\+\_\+str on success and NULL otherwise 
\end{DoxyReturn}


\doxysubsection{Variable Documentation}
\mbox{\label{apn_8c_a4ef2d70a08d0343fca6490e5351ff455}} 
\index{apn.c@{apn.c}!apn\_strbuf@{apn\_strbuf}}
\index{apn\_strbuf@{apn\_strbuf}!apn.c@{apn.c}}
\doxysubsubsection{apn\_strbuf}
{\footnotesize\ttfamily \+\_\+\+\_\+thread char apn\+\_\+strbuf[\textbf{ APN\+\_\+\+MAXLEN}+1]\hspace{0.3cm}{\ttfamily [static]}}



Referenced by \textbf{ osmo\+\_\+apn\+\_\+qualify()}, and \textbf{ osmo\+\_\+apn\+\_\+qualify\+\_\+from\+\_\+imsi()}.

