57 #ifdef PCSCLITE_STATIC_DRIVER
60 #if ! (defined(IFDHANDLERv2) || defined(IFDHANDLERv3))
61 #error IFDHANDLER version not defined
70 UCHAR ucPTS1, UCHAR ucPTS2, UCHAR ucPTS3)
74 #ifndef PCSCLITE_STATIC_DRIVER
75 RESPONSECODE(*IFDH_set_protocol_parameters) (DWORD, DWORD, UCHAR,
76 UCHAR, UCHAR, UCHAR) = NULL;
78 IFDH_set_protocol_parameters = (RESPONSECODE(*)(DWORD, DWORD, UCHAR,
82 if (NULL == IFDH_set_protocol_parameters)
93 #ifndef PCSCLITE_STATIC_DRIVER
94 rv = (*IFDH_set_protocol_parameters) (rContext->
slot,
95 dwProtocol, ucFlags, ucPTS1, ucPTS2, ucPTS3);
98 ucPTS1, ucPTS2, ucPTS3);
111 #ifndef PCSCLITE_STATIC_DRIVER
112 RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL;
113 RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPSTR) = NULL;
115 if (rContext->
version == IFD_HVERSION_2_0)
116 IFDH_create_channel =
120 IFDH_create_channel =
122 IFDH_create_channel_by_name =
128 (void)pthread_mutex_lock(rContext->
mMutex);
130 #ifndef PCSCLITE_STATIC_DRIVER
131 if (rContext->
version == IFD_HVERSION_2_0)
133 rv = (*IFDH_create_channel) (rContext->
slot, rContext->
port);
137 if (rContext->
device[0] !=
'\0')
138 rv = (*IFDH_create_channel_by_name) (rContext->
slot, rContext->
device);
140 rv = (*IFDH_create_channel) (rContext->
slot, rContext->
port);
143 #if defined(IFDHANDLERv2)
148 if (rContext->
device[0] !=
'\0')
157 (void)pthread_mutex_unlock(rContext->
mMutex);
170 #ifndef PCSCLITE_STATIC_DRIVER
171 RESPONSECODE(*IFDH_close_channel) (DWORD) = NULL;
179 rv = pthread_mutex_trylock(rContext->
mMutex);
182 Log1(PCSC_LOG_ERROR,
"Locking failed");
191 #ifndef PCSCLITE_STATIC_DRIVER
192 rv = (*IFDH_close_channel) (rContext->
slot);
198 (void)pthread_mutex_unlock(rContext->
mMutex);
207 DWORD dwLength, PUCHAR pucValue)
211 #ifndef PCSCLITE_STATIC_DRIVER
212 RESPONSECODE(*IFDH_set_capabilities) (DWORD, DWORD, DWORD, PUCHAR) = NULL;
222 #ifndef PCSCLITE_STATIC_DRIVER
223 rv = (*IFDH_set_capabilities) (rContext->
slot, dwTag,
238 PDWORD pdwLength, PUCHAR pucValue)
242 #ifndef PCSCLITE_STATIC_DRIVER
243 RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, PUCHAR) = NULL;
245 IFDH_get_capabilities =
250 (void)pthread_mutex_lock(rContext->
mMutex);
252 #ifndef PCSCLITE_STATIC_DRIVER
253 rv = (*IFDH_get_capabilities) (rContext->
slot, dwTag, pdwLength, pucValue);
259 (void)pthread_mutex_unlock(rContext->
mMutex);
268 PUCHAR pucAtr, PDWORD pdwAtrLen)
273 DWORD dummyAtrLen =
sizeof(dummyAtr);
275 #ifndef PCSCLITE_STATIC_DRIVER
276 RESPONSECODE(*IFDH_power_icc) (DWORD, DWORD, PUCHAR, PDWORD) = NULL;
286 if (NULL == pdwAtrLen)
287 pdwAtrLen = &dummyAtrLen;
303 #ifndef PCSCLITE_STATIC_DRIVER
308 (void)pthread_mutex_lock(rContext->
mMutex);
310 #ifndef PCSCLITE_STATIC_DRIVER
311 rv = (*IFDH_power_icc) (rContext->
slot, dwAction, pucAtr, pdwAtrLen);
317 (void)pthread_mutex_unlock(rContext->
mMutex);
327 (void)SendHotplugSignal();
344 DWORD dwCardStatus = 0;
346 #ifndef PCSCLITE_STATIC_DRIVER
347 RESPONSECODE(*IFDH_icc_presence) (DWORD) = NULL;
353 (void)pthread_mutex_lock(rContext->
mMutex);
355 #ifndef PCSCLITE_STATIC_DRIVER
356 rv = (*IFDH_icc_presence) (rContext->
slot);
362 (void)pthread_mutex_unlock(rContext->
mMutex);
371 Log2(PCSC_LOG_ERROR,
"Card not transacted: %ld", rv);
376 (void)SendHotplugSignal();
383 *pdwStatus = dwCardStatus;
399 DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength)
403 #ifndef PCSCLITE_STATIC_DRIVER
404 RESPONSECODE(*IFDH_control_v2) (DWORD, PUCHAR, DWORD, PUCHAR,
408 if (rContext->
version != IFD_HVERSION_2_0)
411 #ifndef PCSCLITE_STATIC_DRIVER
416 (void)pthread_mutex_lock(rContext->
mMutex);
418 #ifndef PCSCLITE_STATIC_DRIVER
419 rv = (*IFDH_control_v2) (rContext->
slot, TxBuffer, TxLength,
421 #elif defined(IFDHANDLERv2)
427 (void)pthread_mutex_unlock(rContext->
mMutex);
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);
450 LPCVOID TxBuffer, DWORD TxLength, LPVOID RxBuffer, DWORD RxLength,
451 LPDWORD BytesReturned)
455 #ifndef PCSCLITE_STATIC_DRIVER
456 RESPONSECODE(*IFDH_control) (DWORD, DWORD, LPCVOID, DWORD, LPVOID, DWORD, LPDWORD);
459 if (rContext->
version < IFD_HVERSION_3_0)
462 #ifndef PCSCLITE_STATIC_DRIVER
467 (void)pthread_mutex_lock(rContext->
mMutex);
469 #ifndef PCSCLITE_STATIC_DRIVER
470 rv = (*IFDH_control) (rContext->
slot, ControlCode, TxBuffer,
471 TxLength, RxBuffer, RxLength, BytesReturned);
472 #elif defined(IFDHANDLERv3)
474 TxLength, RxBuffer, RxLength, BytesReturned);
478 (void)pthread_mutex_unlock(rContext->
mMutex);
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);
492 (void)SendHotplugSignal();
510 PUCHAR pucTxBuffer, DWORD dwTxLength, PUCHAR pucRxBuffer,
515 #ifndef PCSCLITE_STATIC_DRIVER
521 DebugLogCategory(DEBUG_CATEGORY_APDU, pucTxBuffer, dwTxLength);
523 #ifndef PCSCLITE_STATIC_DRIVER
524 IFDH_transmit_to_icc =
529 (void)pthread_mutex_lock(rContext->
mMutex);
531 #ifndef PCSCLITE_STATIC_DRIVER
532 rv = (*IFDH_transmit_to_icc) (rContext->
slot, pioTxPci, (LPBYTE)
533 pucTxBuffer, dwTxLength, pucRxBuffer, pdwRxLength, pioRxPci);
536 (LPBYTE) pucTxBuffer, dwTxLength,
537 pucRxBuffer, pdwRxLength, pioRxPci);
541 (void)pthread_mutex_unlock(rContext->
mMutex);
544 DebugLogCategory(DEBUG_CATEGORY_SW, pucRxBuffer, *pdwRxLength);
550 Log2(PCSC_LOG_ERROR,
"Card not transacted: %ld", rv);
554 (void)SendHotplugSignal();
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...
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...
LONG IFDSetPTS(READER_CONTEXT *rContext, DWORD dwProtocol, UCHAR ucFlags, UCHAR ucPTS1, UCHAR ucPTS2, UCHAR ucPTS3)
Set the protocol type selection (PTS).
#define IFD_NOT_SUPPORTED
request is not supported
#define SCARD_E_READER_UNAVAILABLE
The specified reader is not currently available for use.
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.
#define SCARD_UNKNOWN
Unknown state.
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.
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.
int SYS_USleep(int)
Makes the current process sleep for some microseconds.
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
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.
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.
LONG IFDCloseIFD(READER_CONTEXT *rContext)
Close a communication channel to the IFD.
#define SCARD_W_REMOVED_CARD
The smart card has been removed, so further communication is not possible.
#define SCARD_E_UNSUPPORTED_FEATURE
This smart card does not support the requested feature.
LONG IFDPowerICC(READER_CONTEXT *rContext, DWORD dwAction, PUCHAR pucAtr, PDWORD pdwAtrLen)
Power up/down or reset's an ICC located in the IFD.
LONG IFDOpenIFD(READER_CONTEXT *rContext)
Open a communication channel to the IFD.
This keeps a list of defines for pcsc-lite.
#define SCARD_ABSENT
Card is absent.
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.
#define IFD_ERROR_INSUFFICIENT_BUFFER
buffer is too small
#define SCARD_E_INSUFFICIENT_BUFFER
The data buffer to receive returned data is too small for the returned data.
#define IFD_ICC_NOT_PRESENT
card is absent
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_S_SUCCESS
error codes from http://msdn.microsoft.com/en-us/library/aa924526.aspx
#define IFD_SUCCESS
no error
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.