\doxysection{src/sim/core.c File Reference}
\label{core_8c}\index{src/sim/core.c@{src/sim/core.c}}


Core routines for SIM/\+UICC/\+USIM access.  


{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/sim/sim.\+h$>$}\newline
{\ttfamily \#include \char`\"{}sim\+\_\+int.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$ \textbf{ osim\+\_\+file\+\_\+decode} (struct \textbf{ osim\+\_\+file} $\ast$\textbf{ file}, int \textbf{ len}, uint8\+\_\+t $\ast$\textbf{ data})
\item 
struct \textbf{ msgb} $\ast$ \textbf{ osim\+\_\+file\+\_\+encode} (const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$\textbf{ desc}, const struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$\textbf{ data})
\item 
static struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ \textbf{ \+\_\+\+\_\+element\+\_\+alloc} (void $\ast$ctx, const char $\ast$\textbf{ name}, enum \textbf{ osim\+\_\+element\+\_\+type} \textbf{ type}, enum \textbf{ osim\+\_\+element\+\_\+repr} repr)
\item 
struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ \textbf{ element\+\_\+alloc} (struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$dd, const char $\ast$\textbf{ name}, enum \textbf{ osim\+\_\+element\+\_\+type} \textbf{ type}, enum \textbf{ osim\+\_\+element\+\_\+repr} repr)
\item 
struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ \textbf{ element\+\_\+alloc\+\_\+sub} (struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ee, const char $\ast$\textbf{ name}, enum \textbf{ osim\+\_\+element\+\_\+type} \textbf{ type}, enum \textbf{ osim\+\_\+element\+\_\+repr} repr)
\item 
void \textbf{ add\+\_\+filedesc} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$root, const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$in, int num)
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ alloc\+\_\+df} (void $\ast$ctx, uint16\+\_\+t fid, const char $\ast$\textbf{ name})
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ add\+\_\+df\+\_\+with\+\_\+ef} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$parent, uint16\+\_\+t fid, const char $\ast$\textbf{ name}, const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$in, int num)
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ alloc\+\_\+adf\+\_\+with\+\_\+ef} (void $\ast$ctx, const uint8\+\_\+t $\ast$adf\+\_\+name, uint8\+\_\+t adf\+\_\+name\+\_\+len, const char $\ast$\textbf{ name}, const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$in, int num)
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+name} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$parent, const char $\ast$\textbf{ name})
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+aid} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$parent, const uint8\+\_\+t $\ast$aid, uint8\+\_\+t aid\+\_\+len)
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+fid} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$parent, uint16\+\_\+t fid)
\item 
struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ \textbf{ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+sfid} (struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$parent, uint8\+\_\+t sfid)
\item 
static \textbf{ LLIST\+\_\+\+HEAD} (g\+\_\+app\+\_\+profiles)
\item 
void \textbf{ osim\+\_\+app\+\_\+profile\+\_\+register} (struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$aprof)
\begin{DoxyCompactList}\small\item\em Register an application profile. \end{DoxyCompactList}\item 
const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$ \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+name} (const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Find any registered application profile based on its name (e.\+g. \end{DoxyCompactList}\item 
const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$ \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+aid} (const uint8\+\_\+t $\ast$aid, uint8\+\_\+t aid\+\_\+len)
\begin{DoxyCompactList}\small\item\em Find any registered application profile based on its AID. \end{DoxyCompactList}\item 
struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl} $\ast$ \textbf{ osim\+\_\+card\+\_\+hdl\+\_\+find\+\_\+app} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ch, const uint8\+\_\+t $\ast$aid, uint8\+\_\+t aid\+\_\+len)
\item 
int \textbf{ osim\+\_\+card\+\_\+hdl\+\_\+add\+\_\+app} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ch, const uint8\+\_\+t $\ast$aid, uint8\+\_\+t aid\+\_\+len, const char $\ast$label)
\begin{DoxyCompactList}\small\item\em Add an application to a given card. \end{DoxyCompactList}\item 
struct \textbf{ msgb} $\ast$ \textbf{ osim\+\_\+new\+\_\+apdumsg} (uint8\+\_\+t \textbf{ cla}, uint8\+\_\+t \textbf{ ins}, uint8\+\_\+t \textbf{ p1}, uint8\+\_\+t \textbf{ p2}, uint16\+\_\+t \textbf{ lc}, uint16\+\_\+t \textbf{ le})
\begin{DoxyCompactList}\small\item\em Generate an APDU message and initialize APDU command header. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osim\+\_\+print\+\_\+sw\+\_\+buf} (char $\ast$buf, size\+\_\+t buf\+\_\+len, const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$ch, uint16\+\_\+t sw\+\_\+in)
\item 
char $\ast$ \textbf{ osim\+\_\+print\+\_\+sw} (const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$ch, uint16\+\_\+t sw\+\_\+in)
\item 
char $\ast$ \textbf{ osim\+\_\+print\+\_\+sw\+\_\+c} (const void $\ast$ctx, const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$ch, uint16\+\_\+t sw\+\_\+in)
\item 
const struct \textbf{ osim\+\_\+card\+\_\+sw} $\ast$ \textbf{ osim\+\_\+cprof\+\_\+find\+\_\+sw} (const struct \textbf{ osim\+\_\+card\+\_\+profile} $\ast$cp, uint16\+\_\+t sw\+\_\+in)
\begin{DoxyCompactList}\small\item\em Find status word within given card profile. \end{DoxyCompactList}\item 
const struct \textbf{ osim\+\_\+card\+\_\+sw} $\ast$ \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+sw} (const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$ap, uint16\+\_\+t sw\+\_\+in)
\begin{DoxyCompactList}\small\item\em Find application-\/specific status word within given card application profile. \end{DoxyCompactList}\item 
enum \textbf{ osim\+\_\+card\+\_\+sw\+\_\+class} \textbf{ osim\+\_\+sw\+\_\+class} (const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$ch, uint16\+\_\+t sw\+\_\+in)
\item 
int \textbf{ default\+\_\+decode} (struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$dd, const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$\textbf{ desc}, int \textbf{ len}, uint8\+\_\+t $\ast$\textbf{ data})
\item 
int \textbf{ osim\+\_\+init} (void $\ast$ctx)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Core routines for SIM/\+UICC/\+USIM access. 



