| 1 | /* |
|---|
| 2 | * Transparent protocol - simply pass everything to the reader driver |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2003, Olaf Kirch <okir@suse.de> |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | #include "internal.h" |
|---|
| 8 | #include <unistd.h> |
|---|
| 9 | #include <stdlib.h> |
|---|
| 10 | #include <string.h> |
|---|
| 11 | |
|---|
| 12 | /* |
|---|
| 13 | * Attach t0 protocol |
|---|
| 14 | */ |
|---|
| 15 | static int trans_init(ifd_protocol_t * prot) |
|---|
| 16 | { |
|---|
| 17 | ifd_reader_t *reader = prot->reader; |
|---|
| 18 | const ifd_driver_t *drv; |
|---|
| 19 | |
|---|
| 20 | if (!reader || !(drv = reader->driver) |
|---|
| 21 | || !drv->ops || !drv->ops->transparent) |
|---|
| 22 | return -1; |
|---|
| 23 | return 0; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | /* |
|---|
| 27 | * Detach t0 protocol |
|---|
| 28 | */ |
|---|
| 29 | static void trans_release(ifd_protocol_t * prot) |
|---|
| 30 | { |
|---|
| 31 | /* NOP */ |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | /* |
|---|
| 35 | * Get/set parmaters for T1 protocol |
|---|
| 36 | */ |
|---|
| 37 | static int trans_set_param(ifd_protocol_t * prot, int type, long value) |
|---|
| 38 | { |
|---|
| 39 | ct_error("set_pameter not supported"); |
|---|
| 40 | return -1; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | static int trans_get_param(ifd_protocol_t * prot, int type, long *result) |
|---|
| 44 | { |
|---|
| 45 | ct_error("get_pameter not supported"); |
|---|
| 46 | return -1; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | /* |
|---|
| 50 | * Transceive an APDU |
|---|
| 51 | */ |
|---|
| 52 | static int trans_transceive(ifd_protocol_t * prot, int dad, const void *sbuf, |
|---|
| 53 | size_t slen, void *rbuf, size_t rlen) |
|---|
| 54 | { |
|---|
| 55 | ifd_reader_t *reader = prot->reader; |
|---|
| 56 | const ifd_driver_t *drv = reader->driver; |
|---|
| 57 | |
|---|
| 58 | return drv->ops->transparent(reader, dad, sbuf, slen, rbuf, rlen); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | /* |
|---|
| 62 | * Protocol struct |
|---|
| 63 | */ |
|---|
| 64 | struct ifd_protocol_ops ifd_protocol_trans = { |
|---|
| 65 | IFD_PROTOCOL_TRANSPARENT, /* id */ |
|---|
| 66 | "transparent", /* name */ |
|---|
| 67 | sizeof(ifd_protocol_t), /* size */ |
|---|
| 68 | trans_init, /* init */ |
|---|
| 69 | trans_release, /* release */ |
|---|
| 70 | trans_set_param, /* set_param */ |
|---|
| 71 | trans_get_param, /* get_param */ |
|---|
| 72 | NULL, /* resynchronize */ |
|---|
| 73 | trans_transceive, /* transceive */ |
|---|
| 74 | NULL, /* sync_read */ |
|---|
| 75 | NULL, /* sync_write */ |
|---|
| 76 | }; |
|---|