pcsc-lite 1.6.4
Data Structures | Defines | Enumerations | Functions
winscard_msg.h File Reference

This defines some structures and #defines to be used over the transport layer. More...

#include <stdint.h>
Include dependency graph for winscard_msg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  version_struct
 Information transmitted in CMD_VERSION Messages. More...
struct  rxHeader
 header structure for client/server message data exchange. More...
struct  client_struct
struct  wait_reader_state_change
 Information contained in CMD_WAIT_READER_STATE_CHANGE Messages. More...
struct  establish_struct
 Information contained in SCARD_ESTABLISH_CONTEXT Messages. More...
struct  release_struct
 Information contained in SCARD_RELEASE_CONTEXT Messages. More...
struct  connect_struct
 contained in SCARD_CONNECT Messages. More...
struct  reconnect_struct
 contained in SCARD_RECONNECT Messages. More...
struct  disconnect_struct
 contained in SCARD_DISCONNECT Messages. More...
struct  begin_struct
 contained in SCARD_BEGIN_TRANSACTION Messages. More...
struct  end_struct
 contained in SCARD_END_TRANSACTION Messages. More...
struct  cancel_struct
 contained in SCARD_CANCEL Messages. More...
struct  cancel_transaction_struct
 contained in SCARD_CANCEL_TRANSACTION Messages. More...
struct  status_struct
 contained in SCARD_STATUS Messages. More...
struct  transmit_struct
 contained in SCARD_TRANSMIT Messages. More...
struct  control_struct
 contained in SCARD_CONTROL Messages. More...
struct  getset_struct
 contained in SCARD_GET_ATTRIB and Messages. More...

Defines

#define PROTOCOL_VERSION_MAJOR   4
 Major version of the current message protocol.
#define PROTOCOL_VERSION_MINOR   0
 Minor version of the current message protocol.

Enumerations

enum  pcsc_msg_commands {
  CMD_ENUM_FIRST,
  SCARD_ESTABLISH_CONTEXT = 0x01,
  SCARD_RELEASE_CONTEXT = 0x02,
  SCARD_LIST_READERS = 0x03,
  SCARD_CONNECT = 0x04,
  SCARD_RECONNECT = 0x05,
  SCARD_DISCONNECT = 0x06,
  SCARD_BEGIN_TRANSACTION = 0x07,
  SCARD_END_TRANSACTION = 0x08,
  SCARD_TRANSMIT = 0x09,
  SCARD_CONTROL = 0x0A,
  SCARD_STATUS = 0x0B,
  SCARD_GET_STATUS_CHANGE = 0x0C,
  SCARD_CANCEL = 0x0D,
  SCARD_CANCEL_TRANSACTION = 0x0E,
  SCARD_GET_ATTRIB = 0x0F,
  SCARD_SET_ATTRIB = 0x10,
  CMD_VERSION = 0x11,
  CMD_GET_READERS_STATE = 0x12,
  CMD_WAIT_READER_STATE_CHANGE = 0x13,
  CMD_STOP_WAITING_READER_STATE_CHANGE = 0x14,
  CMD_ENUM_LAST
}
 Commands available to use in the field sharedSegmentMsg.command. More...

Functions

int32_t ClientSetupSession (uint32_t *)
 Prepares a communication channel for the client to talk to the server.
int32_t ClientCloseSession (uint32_t)
 Closes the socket used by the client to communicate with the server.
int32_t InitializeSocket (void)
 Prepares the communication channel used by the server to talk to the clients.
int32_t ProcessEventsServer (uint32_t *)
 Looks for messages sent by clients.
int32_t MessageSend (void *buffer, uint64_t buffer_size, int32_t filedes)
 Sends a menssage from client to server or vice-versa.
int32_t MessageReceive (void *buffer, uint64_t buffer_size, int32_t filedes)
 Called by the Client to get the reponse from the server or vice-versa.
int32_t MessageReceiveTimeout (uint32_t command, void *buffer, uint64_t buffer_size, int32_t filedes, int32_t timeOut)
 Called by the Client to get the reponse from the server or vice-versa.
int32_t MessageSendWithHeader (uint32_t command, uint32_t dwClientID, uint64_t size, void *data)
 Wrapper for the MessageSend() function.
void CleanupSharedSegment (int32_t, const char *)

Detailed Description

This defines some structures and #defines to be used over the transport layer.

Definition in file winscard_msg.h.


Enumeration Type Documentation

Commands available to use in the field sharedSegmentMsg.command.

Enumerator:
SCARD_ESTABLISH_CONTEXT 

used by SCardEstablishContext()

SCARD_RELEASE_CONTEXT 

used by SCardReleaseContext()

SCARD_LIST_READERS 

used by SCardListReaders()

SCARD_CONNECT 

used by SCardConnect()

SCARD_RECONNECT 

used by SCardReconnect()

SCARD_DISCONNECT 

used by SCardDisconnect()

SCARD_BEGIN_TRANSACTION 

used by SCardBeginTransaction()

SCARD_END_TRANSACTION 

used by SCardEndTransaction()

SCARD_TRANSMIT 

used by SCardTransmit()

SCARD_CONTROL 

used by SCardControl()

SCARD_STATUS 

used by SCardStatus()

SCARD_GET_STATUS_CHANGE 

used by SCardGetStatusChange()

SCARD_CANCEL 

used by SCardCancel()

SCARD_CANCEL_TRANSACTION 

used by SCardCancelTransaction()

