~ubuntu-branches/ubuntu/jaunty/pcsc-lite/jaunty-security

« back to all changes in this revision

Viewing changes to src/winscard_msg.h

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Rousseau
  • Date: 2005-11-27 18:04:59 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127180459-qrex2gzpq9d8jexd
Tags: 1.2.9-beta9-1
* New upstream version
* debian/compat: change from 3 to 4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
 
3
 *
 
4
 * Copyright (C) 2001-2004
 
5
 *  David Corcoran <corcoran@linuxnet.com>
 
6
 *  Damien Sauveron <damien.sauveron@labri.fr>
 
7
 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
 
8
 *
 
9
 * $Id: winscard_msg.h 1695 2005-10-29 16:27:33Z rousseau $
 
10
 */
 
11
 
 
12
/**
 
13
 * @file
 
14
 * @brief This defines some structures and \#defines to be used over
 
15
 * the transport layer.
 
16
 */
 
17
 
 
18
#ifndef __winscard_msg_h__
 
19
#define __winscard_msg_h__
 
20
 
 
21
/** Major version of the current message protocol */
 
22
#define PROTOCOL_VERSION_MAJOR 2
 
23
/** Minor version of the current message protocol */
 
24
#define PROTOCOL_VERSION_MINOR 0
 
25
 
 
26
#ifdef __cplusplus
 
27
extern "C"
 
