From d83d29610a7c63a387fee77dbc2b18b19dc83b14 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 4 Mar 2013 17:52:33 +0000 Subject: sim: further updates/fixes --- src/sim/core.c | 11 +++++++++++ src/sim/reader.c | 5 +++-- src/sim/reader_pcsc.c | 1 + src/sim/sim_int.h | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sim/core.c b/src/sim/core.c index bf682777..d1d4de73 100644 --- a/src/sim/core.c +++ b/src/sim/core.c @@ -279,3 +279,14 @@ const struct osim_card_sw *osim_find_sw(const struct osim_card_profile *cp, } return NULL; } + +enum osim_card_sw_class osim_sw_class(const struct osim_card_profile *cp, + uint16_t sw_in) +{ + const struct osim_card_sw *csw = osim_find_sw(cp, sw_in); + + if (!csw) + return SW_CLS_NONE; + + return csw->class; +} diff --git a/src/sim/reader.c b/src/sim/reader.c index 71d10d14..4f72dd0f 100644 --- a/src/sim/reader.c +++ b/src/sim/reader.c @@ -166,6 +166,7 @@ case_2s: goto transceive_again; break; case 0x61: /* Case 4S.3: command accepted with info added */ + case 0x9F: /* FIXME: This is specific to SIM cards */ tpduh->ins = 0xC0; tpduh->p1 = tpduh->p2 = 0; tpduh->p3 = OSMO_MIN(msgb_apdu_le(amsg), sw & 0xff); @@ -230,13 +231,13 @@ int osim_transceive_apdu(struct osim_chan_hdl *st, struct msgb *amsg) -struct osim_reader_hdl *osim_reader_open(int idx, const char *name) +struct osim_reader_hdl *osim_reader_open(int idx, const char *name, void *ctx) { /* FIXME: support multiple drivers */ const struct osim_reader_ops *ops = &pcsc_reader_ops; struct osim_reader_hdl *rh; - rh = ops->reader_open(idx, name); + rh = ops->reader_open(idx, name, ctx); if (!rh) return NULL; rh->ops = ops; diff --git a/src/sim/reader_pcsc.c b/src/sim/reader_pcsc.c index 60a9dee1..b490b97f 100644 --- a/src/sim/reader_pcsc.c +++ b/src/sim/reader_pcsc.c @@ -70,6 +70,7 @@ static struct osim_reader_hdl *pcsc_reader_open(int num, const char *id, void *c rc = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &st->hContext); + PCSC_ERROR(rc, "SCardEstablishContext"); if (rc != SCARD_S_SUCCESS) goto end; diff --git a/src/sim/sim_int.h b/src/sim/sim_int.h index 411c3225..73f144ca 100644 --- a/src/sim/sim_int.h +++ b/src/sim/sim_int.h @@ -28,7 +28,7 @@ add_adf_with_ef(struct osim_file_desc *parent, struct osim_reader_ops { const char *name; - struct osim_reader_hdl *(*reader_open)(int idx, 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); int (*transceive)(struct osim_reader_hdl *rh, struct msgb *msg); }; -- cgit v1.2.3