adapted to changes of fb4dbe59ba
This commit is contained in:
@@ -33,19 +33,26 @@ unsigned int vpcdport = VPCDPORT;
|
|||||||
|
|
||||||
static int vpcd_connect(driver_data_t **driver_data)
|
static int vpcd_connect(driver_data_t **driver_data)
|
||||||
{
|
{
|
||||||
|
struct vicc_ctx *ctx;
|
||||||
|
|
||||||
int vicc_found = 0;
|
int vicc_found = 0;
|
||||||
|
|
||||||
|
if (!driver_data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (vicc_init(vpcdport) < 0) {
|
|
||||||
|
ctx = vicc_init(vpcdport);
|
||||||
|
if (!ctx) {
|
||||||
RELAY_ERROR("Could not initialize connection to virtual ICC\n");
|
RELAY_ERROR("Could not initialize connection to virtual ICC\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*driver_data = ctx;
|
||||||
|
|
||||||
|
|
||||||
INFO("Waiting for virtual ICC on port %hu\n",
|
INFO("Waiting for virtual ICC on port %hu\n",
|
||||||
(unsigned short) vpcdport);
|
(unsigned short) vpcdport);
|
||||||
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
switch (vicc_present()) {
|
switch (vicc_present(ctx)) {
|
||||||
case 0:
|
case 0:
|
||||||
/* not present */
|
/* not present */
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@@ -60,7 +67,7 @@ static int vpcd_connect(driver_data_t **driver_data)
|
|||||||
} while (!vicc_found);
|
} while (!vicc_found);
|
||||||
|
|
||||||
|
|
||||||
if (vicc_poweron() < 0) {
|
if (vicc_poweron(ctx) < 0) {
|
||||||
RELAY_ERROR("could not powerup\n");
|
RELAY_ERROR("could not powerup\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -73,10 +80,12 @@ static int vpcd_connect(driver_data_t **driver_data)
|
|||||||
|
|
||||||
static int vpcd_disconnect(driver_data_t *driver_data)
|
static int vpcd_disconnect(driver_data_t *driver_data)
|
||||||
{
|
{
|
||||||
if (vicc_eject() != 0)
|
struct vicc_ctx *ctx = driver_data;
|
||||||
|
|
||||||
|
if (vicc_eject(ctx) != 0)
|
||||||
DEBUG("Could not eject virtual ICC\n");
|
DEBUG("Could not eject virtual ICC\n");
|
||||||
|
|
||||||
if (vicc_exit() != 0) {
|
if (vicc_exit(ctx) != 0) {
|
||||||
RELAY_ERROR("Could not close connection to virtual ICC\n");
|
RELAY_ERROR("Could not close connection to virtual ICC\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -88,9 +97,11 @@ static int vpcd_transmit(driver_data_t *driver_data,
|
|||||||
const unsigned char *send, size_t send_len,
|
const unsigned char *send, size_t send_len,
|
||||||
unsigned char *recv, size_t *recv_len)
|
unsigned char *recv, size_t *recv_len)
|
||||||
{
|
{
|
||||||
|
struct vicc_ctx *ctx = driver_data;
|
||||||
|
|
||||||
unsigned char *rapdu = NULL;
|
unsigned char *rapdu = NULL;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
ssize_t size = vicc_transmit(send_len, send, &rapdu);
|
ssize_t size = vicc_transmit(ctx, send_len, send, &rapdu);
|
||||||
|
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
RELAY_ERROR("could not send apdu or receive rapdu\n");
|
RELAY_ERROR("could not send apdu or receive rapdu\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user