28
{
 
29
#endif
 
30
 
 
31
        /**
 
32
         * @brief General structure for client/serve message data exchange.
 
33
         *
 
34
         * It is used in the calls of \c SHMMessageSend and \c SHMMessageReceive.
 
35
         * The field \c data is interpreted according to the values of the fields
 
36
         * \c mtype and \c command. The possible structs the \c data field can
 
37
         * represent are: \c version_struct \c client_struct \c establish_struct
 
38
         * \c release_struct \c connect_struct \c reconnect_struct
 
39
         * \c disconnect_struct \c begin_struct \c end_struct \c cancel_struct
 
40
         * \c status_struct \c transmit_struct \c control_struct \c getset_struct
 
41
         */
 
42
        typedef struct rxSharedSegment
 
43
        {
 
44
                unsigned int mtype;             /** one of the \c pcsc_adm_commands */
 
45
                unsigned int user_id;
 
46
                unsigned int group_id;
 
47
                unsigned int command;   /** one of the \c pcsc_msg_commands */
 
48
                unsigned int dummy;     /* was request_id in pcsc-lite <= 1.2.0 */
 
49
                time_t date;
 
50
                unsigned char key[PCSCLITE_MSG_KEY_LEN];
 
51
                unsigned char data[PCSCLITE_MAX_MESSAGE_SIZE];
 
52
        }
 
53
        sharedSegmentMsg, *psharedSegmentMsg;
 
54
 
 
55
        /**
 
56
         * Command types available to use in the field \c sharedSegmentMsg.mtype.
 
57
         */
 
58
        enum pcsc_adm_commands
 
59
        {
 
60
                CMD_FUNCTION = 0xF1,
 
61
                CMD_FAILED = 0xF2,
 
62
                CMD_SERVER_DIED = 0xF3,
 
63
                CMD_CLIENT_DIED = 0xF4,
 
64
                CMD_READER_EVENT = 0xF5,
 
65
                CMD_SYN = 0xF6,
 
66
                CMD_ACK = 0xF7,
 
67
                CMD_VERSION = 0xF8
 
68
        };
 
69
 
 
70
        /**
 
71
         * @brief Commands available to use in the field \c sharedSegmentMsg.command.
 
72
         */
 
73
        enum pcsc_msg_commands
 
74
        {
 
75
                SCARD_ESTABLISH_CONTEXT = 0x01,
 
76
                SCARD_RELEASE_CONTEXT = 0x02,
 
77
                SCARD_LIST_READERS = 0x03,
 
78
                SCARD_CONNECT = 0x04,
 
79
                SCARD_RECONNECT = 0x05,
 
80
                SCARD_DISCONNECT = 0x06,
 
81
                SCARD_BEGIN_TRANSACTION = 0x07,
 
82
                SCARD_END_TRANSACTION = 0x08,
 
83
                SCARD_TRANSMIT = 0x09,
 
84
                SCARD_CONTROL = 0x0A,
 
85
                SCARD_STATUS = 0x0B,
 
86
                SCARD_GET_STATUS_CHANGE = 0x0C,
 
87
                SCARD_CANCEL = 0x0D,
 
88
                SCARD_CANCEL_TRANSACTION = 0x0E,
 
89
                SCARD_GET_ATTRIB = 0x0F,
 
90
                SCARD_SET_ATTRIB = 0x10
 
91
        };
 
92
 
 
93
        /**
 
94
         * @brief Information transmitted in \c CMD_VERSION Messages.
 
95
         */
 
96
        struct version_struct
 
97
        {
 
98
                int major;
 
99
                int minor;
 
100
                LONG rv;
 
101
        };
 
102
        typedef struct version_struct version_struct;
 
103
 
 
104
        struct client_struct
 
105
        {
 
106
                SCARDCONTEXT hContext;
 
107
        };
 
108
        typedef struct client_struct client_struct;
 
109
 
 
110
        /**
 
111
         * @brief Information contained in \c SCARD_ESTABLISH_CONTEXT Messages.
 
112
         *
 
113
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
114
         */
 
115
        struct establish_struct
 
116
        {
 
117
                DWORD dwScope;
 
118
                SCARDCONTEXT phContext;
 
119
                LONG rv;
 
120
        };
 
121
        typedef struct establish_struct establish_struct;
 
122
 
 
123
        /**
 
124
         * @brief Information contained in \c SCARD_RELEASE_CONTEXT Messages.
 
125
         *
 
126
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
127
         */
 
128
        struct release_struct
 
129
        {
 
130
                SCARDCONTEXT hContext;
 
131
                LONG rv;
 
132
        };
 
133
        typedef struct release_struct release_struct;
 
134
 
 
135
        /**
 
136
         * @brief contained in \c SCARD_CONNECT Messages.
 
137
         *
 
138
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
139
         */
 
140
        struct connect_struct
 
141
        {
 
142
                SCARDCONTEXT hContext;
 
143
                char szReader[MAX_READERNAME];
 
144
                DWORD dwShareMode;
 
145
                DWORD dwPreferredProtocols;
 
146
                SCARDHANDLE phCard;
 
147
                DWORD pdwActiveProtocol;
 
148
                LONG rv;
 
149
        };
 
150
        typedef struct connect_struct connect_struct;
 
151
 
 
152
        /**
 
153
         * @brief contained in \c SCARD_RECONNECT Messages.
 
154
         *
 
155
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
156
         */
 
157
        struct reconnect_struct
 
158
        {
 
159
                SCARDHANDLE hCard;
 
160
                DWORD dwShareMode;
 
161
                DWORD dwPreferredProtocols;
 
162
                DWORD dwInitialization;
 
163
                DWORD pdwActiveProtocol;
 
164
                LONG rv;
 
165
        };
 
166
        typedef struct reconnect_struct reconnect_struct;
 
167
 
 
168
        /**
 
169
         * @brief contained in \c SCARD_DISCONNECT Messages.
 
170
         *
 
171
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
172
         */
 
173
        struct disconnect_struct
 
174
        {
 
175
                SCARDHANDLE hCard;
 
176
                DWORD dwDisposition;
 
177
                LONG rv;
 
178
        };
 
179
        typedef struct disconnect_struct disconnect_struct;
 
180
 
 
181
        /**
 
182
         * @brief contained in \c SCARD_BEGIN_TRANSACTION Messages.
 
183
         *
 
184
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
185
         */
 
186
        struct begin_struct
 
187
        {
 
188
                SCARDHANDLE hCard;
 
189
                LONG rv;
 
190
        };
 
191
        typedef struct begin_struct begin_struct;
 
192
 
 
193
        /**
 
194
         * @brief contained in \c SCARD_END_TRANSACTION Messages.
 
195
         *
 
196
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
197
         */
 
198
        struct end_struct
 
199
        {
 
200
                SCARDHANDLE hCard;
 
201
                DWORD dwDisposition;
 
202
                LONG rv;
 
203
        };
 
204
        typedef struct end_struct end_struct;
 
205
 
 
206
        /**
 
207
         * @brief contained in \c SCARD_CANCEL Messages.
 
208
         *
 
209
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
210
         */
 
211
        struct cancel_struct
 
212
        {
 
213
                SCARDHANDLE hCard;
 
214
                LONG rv;
 
215
        };
 
216
        typedef struct cancel_struct cancel_struct;
 
217
 
 
218
        /**
 
219
         * @brief contained in \c SCARD_STATUS Messages.
 
220
         *
 
221
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
222
         */
 
223
        struct status_struct
 
224
        {
 
225
                SCARDHANDLE hCard;
 
226
                char mszReaderNames[MAX_READERNAME];
 
227
                DWORD pcchReaderLen;
 
228
                DWORD pdwState;
 
229
                DWORD pdwProtocol;
 
230
                UCHAR pbAtr[MAX_ATR_SIZE];
 
231
                DWORD pcbAtrLen;
 
232
                LONG rv;
 
233
        };
 
234
        typedef struct status_struct status_struct;
 
235
 
 
236
        /**
 
237
         * @brief contained in \c SCARD_TRANSMIT Messages.
 
238
         *
 
239
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
240
         */
 
241
        struct transmit_struct
 
242
        {
 
243
                SCARDHANDLE hCard;
 
244
                SCARD_IO_REQUEST pioSendPci;
 
245
                UCHAR pbSendBuffer[MAX_BUFFER_SIZE];
 
246
                DWORD cbSendLength;
 
247
                SCARD_IO_REQUEST pioRecvPci;
 
248
                BYTE pbRecvBuffer[MAX_BUFFER_SIZE];
 
249
                DWORD pcbRecvLength;
 
250
                LONG rv;
 
251
        };
 
252
        typedef struct transmit_struct transmit_struct;
 
253
 
 
254
        /**
 
255
         * @brief contained in \c SCARD_CONTROL Messages.
 
256
         *
 
257
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
258
         */
 
259
        struct control_struct
 
260
        {
 
261
                SCARDHANDLE hCard;
 
262
                DWORD dwControlCode;
 
263
                UCHAR pbSendBuffer[MAX_BUFFER_SIZE];
 
264
                DWORD cbSendLength;
 
265
                UCHAR pbRecvBuffer[MAX_BUFFER_SIZE];
 
266
                DWORD cbRecvLength;
 
267
                DWORD dwBytesReturned;
 
268
                LONG rv;
 
269
        };
 
270
        typedef struct control_struct control_struct;
 
271
 
 
272
        /**
 
273
         * @brief contained in \c SCARD_GET_ATTRIB and \c  Messages.
 
274
         *
 
275
         * These data are passed throw the field \c sharedSegmentMsg.data.
 
276
         */
 
277
        struct getset_struct
 
278
        {
 
279
                SCARDHANDLE hCard;
 
280
                DWORD dwAttrId;
 
281
                UCHAR pbAttr[MAX_BUFFER_SIZE];
 
282
                DWORD cbAttrLen;
 
283
                LONG rv;
 
284
        };
 
285
        typedef struct getset_struct getset_struct;
 
286
 
 
287
        /*
 
288
         * Now some function definitions 
 
289
         */
 
290
 
 
291
        int SHMClientRead(psharedSegmentMsg, DWORD, int);
 
292
        int SHMClientSetupSession(PDWORD);
 
293
        int SHMClientCloseSession(DWORD);
 
294
        int SHMInitializeCommonSegment(void);
 
295
        int SHMProcessEventsContext(PDWORD, psharedSegmentMsg, int);
 
296
        int SHMProcessEventsServer(PDWORD, int);
 
297
        int SHMMessageSend(psharedSegmentMsg, int, int);
 
298
        int SHMMessageReceive(psharedSegmentMsg, int, int);
 
299
        int WrapSHMWrite(unsigned int, DWORD, unsigned int,
 
300
                unsigned int, void *);
 
301
        void SHMCleanupSharedSegment(int, char *);
 
302
 
 
303
#ifdef __cplusplus
 
304
}
 
305
#endif
 
306
 
 
307
#endif