\doxysubsection{Function Documentation}
\mbox{\label{core_8c_a8d04f8874d2b1992159bffeafc6c5379}} 
\index{core.c@{core.c}!\_\_element\_alloc@{\_\_element\_alloc}}
\index{\_\_element\_alloc@{\_\_element\_alloc}!core.c@{core.c}}
\doxysubsubsection{\_\_element\_alloc()}
{\footnotesize\ttfamily static struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ \+\_\+\+\_\+element\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const char $\ast$}]{name,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+type}}]{type,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+repr}}]{repr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ ELEM\+\_\+\+T\+\_\+\+GROUP}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, \textbf{ name}, \textbf{ osim\+\_\+decoded\+\_\+element\+::name}, \textbf{ osim\+\_\+decoded\+\_\+element\+::representation}, \textbf{ osim\+\_\+decoded\+\_\+element\+::siblings}, \textbf{ osim\+\_\+decoded\+\_\+element\+::type}, and \textbf{ osim\+\_\+decoded\+\_\+element\+::u}.



Referenced by \textbf{ element\+\_\+alloc()}, and \textbf{ element\+\_\+alloc\+\_\+sub()}.

\mbox{\label{core_8c_ac82d112fc2a2638dfeabf76c2d923921}} 
\index{core.c@{core.c}!add\_df\_with\_ef@{add\_df\_with\_ef}}
\index{add\_df\_with\_ef@{add\_df\_with\_ef}!core.c@{core.c}}
\doxysubsubsection{add\_df\_with\_ef()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ add\+\_\+df\+\_\+with\+\_\+ef (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{parent,  }\item[{uint16\+\_\+t}]{fid,  }\item[{const char $\ast$}]{name,  }\item[{const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{in,  }\item[{int}]{num }\end{DoxyParamCaption})}



References \textbf{ add\+\_\+filedesc()}, \textbf{ alloc\+\_\+df()}, \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::fid}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, \textbf{ llist\+\_\+add\+\_\+tail()}, \textbf{ name}, and \textbf{ osim\+\_\+file\+\_\+desc\+::parent}.



Referenced by \textbf{ osim\+\_\+aprof\+\_\+usim()}, \textbf{ osim\+\_\+cprof\+\_\+tsim()}, \textbf{ osim\+\_\+int\+\_\+cprof\+\_\+add\+\_\+gsm()}, and \textbf{ osim\+\_\+int\+\_\+cprof\+\_\+add\+\_\+telecom()}.

\mbox{\label{core_8c_a49223048285e9b3c260e0836d02ef692}} 
\index{core.c@{core.c}!add\_filedesc@{add\_filedesc}}
\index{add\_filedesc@{add\_filedesc}!core.c@{core.c}}
\doxysubsubsection{add\_filedesc()}
{\footnotesize\ttfamily void add\+\_\+filedesc (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{root,  }\item[{const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{in,  }\item[{int}]{num }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, and \textbf{ llist\+\_\+add\+\_\+tail()}.



Referenced by \textbf{ add\+\_\+df\+\_\+with\+\_\+ef()}, \textbf{ alloc\+\_\+adf\+\_\+with\+\_\+ef()}, \textbf{ osim\+\_\+cprof\+\_\+sim()}, \textbf{ osim\+\_\+cprof\+\_\+tsim()}, and \textbf{ osim\+\_\+cprof\+\_\+uicc()}.

\mbox{\label{core_8c_ab912c1310b8d57e15fcb869d02a53544}} 
\index{core.c@{core.c}!alloc\_adf\_with\_ef@{alloc\_adf\_with\_ef}}
\index{alloc\_adf\_with\_ef@{alloc\_adf\_with\_ef}!core.c@{core.c}}
\doxysubsubsection{alloc\_adf\_with\_ef()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ alloc\+\_\+adf\+\_\+with\+\_\+ef (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const uint8\+\_\+t $\ast$}]{adf\+\_\+name,  }\item[{uint8\+\_\+t}]{adf\+\_\+name\+\_\+len,  }\item[{const char $\ast$}]{name,  }\item[{const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{in,  }\item[{int}]{num }\end{DoxyParamCaption})}



References \textbf{ add\+\_\+filedesc()}, \textbf{ alloc\+\_\+df()}, \textbf{ osim\+\_\+file\+\_\+desc\+::df\+\_\+name}, \textbf{ osim\+\_\+file\+\_\+desc\+::df\+\_\+name\+\_\+len}, \textbf{ name}, \textbf{ osim\+\_\+file\+\_\+desc\+::type}, and \textbf{ TYPE\+\_\+\+ADF}.



Referenced by \textbf{ osim\+\_\+aprof\+\_\+hpsim()}, \textbf{ osim\+\_\+aprof\+\_\+isim()}, and \textbf{ osim\+\_\+aprof\+\_\+usim()}.

\mbox{\label{core_8c_ab05975262a896023c4adfe5856662964}} 
\index{core.c@{core.c}!alloc\_df@{alloc\_df}}
\index{alloc\_df@{alloc\_df}!core.c@{core.c}}
\doxysubsubsection{alloc\_df()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ alloc\+\_\+df (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{uint16\+\_\+t}]{fid,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::fid}, \textbf{ INIT\+\_\+\+LLIST\+\_\+\+HEAD}, \textbf{ name}, \textbf{ osim\+\_\+file\+\_\+desc\+::short\+\_\+name}, \textbf{ osim\+\_\+file\+\_\+desc\+::type}, and \textbf{ TYPE\+\_\+\+DF}.



Referenced by \textbf{ add\+\_\+df\+\_\+with\+\_\+ef()}, \textbf{ alloc\+\_\+adf\+\_\+with\+\_\+ef()}, \textbf{ osim\+\_\+cprof\+\_\+sim()}, \textbf{ osim\+\_\+cprof\+\_\+tsim()}, and \textbf{ osim\+\_\+cprof\+\_\+uicc()}.

\mbox{\label{core_8c_ac5c822b3b087e4cb135f715727e19e67}} 
\index{core.c@{core.c}!default\_decode@{default\_decode}}
\index{default\_decode@{default\_decode}!core.c@{core.c}}
\doxysubsubsection{default\_decode()}
{\footnotesize\ttfamily int default\+\_\+decode (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$}]{dd,  }\item[{const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{desc,  }\item[{int}]{len,  }\item[{uint8\+\_\+t $\ast$}]{data }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+decoded\+\_\+element\+::buf}, \textbf{ data}, \textbf{ ELEM\+\_\+\+REPR\+\_\+\+HEX}, \textbf{ ELEM\+\_\+\+T\+\_\+\+BYTES}, \textbf{ element\+\_\+alloc()}, \textbf{ len()}, and \textbf{ osim\+\_\+decoded\+\_\+element\+::u}.

\mbox{\label{core_8c_a9d6a6d137e0426b291b95a85d0431565}} 
\index{core.c@{core.c}!element\_alloc@{element\_alloc}}
\index{element\_alloc@{element\_alloc}!core.c@{core.c}}
\doxysubsubsection{element\_alloc()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ element\+\_\+alloc (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$}]{dd,  }\item[{const char $\ast$}]{name,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+type}}]{type,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+repr}}]{repr }\end{DoxyParamCaption})}



References \textbf{ \+\_\+\+\_\+element\+\_\+alloc()}, \textbf{ osim\+\_\+decoded\+\_\+data\+::decoded\+\_\+elements}, \textbf{ osim\+\_\+decoded\+\_\+element\+::list}, \textbf{ llist\+\_\+add\+\_\+tail()}, \textbf{ name}, and \textbf{ osim\+\_\+decoded\+\_\+element\+::type}.



Referenced by \textbf{ default\+\_\+decode()}, \textbf{ elp\+\_\+decode()}, \textbf{ gsm\+\_\+hpplmn\+\_\+decode()}, \textbf{ gsm\+\_\+imsi\+\_\+decode()}, \textbf{ gsm\+\_\+kc\+\_\+decode()}, \textbf{ gsm\+\_\+lp\+\_\+decode()}, \textbf{ gsm\+\_\+plmnsel\+\_\+decode()}, and \textbf{ iccid\+\_\+decode()}.

\mbox{\label{core_8c_a3536009303b5c04aff61bfd8afd59574}} 
\index{core.c@{core.c}!element\_alloc\_sub@{element\_alloc\_sub}}
\index{element\_alloc\_sub@{element\_alloc\_sub}!core.c@{core.c}}
\doxysubsubsection{element\_alloc\_sub()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$ element\+\_\+alloc\+\_\+sub (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+decoded\+\_\+element} $\ast$}]{ee,  }\item[{const char $\ast$}]{name,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+type}}]{type,  }\item[{enum \textbf{ osim\+\_\+element\+\_\+repr}}]{repr }\end{DoxyParamCaption})}



