| 1 |
/*
|
| 2 |
defs.h:
|
| 3 |
Copyright (C) 2003-2010 Ludovic Rousseau
|
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or
|
| 6 |
modify it under the terms of the GNU Lesser General Public
|
| 7 |
License as published by the Free Software Foundation; either
|
| 8 |
version 2.1 of the License, or (at your option) any later version.
|
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful,
|
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
Lesser General Public License for more details.
|
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public License
|
| 16 |
along with this library; if not, write to the Free Software Foundation,
|
| 17 |
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| 18 |
*/
|
| 19 |
|
| 20 |
/*
|
| 21 |
* $Id$
|
| 22 |
*/
|
| 23 |
|
| 24 |
#include <pcsclite.h>
|
| 25 |
|
| 26 |
#include "openct/proto-t1.h"
|
| 27 |
|
| 28 |
typedef struct CCID_DESC
|
| 29 |
{
|
| 30 |
/*
|
| 31 |
* ATR
|
| 32 |
*/
|
| 33 |
int nATRLength;
|
| 34 |
UCHAR pcATRBuffer[MAX_ATR_SIZE];
|
| 35 |
|
| 36 |
/*
|
| 37 |
* Card state
|
| 38 |
*/
|
| 39 |
UCHAR bPowerFlags;
|
| 40 |
|
| 41 |
/*
|
| 42 |
* T=1 Protocol context
|
| 43 |
*/
|
| 44 |
t1_state_t t1;
|
| 45 |
|
| 46 |
/* reader name passed to IFDHCreateChannelByName() */
|
| 47 |
char *readerName;
|
| 48 |
} CcidDesc;
|
| 49 |
|
| 50 |
typedef enum {
|
| 51 |
STATUS_NO_SUCH_DEVICE = 0xF9,
|
| 52 |
STATUS_SUCCESS = 0xFA,
|
| 53 |
STATUS_UNSUCCESSFUL = 0xFB,
|
| 54 |
STATUS_COMM_ERROR = 0xFC,
|
| 55 |
STATUS_DEVICE_PROTOCOL_ERROR = 0xFD,
|
| 56 |
STATUS_COMM_NAK = 0xFE,
|
| 57 |
STATUS_SECONDARY_SLOT = 0xFF
|
| 58 |
} status_t;
|
| 59 |
|
| 60 |
/* Powerflag (used to detect quick insertion removals unnoticed by the
|
| 61 |
* resource manager) */
|
| 62 |
/* Initial value */
|
| 63 |
#define POWERFLAGS_RAZ 0x00
|
| 64 |
/* Flag set when a power up has been requested */
|
| 65 |
#define MASK_POWERFLAGS_PUP 0x01
|
| 66 |
/* Flag set when a power down is requested */
|
| 67 |
#define MASK_POWERFLAGS_PDWN 0x02
|
| 68 |
|
| 69 |
/* Communication buffer size (max=adpu+Lc+data+Le)
|
| 70 |
* we use a 64kB for extended APDU on APDU mode readers */
|
| 71 |
#define CMD_BUF_SIZE (4 +3 +64*1024 +3)
|
| 72 |
|
| 73 |
/* Protocols */
|
| 74 |
#define T_0 0
|
| 75 |
#define T_1 1
|
| 76 |
|
| 77 |
/* Default communication read timeout in milliseconds */
|
| 78 |
#define DEFAULT_COM_READ_TIMEOUT (2*1000)
|
| 79 |
|
| 80 |
/*
|
| 81 |
* communication ports abstraction
|
| 82 |
*/
|
| 83 |
#ifdef TWIN_SERIAL
|
| 84 |
|
| 85 |
#define OpenPortByName OpenSerialByName
|
| 86 |
#define OpenPort OpenSerial
|
| 87 |
#define ClosePort CloseSerial
|
| 88 |
#define ReadPort ReadSerial
|
| 89 |
#define WritePort WriteSerial
|
| 90 |
#include "ccid_serial.h"
|
| 91 |
|
| 92 |
#else
|
| 93 |
|
| 94 |
#define OpenPortByName OpenUSBByName
|
| 95 |
#define OpenPort OpenUSB
|
| 96 |
#define ClosePort CloseUSB
|
| 97 |
#define ReadPort ReadUSB
|
| 98 |
#define WritePort WriteUSB
|
| 99 |
#include "ccid_usb.h"
|
| 100 |
|
| 101 |
#endif
|
| 102 |
|