pcsclite.h

Go to the documentation of this file.
00001 /*
00002  * MUSCLE SmartCard Development ( http://www.linuxnet.com )
00003  *
00004  * Copyright (C) 1999-2004
00005  *  David Corcoran <corcoran@linuxnet.com>
00006  *  Ludovic Rousseau <ludovic.rousseau@free.fr>
00007  *
00008  * $Id: pcsclite.h.in 1517 2005-05-18 17:06:07Z rousseau $
00009  */
00010 
00016 #ifndef __pcsclite_h__
00017 #define __pcsclite_h__
00018 
00019 #include <wintypes.h>
00020 
00021 #ifdef __cplusplus
00022 extern "C"
00023 {
00024 #endif
00025 
00026 #ifdef WIN32
00027 #include <winscard.h>
00028 #else
00029 typedef long SCARDCONTEXT;
00030 typedef SCARDCONTEXT *PSCARDCONTEXT;
00031 typedef SCARDCONTEXT *LPSCARDCONTEXT;
00032 typedef long SCARDHANDLE;
00033 typedef SCARDHANDLE *PSCARDHANDLE;
00034 typedef SCARDHANDLE *LPSCARDHANDLE;
00035 
00036 #define MAX_ATR_SIZE            33  /* Maximum ATR size */
00037 
00038 typedef struct
00039 {
00040     const char *szReader;
00041     void *pvUserData;
00042     unsigned long dwCurrentState;
00043     unsigned long dwEventState;
00044     unsigned long cbAtr;
00045     unsigned char rgbAtr[MAX_ATR_SIZE];
00046 }
00047 SCARD_READERSTATE_A;
00048 
00049 typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A,
00050     *LPSCARD_READERSTATE_A;
00051 
00052 typedef struct _SCARD_IO_REQUEST
00053 {
00054     unsigned long dwProtocol;   /* Protocol identifier */
00055     unsigned long cbPciLength;  /* Protocol Control Inf Length */
00056 }
00057 SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
00058 
00059 typedef const SCARD_IO_REQUEST *LPCSCARD_IO_REQUEST;
00060 
00061 extern SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci,
00062     g_rgSCardRawPci;
00063 
00064 #define SCARD_PCI_T0    (&g_rgSCardT0Pci)
00065 #define SCARD_PCI_T1    (&g_rgSCardT1Pci)
00066 #define SCARD_PCI_RAW   (&g_rgSCardRawPci)
00067 
00068 #define SCARD_S_SUCCESS         0x00000000
00069 #define SCARD_E_CANCELLED       0x80100002
00070 #define SCARD_E_CANT_DISPOSE        0x8010000E
00071 #define SCARD_E_INSUFFICIENT_BUFFER 0x80100008
00072 #define SCARD_E_INVALID_ATR     0x80100015
00073 #define SCARD_E_INVALID_HANDLE      0x80100003
00074 #define SCARD_E_INVALID_PARAMETER   0x80100004
00075 #define SCARD_E_INVALID_TARGET      0x80100005
00076 #define SCARD_E_INVALID_VALUE       0x80100011
00077 #define SCARD_E_NO_MEMORY       0x80100006
00078 #define SCARD_F_COMM_ERROR      0x80100013
00079 #define SCARD_F_INTERNAL_ERROR      0x80100001
00080 #define SCARD_F_UNKNOWN_ERROR       0x80100014
00081 #define SCARD_F_WAITED_TOO_LONG     0x80100007
00082 #define SCARD_E_UNKNOWN_READER      0x80100009
00083 #define SCARD_E_TIMEOUT         0x8010000A
00084 #define SCARD_E_SHARING_VIOLATION   0x8010000B
00085 #define SCARD_E_NO_SMARTCARD        0x8010000C
00086 #define SCARD_E_UNKNOWN_CARD        0x8010000D
00087 #define SCARD_E_PROTO_MISMATCH      0x8010000F
00088 #define SCARD_E_NOT_READY       0x80100010
00089 #define SCARD_E_SYSTEM_CANCELLED    0x80100012
00090 #define SCARD_E_NOT_TRANSACTED      0x80100016
00091 #define SCARD_E_READER_UNAVAILABLE  0x80100017
00092 
00093 #define SCARD_W_UNSUPPORTED_CARD    0x80100065
00094 #define SCARD_W_UNRESPONSIVE_CARD   0x80100066
00095 #define SCARD_W_UNPOWERED_CARD      0x80100067
00096 #define SCARD_W_RESET_CARD      0x80100068
00097 #define SCARD_W_REMOVED_CARD        0x80100069
00098 
00099 #define SCARD_E_PCI_TOO_SMALL       0x80100019
00100 #define SCARD_E_READER_UNSUPPORTED  0x8010001A
00101 #define SCARD_E_DUPLICATE_READER    0x8010001B
00102 #define SCARD_E_CARD_UNSUPPORTED    0x8010001C
00103 #define SCARD_E_NO_SERVICE      0x8010001D
00104 #define SCARD_E_SERVICE_STOPPED     0x8010001E
00105 
00106 #define SCARD_SCOPE_USER        0x0000  /* Scope in user space */
00107 #define SCARD_SCOPE_TERMINAL        0x0001  /* Scope in terminal */
00108 #define SCARD_SCOPE_SYSTEM      0x0002  /* Scope in system */
00109 
00110 #define SCARD_PROTOCOL_UNSET        0x0000  /* protocol not set */
00111 #define SCARD_PROTOCOL_T0       0x0001  /* T=0 active protocol. */
00112 #define SCARD_PROTOCOL_T1       0x0002  /* T=1 active protocol. */
00113 #define SCARD_PROTOCOL_RAW      0x0004  /* Raw active protocol. */
00114 #define SCARD_PROTOCOL_T15      0x0008  /* T=15 protocol. */
00115 
00116 #define SCARD_PROTOCOL_ANY      (SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1)   /* IFD determines prot. */
00117 
00118 #define SCARD_SHARE_EXCLUSIVE       0x0001  /* Exclusive mode only */
00119 #define SCARD_SHARE_SHARED      0x0002  /* Shared mode only */
00120 #define SCARD_SHARE_DIRECT      0x0003  /* Raw mode only */
00121 
00122 #define SCARD_LEAVE_CARD        0x0000  /* Do nothing on close */
00123 #define SCARD_RESET_CARD        0x0001  /* Reset on close */
00124 #define SCARD_UNPOWER_CARD      0x0002  /* Power down on close */
00125 #define SCARD_EJECT_CARD        0x0003  /* Eject on close */
00126 
00127 #define SCARD_UNKNOWN           0x0001  /* Unknown state */
00128 #define SCARD_ABSENT            0x0002  /* Card is absent */
00129 #define SCARD_PRESENT           0x0004  /* Card is present */
00130 #define SCARD_SWALLOWED         0x0008  /* Card not powered */
00131 #define SCARD_POWERED           0x0010  /* Card is powered */
00132 #define SCARD_NEGOTIABLE        0x0020  /* Ready for PTS */
00133 #define SCARD_SPECIFIC          0x0040  /* PTS has been set */
00134 
00135 #define SCARD_STATE_UNAWARE     0x0000  /* App wants status */
00136 #define SCARD_STATE_IGNORE      0x0001  /* Ignore this reader */
00137 #define SCARD_STATE_CHANGED     0x0002  /* State has changed */
00138 #define SCARD_STATE_UNKNOWN     0x0004  /* Reader unknown */
00139 #define SCARD_STATE_UNAVAILABLE     0x0008  /* Status unavailable */
00140 #define SCARD_STATE_EMPTY       0x0010  /* Card removed */
00141 #define SCARD_STATE_PRESENT     0x0020  /* Card inserted */
00142 #define SCARD_STATE_ATRMATCH        0x0040  /* ATR matches card */
00143 #define SCARD_STATE_EXCLUSIVE       0x0080  /* Exclusive Mode */
00144 #define SCARD_STATE_INUSE       0x0100  /* Shared Mode */
00145 #define SCARD_STATE_MUTE        0x0200  /* Unresponsive card */
00146 #define SCARD_STATE_UNPOWERED       0x0400  /* Unpowered card */
00147 
00148 #endif
00149 
00150 /* PC/SC Lite specific extensions */
00151 #define SCARD_W_INSERTED_CARD       0x8010006A
00152 #define SCARD_E_UNSUPPORTED_FEATURE 0x8010001F
00153 
00154 #define SCARD_SCOPE_GLOBAL      0x0003  /* Scope is global */
00155 
00156 #define SCARD_RESET         0x0001  /* Card was reset */
00157 #define SCARD_INSERTED          0x0002  /* Card was inserted */
00158 #define SCARD_REMOVED           0x0004  /* Card was removed */
00159 
00160 #define BLOCK_STATUS_RESUME     0x00FF  /* Normal resume */
00161 #define BLOCK_STATUS_BLOCKING       0x00FA  /* Function is blocking */
00162 
00163 #define PCSCLITE_CONFIG_DIR     "/etc"
00164 
00165 #ifndef USE_IPCDIR
00166 #define PCSCLITE_IPC_DIR        "/var/run"
00167 #else
00168 #define PCSCLITE_IPC_DIR        USE_IPCDIR
00169 #endif
00170 
00171 #define PCSCLITE_READER_CONFIG      PCSCLITE_CONFIG_DIR "/reader.conf"
00172 #define PCSCLITE_PUBSHM_FILE        PCSCLITE_IPC_DIR "/pcscd.pub"
00173 #define PCSCLITE_CSOCK_NAME     PCSCLITE_IPC_DIR "/pcscd.comm"
00174 
00175 #define PCSCLITE_SVC_IDENTITY       0x01030000  /* Service ID */
00176 
00177 #ifndef INFINITE
00178 #define INFINITE            0xFFFFFFFF  /* Infinite timeout */
00179 #endif
00180 #define PCSCLITE_INFINITE_TIMEOUT   4320000     /* 50 day infinite t/o */
00181 
00182 #define PCSCLITE_VERSION_NUMBER     "1.3.1" /* Current version */
00183 #define PCSCLITE_CLIENT_ATTEMPTS    120     /* Attempts to reach sv */
00184 #define PCSCLITE_MCLIENT_ATTEMPTS   20      /* Attempts to reach sv */
00185 #define PCSCLITE_STATUS_POLL_RATE   400000      /* Status polling rate */
00186 #define PCSCLITE_MSG_KEY_LEN        16      /* App ID key length */
00187 #define PCSCLITE_RW_ATTEMPTS        100     /* Attempts to rd/wrt */
00188 
00189 /* Maximum applications */
00190 #define PCSCLITE_MAX_APPLICATIONS           16
00191 /* Maximum contexts by application */
00192 #define PCSCLITE_MAX_APPLICATION_CONTEXTS       16
00193 /* Maximum of applications contexts that pcscd can accept */
00194 #define PCSCLITE_MAX_APPLICATIONS_CONTEXTS \
00195     PCSCLITE_MAX_APPLICATIONS * PCSCLITE_MAX_APPLICATION_CONTEXTS
00196 /* Maximum channels on a reader context */
00197 #define PCSCLITE_MAX_READER_CONTEXT_CHANNELS        16
00198 /* Maximum channels on an application context */
00199 #define PCSCLITE_MAX_APPLICATION_CONTEXT_CHANNELS   16
00200 /* Maximum readers context (a slot is count as a reader) */
00201 #define PCSCLITE_MAX_READERS_CONTEXTS           16
00202 
00203 /* PCSCLITE_MAX_READERS is deprecated
00204  * use PCSCLITE_MAX_READERS_CONTEXTS instead */
00205 /* extern int PCSCLITE_MAX_READERS __attribute__ ((deprecated)); */
00206 
00207 #define PCSCLITE_MAX_THREADS        16  /* Stat change threads */
00208 #define PCSCLITE_STATUS_WAIT        200000  /* Status Change Sleep */
00209 #define PCSCLITE_TRANSACTION_TIMEOUT    40  /* Transaction timeout */
00210 #define MAX_READERNAME          52
00211 #define MAX_LIBNAME         100
00212 #define MAX_DEVICENAME      255
00213 
00214 #ifndef SCARD_ATR_LENGTH
00215 #define SCARD_ATR_LENGTH        MAX_ATR_SIZE    /* Maximum ATR size */
00216 #endif
00217 
00218 /*
00219  * Enhanced messaging has been added to accomodate newer devices which have
00220  * more advanced capabilites, such as dedicated secure co-processors which
00221  * can stream and encrypt data over USB. In order to used enhanced messaging
00222  * you must define PCSCLITE_ENHANCED_MESSAGING in the framework(library),
00223  * the daemon, and your application
00224  */
00225 #undef PCSCLITE_ENHANCED_MESSAGING
00226 #ifndef PCSCLITE_ENHANCED_MESSAGING
00227 #define PCSCLITE_MAX_MESSAGE_SIZE   2048    /* Transport msg len */
00228 #define MAX_BUFFER_SIZE         264 /* Maximum Tx/Rx Buffer */
00229 #define PCSCLITE_SERVER_ATTEMPTS    5   /* Attempts to reach cl */
00230 #else
00231 /*
00232  * The message and buffer sizes must be multiples of 16.
00233  * The max message size must be at least large enough
00234  * to accomodate the transmit_struct
00235  */
00236 #define PCSCLITE_MAX_MESSAGE_SIZE   (1<<17) /* enhanced (128K) msg len */
00237 #define MAX_BUFFER_SIZE         (1<<15) /* enhanced (32K) Tx/Rx Buffer */
00238 #define PCSCLITE_SERVER_ATTEMPTS    200 /* To allow larger data reads/writes */
00239 #endif
00240 
00241 /*
00242  * Gets a stringified error response
00243  */
00244 char *pcsc_stringify_error(long);
00245 
00246 #ifdef __cplusplus
00247 }
00248 #endif
00249 
00250 #endif

Generated on Sat Sep 15 17:18:32 2007 for pcsc-lite by  doxygen 1.4.7