/** * Get's capabilities in the reader. * Other functions int this file will call * the driver directly to not cause a deadlock. */ LONG IFDGetCapabilities(READER_CONTEXT * rContext, DWORD dwTag, PDWORD pdwLength, PUCHAR pucValue) { RESPONSECODE rv; #ifndef PCSCLITE_STATIC_DRIVER RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, /*@out@*/ PUCHAR) = NULL; IFDH_get_capabilities = rContext->psFunctions.psFunctions_v2.pvfGetCapabilities; #endif /* LOCK THIS CODE REGION */ (void)pthread_mutex_lock(rContext->mMutex); #ifndef PCSCLITE_STATIC_DRIVER rv = (*IFDH_get_capabilities) (rContext->slot, dwTag, pdwLength, pucValue); #else rv = IFDHGetCapabilities(rContext->slot, dwTag, pdwLength, pucValue); #endif /* END OF LOCKED REGION */ (void)pthread_mutex_unlock(rContext->mMutex); return rv; }
RESPONSECODE IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength) { switch (Action) { case IFD_POWER_DOWN: if (vicc_poweroff() < 0) { Log1(PCSC_LOG_ERROR, "could not powerdown"); return IFD_COMMUNICATION_ERROR; } /* XXX see bug #312754 on https://alioth.debian.org/projects/pcsclite */ #if 0 *AtrLength = 0; #endif return IFD_SUCCESS; case IFD_POWER_UP: if (vicc_poweron() < 0) { Log1(PCSC_LOG_ERROR, "could not powerup"); return IFD_COMMUNICATION_ERROR; } break; case IFD_RESET: if (vicc_reset() < 0) { Log1(PCSC_LOG_ERROR, "could not reset"); return IFD_COMMUNICATION_ERROR; } break; default: Log2(PCSC_LOG_ERROR, "%0lX not supported", Action); return IFD_NOT_SUPPORTED; } return IFDHGetCapabilities (Lun, TAG_IFD_ATR, AtrLength, Atr); }
RESPONSECODE IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength) { size_t slot = Lun & 0xffff; RESPONSECODE r = IFD_COMMUNICATION_ERROR; if (slot >= vicc_max_slots) { goto err; } switch (Action) { case IFD_POWER_DOWN: if (vicc_poweroff(ctx[slot]) < 0) { Log1(PCSC_LOG_ERROR, "could not powerdown"); goto err; } /* XXX see bug #312754 on https://alioth.debian.org/projects/pcsclite */ #if 0 *AtrLength = 0; #endif return IFD_SUCCESS; case IFD_POWER_UP: if (vicc_poweron(ctx[slot]) < 0) { Log1(PCSC_LOG_ERROR, "could not powerup"); goto err; } break; case IFD_RESET: if (vicc_reset(ctx[slot]) < 0) { Log1(PCSC_LOG_ERROR, "could not reset"); goto err; } break; default: Log2(PCSC_LOG_ERROR, "%0lX not supported", Action); r = IFD_NOT_SUPPORTED; goto err; } r = IFD_SUCCESS; err: if (r != IFD_SUCCESS && AtrLength) *AtrLength = 0; else r = IFDHGetCapabilities (Lun, TAG_IFD_ATR, AtrLength, Atr); return r; }
/** * Get's capabilities in the reader. * Other functions int this file will call * the driver directly to not cause a deadlock. */ LONG IFDGetCapabilities(PREADER_CONTEXT rContext, DWORD dwTag, PDWORD pdwLength, PUCHAR pucValue) { RESPONSECODE rv = IFD_SUCCESS; #ifndef PCSCLITE_STATIC_DRIVER RESPONSECODE(*IFD_get_capabilities) (DWORD, /*@out@*/ PUCHAR) = NULL; RESPONSECODE(*IFDH_get_capabilities) (DWORD, DWORD, PDWORD, /*@out@*/ PUCHAR) = NULL; if (rContext->dwVersion == IFD_HVERSION_1_0) IFD_get_capabilities = rContext->psFunctions.psFunctions_v1.pvfGetCapabilities; else IFDH_get_capabilities = rContext->psFunctions.psFunctions_v2.pvfGetCapabilities; #endif /* LOCK THIS CODE REGION */ (void)SYS_MutexLock(rContext->mMutex); #ifndef PCSCLITE_STATIC_DRIVER if (rContext->dwVersion == IFD_HVERSION_1_0) rv = (*IFD_get_capabilities) (dwTag, pucValue); else rv = (*IFDH_get_capabilities) (rContext->dwSlot, dwTag, pdwLength, pucValue); #else if (rContext->dwVersion == IFD_HVERSION_1_0) rv = IFD_Get_Capabilities(dwTag, pucValue); else rv = IFDHGetCapabilities(rContext->dwSlot, dwTag, pdwLength, pucValue); #endif /* END OF LOCKED REGION */ (void)SYS_MutexUnLock(rContext->mMutex); return rv; }
static LONG handle2atr(DWORD Lun, LPBYTE pbAtr, LPDWORD pcbAtrLen) { LONG r; void *atr; unsigned char _atr[MAX_ATR_SIZE]; SET_R_TEST( responsecode2long( IFDHICCPresence(Lun))); SET_R_TEST( autoallocate(pbAtr, pcbAtrLen, MAX_ATR_SIZE, (void **) &atr)); if (!atr) { /* caller wants to have the length */ *pcbAtrLen = sizeof _atr; atr = _atr; } SET_R_TEST( responsecode2long( IFDHGetCapabilities (Lun, TAG_IFD_ATR, pcbAtrLen, atr))); err: return r; }