ifdhandler.h

Go to the documentation of this file.
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-2009
00009  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
00010  *
00011  * $Id: ifdhandler.h 5031 2010-06-22 11:37:00Z rousseau $
00012  */
00013 
00224 #ifndef _ifd_handler_h_
00225 #define _ifd_handler_h_
00226 
00227 #include <pcsclite.h>
00228 
00229 #ifdef __cplusplus
00230 extern "C"
00231 {
00232 #endif
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  
00309     /*
00310      * IFD Handler version number enummerations
00311      */
00312 #define IFD_HVERSION_1_0               0x00010000
00313 #define IFD_HVERSION_2_0               0x00020000
00314 #define IFD_HVERSION_3_0               0x00030000
00315 
00316     /*
00317      * List of defines available to ifdhandler
00318      */
00319 #define IFD_POWER_UP            500 
00320 #define IFD_POWER_DOWN          501 
00321 #define IFD_RESET           502 
00323 #define IFD_NEGOTIATE_PTS1      1   
00324 #define IFD_NEGOTIATE_PTS2      2   
00325 #define IFD_NEGOTIATE_PTS3              4   
00327 #define IFD_SUCCESS         0   
00328 #define IFD_ERROR_TAG           600 
00329 #define IFD_ERROR_SET_FAILURE       601 
00330 #define IFD_ERROR_VALUE_READ_ONLY   602 
00331 #define IFD_ERROR_PTS_FAILURE       605 
00332 #define IFD_ERROR_NOT_SUPPORTED     606
00333 #define IFD_PROTOCOL_NOT_SUPPORTED  607 
00334 #define IFD_ERROR_POWER_ACTION      608 
00335 #define IFD_ERROR_SWALLOW       609
00336 #define IFD_ERROR_EJECT         610
00337 #define IFD_ERROR_CONFISCATE        611
00338 #define IFD_COMMUNICATION_ERROR     612 
00339 #define IFD_RESPONSE_TIMEOUT        613 
00340 #define IFD_NOT_SUPPORTED       614 
00341 #define IFD_ICC_PRESENT         615 
00342 #define IFD_ICC_NOT_PRESENT     616 
00348 #define IFD_NO_SUCH_DEVICE      617
00349 #define IFD_ERROR_INSUFFICIENT_BUFFER   618 
00351 #ifndef RESPONSECODE_DEFINED_IN_WINTYPES_H
00352     typedef long RESPONSECODE;
00353 #endif
00354 
00355     /*
00356      * If you want to compile a V2.0 IFDHandler, define IFDHANDLERv2
00357      * before you include this file.
00358      *
00359      * By default it is setup for for most recent version of the API (V3.0)
00360      */
00361 
00362 #ifndef IFDHANDLERv2
00363 
00364     /*
00365      * List of Defined Functions Available to IFD_Handler 3.0
00366      *
00367      * All the functions of IFD_Handler 2.0 are available
00368      * IFDHCreateChannelByName() is new
00369      * IFDHControl() API changed
00370      */
00371 
00459 RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName);
00460 
00492 RESPONSECODE IFDHControl(DWORD Lun, DWORD dwControlCode, PUCHAR
00493     TxBuffer, DWORD TxLength, PUCHAR RxBuffer, DWORD RxLength,
00494     LPDWORD pdwBytesReturned);
00495 
00496 #else
00497 
00504 RESPONSECODE IFDHControl(DWORD Lun, PUCHAR TxBuffer, DWORD TxLength,
00505     PUCHAR RxBuffer, PDWORD RxLength);
00506 
00507 #endif
00508 
00509     /*
00510      * common functions in IFD_Handler 2.0 and 3.0
00511      */
00553 RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel);
00554 
00569 RESPONSECODE IFDHCloseChannel(DWORD Lun);
00570 
00613 RESPONSECODE IFDHGetCapabilities(DWORD Lun, DWORD Tag, PDWORD Length,
00614     PUCHAR Value);
00615 
00641 RESPONSECODE IFDHSetCapabilities(DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value);
00642 
00672 RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol, UCHAR Flags,
00673     UCHAR PTS1, UCHAR PTS2, UCHAR PTS3);
00706 RESPONSECODE IFDHPowerICC(DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD
00707     AtrLength);
00708 
00760 RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci,
00761     PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD
00762     RxLength, PSCARD_IO_HEADER RecvPci);
00763 
00780 RESPONSECODE IFDHICCPresence(DWORD Lun);
00781 
00782 #ifdef __cplusplus
00783 }
00784 #endif
00785 
00786 #endif