1/* 2 defs.h: 3 Copyright (C) 2003 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: defs.h 4292 2009-07-01 12:28:01Z rousseau $ 22 */ 23 24#include <pcsclite.h> 25 26#include "openct/proto-t1.h" 27 28typedef 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 50typedef 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/* Kobil readers does not support APDU chaining for T=1 so you can't send an 70 * extended APDU. The readers supports a command of up to 512 or 420 bytes. 71 * For a Kobil KAAN Base/advanced reader you should use 72 * #define CMD_BUF_SIZE 420 73 * For the other models you should use 74 * #define CMD_BUF_SIZE 512 75 * Kobil is aware of the problem and do not plan to solve it. 76 */ 77/* Communication buffer size (max=adpu+Lc+data+Le) */ 78#define CMD_BUF_SIZE (4+1+256+1) 79/* Larger communication buffer size (max=reader status+data+sw) */ 80#define RESP_BUF_SIZE (1+256+2) 81 82/* Protocols */ 83#define T_0 0 84#define T_1 1 85 86/* Size of an ISO command (CLA+INS+P1+P2) */ 87#define ISO_CMD_SIZE 4 88/* Offset of the length byte in an TPDU */ 89#define ISO_OFFSET_LENGTH 4 90/* Offset of the data in a TPDU */ 91#define ISO_OFFSET_TPDU_DATA 5 92/* ISO length size (1 in general) */ 93#define ISO_LENGTH_SIZE 1 94 95/* Default communication read timeout in seconds */ 96#define DEFAULT_COM_READ_TIMEOUT 2 97 98/* 99 * communication ports abstraction 100 */ 101#ifdef TWIN_SERIAL 102 103#define OpenPortByName OpenSerialByName 104#define OpenPort OpenSerial 105#define ClosePort CloseSerial 106#define ReadPort ReadSerial 107#define WritePort WriteSerial 108#include "ccid_serial.h" 109 110#else 111 112#define OpenPortByName OpenUSBByName 113#define OpenPort OpenUSB 114#define ClosePort CloseUSB 115#define ReadPort ReadUSB 116#define WritePort WriteUSB 117#include "ccid_usb.h" 118 119#endif 120 121