References \textbf{ \+\_\+\+\_\+element\+\_\+alloc()}, \textbf{ osim\+\_\+decoded\+\_\+element\+::list}, \textbf{ llist\+\_\+add()}, \textbf{ name}, \textbf{ osim\+\_\+decoded\+\_\+element\+::siblings}, \textbf{ osim\+\_\+decoded\+\_\+element\+::type}, and \textbf{ osim\+\_\+decoded\+\_\+element\+::u}.



Referenced by \textbf{ gsm\+\_\+plmnsel\+\_\+decode()}.

\mbox{\label{core_8c_afffc0584b4c078eeaae59375186431af}} 
\index{core.c@{core.c}!LLIST\_HEAD@{LLIST\_HEAD}}
\index{LLIST\_HEAD@{LLIST\_HEAD}!core.c@{core.c}}
\doxysubsubsection{LLIST\_HEAD()}
{\footnotesize\ttfamily static LLIST\+\_\+\+HEAD (\begin{DoxyParamCaption}\item[{g\+\_\+app\+\_\+profiles}]{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

\mbox{\label{core_8c_ab2cae1c97f978efae5dea91076d1b8c5}} 
\index{core.c@{core.c}!osim\_app\_profile\_find\_by\_aid@{osim\_app\_profile\_find\_by\_aid}}
\index{osim\_app\_profile\_find\_by\_aid@{osim\_app\_profile\_find\_by\_aid}!core.c@{core.c}}
\doxysubsubsection{osim\_app\_profile\_find\_by\_aid()}
{\footnotesize\ttfamily const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+aid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{aid,  }\item[{uint8\+\_\+t}]{aid\+\_\+len }\end{DoxyParamCaption})}



Find any registered application profile based on its AID. 



References \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::aid}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::aid\+\_\+len}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::list}, and \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}.



