\doxysection{src/sim/reader.c File Reference}
\label{reader_8c}\index{src/sim/reader.c@{src/sim/reader.c}}


Card reader abstraction for libosmosim.  


{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$netinet/in.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/msgb.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/sim/sim.\+h$>$}\newline
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}sim\+\_\+int.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ get\+\_\+sw} (struct \textbf{ msgb} $\ast$resp)
\item 
static int \textbf{ transceive\+\_\+apdu\+\_\+t0} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$st, struct \textbf{ msgb} $\ast$amsg)
\item 
int \textbf{ osim\+\_\+transceive\+\_\+apdu} (struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$st, struct \textbf{ msgb} $\ast$amsg)
\item 
struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$ \textbf{ osim\+\_\+reader\+\_\+open} (enum \textbf{ osim\+\_\+reader\+\_\+driver} driver, int idx, const char $\ast$\textbf{ name}, void $\ast$ctx)
\item 
struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ \textbf{ osim\+\_\+card\+\_\+open} (struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$rh, enum \textbf{ osim\+\_\+proto} proto)
\item 
int \textbf{ osim\+\_\+card\+\_\+reset} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$card, bool cold\+\_\+reset)
\item 
int \textbf{ osim\+\_\+card\+\_\+close} (struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$card)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Card reader abstraction for libosmosim. 



\doxysubsection{Function Documentation}
\mbox{\label{reader_8c_a4e2c9098d7ae1da9e8e283d225a60746}} 
\index{reader.c@{reader.c}!get\_sw@{get\_sw}}
\index{get\_sw@{get\_sw}!reader.c@{reader.c}}
\doxysubsubsection{get\_sw()}
{\footnotesize\ttfamily static int get\+\_\+sw (\begin{DoxyParamCaption}\item[{struct \textbf{ msgb} $\ast$}]{resp }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ msgb\+::l2h}, \textbf{ msgb\+\_\+apdu\+\_\+le}, and \textbf{ msgb\+\_\+get\+\_\+u16()}.



Referenced by \textbf{ transceive\+\_\+apdu\+\_\+t0()}.

\mbox{\label{reader_8c_a41af2a461b449e304a704eba35bf20aa}} 
\index{reader.c@{reader.c}!osim\_card\_close@{osim\_card\_close}}
\index{osim\_card\_close@{osim\_card\_close}!reader.c@{reader.c}}
\doxysubsubsection{osim\_card\_close()}
{\footnotesize\ttfamily int osim\+\_\+card\+\_\+close (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{card }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+reader\+\_\+hdl\+::card}, \textbf{ osim\+\_\+reader\+\_\+ops\+::card\+\_\+close}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::ops}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.

\mbox{\label{reader_8c_af1c503b26556a3eecb43345cfdee9c6b}} 
\index{reader.c@{reader.c}!osim\_card\_open@{osim\_card\_open}}
\index{osim\_card\_open@{osim\_card\_open}!reader.c@{reader.c}}
\doxysubsubsection{osim\_card\_open()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$ osim\+\_\+card\+\_\+open (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$}]{rh,  }\item[{enum \textbf{ osim\+\_\+proto}}]{proto }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+reader\+\_\+ops\+::card\+\_\+open}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::ops}, \textbf{ osim\+\_\+card\+\_\+hdl\+::proto}, and \textbf{ osim\+\_\+reader\+\_\+hdl\+::proto\+\_\+supported}.

\mbox{\label{reader_8c_a1cfcfad9aa83ac1f669796c6df872c68}} 
\index{reader.c@{reader.c}!osim\_card\_reset@{osim\_card\_reset}}
\index{osim\_card\_reset@{osim\_card\_reset}!reader.c@{reader.c}}
\doxysubsubsection{osim\_card\_reset()}
{\footnotesize\ttfamily int osim\+\_\+card\+\_\+reset (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{card,  }\item[{bool}]{cold\+\_\+reset }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+reader\+\_\+hdl\+::card}, \textbf{ osim\+\_\+reader\+\_\+ops\+::card\+\_\+reset}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::ops}, and \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}.

