\doxysection{sim.\+h}
\label{sim_8h_source}\index{include/osmocom/sim/sim.h@{include/osmocom/sim/sim.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{5 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{9 }
\DoxyCodeLine{10 \textcolor{preprocessor}{\#define APDU\_HDR\_LEN    5}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#define MAX\_AID\_LEN     16 }\textcolor{comment}{/* Table 13.2 of TS 102 221 */}\textcolor{preprocessor}{}}
\DoxyCodeLine{12 }
\DoxyCodeLine{13 }
\DoxyCodeLine{18 \textcolor{preprocessor}{\#define OSIM\_MAX\_ATR\_LEN 33}}
\DoxyCodeLine{19 }
\DoxyCodeLine{24 \textcolor{keyword}{enum} osim\_apdu\_case \{}
\DoxyCodeLine{25         APDU\_CASE\_1, }
\DoxyCodeLine{26         APDU\_CASE\_2S, }
\DoxyCodeLine{27         APDU\_CASE\_2E, }
\DoxyCodeLine{28         APDU\_CASE\_3S, }
\DoxyCodeLine{29         APDU\_CASE\_3E, }
\DoxyCodeLine{30         APDU\_CASE\_4S, }
\DoxyCodeLine{31         APDU\_CASE\_4E }
\DoxyCodeLine{32 \};}
\DoxyCodeLine{33 }
\DoxyCodeLine{43 \textcolor{keyword}{struct }osim\_apdu\_cmd\_hdr \{}
\DoxyCodeLine{44         uint8\_t cla; }
\DoxyCodeLine{45         uint8\_t ins; }
\DoxyCodeLine{46         uint8\_t p1; }
\DoxyCodeLine{47         uint8\_t p2; }
\DoxyCodeLine{48         uint8\_t p3; }
\DoxyCodeLine{49 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{50 }
\DoxyCodeLine{51 \textcolor{preprocessor}{\#define msgb\_apdu\_dr(\_\_x)}}
\DoxyCodeLine{52 }
\DoxyCodeLine{58 \textcolor{keyword}{struct }osim\_msgb\_cb \{}
\DoxyCodeLine{59         \textcolor{keyword}{enum} osim\_apdu\_case apduc; }
\DoxyCodeLine{60         uint16\_t lc; }
\DoxyCodeLine{61         uint16\_t le; }
\DoxyCodeLine{62         uint16\_t sw; }
\DoxyCodeLine{63 \} \_\_attribute\_\_((\_\_may\_alias\_\_));}
\DoxyCodeLine{64 \textcolor{preprocessor}{\#define OSIM\_MSGB\_CB(\_\_msgb)    ((struct osim\_msgb\_cb *)\&((\_\_msgb)-\/>cb[0]))}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\#define msgb\_apdu\_case(\_\_x)     OSIM\_MSGB\_CB(\_\_x)-\/>apduc}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#define msgb\_apdu\_lc(\_\_x)       OSIM\_MSGB\_CB(\_\_x)-\/>lc}}
\DoxyCodeLine{68 \textcolor{preprocessor}{\#define msgb\_apdu\_le(\_\_x)       OSIM\_MSGB\_CB(\_\_x)-\/>le}}
\DoxyCodeLine{69 \textcolor{preprocessor}{\#define msgb\_apdu\_sw(\_\_x)       OSIM\_MSGB\_CB(\_\_x)-\/>sw}}
\DoxyCodeLine{71 \textcolor{preprocessor}{\#define msgb\_apdu\_h(\_\_x)        ((struct osim\_apdu\_cmd\_hdr *)(\_\_x)-\/>l2h)}}
\DoxyCodeLine{72 }
\DoxyCodeLine{73 \textcolor{preprocessor}{\#define msgb\_apdu\_dc(\_\_x)       ((\_\_x)-\/>l2h + sizeof(struct osim\_apdu\_cmd\_hdr))}}
\DoxyCodeLine{74 \textcolor{preprocessor}{\#define msgb\_apdu\_de(\_\_x)       ((\_\_x)-\/>l2h + sizeof(struct osim\_apdu\_cmd\_hdr) + msgb\_apdu\_lc(\_\_x))}}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{keywordtype}{int} osim\_init(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{77 }
\DoxyCodeLine{78 \textcolor{comment}{/* FILES */}}
\DoxyCodeLine{79 }
\DoxyCodeLine{80 \textcolor{keyword}{struct }osim\_file;}
\DoxyCodeLine{81 \textcolor{keyword}{struct }osim\_file\_desc;}
\DoxyCodeLine{82 \textcolor{keyword}{struct }osim\_decoded\_data;}
\DoxyCodeLine{83 }
\DoxyCodeLine{85 \textcolor{keyword}{struct }osim\_file\_ops \{}
\DoxyCodeLine{87         int (*parse)(\textcolor{keyword}{struct }osim\_decoded\_data *dd,}
\DoxyCodeLine{88                      \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_file\_desc *desc,}
\DoxyCodeLine{89                      \textcolor{keywordtype}{int} len, uint8\_t *data);}
\DoxyCodeLine{91         \textcolor{keyword}{struct }msgb * (*encode)(\textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_file\_desc *desc,}
\DoxyCodeLine{92                                 \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_decoded\_data *decoded);}
\DoxyCodeLine{93 \};}
\DoxyCodeLine{94 }
\DoxyCodeLine{95 \textcolor{keyword}{enum} osim\_element\_type \{}
\DoxyCodeLine{96         ELEM\_T\_NONE,}
\DoxyCodeLine{97         ELEM\_T\_BOOL, }
\DoxyCodeLine{98         ELEM\_T\_UINT8,       }
\DoxyCodeLine{99         ELEM\_T\_UINT16,     }
\DoxyCodeLine{100         ELEM\_T\_UINT32,     }
\DoxyCodeLine{101         ELEM\_T\_STRING,     }
\DoxyCodeLine{102         ELEM\_T\_BCD,   }
\DoxyCodeLine{103         ELEM\_T\_BYTES,       }
\DoxyCodeLine{104         ELEM\_T\_GROUP,       }
\DoxyCodeLine{105 \};}
\DoxyCodeLine{106 }
\DoxyCodeLine{107 \textcolor{keyword}{enum} osim\_element\_repr \{}
\DoxyCodeLine{108         ELEM\_REPR\_NONE,}
\DoxyCodeLine{109         ELEM\_REPR\_DEC,}
\DoxyCodeLine{110         ELEM\_REPR\_HEX,}
\DoxyCodeLine{111 \};}
\DoxyCodeLine{112 }
\DoxyCodeLine{114 \textcolor{keyword}{struct }osim\_decoded\_element \{}
\DoxyCodeLine{115         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{116 }
\DoxyCodeLine{117         \textcolor{keyword}{enum} osim\_element\_type type;}
\DoxyCodeLine{118         \textcolor{keyword}{enum} osim\_element\_repr representation;}
\DoxyCodeLine{119         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{120 }
\DoxyCodeLine{121         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} length;}
\DoxyCodeLine{122         \textcolor{keyword}{union }\{}
\DoxyCodeLine{123                 uint8\_t u8;}
\DoxyCodeLine{124                 uint16\_t u16;}
\DoxyCodeLine{125                 uint32\_t u32;}
\DoxyCodeLine{126                 uint8\_t *buf;}
\DoxyCodeLine{128                 \textcolor{keyword}{struct }llist\_head siblings;}
\DoxyCodeLine{129         \} u;}
\DoxyCodeLine{130 \};}
\DoxyCodeLine{131 }
\DoxyCodeLine{133 \textcolor{keyword}{struct }osim\_decoded\_data \{}
\DoxyCodeLine{135         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_file *file;}
\DoxyCodeLine{137         \textcolor{keyword}{struct }llist\_head decoded\_elements;}
\DoxyCodeLine{138 \};}
\DoxyCodeLine{139 }
\DoxyCodeLine{140 }
\DoxyCodeLine{141 \textcolor{keyword}{enum} osim\_file\_type \{}
\DoxyCodeLine{142         TYPE\_NONE,}
\DoxyCodeLine{143         TYPE\_DF, }
\DoxyCodeLine{144         TYPE\_ADF,       }
\DoxyCodeLine{145         TYPE\_EF, }
\DoxyCodeLine{146         TYPE\_EF\_INT, }
\DoxyCodeLine{147         TYPE\_MF, }
\DoxyCodeLine{148 \};}
\DoxyCodeLine{149 }
\DoxyCodeLine{150 \textcolor{keyword}{enum} osim\_ef\_type \{}
\DoxyCodeLine{151         EF\_TYPE\_TRANSP,           }
\DoxyCodeLine{152         EF\_TYPE\_RECORD\_FIXED,       }
\DoxyCodeLine{153         EF\_TYPE\_RECORD\_CYCLIC,     }
\DoxyCodeLine{154         EF\_TYPE\_KEY,         }
\DoxyCodeLine{155 \};}
\DoxyCodeLine{156 }
\DoxyCodeLine{157 \textcolor{preprocessor}{\#define F\_OPTIONAL              0x0001}}
\DoxyCodeLine{158 }
\DoxyCodeLine{159 \textcolor{preprocessor}{\#define SFI\_NONE                0xFF}}
\DoxyCodeLine{160 }
\DoxyCodeLine{161 \textcolor{keyword}{struct }osim\_file\_desc \{}
\DoxyCodeLine{162         \textcolor{keyword}{struct }llist\_head list;           }
\DoxyCodeLine{163         \textcolor{keyword}{struct }llist\_head child\_list;       }
\DoxyCodeLine{164         \textcolor{keyword}{struct }osim\_file\_desc *parent;      }
\DoxyCodeLine{166         \textcolor{keyword}{enum} osim\_file\_type type;     }
\DoxyCodeLine{167         \textcolor{keyword}{enum} osim\_ef\_type ef\_type;   }
\DoxyCodeLine{169         uint16\_t fid;                        }
\DoxyCodeLine{170         uint8\_t sfid;                       }
\DoxyCodeLine{171         \textcolor{keyword}{const} uint8\_t *df\_name;}
\DoxyCodeLine{172         uint8\_t df\_name\_len;}
\DoxyCodeLine{173 }
\DoxyCodeLine{174         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *short\_name;               }
\DoxyCodeLine{175         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *long\_name;         }
\DoxyCodeLine{176         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} flags;}
\DoxyCodeLine{177 }
\DoxyCodeLine{178         \textcolor{keyword}{struct }osim\_file\_ops ops;       }
\DoxyCodeLine{180         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{181                 \textcolor{keywordtype}{size\_t} min;          }
\DoxyCodeLine{184                 \textcolor{keywordtype}{size\_t} rec;          }
\DoxyCodeLine{185         \} size;}
\DoxyCodeLine{186 \};}
\DoxyCodeLine{187 }
\DoxyCodeLine{189 \textcolor{keyword}{struct }osim\_file \{}
\DoxyCodeLine{191         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_file\_desc *desc;}
\DoxyCodeLine{192 }
\DoxyCodeLine{194         \textcolor{keyword}{struct }msgb *encoded\_data;}
\DoxyCodeLine{196         \textcolor{keyword}{struct }osim\_decoded\_data *decoded\_data;}
\DoxyCodeLine{197 \};}
\DoxyCodeLine{198 }
\DoxyCodeLine{200 \textcolor{preprocessor}{\#define EF(pfid, sfi, pns, pflags, pnl, ptype, smin, srec, pdec, penc)  \(\backslash\)}}
\DoxyCodeLine{201 \textcolor{preprocessor}{        \{                                                               \(\backslash\)}}
\DoxyCodeLine{202 \textcolor{preprocessor}{                .fid            = pfid,                                 \(\backslash\)}}
\DoxyCodeLine{203 \textcolor{preprocessor}{                .sfid           = sfi,                                  \(\backslash\)}}
\DoxyCodeLine{204 \textcolor{preprocessor}{                .type           = TYPE\_EF,                              \(\backslash\)}}
\DoxyCodeLine{205 \textcolor{preprocessor}{                .ef\_type        = ptype,                                \(\backslash\)}}
\DoxyCodeLine{206 \textcolor{preprocessor}{                .short\_name     = pns,                                  \(\backslash\)}}
\DoxyCodeLine{207 \textcolor{preprocessor}{                .long\_name      = pnl,                                  \(\backslash\)}}
\DoxyCodeLine{208 \textcolor{preprocessor}{                .flags          = pflags,                               \(\backslash\)}}
\DoxyCodeLine{209 \textcolor{preprocessor}{                .ops            = \{ .encode = penc, .parse = pdec \},    \(\backslash\)}}
\DoxyCodeLine{210 \textcolor{preprocessor}{                .size           = \{ .min = smin, .rec = srec\},          \(\backslash\)}}
\DoxyCodeLine{211 \textcolor{preprocessor}{        \}}}
\DoxyCodeLine{212 }
\DoxyCodeLine{213 }
\DoxyCodeLine{215 \textcolor{preprocessor}{\#define EF\_TRANSP(fid, sfi, ns, flags, smin, srec, nl, dec, enc)        \(\backslash\)}}
\DoxyCodeLine{216 \textcolor{preprocessor}{                EF(fid, sfi, ns, flags, nl, EF\_TYPE\_TRANSP,             \(\backslash\)}}
\DoxyCodeLine{217 \textcolor{preprocessor}{                   smin, srec, dec, enc)}}
\DoxyCodeLine{219 \textcolor{preprocessor}{\#define EF\_TRANSP\_N(fid, sfi, ns, flags, smin, srec, nl)                \(\backslash\)}}
\DoxyCodeLine{220 \textcolor{preprocessor}{                EF\_TRANSP(fid, sfi, ns, flags, smin, srec,              \(\backslash\)}}
\DoxyCodeLine{221 \textcolor{preprocessor}{                          nl, \&default\_decode, NULL)}}
\DoxyCodeLine{222 }
\DoxyCodeLine{224 \textcolor{preprocessor}{\#define EF\_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, dec, enc)        \(\backslash\)}}
\DoxyCodeLine{225 \textcolor{preprocessor}{                EF(fid, sfi, ns, flags, nl, EF\_TYPE\_RECORD\_CYCLIC,      \(\backslash\)}}
\DoxyCodeLine{226 \textcolor{preprocessor}{                   smin, srec, dec, enc)}}
\DoxyCodeLine{228 \textcolor{preprocessor}{\#define EF\_CYCLIC\_N(fid, sfi, ns, flags, smin, srec, nl)                \(\backslash\)}}
\DoxyCodeLine{229 \textcolor{preprocessor}{                EF\_CYCLIC(fid, sfi, ns, flags, smin, srec, nl,          \(\backslash\)}}
\DoxyCodeLine{230 \textcolor{preprocessor}{                          \&default\_decode, NULL)}}
\DoxyCodeLine{231 }
\DoxyCodeLine{233 \textcolor{preprocessor}{\#define EF\_LIN\_FIX(fid, sfi, ns, flags, smin, srec, nl, dec, enc)       \(\backslash\)}}
\DoxyCodeLine{234 \textcolor{preprocessor}{                EF(fid, sfi, ns, flags, nl, EF\_TYPE\_RECORD\_FIXED,       \(\backslash\)}}
\DoxyCodeLine{235 \textcolor{preprocessor}{                   smin, srec, dec, enc)}}
\DoxyCodeLine{237 \textcolor{preprocessor}{\#define EF\_LIN\_FIX\_N(fid, sfi, ns, flags, smin, srec, nl)               \(\backslash\)}}
\DoxyCodeLine{238 \textcolor{preprocessor}{                EF\_LIN\_FIX(fid, sfi, ns, flags, smin, srec, nl,         \(\backslash\)}}
\DoxyCodeLine{239 \textcolor{preprocessor}{                           \&default\_decode, NULL)}}
\DoxyCodeLine{240 }
\DoxyCodeLine{242 \textcolor{preprocessor}{\#define EF\_KEY(fid, sfi, ns, flags, smin, srec, nl, dec, enc)           \(\backslash\)}}
\DoxyCodeLine{243 \textcolor{preprocessor}{                EF(fid, sfi, ns, flags, nl, EF\_TYPE\_KEY,                \(\backslash\)}}
\DoxyCodeLine{244 \textcolor{preprocessor}{                   smin, srec, dec, enc)}}
\DoxyCodeLine{246 \textcolor{preprocessor}{\#define EF\_KEY\_N(fid, sfi, ns, flags, smin, srec, nl)                   \(\backslash\)}}
\DoxyCodeLine{247 \textcolor{preprocessor}{                EF\_KEY(fid, sfi, ns, flags, smin, srec, nl,             \(\backslash\)}}
\DoxyCodeLine{248 \textcolor{preprocessor}{                       \&default\_decode, NULL)}}
\DoxyCodeLine{249 }
\DoxyCodeLine{250 }
\DoxyCodeLine{251 \textcolor{keyword}{struct }osim\_file\_desc *}
\DoxyCodeLine{252 osim\_file\_desc\_find\_name(\textcolor{keyword}{struct} osim\_file\_desc *parent, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{253 }
\DoxyCodeLine{254 \textcolor{keyword}{struct }osim\_file\_desc *}
\DoxyCodeLine{255 osim\_file\_desc\_find\_aid(\textcolor{keyword}{struct} osim\_file\_desc *parent, \textcolor{keyword}{const} uint8\_t *aid, uint8\_t aid\_len);}
\DoxyCodeLine{256 }
\DoxyCodeLine{257 \textcolor{keyword}{struct }osim\_file\_desc *}
\DoxyCodeLine{258 osim\_file\_desc\_find\_fid(\textcolor{keyword}{struct} osim\_file\_desc *parent, uint16\_t fid);}
\DoxyCodeLine{259 }
\DoxyCodeLine{260 \textcolor{keyword}{struct }osim\_file\_desc *}
\DoxyCodeLine{261 osim\_file\_desc\_find\_sfid(\textcolor{keyword}{struct} osim\_file\_desc *parent, uint8\_t sfid);}
\DoxyCodeLine{262 }
\DoxyCodeLine{263 \textcolor{comment}{/* STATUS WORDS */}}
\DoxyCodeLine{264 }
\DoxyCodeLine{265 \textcolor{keyword}{enum} osim\_card\_sw\_type \{}
\DoxyCodeLine{266         SW\_TYPE\_NONE,}
\DoxyCodeLine{267         SW\_TYPE\_STR,}
\DoxyCodeLine{268 \};}
\DoxyCodeLine{269 }
\DoxyCodeLine{270 \textcolor{keyword}{enum} osim\_card\_sw\_class \{}
\DoxyCodeLine{271         SW\_CLS\_NONE,}
\DoxyCodeLine{272         SW\_CLS\_OK,}
\DoxyCodeLine{273         SW\_CLS\_POSTP,}
\DoxyCodeLine{274         SW\_CLS\_WARN,}
\DoxyCodeLine{275         SW\_CLS\_ERROR,}
\DoxyCodeLine{276 \};}
\DoxyCodeLine{277 }
\DoxyCodeLine{279 \textcolor{keyword}{struct }osim\_card\_sw \{}
\DoxyCodeLine{281         uint16\_t code;}
\DoxyCodeLine{283         uint16\_t mask;}
\DoxyCodeLine{284         \textcolor{keyword}{enum} osim\_card\_sw\_type type;}
\DoxyCodeLine{285         \textcolor{keyword}{enum} osim\_card\_sw\_class \textcolor{keyword}{class};}
\DoxyCodeLine{286         \textcolor{keyword}{union }\{}
\DoxyCodeLine{288                 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *str;}
\DoxyCodeLine{289         \} u;}
\DoxyCodeLine{290 \};}
\DoxyCodeLine{291 }
\DoxyCodeLine{292 \textcolor{preprocessor}{\#define OSIM\_CARD\_SW\_LAST       \{                       \(\backslash\)}}
\DoxyCodeLine{293 \textcolor{preprocessor}{        .code = 0, .mask = 0, .type = SW\_TYPE\_NONE,     \(\backslash\)}}
\DoxyCodeLine{294 \textcolor{preprocessor}{        .class = SW\_CLS\_NONE, .u.str = NULL             \(\backslash\)}}
\DoxyCodeLine{295 \textcolor{preprocessor}{\}}}
\DoxyCodeLine{296 }
\DoxyCodeLine{298 \textcolor{keyword}{struct }osim\_card\_app\_profile \{}
\DoxyCodeLine{300         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{302         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{304         uint8\_t aid[MAX\_AID\_LEN];}
\DoxyCodeLine{305         uint8\_t aid\_len;}
\DoxyCodeLine{307         \textcolor{keyword}{struct }osim\_file\_desc *adf;}
\DoxyCodeLine{309         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_sw *sw;}
\DoxyCodeLine{310 \};}
\DoxyCodeLine{311 }
\DoxyCodeLine{312 \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_app\_profile *}
\DoxyCodeLine{313 osim\_app\_profile\_find\_by\_name(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{314 }
\DoxyCodeLine{315 \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_app\_profile *}
\DoxyCodeLine{316 osim\_app\_profile\_find\_by\_aid(\textcolor{keyword}{const} uint8\_t *aid, uint8\_t aid\_len);}
\DoxyCodeLine{317 }
\DoxyCodeLine{318 \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_sw *osim\_app\_profile\_find\_sw(\textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_card\_app\_profile *ap, uint16\_t sw\_in);}
\DoxyCodeLine{319 }
\DoxyCodeLine{321 \textcolor{keyword}{struct }osim\_card\_profile \{}
\DoxyCodeLine{322         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{324         \textcolor{keyword}{struct }osim\_file\_desc *mf;}
\DoxyCodeLine{326         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_sw **sws;}
\DoxyCodeLine{327 \};}
\DoxyCodeLine{328 }
\DoxyCodeLine{329 \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_sw *osim\_cprof\_find\_sw(\textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_card\_profile *cp, uint16\_t sw\_in);}
\DoxyCodeLine{330 }
\DoxyCodeLine{331 \textcolor{keyword}{struct }osim\_chan\_hdl;}
\DoxyCodeLine{332 \textcolor{keyword}{enum} osim\_card\_sw\_class osim\_sw\_class(\textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_chan\_hdl *ch, uint16\_t sw\_in);}
\DoxyCodeLine{333 \textcolor{keywordtype}{char} *osim\_print\_sw\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} buf\_len, \textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_chan\_hdl *ch, uint16\_t sw\_in);}
\DoxyCodeLine{334 \textcolor{keywordtype}{char} *osim\_print\_sw(\textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_chan\_hdl *ch, uint16\_t sw\_in);}
\DoxyCodeLine{335 \textcolor{keywordtype}{char} *osim\_print\_sw\_c(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} osim\_chan\_hdl *ch, uint16\_t sw\_in);}
\DoxyCodeLine{336 }
\DoxyCodeLine{337 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }tlv\_definition ts102221\_fcp\_tlv\_def;}
\DoxyCodeLine{338 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string ts102221\_fcp\_vals[14];}
\DoxyCodeLine{339 }
\DoxyCodeLine{340 \textcolor{comment}{/* 11.1.1.3 */}}
\DoxyCodeLine{341 \textcolor{keyword}{enum} ts102221\_fcp\_tag \{}
\DoxyCodeLine{342         UICC\_FCP\_T\_FCP            = 0x62,}
\DoxyCodeLine{343         UICC\_FCP\_T\_FILE\_SIZE        = 0x80,}
\DoxyCodeLine{344         UICC\_FCP\_T\_TOT\_F\_SIZE      = 0x81,}
\DoxyCodeLine{345         UICC\_FCP\_T\_FILE\_DESC        = 0x82,}
\DoxyCodeLine{346         UICC\_FCP\_T\_FILE\_ID    = 0x83,}
\DoxyCodeLine{347         UICC\_FCP\_T\_DF\_NAME    = 0x84,}
\DoxyCodeLine{348         UICC\_FCP\_T\_SFID          = 0x88,}
\DoxyCodeLine{349         UICC\_FCP\_T\_LIFEC\_STS        = 0x8A,}
\DoxyCodeLine{350         UICC\_FCP\_T\_SEC\_ATTR\_REFEXP= 0x8B,}
\DoxyCodeLine{351         UICC\_FCP\_T\_SEC\_ATTR\_COMP= 0x8C,}
\DoxyCodeLine{352         UICC\_FCP\_T\_PROPRIETARY    = 0xA5,}
\DoxyCodeLine{353         UICC\_FCP\_T\_SEC\_ATTR\_EXP  = 0xAB,}
\DoxyCodeLine{354         UICC\_FCP\_T\_PIN\_STS\_DO      = 0xC6,}
\DoxyCodeLine{355 \};}
\DoxyCodeLine{356 }
\DoxyCodeLine{357 \textcolor{keyword}{struct }msgb *osim\_new\_apdumsg(uint8\_t cla, uint8\_t ins, uint8\_t p1,}
\DoxyCodeLine{358                               uint8\_t p2, uint16\_t lc, uint16\_t le);}
\DoxyCodeLine{359 }
\DoxyCodeLine{360 \textcolor{comment}{/* CARD READERS */}}
\DoxyCodeLine{361 }
\DoxyCodeLine{362 \textcolor{keyword}{enum} osim\_proto \{}
\DoxyCodeLine{363         OSIM\_PROTO\_T0      = 0,}
\DoxyCodeLine{364         OSIM\_PROTO\_T1      = 1,}
\DoxyCodeLine{365 \};}
\DoxyCodeLine{366 }
\DoxyCodeLine{367 \textcolor{keyword}{enum} osim\_reader\_driver \{}
\DoxyCodeLine{368         OSIM\_READER\_DRV\_PCSC = 0,}
\DoxyCodeLine{369         OSIM\_READER\_DRV\_OPENCT = 1,}
\DoxyCodeLine{370         OSIM\_READER\_DRV\_SERIAL = 2,}
\DoxyCodeLine{371 \};}
\DoxyCodeLine{372 }
\DoxyCodeLine{373 \textcolor{keyword}{struct }osim\_reader\_ops \{}
\DoxyCodeLine{374         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{375         \textcolor{keyword}{struct }osim\_reader\_hdl *(*reader\_open)(\textcolor{keywordtype}{int} idx, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name, \textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{376         \textcolor{keyword}{struct }osim\_card\_hdl *(*card\_open)(\textcolor{keyword}{struct }osim\_reader\_hdl *rh, \textcolor{keyword}{enum} osim\_proto proto);}
\DoxyCodeLine{377         int (*card\_reset)(\textcolor{keyword}{struct }osim\_card\_hdl *card, \textcolor{keywordtype}{bool} cold\_reset);}
\DoxyCodeLine{378         int (*card\_close)(\textcolor{keyword}{struct }osim\_card\_hdl *card);}
\DoxyCodeLine{379         int (*transceive)(\textcolor{keyword}{struct }osim\_reader\_hdl *rh, \textcolor{keyword}{struct }msgb *msg);}
\DoxyCodeLine{380 \};}
\DoxyCodeLine{381 }
\DoxyCodeLine{382 \textcolor{keyword}{struct }osim\_reader\_hdl \{}
\DoxyCodeLine{384         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{385         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_reader\_ops *ops;}
\DoxyCodeLine{386         uint32\_t proto\_supported;}
\DoxyCodeLine{387         \textcolor{keywordtype}{void} *priv;}
\DoxyCodeLine{389         \textcolor{keyword}{struct }osim\_card\_hdl *card;}
\DoxyCodeLine{390 \};}
\DoxyCodeLine{391 }
\DoxyCodeLine{393 \textcolor{keyword}{struct }osim\_card\_app\_hdl \{}
\DoxyCodeLine{395         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{397         uint8\_t aid[MAX\_AID\_LEN];}
\DoxyCodeLine{398         uint8\_t aid\_len;}
\DoxyCodeLine{400         \textcolor{keywordtype}{char} *label;}
\DoxyCodeLine{402         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_card\_app\_profile *prof;}
\DoxyCodeLine{403 \};}
\DoxyCodeLine{404 }
\DoxyCodeLine{405 \textcolor{keyword}{struct }osim\_card\_hdl \{}
\DoxyCodeLine{407         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{409         \textcolor{keyword}{struct }osim\_reader\_hdl *reader;}
\DoxyCodeLine{411         \textcolor{keyword}{struct }osim\_card\_profile *prof;}
\DoxyCodeLine{413         \textcolor{keyword}{enum} osim\_proto proto;}
\DoxyCodeLine{414 }
\DoxyCodeLine{416         \textcolor{keyword}{struct }llist\_head channels;}
\DoxyCodeLine{417 }
\DoxyCodeLine{419         \textcolor{keyword}{struct }llist\_head apps;}
\DoxyCodeLine{420 }
\DoxyCodeLine{422         uint8\_t atr[OSIM\_MAX\_ATR\_LEN];}
\DoxyCodeLine{423         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} atr\_len;}
\DoxyCodeLine{424 \};}
\DoxyCodeLine{425 }
\DoxyCodeLine{426 \textcolor{keyword}{struct }osim\_chan\_hdl \{}
\DoxyCodeLine{428         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{430         \textcolor{keyword}{struct }osim\_card\_hdl *card;}
\DoxyCodeLine{432         \textcolor{keyword}{const} \textcolor{keyword}{struct }osim\_file\_desc *cwd;}
\DoxyCodeLine{434         \textcolor{keyword}{struct }osim\_card\_app\_hdl *cur\_app;}
\DoxyCodeLine{435 \};}
\DoxyCodeLine{436 }
\DoxyCodeLine{437 \textcolor{keywordtype}{int} osim\_card\_hdl\_add\_app(\textcolor{keyword}{struct} osim\_card\_hdl *ch, \textcolor{keyword}{const} uint8\_t *aid, uint8\_t aid\_len,}
\DoxyCodeLine{438                           \textcolor{keyword}{const} \textcolor{keywordtype}{char} *label);}
\DoxyCodeLine{439 }
\DoxyCodeLine{440 \textcolor{comment}{/* reader.c */}}
\DoxyCodeLine{441 \textcolor{keywordtype}{int} osim\_transceive\_apdu(\textcolor{keyword}{struct} osim\_chan\_hdl *st, \textcolor{keyword}{struct} msgb *amsg);}
\DoxyCodeLine{442 \textcolor{keyword}{struct }osim\_reader\_hdl *osim\_reader\_open(\textcolor{keyword}{enum} osim\_reader\_driver drv, \textcolor{keywordtype}{int} idx,}
\DoxyCodeLine{443                                          \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name, \textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{444 \textcolor{keyword}{struct }osim\_card\_hdl *osim\_card\_open(\textcolor{keyword}{struct} osim\_reader\_hdl *rh, \textcolor{keyword}{enum} osim\_proto proto);}
\DoxyCodeLine{445 \textcolor{keywordtype}{int} osim\_card\_reset(\textcolor{keyword}{struct} osim\_card\_hdl *card, \textcolor{keywordtype}{bool} cold\_reset);}
\DoxyCodeLine{446 \textcolor{keywordtype}{int} osim\_card\_close(\textcolor{keyword}{struct} osim\_card\_hdl *card);}

\end{DoxyCode}
