Loading...
Searching...
No Matches
sim.h File Reference

Routines for helping with SIM (ISO/IEC 7816-4 more generally) communication. More...

`#include <osmocom/core/msgb.h>`
`#include <osmocom/core/linuxlist.h>`

Go to the source code of this file.

## Data Structures

struct | osim_apdu_cmd_hdr
| APDU/TPDU command header. More...
struct | osim_msgb_cb
| APDU command body. More...
struct | osim_file_ops
| Operations for a given File. More...
struct | osim_decoded_element
| A single decoded element inside a file. More...
struct | osim_decoded_data
| Decoded data for a single file, consisting of all decoded elements. More...
struct | osim_file_desc
struct | osim_file
| A single instance of a file: Descriptor and contents. More...
struct | osim_card_sw
| A card status word (SW) More...
struct | osim_card_app_profile
| A card application (e.g. More...
struct | osim_card_profile
| A card profile (e.g. More...
struct | osim_reader_ops
struct | osim_reader_hdl
struct | osim_card_app_hdl
| descriptor for a given application present on a card More...
struct | osim_card_hdl
struct | osim_chan_hdl

## Macros

#define | APDU_HDR_LEN 5
#define | MAX_AID_LEN 16 /* Table 13.2 of TS 102 221 */
#define | OSIM_MAX_ATR_LEN 33
| Maximum Answer-To-Reset (ATR) size in bytes.
#define | msgb_apdu_dr(__x)
#define | OSIM_MSGB_CB(__msgb) ((struct osim_msgb_cb *)&((__msgb)->cb[0]))
#define | msgb_apdu_case(__x) OSIM_MSGB_CB(__x)->apduc
| status word from msgb->cb
#define | msgb_apdu_lc(__x) OSIM_MSGB_CB(__x)->lc
#define | msgb_apdu_le(__x) OSIM_MSGB_CB(__x)->le
#define | msgb_apdu_sw(__x) OSIM_MSGB_CB(__x)->sw
#define | msgb_apdu_h(__x) ((struct osim_apdu_cmd_hdr *)(__x)->l2h)
| pointer to the command header of the APDU
#define | msgb_apdu_dc(__x) ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr))
#define | msgb_apdu_de(__x) ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr) + msgb_apdu_lc(__x))
#define | F_OPTIONAL 0x0001
#define | SFI_NONE 0xFF
#define | EF(pfid, sfi, pns, pflags, pnl, ptype, smin, srec, pdec, penc)
| Convenience macros for defining EF.
#define | EF_TRANSP(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
| Convenience macros for defining EF.
#define | EF_TRANSP_N(fid, sfi, ns, flags, smin, srec, nl)
| Convenience macros for defining EF.
#define | EF_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
| Convenience macros for defining EF.
#define | EF_CYCLIC_N(fid, sfi, ns, flags, smin, srec, nl)
| Convenience macros for defining EF.
#define | EF_LIN_FIX(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
| Convenience macros for defining EF.
#define | EF_LIN_FIX_N(fid, sfi, ns, flags, smin, srec, nl)
| Convenience macros for defining EF.
#define | EF_KEY(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
| Convenience macros for defining EF.
#define | EF_KEY_N(fid, sfi, ns, flags, smin, srec, nl)
| Convenience macros for defining EF.
#define | OSIM_CARD_SW_LAST

## Enumerations

enum | osim_apdu_case { APDU_CASE_1 , APDU_CASE_2S , APDU_CASE_2E , APDU_CASE_3S , APDU_CASE_3E , APDU_CASE_4S , APDU_CASE_4E }
| command-response pairs cases More...
enum | osim_element_type { ELEM_T_NONE , ELEM_T_BOOL , ELEM_T_UINT8 , ELEM_T_UINT16 , ELEM_T_UINT32 , ELEM_T_STRING , ELEM_T_BCD , ELEM_T_BYTES , ELEM_T_GROUP }
enum | osim_element_repr { ELEM_REPR_NONE , ELEM_REPR_DEC , ELEM_REPR_HEX }
enum | osim_file_type { TYPE_NONE , TYPE_DF , TYPE_ADF , TYPE_EF , TYPE_EF_INT , TYPE_MF }
enum | osim_ef_type { EF_TYPE_TRANSP , EF_TYPE_RECORD_FIXED , EF_TYPE_RECORD_CYCLIC , EF_TYPE_KEY }
enum | osim_card_sw_type { SW_TYPE_NONE , SW_TYPE_STR }
enum | osim_card_sw_class { SW_CLS_NONE , SW_CLS_OK , SW_CLS_POSTP , SW_CLS_WARN , SW_CLS_ERROR }

enum

ts102221_fcp_tag {
UICC_FCP_T_FCP = 0x62 ,
UICC_FCP_T_FILE_SIZE = 0x80 ,
UICC_FCP_T_TOT_F_SIZE = 0x81 ,
UICC_FCP_T_FILE_DESC = 0x82 ,
UICC_FCP_T_FILE_ID = 0x83 ,
UICC_FCP_T_DF_NAME = 0x84 ,
UICC_FCP_T_SFID = 0x88 ,
UICC_FCP_T_LIFEC_STS = 0x8A ,
UICC_FCP_T_SEC_ATTR_REFEXP = 0x8B ,
UICC_FCP_T_SEC_ATTR_COMP = 0x8C ,
UICC_FCP_T_PROPRIETARY = 0xA5 ,
UICC_FCP_T_SEC_ATTR_EXP = 0xAB ,
UICC_FCP_T_PIN_STS_DO = 0xC6
}

enum | osim_proto { OSIM_PROTO_T0 = 0 , OSIM_PROTO_T1 = 1 }
enum | osim_reader_driver { OSIM_READER_DRV_PCSC = 0 , OSIM_READER_DRV_OPENCT = 1 , OSIM_READER_DRV_SERIAL = 2 }

## Functions

struct osim_apdu_cmd_hdr | __attribute__ ((packed))
struct osim_msgb_cb | __attribute__ ((__may_alias__))
int | osim_init (void *ctx)
struct osim_file_desc * | osim_file_desc_find_name (struct osim_file_desc *parent, const char *name)
struct osim_file_desc * | osim_file_desc_find_aid (struct osim_file_desc *parent, const uint8_t *aid, uint8_t aid_len)
struct osim_file_desc * | osim_file_desc_find_fid (struct osim_file_desc *parent, uint16_t fid)
struct osim_file_desc * | osim_file_desc_find_sfid (struct osim_file_desc *parent, uint8_t sfid)
const struct osim_card_app_profile * | osim_app_profile_find_by_name (const char *name)
| Find any registered application profile based on its name (e.g.
const struct osim_card_app_profile * | osim_app_profile_find_by_aid (const uint8_t *aid, uint8_t aid_len)
| Find any registered application profile based on its AID.
const struct osim_card_sw * | osim_app_profile_find_sw (const struct osim_card_app_profile *ap, uint16_t sw_in)
| Find application-specific status word within given card application profile.
const struct osim_card_sw * | osim_cprof_find_sw (const struct osim_card_profile *cp, uint16_t sw_in)
| Find status word within given card profile.
enum osim_card_sw_class | osim_sw_class (const struct osim_chan_hdl *ch, uint16_t sw_in)
char * | osim_print_sw_buf (char *buf, size_t buf_len, const struct osim_chan_hdl *ch, uint16_t sw_in)
char * | osim_print_sw (const struct osim_chan_hdl *ch, uint16_t sw_in)
char * | osim_print_sw_c (const void *ctx, const struct osim_chan_hdl *ch, uint16_t sw_in)
struct msgb * | osim_new_apdumsg (uint8_t cla, uint8_t ins, uint8_t p1, uint8_t p2, uint16_t lc, uint16_t le)
| Generate an APDU message and initialize APDU command header.
int | osim_card_hdl_add_app (struct osim_card_hdl *ch, const uint8_t *aid, uint8_t aid_len, const char *label)
| Add an application to a given card.
int | osim_transceive_apdu (struct osim_chan_hdl *st, struct msgb *amsg)
struct osim_reader_hdl * | osim_reader_open (enum osim_reader_driver drv, int idx, const char *name, void *ctx)
struct osim_card_hdl * | osim_card_open (struct osim_reader_hdl *rh, enum osim_proto proto)
int | osim_card_reset (struct osim_card_hdl *card, bool cold_reset)
int | osim_card_close (struct osim_card_hdl *card)

## Variables

uint8_t | cla
| CLASS byte.
uint8_t | ins
| INSTRUCTION byte.
uint8_t | p1
| Parameter 1 byte.
uint8_t | p2
| Parameter 2 byte.
uint8_t | p3
| Parameter 3 byte, used for TPDU by T=0.
enum osim_apdu_case | apduc
| command-response pair case, defining the encoding of Lc and Le
uint16_t | lc
| number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc, depending on the case
uint16_t | le
| maximum number of bytes expected in the response data field, which will encoded in 0, 1, 2 or 3 bytes into Le, depending on the case
uint16_t | sw
| status word, composed of SW1 and SW2 bytes
struct osim_file_ops | __attribute__
const struct tlv_definition | ts102221_fcp_tlv_def
const struct value_string | ts102221_fcp_vals [14]

## Detailed Description

Routines for helping with SIM (ISO/IEC 7816-4 more generally) communication.

## Macro Definition Documentation

## APDU_HDR_LEN

#define APDU_HDR_LEN 5

## EF

#define EF | ( |  | pfid,
|  |  | sfi,
|  |  | pns,
|  |  | pflags,
|  |  | pnl,
|  |  | ptype,
|  |  | smin,
|  |  | srec,
|  |  | pdec,
|  |  | penc
| ) |  |

Value:
{ \
.fid = pfid, \
.sfid = sfi, \
.type = TYPE_EF, \
.ef_type = ptype, \
.short_name = pns, \
.long_name = pnl, \
.flags = pflags, \
.ops = { .encode = penc, .parse = pdec }, \
.size = { .min = smin, .rec = srec}, \
}
TYPE_EF
@ TYPE_EF
Entry File.
Definition sim.h:145

Convenience macros for defining EF.

## EF_CYCLIC

#define EF_CYCLIC | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl,
|  |  | dec,
|  |  | enc
| ) |  |

Value:
EF(fid, sfi, ns, flags, nl, EF_TYPE_RECORD_CYCLIC, \
smin, srec, dec, enc)
EF_TYPE_RECORD_CYCLIC
@ EF_TYPE_RECORD_CYCLIC
Cyclic Record EF.
Definition sim.h:153
EF
#define EF(pfid, sfi, pns, pflags, pnl, ptype, smin, srec, pdec, penc)
Convenience macros for defining EF.
Definition sim.h:200

Convenience macros for defining EF.

## EF_CYCLIC_N

#define EF_CYCLIC_N | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl
| ) |  |