SCARD_GET_ATTRIB 

used by SCardGetAttrib()

SCARD_SET_ATTRIB 

used by SCardSetAttrib()

CMD_VERSION 

get the client/server protocol version

CMD_GET_READERS_STATE 

get the readers state

CMD_WAIT_READER_STATE_CHANGE 

wait for a reader state change

CMD_STOP_WAITING_READER_STATE_CHANGE 

stop waiting for a reader state change

Definition at line 57 of file winscard_msg.h.


Function Documentation

int32_t ClientCloseSession ( uint32_t  dwClientID)

Closes the socket used by the client to communicate with the server.

Parameters:
[in]dwClientIDClient socket handle to be closed.
Return values:
0Success.

Definition at line 108 of file winscard_msg.c.

Referenced by SCardCancel().

int32_t ClientSetupSession ( uint32_t *  pdwClientID)

Prepares a communication channel for the client to talk to the server.

This is called by the application to create a socket for local IPC with the server. The socket is associated to the file PCSCLITE_CSOCK_NAME.

Parameters:
[out]pdwClientIDClient Connection ID.
Return values:
0Success.
-1Can not create the socket.
-1The socket can not open a connection.
-1Can not set the socket to non-blocking.

Definition at line 61 of file winscard_msg.c.

Referenced by SCardCancel(), and SCardEstablishContextTH().

int32_t InitializeSocket ( void  )

Prepares the communication channel used by the server to talk to the clients.

This is called by the server to create a socket for local IPC with the clients. The socket is associated to the file PCSCLITE_CSOCK_NAME. Each client will open a connection to this socket.

Returns:
Error code.
Return values:
0Success
-1Can not create the socket.
-1Can not bind the socket to the file PCSCLITE_CSOCK_NAME.
-1Can not put the socket in listen mode.

Definition at line 98 of file winscard_msg_srv.c.

References CleanupSharedSegment(), and commonSocket.

Here is the call graph for this function:

int32_t MessageReceive ( void *  buffer_void,
uint64_t  buffer_size,
int32_t  filedes 
)

Called by the Client to get the reponse from the server or vice-versa.

Reads the message from the file filedes.

Parameters:
[out]buffer_voidMessage read.
[in]buffer_sizeSize to read
[in]filedesSocket handle.
Return values:
0Success.
-1Socket is closed.
-1A signal was received.

Definition at line 226 of file winscard_msg.c.

Referenced by SCardBeginTransaction(), SCardCancel(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContextTH(), SCardGetStatusChange(), SCardReconnect(), SCardReleaseContext(), SCardStatus(), and SCardTransmit().

int32_t MessageReceiveTimeout ( uint32_t  command,
void *  buffer_void,
uint64_t  buffer_size,
int32_t  filedes,
int32_t  timeOut 
)

Called by the Client to get the reponse from the server or vice-versa.

Reads the message from the file filedes.

Parameters:
[in]commandone of the pcsc_msg_commands commands
[out]buffer_voidMessage read.
[in]buffer_sizeSize to read
[in]filedesSocket handle.
[in]timeOutTimeout in milliseconds.
Return values:
0Success.
-1Timeout.
-1Socket is closed.
-1A signal was received.

Definition at line 314 of file winscard_msg.c.

References SCARD_S_SUCCESS, SCardCheckDaemonAvailability(), and time_sub().

Referenced by SCardGetStatusChange().

Here is the call graph for this function:

int32_t MessageSend ( void *  buffer_void,
uint64_t  buffer_size,
int32_t  filedes 
)

Sends a menssage from client to server or vice-versa.

Writes the message in the shared file filedes.

Parameters:
[in]buffer_voidMessage to be sent.
[in]buffer_sizeSize of the message to send
[in]filedesSocket handle.
[in]timeOutTimeout in milliseconds.
Return values:
0Success
-1Timeout.
-1Socket is closed.
-1A signal was received.

Definition at line 128 of file winscard_msg.c.

Referenced by MessageSendWithHeader(), SCardControl(), and SCardTransmit().

int32_t MessageSendWithHeader ( uint32_t  command,
uint32_t  dwClientID,
uint64_t  size,
void *  data_void 
)

Wrapper for the MessageSend() function.

Called by clients to send messages to the server. The parameters command and data are set in the sharedSegmentMsg struct in order to be sent.

Parameters:
[in]commandCommand to be sent.
[in]dwClientIDClient socket handle.
[in]sizeSize of the message (data).
[in]timeOutTimeout to the operation in ms.
[in]data_voidData to be sent.
Returns:
Same error codes as MessageSend().

Definition at line 445 of file winscard_msg.c.

References rxHeader::command, MessageSend(), and rxHeader::size.

Referenced by SCardBeginTransaction(), SCardCancel(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContextTH(), SCardGetStatusChange(), SCardReconnect(), SCardReleaseContext(), SCardStatus(), and SCardTransmit().

Here is the call graph for this function:

int32_t ProcessEventsServer ( uint32_t *  pdwClientID)

Looks for messages sent by clients.

This is called by the Server's function SVCServiceRunLoop().

Parameters:
[out]pdwClientIDConnection ID used to reference the Client.
Returns:
Error code.
Return values:
0Success.
-1Error accessing the communication channel.
-2EINTR
2Timeout.

Definition at line 158 of file winscard_msg_srv.c.

References commonSocket, and ProcessCommonChannelRequest().

Referenced by SVCServiceRunLoop().

Here is the call graph for this function: