diff options
Diffstat (limited to 'include/osmocom/sim')
-rw-r--r-- | include/osmocom/sim/Makefile.am | 6 | ||||
-rw-r--r-- | include/osmocom/sim/class_tables.h | 4 | ||||
-rw-r--r-- | include/osmocom/sim/sim.h | 21 |
3 files changed, 23 insertions, 8 deletions
diff --git a/include/osmocom/sim/Makefile.am b/include/osmocom/sim/Makefile.am new file mode 100644 index 00000000..bcc9459f --- /dev/null +++ b/include/osmocom/sim/Makefile.am @@ -0,0 +1,6 @@ +osmosim_HEADERS = \ + class_tables.h \ + sim.h + $(NULL) + +osmosimdir = $(includedir)/osmocom/sim diff --git a/include/osmocom/sim/class_tables.h b/include/osmocom/sim/class_tables.h index d5be39dd..ec9ec490 100644 --- a/include/osmocom/sim/class_tables.h +++ b/include/osmocom/sim/class_tables.h @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once 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); |