1 /* 2 3 G N O K I I 4 5 A Linux/Unix toolset and driver for the mobile phones. 6 7 This file is part of gnokii. 8 9 Gnokii is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 Gnokii is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with gnokii; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 Copyright (C) 2007 Daniele Forsi 24 25 This file provides functions for accessing PC/SC SIM smart cards. 26 27 */ 28 29 #ifndef _gnokii_phones_pcsc_h 30 #define _gnokii_phones_pcsc_h 31 32 #include "compat.h" 33 #include "gnokii.h" 34 #include "phones/generic.h" 35 #include "gnokii-internal.h" 36 37 #include <PCSC/wintypes.h> 38 #include <PCSC/winscard.h> 39 40 #if !HAVE_LPCSTR 41 typedef const char *LPCSTR; 42 #endif 43 44 /* 45 some CLAss, INStruction pairs defined by GSM specs 46 taken from ETSI TS 100 977 V8.13.0 (2005-06) 47 subclause : command 48 9.2.1 : SELECT 49 9.2.3 : READ BINARY 50 9.2.4 : UPDATE BINARY 51 9.2.5 : READ RECORD 52 9.2.6 : UPDATE RECORD 53 9.2.9 : VERIFY CHV 54 9.2.18 : GET RESPONSE 55 */ 56 #define GN_PCSC_CMD_SELECT 0xA0, 0xA4 57 #define GN_PCSC_CMD_READ_BINARY 0xA0, 0xB0 58 #define GN_PCSC_CMD_UPDATE_BINARY 0xA0, 0xD6 59 #define GN_PCSC_CMD_READ_RECORD 0xA0, 0xB2 60 #define GN_PCSC_CMD_UPDATE_RECORD 0xA0, 0xDC 61 #define GN_PCSC_CMD_VERIFY_CHV 0xA0, 0x20 62 #define GN_PCSC_CMD_GET_RESPONSE 0xA0, 0xC0 63 64 /* useful defines from subclause 9.2.5 */ 65 66 #define GN_PCSC_FILE_READ_NEXT 2 67 #define GN_PCSC_FILE_READ_PREV 3 68 #define GN_PCSC_FILE_READ_ABS 4 69 70 /* useful defines from subclause 9.3 */ 71 72 #define GN_PCSC_FILE_STRUCTURE_TRANSPARENT 0 73 #define GN_PCSC_FILE_STRUCTURE_LINEAR_FIXED 1 74 #define GN_PCSC_FILE_STRUCTURE_CYCLIC 3 75 76 #define GN_PCSC_FILE_TYPE_MF 1 77 #define GN_PCSC_FILE_TYPE_DF 2 78 #define GN_PCSC_FILE_TYPE_EF 4 79 80 #define GN_PCSC_PARAMETER_OFFSET_P1 2 81 #define GN_PCSC_PARAMETER_OFFSET_P2 3 82 #define GN_PCSC_PARAMETER_OFFSET_P3 4 83 #define GN_PCSC_PARAMETER_OFFSET_FILEID_HI 5 84 #define GN_PCSC_PARAMETER_OFFSET_FILEID_LO 6 85 #define GN_PCSC_DATA_OFFSET 5 86 87 /* misc defines */ 88 #define GN_PCSC_ICCID_MAX_LENGTH 21 89 #define GN_PCSC_IMSI_MAX_LENGTH 16 90 #define GN_PCSC_SPN_MAX_LENGTH 17 91 92 /* some file identifiers (full list is in subclause 10.7) */ 93 94 /* This is the top level container */ 95 #define GN_PCSC_FILE_MF 0x3F00 96 /* ICC Identification */ 97 #define GN_PCSC_FILE_EF_ICCID 0x2FE2 98 /* This is the container of phonebooks and SMS */ 99 #define GN_PCSC_FILE_DF_TELECOM 0x7F10 100 /* This is the container of GSM specific information */ 101 #define GN_PCSC_FILE_DF_GSM 0x7F20 102 /* International Mobile Subscriber Identity (IMSI) */ 103 #define GN_PCSC_FILE_EF_IMSI 0x6F07 104 /* Abbreviated Dialling Numbers */ 105 #define GN_PCSC_FILE_EF_ADN 0x6F3A 106 /* Fixed Dialling Numbers */ 107 #define GN_PCSC_FILE_EF_FDN 0x6F3B 108 /* Short Messages */ 109 #define GN_PCSC_FILE_EF_SMS 0x6F3C 110 /* Mobile Subscriber Integrated Services Digital Network Number */ 111 #define GN_PCSC_FILE_EF_MSISDN 0x6F40 112 /* Short Message Service Parameters */ 113 #define GN_PCSC_FILE_EF_SMSP 0x6f42 114 /* Last Numbers Dialled */ 115 #define GN_PCSC_FILE_EF_LND 0x6F44 116 /* Service Provider Name */ 117 #define GN_PCSC_FILE_EF_SPN 0x6F46 118 /* Service Dialling Numbers */ 119 #define GN_PCSC_FILE_EF_SDN 0x6F49 120 /* Location Information */ 121 #define GN_PCSC_FILE_EF_LOCI 0x6F7E 122 /* Barred Dialling Numbers */ 123 #define GN_PCSC_FILE_EF_BDN 0x6F4D 124 /* Administrative data */ 125 #define GN_PCSC_FILE_EF_AD 0x6FAD 126 /* Phase Identification */ 127 #define GN_PCSC_FILE_EF_PHASE 0x6FAE 128 /* Emergency Call Codes */ 129 #define GN_PCSC_FILE_EF_ECC 0x6FB7 130 /* a convenience define */ 131 #define GN_PCSC_FILE_UNKNOWN 0x0000 132 133 typedef struct { 134 BYTE *pbRecvBuffer; 135 DWORD dwRecvLength; 136 DWORD dwReceived; 137 BYTE bRecordNumber; 138 } PCSC_IOSTRUCT; 139 140 #endif /* #ifndef _gnokii_phones_pcsc_h */ 141