2 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
4 * Copyright (C) 1999-2004
5 * David Corcoran <corcoran@linuxnet.com>
6 * Damien Sauveron <damien.sauveron@labri.fr>
8 * $Id: ifdhandler.h 3029 2008-06-26 13:58:52Z rousseau $
13 * @brief This provides reader specific low-level calls.
16 #ifndef _ifd_handler_h_
17 #define _ifd_handler_h_
27 * List of data structures available to ifdhandler
30 typedef struct _DEVICE_CAPABILITIES
32 LPSTR Vendor_Name
; /**< Tag 0x0100 */
33 LPSTR IFD_Type
; /**< Tag 0x0101 */
34 DWORD IFD_Version
; /**< Tag 0x0102 */
35 LPSTR IFD_Serial
; /**< Tag 0x0103 */
36 DWORD IFD_Channel_ID
; /**< Tag 0x0110 */
38 DWORD Asynch_Supported
; /**< Tag 0x0120 */
39 DWORD Default_Clock
; /**< Tag 0x0121 */
40 DWORD Max_Clock
; /**< Tag 0x0122 */
41 DWORD Default_Data_Rate
; /**< Tag 0x0123 */
42 DWORD Max_Data_Rate
; /**< Tag 0x0124 */
43 DWORD Max_IFSD
; /**< Tag 0x0125 */
44 DWORD Synch_Supported
; /**< Tag 0x0126 */
45 DWORD Power_Mgmt
; /**< Tag 0x0131 */
46 DWORD Card_Auth_Devices
; /**< Tag 0x0140 */
47 DWORD User_Auth_Device
; /**< Tag 0x0142 */
48 DWORD Mechanics_Supported
; /**< Tag 0x0150 */
49 DWORD Vendor_Features
; /**< Tag 0x0180 - 0x01F0 User Defined. */
51 DEVICE_CAPABILITIES
, *PDEVICE_CAPABILITIES
;
53 typedef struct _ICC_STATE
55 UCHAR ICC_Presence
; /**< Tag 0x0300 */
56 UCHAR ICC_Interface_Status
; /**< Tag 0x0301 */
57 UCHAR ATR
[MAX_ATR_SIZE
]; /**< Tag 0x0303 */
58 UCHAR ICC_Type
; /**< Tag 0x0304 */
60 ICC_STATE
, *PICC_STATE
;
62 typedef struct _PROTOCOL_OPTIONS
64 DWORD Protocol_Type
; /**< Tag 0x0201 */
65 DWORD Current_Clock
; /**< Tag 0x0202 */
66 DWORD Current_F
; /**< Tag 0x0203 */
67 DWORD Current_D
; /**< Tag 0x0204 */
68 DWORD Current_N
; /**< Tag 0x0205 */
69 DWORD Current_W
; /**< Tag 0x0206 */
70 DWORD Current_IFSC
; /**< Tag 0x0207 */
71 DWORD Current_IFSD
; /**< Tag 0x0208 */
72 DWORD Current_BWT
; /**< Tag 0x0209 */
73 DWORD Current_CWT
; /**< Tag 0x020A */
74 DWORD Current_EBC
; /**< Tag 0x020B */
76 PROTOCOL_OPTIONS
, *PPROTOCOL_OPTIONS
;
78 typedef struct _SCARD_IO_HEADER
83 SCARD_IO_HEADER
, *PSCARD_IO_HEADER
;
86 * End of structure list
90 * The list of tags should be alot more but this is all I use in the
94 #define TAG_IFD_ATR 0x0303
95 #define TAG_IFD_SLOTNUM 0x0180
96 #define TAG_IFD_SLOT_THREAD_SAFE 0x0FAC
97 #define TAG_IFD_THREAD_SAFE 0x0FAD
98 #define TAG_IFD_SLOTS_NUMBER 0x0FAE
99 #define TAG_IFD_SIMULTANEOUS_ACCESS 0x0FAF
100 #define TAG_IFD_POLLING_THREAD 0x0FB0
101 #define TAG_IFD_POLLING_THREAD_KILLABLE 0x0FB1
108 * IFD Handler version number enummerations
110 #define IFD_HVERSION_1_0 0x00010000
111 #define IFD_HVERSION_2_0 0x00020000
112 #define IFD_HVERSION_3_0 0x00030000
114 * End of version number enummerations
118 * List of defines available to ifdhandler
121 #define IFD_POWER_UP 500
122 #define IFD_POWER_DOWN 501
123 #define IFD_RESET 502
125 #define IFD_NEGOTIATE_PTS1 1
126 #define IFD_NEGOTIATE_PTS2 2
127 #define IFD_NEGOTIATE_PTS3 4
129 #define IFD_SUCCESS 0
130 #define IFD_ERROR_TAG 600
131 #define IFD_ERROR_SET_FAILURE 601
132 #define IFD_ERROR_VALUE_READ_ONLY 602
133 #define IFD_ERROR_PTS_FAILURE 605
134 #define IFD_ERROR_NOT_SUPPORTED 606
135 #define IFD_PROTOCOL_NOT_SUPPORTED 607
136 #define IFD_ERROR_POWER_ACTION 608
137 #define IFD_ERROR_SWALLOW 609
138 #define IFD_ERROR_EJECT 610
139 #define IFD_ERROR_CONFISCATE 611
140 #define IFD_COMMUNICATION_ERROR 612
141 #define IFD_RESPONSE_TIMEOUT 613
142 #define IFD_NOT_SUPPORTED 614
143 #define IFD_ICC_PRESENT 615
144 #define IFD_ICC_NOT_PRESENT 616
145 #define IFD_NO_SUCH_DEVICE 617
147 #ifndef RESPONSECODE_DEFINED_IN_WINTYPES_H
148 typedef long RESPONSECODE
;
152 * If you want to compile a V2.0 IFDHandler, define IFDHANDLERv2 before you
155 * By default it is setup for for most recent version of the API (V3.0)
161 * List of Defined Functions Available to IFD_Handler 3.0
163 * All the functions of IFD_Handler 2.0 are available
164 * IFDHCreateChannelByName() is new
165 * IFDHControl() API changed
168 RESPONSECODE
IFDHCreateChannelByName(DWORD
, LPSTR
);
169 RESPONSECODE
IFDHControl(DWORD
, DWORD
, PUCHAR
, DWORD
, PUCHAR
,
174 * List of Defined Functions Available to IFD_Handler 2.0
177 RESPONSECODE
IFDHControl(DWORD
, PUCHAR
, DWORD
, PUCHAR
, PDWORD
);
182 * common functions in IFD_Handler 2.0 and 3.0
184 RESPONSECODE
IFDHCreateChannel(DWORD
, DWORD
);
185 RESPONSECODE
IFDHCloseChannel(DWORD
);
186 RESPONSECODE
IFDHGetCapabilities(DWORD
, DWORD
, PDWORD
, PUCHAR
);
187 RESPONSECODE
IFDHSetCapabilities(DWORD
, DWORD
, DWORD
, PUCHAR
);
188 RESPONSECODE
IFDHSetProtocolParameters(DWORD
, DWORD
, UCHAR
,
189 UCHAR
, UCHAR
, UCHAR
);
190 RESPONSECODE
IFDHPowerICC(DWORD
, DWORD
, PUCHAR
, PDWORD
);
191 RESPONSECODE
IFDHTransmitToICC(DWORD
, SCARD_IO_HEADER
, PUCHAR
,
192 DWORD
, PUCHAR
, PDWORD
, PSCARD_IO_HEADER
);
193 RESPONSECODE
IFDHICCPresence(DWORD
);
196 * List of Defined Functions Available to IFD_Handler 1.0
199 RESPONSECODE
IO_Create_Channel(DWORD
);
200 RESPONSECODE
IO_Close_Channel(void);
201 RESPONSECODE
IFD_Get_Capabilities(DWORD
, PUCHAR
);
202 RESPONSECODE
IFD_Set_Capabilities(DWORD
, PUCHAR
);
203 RESPONSECODE
IFD_Set_Protocol_Parameters(DWORD
, UCHAR
, UCHAR
,
205 RESPONSECODE
IFD_Power_ICC(DWORD
);
206 RESPONSECODE
IFD_Swallow_ICC(void);
207 RESPONSECODE
IFD_Eject_ICC(void);
208 RESPONSECODE
IFD_Confiscate_ICC(void);
209 RESPONSECODE
IFD_Transmit_to_ICC(SCARD_IO_HEADER
, PUCHAR
, DWORD
,
210 PUCHAR
, PDWORD
, PSCARD_IO_HEADER
);
211 RESPONSECODE
IFD_Is_ICC_Present(void);
212 RESPONSECODE
IFD_Is_ICC_Absent(void);