VirtualBox

source: vbox/trunk/src/VBox/RDP/client/scard.h@ 13384

Last change on this file since 13384 was 11982, checked in by vboxsync, 16 years ago

All: license header changes for 2.0 (OSE headers, add Sun GPL/LGPL disclaimer)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
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/*
22 * Sun GPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
24 * the General Public License version 2 (GPLv2) at this time for any software where
25 * a choice of GPL license versions is made available with the language indicating
26 * that GPLv2 or any later version may be used, or where a choice of which version
27 * of the GPL is applied is otherwise unspecified.
28 */
29
30#include <pthread.h>
31#include "proto.h"
32
33/*************************************************************************/
34/* these are the additional types needed to split out 64-vs-32-bit APIs */
35/* */
36
37/* The point of all of this is to avoid patching the existing smartcard
38 * infrastructure (PC/SC Lite, libmusclecard+libmusclepkcs11 or CoolKey, any
39 * other apps linking against any of these) because the need for patches
40 * spreads without limit. The alternative is to patch the heck out of rdesktop,
41 * which is already being done anyway.
42 *
43 * - jared.jennings@eglin.af.mil, 2 Aug 2006
44 */
45
46#ifdef HAVE_STDINT_H
47#include <stdint.h>
48#endif
49#ifdef HAVE_INTTYPES_H
50#include <inttypes.h>
51#endif
52
53/* A DWORD when dealing with the smartcard stuff. Could be 32 bits or 64. */
54typedef DWORD MYPCSC_DWORD;
55/* A DWORD when talking to the server. Must be exactly 32 bits all the time.*/
56typedef uint32_t SERVER_DWORD;
57
58typedef SCARDCONTEXT MYPCSC_SCARDCONTEXT;
59typedef SCARDHANDLE MYPCSC_SCARDHANDLE;
60typedef uint32_t SERVER_SCARDCONTEXT;
61typedef uint32_t SERVER_SCARDHANDLE;
62
63typedef SCARD_READERSTATE_A MYPCSC_SCARD_READERSTATE_A;
64typedef LPSCARD_READERSTATE_A MYPCSC_LPSCARD_READERSTATE_A;
65
66typedef struct
67{
68 const char *szReader;
69 void *pvUserData;
70 SERVER_DWORD dwCurrentState;
71 SERVER_DWORD dwEventState;
72 SERVER_DWORD cbAtr;
73 unsigned char rgbAtr[MAX_ATR_SIZE];
74}
75SERVER_SCARD_READERSTATE_A;
76
77typedef SERVER_SCARD_READERSTATE_A *SERVER_LPSCARD_READERSTATE_A;
78
79#define SERVER_SCARDSTATESIZE (sizeof(SERVER_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
80#define MYPCSC_SCARDSTATESIZE (sizeof(MYPCSC_SCARD_READERSTATE_A) - sizeof(const char *) - sizeof(void *))
81
82typedef struct _SERVER_SCARD_IO_REQUEST
83{
84 SERVER_DWORD dwProtocol; /* Protocol identifier */
85 SERVER_DWORD cbPciLength; /* Protocol Control Inf Length */
86}
87SERVER_SCARD_IO_REQUEST, *SERVER_LPSCARD_IO_REQUEST;
88
89typedef SCARD_IO_REQUEST MYPCSC_SCARD_IO_REQUEST;
90typedef LPSCARD_IO_REQUEST MYPCSC_LPSCARD_IO_REQUEST;
91
92
93/* */
94/* */
95/*************************************************************************/
96
97
98#define SC_TRUE 1
99#define SC_FALSE 0
100
101#define SC_ESTABLISH_CONTEXT 0x00090014 /* EstablishContext */
102#define SC_RELEASE_CONTEXT 0x00090018 /* ReleaseContext */
103#define SC_IS_VALID_CONTEXT 0x0009001C /* IsValidContext */
104#define SC_LIST_READER_GROUPS 0x00090020 /* ListReaderGroups */
105#define SC_LIST_READERS 0x00090028 /* ListReadersA */
106#define SC_INTRODUCE_READER_GROUP 0x00090050 /* IntroduceReaderGroup */
107#define SC_FORGET_READER_GROUP 0x00090058 /* ForgetReader */
108#define SC_INTRODUCE_READER 0x00090060 /* IntroduceReader */
109#define SC_FORGET_READER 0x00090068 /* IntroduceReader */
110#define SC_ADD_READER_TO_GROUP 0x00090070 /* AddReaderToGroup */
111#define SC_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup */
112#define SC_CONNECT 0x000900AC /* ConnectA */
113#define SC_RECONNECT 0x000900B4 /* Reconnect */
114#define SC_DISCONNECT 0x000900B8 /* Disconnect */
115#define SC_GET_STATUS_CHANGE 0x000900A0 /* GetStatusChangeA */
116#define SC_CANCEL 0x000900A8 /* Cancel */
117#define SC_BEGIN_TRANSACTION 0x000900BC /* BeginTransaction */
118#define SC_END_TRANSACTION 0x000900C0 /* EndTransaction */
119#define SC_STATE 0x000900C4 /* State */
120#define SC_STATUS 0x000900C8 /* StatusA */
121#define SC_TRANSMIT 0x000900D0 /* Transmit */
122#define SC_CONTROL 0x000900D4 /* Control */
123#define SC_GETATTRIB 0x000900D8 /* GetAttrib */
124#define SC_SETATTRIB 0x000900DC /* SetAttrib */
125#define SC_ACCESS_STARTED_EVENT 0x000900E0 /* SCardAccessStartedEvent */
126#define SC_LOCATE_CARDS_BY_ATR 0x000900E8 /* LocateCardsByATR */
127
128/* #define INPUT_LINKED 0x00020000 */
129#define INPUT_LINKED 0xFFFFFFFF
130
131#define SC_THREAD_FUNCTION(f) void *(*f)(void *)
132
133extern RDPDR_DEVICE g_rdpdr_device[];
134
135typedef struct _MEM_HANDLE
136{
137 struct _MEM_HANDLE *prevHandle;
138 struct _MEM_HANDLE *nextHandle;
139 int dataSize;
140} MEM_HANDLE, *PMEM_HANDLE;
141
142typedef struct _SCARD_ATRMASK_L
143{
144 unsigned int cbAtr;
145 unsigned char rgbAtr[36];
146 unsigned char rgbMask[36];
147} SCARD_ATRMASK_L, *PSCARD_ATRMASK_L, *LPSCARD_ATRMASK_L;
148
149typedef struct _TSCNameMapRec
150{
151 char alias[128];
152 char name[128];
153 char vendor[128];
154} TSCNameMapRec, *PSCNameMapRec;
155
156typedef struct _TSCHCardRec
157{
158 DWORD hCard;
159 char *vendor;
160 struct _TSCHCardRec *next;
161 struct _TSCHCardRec *prev;
162} TSCHCardRec, *PSCHCardRec;
163
164typedef struct _TSCThreadData
165{
166 uint32 device;
167 uint32 id;
168 RD_NTHANDLE handle;
169 uint32 request;
170 STREAM in;
171 STREAM out;
172 PMEM_HANDLE memHandle;
173 struct _TSCThreadData *next;
174} TSCThreadData, *PSCThreadData;
175
176typedef struct _TThreadListElement
177{
178 pthread_t thread;
179 pthread_mutex_t busy;
180 pthread_cond_t nodata;
181 PSCThreadData data;
182 struct _TThreadListElement *next;
183} TThreadListElement, *PThreadListElement;
184
185int scard_enum_devices(uint32 * id, char *optarg);
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette