pcsc-lite  2.5.0
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-2025
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
51 
52 #define PROTOCOL_VERSION_MINOR 6
53 
54 #define PROTOCOL_VERSION_MINOR_CLIENT_BACKWARD 4
55 
56 #define PROTOCOL_VERSION_MINOR_SERVER_BACKWARD 4
57 
62  {
63  int32_t major;
64  int32_t minor;
65  uint32_t rv;
66  };
67 
71  struct rxHeader
72  {
73  uint32_t size;
74  uint32_t command;
75  };
76 
81  {
82  CMD_ENUM_FIRST,
86  SCARD_CONNECT = 0x04,
87  SCARD_RECONNECT = 0x05,
91  SCARD_TRANSMIT = 0x09,
92  SCARD_CONTROL = 0x0A,
93  SCARD_STATUS = 0x0B,
95  SCARD_CANCEL = 0x0D,
99  CMD_VERSION = 0x11,
104  CMD_GET_READERS_STATE_SIZE = 0x16, /* get the size of the readers state array */
106  CMD_ENUM_LAST
107  };
108 
110  {
111  uint32_t hContext;
112  };
113 
118  {
119  uint32_t timeOut;
120  uint32_t rv;
121  };
122 
129  {
130  uint32_t dwScope;
131  uint32_t hContext;
132  uint32_t rv;
133  };
134 
141  {
142  uint32_t hContext;
143  uint32_t rv;
144  };
145 
152  {
153  uint32_t hContext;
154  char szReader[MAX_READERNAME];
155  uint32_t dwShareMode;
156  uint32_t dwPreferredProtocols;
157  int32_t hCard;
158  uint32_t dwActiveProtocol;
159  uint32_t rv;
160  };
161 
168  {
169  int32_t hCard;
170  uint32_t dwShareMode;
171  uint32_t dwPreferredProtocols;
172  uint32_t dwInitialization;
173  uint32_t dwActiveProtocol;
174  uint32_t rv;
175  };
176 
183  {
184  int32_t hCard;
185  uint32_t dwDisposition;
186  uint32_t rv;
187  };
188 
195  {
196  int32_t hCard;
197  uint32_t rv;
198  };
199 
205  struct end_struct
206  {
207  int32_t hCard;
208  uint32_t dwDisposition;
209  uint32_t rv;
210  };
211 
218  {
219  int32_t hContext;
220  uint32_t rv;
221  };
222 
229  {
230  int32_t hCard;
231  uint32_t rv;
232  };
233 
240  {
241  int32_t hCard;
242  uint32_t ioSendPciProtocol;
243  uint32_t ioSendPciLength;
244  uint32_t cbSendLength;
245  uint32_t ioRecvPciProtocol;
246  uint32_t ioRecvPciLength;
247  uint32_t pcbRecvLength;
248  uint32_t rv;
249  };
250 
257  {
258  int32_t hCard;
259  uint32_t dwControlCode;
260  uint32_t cbSendLength;
261  uint32_t cbRecvLength;
262  uint32_t dwBytesReturned;
263  uint32_t rv;
264  };
265 
272  {
273  int32_t hCard;
274  uint32_t dwAttrId;
275  uint8_t pbAttr[MAX_BUFFER_SIZE];
276  uint32_t cbAttrLen;
277  uint32_t rv;
278  };
279 
281  {
282  uint32_t readerEvents;
283  uint32_t rv;
284  };
285 
286  /*
287  * Now some function definitions
288  */
289 
290 #ifdef PCSCD
291  int32_t InitializeSocket(void);
292  int32_t ListenExistingSocket(int fd);
293  int32_t ProcessEventsServer(/*@out@*/ uint32_t *);
294 #else
295  char *getSocketName(void);
296  int32_t ClientSetupSession(uint32_t *);
297  void ClientCloseSession(uint32_t);
298  LONG MessageReceiveTimeout(uint32_t command, /*@out@*/ void *buffer,
299  uint64_t buffer_size, int32_t filedes, long timeOut);
300  LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID,
301  uint64_t size, void *data);
302 #endif
303  LONG MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes);
304  LONG MessageReceive(/*@out@*/ void *buffer, uint64_t buffer_size,
305  int32_t filedes);
306 
307 #endif
used by SCardBeginTransaction()
Definition: winscard_msg.h:89
contained in SCARD_CONNECT Messages.
Definition: winscard_msg.h:151
wait for a reader state change
Definition: winscard_msg.h:101
contained in SCARD_CANCEL Messages.
Definition: winscard_msg.h:217
contained in SCARD_TRANSMIT Messages.
Definition: winscard_msg.h:239
void ClientCloseSession(uint32_t)
Closes the socket used by the client to communicate with the server.
Definition: winscard_msg.c:175
contained in SCARD_END_TRANSACTION Messages.
Definition: winscard_msg.h:205
int32_t ClientSetupSession(uint32_t *)
Prepares a communication channel for the client to talk to the server.
Definition: winscard_msg.c:121
#define MAX_BUFFER_SIZE
Maximum Tx/Rx Buffer for short APDU.
Definition: pcsclite.h:298
get the client/server protocol version
Definition: winscard_msg.h:99
used by SCardEstablishContext()
Definition: winscard_msg.h:83
int32_t minor
IPC minor PROTOCOL_VERSION_MINOR.
Definition: winscard_msg.h:64
used by SCardEndTransaction()
Definition: winscard_msg.h:90
uint32_t command
one of the pcsc_msg_commands
Definition: winscard_msg.h:74
get the readers state array
Definition: winscard_msg.h:105
used by SCardConnect()
Definition: winscard_msg.h:86
contained in SCARD_DISCONNECT Messages.
Definition: winscard_msg.h:182
Information contained in SCARD_RELEASE_CONTEXT Messages.
Definition: winscard_msg.h:140
contained in SCARD_BEGIN_TRANSACTION Messages.
Definition: winscard_msg.h:194
Information contained in SCARD_ESTABLISH_CONTEXT Messages.
Definition: winscard_msg.h:128
get the readers state
Definition: winscard_msg.h:100
LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size, void *data)
Wrapper for the MessageSend() function.
Definition: winscard_msg.c:320
Information transmitted in CMD_VERSION Messages.
Definition: winscard_msg.h:61
header structure for client/server message data exchange.
Definition: winscard_msg.h:71
used by SCardReleaseContext()
Definition: winscard_msg.h:84
contained in SCARD_STATUS Messages.
Definition: winscard_msg.h:228
contained in SCARD_RECONNECT Messages.
Definition: winscard_msg.h:167
uint32_t timeOut
timeout in ms
Definition: winscard_msg.h:119
contained in SCARD_GET_ATTRIB and Messages.
Definition: winscard_msg.h:271
get the number of reader events
Definition: winscard_msg.h:103
Information contained in CMD_WAIT_READER_STATE_CHANGE Messages.
Definition: winscard_msg.h:117
INTERNAL int32_t InitializeSocket(void)
Prepares the communication channel used by the server to talk to the clients.
used by SCardReconnect()
Definition: winscard_msg.h:87
used by SCardTransmit()
Definition: winscard_msg.h:91
pcsc_msg_commands
Commands available to use in the field sharedSegmentMsg.command.
Definition: winscard_msg.h:80
This keeps a list of defines for pcsc-lite.
LONG MessageReceiveTimeout(uint32_t command, void *buffer, uint64_t buffer_size, int32_t filedes, long timeOut)
Called by the Client to get the response from the server or vice-versa.
Definition: winscard_msg.c:197
stop waiting for a reader state change
Definition: winscard_msg.h:102
uint32_t size
size of the message excluding this header
Definition: winscard_msg.h:73
This keeps a list of Windows(R) types.
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
used by SCardControl()
Definition: winscard_msg.h:92
used by SCardSetAttrib()
Definition: winscard_msg.h:98
used by SCardListReaders()
Definition: winscard_msg.h:85
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Looks for messages sent by clients.
used by SCardDisconnect()
Definition: winscard_msg.h:88
contained in SCARD_CONTROL Messages.
Definition: winscard_msg.h:256
used by SCardGetAttrib()
Definition: winscard_msg.h:97
LONG MessageReceive(void *buffer, uint64_t buffer_size, int32_t filedes)
Called by the Client to get the response from the server or vice-versa.
Definition: winscard_msg.c:461
used by SCardCancel()
Definition: winscard_msg.h:95
int32_t major
IPC major PROTOCOL_VERSION_MAJOR.
Definition: winscard_msg.h:63
used by SCardStatus()
Definition: winscard_msg.h:93