Referenced by \textbf{ osim\+\_\+app\+\_\+profile\+\_\+register()}, and \textbf{ osim\+\_\+card\+\_\+hdl\+\_\+add\+\_\+app()}.

\mbox{\label{core_8c_a1af2c427e38473dd42c5977e9b2c843f}} 
\index{core.c@{core.c}!osim\_app\_profile\_find\_by\_name@{osim\_app\_profile\_find\_by\_name}}
\index{osim\_app\_profile\_find\_by\_name@{osim\_app\_profile\_find\_by\_name}!core.c@{core.c}}
\doxysubsubsection{osim\_app\_profile\_find\_by\_name()}
{\footnotesize\ttfamily const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+name (\begin{DoxyParamCaption}\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Find any registered application profile based on its name (e.\+g. 

\char`\"{}\+ADF.\+USIM\char`\"{}) 

References \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ name}, and \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::name}.



Referenced by \textbf{ osim\+\_\+app\+\_\+profile\+\_\+register()}.

\mbox{\label{core_8c_a673de5082794b80a75fedec73403dd7f}} 
\index{core.c@{core.c}!osim\_app\_profile\_find\_sw@{osim\_app\_profile\_find\_sw}}
\index{osim\_app\_profile\_find\_sw@{osim\_app\_profile\_find\_sw}!core.c@{core.c}}
\doxysubsubsection{osim\_app\_profile\_find\_sw()}
{\footnotesize\ttfamily const struct \textbf{ osim\+\_\+card\+\_\+sw} $\ast$ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+sw (\begin{DoxyParamCaption}\item[{const struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$}]{ap,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



Find application-\/specific status word within given card application profile. 



References \textbf{ sw}, and \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::sw}.



Referenced by \textbf{ osim\+\_\+print\+\_\+sw\+\_\+buf()}, and \textbf{ osim\+\_\+sw\+\_\+class()}.

\mbox{\label{core_8c_a3cac49d1becf9386a9e1f7d7f527f5c6}} 
\index{core.c@{core.c}!osim\_app\_profile\_register@{osim\_app\_profile\_register}}
\index{osim\_app\_profile\_register@{osim\_app\_profile\_register}!core.c@{core.c}}
\doxysubsubsection{osim\_app\_profile\_register()}
{\footnotesize\ttfamily void osim\+\_\+app\+\_\+profile\+\_\+register (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile} $\ast$}]{aprof }\end{DoxyParamCaption})}



