pcsc-lite  1.9.5
winscard_msg.h
Go to the documentation of this file.
1 /*
2  * MUSCLE SmartCard Development ( https://pcsclite.apdu.fr/ )
3  *
4  * Copyright (C) 2001-2004
5  * David Corcoran <corcoran@musclecard.com>
6  * Copyright (C) 2003-2004
7  * Damien Sauveron <damien.sauveron@labri.fr>
8  * Copyright (C) 2002-2010
9  * Ludovic Rousseau <ludovic.rousseau@free.fr>
10  *
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions
13 are met:
14 
15 1. Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 3. The name of the author may not be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
41 #ifndef __winscard_msg_h__
42 #define __winscard_msg_h__
43 
44 #include <stdint.h>
45 
46 #include "pcsclite.h"
47 #include "wintypes.h"
48 
50 #define PROTOCOL_VERSION_MAJOR 4
52 #define PROTOCOL_VERSION_MINOR 4
53 
58  {
59  int32_t major;
60  int32_t minor;
61  uint32_t rv;
62  };
63 
67  struct rxHeader
68  {
69  uint32_t size;
70  uint32_t command;
71  };
72 
77  {
78  CMD_ENUM_FIRST,
82  SCARD_CONNECT = 0x04,
83  SCARD_RECONNECT = 0x05,
87  SCARD_TRANSMIT = 0x09,
88  SCARD_CONTROL = 0x0A,
89  SCARD_STATUS = 0x0B,
91  SCARD_CANCEL = 0x0D,
95  CMD_VERSION = 0x11,
99  CMD_ENUM_LAST
100  };
101 
103  {
104  uint32_t hContext;
105  };
106 
111  {
112  uint32_t timeOut;
113  uint32_t rv;
114  };
115 
122  {
123  uint32_t dwScope;
124  uint32_t hContext;
125  uint32_t rv;
126  };
127 
134  {
135  uint32_t hContext;
136  uint32_t rv;
137  };
138 
145  {
146  uint32_t hContext;
147  char szReader[MAX_READERNAME];
148  uint32_t dwShareMode;
149  uint32_t dwPreferredProtocols;
150  int32_t hCard;
151  uint32_t dwActiveProtocol;
152  uint32_t rv;
153  };
154 
161  {
162  int32_t hCard;
163  uint32_t dwShareMode;
164  uint32_t dwPreferredProtocols;
165  uint32_t dwInitialization;
166  uint32_t dwActiveProtocol;
167  uint32_t rv;
168  };
169 
176  {
177  int32_t hCard;
178  uint32_t dwDisposition;
179  uint32_t rv;
180  };
181 
188  {
189  int32_t hCard;
190  uint32_t rv;
191  };
192 
198  struct end_struct
199  {
200  int32_t hCard;
201  uint32_t dwDisposition;
202  uint32_t rv;
203  };
204 
211  {
212  int32_t hContext;
213  uint32_t rv;
214  };
215 
222  {
223  int32_t hCard;
224  uint32_t rv;
225  };
226 
233  {
234  int32_t hCard;
235  uint32_t ioSendPciProtocol;
236  uint32_t ioSendPciLength;
237  uint32_t cbSendLength;
238  uint32_t ioRecvPciProtocol;
239  uint32_t ioRecvPciLength;
240  uint32_t pcbRecvLength;
241  uint32_t rv;
242  };
243 
250  {
251  int32_t hCard;
252  uint32_t dwControlCode;
253  uint32_t cbSendLength;
254  uint32_t cbRecvLength;
255  uint32_t dwBytesReturned;
256  uint32_t rv;
257  };
258 
265  {
266  int32_t hCard;
267  uint32_t dwAttrId;
268  uint8_t pbAttr[MAX_BUFFER_SIZE];
269  uint32_t cbAttrLen;
270  uint32_t rv;
271  };
272 
273  /*
274  * Now some function definitions
275  */
276 
277 #ifdef PCSCD
278  int32_t InitializeSocket(void);
279  int32_t ListenExistingSocket(int fd);
280  int32_t ProcessEventsServer(/*@out@*/ uint32_t *);
281 #else
282  char *getSocketName(void);
283  int32_t ClientSetupSession(uint32_t *);
284  void ClientCloseSession(uint32_t);
285  LONG MessageReceiveTimeout(uint32_t command, /*@out@*/ void *buffer,
286  uint64_t buffer_size, int32_t filedes, long timeOut);
287  LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID,
288  uint64_t size, void *data);
289 #endif
290  LONG MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes);
291  LONG MessageReceive(/*@out@*/ void *buffer, uint64_t buffer_size,
292  int32_t filedes);
293 
294 #endif
This keeps a list of defines for pcsc-lite.
#define MAX_BUFFER_SIZE
Maximum Tx/Rx Buffer for short APDU.
Definition: pcsclite.h:297
contained in SCARD_BEGIN_TRANSACTION Messages.
Definition: winscard_msg.h:188
contained in SCARD_CANCEL Messages.
Definition: winscard_msg.h:211
contained in SCARD_CONNECT Messages.
Definition: winscard_msg.h:145
contained in SCARD_CONTROL Messages.
Definition: winscard_msg.h:250
contained in SCARD_DISCONNECT Messages.
Definition: winscard_msg.h:176
contained in SCARD_END_TRANSACTION Messages.
Definition: winscard_msg.h:199
Information contained in SCARD_ESTABLISH_CONTEXT Messages.
Definition: winscard_msg.h:122
contained in SCARD_GET_ATTRIB and Messages.
Definition: winscard_msg.h:265
contained in SCARD_RECONNECT Messages.
Definition: winscard_msg.h:161
Information contained in SCARD_RELEASE_CONTEXT Messages.
Definition: winscard_msg.h:134
header structure for client/server message data exchange.
Definition: winscard_msg.h:68
uint32_t size
size of the message excluding this header
Definition: winscard_msg.h:69
uint32_t command
one of the pcsc_msg_commands
Definition: winscard_msg.h:70
contained in SCARD_STATUS Messages.
Definition: winscard_msg.h:222
contained in SCARD_TRANSMIT Messages.
Definition: winscard_msg.h:233
Information transmitted in CMD_VERSION Messages.
Definition: winscard_msg.h:58
int32_t major
IPC major PROTOCOL_VERSION_MAJOR.
Definition: winscard_msg.h:59
int32_t minor
IPC minor PROTOCOL_VERSION_MINOR.
Definition: winscard_msg.h:60
Information contained in CMD_WAIT_READER_STATE_CHANGE Messages.
Definition: winscard_msg.h:111
uint32_t timeOut
timeout in ms
Definition: winscard_msg.h:112
LONG MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes)
Sends a menssage from client to server or vice-versa.
Definition: winscard_msg.c:357
LONG MessageReceive(void *buffer, uint64_t buffer_size, int32_t filedes)
Called by the Client to get the reponse from the server or vice-versa.
Definition: winscard_msg.c:457
LONG MessageReceiveTimeout(uint32_t command, void *buffer, uint64_t buffer_size, int32_t filedes, long timeOut)
Called by the Client to get the reponse from the server or vice-versa.
Definition: winscard_msg.c:197
LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size, void *data)
Wrapper for the MessageSend() function.
Definition: winscard_msg.c:320
void ClientCloseSession(uint32_t)
Closes the socket used by the client to communicate with the server.
Definition: winscard_msg.c:175
int32_t ClientSetupSession(uint32_t *)
Prepares a communication channel for the client to talk to the server.
Definition: winscard_msg.c:121
pcsc_msg_commands
Commands available to use in the field sharedSegmentMsg.command.
Definition: winscard_msg.h:77
@ SCARD_DISCONNECT
used by SCardDisconnect()
Definition: winscard_msg.h:84
@ SCARD_SET_ATTRIB
used by SCardSetAttrib()
Definition: winscard_msg.h:94
@ SCARD_RELEASE_CONTEXT
used by SCardReleaseContext()
Definition: winscard_msg.h:80
@ CMD_STOP_WAITING_READER_STATE_CHANGE
stop waiting for a reader state change
Definition: winscard_msg.h:98
@ CMD_GET_READERS_STATE
get the readers state
Definition: winscard_msg.h:96
@ SCARD_GET_STATUS_CHANGE
not used
Definition: winscard_msg.h:90
@ SCARD_CONTROL
used by SCardControl()
Definition: winscard_msg.h:88
@ CMD_VERSION
get the client/server protocol version
Definition: winscard_msg.h:95
@ CMD_WAIT_READER_STATE_CHANGE
wait for a reader state change
Definition: winscard_msg.h:97
@ SCARD_RECONNECT
used by SCardReconnect()
Definition: winscard_msg.h:83
@ SCARD_STATUS
used by SCardStatus()
Definition: winscard_msg.h:89
@ SCARD_GET_ATTRIB
used by SCardGetAttrib()
Definition: winscard_msg.h:93
@ SCARD_BEGIN_TRANSACTION
used by SCardBeginTransaction()
Definition: winscard_msg.h:85
@ SCARD_TRANSMIT
used by SCardTransmit()
Definition: winscard_msg.h:87
@ SCARD_LIST_READERS
used by SCardListReaders()
Definition: winscard_msg.h:81
@ SCARD_END_TRANSACTION
used by SCardEndTransaction()
Definition: winscard_msg.h:86
@ SCARD_CANCEL
used by SCardCancel()
Definition: winscard_msg.h:91
@ SCARD_CANCEL_TRANSACTION
not used
Definition: winscard_msg.h:92
@ SCARD_CONNECT
used by SCardConnect()
Definition: winscard_msg.h:82
@ SCARD_ESTABLISH_CONTEXT
used by SCardEstablishContext()
Definition: winscard_msg.h:79
INTERNAL int32_t InitializeSocket(void)
Prepares the communication channel used by the server to talk to the clients.
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Looks for messages sent by clients.
This keeps a list of Windows(R) types.