Loading...
Searching...
No Matches
sim.h
Go to the documentation of this file.
#pragma once
#include <osmocom/core/msgb.h>
#include <osmocom/core/linuxlist.h>
#define APDU_HDR_LEN 5
#define MAX_AID_LEN 16 /* Table 13.2 of TS 102 221 */
#define OSIM_MAX_ATR_LEN 33
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
};
struct osim_apdu_cmd_hdr {
uint8_t cla;
uint8_t ins;
uint8_t p1;
uint8_t p2;
uint8_t p3;
} __attribute__ ((packed));
#define msgb_apdu_dr(__x)
struct osim_msgb_cb {
enum osim_apdu_case apduc;
uint16_t lc;
uint16_t le;
uint16_t sw;
} __attribute__((__may_alias__));
#define OSIM_MSGB_CB(__msgb) ((struct osim_msgb_cb *)&((__msgb)->cb[0]))
#define msgb_apdu_case(__x) OSIM_MSGB_CB(__x)->apduc
#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)
#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))
int osim_init(void *ctx);
/* FILES */
struct osim_file;
struct osim_file_desc;
struct osim_decoded_data;
struct osim_file_ops {
int (*parse)(struct osim_decoded_data *dd,
const struct osim_file_desc *desc,
int len, uint8_t *data);
struct msgb * (*encode)(const struct osim_file_desc *desc,
const struct osim_decoded_data *decoded);
};
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,
};
struct osim_decoded_element {
struct llist_head list;
enum osim_element_type type;
enum osim_element_repr representation;
const char *name;
unsigned int length;
union {
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint8_t *buf;
struct llist_head siblings;
} u;
};
struct osim_decoded_data {
const struct osim_file *file;
struct llist_head decoded_elements;
};
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,
};
#define F_OPTIONAL 0x0001
#define SFI_NONE 0xFF
struct osim_file_desc {
struct llist_head list;
struct llist_head child_list;
struct osim_file_desc *parent;
enum osim_file_type type;
enum osim_ef_type ef_type;
uint16_t fid;
uint8_t sfid;
const uint8_t *df_name;
uint8_t df_name_len;
const char *short_name;
const char *long_name;
unsigned int flags;
struct osim_file_ops ops;
struct {
size_t min;
size_t rec;
} size;
};
struct osim_file {
const struct osim_file_desc *desc;
struct msgb *encoded_data;
struct osim_decoded_data *decoded_data;
};
#define EF(pfid, sfi, pns, pflags, pnl, ptype, smin, srec, pdec, penc) \
{ \
.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}, \
}
#define EF_TRANSP(fid, sfi, ns, flags, smin, srec, nl, dec, enc) \
EF(fid, sfi, ns, flags, nl, EF_TYPE_TRANSP, \
smin, srec, dec, enc)
#define EF_TRANSP_N(fid, sfi, ns, flags, smin, srec, nl) \
EF_TRANSP(fid, sfi, ns, flags, smin, srec, \
nl, &default_decode, NULL)
#define EF_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, dec, enc) \
EF(fid, sfi, ns, flags, nl, EF_TYPE_RECORD_CYCLIC, \
smin, srec, dec, enc)
#define EF_CYCLIC_N(fid, sfi, ns, flags, smin, srec, nl) \
EF_CYCLIC(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
#define EF_LIN_FIX(fid, sfi, ns, flags, smin, srec, nl, dec, enc) \
EF(fid, sfi, ns, flags, nl, EF_TYPE_RECORD_FIXED, \
smin, srec, dec, enc)
#define EF_LIN_FIX_N(fid, sfi, ns, flags, smin, srec, nl) \
EF_LIN_FIX(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
#define EF_KEY(fid, sfi, ns, flags, smin, srec, nl, dec, enc) \
EF(fid, sfi, ns, flags, nl, EF_TYPE_KEY, \
smin, srec, dec, enc)
#define EF_KEY_N(fid, sfi, ns, flags, smin, srec, nl) \
EF_KEY(fid, sfi, ns, flags, smin, srec, nl, \
&default_decode, NULL)
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);
/* STATUS WORDS */
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,
};
struct osim_card_sw {
uint16_t code;
uint16_t mask;
enum osim_card_sw_type type;
enum osim_card_sw_class class;
union {
const char *str;
} u;
};
#define OSIM_CARD_SW_LAST { \
.code = 0, .mask = 0, .type = SW_TYPE_NONE, \
.class = SW_CLS_NONE, .u.str = NULL \
}
struct osim_card_app_profile {
struct llist_head list;
const char *name;
uint8_t aid[MAX_AID_LEN];
uint8_t aid_len;
struct osim_file_desc *adf;
const struct osim_card_sw *sw;
};
const struct osim_card_app_profile *
osim_app_profile_find_by_name(const char *name);
const struct osim_card_app_profile *
osim_app_profile_find_by_aid(const uint8_t *aid, uint8_t aid_len);
const struct osim_card_sw *osim_app_profile_find_sw(const struct osim_card_app_profile *ap, uint16_t sw_in);
struct osim_card_profile {
const char *name;
struct osim_file_desc *mf;
const struct osim_card_sw **sws;
};
const struct osim_card_sw *osim_cprof_find_sw(const struct osim_card_profile *cp, uint16_t sw_in);
struct osim_chan_hdl;
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);
extern const struct tlv_definition ts102221_fcp_tlv_def;
extern const struct value_string ts102221_fcp_vals[14];
/* 11.1.1.3 */
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,
};
struct msgb *osim_new_apdumsg(uint8_t cla, uint8_t ins, uint8_t p1,
uint8_t p2, uint16_t lc, uint16_t le);
/* CARD READERS */
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,
};
struct osim_reader_ops {
const char *name;
struct osim_reader_hdl *(*reader_open)(int idx, const char *name, void *ctx);
struct osim_card_hdl *(*card_open)(struct osim_reader_hdl *rh, enum osim_proto proto);
int (*card_reset)(struct osim_card_hdl *card, bool cold_reset);
int (*card_close)(struct osim_card_hdl *card);
int (*transceive)(struct osim_reader_hdl *rh, struct msgb *msg);
};
struct osim_reader_hdl {
struct llist_head list;
const struct osim_reader_ops *ops;
uint32_t proto_supported;
void *priv;
struct osim_card_hdl *card;
};
struct osim_card_app_hdl {
struct llist_head list;
uint8_t aid[MAX_AID_LEN];
uint8_t aid_len;
char *label;
const struct osim_card_app_profile *prof;
};
struct osim_card_hdl {
struct llist_head list;
struct osim_reader_hdl *reader;
struct osim_card_profile *prof;
enum osim_proto proto;
struct llist_head channels;
struct llist_head apps;
uint8_t atr[OSIM_MAX_ATR_LEN];
unsigned int atr_len;
};
struct osim_chan_hdl {
struct llist_head list;
struct osim_card_hdl *card;
const struct osim_file_desc *cwd;
struct osim_card_app_hdl *cur_app;
};
int osim_card_hdl_add_app(struct osim_card_hdl *ch, const uint8_t *aid, uint8_t aid_len,
const char *label);
/* reader.c */
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);
len
static size_t len(const char *str)
osim_file_desc_find_sfid
struct osim_file_desc * osim_file_desc_find_sfid(struct osim_file_desc *parent, uint8_t sfid)
Definition core.c:215
osim_proto
osim_proto
Definition sim.h:362
OSIM_PROTO_T1
@ OSIM_PROTO_T1
Definition sim.h:364
OSIM_PROTO_T0
@ OSIM_PROTO_T0
Definition sim.h:363
le
uint16_t le
maximum number of bytes expected in the response data field, which will encoded in 0,...
Definition sim.h:2
osim_apdu_case
osim_apdu_case
command-response pairs cases
Definition sim.h:24
APDU_CASE_3E
@ APDU_CASE_3E
command header, command data field (extended), no response data field
Definition sim.h:29
APDU_CASE_4S
@ APDU_CASE_4S
command header, command data field (short), response data field (short)
Definition sim.h:30
APDU_CASE_2E
@ APDU_CASE_2E
command header, no command data field, response data field (extended)
Definition sim.h:27
APDU_CASE_3S
@ APDU_CASE_3S
command header, command data field (short), no response data field
Definition sim.h:28
APDU_CASE_4E
@ APDU_CASE_4E
command header, command data field (extended), response data field (extended)
Definition sim.h:31
APDU_CASE_2S
@ APDU_CASE_2S
command header, no command data field, response data field (short)
Definition sim.h:26
APDU_CASE_1
@ APDU_CASE_1
command header, no command data field, no response data field
Definition sim.h:25
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.
Definition core.c:245
osim_card_reset
int osim_card_reset(struct osim_card_hdl *card, bool cold_reset)
Definition reader.c:277
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)
Definition core.c:187
ts102221_fcp_tlv_def
const struct tlv_definition ts102221_fcp_tlv_def
Definition card_fs_uicc.c:209
osim_card_sw_class
osim_card_sw_class
Definition sim.h:270
SW_CLS_WARN
@ SW_CLS_WARN
Definition sim.h:274
SW_CLS_NONE
@ SW_CLS_NONE
Definition sim.h:271
SW_CLS_OK
@ SW_CLS_OK
Definition sim.h:272
SW_CLS_ERROR
@ SW_CLS_ERROR
Definition sim.h:275
SW_CLS_POSTP
@ SW_CLS_POSTP
Definition sim.h:273
osim_transceive_apdu
int osim_transceive_apdu(struct osim_chan_hdl *st, struct msgb *amsg)
Definition reader.c:224
p1
uint8_t p1
Parameter 1 byte.
Definition sim.h:2
osim_file_type
osim_file_type
Definition sim.h:141
TYPE_NONE
@ TYPE_NONE
Definition sim.h:142
TYPE_MF
@ TYPE_MF
Master File.
Definition sim.h:147
TYPE_ADF
@ TYPE_ADF
Application Dedicated File.
Definition sim.h:144
TYPE_EF
@ TYPE_EF
Entry File.
Definition sim.h:145
TYPE_DF
@ TYPE_DF
Dedicated File.
Definition sim.h:143
TYPE_EF_INT
@ TYPE_EF_INT
Internal Entry File.
Definition sim.h:146
osim_file_desc_find_name
struct osim_file_desc * osim_file_desc_find_name(struct osim_file_desc *parent, const char *name)
Definition core.c:175
ts102221_fcp_tag
ts102221_fcp_tag
Definition sim.h:341
UICC_FCP_T_FILE_DESC
@ UICC_FCP_T_FILE_DESC
Definition sim.h:345
UICC_FCP_T_FILE_ID
@ UICC_FCP_T_FILE_ID
Definition sim.h:346
UICC_FCP_T_SEC_ATTR_COMP
@ UICC_FCP_T_SEC_ATTR_COMP
Definition sim.h:351
UICC_FCP_T_FCP
@ UICC_FCP_T_FCP
Definition sim.h:342
UICC_FCP_T_PROPRIETARY
@ UICC_FCP_T_PROPRIETARY
Definition sim.h:352
UICC_FCP_T_FILE_SIZE
@ UICC_FCP_T_FILE_SIZE
Definition sim.h:343
UICC_FCP_T_SFID
@ UICC_FCP_T_SFID
Definition sim.h:348
UICC_FCP_T_DF_NAME
@ UICC_FCP_T_DF_NAME
Definition sim.h:347
UICC_FCP_T_SEC_ATTR_REFEXP
@ UICC_FCP_T_SEC_ATTR_REFEXP
Definition sim.h:350
UICC_FCP_T_LIFEC_STS
@ UICC_FCP_T_LIFEC_STS
Definition sim.h:349
UICC_FCP_T_SEC_ATTR_EXP
@ UICC_FCP_T_SEC_ATTR_EXP
Definition sim.h:353
UICC_FCP_T_PIN_STS_DO
@ UICC_FCP_T_PIN_STS_DO
Definition sim.h:354
UICC_FCP_T_TOT_F_SIZE
@ UICC_FCP_T_TOT_F_SIZE
Definition sim.h:344
osim_card_close
int osim_card_close(struct osim_card_hdl *card)
Definition reader.c:284
MAX_AID_LEN
#define MAX_AID_LEN
Definition sim.h:11
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.
Definition core.c:416
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.
Definition core.c:324
p2
uint8_t p2
Parameter 2 byte.
Definition sim.h:3
osim_reader_open
struct osim_reader_hdl * osim_reader_open(enum osim_reader_driver drv, int idx, const char *name, void *ctx)
Definition reader.c:234
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)
Definition core.c:366
osim_print_sw_c
char * osim_print_sw_c(const void *ctx, const struct osim_chan_hdl *ch, uint16_t sw_in)
Definition core.c:407
lc
uint16_t lc
number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc,...
Definition sim.h:1
cla
uint8_t cla
CLASS byte.
Definition sim.h:0
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.
Definition core.c:431
osim_element_repr
osim_element_repr
Definition sim.h:107
ELEM_REPR_HEX
@ ELEM_REPR_HEX
Definition sim.h:110
ELEM_REPR_DEC
@ ELEM_REPR_DEC
Definition sim.h:109
ELEM_REPR_NONE
@ ELEM_REPR_NONE
Definition sim.h:108
OSIM_MAX_ATR_LEN
#define OSIM_MAX_ATR_LEN
Maximum Answer-To-Reset (ATR) size in bytes.
Definition sim.h:18
ins
uint8_t ins
INSTRUCTION byte.
Definition sim.h:1
osim_init
int osim_init(void *ctx)
Definition core.c:473
__attribute__
struct osim_file_ops __attribute__
ts102221_fcp_vals
const struct value_string ts102221_fcp_vals[14]
Definition card_fs_uicc.c:191
osim_element_type
osim_element_type
Definition sim.h:95
ELEM_T_UINT16
@ ELEM_T_UINT16
unsigned integer
Definition sim.h:99
ELEM_T_UINT32
@ ELEM_T_UINT32
unsigned integer
Definition sim.h:100
ELEM_T_GROUP
@ ELEM_T_GROUP
group container, has siblings
Definition sim.h:104
ELEM_T_BOOL
@ ELEM_T_BOOL
a boolean flag
Definition sim.h:97
ELEM_T_BCD
@ ELEM_T_BCD
BCD encoded digits.
Definition sim.h:102
ELEM_T_STRING
@ ELEM_T_STRING
generic string
Definition sim.h:101
ELEM_T_BYTES
@ ELEM_T_BYTES
BCD encoded digits.
Definition sim.h:103
ELEM_T_UINT8
@ ELEM_T_UINT8
unsigned integer
Definition sim.h:98
ELEM_T_NONE
@ ELEM_T_NONE
Definition sim.h:96
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.
Definition core.c:258
osim_sw_class
enum osim_card_sw_class osim_sw_class(const struct osim_chan_hdl *ch, uint16_t sw_in)
Definition core.c:442
osim_card_sw_type
osim_card_sw_type
Definition sim.h:265
SW_TYPE_STR
@ SW_TYPE_STR
Definition sim.h:267
SW_TYPE_NONE
@ SW_TYPE_NONE
Definition sim.h:266
osim_file_desc_find_fid
struct osim_file_desc * osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid)
Definition core.c:203
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.
Definition core.c:287
osim_ef_type
osim_ef_type
Definition sim.h:150
EF_TYPE_TRANSP
@ EF_TYPE_TRANSP
Transparent EF.
Definition sim.h:151
EF_TYPE_RECORD_FIXED
@ EF_TYPE_RECORD_FIXED
Fixed-Size Record EF.
Definition sim.h:152
EF_TYPE_RECORD_CYCLIC
@ EF_TYPE_RECORD_CYCLIC
Cyclic Record EF.
Definition sim.h:153
EF_TYPE_KEY
@ EF_TYPE_KEY
Key file as used in TETRA.
Definition sim.h:154
osim_reader_driver
osim_reader_driver
Definition sim.h:367
OSIM_READER_DRV_SERIAL
@ OSIM_READER_DRV_SERIAL
Definition sim.h:370
OSIM_READER_DRV_OPENCT
@ OSIM_READER_DRV_OPENCT
Definition sim.h:369
OSIM_READER_DRV_PCSC
@ OSIM_READER_DRV_PCSC
Definition sim.h:368
osim_card_open
struct osim_card_hdl * osim_card_open(struct osim_reader_hdl *rh, enum osim_proto proto)
Definition reader.c:261
osim_print_sw
char * osim_print_sw(const struct osim_chan_hdl *ch, uint16_t sw_in)
Definition core.c:401
desc
osim_apdu_cmd_hdr
APDU/TPDU command header.
Definition sim.h:43
osim_apdu_cmd_hdr::p2
uint8_t p2
Parameter 2 byte.
Definition sim.h:47
osim_apdu_cmd_hdr::cla
uint8_t cla
CLASS byte.
Definition sim.h:44
osim_apdu_cmd_hdr::p1
uint8_t p1
Parameter 1 byte.
Definition sim.h:46
osim_apdu_cmd_hdr::p3
uint8_t p3
Parameter 3 byte, used for TPDU by T=0.
Definition sim.h:48
osim_apdu_cmd_hdr::ins
uint8_t ins
INSTRUCTION byte.
Definition sim.h:45
osim_card_app_hdl
descriptor for a given application present on a card
Definition sim.h:393
osim_card_app_hdl::prof
const struct osim_card_app_profile * prof
application profile (if any known)
Definition sim.h:402
osim_card_app_hdl::aid
uint8_t aid[MAX_AID_LEN]
AID of the application.
Definition sim.h:397
osim_card_app_hdl::list
struct llist_head list
member in card list of applications
Definition sim.h:395
osim_card_app_hdl::label
char * label
application label from EF_DIR
Definition sim.h:400
osim_card_app_hdl::aid_len
uint8_t aid_len
Definition sim.h:398
osim_card_app_profile
A card application (e.g.
Definition sim.h:298
osim_card_app_profile::list
struct llist_head list
entry in the global list of card application profiles
Definition sim.h:300
osim_card_app_profile::name
const char * name
human-readable name
Definition sim.h:302
osim_card_app_profile::aid
uint8_t aid[MAX_AID_LEN]
AID of this application, as used in EF.DIR.
Definition sim.h:304
osim_card_app_profile::aid_len
uint8_t aid_len
Definition sim.h:305
osim_card_app_profile::sw
const struct osim_card_sw * sw
Status words defined by application.
Definition sim.h:309
osim_card_app_profile::adf
struct osim_file_desc * adf
file system description
Definition sim.h:307
osim_card_hdl
Definition sim.h:405
osim_card_hdl::atr_len
unsigned int atr_len
Definition sim.h:423
osim_card_hdl::prof
struct osim_card_profile * prof
card profile
Definition sim.h:411
osim_card_hdl::reader
struct osim_reader_hdl * reader
reader through which card is accessed
Definition sim.h:409
osim_card_hdl::list
struct llist_head list
member in global list of cards
Definition sim.h:407
osim_card_hdl::proto
enum osim_proto proto
card protocol
Definition sim.h:413
osim_card_hdl::channels
struct llist_head channels
list of channels for this card
Definition sim.h:416
osim_card_hdl::atr
uint8_t atr[OSIM_MAX_ATR_LEN]
ATR (Answer To Reset) of the card.
Definition sim.h:422
osim_card_hdl::apps
struct llist_head apps
list of applications found on card
Definition sim.h:419
osim_card_profile
A card profile (e.g.
Definition sim.h:321
osim_card_profile::name
const char * name
Definition sim.h:322
osim_card_profile::mf
struct osim_file_desc * mf
Descriptor for the MF (root directory.
Definition sim.h:324
osim_card_profile::sws
const struct osim_card_sw ** sws
Array of pointers to status words.
Definition sim.h:326
osim_card_sw
A card status word (SW).
Definition sim.h:279
osim_card_sw::code
uint16_t code
status word code (2 bytes)
Definition sim.h:281
osim_card_sw::u
union osim_card_sw::@076362226051156275237267370250007131145255014030 u
osim_card_sw::str
const char * str
Human-readable meaning of SW.
Definition sim.h:288
osim_card_sw::mask
uint16_t mask
status word mask (2 bytes), to match range/prefix of SW
Definition sim.h:283
osim_card_sw::type
enum osim_card_sw_type type
Definition sim.h:284
osim_chan_hdl
Definition sim.h:426
osim_chan_hdl::cwd
const struct osim_file_desc * cwd
current working directory
Definition sim.h:432
osim_chan_hdl::list
struct llist_head list
linked to card->channels
Definition sim.h:428
osim_chan_hdl::cur_app
struct osim_card_app_hdl * cur_app
currently selected application (if any)
Definition sim.h:434
osim_chan_hdl::card
struct osim_card_hdl * card
card to which this channel belongs
Definition sim.h:430
osim_decoded_data
Decoded data for a single file, consisting of all decoded elements.
Definition sim.h:133
osim_decoded_data::file
const struct osim_file * file
file to which we belong
Definition sim.h:135
osim_decoded_data::decoded_elements
struct llist_head decoded_elements
list of 'struct decoded_element'
Definition sim.h:137
osim_decoded_element
A single decoded element inside a file.
Definition sim.h:114
osim_decoded_element::length
unsigned int length
Definition sim.h:121
osim_decoded_element::buf
uint8_t * buf
Definition sim.h:126
osim_decoded_element::representation
enum osim_element_repr representation
Definition sim.h:118
osim_decoded_element::u8
uint8_t u8
Definition sim.h:123
osim_decoded_element::u16
uint16_t u16
Definition sim.h:124
osim_decoded_element::u32
uint32_t u32
Definition sim.h:125
osim_decoded_element::type
enum osim_element_type type
Definition sim.h:117
osim_decoded_element::siblings
struct llist_head siblings
A list of sibling decoded_items.
Definition sim.h:128
osim_decoded_element::name
const char * name
Definition sim.h:119
osim_decoded_element::u
union osim_decoded_element::@136065024245375361367036020250340362374006214367 u
osim_decoded_element::list
struct llist_head list
Definition sim.h:115
osim_file_desc
Definition sim.h:161
osim_file_desc::size
struct osim_file_desc::@060326316070251173254012051333301177310140165071 size
osim_file_desc::min
size_t min
Minimum size of the file (transparent) or record in cyclic / linear file.
Definition sim.h:181
osim_file_desc::flags
unsigned int flags
Definition sim.h:176
osim_file_desc::ops
struct osim_file_ops ops
Operations (parse/encode.
Definition sim.h:178
osim_file_desc::ef_type
enum osim_ef_type ef_type
Type of the EF, if type == TYPE_EF.
Definition sim.h:167
osim_file_desc::parent
struct osim_file_desc * parent
parent DF
Definition sim.h:164
osim_file_desc::list
struct llist_head list
local element in list
Definition sim.h:162
osim_file_desc::short_name
const char * short_name
Short Name (like EF.ICCID).
Definition sim.h:174
osim_file_desc::sfid
uint8_t sfid
Short File IDentifier.
Definition sim.h:170
osim_file_desc::child_list
struct llist_head child_list
list of children EF in DF
Definition sim.h:163
osim_file_desc::rec
size_t rec
Recommended size.
Definition sim.h:184
osim_file_desc::fid
uint16_t fid
File Identifier.
Definition sim.h:169
osim_file_desc::long_name
const char * long_name
Long / description.
Definition sim.h:175
osim_file_desc::df_name
const uint8_t * df_name
Definition sim.h:171
osim_file_desc::df_name_len
uint8_t df_name_len
Definition sim.h:172
osim_file_desc::type
enum osim_file_type type
Type of the file (EF, DF, ...).
Definition sim.h:166
osim_file_ops
Operations for a given File.
Definition sim.h:85
osim_file_ops::parse
int(* parse)(struct osim_decoded_data *dd, const struct osim_file_desc *desc, int len, uint8_t *data)
Parse binary file data into osim_decoded_data.
Definition sim.h:87
osim_file
A single instance of a file: Descriptor and contents.
Definition sim.h:189
osim_file::encoded_data
struct msgb * encoded_data
Encoded file contents.
Definition sim.h:194
osim_file::desc
const struct osim_file_desc * desc
Descriptor for the file.
Definition sim.h:191
osim_file::decoded_data
struct osim_decoded_data * decoded_data
Parsed/Decoded file contents.
Definition sim.h:196
osim_msgb_cb
APDU command body.
Definition sim.h:58
osim_msgb_cb::sw
uint16_t sw
status word, composed of SW1 and SW2 bytes
Definition sim.h:62
osim_msgb_cb::lc
uint16_t lc
number of bytes in the command data field Nc, which will encoded in 0, 1 or 3 bytes into Lc,...
Definition sim.h:60
osim_msgb_cb::apduc
enum osim_apdu_case apduc
command-response pair case, defining the encoding of Lc and Le
Definition sim.h:59
osim_msgb_cb::le
uint16_t le
maximum number of bytes expected in the response data field, which will encoded in 0,...
Definition sim.h:61
osim_reader_hdl
Definition sim.h:382
osim_reader_hdl::ops
const struct osim_reader_ops * ops
Definition sim.h:385
osim_reader_hdl::card
struct osim_card_hdl * card
current card, if any
Definition sim.h:389
osim_reader_hdl::priv
void * priv
Definition sim.h:387
osim_reader_hdl::proto_supported
uint32_t proto_supported
Definition sim.h:386
osim_reader_hdl::list
struct llist_head list
member in global list of readers
Definition sim.h:384
osim_reader_ops
Definition sim.h:373
osim_reader_ops::transceive
int(* transceive)(struct osim_reader_hdl *rh, struct msgb *msg)
Definition sim.h:379
osim_reader_ops::card_close
int(* card_close)(struct osim_card_hdl *card)
Definition sim.h:378
osim_reader_ops::name
const char * name
Definition sim.h:374
osim_reader_ops::card_reset
int(* card_reset)(struct osim_card_hdl *card, bool cold_reset)
Definition sim.h:377