Register an application profile. 

Typically called at early start-\/up. 

References \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::aid}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::aid\+\_\+len}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::list}, \textbf{ llist\+\_\+add\+\_\+tail()}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+profile\+::name}, \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+aid()}, \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+name()}, and \textbf{ OSMO\+\_\+\+ASSERT}.



Referenced by \textbf{ osim\+\_\+init()}.

\mbox{\label{core_8c_ad0a4d51bef9b52e529c0a10cd42c1b7d}} 
\index{core.c@{core.c}!osim\_card\_hdl\_add\_app@{osim\_card\_hdl\_add\_app}}
\index{osim\_card\_hdl\_add\_app@{osim\_card\_hdl\_add\_app}!core.c@{core.c}}
\doxysubsubsection{osim\_card\_hdl\_add\_app()}
{\footnotesize\ttfamily int osim\+\_\+card\+\_\+hdl\+\_\+add\+\_\+app (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{ch,  }\item[{const uint8\+\_\+t $\ast$}]{aid,  }\item[{uint8\+\_\+t}]{aid\+\_\+len,  }\item[{const char $\ast$}]{label }\end{DoxyParamCaption})}



Add an application to a given card. 



References \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::aid}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::aid\+\_\+len}, \textbf{ osim\+\_\+card\+\_\+hdl\+::apps}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::label}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::list}, \textbf{ llist\+\_\+add\+\_\+tail()}, \textbf{ MAX\+\_\+\+AID\+\_\+\+LEN}, \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+by\+\_\+aid()}, \textbf{ osim\+\_\+card\+\_\+hdl\+\_\+find\+\_\+app()}, and \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::prof}.

\mbox{\label{core_8c_a148e1042d5b8483b4941e1385ce14463}} 
\index{core.c@{core.c}!osim\_card\_hdl\_find\_app@{osim\_card\_hdl\_find\_app}}
\index{osim\_card\_hdl\_find\_app@{osim\_card\_hdl\_find\_app}!core.c@{core.c}}
\doxysubsubsection{osim\_card\_hdl\_find\_app()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl} $\ast$ osim\+\_\+card\+\_\+hdl\+\_\+find\+\_\+app (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{ch,  }\item[{const uint8\+\_\+t $\ast$}]{aid,  }\item[{uint8\+\_\+t}]{aid\+\_\+len }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::aid}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::aid\+\_\+len}, \textbf{ osim\+\_\+card\+\_\+hdl\+::apps}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ MAX\+\_\+\+AID\+\_\+\+LEN}.



