diff options
author | Harald Welte <laforge@osmocom.org> | 2021-04-25 20:50:13 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-04-25 21:09:23 +0200 |
commit | 22117a7164012d6d88fc202cd63df79c6068484d (patch) | |
tree | ebd838fbe90a86799b902d41d30b31dc18baf715 /src | |
parent | a0f2b21c6d275456995fc6778f654af3a5e7ee93 (diff) |
sim: Obtain card ATR when opening the card
Change-Id: I42e387535c40f371b06f384af0ca5dc1e42ed00e
Diffstat (limited to 'src')
-rw-r--r-- | src/sim/reader_pcsc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sim/reader_pcsc.c b/src/sim/reader_pcsc.c index c37380a3..7d424b85 100644 --- a/src/sim/reader_pcsc.c +++ b/src/sim/reader_pcsc.c @@ -56,6 +56,27 @@ struct pcsc_reader_state { char *name; }; +static int pcsc_get_atr(struct osim_card_hdl *card) +{ + struct osim_reader_hdl *rh = card->reader; + struct pcsc_reader_state *st = rh->priv; + char pbReader[MAX_READERNAME]; + DWORD dwReaderLen = sizeof(pbReader); + DWORD dwAtrLen = sizeof(card->atr); + DWORD dwState, dwProt; + long rc; + + rc = SCardStatus(st->hCard, pbReader, &dwReaderLen, &dwState, &dwProt, + card->atr, &dwAtrLen); + PCSC_ERROR(rc, "SCardStatus"); + card->atr_len = dwAtrLen; + + return 0; + +end: + return -EIO; +} + static struct osim_reader_hdl *pcsc_reader_open(int num, const char *id, void *ctx) { struct osim_reader_hdl *rh; @@ -130,6 +151,8 @@ static struct osim_card_hdl *pcsc_card_open(struct osim_reader_hdl *rh, chan->card = card; llist_add(&chan->list, &card->channels); + pcsc_get_atr(card); + return card; end: |