/[rdesktop]/jpeg/rdesktop/trunk/scard.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /jpeg/rdesktop/trunk/scard.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1367 - (show annotations)
Thu Jan 4 14:38:48 2007 UTC (17 years, 5 months ago) by stargo
Original Path: sourceforge.net/trunk/rdesktop/scard.h
File MIME type: text/plain
File size: 6101 byte(s)
RD_ prefix

1 /*
2 rdesktop: A Remote Desktop Protocol client.
3 Smart Card support
4 Copyright (C) Alexi Volkov <alexi@myrealbox.com> 2006
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <pthread.h>
22 #include "proto.h"
23
24 /*************************************************************************/
25 /* these are the additional types needed to split out 64-vs-32-bit APIs */
26 /* */
27
28 /* The point of all of this is to avoid patching the existing smartcard
29 * infrastructure (PC/SC Lite, libmusclecard+libmusclepkcs11 or CoolKey, any
30 * other apps linking against any of these) because the need for patches
31 * spreads without limit. The alternative is to patch the heck out of rdesktop,
32 * which is already being done anyway.
33 *
34 * - jared.jennings@eglin.af.mil, 2 Aug 2006
35 */
36
37 #include <stdint.h>
38
39 /* A DWORD when dealing with the smartcard stuff. Could be 32 bits or 64. */
40 typedef DWORD MYPCSC_DWORD;
41 /* A DWORD when talking to the server. Must be exactly 32 bits all the time.*/
42 typedef uint32_t SERVER_DWORD;
43
44 typedef SCARDCONTEXT MYPCSC_SCARDCONTEXT;
45 typedef SCARDHANDLE MYPCSC_SCARDHANDLE;
46 typedef uint32_t SERVER_SCARDCONTEXT;
47 typedef uint32_t SERVER_SCARDHANDLE;
48
49 typedef SCARD_READERSTATE_A MYPCSC_SCARD_READERSTATE_A;
50 typedef LPSCARD_READERSTATE_A MYPCSC_LPSCARD_READERSTATE_A;
51
52 typedef struct
53 {
54 const char *szReader;
55 void *pvUserData;
56 SERVER_DWORD dwCurrentState;
57 SERVER_DWORD dwEventState;
58 SERVER_DWORD cbAtr;
59 unsigned char rgbAtr[MAX_ATR_SIZE];
60 }
61 SERVER_SCARD_READERSTATE_A;
62
63 typedef SERVER_SCARD_READERSTATE_A *SERVER_LPSCARD_READERSTATE_A;
64
65 #define SERVER_SCARDSTATESIZE (sizeof(SERVER_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
66 #define MYPCSC_SCARDSTATESIZE (sizeof(MYPCSC_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
67
68 typedef struct _SERVER_SCARD_IO_REQUEST
69 {
70 SERVER_DWORD dwProtocol; /* Protocol identifier */
71 SERVER_DWORD cbPciLength; /* Protocol Control Inf Length */
72 }
73 SERVER_SCARD_IO_REQUEST, *SERVER_LPSCARD_IO_REQUEST;
74
75 typedef SCARD_IO_REQUEST MYPCSC_SCARD_IO_REQUEST;
76 typedef LPSCARD_IO_REQUEST MYPCSC_LPSCARD_IO_REQUEST;
77
78
79 /* */
80 /* */
81 /*************************************************************************/
82
83
84 #define SC_TRUE 1
85 #define SC_FALSE 0
86
87 #define SC_ESTABLISH_CONTEXT 0x00090014 /* EstablishContext */
88 #define SC_RELEASE_CONTEXT 0x00090018 /* ReleaseContext */
89 #define SC_IS_VALID_CONTEXT 0x0009001C /* IsValidContext */
90 #define SC_LIST_READER_GROUPS 0x00090020 /* ListReaderGroups */
91 #define SC_LIST_READERS 0x00090028 /* ListReadersA */
92 #define SC_INTRODUCE_READER_GROUP 0x00090050 /* IntroduceReaderGroup */
93 #define SC_FORGET_READER_GROUP 0x00090058 /* ForgetReader */
94 #define SC_INTRODUCE_READER 0x00090060 /* IntroduceReader */
95 #define SC_FORGET_READER 0x00090068 /* IntroduceReader */
96 #define SC_ADD_READER_TO_GROUP 0x00090070 /* AddReaderToGroup */
97 #define SC_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup */
98 #define SC_CONNECT 0x000900AC /* ConnectA */
99 #define SC_RECONNECT 0x000900B4 /* Reconnect */
100 #define SC_DISCONNECT 0x000900B8 /* Disconnect */
101 #define SC_GET_STATUS_CHANGE 0x000900A0 /* GetStatusChangeA */
102 #define SC_CANCEL 0x000900A8 /* Cancel */
103 #define SC_BEGIN_TRANSACTION 0x000900BC /* BeginTransaction */
104 #define SC_END_TRANSACTION 0x000900C0 /* EndTransaction */
105 #define SC_STATE 0x000900C4 /* State */
106 #define SC_STATUS 0x000900C8 /* StatusA */
107 #define SC_TRANSMIT 0x000900D0 /* Transmit */
108 #define SC_CONTROL 0x000900D4 /* Control */
109 #define SC_GETATTRIB 0x000900D8 /* GetAttrib */
110 #define SC_SETATTRIB 0x000900DC /* SetAttrib */
111 #define SC_ACCESS_STARTED_EVENT 0x000900E0 /* SCardAccessStartedEvent */
112 #define SC_LOCATE_CARDS_BY_ATR 0x000900E8 /* LocateCardsByATR */
113
114 /* #define INPUT_LINKED 0x00020000 */
115 #define INPUT_LINKED 0xFFFFFFFF
116
117 #define SC_THREAD_FUNCTION(f) void *(*f)(void *)
118
119 extern RDPDR_DEVICE g_rdpdr_device[];
120
121 typedef struct _MEM_HANDLE
122 {
123 struct _MEM_HANDLE *prevHandle;
124 struct _MEM_HANDLE *nextHandle;
125 int dataSize;
126 } MEM_HANDLE, *PMEM_HANDLE;
127
128 typedef struct _SCARD_ATRMASK_L
129 {
130 unsigned int cbAtr;
131 unsigned char rgbAtr[36];
132 unsigned char rgbMask[36];
133 } SCARD_ATRMASK_L, *PSCARD_ATRMASK_L, *LPSCARD_ATRMASK_L;
134
135 typedef struct _TSCNameMapRec
136 {
137 char alias[128];
138 char name[128];
139 char vendor[128];
140 } TSCNameMapRec, *PSCNameMapRec;
141
142 typedef struct _TSCHCardRec
143 {
144 DWORD hCard;
145 char *vendor;
146 struct _TSCHCardRec *next;
147 struct _TSCHCardRec *prev;
148 } TSCHCardRec, *PSCHCardRec;
149
150 typedef struct _TSCThreadData
151 {
152 uint32 device;
153 uint32 id;
154 RD_NTHANDLE handle;
155 uint32 request;
156 STREAM in;
157 STREAM out;
158 PMEM_HANDLE memHandle;
159 struct _TSCThreadData *next;
160 } TSCThreadData, *PSCThreadData;
161
162 typedef struct _TThreadListElement
163 {
164 pthread_t thread;
165 pthread_mutex_t busy;
166 pthread_mutex_t nodata;
167 PSCThreadData data;
168 struct _TThreadListElement *next;
169 } TThreadListElement, *PThreadListElement;
170
171 int scard_enum_devices(uint32 * id, char *optarg);

  ViewVC Help
Powered by ViewVC 1.1.26