pcsc-lite
1.7.4
|
00001 /* 00002 * MUSCLE SmartCard Development ( http://www.linuxnet.com ) 00003 * 00004 * Copyright (C) 1999-2004 00005 * David Corcoran <corcoran@linuxnet.com> 00006 * Copyright (C) 2003-2004 00007 * Damien Sauveron <damien.sauveron@labri.fr> 00008 * Copyright (C) 2002-2011 00009 * Ludovic Rousseau <ludovic.rousseau@free.fr> 00010 * 00011 * $Id: ifdhandler.h 5714 2011-05-05 09:26:47Z rousseau $ 00012 */ 00013 00229 #ifndef _ifd_handler_h_ 00230 #define _ifd_handler_h_ 00231 00232 #include <pcsclite.h> 00233 00234 /* 00235 * List of data structures available to ifdhandler 00236 */ 00237 typedef struct _DEVICE_CAPABILITIES 00238 { 00239 LPSTR Vendor_Name; 00240 LPSTR IFD_Type; 00241 DWORD IFD_Version; 00242 LPSTR IFD_Serial; 00243 DWORD IFD_Channel_ID; 00245 DWORD Asynch_Supported; 00246 DWORD Default_Clock; 00247 DWORD Max_Clock; 00248 DWORD Default_Data_Rate; 00249 DWORD Max_Data_Rate; 00250 DWORD Max_IFSD; 00251 DWORD Synch_Supported; 00252 DWORD Power_Mgmt; 00253 DWORD Card_Auth_Devices; 00254 DWORD User_Auth_Device; 00255 DWORD Mechanics_Supported; 00256 DWORD Vendor_Features; 00257 } 00258 DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; 00259 00260 typedef struct _ICC_STATE 00261 { 00262 UCHAR ICC_Presence; 00263 UCHAR ICC_Interface_Status; 00264 UCHAR ATR[MAX_ATR_SIZE]; 00265 UCHAR ICC_Type; 00266 } 00267 ICC_STATE, *PICC_STATE; 00268 00269 typedef struct _PROTOCOL_OPTIONS 00270 { 00271 DWORD Protocol_Type; 00272 DWORD Current_Clock; 00273 DWORD Current_F; 00274 DWORD Current_D; 00275 DWORD Current_N; 00276 DWORD Current_W; 00277 DWORD Current_IFSC; 00278 DWORD Current_IFSD; 00279 DWORD Current_BWT; 00280 DWORD Current_CWT; 00281 DWORD Current_EBC; 00282 } 00283 PROTOCOL_OPTIONS, *PPROTOCOL_OPTIONS; 00284 00288 typedef struct _SCARD_IO_HEADER 00289 { 00290 DWORD Protocol; 00291 DWORD Length; 00292 } 00293 SCARD_IO_HEADER, *PSCARD_IO_HEADER; 00294 00295 /* 00296 * The list of tags should be alot more but this is all I use in the 00297 * meantime 00298 */ 00299 #define TAG_IFD_ATR 0x0303 00300 #define TAG_IFD_SLOTNUM 0x0180 00301 #define TAG_IFD_SLOT_THREAD_SAFE 0x0FAC 00302 #define TAG_IFD_THREAD_SAFE 0x0FAD 00303 #define TAG_IFD_SLOTS_NUMBER 0x0FAE 00304 #define TAG_IFD_SIMULTANEOUS_ACCESS 0x0FAF 00305 #define TAG_IFD_POLLING_THREAD 0x0FB0 00306 #define TAG_IFD_POLLING_THREAD_KILLABLE 0x0FB1 00307 #define TAG_IFD_STOP_POLLING_THREAD 0x0FB2 00308 #define TAG_IFD_POLLING_THREAD_WITH_TIMEOUT 0x0FB3 00310 /* 00311 * IFD Handler version number enummerations 00312 */ 00313 #define IFD_HVERSION_1_0 0x00010000 00314 #define IFD_HVERSION_2_0 0x00020000 00315 #define IFD_HVERSION_3_0 0x00030000 00316 00317 /* 00318 * List of defines available to ifdhandler 00319 */ 00320 #define IFD_POWER_UP 500 00321 #define IFD_POWER_DOWN 501 00322 #define IFD_RESET 502 00324 #define IFD_NEGOTIATE_PTS1 1 00325 #define IFD_NEGOTIATE_PTS2 2 00326 #define IFD_NEGOTIATE_PTS3 4 00328 #define IFD_SUCCESS 0 00329 #define IFD_ERROR_TAG 600 00330 #define IFD_ERROR_SET_FAILURE 601 00331 #define IFD_ERROR_VALUE_READ_ONLY 602 00332 #define IFD_ERROR_PTS_FAILURE 605 00333 #define IFD_ERROR_NOT_SUPPORTED 606 00334 #define IFD_PROTOCOL_NOT_SUPPORTED 607 00335 #define IFD_ERROR_POWER_ACTION 608 00336 #define IFD_ERROR_SWALLOW 609 00337 #define IFD_ERROR_EJECT 610 00338 #define IFD_ERROR_CONFISCATE 611 00339 #define IFD_COMMUNICATION_ERROR 612 00340 #define IFD_RESPONSE_TIMEOUT 613 00341 #define IFD_NOT_SUPPORTED 614 00342 #define IFD_ICC_PRESENT 615 00343 #define IFD_ICC_NOT_PRESENT 616 00349 #define IFD_NO_SUCH_DEVICE 617 00350 #define IFD_ERROR_INSUFFICIENT_BUFFER 618 00352 #ifndef RESPONSECODE_DEFINED_IN_WINTYPES_H 00353 typedef long RESPONSECODE; 00354 #endif 00355 00356 /* 00357 * If you want to compile a V2.0 IFDHandler, define IFDHANDLERv2 00358 * before you include this file. 00359 * 00360 * By default it is setup for for most recent version of the API (V3.0) 00361 */ 00362 00363 #ifndef IFDHANDLERv2 00364 00365 /* 00366 * List of Defined Functions Available to IFD_Handler 3.0 00367 * 00368 * All the functions of IFD_Handler 2.0 are available 00369 * IFDHCreateChannelByName() is new 00370 * IFDHControl() API changed 00371 */ 00372 00464 RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName); 00465 00497 RESPONSECODE IFDHControl(DWORD Lun, DWORD dwControlCode, PUCHAR 00498 TxBuffer, DWORD TxLength, PUCHAR RxBuffer, DWORD RxLength, 00499 LPDWORD pdwBytesReturned); 00500 00501 #else 00502 00509 RESPONSECODE IFDHControl(DWORD Lun, PUCHAR TxBuffer, DWORD TxLength, 00510 PUCHAR RxBuffer, PDWORD RxLength); 00511 00512 #endif 00513 00514 /* 00515 * common functions in IFD_Handler 2.0 and 3.0 00516 */ 00558 RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel); 00559 00574 RESPONSECODE IFDHCloseChannel(DWORD Lun); 00575 00618 RESPONSECODE IFDHGetCapabilities(DWORD Lun, DWORD Tag, PDWORD Length, 00619 PUCHAR Value); 00620 00642 RESPONSECODE IFDHSetCapabilities(DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value); 00643 00673 RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol, UCHAR Flags, 00674 UCHAR PTS1, UCHAR PTS2, UCHAR PTS3); 00707 RESPONSECODE IFDHPowerICC(DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD 00708 AtrLength); 00709 00761 RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci, 00762 PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD 00763 RxLength, PSCARD_IO_HEADER RecvPci); 00764 00781 RESPONSECODE IFDHICCPresence(DWORD Lun); 00782 00783 #endif