Value:
EF_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
default_decode
int default_decode(struct osim_decoded_data *dd, const struct osim_file_desc *desc, int len, uint8_t *data)
Definition core.c:461
EF_CYCLIC
#define EF_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
Convenience macros for defining EF.
Definition sim.h:224

Convenience macros for defining EF.

## EF_KEY

#define EF_KEY | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl,
|  |  | dec,
|  |  | enc
| ) |  |

Value:
EF(fid, sfi, ns, flags, nl, EF_TYPE_KEY, \
smin, srec, dec, enc)
EF_TYPE_KEY
@ EF_TYPE_KEY
Key file as used in TETRA.
Definition sim.h:154

Convenience macros for defining EF.

## EF_KEY_N

#define EF_KEY_N | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl
| ) |  |

Value:
EF_KEY(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
EF_KEY
#define EF_KEY(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
Convenience macros for defining EF.
Definition sim.h:242

Convenience macros for defining EF.

## EF_LIN_FIX

#define EF_LIN_FIX | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl,
|  |  | dec,
|  |  | enc
| ) |  |

Value:
EF(fid, sfi, ns, flags, nl, EF_TYPE_RECORD_FIXED, \
smin, srec, dec, enc)
EF_TYPE_RECORD_FIXED
@ EF_TYPE_RECORD_FIXED
Fixed-Size Record EF.
Definition sim.h:152

Convenience macros for defining EF.

## EF_LIN_FIX_N

#define EF_LIN_FIX_N | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl
| ) |  |

Value:
EF_LIN_FIX(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
EF_LIN_FIX
#define EF_LIN_FIX(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
Convenience macros for defining EF.
Definition sim.h:233

Convenience macros for defining EF.

## EF_TRANSP

#define EF_TRANSP | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl,
|  |  | dec,
|  |  | enc
| ) |  |

Value:
EF(fid, sfi, ns, flags, nl, EF_TYPE_TRANSP, \
smin, srec, dec, enc)
EF_TYPE_TRANSP
@ EF_TYPE_TRANSP
Transparent EF.
Definition sim.h:151

Convenience macros for defining EF.

## EF_TRANSP_N

#define EF_TRANSP_N | ( |  | fid,
|  |  | sfi,
|  |  | ns,
|  |  | flags,
|  |  | smin,
|  |  | srec,
|  |  | nl
| ) |  |

Value:
EF_TRANSP(fid, sfi, ns, flags, smin, srec, \
nl, &default_decode, NULL)
EF_TRANSP
#define EF_TRANSP(fid, sfi, ns, flags, smin, srec, nl, dec, enc)
Convenience macros for defining EF.
Definition sim.h:215

Convenience macros for defining EF.

