diff options
Diffstat (limited to 'include/osmocom/sim/sim.h')
-rw-r--r-- | include/osmocom/sim/sim.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h index bfd1ac94..639682a0 100644 --- a/include/osmocom/sim/sim.h +++ b/include/osmocom/sim/sim.h @@ -2,8 +2,7 @@ * Routines for helping with SIM (ISO/IEC 7816-4 more generally) communication. */ -#ifndef _OSMOCOM_SIM_H -#define _OSMOCOM_SIM_H +#pragma once #include <osmocom/core/msgb.h> #include <osmocom/core/linuxlist.h> @@ -11,6 +10,13 @@ #define APDU_HDR_LEN 5 #define MAX_AID_LEN 16 /* Table 13.2 of TS 102 221 */ + +/*! 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 + * @remark technical there is no size limitation since Yi present in T0,TDi will indicate if more interface bytes are present, including TDi+i + */ +#define OSIM_MAX_ATR_LEN 33 + /*! 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. @@ -283,7 +289,7 @@ struct osim_card_sw { } u; }; -#define OSIM_CARD_SW_LAST (const struct osim_card_sw) { \ +#define OSIM_CARD_SW_LAST { \ .code = 0, .mask = 0, .type = SW_TYPE_NONE, \ .class = SW_CLS_NONE, .u.str = NULL \ } @@ -368,6 +374,8 @@ 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); }; @@ -409,6 +417,10 @@ struct osim_card_hdl { /*! list of applications found on card */ struct llist_head apps; + + /*! ATR (Answer To Reset) of the card */ + uint8_t atr[OSIM_MAX_ATR_LEN]; + unsigned int atr_len; }; struct osim_chan_hdl { @@ -430,4 +442,5 @@ 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); -#endif /* _OSMOCOM_SIM_H */ +int osim_card_reset(struct osim_card_hdl *card, bool cold_reset); +int osim_card_close(struct osim_card_hdl *card); |