1 /* $Id: ifdhandler.h,v 1.2 2003/06/19 22:40:53 rees Exp $ */
2 
3 /*
4 copyright 2001
5 the regents of the university of michigan
6 all rights reserved
7 
8 permission is granted to use, copy, create derivative works
9 and redistribute this software and such derivative works
10 for any purpose, so long as the name of the university of
11 michigan is not used in any advertising or publicity
12 pertaining to the use or distribution of this software
13 without specific, written prior authorization.  if the
14 above copyright notice or any other identification of the
15 university of michigan is included in any copy of any
16 portion of this software, then the disclaimer below must
17 also be included.
18 
19 this software is provided as is, without representation
20 from the university of michigan as to its fitness for any
21 purpose, and without warranty by the university of
22 michigan of any kind, either express or implied, including
23 without limitation the implied warranties of
24 merchantability and fitness for a particular purpose. the
25 regents of the university of michigan shall not be liable
26 for any damages, including special, indirect, incidental, or
27 consequential damages, with respect to any claim arising
28 out of or in connection with the use of the software, even
29 if it has been or is hereafter advised of the possibility of
30 such damages.
31 */
32 
33 #ifndef _IFDHANDLER_H_
34 #define _IFDHANDLER_H_
35 
36 /*
37  * pcsc cruft
38  */
39 
40 #define MAX_ATR_SIZE 33
41 #define IFD_POWER_UP 500
42 #define IFD_POWER_DOWN 501
43 #define IFD_RESET 502
44 #define IFD_ERROR_NOT_SUPPORTED 606
45 #define IFD_ERROR_POWER_ACTION 608
46 #define IFD_COMMUNICATION_ERROR 612
47 #define IFD_NOT_SUPPORTED 614
48 #define IFD_ICC_PRESENT 615
49 #define IFD_ICC_NOT_PRESENT 616
50 #define TAG_IFD_ATR 0x303
51 
52 /* Extra tags for things they forgot to put in the ifd interface */
53 #define SCTAG_IFD_ATRLEN 0x6601
54 #define SCTAG_IFD_CARDPRESENT 0x301
55 #define SCTAG_OPEN_FLAGS  0x800
56 #define SCTAG_RESET_FLAGS 0x801
57 
58 #define IFDH_VERSION_1_0	1
59 #define IFDH_VERSION_2_0	2
60 
61 typedef struct _SCARD_IO_HEADER {
62     unsigned long Protocol, Length;
63 } SCARD_IO_HEADER;
64 
65 typedef struct {
66     unsigned long 	channelID;
67     unsigned long	lun;
68     char 		*driverPath;
69     unsigned int	driverLoaded;
70     int			version;
71     void *open;
72     void *close;
73     void *data;
74     void *power;
75     void *getcapa;
76     void *setcapa;
77     void *cardpresent;
78 } readerInfo;
79 
80 /* IFD interface version 1 */
81 unsigned long IO_Create_Channel(unsigned long ChannelId);
82 unsigned long IO_Close_Channel();
83 unsigned long IFD_Get_Capabilities(unsigned long Tag, unsigned char Value[]);
84 unsigned long IFD_Set_Capabilities(unsigned long Tag, unsigned char Value[]);
85 unsigned long IFD_Set_Protocol_Parameters(unsigned long ProtocolType, unsigned char SelectionFlags, unsigned char PTS1, unsigned char PTS2, unsigned char PTS3);
86 unsigned long IFD_Power_ICC(unsigned long a);
87 unsigned long IFD_Swallow_ICC();
88 unsigned long IFD_Eject_ICC();
89 unsigned long IFD_Confiscate_ICC();
90 unsigned long IFD_Transmit_to_ICC(SCARD_IO_HEADER SendPci,
91 		    unsigned char ibuf[], unsigned long ilen,
92 		    unsigned char obuf[], unsigned long *olen,
93 		    SCARD_IO_HEADER *RecvPci);
94 unsigned long IFD_Is_ICC_Present();
95 
96 /* IFD interface version 2 */
97 unsigned long IFDHCreateChannel(unsigned long Lun, unsigned long Channel);
98 unsigned long IFDHCloseChannel(unsigned long Lun);
99 unsigned long IFDHGetCapabilities (unsigned long Lun, unsigned long Tag,
100 		unsigned long *length, unsigned char *value);
101 unsigned long IFDHSetCapabilities (unsigned long Lun, unsigned long Tag,
102 		unsigned long Length, unsigned char *value);
103 unsigned long IFDHSetProtocolParameters (unsigned long Lun,
104 		unsigned long Protocol, unsigned char Flags,
105 		unsigned char PTS1, unsigned char PTS2, unsigned char PTS3);
106 unsigned long IFDHPowerICC (unsigned long Lun, unsigned long Action,
107 		unsigned char *Atr, unsigned long *AtrLength);
108 unsigned long IFDHTransmitToICC (unsigned long Lun, SCARD_IO_HEADER SendPci,
109 		unsigned char *TxBuffer, unsigned long TxLength,
110 		unsigned char *RxBuffer, unsigned long RxLength,
111 		SCARD_IO_HEADER *RecvPci);
112 unsigned long IFDHControl (unsigned long Lun, unsigned char* TxBuffer,
113 		unsigned long TxLength, unsigned char *RxBuffer,
114 		unsigned long *RxLength);
115 unsigned long IFDHICCPresence(unsigned long Lun);
116 
117 #endif /* _IFDHANDLER_H_ */
118