Referenced by \textbf{ osim\+\_\+card\+\_\+hdl\+\_\+add\+\_\+app()}.

\mbox{\label{core_8c_a4cf2bc638943f63a295e97f0888e2a66}} 
\index{core.c@{core.c}!osim\_cprof\_find\_sw@{osim\_cprof\_find\_sw}}
\index{osim\_cprof\_find\_sw@{osim\_cprof\_find\_sw}!core.c@{core.c}}
\doxysubsubsection{osim\_cprof\_find\_sw()}
{\footnotesize\ttfamily const struct \textbf{ osim\+\_\+card\+\_\+sw} $\ast$ osim\+\_\+cprof\+\_\+find\+\_\+sw (\begin{DoxyParamCaption}\item[{const struct \textbf{ osim\+\_\+card\+\_\+profile} $\ast$}]{cp,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



Find status word within given card profile. 



References \textbf{ sw}, and \textbf{ osim\+\_\+card\+\_\+profile\+::sws}.



Referenced by \textbf{ osim\+\_\+print\+\_\+sw\+\_\+buf()}, and \textbf{ osim\+\_\+sw\+\_\+class()}.

\mbox{\label{core_8c_a8b3fc42e576df436d6f708a2c2622e32}} 
\index{core.c@{core.c}!osim\_file\_decode@{osim\_file\_decode}}
\index{osim\_file\_decode@{osim\_file\_decode}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_decode()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$ osim\+\_\+file\+\_\+decode (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file} $\ast$}]{file,  }\item[{int}]{len,  }\item[{uint8\+\_\+t $\ast$}]{data }\end{DoxyParamCaption})}



References \textbf{ data}, \textbf{ file()}, \textbf{ osim\+\_\+decoded\+\_\+data\+::file}, and \textbf{ len()}.

\mbox{\label{core_8c_a23aa361a207d1c07b93bc4ecbb1c1c5c}} 
\index{core.c@{core.c}!osim\_file\_desc\_find\_aid@{osim\_file\_desc\_find\_aid}}
\index{osim\_file\_desc\_find\_aid@{osim\_file\_desc\_find\_aid}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_desc\_find\_aid()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+aid (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{parent,  }\item[{const uint8\+\_\+t $\ast$}]{aid,  }\item[{uint8\+\_\+t}]{aid\+\_\+len }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::df\+\_\+name}, \textbf{ osim\+\_\+file\+\_\+desc\+::df\+\_\+name\+\_\+len}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ osim\+\_\+file\+\_\+desc\+::parent}, \textbf{ osim\+\_\+file\+\_\+desc\+::type}, and \textbf{ TYPE\+\_\+\+ADF}.

