pcsc-lite  1.8.11
ifdhandler.h
Go to the documentation of this file.
1 /*
2  * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
3  *
4  * Copyright (C) 1999-2004
5  * David Corcoran <corcoran@musclecard.com>
6  * Copyright (C) 2003-2004
7  * Damien Sauveron <damien.sauveron@labri.fr>
8  * Copyright (C) 2002-2011
9  * Ludovic Rousseau <ludovic.rousseau@free.fr>
10  *
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14 
15 1. Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 3. The name of the author may not be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 Changes to this license can be made only by the copyright author with
24 explicit written consent.
25 
26 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id: ifdhandler.h 6851 2014-02-14 15:43:32Z rousseau $
38  */
39 
255 #ifndef _ifd_handler_h_
256 #define _ifd_handler_h_
257 
258 #include <pcsclite.h>
259 
260  /*
261  * List of data structures available to ifdhandler
262  */
263  typedef struct _DEVICE_CAPABILITIES
264  {
265  LPSTR Vendor_Name;
266  LPSTR IFD_Type;
267  DWORD IFD_Version;
268  LPSTR IFD_Serial;
273  DWORD Max_Clock;
276  DWORD Max_IFSD;
278  DWORD Power_Mgmt;
283  }
285 
286  typedef struct _ICC_STATE
287  {
288  UCHAR ICC_Presence;
290  UCHAR ATR[MAX_ATR_SIZE];
291  UCHAR ICC_Type;
292  }
294 
295  typedef struct _PROTOCOL_OPTIONS
296  {
299  DWORD Current_F;
300  DWORD Current_D;
301  DWORD Current_N;
302  DWORD Current_W;
303  DWORD Current_IFSC;
304  DWORD Current_IFSD;
305  DWORD Current_BWT;
306  DWORD Current_CWT;
307  DWORD Current_EBC;
308  }
310 
314  typedef struct _SCARD_IO_HEADER
315  {
316  DWORD Protocol;
317  DWORD Length;
318  }
320 
321  /*
322  * The list of tags should be alot more but this is all I use in the
323  * meantime
324  */
325 #define TAG_IFD_ATR 0x0303
326 #define TAG_IFD_SLOTNUM 0x0180
327 #define TAG_IFD_SLOT_THREAD_SAFE 0x0FAC
328 #define TAG_IFD_THREAD_SAFE 0x0FAD
329 #define TAG_IFD_SLOTS_NUMBER 0x0FAE
330 #define TAG_IFD_SIMULTANEOUS_ACCESS 0x0FAF
331 #define TAG_IFD_POLLING_THREAD 0x0FB0
332 #define TAG_IFD_POLLING_THREAD_KILLABLE 0x0FB1
333 #define TAG_IFD_STOP_POLLING_THREAD 0x0FB2
334 #define TAG_IFD_POLLING_THREAD_WITH_TIMEOUT 0x0FB3
336  /*
337  * IFD Handler version number enummerations
338  */
339 #define IFD_HVERSION_1_0 0x00010000
340 #define IFD_HVERSION_2_0 0x00020000
341 #define IFD_HVERSION_3_0 0x00030000
342 
343  /*
344  * List of defines available to ifdhandler
345  */
346 #define IFD_POWER_UP 500
347 #define IFD_POWER_DOWN 501
348 #define IFD_RESET 502
350 #define IFD_NEGOTIATE_PTS1 1
351 #define IFD_NEGOTIATE_PTS2 2
352 #define IFD_NEGOTIATE_PTS3 4
354 #define IFD_SUCCESS 0
355 #define IFD_ERROR_TAG 600
356 #define IFD_ERROR_SET_FAILURE 601
357 #define IFD_ERROR_VALUE_READ_ONLY 602
358 #define IFD_ERROR_PTS_FAILURE 605
359 #define IFD_ERROR_NOT_SUPPORTED 606
360 #define IFD_PROTOCOL_NOT_SUPPORTED 607
361 #define IFD_ERROR_POWER_ACTION 608
362 #define IFD_ERROR_SWALLOW 609
363 #define IFD_ERROR_EJECT 610
364 #define IFD_ERROR_CONFISCATE 611
365 #define IFD_COMMUNICATION_ERROR 612
366 #define IFD_RESPONSE_TIMEOUT 613
367 #define IFD_NOT_SUPPORTED 614
368 #define IFD_ICC_PRESENT 615
369 #define IFD_ICC_NOT_PRESENT 616
375 #define IFD_NO_SUCH_DEVICE 617
376 #define IFD_ERROR_INSUFFICIENT_BUFFER 618
378 #ifndef RESPONSECODE_DEFINED_IN_WINTYPES_H
379  typedef long RESPONSECODE;
380 #endif
381 
382  /*
383  * If you want to compile a V2.0 IFDHandler, define IFDHANDLERv2
384  * before you include this file.
385  *
386  * By default it is setup for for most recent version of the API (V3.0)
387  */
388 
389 #ifndef IFDHANDLERv2
390 
391  /*
392  * List of Defined Functions Available to IFD_Handler 3.0
393  *
394  * All the functions of IFD_Handler 2.0 are available
395  * IFDHCreateChannelByName() is new
396  * IFDHControl() API changed
397  */
398 
489 RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName);
490 
522 RESPONSECODE IFDHControl(DWORD Lun, DWORD dwControlCode, PUCHAR
523  TxBuffer, DWORD TxLength, PUCHAR RxBuffer, DWORD RxLength,
524  LPDWORD pdwBytesReturned);
525 
526 #else
527 
534 RESPONSECODE IFDHControl(DWORD Lun, PUCHAR TxBuffer, DWORD TxLength,
535  PUCHAR RxBuffer, PDWORD RxLength);
536 
537 #endif
538 
539  /*
540  * common functions in IFD_Handler 2.0 and 3.0
541  */
583 RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel);
584 
599 RESPONSECODE IFDHCloseChannel(DWORD Lun);
600 
658 RESPONSECODE IFDHGetCapabilities(DWORD Lun, DWORD Tag, PDWORD Length,
659  PUCHAR Value);
660 
682 RESPONSECODE IFDHSetCapabilities(DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value);
683 
713 RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol, UCHAR Flags,
714  UCHAR PTS1, UCHAR PTS2, UCHAR PTS3);
747 RESPONSECODE IFDHPowerICC(DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD
748  AtrLength);
749 
801 RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci,
802  PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD
803  RxLength, PSCARD_IO_HEADER RecvPci);
804 
821 RESPONSECODE IFDHICCPresence(DWORD Lun);
822 
823 #endif
DWORD Card_Auth_Devices
Tag 0x0140.
Definition: ifdhandler.h:279
RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength, PSCARD_IO_HEADER RecvPci)
This function performs an APDU exchange with the card/slot specified by Lun.
DWORD Default_Data_Rate
Tag 0x0123.
Definition: ifdhandler.h:274
DWORD Max_Data_Rate
Tag 0x0124.
Definition: ifdhandler.h:275
UCHAR ATR[MAX_ATR_SIZE]
Tag 0x0303.
Definition: ifdhandler.h:290
UCHAR ICC_Interface_Status
Tag 0x0301.
Definition: ifdhandler.h:289
DWORD Max_Clock
Tag 0x0122.
Definition: ifdhandler.h:273
DWORD Default_Clock
Tag 0x0121.
Definition: ifdhandler.h:272
DWORD Current_D
Tag 0x0204.
Definition: ifdhandler.h:300
DWORD Current_BWT
Tag 0x0209.
Definition: ifdhandler.h:305
RESPONSECODE IFDHCloseChannel(DWORD Lun)
This function should close the reader communication channel for the particular reader.
RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel)
This function is required to open a communications channel to the port listed by Channel.
DWORD Current_CWT
Tag 0x020A.
Definition: ifdhandler.h:306
RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol, UCHAR Flags, UCHAR PTS1, UCHAR PTS2, UCHAR PTS3)
This function should set the Protocol Type Selection (PTS) of a particular card/slot using the three ...
DWORD Protocol_Type
Tag 0x0201.
Definition: ifdhandler.h:297
UCHAR ICC_Presence
Tag 0x0300.
Definition: ifdhandler.h:288
RESPONSECODE IFDHPowerICC(DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength)
This function controls the power and reset signals of the smart card reader at the particular reader/...
struct _SCARD_IO_HEADER SCARD_IO_HEADER
Use by SCardTransmit()
DWORD Current_IFSC
Tag 0x0207.
Definition: ifdhandler.h:303
RESPONSECODE IFDHGetCapabilities(DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value)
This function should get the slot/card capabilities for a particular slot/card specified by Lun...
DWORD Current_IFSD
Tag 0x0208.
Definition: ifdhandler.h:304
DWORD User_Auth_Device
Tag 0x0142.
Definition: ifdhandler.h:280
DWORD Mechanics_Supported
Tag 0x0150.
Definition: ifdhandler.h:281
RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName)
This function is required to open a communications channel to the port listed by DeviceName.
LPSTR IFD_Type
Tag 0x0101.
Definition: ifdhandler.h:266
RESPONSECODE IFDHControl(DWORD Lun, DWORD dwControlCode, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, DWORD RxLength, LPDWORD pdwBytesReturned)
This function performs a data exchange with the reader (not the card) specified by Lun...
DWORD IFD_Version
Tag 0x0102.
Definition: ifdhandler.h:267
DWORD Power_Mgmt
Tag 0x0131.
Definition: ifdhandler.h:278
DWORD IFD_Channel_ID
Tag 0x0110.
Definition: ifdhandler.h:269
DWORD Synch_Supported
Tag 0x0126.
Definition: ifdhandler.h:277
This keeps a list of defines for pcsc-lite.
DWORD Max_IFSD
Tag 0x0125.
Definition: ifdhandler.h:276
DWORD Vendor_Features
Tag 0x0180 - 0x01F0 User Defined.
Definition: ifdhandler.h:282
LPSTR Vendor_Name
Tag 0x0100.
Definition: ifdhandler.h:265
DWORD Current_N
Tag 0x0205.
Definition: ifdhandler.h:301
DWORD Current_F
Tag 0x0203.
Definition: ifdhandler.h:299
DWORD Current_Clock
Tag 0x0202.
Definition: ifdhandler.h:298
RESPONSECODE IFDHICCPresence(DWORD Lun)
This function returns the status of the card inserted in the reader/slot specified by Lun...
#define MAX_ATR_SIZE
Maximum ATR size.
Definition: pcsclite.h:64
DWORD Current_W
Tag 0x0206.
Definition: ifdhandler.h:302
RESPONSECODE IFDHSetCapabilities(DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value)
This function should set the slot/card capabilities for a particular slot/card specified by Lun...
Use by SCardTransmit()
Definition: ifdhandler.h:314
DWORD Current_EBC
Tag 0x020B.
Definition: ifdhandler.h:307
DWORD Asynch_Supported
Tag 0x0120.
Definition: ifdhandler.h:271
UCHAR ICC_Type
Tag 0x0304.
Definition: ifdhandler.h:291
LPSTR IFD_Serial
Tag 0x0103.
Definition: ifdhandler.h:268