pcsc-lite  1.8.8
Functions
winscard_msg.c File Reference

This is responsible for client/server communication. More...

#include "config.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/un.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include "misc.h"
#include "pcscd.h"
#include "winscard.h"
#include "debuglog.h"
#include "winscard_msg.h"
#include "sys_generic.h"
#include "utils.h"
#include "strlcpycat.h"

Go to the source code of this file.

Functions

char * getSocketName (void)
 
INTERNAL int ClientSetupSession (uint32_t *pdwClientID)
 Prepares a communication channel for the client to talk to the server. More...
 
INTERNAL int ClientCloseSession (uint32_t dwClientID)
 Closes the socket used by the client to communicate with the server. More...
 
INTERNAL LONG MessageReceiveTimeout (uint32_t command, void *buffer_void, uint64_t buffer_size, int32_t filedes, long timeOut)
 Called by the Client to get the reponse from the server or vice-versa. More...
 
INTERNAL LONG MessageSendWithHeader (uint32_t command, uint32_t dwClientID, uint64_t size, void *data_void)
 Wrapper for the MessageSend() function. More...
 
INTERNAL LONG MessageSend (void *buffer_void, uint64_t buffer_size, int32_t filedes)
 Sends a menssage from client to server or vice-versa. More...
 
INTERNAL LONG 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. More...
 

Detailed Description

This is responsible for client/server communication.

A file based socket (commonSocket) is used to send/receive only messages among clients and server.
The messages' data are passed throw a memory mapped file: sharedSegmentMsg.

Definition in file winscard_msg.c.

Function Documentation

INTERNAL int 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 145 of file winscard_msg.c.

Referenced by SCardCancel().

INTERNAL int 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 90 of file winscard_msg.c.

Referenced by SCardCancel(), and SCardEstablishContextTH().

INTERNAL LONG 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
SCARD_S_SUCCESSSuccess.
SCARD_F_COMM_ERRORSocket is closed.
SCARD_F_COMM_ERRORA signal was received.

Definition at line 422 of file winscard_msg.c.

References SCARD_F_COMM_ERROR, and SCARD_S_SUCCESS.

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

INTERNAL LONG MessageReceiveTimeout ( uint32_t  command,
void *  buffer_void,
uint64_t  buffer_size,
int32_t  filedes,
long  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
SCARD_S_SUCCESSSuccess.
SCARD_E_TIMEOUTTimeout.
SCARD_F_COMM_ERRORSocket is closed.
SCARD_F_COMM_ERRORA signal was received.

Definition at line 166 of file winscard_msg.c.

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

Referenced by SCardEstablishContextTH(), and SCardGetStatusChange().

INTERNAL LONG 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.
Return values
SCARD_S_SUCCESSSuccess
SCARD_E_TIMEOUTTimeout.
SCARD_F_COMM_ERRORSocket is closed.
SCARD_F_COMM_ERRORA signal was received.

Definition at line 324 of file winscard_msg.c.

References SCARD_E_NO_SERVICE, SCARD_E_TIMEOUT, SCARD_F_COMM_ERROR, and SCARD_S_SUCCESS.

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

INTERNAL LONG 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]data_voidData to be sent.
Returns
Same error codes as MessageSend().

Definition at line 288 of file winscard_msg.c.

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

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