pcsc-lite  1.8.20
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 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 
47 #define PROTOCOL_VERSION_MAJOR 4
48 
49 #define PROTOCOL_VERSION_MINOR 3
50 
55  {
56  int32_t major;
57  int32_t minor;
58  uint32_t rv;
59  };
60 
64  struct rxHeader
65  {
66  uint32_t size;
67  uint32_t command;
68  };
69 
74  {
75  CMD_ENUM_FIRST,
79  SCARD_CONNECT = 0x04,
80  SCARD_RECONNECT = 0x05,
84  SCARD_TRANSMIT = 0x09,
85  SCARD_CONTROL = 0x0A,
86  SCARD_STATUS = 0x0B,
88  SCARD_CANCEL = 0x0D,
92  CMD_VERSION = 0x11,
96  CMD_ENUM_LAST
97  };
98 
100  {
101  uint32_t hContext;
102  };
103 
108  {
109  uint32_t timeOut;
110  uint32_t rv;
111  };
112 
119  {
120  uint32_t dwScope;
121  uint32_t hContext;
122  uint32_t rv;
123  };
124 
131  {
132  uint32_t hContext;
133  uint32_t rv;
134  };
135 
142  {
143  uint32_t hContext;
144  char szReader[MAX_READERNAME];
145  uint32_t dwShareMode;
146  uint32_t dwPreferredProtocols;
147  int32_t hCard;
148  uint32_t dwActiveProtocol;
149  uint32_t rv;
150  };
151 
158  {
159  int32_t hCard;
160  uint32_t dwShareMode;
161  uint32_t dwPreferredProtocols;
162  uint32_t dwInitialization;
163  uint32_t dwActiveProtocol;
164  uint32_t rv;
165  };
166 
173  {
174  int32_t hCard;
175  uint32_t dwDisposition;
176  uint32_t rv;
177  };
178 
185  {
186  int32_t hCard;
187  uint32_t rv;
188  };
189 
195  struct end_struct
196  {
197  int32_t hCard;
198  uint32_t dwDisposition;
199  uint32_t rv;
200  };
201 
208  {
209  int32_t hContext;
210  uint32_t rv;
211  };
212 
219  {
220  int32_t hCard;
221  uint32_t rv;
222  };
223 
230  {
231  int32_t hCard;
232  uint32_t ioSendPciProtocol;
233  uint32_t ioSendPciLength;
234  uint32_t cbSendLength;
235  uint32_t ioRecvPciProtocol;
236  uint32_t ioRecvPciLength;
237  uint32_t pcbRecvLength;
238  uint32_t rv;
239  };
240 
247  {
248  int32_t hCard;
249  uint32_t dwControlCode;
250  uint32_t cbSendLength;
251  uint32_t cbRecvLength;
252  uint32_t dwBytesReturned;
253  uint32_t rv;
254  };
255 
262  {
263  int32_t hCard;
264  uint32_t dwAttrId;
265  uint8_t pbAttr[MAX_BUFFER_SIZE];
266  uint32_t cbAttrLen;
267  uint32_t rv;
268  };
269 
270  /*
271  * Now some function definitions
272  */
273 
274 #ifdef PCSCD
275  int32_t InitializeSocket(void);
276  int32_t ListenExistingSocket(int fd);
277  int32_t ProcessEventsServer(/*@out@*/ uint32_t *);
278 #else
279  char *getSocketName(void);
280  int32_t ClientSetupSession(uint32_t *);
281  void ClientCloseSession(uint32_t);
282  LONG MessageReceiveTimeout(uint32_t command, /*@out@*/ void *buffer,
283  uint64_t buffer_size, int32_t filedes, long timeOut);
284  LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID,
285  uint64_t size, void *data);
286 #endif
287  LONG MessageSend(void *buffer, uint64_t buffer_size, int32_t filedes);
288  LONG MessageReceive(/*@out@*/ void *buffer, uint64_t buffer_size,
289  int32_t filedes);
290 
291 #endif
used by SCardBeginTransaction()
Definition: winscard_msg.h:82
contained in SCARD_CONNECT Messages.
Definition: winscard_msg.h:141
wait for a reader state change
Definition: winscard_msg.h:94
contained in SCARD_CANCEL Messages.
Definition: winscard_msg.h:207
contained in SCARD_TRANSMIT Messages.
Definition: winscard_msg.h:229
void ClientCloseSession(uint32_t)
Closes the socket used by the client to communicate with the server.
Definition: winscard_msg.c:172
contained in SCARD_END_TRANSACTION Messages.
Definition: winscard_msg.h:195
int32_t ClientSetupSession(uint32_t *)
Prepares a communication channel for the client to talk to the server.
Definition: winscard_msg.c:117
#define MAX_BUFFER_SIZE
Maximum Tx/Rx Buffer for short APDU.
Definition: pcsclite.h:297
INTERNAL int32_t ListenExistingSocket(int fd)
Acquires a socket passed in from systemd.
get the client/server protocol version
Definition: winscard_msg.h:92
used by SCardEstablishContext()
Definition: winscard_msg.h:76
int32_t minor
IPC minor PROTOCOL_VERSION_MINOR.
Definition: winscard_msg.h:57
used by SCardEndTransaction()
Definition: winscard_msg.h:83
uint32_t command
one of the pcsc_msg_commands
Definition: winscard_msg.h:67
used by SCardConnect()
Definition: winscard_msg.h:79
contained in SCARD_DISCONNECT Messages.
Definition: winscard_msg.h:172
Information contained in SCARD_RELEASE_CONTEXT Messages.
Definition: winscard_msg.h:130
contained in SCARD_BEGIN_TRANSACTION Messages.
Definition: winscard_msg.h:184
Information contained in SCARD_ESTABLISH_CONTEXT Messages.
Definition: winscard_msg.h:118
get the readers state
Definition: winscard_msg.h:93
LONG MessageSendWithHeader(uint32_t command, uint32_t dwClientID, uint64_t size, void *data)
Wrapper for the MessageSend() function.
Definition: winscard_msg.c:318
Information transmitted in CMD_VERSION Messages.
Definition: winscard_msg.h:54
header structure for client/server message data exchange.
Definition: winscard_msg.h:64
used by SCardReleaseContext()
Definition: winscard_msg.h:77
contained in SCARD_STATUS Messages.
Definition: winscard_msg.h:218
contained in SCARD_RECONNECT Messages.
Definition: winscard_msg.h:157
uint32_t timeOut
timeout in ms
Definition: winscard_msg.h:109
contained in SCARD_GET_ATTRIB and Messages.
Definition: winscard_msg.h:261
Information contained in CMD_WAIT_READER_STATE_CHANGE Messages.
Definition: winscard_msg.h:107
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:80
used by SCardTransmit()
Definition: winscard_msg.h:84
pcsc_msg_commands
Commands available to use in the field sharedSegmentMsg.command.
Definition: winscard_msg.h:73
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:193
stop waiting for a reader state change
Definition: winscard_msg.h:95
uint32_t size
size of the message excluding this header
Definition: winscard_msg.h:66
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:354
used by SCardControl()
Definition: winscard_msg.h:85
used by SCardSetAttrib()
Definition: winscard_msg.h:91
used by SCardListReaders()
Definition: winscard_msg.h:78
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Looks for messages sent by clients.
used by SCardDisconnect()
Definition: winscard_msg.h:81
contained in SCARD_CONTROL Messages.
Definition: winscard_msg.h:246
used by SCardGetAttrib()
Definition: winscard_msg.h:90
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:452
used by SCardCancel()
Definition: winscard_msg.h:88
int32_t major
IPC major PROTOCOL_VERSION_MAJOR.
Definition: winscard_msg.h:56
used by SCardStatus()
Definition: winscard_msg.h:86