\mbox{\label{core_8c_acd05c7cf1e03896a7c0ef569af395825}} 
\index{core.c@{core.c}!osim\_file\_desc\_find\_fid@{osim\_file\_desc\_find\_fid}}
\index{osim\_file\_desc\_find\_fid@{osim\_file\_desc\_find\_fid}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_desc\_find\_fid()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+fid (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{parent,  }\item[{uint16\+\_\+t}]{fid }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::fid}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, and \textbf{ osim\+\_\+file\+\_\+desc\+::parent}.

\mbox{\label{core_8c_a3c5aeeb115e2bf7f56f63f58d1e9deef}} 
\index{core.c@{core.c}!osim\_file\_desc\_find\_name@{osim\_file\_desc\_find\_name}}
\index{osim\_file\_desc\_find\_name@{osim\_file\_desc\_find\_name}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_desc\_find\_name()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+name (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{parent,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ name}, \textbf{ osim\+\_\+file\+\_\+desc\+::parent}, and \textbf{ osim\+\_\+file\+\_\+desc\+::short\+\_\+name}.

\mbox{\label{core_8c_a07d382dd66bd16e3ab733af159f174fc}} 
\index{core.c@{core.c}!osim\_file\_desc\_find\_sfid@{osim\_file\_desc\_find\_sfid}}
\index{osim\_file\_desc\_find\_sfid@{osim\_file\_desc\_find\_sfid}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_desc\_find\_sfid()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$ osim\+\_\+file\+\_\+desc\+\_\+find\+\_\+sfid (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{parent,  }\item[{uint8\+\_\+t}]{sfid }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+file\+\_\+desc\+::child\+\_\+list}, \textbf{ osim\+\_\+file\+\_\+desc\+::list}, \textbf{ llist\+\_\+for\+\_\+each\+\_\+entry}, \textbf{ osim\+\_\+file\+\_\+desc\+::parent}, \textbf{ SFI\+\_\+\+NONE}, and \textbf{ osim\+\_\+file\+\_\+desc\+::sfid}.

\mbox{\label{core_8c_aed277b8c4ec2b27c48f3ac2ef6dbd779}} 
\index{core.c@{core.c}!osim\_file\_encode@{osim\_file\_encode}}
\index{osim\_file\_encode@{osim\_file\_encode}!core.c@{core.c}}
\doxysubsubsection{osim\_file\_encode()}
{\footnotesize\ttfamily struct \textbf{ msgb} $\ast$ osim\+\_\+file\+\_\+encode (\begin{DoxyParamCaption}\item[{const struct \textbf{ osim\+\_\+file\+\_\+desc} $\ast$}]{desc,  }\item[{const struct \textbf{ osim\+\_\+decoded\+\_\+data} $\ast$}]{data }\end{DoxyParamCaption})}



References \textbf{ data}.

\mbox{\label{core_8c_a87b674dda5a82fa4f3ae2b3f42c62e75}} 
\index{core.c@{core.c}!osim\_init@{osim\_init}}
\index{osim\_init@{osim\_init}!core.c@{core.c}}
\doxysubsubsection{osim\_init()}
{\footnotesize\ttfamily int osim\+\_\+init (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+app\+\_\+profile\+\_\+register()}, \textbf{ osim\+\_\+aprof\+\_\+hpsim()}, \textbf{ osim\+\_\+aprof\+\_\+isim()}, and \textbf{ osim\+\_\+aprof\+\_\+usim()}.

\mbox{\label{core_8c_a4d8128375c59e9754c32d27bb47c9f7e}} 
\index{core.c@{core.c}!osim\_new\_apdumsg@{osim\_new\_apdumsg}}
\index{osim\_new\_apdumsg@{osim\_new\_apdumsg}!core.c@{core.c}}
\doxysubsubsection{osim\_new\_apdumsg()}
{\footnotesize\ttfamily struct \textbf{ msgb} $\ast$ osim\+\_\+new\+\_\+apdumsg (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{cla,  }\item[{uint8\+\_\+t}]{ins,  }\item[{uint8\+\_\+t}]{p1,  }\item[{uint8\+\_\+t}]{p2,  }\item[{uint16\+\_\+t}]{lc,  }\item[{uint16\+\_\+t}]{le }\end{DoxyParamCaption})}



Generate an APDU message and initialize APDU command header. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cla} & CLASS byte \\
\hline
\mbox{\texttt{ in}}  & {\em ins} & INSTRUCTION byte \\
\hline
\mbox{\texttt{ in}}  & {\em p1} & Parameter 1 byte \\
\hline
\mbox{\texttt{ in}}  & {\em p2} & Parameter 2 byte \\
\hline
\mbox{\texttt{ in}}  & {\em lc} & number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc \\
\hline
\mbox{\texttt{ in}}  & {\em le} & maximum number of bytes expected in the response data field, which will encoded in 0, 1, 2 or 3 bytes into Le \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
an APDU message generated using provided APDU parameters
\end{DoxyReturn}
This function generates an APDU message, as defined in ISO/\+IEC 7816-\/4\+:2005(E) §5.1. The APDU command header, command and response fields lengths are initialized using the parameters. The APDU case is determined by the command and response fields lengths. 

References \textbf{ APDU\+\_\+\+CASE\+\_\+1}, \textbf{ APDU\+\_\+\+CASE\+\_\+2E}, \textbf{ APDU\+\_\+\+CASE\+\_\+2S}, \textbf{ APDU\+\_\+\+CASE\+\_\+3E}, \textbf{ APDU\+\_\+\+CASE\+\_\+3S}, \textbf{ APDU\+\_\+\+CASE\+\_\+4E}, \textbf{ APDU\+\_\+\+CASE\+\_\+4S}, \textbf{ cla}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::cla}, \textbf{ ins}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::ins}, \textbf{ msgb\+::l2h}, \textbf{ lc}, \textbf{ le}, \textbf{ msgb\+\_\+alloc()}, \textbf{ msgb\+\_\+apdu\+\_\+case}, \textbf{ msgb\+\_\+apdu\+\_\+lc}, \textbf{ msgb\+\_\+apdu\+\_\+le}, \textbf{ msgb\+\_\+put()}, \textbf{ p1}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::p1}, \textbf{ p2}, and \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::p2}.

