pcsc-lite  1.8.11
winscard_msg.h
Go to the documentation of this file.
1 /*
2  * MUSCLE SmartCard Development ( http://pcsclite.alioth.debian.org/pcsclite.html )
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 Changes to this license can be made only by the copyright author with
24 explicit written consent.
25 
26 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id: winscard_msg.h 6851 2014-02-14 15:43:32Z rousseau $
38  */
39 
46 #ifndef __winscard_msg_h__
47 #define __winscard_msg_h__
48 
49 #include <stdint.h>
50 
52 #define PROTOCOL_VERSION_MAJOR 4
53 
54 #define PROTOCOL_VERSION_MINOR 3
55 
60  {
61  int32_t major;
62  int32_t minor;
63  uint32_t rv;
64  };
65 
69  struct rxHeader
70  {
71  uint32_t size;
72  uint32_t command;
73  };
74 
79  {
80  CMD_ENUM_FIRST,
84  SCARD_CONNECT = 0x04,
85  SCARD_RECONNECT = 0x05,
89  SCARD_TRANSMIT = 0x09,
90  SCARD_CONTROL = 0x0A,
91  SCARD_STATUS = 0x0B,
93  SCARD_CANCEL = 0x0D,
97  CMD_VERSION = 0x11,
101  CMD_ENUM_LAST
102  };
103 
105  {
106  uint32_t hContext;
107  };
108 
113  {
114  uint32_t timeOut;
115  uint32_t rv;
116  };
117 
124  {
125  uint32_t dwScope;
126  uint32_t hContext;
127  uint32_t rv;
128  };
129 
136  {
137  uint32_t hContext;
138  uint32_t rv;
139  };
140 
147  {
148  uint32_t hContext;
149  char szReader[MAX_READERNAME];
150  uint32_t dwShareMode;
151  uint32_t dwPreferredProtocols;
152  int32_t hCard;
153  uint32_t dwActiveProtocol;
154  uint32_t rv;
155  };
156 
163  {
164  int32_t hCard;
165  uint32_t dwShareMode;
166  uint32_t dwPreferredProtocols;
167  uint32_t dwInitialization;
168  uint32_t dwActiveProtocol;
169  uint32_t rv;
170  };
171 
178  {
179  int32_t hCard;
180  uint32_t dwDisposition;
181  uint32_t rv;
182  };
183 
190  {
191  int32_t hCard;
192  uint32_t rv;
193  };
194 
200  struct end_struct
201  {
202  int32_t hCard;
203  uint32_t dwDisposition;
204  uint32_t rv;
205  };
206 
213  {
214  int32_t hContext;
215  uint32_t rv;
216  };
217 
224  {
225  int32_t hCard;
226  uint32_t rv;
227  };
228 
235  {
236  int32_t hCard;
237  uint32_t ioSendPciProtocol;
238  uint32_t ioSendPciLength;
239  uint32_t cbSendLength;
240  uint32_t ioRecvPciProtocol;
241  uint32_t ioRecvPciLength;
242  uint32_t pcbRecvLength;
243  uint32_t rv;
244  };
245 
252  {
253  int32_t hCard;
254  uint32_t dwControlCode;
255  uint32_t cbSendLength;
256  uint32_t cbRecvLength;
257  uint32_t dwBytesReturned;
258  uint32_t rv;
259  };
260 
267  {
268  int32_t hCard;
269  uint32_t dwAttrId;
270  uint8_t pbAttr[MAX_BUFFER_SIZE];
271  uint32_t cbAttrLen;
272  uint32_t rv;
273  };
274 
275  /*
276  * Now some function definitions
277  */
278 
279 #ifdef PCSCD
280  int32_t InitializeSocket(void);
281  int32_t ListenExistingSocket(int fd);
282  int32_t ProcessEventsServer(/*@out@*/ uint32_t *);
283 #else
284  char *getSocketName(void);
285  int32_t ClientSetupSession(uint32_t *);
286  int32_t ClientCloseSession(uint32_t);
287  LONG MessageReceiveTimeout(uint32_t command, /*@out@*/ void *buffer,
288  uint64_t buffer_size, int32_t filedes, long timeOut);
289  LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID,
290  uint64_t size, void *data);
291 #endif
292  LONG MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes);
293  LONG MessageReceive(/*@out@*/ void *buffer, uint64_t buffer_size,
294  int32_t filedes);
295 
296 #endif
used by SCardBeginTransaction()
Definition: winscard_msg.h:87
contained in SCARD_CONNECT Messages.
Definition: winscard_msg.h:146
wait for a reader state change
Definition: winscard_msg.h:99
contained in SCARD_CANCEL Messages.
Definition: winscard_msg.h:212
contained in SCARD_TRANSMIT Messages.
Definition: winscard_msg.h:234
contained in SCARD_END_TRANSACTION Messages.
Definition: winscard_msg.h:200
int32_t ClientSetupSession(uint32_t *)
Prepares a communication channel for the client to talk to the server.
Definition: winscard_msg.c:116
#define MAX_BUFFER_SIZE
Maximum Tx/Rx Buffer for short APDU.
Definition: pcsclite.h:234
INTERNAL int32_t ListenExistingSocket(int fd)
Acquires a socket passed in from systemd.
get the client/server protocol version
Definition: winscard_msg.h:97
used by SCardEstablishContext()
Definition: winscard_msg.h:81
int32_t minor
IPC minor PROTOCOL_VERSION_MINOR.
Definition: winscard_msg.h:62
used by SCardEndTransaction()
Definition: winscard_msg.h:88
uint32_t command
one of the pcsc_msg_commands
Definition: winscard_msg.h:72
used by SCardConnect()
Definition: winscard_msg.h:84
contained in SCARD_DISCONNECT Messages.
Definition: winscard_msg.h:177
Information contained in SCARD_RELEASE_CONTEXT Messages.
Definition: winscard_msg.h:135
contained in SCARD_BEGIN_TRANSACTION Messages.
Definition: winscard_msg.h:189
Information contained in SCARD_ESTABLISH_CONTEXT Messages.
Definition: winscard_msg.h:123
get the readers state
Definition: winscard_msg.h:98
LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size, void *data)
Wrapper for the MessageSend() function.
Definition: winscard_msg.c:314
Information transmitted in CMD_VERSION Messages.
Definition: winscard_msg.h:59
header structure for client/server message data exchange.
Definition: winscard_msg.h:69
used by SCardReleaseContext()
Definition: winscard_msg.h:82
contained in SCARD_STATUS Messages.
Definition: winscard_msg.h:223
contained in SCARD_RECONNECT Messages.
Definition: winscard_msg.h:162
uint32_t timeOut
timeout in ms
Definition: winscard_msg.h:114
contained in SCARD_GET_ATTRIB and Messages.
Definition: winscard_msg.h:266
Information contained in CMD_WAIT_READER_STATE_CHANGE Messages.
Definition: winscard_msg.h:112
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:85
used by SCardTransmit()
Definition: winscard_msg.h:89
pcsc_msg_commands
Commands available to use in the field sharedSegmentMsg.command.
Definition: winscard_msg.h:78
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:192
stop waiting for a reader state change
Definition: winscard_msg.h:100
uint32_t size
size of the message excluding this header
Definition: winscard_msg.h:71
int32_t ClientCloseSession(uint32_t)
Closes the socket used by the client to communicate with the server.
Definition: winscard_msg.c:171
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:350
used by SCardControl()
Definition: winscard_msg.h:90
used by SCardSetAttrib()
Definition: winscard_msg.h:96
used by SCardListReaders()
Definition: winscard_msg.h:83
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Looks for messages sent by clients.
used by SCardDisconnect()
Definition: winscard_msg.h:86
contained in SCARD_CONTROL Messages.
Definition: winscard_msg.h:251
used by SCardGetAttrib()
Definition: winscard_msg.h:95
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:448
used by SCardCancel()
Definition: winscard_msg.h:93
int32_t major
IPC major PROTOCOL_VERSION_MAJOR.
Definition: winscard_msg.h:61
used by SCardStatus()
Definition: winscard_msg.h:91