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