pcsc-lite  1.8.11
ifdwrapper.c
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: ifdwrapper.c 6851 2014-02-14 15:43:32Z rousseau $
38  */
39 
45 #include <errno.h>
46 #include <unistd.h>
47 #include <pthread.h>
48 
49 #include "config.h"
50 #include "misc.h"
51 #include "pcscd.h"
52 #include "debuglog.h"
53 #include "readerfactory.h"
54 #include "ifdwrapper.h"
55 #include "atrhandler.h"
56 #include "dyn_generic.h"
57 #include "sys_generic.h"
58 #include "utils.h"
59 
60 #ifdef PCSCLITE_STATIC_DRIVER
61 /* check that either IFDHANDLERv2 or IFDHANDLERv3 is
62  * defined */
63  #if ! (defined(IFDHANDLERv2) || defined(IFDHANDLERv3))
64  #error IFDHANDLER version not defined
65  #endif
66 #endif
67 
72 LONG IFDSetPTS(READER_CONTEXT * rContext, DWORD dwProtocol, UCHAR ucFlags,
73  UCHAR ucPTS1, UCHAR ucPTS2, UCHAR ucPTS3)
74 {
75  RESPONSECODE rv;
76 
77 #ifndef PCSCLITE_STATIC_DRIVER
78  RESPONSECODE(*IFDH_set_protocol_parameters) (DWORD, DWORD, UCHAR,
79  UCHAR, UCHAR, UCHAR) = NULL;
80 
81  IFDH_set_protocol_parameters = (RESPONSECODE(*)(DWORD, DWORD, UCHAR,
82  UCHAR, UCHAR, UCHAR))
83  rContext->psFunctions.psFunctions_v2.pvfSetProtocolParameters;
84 
85  if (NULL == IFDH_set_protocol_parameters)
87 #endif
88 
89  /*
90  * Locking is done in winscard.c SCardConnect() and SCardReconnect()
91  *
92  * This avoids to renegotiate the protocol and confuse the card
93  * Error returned by CCID driver is: CCID_Receive Procedure byte conflict
94  */
95 
96 #ifndef PCSCLITE_STATIC_DRIVER
97  rv = (*IFDH_set_protocol_parameters) (rContext->slot,
98  dwProtocol, ucFlags, ucPTS1, ucPTS2, ucPTS3);
99 #else
100  rv = IFDHSetProtocolParameters(rContext->slot, dwProtocol, ucFlags,
101  ucPTS1, ucPTS2, ucPTS3);
102 #endif
103 
104  return rv;
105 }
106 
110 LONG IFDOpenIFD(READER_CONTEXT * rContext)
111 {
112  RESPONSECODE rv = 0;
113 
114 #ifndef PCSCLITE_STATIC_DRIVER
115  RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL;
116  RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPSTR) = NULL;
117 
118  if (rContext->version == IFD_HVERSION_2_0)
119  IFDH_create_channel =
120  rContext->psFunctions.psFunctions_v2.pvfCreateChannel;
121  else
122  {
123  IFDH_create_channel =
124  rContext->psFunctions.psFunctions_v3.pvfCreateChannel;
125  IFDH_create_channel_by_name =
126  rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName;
127  }
128 #endif
129 
130  /* LOCK THIS CODE REGION */
131  (void)pthread_mutex_lock(rContext->mMutex);
132 
133 #ifndef PCSCLITE_STATIC_DRIVER
134  if (rContext->version == IFD_HVERSION_2_0)
135  {
136  rv = (*IFDH_create_channel) (rContext->slot, rContext->port);
137  } else
138  {
139  /* use device name only if defined */
140  if (rContext->device[0] != '\0')
141  rv = (*IFDH_create_channel_by_name) (rContext->slot, rContext->device);
142  else
143  rv = (*IFDH_create_channel) (rContext->slot, rContext->port);
144  }
145 #else
146 #if defined(IFDHANDLERv2)
147  rv = IFDHCreateChannel(rContext->slot, rContext->port);
148 #else
149  {
150  /* Use device name only if defined */
151  if (rContext->device[0] != '\0')
152  rv = IFDHCreateChannelByName(rContext->slot, rContext->device);
153  else
154  rv = IFDHCreateChannel(rContext->slot, rContext->port);
155  }
156 #endif
157 #endif
158 
159  /* END OF LOCKED REGION */
160  (void)pthread_mutex_unlock(rContext->mMutex);
161 
162  return rv;
163 }
164 
168 LONG IFDCloseIFD(READER_CONTEXT * rContext)
169 {
170  RESPONSECODE rv;
171  int repeat;
172 
173 #ifndef PCSCLITE_STATIC_DRIVER
174  RESPONSECODE(*IFDH_close_channel) (DWORD) = NULL;
175 
176  IFDH_close_channel = rContext->psFunctions.psFunctions_v2.pvfCloseChannel;
177 #endif
178 
179  /* TRY TO LOCK THIS CODE REGION */
180  repeat = 5;
181 again:
182  rv = pthread_mutex_trylock(rContext->mMutex);
183  if (EBUSY == rv)
184  {
185  Log1(PCSC_LOG_ERROR, "Locking failed");
186  repeat--;
187  if (repeat)
188  {
189  (void)SYS_USleep(100*1000); /* 100 ms */
190  goto again;
191  }
192  }
193 
194 #ifndef PCSCLITE_STATIC_DRIVER
195  rv = (*IFDH_close_channel) (rContext->slot);
196 #else
197  rv = IFDHCloseChannel(rContext->slot);
198 #endif
199 
200  /* END OF LOCKED REGION */
201  (void)pthread_mutex_unlock(rContext->mMutex);
202 
203  return rv;
204 }
205 
209 LONG IFDSetCapabilities(READER_CONTEXT * rContext, DWORD dwTag,
210  DWORD dwLength, PUCHAR pucValue)
211 {
212  RESPONSECODE rv;
213 
214 #ifndef PCSCLITE_STATIC_DRIVER
215  RESPONSECODE(*IFDH_set_capabilities) (DWORD, DWORD, DWORD, PUCHAR) = NULL;
216 
217  IFDH_set_capabilities = rContext->psFunctions.psFunctions_v2.pvfSetCapabilities;
218 #endif
219 
220  /*
221  * Let the calling function lock this otherwise a deadlock will
222  * result
223  */
224 
225 #ifndef PCSCLITE_STATIC_DRIVER
226  rv = (*IFDH_set_capabilities) (rContext->slot, dwTag,
227  dwLength, pucValue);
228 #else
229  rv = IFDHSetCapabilities(rContext->slot, dwTag, dwLength, pucValue);
230 #endif
231 
232  return rv;
233 }
234 
240 LONG IFDGetCapabilities(READER_CONTEXT * rContext, DWORD dwTag,
241  PDWORD pdwLength, PUCHAR pucValue)
242 {
243  RESPONSECODE rv;
244 
245 #ifndef PCSCLITE_STATIC_DRIVER
246  RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, /*@out@*/ PUCHAR) = NULL;
247 
248  IFDH_get_capabilities =
249  rContext->psFunctions.psFunctions_v2.pvfGetCapabilities;
250 #endif
251 
252  /* LOCK THIS CODE REGION */
253  (void)pthread_mutex_lock(rContext->mMutex);
254 
255 #ifndef PCSCLITE_STATIC_DRIVER
256  rv = (*IFDH_get_capabilities) (rContext->slot, dwTag, pdwLength, pucValue);
257 #else
258  rv = IFDHGetCapabilities(rContext->slot, dwTag, pdwLength, pucValue);
259 #endif
260 
261  /* END OF LOCKED REGION */
262  (void)pthread_mutex_unlock(rContext->mMutex);
263 
264  return rv;
265 }
266 
270 LONG IFDPowerICC(READER_CONTEXT * rContext, DWORD dwAction,
271  PUCHAR pucAtr, PDWORD pdwAtrLen)
272 {
273  RESPONSECODE rv;
274  DWORD dwStatus;
275  UCHAR dummyAtr[MAX_ATR_SIZE];
276  DWORD dummyAtrLen = sizeof(dummyAtr);
277 
278 #ifndef PCSCLITE_STATIC_DRIVER
279  RESPONSECODE(*IFDH_power_icc) (DWORD, DWORD, PUCHAR, PDWORD) = NULL;
280 #endif
281 
282  /*
283  * Zero out everything
284  */
285  dwStatus = 0;
286 
287  if (NULL == pucAtr)
288  pucAtr = dummyAtr;
289  if (NULL == pdwAtrLen)
290  pdwAtrLen = &dummyAtrLen;
291 
292  /*
293  * Check that the card is inserted first
294  */
295  rv = IFDStatusICC(rContext, &dwStatus);
296  if (rv != IFD_SUCCESS)
297  {
298  if (rv == IFD_NO_SUCH_DEVICE)
300 
301  return SCARD_E_NOT_TRANSACTED;
302  }
303 
304  if (dwStatus & SCARD_ABSENT)
305  return SCARD_W_REMOVED_CARD;
306 #ifndef PCSCLITE_STATIC_DRIVER
307  IFDH_power_icc = rContext->psFunctions.psFunctions_v2.pvfPowerICC;
308 #endif
309 
310  /* LOCK THIS CODE REGION */
311  (void)pthread_mutex_lock(rContext->mMutex);
312 
313 #ifndef PCSCLITE_STATIC_DRIVER
314  rv = (*IFDH_power_icc) (rContext->slot, dwAction, pucAtr, pdwAtrLen);
315 #else
316  rv = IFDHPowerICC(rContext->slot, dwAction, pucAtr, pdwAtrLen);
317 #endif
318 
319  /* END OF LOCKED REGION */
320  (void)pthread_mutex_unlock(rContext->mMutex);
321 
322  /* use clean values in case of error */
323  if (rv != IFD_SUCCESS)
324  {
325  *pdwAtrLen = 0;
326  pucAtr[0] = '\0';
327 
328  if (rv == IFD_NO_SUCH_DEVICE)
329  {
330  (void)SendHotplugSignal();
332  }
333 
334  return SCARD_E_NOT_TRANSACTED;
335  }
336 
337  return rv;
338 }
339 
344 LONG IFDStatusICC(READER_CONTEXT * rContext, PDWORD pdwStatus)
345 {
346  RESPONSECODE rv;
347  DWORD dwCardStatus = 0;
348 
349 #ifndef PCSCLITE_STATIC_DRIVER
350  RESPONSECODE(*IFDH_icc_presence) (DWORD) = NULL;
351 
352  IFDH_icc_presence = rContext->psFunctions.psFunctions_v2.pvfICCPresence;
353 #endif
354 
355  /* LOCK THIS CODE REGION */
356  (void)pthread_mutex_lock(rContext->mMutex);
357 
358 #ifndef PCSCLITE_STATIC_DRIVER
359  rv = (*IFDH_icc_presence) (rContext->slot);
360 #else
361  rv = IFDHICCPresence(rContext->slot);
362 #endif
363 
364  /* END OF LOCKED REGION */
365  (void)pthread_mutex_unlock(rContext->mMutex);
366 
367  if (rv == IFD_SUCCESS || rv == IFD_ICC_PRESENT)
368  dwCardStatus |= SCARD_PRESENT;
369  else
370  if (rv == IFD_ICC_NOT_PRESENT)
371  dwCardStatus |= SCARD_ABSENT;
372  else
373  {
374  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
375  *pdwStatus = SCARD_UNKNOWN;
376 
377  if (rv == IFD_NO_SUCH_DEVICE)
378  {
379  (void)SendHotplugSignal();
381  }
382 
383  return SCARD_E_NOT_TRANSACTED;
384  }
385 
386  *pdwStatus = dwCardStatus;
387 
388  return SCARD_S_SUCCESS;
389 }
390 
391 /*
392  * Function: IFDControl Purpose : This function provides a means for
393  * toggling a specific action on the reader such as swallow, eject,
394  * biometric.
395  */
396 
397 /*
398  * Valid only for IFDHandler version 2.0
399  */
400 
401 LONG IFDControl_v2(READER_CONTEXT * rContext, PUCHAR TxBuffer,
402  DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength)
403 {
404  RESPONSECODE rv = IFD_SUCCESS;
405 
406 #ifndef PCSCLITE_STATIC_DRIVER
407  RESPONSECODE(*IFDH_control_v2) (DWORD, PUCHAR, DWORD, /*@out@*/ PUCHAR,
408  PDWORD);
409 #endif
410 
411  if (rContext->version != IFD_HVERSION_2_0)
413 
414 #ifndef PCSCLITE_STATIC_DRIVER
415  IFDH_control_v2 = rContext->psFunctions.psFunctions_v2.pvfControl;
416 #endif
417 
418  /* LOCK THIS CODE REGION */
419  (void)pthread_mutex_lock(rContext->mMutex);
420 
421 #ifndef PCSCLITE_STATIC_DRIVER
422  rv = (*IFDH_control_v2) (rContext->slot, TxBuffer, TxLength,
423  RxBuffer, RxLength);
424 #elif defined(IFDHANDLERv2)
425  rv = IFDHControl(rContext->slot, TxBuffer, TxLength,
426  RxBuffer, RxLength);
427 #endif
428 
429  /* END OF LOCKED REGION */
430  (void)pthread_mutex_unlock(rContext->mMutex);
431 
432  if (rv == IFD_SUCCESS)
433  return SCARD_S_SUCCESS;
434  else
435  {
436  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
437  LogXxd(PCSC_LOG_DEBUG, "TxBuffer ", TxBuffer, TxLength);
438  LogXxd(PCSC_LOG_DEBUG, "RxBuffer ", RxBuffer, *RxLength);
439  return SCARD_E_NOT_TRANSACTED;
440  }
441 }
442 
448 /*
449  * Valid only for IFDHandler version 3.0 and up
450  */
451 
452 LONG IFDControl(READER_CONTEXT * rContext, DWORD ControlCode,
453  LPCVOID TxBuffer, DWORD TxLength, LPVOID RxBuffer, DWORD RxLength,
454  LPDWORD BytesReturned)
455 {
456  RESPONSECODE rv = IFD_SUCCESS;
457 
458 #ifndef PCSCLITE_STATIC_DRIVER
459  RESPONSECODE(*IFDH_control) (DWORD, DWORD, LPCVOID, DWORD, LPVOID, DWORD, LPDWORD);
460 #endif
461 
462  if (rContext->version < IFD_HVERSION_3_0)
464 
465 #ifndef PCSCLITE_STATIC_DRIVER
466  IFDH_control = rContext->psFunctions.psFunctions_v3.pvfControl;
467 #endif
468 
469  /* LOCK THIS CODE REGION */
470  (void)pthread_mutex_lock(rContext->mMutex);
471 
472 #ifndef PCSCLITE_STATIC_DRIVER
473  rv = (*IFDH_control) (rContext->slot, ControlCode, TxBuffer,
474  TxLength, RxBuffer, RxLength, BytesReturned);
475 #elif defined(IFDHANDLERv3)
476  rv = IFDHControl(rContext->slot, ControlCode, TxBuffer,
477  TxLength, RxBuffer, RxLength, BytesReturned);
478 #endif
479 
480  /* END OF LOCKED REGION */
481  (void)pthread_mutex_unlock(rContext->mMutex);
482 
483  if (rv == IFD_SUCCESS)
484  return SCARD_S_SUCCESS;
485  else
486  {
487  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
488  Log3(PCSC_LOG_DEBUG, "ControlCode: 0x%.8lX BytesReturned: %ld",
489  ControlCode, *BytesReturned);
490  LogXxd(PCSC_LOG_DEBUG, "TxBuffer ", TxBuffer, TxLength);
491  LogXxd(PCSC_LOG_DEBUG, "RxBuffer ", RxBuffer, *BytesReturned);
492 
493  if (rv == IFD_NO_SUCH_DEVICE)
494  {
495  (void)SendHotplugSignal();
497  }
498 
499  if ((IFD_ERROR_NOT_SUPPORTED == rv) || (IFD_NOT_SUPPORTED == rv))
501 
504 
505  return SCARD_E_NOT_TRANSACTED;
506  }
507 }
508 
512 LONG IFDTransmit(READER_CONTEXT * rContext, SCARD_IO_HEADER pioTxPci,
513  PUCHAR pucTxBuffer, DWORD dwTxLength, PUCHAR pucRxBuffer,
514  PDWORD pdwRxLength, PSCARD_IO_HEADER pioRxPci)
515 {
516  RESPONSECODE rv;
517 
518 #ifndef PCSCLITE_STATIC_DRIVER
519  RESPONSECODE(*IFDH_transmit_to_icc) (DWORD, SCARD_IO_HEADER, PUCHAR,
520  DWORD, /*@out@*/ PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
521 #endif
522 
523  /* log the APDU */
524  DebugLogCategory(DEBUG_CATEGORY_APDU, pucTxBuffer, dwTxLength);
525 
526 #ifndef PCSCLITE_STATIC_DRIVER
527  IFDH_transmit_to_icc =
528  rContext->psFunctions.psFunctions_v2.pvfTransmitToICC;
529 #endif
530 
531  /* LOCK THIS CODE REGION */
532  (void)pthread_mutex_lock(rContext->mMutex);
533 
534 #ifndef PCSCLITE_STATIC_DRIVER
535  rv = (*IFDH_transmit_to_icc) (rContext->slot, pioTxPci, (LPBYTE)
536  pucTxBuffer, dwTxLength, pucRxBuffer, pdwRxLength, pioRxPci);
537 #else
538  rv = IFDHTransmitToICC(rContext->slot, pioTxPci,
539  (LPBYTE) pucTxBuffer, dwTxLength,
540  pucRxBuffer, pdwRxLength, pioRxPci);
541 #endif
542 
543  /* END OF LOCKED REGION */
544  (void)pthread_mutex_unlock(rContext->mMutex);
545 
546  /* log the returned status word */
547  DebugLogCategory(DEBUG_CATEGORY_SW, pucRxBuffer, *pdwRxLength);
548 
549  if (rv == IFD_SUCCESS)
550  return SCARD_S_SUCCESS;
551  else
552  {
553  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
554 
555  if (rv == IFD_NO_SUCH_DEVICE)
556  {
557  (void)SendHotplugSignal();
559  }
560 
561  return SCARD_E_NOT_TRANSACTED;
562  }
563 }
564 
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.
LONG IFDStatusICC(READER_CONTEXT *rContext, PDWORD pdwStatus)
Provide statistical information about the IFD and ICC including insertions, atr, powering status/etc...
Definition: ifdwrapper.c:344
This abstracts dynamic library loading functions.
#define IFD_NO_SUCH_DEVICE
The IFD_NO_SUCH_DEVICE error must be returned by the driver when it detects the reader is no more pre...
Definition: ifdhandler.h:375
int port
Port ID.
LONG IFDSetPTS(READER_CONTEXT *rContext, DWORD dwProtocol, UCHAR ucFlags, UCHAR ucPTS1, UCHAR ucPTS2, UCHAR ucPTS3)
Set the protocol type selection (PTS).
Definition: ifdwrapper.c:72
#define IFD_NOT_SUPPORTED
request is not supported
Definition: ifdhandler.h:367
#define SCARD_E_READER_UNAVAILABLE
The specified reader is not currently available for use.
Definition: pcsclite.h:129
FCT_MAP_V2 psFunctions_v2
API V2.0.
LONG IFDGetCapabilities(READER_CONTEXT *rContext, DWORD dwTag, PDWORD pdwLength, PUCHAR pucValue)
Get's capabilities in the reader.
Definition: ifdwrapper.c:240
#define SCARD_UNKNOWN
Unknown state.
Definition: pcsclite.h:194
RESPONSECODE IFDHCloseChannel(DWORD Lun)
This function should close the reader communication channel for the particular reader.
#define SCARD_E_NOT_TRANSACTED
An attempt was made to end a non-existent transaction.
Definition: pcsclite.h:128
RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel)
This function is required to open a communications channel to the port listed by Channel.
This handles abstract system level calls.
int slot
Current Reader Slot.
union ReaderContext::@3 psFunctions
driver functions
This wraps the dynamic ifdhandler functions.
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 ...
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()
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...
#define SCARD_PRESENT
Card is present.
Definition: pcsclite.h:196
int SYS_USleep(int)
Makes the current process sleep for some microseconds.
Definition: sys_unix.c:88
RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName)
This function is required to open a communications channel to the port listed by DeviceName.
#define IFD_ICC_PRESENT
card is present
Definition: ifdhandler.h:368
This keeps track of smart card protocols, timing issues and Answer to Reset ATR handling.
FCT_MAP_V3 psFunctions_v3
API V3.0.
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...
LONG IFDTransmit(READER_CONTEXT *rContext, SCARD_IO_HEADER pioTxPci, PUCHAR pucTxBuffer, DWORD dwTxLength, PUCHAR pucRxBuffer, PDWORD pdwRxLength, PSCARD_IO_HEADER pioRxPci)
Transmit an APDU to the ICC.
Definition: ifdwrapper.c:512
int version
IFD Handler version number.
pthread_mutex_t * mMutex
Mutex for this connection.
LONG IFDSetCapabilities(READER_CONTEXT *rContext, DWORD dwTag, DWORD dwLength, PUCHAR pucValue)
Set capabilities in the reader.
Definition: ifdwrapper.c:209
LONG IFDCloseIFD(READER_CONTEXT *rContext)
Close a communication channel to the IFD.
Definition: ifdwrapper.c:168
#define SCARD_W_REMOVED_CARD
The smart card has been removed, so further communication is not possible.
Definition: pcsclite.h:162
#define SCARD_E_UNSUPPORTED_FEATURE
This smart card does not support the requested feature.
Definition: pcsclite.h:138
LONG IFDPowerICC(READER_CONTEXT *rContext, DWORD dwAction, PUCHAR pucAtr, PDWORD pdwAtrLen)
Power up/down or reset's an ICC located in the IFD.
Definition: ifdwrapper.c:270
LONG IFDOpenIFD(READER_CONTEXT *rContext)
Open a communication channel to the IFD.
Definition: ifdwrapper.c:110
This keeps a list of defines for pcsc-lite.
#define SCARD_ABSENT
Card is absent.
Definition: pcsclite.h:195
char * device
Device Name.
RESPONSECODE IFDHICCPresence(DWORD Lun)
This function returns the status of the card inserted in the reader/slot specified by Lun...
This keeps track of a list of currently available reader structures.
#define MAX_ATR_SIZE
Maximum ATR size.
Definition: pcsclite.h:64
#define IFD_ERROR_INSUFFICIENT_BUFFER
buffer is too small
Definition: ifdhandler.h:376
#define SCARD_E_INSUFFICIENT_BUFFER
The data buffer to receive returned data is too small for the returned data.
Definition: pcsclite.h:114
#define IFD_ICC_NOT_PRESENT
card is absent
Definition: ifdhandler.h:369
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
#define SCARD_S_SUCCESS
error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx
Definition: pcsclite.h:106
This handles debugging.
#define IFD_SUCCESS
no error
Definition: ifdhandler.h:354
LONG IFDControl(READER_CONTEXT *rContext, DWORD ControlCode, LPCVOID TxBuffer, DWORD TxLength, LPVOID RxBuffer, DWORD RxLength, LPDWORD BytesReturned)
Provide a means for toggling a specific action on the reader such as swallow, eject, biometric.
Definition: ifdwrapper.c:452