/** * Open a communication channel to the IFD. */ LONG IFDOpenIFD(READER_CONTEXT * rContext) { RESPONSECODE rv = 0; #ifndef PCSCLITE_STATIC_DRIVER RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL; RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPSTR) = NULL; if (rContext->version == IFD_HVERSION_2_0) IFDH_create_channel = rContext->psFunctions.psFunctions_v2.pvfCreateChannel; else { IFDH_create_channel = rContext->psFunctions.psFunctions_v3.pvfCreateChannel; IFDH_create_channel_by_name = rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName; } #endif /* LOCK THIS CODE REGION */ (void)pthread_mutex_lock(rContext->mMutex); #ifndef PCSCLITE_STATIC_DRIVER if (rContext->version == IFD_HVERSION_2_0) { rv = (*IFDH_create_channel) (rContext->slot, rContext->port); } else { /* use device name only if defined */ if (rContext->device[0] != '\0') rv = (*IFDH_create_channel_by_name) (rContext->slot, rContext->device); else rv = (*IFDH_create_channel) (rContext->slot, rContext->port); } #else #if defined(IFDHANDLERv2) rv = IFDHCreateChannel(rContext->slot, rContext->port); #else { /* Use device name only if defined */ if (rContext->device[0] != '\0') rv = IFDHCreateChannelByName(rContext->slot, rContext->device); else rv = IFDHCreateChannel(rContext->slot, rContext->port); } #endif #endif /* END OF LOCKED REGION */ (void)pthread_mutex_unlock(rContext->mMutex); return rv; }
static void initialize_globals(void) { uint32_t index; DWORD Channel = VPCDPORT; const char *hostname_old = hostname; hostname = VPCDHOST; for (index = 0; index < PCSCLITE_MAX_READERS_CONTEXTS && index < vicc_max_slots; index++) { IFDHCreateChannel ((DWORD) index, Channel); } hostname = hostname_old; }
RESPONSECODE IFDHCreateChannelByName (DWORD Lun, LPSTR DeviceName) { RESPONSECODE r = IFD_NOT_SUPPORTED; char *dots; char _hostname[MAX_READERNAME]; size_t hostname_len; unsigned long int port = VPCDPORT; dots = strchr(DeviceName, ':'); if (dots) { /* a port has been specified behind the device name */ hostname_len = dots - DeviceName; if (strlen(openport) != hostname_len || strncmp(DeviceName, openport, hostname_len) != 0) { /* a hostname other than /dev/null has been specified, * so we connect initialize hostname to connect to vicc */ if (hostname_len < sizeof _hostname) memcpy(_hostname, DeviceName, hostname_len); else { Log3(PCSC_LOG_ERROR, "Not enough memory to hold hostname (have %u, need %u)", sizeof _hostname, hostname_len); goto err; } _hostname[hostname_len] = '\0'; hostname = _hostname; } /* skip the ':' */ dots++; errno = 0; port = strtoul(dots, NULL, 0); if (errno) { Log2(PCSC_LOG_ERROR, "Could not parse port: %s", dots); goto err; } } else { Log1(PCSC_LOG_INFO, "Using default port."); } r = IFDHCreateChannel (Lun, port); err: /* set hostname back to default in case it has been changed */ hostname = NULL; return r; }
/** * Open a communication channel to the IFD. */ LONG IFDOpenIFD(PREADER_CONTEXT rContext) { RESPONSECODE rv = 0; #ifndef PCSCLITE_STATIC_DRIVER RESPONSECODE(*IO_create_channel) (DWORD) = NULL; RESPONSECODE(*IFDH_create_channel) (DWORD, DWORD) = NULL; RESPONSECODE(*IFDH_create_channel_by_name) (DWORD, LPSTR) = NULL; if (rContext->dwVersion == IFD_HVERSION_1_0) IO_create_channel = rContext->psFunctions.psFunctions_v1.pvfCreateChannel; else if (rContext->dwVersion == IFD_HVERSION_2_0) IFDH_create_channel = rContext->psFunctions.psFunctions_v2.pvfCreateChannel; else { IFDH_create_channel = rContext->psFunctions.psFunctions_v3.pvfCreateChannel; IFDH_create_channel_by_name = rContext->psFunctions.psFunctions_v3.pvfCreateChannelByName; } #endif /* LOCK THIS CODE REGION */ (void)SYS_MutexLock(rContext->mMutex); #ifndef PCSCLITE_STATIC_DRIVER if (rContext->dwVersion == IFD_HVERSION_1_0) { rv = (*IO_create_channel) (rContext->dwPort); } else if (rContext->dwVersion == IFD_HVERSION_2_0) { rv = (*IFDH_create_channel) (rContext->dwSlot, rContext->dwPort); } else { /* use device name only if defined */ if (rContext->lpcDevice[0] != '\0') rv = (*IFDH_create_channel_by_name) (rContext->dwSlot, rContext->lpcDevice); else rv = (*IFDH_create_channel) (rContext->dwSlot, rContext->dwPort); } #else if (rContext->dwVersion == IFD_HVERSION_1_0) { rv = IO_Create_Channel(rContext->dwPort); } else if (rContext->dwVersion == IFD_HVERSION_2_0) { rv = IFDHCreateChannel(rContext->dwSlot, rContext->dwPort); } else { /* Use device name only if defined */ if (rContext->lpcDevice[0] != '\0') rv = IFDHCreateChannelByName(rContext->dwSlot, rContext->lpcDevice); else rv = IFDHCreateChannel(rContext->dwSlot, rContext->dwPort); } #endif /* END OF LOCKED REGION */ (void)SYS_MutexUnLock(rContext->mMutex); return rv; }
RESPONSECODE IFDHCreateChannelByName ( DWORD Lun, LPSTR DeviceName ) { return IFDHCreateChannel(Lun, 0); }
RESPONSECODE IFDHCreateChannelByName (DWORD Lun, LPSTR DeviceName) { Log3(PCSC_LOG_INFO, "Not opening %s. Using default port %hu", DeviceName, VPCDPORT); return IFDHCreateChannel (Lun, VPCDPORT); }