pcsc-lite  1.8.13
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 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id: ifdwrapper.c 7004 2014-10-02 09:26:36Z rousseau $
35  */
36 
42 #include <errno.h>
43 #include <unistd.h>
44 #include <pthread.h>
45 
46 #include "config.h"
47 #include "misc.h"
48 #include "pcscd.h"
49 #include "debuglog.h"
50 #include "readerfactory.h"
51 #include "ifdwrapper.h"
52 #include "atrhandler.h"
53 #include "dyn_generic.h"
54 #include "sys_generic.h"
55 #include "utils.h"
56 
57 #ifdef PCSCLITE_STATIC_DRIVER
58 /* check that either IFDHANDLERv2 or IFDHANDLERv3 is
59  * defined */
60  #if ! (defined(IFDHANDLERv2) || defined(IFDHANDLERv3))
61  #error IFDHANDLER version not defined
62  #endif
63 #endif
64 
69 LONG IFDSetPTS(READER_CONTEXT * rContext, DWORD dwProtocol, UCHAR ucFlags,
70  UCHAR ucPTS1, UCHAR ucPTS2, UCHAR ucPTS3)
71 {
72  RESPONSECODE rv;
73 
74 #ifndef PCSCLITE_STATIC_DRIVER
75  RESPONSECODE(*IFDH_set_protocol_parameters) (DWORD, DWORD, UCHAR,
76  UCHAR, UCHAR, UCHAR) = NULL;
77 
78  IFDH_set_protocol_parameters = (RESPONSECODE(*)(DWORD, DWORD, UCHAR,
79  UCHAR, UCHAR, UCHAR))
80  rContext->psFunctions.psFunctions_v2.pvfSetProtocolParameters;
81 
82  if (NULL == IFDH_set_protocol_parameters)
84 #endif
85 
86  /*
87  * Locking is done in winscard.c SCardConnect() and SCardReconnect()
88  *
89  * This avoids to renegotiate the protocol and confuse the card
90  * Error returned by CCID driver is: CCID_Receive Procedure byte conflict
91  */
92 
93 #ifndef PCSCLITE_STATIC_DRIVER
94  rv = (*IFDH_set_protocol_parameters) (rContext->slot,
95  dwProtocol, ucFlags, ucPTS1, ucPTS2, ucPTS3);
96 #else
97  rv = IFDHSetProtocolParameters(rContext->slot, dwProtocol, ucFlags,
98  ucPTS1, ucPTS2, ucPTS3);
99 #endif
100 
101  return rv;
102 }
103 
107 LONG IFDOpenIFD(READER_CONTEXT * rContext)
108 {
109  RESPONSECODE rv = 0;
110 
111 #ifndef PCSCLITE_STATIC_DRIVER
112  RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL;
113  RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPSTR) = NULL;
114 
115  if (rContext->version == IFD_HVERSION_2_0)
116  IFDH_create_channel =
117  rContext->psFunctions.psFunctions_v2.pvfCreateChannel;
118  else
119  {
120  IFDH_create_channel =
121  rContext->psFunctions.psFunctions_v3.pvfCreateChannel;
122  IFDH_create_channel_by_name =
123  rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName;
124  }
125 #endif
126 
127  /* LOCK THIS CODE REGION */
128  (void)pthread_mutex_lock(rContext->mMutex);
129 
130 #ifndef PCSCLITE_STATIC_DRIVER
131  if (rContext->version == IFD_HVERSION_2_0)
132  {
133  rv = (*IFDH_create_channel) (rContext->slot, rContext->port);
134  } else
135  {
136  /* use device name only if defined */
137  if (rContext->device[0] != '\0')
138  rv = (*IFDH_create_channel_by_name) (rContext->slot, rContext->device);
139  else
140  rv = (*IFDH_create_channel) (rContext->slot, rContext->port);
141  }
142 #else
143 #if defined(IFDHANDLERv2)
144  rv = IFDHCreateChannel(rContext->slot, rContext->port);
145 #else
146  {
147  /* Use device name only if defined */
148  if (rContext->device[0] != '\0')
149  rv = IFDHCreateChannelByName(rContext->slot, rContext->device);
150  else
151  rv = IFDHCreateChannel(rContext->slot, rContext->port);
152  }
153 #endif
154 #endif
155 
156  /* END OF LOCKED REGION */
157  (void)pthread_mutex_unlock(rContext->mMutex);
158 
159  return rv;
160 }
161 
165 LONG IFDCloseIFD(READER_CONTEXT * rContext)
166 {
167  RESPONSECODE rv;
168  int repeat;
169 
170 #ifndef PCSCLITE_STATIC_DRIVER
171  RESPONSECODE(*IFDH_close_channel) (DWORD) = NULL;
172 
173  IFDH_close_channel = rContext->psFunctions.psFunctions_v2.pvfCloseChannel;
174 #endif
175 
176  /* TRY TO LOCK THIS CODE REGION */
177  repeat = 5;
178 again:
179  rv = pthread_mutex_trylock(rContext->mMutex);
180  if (EBUSY == rv)
181  {
182  Log1(PCSC_LOG_ERROR, "Locking failed");
183  repeat--;
184  if (repeat)
185  {
186  (void)SYS_USleep(100*1000); /* 100 ms */
187  goto again;
188  }
189  }
190 
191 #ifndef PCSCLITE_STATIC_DRIVER
192  rv = (*IFDH_close_channel) (rContext->slot);
193 #else
194  rv = IFDHCloseChannel(rContext->slot);
195 #endif
196 
197  /* END OF LOCKED REGION */
198  (void)pthread_mutex_unlock(rContext->mMutex);
199 
200  return rv;
201 }
202 
206 LONG IFDSetCapabilities(READER_CONTEXT * rContext, DWORD dwTag,
207  DWORD dwLength, PUCHAR pucValue)
208 {
209  RESPONSECODE rv;
210 
211 #ifndef PCSCLITE_STATIC_DRIVER
212  RESPONSECODE(*IFDH_set_capabilities) (DWORD, DWORD, DWORD, PUCHAR) = NULL;
213 
214  IFDH_set_capabilities = rContext->psFunctions.psFunctions_v2.pvfSetCapabilities;
215 #endif
216 
217  /*
218  * Let the calling function lock this otherwise a deadlock will
219  * result
220  */
221 
222 #ifndef PCSCLITE_STATIC_DRIVER
223  rv = (*IFDH_set_capabilities) (rContext->slot, dwTag,
224  dwLength, pucValue);
225 #else
226  rv = IFDHSetCapabilities(rContext->slot, dwTag, dwLength, pucValue);
227 #endif
228 
229  return rv;
230 }
231 
237 LONG IFDGetCapabilities(READER_CONTEXT * rContext, DWORD dwTag,
238  PDWORD pdwLength, PUCHAR pucValue)
239 {
240  RESPONSECODE rv;
241 
242 #ifndef PCSCLITE_STATIC_DRIVER
243  RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, /*@out@*/ PUCHAR) = NULL;
244 
245  IFDH_get_capabilities =
246  rContext->psFunctions.psFunctions_v2.pvfGetCapabilities;
247 #endif
248 
249  /* LOCK THIS CODE REGION */
250  (void)pthread_mutex_lock(rContext->mMutex);
251 
252 #ifndef PCSCLITE_STATIC_DRIVER
253  rv = (*IFDH_get_capabilities) (rContext->slot, dwTag, pdwLength, pucValue);
254 #else
255  rv = IFDHGetCapabilities(rContext->slot, dwTag, pdwLength, pucValue);
256 #endif
257 
258  /* END OF LOCKED REGION */
259  (void)pthread_mutex_unlock(rContext->mMutex);
260 
261  return rv;
262 }
263 
267 LONG IFDPowerICC(READER_CONTEXT * rContext, DWORD dwAction,
268  PUCHAR pucAtr, PDWORD pdwAtrLen)
269 {
270  RESPONSECODE rv;
271  DWORD dwStatus;
272  UCHAR dummyAtr[MAX_ATR_SIZE];
273  DWORD dummyAtrLen = sizeof(dummyAtr);
274 
275 #ifndef PCSCLITE_STATIC_DRIVER
276  RESPONSECODE(*IFDH_power_icc) (DWORD, DWORD, PUCHAR, PDWORD) = NULL;
277 #endif
278 
279  /*
280  * Zero out everything
281  */
282  dwStatus = 0;
283 
284  if (NULL == pucAtr)
285  pucAtr = dummyAtr;
286  if (NULL == pdwAtrLen)
287  pdwAtrLen = &dummyAtrLen;
288 
289  /*
290  * Check that the card is inserted first
291  */
292  rv = IFDStatusICC(rContext, &dwStatus);
293  if (rv != IFD_SUCCESS)
294  {
295  if (rv == IFD_NO_SUCH_DEVICE)
297 
298  return SCARD_E_NOT_TRANSACTED;
299  }
300 
301  if (dwStatus & SCARD_ABSENT)
302  return SCARD_W_REMOVED_CARD;
303 #ifndef PCSCLITE_STATIC_DRIVER
304  IFDH_power_icc = rContext->psFunctions.psFunctions_v2.pvfPowerICC;
305 #endif
306 
307  /* LOCK THIS CODE REGION */
308  (void)pthread_mutex_lock(rContext->mMutex);
309 
310 #ifndef PCSCLITE_STATIC_DRIVER
311  rv = (*IFDH_power_icc) (rContext->slot, dwAction, pucAtr, pdwAtrLen);
312 #else
313  rv = IFDHPowerICC(rContext->slot, dwAction, pucAtr, pdwAtrLen);
314 #endif
315 
316  /* END OF LOCKED REGION */
317  (void)pthread_mutex_unlock(rContext->mMutex);
318 
319  /* use clean values in case of error */
320  if (rv != IFD_SUCCESS)
321  {
322  *pdwAtrLen = 0;
323  pucAtr[0] = '\0';
324 
325  if (rv == IFD_NO_SUCH_DEVICE)
326  {
327  (void)SendHotplugSignal();
329  }
330 
331  return SCARD_E_NOT_TRANSACTED;
332  }
333 
334  return rv;
335 }
336 
341 LONG IFDStatusICC(READER_CONTEXT * rContext, PDWORD pdwStatus)
342 {
343  RESPONSECODE rv;
344  DWORD dwCardStatus = 0;
345 
346 #ifndef PCSCLITE_STATIC_DRIVER
347  RESPONSECODE(*IFDH_icc_presence) (DWORD) = NULL;
348 
349  IFDH_icc_presence = rContext->psFunctions.psFunctions_v2.pvfICCPresence;
350 #endif
351 
352  /* LOCK THIS CODE REGION */
353  (void)pthread_mutex_lock(rContext->mMutex);
354 
355 #ifndef PCSCLITE_STATIC_DRIVER
356  rv = (*IFDH_icc_presence) (rContext->slot);
357 #else
358  rv = IFDHICCPresence(rContext->slot);
359 #endif
360 
361  /* END OF LOCKED REGION */
362  (void)pthread_mutex_unlock(rContext->mMutex);
363 
364  if (rv == IFD_SUCCESS || rv == IFD_ICC_PRESENT)
365  dwCardStatus |= SCARD_PRESENT;
366  else
367  if (rv == IFD_ICC_NOT_PRESENT)
368  dwCardStatus |= SCARD_ABSENT;
369  else
370  {
371  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
372  *pdwStatus = SCARD_UNKNOWN;
373 
374  if (rv == IFD_NO_SUCH_DEVICE)
375  {
376  (void)SendHotplugSignal();
378  }
379 
380  return SCARD_E_NOT_TRANSACTED;
381  }
382 
383  *pdwStatus = dwCardStatus;
384 
385  return SCARD_S_SUCCESS;
386 }
387 
388 /*
389  * Function: IFDControl Purpose : This function provides a means for
390  * toggling a specific action on the reader such as swallow, eject,
391  * biometric.
392  */
393 
394 /*
395  * Valid only for IFDHandler version 2.0
396  */
397 
398 LONG IFDControl_v2(READER_CONTEXT * rContext, PUCHAR TxBuffer,
399  DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength)
400 {
401  RESPONSECODE rv = IFD_SUCCESS;
402 
403 #ifndef PCSCLITE_STATIC_DRIVER
404  RESPONSECODE(*IFDH_control_v2) (DWORD, PUCHAR, DWORD, /*@out@*/ PUCHAR,
405  PDWORD);
406 #endif
407 
408  if (rContext->version != IFD_HVERSION_2_0)
410 
411 #ifndef PCSCLITE_STATIC_DRIVER
412  IFDH_control_v2 = rContext->psFunctions.psFunctions_v2.pvfControl;
413 #endif
414 
415  /* LOCK THIS CODE REGION */
416  (void)pthread_mutex_lock(rContext->mMutex);
417 
418 #ifndef PCSCLITE_STATIC_DRIVER
419  rv = (*IFDH_control_v2) (rContext->slot, TxBuffer, TxLength,
420  RxBuffer, RxLength);
421 #elif defined(IFDHANDLERv2)
422  rv = IFDHControl(rContext->slot, TxBuffer, TxLength,
423  RxBuffer, RxLength);
424 #endif
425 
426  /* END OF LOCKED REGION */
427  (void)pthread_mutex_unlock(rContext->mMutex);
428 
429  if (rv == IFD_SUCCESS)
430  return SCARD_S_SUCCESS;
431  else
432  {
433  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
434  LogXxd(PCSC_LOG_DEBUG, "TxBuffer ", TxBuffer, TxLength);
435  LogXxd(PCSC_LOG_DEBUG, "RxBuffer ", RxBuffer, *RxLength);
436  return SCARD_E_NOT_TRANSACTED;
437  }
438 }
439 
445 /*
446  * Valid only for IFDHandler version 3.0 and up
447  */
448 
449 LONG IFDControl(READER_CONTEXT * rContext, DWORD ControlCode,
450  LPCVOID TxBuffer, DWORD TxLength, LPVOID RxBuffer, DWORD RxLength,
451  LPDWORD BytesReturned)
452 {
453  RESPONSECODE rv = IFD_SUCCESS;
454 
455 #ifndef PCSCLITE_STATIC_DRIVER
456  RESPONSECODE(*IFDH_control) (DWORD, DWORD, LPCVOID, DWORD, LPVOID, DWORD, LPDWORD);
457 #endif
458 
459  if (rContext->version < IFD_HVERSION_3_0)
461 
462 #ifndef PCSCLITE_STATIC_DRIVER
463  IFDH_control = rContext->psFunctions.psFunctions_v3.pvfControl;
464 #endif
465 
466  /* LOCK THIS CODE REGION */
467  (void)pthread_mutex_lock(rContext->mMutex);
468 
469 #ifndef PCSCLITE_STATIC_DRIVER
470  rv = (*IFDH_control) (rContext->slot, ControlCode, TxBuffer,
471  TxLength, RxBuffer, RxLength, BytesReturned);
472 #elif defined(IFDHANDLERv3)
473  rv = IFDHControl(rContext->slot, ControlCode, TxBuffer,
474  TxLength, RxBuffer, RxLength, BytesReturned);
475 #endif
476 
477  /* END OF LOCKED REGION */
478  (void)pthread_mutex_unlock(rContext->mMutex);
479 
480  if (rv == IFD_SUCCESS)
481  return SCARD_S_SUCCESS;
482  else
483  {
484  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
485  Log3(PCSC_LOG_DEBUG, "ControlCode: 0x%.8lX BytesReturned: %ld",
486  ControlCode, *BytesReturned);
487  LogXxd(PCSC_LOG_DEBUG, "TxBuffer ", TxBuffer, TxLength);
488  LogXxd(PCSC_LOG_DEBUG, "RxBuffer ", RxBuffer, *BytesReturned);
489 
490  if (rv == IFD_NO_SUCH_DEVICE)
491  {
492  (void)SendHotplugSignal();
494  }
495 
496  if ((IFD_ERROR_NOT_SUPPORTED == rv) || (IFD_NOT_SUPPORTED == rv))
498 
501 
502  return SCARD_E_NOT_TRANSACTED;
503  }
504 }
505 
509 LONG IFDTransmit(READER_CONTEXT * rContext, SCARD_IO_HEADER pioTxPci,
510  PUCHAR pucTxBuffer, DWORD dwTxLength, PUCHAR pucRxBuffer,
511  PDWORD pdwRxLength, PSCARD_IO_HEADER pioRxPci)
512 {
513  RESPONSECODE rv;
514 
515 #ifndef PCSCLITE_STATIC_DRIVER
516  RESPONSECODE(*IFDH_transmit_to_icc) (DWORD, SCARD_IO_HEADER, PUCHAR,
517  DWORD, /*@out@*/ PUCHAR, PDWORD, PSCARD_IO_HEADER) = NULL;
518 #endif
519 
520  /* log the APDU */
521  DebugLogCategory(DEBUG_CATEGORY_APDU, pucTxBuffer, dwTxLength);
522 
523 #ifndef PCSCLITE_STATIC_DRIVER
524  IFDH_transmit_to_icc =
525  rContext->psFunctions.psFunctions_v2.pvfTransmitToICC;
526 #endif
527 
528  /* LOCK THIS CODE REGION */
529  (void)pthread_mutex_lock(rContext->mMutex);
530 
531 #ifndef PCSCLITE_STATIC_DRIVER
532  rv = (*IFDH_transmit_to_icc) (rContext->slot, pioTxPci, (LPBYTE)
533  pucTxBuffer, dwTxLength, pucRxBuffer, pdwRxLength, pioRxPci);
534 #else
535  rv = IFDHTransmitToICC(rContext->slot, pioTxPci,
536  (LPBYTE) pucTxBuffer, dwTxLength,
537  pucRxBuffer, pdwRxLength, pioRxPci);
538 #endif
539 
540  /* END OF LOCKED REGION */
541  (void)pthread_mutex_unlock(rContext->mMutex);
542 
543  /* log the returned status word */
544  DebugLogCategory(DEBUG_CATEGORY_SW, pucRxBuffer, *pdwRxLength);
545 
546  if (rv == IFD_SUCCESS)
547  return SCARD_S_SUCCESS;
548  else
549  {
550  Log2(PCSC_LOG_ERROR, "Card not transacted: %ld", rv);
551 
552  if (rv == IFD_NO_SUCH_DEVICE)
553  {
554  (void)SendHotplugSignal();
556  }
557 
558  return SCARD_E_NOT_TRANSACTED;
559  }
560 }
561 
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:341
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:372
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:69
#define IFD_NOT_SUPPORTED
request is not supported
Definition: ifdhandler.h:364
#define SCARD_E_READER_UNAVAILABLE
The specified reader is not currently available for use.
Definition: pcsclite.h:126
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:237
#define SCARD_UNKNOWN
Unknown state.
Definition: pcsclite.h:191
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:125
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:193
int SYS_USleep(int)
Makes the current process sleep for some microseconds.
Definition: sys_unix.c:85
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:365
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:509
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:206
LONG IFDCloseIFD(READER_CONTEXT *rContext)
Close a communication channel to the IFD.
Definition: ifdwrapper.c:165
#define SCARD_W_REMOVED_CARD
The smart card has been removed, so further communication is not possible.
Definition: pcsclite.h:159
#define SCARD_E_UNSUPPORTED_FEATURE
This smart card does not support the requested feature.
Definition: pcsclite.h:135
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:267
LONG IFDOpenIFD(READER_CONTEXT *rContext)
Open a communication channel to the IFD.
Definition: ifdwrapper.c:107
This keeps a list of defines for pcsc-lite.
#define SCARD_ABSENT
Card is absent.
Definition: pcsclite.h:192
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:61
#define IFD_ERROR_INSUFFICIENT_BUFFER
buffer is too small
Definition: ifdhandler.h:373
#define SCARD_E_INSUFFICIENT_BUFFER
The data buffer to receive returned data is too small for the returned data.
Definition: pcsclite.h:111
#define IFD_ICC_NOT_PRESENT
card is absent
Definition: ifdhandler.h:366
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:311
#define SCARD_S_SUCCESS
error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx
Definition: pcsclite.h:103
This handles debugging.
#define IFD_SUCCESS
no error
Definition: ifdhandler.h:351
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:449