2
* MUSCLE SmartCard Development ( http://www.linuxnet.com )
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>
9
* $Id: winscard_msg.h 1695 2005-10-29 16:27:33Z rousseau $
14
* @brief This defines some structures and \#defines to be used over
15
* the transport layer.
18
#ifndef __winscard_msg_h__
19
#define __winscard_msg_h__
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
32
* @brief General structure for client/serve message data exchange.
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
42
typedef struct rxSharedSegment
44
unsigned int mtype; /** one of the \c pcsc_adm_commands */
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 */
50
unsigned char key[PCSCLITE_MSG_KEY_LEN];
51
unsigned char data[PCSCLITE_MAX_MESSAGE_SIZE];
53
sharedSegmentMsg, *psharedSegmentMsg;
56
* Command types available to use in the field \c sharedSegmentMsg.mtype.
58
enum pcsc_adm_commands
62
CMD_SERVER_DIED = 0xF3,
63
CMD_CLIENT_DIED = 0xF4,
64
CMD_READER_EVENT = 0xF5,
71
* @brief Commands available to use in the field \c sharedSegmentMsg.command.
73
enum pcsc_msg_commands
75
SCARD_ESTABLISH_CONTEXT = 0x01,
76
SCARD_RELEASE_CONTEXT = 0x02,
77
SCARD_LIST_READERS = 0x03,
79
SCARD_RECONNECT = 0x05,
80
SCARD_DISCONNECT = 0x06,
81
SCARD_BEGIN_TRANSACTION = 0x07,
82
SCARD_END_TRANSACTION = 0x08,
83
SCARD_TRANSMIT = 0x09,
86
SCARD_GET_STATUS_CHANGE = 0x0C,
88
SCARD_CANCEL_TRANSACTION = 0x0E,
89
SCARD_GET_ATTRIB = 0x0F,
90
SCARD_SET_ATTRIB = 0x10
94
* @brief Information transmitted in \c CMD_VERSION Messages.
102
typedef struct version_struct version_struct;
106
SCARDCONTEXT hContext;
108
typedef struct client_struct client_struct;
111
* @brief Information contained in \c SCARD_ESTABLISH_CONTEXT Messages.
113
* These data are passed throw the field \c sharedSegmentMsg.data.
115
struct establish_struct
118
SCARDCONTEXT phContext;
121
typedef struct establish_struct establish_struct;
124
* @brief Information contained in \c SCARD_RELEASE_CONTEXT Messages.
126
* These data are passed throw the field \c sharedSegmentMsg.data.
128
struct release_struct
130
SCARDCONTEXT hContext;
133
typedef struct release_struct release_struct;
136
* @brief contained in \c SCARD_CONNECT Messages.
138
* These data are passed throw the field \c sharedSegmentMsg.data.
140
struct connect_struct
142
SCARDCONTEXT hContext;
143
char szReader[MAX_READERNAME];
145
DWORD dwPreferredProtocols;
147
DWORD pdwActiveProtocol;
150
typedef struct connect_struct connect_struct;
153
* @brief contained in \c SCARD_RECONNECT Messages.
155
* These data are passed throw the field \c sharedSegmentMsg.data.
157
struct reconnect_struct
161
DWORD dwPreferredProtocols;
162
DWORD dwInitialization;
163
DWORD pdwActiveProtocol;
166
typedef struct reconnect_struct reconnect_struct;
169
* @brief contained in \c SCARD_DISCONNECT Messages.
171
* These data are passed throw the field \c sharedSegmentMsg.data.
173
struct disconnect_struct
179
typedef struct disconnect_struct disconnect_struct;
182
* @brief contained in \c SCARD_BEGIN_TRANSACTION Messages.
184
* These data are passed throw the field \c sharedSegmentMsg.data.
191
typedef struct begin_struct begin_struct;
194
* @brief contained in \c SCARD_END_TRANSACTION Messages.
196
* These data are passed throw the field \c sharedSegmentMsg.data.
204
typedef struct end_struct end_struct;
207
* @brief contained in \c SCARD_CANCEL Messages.
209
* These data are passed throw the field \c sharedSegmentMsg.data.
216
typedef struct cancel_struct cancel_struct;
219
* @brief contained in \c SCARD_STATUS Messages.
221
* These data are passed throw the field \c sharedSegmentMsg.data.
226
char mszReaderNames[MAX_READERNAME];
230
UCHAR pbAtr[MAX_ATR_SIZE];
234
typedef struct status_struct status_struct;
237
* @brief contained in \c SCARD_TRANSMIT Messages.
239
* These data are passed throw the field \c sharedSegmentMsg.data.
241
struct transmit_struct
244
SCARD_IO_REQUEST pioSendPci;
245
UCHAR pbSendBuffer[MAX_BUFFER_SIZE];
247
SCARD_IO_REQUEST pioRecvPci;
248
BYTE pbRecvBuffer[MAX_BUFFER_SIZE];
252
typedef struct transmit_struct transmit_struct;
255
* @brief contained in \c SCARD_CONTROL Messages.
257
* These data are passed throw the field \c sharedSegmentMsg.data.
259
struct control_struct
263
UCHAR pbSendBuffer[MAX_BUFFER_SIZE];
265
UCHAR pbRecvBuffer[MAX_BUFFER_SIZE];
267
DWORD dwBytesReturned;
270
typedef struct control_struct control_struct;
273
* @brief contained in \c SCARD_GET_ATTRIB and \c Messages.
275
* These data are passed throw the field \c sharedSegmentMsg.data.
281
UCHAR pbAttr[MAX_BUFFER_SIZE];
285
typedef struct getset_struct getset_struct;
288
* Now some function definitions
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 *);