## F_OPTIONAL

#define F_OPTIONAL 0x0001

## MAX_AID_LEN

#define MAX_AID_LEN 16 /* Table 13.2 of TS 102 221 */

## msgb_apdu_case

#define msgb_apdu_case | ( |  | __x | ) | OSIM_MSGB_CB(__x)->apduc

status word from msgb->cb

## msgb_apdu_dc

#define msgb_apdu_dc | ( |  | __x | ) | ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr))

## msgb_apdu_de

#define msgb_apdu_de | ( |  | __x | ) | ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr) + msgb_apdu_lc(__x))

## msgb_apdu_dr

#define msgb_apdu_dr | ( |  | __x | ) |

## msgb_apdu_h

#define msgb_apdu_h | ( |  | __x | ) | ((struct osim_apdu_cmd_hdr *)(__x)->l2h)

pointer to the command header of the APDU

## msgb_apdu_lc

#define msgb_apdu_lc | ( |  | __x | ) | OSIM_MSGB_CB(__x)->lc

## msgb_apdu_le

#define msgb_apdu_le | ( |  | __x | ) | OSIM_MSGB_CB(__x)->le

## msgb_apdu_sw

#define msgb_apdu_sw | ( |  | __x | ) | OSIM_MSGB_CB(__x)->sw

## OSIM_CARD_SW_LAST

#define OSIM_CARD_SW_LAST

Value:
{ \
.code = 0, .mask = 0, .type = SW_TYPE_NONE, \
.class = SW_CLS_NONE, .u.str = NULL \
}
SW_CLS_NONE
@ SW_CLS_NONE
Definition sim.h:271
SW_TYPE_NONE
@ SW_TYPE_NONE
Definition sim.h:266

## OSIM_MAX_ATR_LEN

#define OSIM_MAX_ATR_LEN 33

Maximum Answer-To-Reset (ATR) size in bytes.

Note
  defined in ISO/IEC 7816-3:2006(E) section 8.2.1 as 32, on top the initial character TS of section 8.1

Remarks
  technical there is no size limitation since Yi present in T0,TDi will indicate if more interface bytes are present, including TDi+i

## OSIM_MSGB_CB

#define OSIM_MSGB_CB | ( |  | __msgb | ) | ((struct osim_msgb_cb *)&((__msgb)->cb[0]))

## SFI_NONE

#define SFI_NONE 0xFF

## Enumeration Type Documentation

## osim_apdu_case

enum osim_apdu_case

command-response pairs cases

Enumeration used to identify the APDU structure based on command-response pair case , as specified in ISO/IEC 7816-3:2006(E) §12.1.

Enumerator
APDU_CASE_1 | command header, no command data field, no response data field
APDU_CASE_2S | command header, no command data field, response data field (short)
APDU_CASE_2E | command header, no command data field, response data field (extended)
APDU_CASE_3S | command header, command data field (short), no response data field
APDU_CASE_3E | command header, command data field (extended), no response data field
APDU_CASE_4S | command header, command data field (short), response data field (short)
APDU_CASE_4E | command header, command data field (extended), response data field (extended)

## osim_card_sw_class

enum osim_card_sw_class

Enumerator
SW_CLS_NONE |
SW_CLS_OK |
SW_CLS_POSTP |
SW_CLS_WARN |
SW_CLS_ERROR |

## osim_card_sw_type

enum osim_card_sw_type

Enumerator
SW_TYPE_NONE |
SW_TYPE_STR |

## osim_ef_type

enum osim_ef_type

Enumerator
EF_TYPE_TRANSP | Transparent EF.
EF_TYPE_RECORD_FIXED | Fixed-Size Record EF.
EF_TYPE_RECORD_CYCLIC | Cyclic Record EF.
EF_TYPE_KEY | Key file as used in TETRA.

## osim_element_repr

enum osim_element_repr

Enumerator
ELEM_REPR_NONE |
ELEM_REPR_DEC |
ELEM_REPR_HEX |

## osim_element_type

enum osim_element_type

Enumerator
ELEM_T_NONE |
ELEM_T_BOOL | a boolean flag
ELEM_T_UINT8 | unsigned integer
ELEM_T_UINT16 | unsigned integer
ELEM_T_UINT32 | unsigned integer
ELEM_T_STRING | generic string
ELEM_T_BCD | BCD encoded digits.
ELEM_T_BYTES | BCD encoded digits.
ELEM_T_GROUP | group container, has siblings

## osim_file_type

enum osim_file_type

Enumerator
TYPE_NONE |
TYPE_DF | Dedicated File.
TYPE_ADF | Application Dedicated File.
TYPE_EF | Entry File.
TYPE_EF_INT | Internal Entry File.
TYPE_MF | Master File.

## osim_proto

enum osim_proto

Enumerator
OSIM_PROTO_T0 |
OSIM_PROTO_T1 |

## osim_reader_driver

enum osim_reader_driver

Enumerator
OSIM_READER_DRV_PCSC |
OSIM_READER_DRV_OPENCT |
OSIM_READER_DRV_SERIAL |

## ts102221_fcp_tag

enum ts102221_fcp_tag

Enumerator
UICC_FCP_T_FCP |
UICC_FCP_T_FILE_SIZE |
UICC_FCP_T_TOT_F_SIZE |
UICC_FCP_T_FILE_DESC |
UICC_FCP_T_FILE_ID |
UICC_FCP_T_DF_NAME |
UICC_FCP_T_SFID |
UICC_FCP_T_LIFEC_STS |
UICC_FCP_T_SEC_ATTR_REFEXP |
UICC_FCP_T_SEC_ATTR_COMP |
UICC_FCP_T_PROPRIETARY |
UICC_FCP_T_SEC_ATTR_EXP |
UICC_FCP_T_PIN_STS_DO |

## Function Documentation

## __attribute__() [1/2]

struct osim_msgb_cb __attribute__ | ( | (__may_alias__) |  | ) |

## __attribute__() [2/2]

struct osim_apdu_cmd_hdr __attribute__ | ( | (packed) |  | ) |

## osim_app_profile_find_by_aid()

const struct osim_card_app_profile * osim_app_profile_find_by_aid | ( | const uint8_t * | aid,
|  | uint8_t | aid_len
| ) |  |

Find any registered application profile based on its AID.

References osim_card_app_profile::aid, osim_card_app_profile::aid_len, and osim_card_app_profile::list.

Referenced by osim_app_profile_register(), and osim_card_hdl_add_app().

## osim_app_profile_find_by_name()

const struct osim_card_app_profile * osim_app_profile_find_by_name | ( | const char * | name | ) |

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

"ADF.USIM")

References osim_card_app_profile::list, and osim_card_app_profile::name.

Referenced by osim_app_profile_register().

## osim_app_profile_find_sw()

const struct osim_card_sw * osim_app_profile_find_sw | ( | const struct osim_card_app_profile * | ap,
|  | uint16_t | sw_in
| ) |  |

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

References osim_card_sw::code, sw, and osim_card_app_profile::sw.

Referenced by osim_print_sw_buf(), and osim_sw_class().

## osim_card_close()

int osim_card_close | ( | struct osim_card_hdl * | card | ) |

References osim_reader_hdl::card, osim_reader_ops::card_close, osim_reader_hdl::ops, and osim_card_hdl::reader.

## osim_card_hdl_add_app()

int osim_card_hdl_add_app | ( | struct osim_card_hdl * | ch,
|  | const uint8_t * | aid,
|  | uint8_t | aid_len,
|  | const char * | label
| ) |  |

Add an application to a given card.

References osim_card_app_hdl::aid, osim_card_app_hdl::aid_len, osim_card_hdl::apps, osim_card_app_hdl::label, osim_card_app_hdl::list, MAX_AID_LEN, osim_app_profile_find_by_aid(), osim_card_hdl_find_app(), and osim_card_app_hdl::prof.

## osim_card_open()

struct osim_card_hdl * osim_card_open | ( | struct osim_reader_hdl * | rh,
|  | enum osim_proto | proto
| ) |  |

References osim_reader_ops::card_open, osim_reader_hdl::ops, osim_card_hdl::proto, and osim_reader_hdl::proto_supported.

## osim_card_reset()

int osim_card_reset | ( | struct osim_card_hdl * | card,
|  | bool | cold_reset
| ) |  |

References osim_reader_hdl::card, osim_reader_ops::card_reset, osim_reader_hdl::ops, and osim_card_hdl::reader.

## osim_cprof_find_sw()

const struct osim_card_sw * osim_cprof_find_sw | ( | const struct osim_card_profile * | cp,
|  | uint16_t | sw_in
| ) |  |

Find status word within given card profile.

References osim_card_sw::code, sw, and osim_card_profile::sws.

Referenced by osim_print_sw_buf(), and osim_sw_class().

## osim_file_desc_find_aid()

struct osim_file_desc * osim_file_desc_find_aid | ( | struct osim_file_desc * | parent,
|  | const uint8_t * | aid,
|  | uint8_t | aid_len
| ) |  |

References osim_file_desc::child_list, osim_file_desc::df_name, osim_file_desc::df_name_len, osim_file_desc::list, osim_file_desc::parent, osim_file_desc::type, and TYPE_ADF.

## osim_file_desc_find_fid()

struct osim_file_desc * osim_file_desc_find_fid | ( | struct osim_file_desc * | parent,
|  | uint16_t | fid
| ) |  |

References osim_file_desc::child_list, osim_file_desc::fid, osim_file_desc::list, and osim_file_desc::parent.

## osim_file_desc_find_name()

struct osim_file_desc * osim_file_desc_find_name | ( | struct osim_file_desc * | parent,
|  | const char * | name
| ) |  |

References osim_file_desc::child_list, osim_file_desc::list, osim_file_desc::parent, and osim_file_desc::short_name.

## osim_file_desc_find_sfid()

struct osim_file_desc * osim_file_desc_find_sfid | ( | struct osim_file_desc * | parent,
|  | uint8_t | sfid
| ) |  |

References osim_file_desc::child_list, osim_file_desc::list, osim_file_desc::parent, SFI_NONE, and osim_file_desc::sfid.

## osim_init()

int osim_init | ( | void * | ctx | ) |

References osim_app_profile_register(), osim_aprof_hpsim(), osim_aprof_isim(), and osim_aprof_usim().

## osim_new_apdumsg()

struct msgb * osim_new_apdumsg | ( | uint8_t | cla,
|  | uint8_t | ins,
|  | uint8_t | p1,
|  | uint8_t | p2,
|  | uint16_t | lc,
|  | uint16_t | le
| ) |  |

Generate an APDU message and initialize APDU command header.

Parameters

  [in] | cla | CLASS byte
  [in] | ins | INSTRUCTION byte
  [in] | p1 | Parameter 1 byte
  [in] | p2 | Parameter 2 byte
  [in] | lc | number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc
  [in] | le | maximum number of bytes expected in the response data field, which will encoded in 0, 1, 2 or 3 bytes into Le