\mbox{\label{core_8c_af6af973c203c8725d18cdc306174e5d0}} 
\index{core.c@{core.c}!osim\_print\_sw@{osim\_print\_sw}}
\index{osim\_print\_sw@{osim\_print\_sw}!core.c@{core.c}}
\doxysubsubsection{osim\_print\_sw()}
{\footnotesize\ttfamily char $\ast$ osim\+\_\+print\+\_\+sw (\begin{DoxyParamCaption}\item[{const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$}]{ch,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+print\+\_\+sw\+\_\+buf()}.

\mbox{\label{core_8c_a579b8c1d81de21d50b23199a32025bce}} 
\index{core.c@{core.c}!osim\_print\_sw\_buf@{osim\_print\_sw\_buf}}
\index{osim\_print\_sw\_buf@{osim\_print\_sw\_buf}!core.c@{core.c}}
\doxysubsubsection{osim\_print\_sw\_buf()}
{\footnotesize\ttfamily char $\ast$ osim\+\_\+print\+\_\+sw\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{buf\+\_\+len,  }\item[{const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$}]{ch,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+chan\+\_\+hdl\+::card}, \textbf{ osim\+\_\+chan\+\_\+hdl\+::cur\+\_\+app}, \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+sw()}, \textbf{ osim\+\_\+cprof\+\_\+find\+\_\+sw()}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::prof}, \textbf{ osim\+\_\+card\+\_\+hdl\+::prof}, \textbf{ osim\+\_\+card\+\_\+sw\+::str}, \textbf{ SW\+\_\+\+TYPE\+\_\+\+STR}, \textbf{ osim\+\_\+card\+\_\+sw\+::type}, and \textbf{ osim\+\_\+card\+\_\+sw\+::u}.



Referenced by \textbf{ osim\+\_\+print\+\_\+sw()}, and \textbf{ osim\+\_\+print\+\_\+sw\+\_\+c()}.

\mbox{\label{core_8c_a5c4a94aa1714e8922f5589eae4d21bfb}} 
\index{core.c@{core.c}!osim\_print\_sw\_c@{osim\_print\_sw\_c}}
\index{osim\_print\_sw\_c@{osim\_print\_sw\_c}!core.c@{core.c}}
\doxysubsubsection{osim\_print\_sw\_c()}
{\footnotesize\ttfamily char $\ast$ osim\+\_\+print\+\_\+sw\+\_\+c (\begin{DoxyParamCaption}\item[{const void $\ast$}]{ctx,  }\item[{const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$}]{ch,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+print\+\_\+sw\+\_\+buf()}.

\mbox{\label{core_8c_ac480a85f701378d7171b1a81944d8da4}} 
\index{core.c@{core.c}!osim\_sw\_class@{osim\_sw\_class}}
\index{osim\_sw\_class@{osim\_sw\_class}!core.c@{core.c}}
\doxysubsubsection{osim\_sw\_class()}
{\footnotesize\ttfamily enum \textbf{ osim\+\_\+card\+\_\+sw\+\_\+class} osim\+\_\+sw\+\_\+class (\begin{DoxyParamCaption}\item[{const struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$}]{ch,  }\item[{uint16\+\_\+t}]{sw\+\_\+in }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+chan\+\_\+hdl\+::card}, \textbf{ osim\+\_\+card\+\_\+sw\+::class}, \textbf{ osim\+\_\+chan\+\_\+hdl\+::cur\+\_\+app}, \textbf{ osim\+\_\+app\+\_\+profile\+\_\+find\+\_\+sw()}, \textbf{ osim\+\_\+cprof\+\_\+find\+\_\+sw()}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osim\+\_\+card\+\_\+app\+\_\+hdl\+::prof}, \textbf{ osim\+\_\+card\+\_\+hdl\+::prof}, and \textbf{ SW\+\_\+\+CLS\+\_\+\+NONE}.