\mbox{\label{reader_8c_a91657fdf310e086465bb60b708a200f4}} 
\index{reader.c@{reader.c}!osim\_reader\_open@{osim\_reader\_open}}
\index{osim\_reader\_open@{osim\_reader\_open}!reader.c@{reader.c}}
\doxysubsubsection{osim\_reader\_open()}
{\footnotesize\ttfamily struct \textbf{ osim\+\_\+reader\+\_\+hdl} $\ast$ osim\+\_\+reader\+\_\+open (\begin{DoxyParamCaption}\item[{enum \textbf{ osim\+\_\+reader\+\_\+driver}}]{driver,  }\item[{int}]{idx,  }\item[{const char $\ast$}]{name,  }\item[{void $\ast$}]{ctx }\end{DoxyParamCaption})}



References \textbf{ name}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::ops}, \textbf{ OSIM\+\_\+\+PROTO\+\_\+\+T0}, \textbf{ OSIM\+\_\+\+READER\+\_\+\+DRV\+\_\+\+PCSC}, \textbf{ pcsc\+\_\+reader\+\_\+ops}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::proto\+\_\+supported}, and \textbf{ osim\+\_\+reader\+\_\+ops\+::reader\+\_\+open}.

\mbox{\label{reader_8c_a2d55db97588ce6352704be8ba8792ce8}} 
\index{reader.c@{reader.c}!osim\_transceive\_apdu@{osim\_transceive\_apdu}}
\index{osim\_transceive\_apdu@{osim\_transceive\_apdu}!reader.c@{reader.c}}
\doxysubsubsection{osim\_transceive\_apdu()}
{\footnotesize\ttfamily int osim\+\_\+transceive\+\_\+apdu (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+chan\+\_\+hdl} $\ast$}]{st,  }\item[{struct \textbf{ msgb} $\ast$}]{amsg }\end{DoxyParamCaption})}



References \textbf{ osim\+\_\+chan\+\_\+hdl\+::card}, \textbf{ OSIM\+\_\+\+PROTO\+\_\+\+T0}, \textbf{ osim\+\_\+card\+\_\+hdl\+::proto}, and \textbf{ transceive\+\_\+apdu\+\_\+t0()}.

\mbox{\label{reader_8c_af83b94190859dcc4060ae7858d1cf580}} 
\index{reader.c@{reader.c}!transceive\_apdu\_t0@{transceive\_apdu\_t0}}
\index{transceive\_apdu\_t0@{transceive\_apdu\_t0}!reader.c@{reader.c}}
\doxysubsubsection{transceive\_apdu\_t0()}
{\footnotesize\ttfamily static int transceive\+\_\+apdu\+\_\+t0 (\begin{DoxyParamCaption}\item[{struct \textbf{ osim\+\_\+card\+\_\+hdl} $\ast$}]{st,  }\item[{struct \textbf{ msgb} $\ast$}]{amsg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



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{ get\+\_\+sw()}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::ins}, \textbf{ msgb\+::l3h}, \textbf{ msgb\+\_\+alloc()}, \textbf{ msgb\+\_\+apdu\+\_\+case}, \textbf{ msgb\+\_\+apdu\+\_\+dc}, \textbf{ msgb\+\_\+apdu\+\_\+de}, \textbf{ msgb\+\_\+apdu\+\_\+h}, \textbf{ msgb\+\_\+apdu\+\_\+lc}, \textbf{ msgb\+\_\+apdu\+\_\+le}, \textbf{ msgb\+\_\+apdu\+\_\+sw}, \textbf{ msgb\+\_\+free()}, \textbf{ msgb\+\_\+get()}, \textbf{ msgb\+\_\+l3len()}, \textbf{ msgb\+\_\+length()}, \textbf{ msgb\+\_\+put()}, \textbf{ msgb\+\_\+put\+\_\+u16()}, \textbf{ osim\+\_\+reader\+\_\+hdl\+::ops}, \textbf{ OSMO\+\_\+\+MIN}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::p1}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::p2}, \textbf{ osim\+\_\+apdu\+\_\+cmd\+\_\+hdr\+::p3}, \textbf{ osim\+\_\+card\+\_\+hdl\+::reader}, \textbf{ sw}, \textbf{ msgb\+::tail}, and \textbf{ osim\+\_\+reader\+\_\+ops\+::transceive}.



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