Returns
  an APDU message generated using provided APDU parameters

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 APDU_CASE_1, APDU_CASE_2E, APDU_CASE_2S, APDU_CASE_3E, APDU_CASE_3S, APDU_CASE_4E, APDU_CASE_4S, cla, osim_apdu_cmd_hdr::cla, ins, osim_apdu_cmd_hdr::ins, lc, le, msgb_apdu_case, msgb_apdu_lc, msgb_apdu_le, p1, osim_apdu_cmd_hdr::p1, p2, and osim_apdu_cmd_hdr::p2.

## osim_print_sw()

char * osim_print_sw | ( | const struct osim_chan_hdl * | ch,
|  | uint16_t | sw_in
| ) |  |

References osim_print_sw_buf().

## osim_print_sw_buf()

char * osim_print_sw_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osim_chan_hdl * | ch,
|  | uint16_t | sw_in
| ) |  |

References osim_chan_hdl::card, osim_chan_hdl::cur_app, osim_app_profile_find_sw(), osim_cprof_find_sw(), osim_card_app_hdl::prof, osim_card_hdl::prof, osim_card_sw::str, SW_TYPE_STR, osim_card_sw::type, and osim_card_sw::u.

Referenced by osim_print_sw(), and osim_print_sw_c().

## osim_print_sw_c()

char * osim_print_sw_c | ( | const void * | ctx,
|  | const struct osim_chan_hdl * | ch,
|  | uint16_t | sw_in
| ) |  |

References osim_print_sw_buf().

## osim_reader_open()

struct osim_reader_hdl * osim_reader_open | ( | enum osim_reader_driver | drv,
|  | int | idx,
|  | const char * | name,
|  | void * | ctx
| ) |  |

References osim_reader_hdl::ops, OSIM_PROTO_T0, OSIM_READER_DRV_PCSC, pcsc_reader_ops, osim_reader_hdl::proto_supported, and osim_reader_ops::reader_open.

## osim_sw_class()

enum osim_card_sw_class osim_sw_class | ( | const struct osim_chan_hdl * | ch,
|  | uint16_t | sw_in
| ) |  |

References osim_chan_hdl::card, osim_card_sw::class, osim_chan_hdl::cur_app, osim_app_profile_find_sw(), osim_cprof_find_sw(), osim_card_app_hdl::prof, osim_card_hdl::prof, and SW_CLS_NONE.

## osim_transceive_apdu()

int osim_transceive_apdu | ( | struct osim_chan_hdl * | st,
|  | struct msgb * | amsg
| ) |  |

References osim_chan_hdl::card, OSIM_PROTO_T0, osim_card_hdl::proto, and transceive_apdu_t0().

## Variable Documentation

## __attribute__

struct osim_file_ops __attribute__

## apduc

enum osim_apdu_case apduc

command-response pair case, defining the encoding of Lc and Le

## cla

uint8_t cla

CLASS byte.

Referenced by osim_determine_apdu_case(), and osim_new_apdumsg().

## ins

uint8_t ins

INSTRUCTION byte.

Referenced by gp_cla_ins_helper(), osim_determine_apdu_case(), osim_new_apdumsg(), and uicc046_cla_ins_helper().

## lc

uint16_t lc

number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc, depending on the case

Referenced by osim_new_apdumsg().

## le

uint16_t le

maximum number of bytes expected in the response data field, which will encoded in 0, 1, 2 or 3 bytes into Le, depending on the case

Referenced by osim_new_apdumsg().

## p1

uint8_t p1

Parameter 1 byte.

Referenced by gp_cla_ins_helper(), osim_new_apdumsg(), and uicc046_cla_ins_helper().

## p2

uint8_t p2

Parameter 2 byte.

Referenced by osim_new_apdumsg(), and uicc046_cla_ins_helper().

## p3

uint8_t p3

Parameter 3 byte, used for TPDU by T=0.

Referenced by gp_cla_ins_helper().

## sw

uint16_t sw

status word, composed of SW1 and SW2 bytes

Referenced by osim_app_profile_find_sw(), osim_cprof_find_sw(), and transceive_apdu_t0().

## ts102221_fcp_tlv_def

const struct tlv_definition ts102221_fcp_tlv_def

extern

## ts102221_fcp_vals

const struct value_string ts102221_fcp_vals[14]

extern