mirror of https://gerrit.osmocom.org/libosmocore
sim: further updates/fixes
This commit is contained in:
parent
7674960ffa
commit
d83d29610a
|
@ -231,6 +231,8 @@ struct osim_card_profile {
|
|||
|
||||
const struct osim_card_sw *osim_find_sw(const struct osim_card_profile *cp,
|
||||
uint16_t sw);
|
||||
enum osim_card_sw_class osim_sw_class(const struct osim_card_profile *cp,
|
||||
uint16_t sw_in);
|
||||
|
||||
struct osim_card_hdl;
|
||||
char *osim_print_sw(const struct osim_card_hdl *ch, uint16_t sw_in);
|
||||
|
@ -291,6 +293,6 @@ struct osim_chan_hdl {
|
|||
|
||||
/* reader.c */
|
||||
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);
|
||||
struct osim_card_hdl *osim_card_open(struct osim_reader_hdl *rh);
|
||||
#endif /* _OSMOCOM_SIM_H */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue