#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 "misc.h"
#include "pcscd.h"
#include "winscard.h"
#include "debug.h"
#include "winscard_msg.h"
#include "sys_generic.h"
#include "utils.h"
Go to the source code of this file.
Functions | |
INTERNAL int32_t | SHMClientRead (psharedSegmentMsg msgStruct, uint32_t dwClientID, int32_t blockamount) |
Wrapper for the SHMMessageReceive() function. | |
INTERNAL int | SHMClientSetupSession (uint32_t *pdwClientID) |
Prepares a communication channel for the client to talk to the server. | |
INTERNAL int | SHMClientCloseSession (uint32_t dwClientID) |
Closes the socket used by the client to communicate with the server. | |
INTERNAL int32_t | SHMMessageSend (void *buffer_void, uint64_t buffer_size, int32_t filedes, int32_t blockAmount) |
Sends a menssage from client to server or vice-versa. | |
INTERNAL int32_t | SHMMessageReceive (void *buffer_void, uint64_t buffer_size, int32_t filedes, int32_t blockAmount) |
Called by the Client to get the reponse from the server or vice-versa. | |
INTERNAL int32_t | WrapSHMWrite (uint32_t command, uint32_t dwClientID, uint64_t size, uint32_t blockAmount, void *data_void) |
Wrapper for the SHMMessageSend() function. | |
INTERNAL void | SHMCleanupSharedSegment (int sockValue, const char *pcFilePath) |
Closes the communications channel used by the server to talk to the clients. |
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.
INTERNAL void SHMCleanupSharedSegment | ( | int | sockValue, | |
const char * | pcFilePath | |||
) |
Closes the communications channel used by the server to talk to the clients.
The socket used is closed and the file it is bound to is removed.
[in] | sockValue | Socket to be closed. |
[in] | pcFilePath | File used by the socket. |
Definition at line 478 of file winscard_msg.c.
References SYS_CloseFile(), and SYS_RemoveFile().
Referenced by SHMInitializeCommonSegment().
INTERNAL int SHMClientCloseSession | ( | uint32_t | dwClientID | ) |
Closes the socket used by the client to communicate with the server.
[in] | dwClientID | Client socket handle to be closed. |
0 | Success. |
Definition at line 122 of file winscard_msg.c.
References SYS_CloseFile().
Referenced by ContextThread().
INTERNAL int32_t SHMClientRead | ( | psharedSegmentMsg | msgStruct, | |
uint32_t | dwClientID, | |||
int32_t | blockamount | |||
) |
Wrapper for the SHMMessageReceive() function.
Called by clients to read the server responses.
[out] | msgStruct | Message read. |
[in] | dwClientID | Client socket handle. |
[in] | blockamount | Timeout in milliseconds. |
Definition at line 57 of file winscard_msg.c.
References SHMMessageReceive().
Referenced by SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContextTH(), SCardReconnect(), SCardReleaseContext(), SCardStatus(), and SCardTransmit().
INTERNAL int SHMClientSetupSession | ( | 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
.
[out] | pdwClientID | Client Connection ID. |
0 | Success. | |
-1 | Can not create the socket. | |
-1 | The socket can not open a connection. | |
-1 | Can not set the socket to non-blocking. |
Definition at line 75 of file winscard_msg.c.
References SYS_CloseFile().
Referenced by SCardEstablishContextTH().
INTERNAL int32_t SHMMessageReceive | ( | void * | buffer_void, | |
uint64_t | buffer_size, | |||
int32_t | filedes, | |||
int32_t | blockAmount | |||
) |
Called by the Client to get the reponse from the server or vice-versa.
Reads the message from the file filedes
.
[out] | buffer_void | Message read. |
[in] | buffer_size | Size to read |
[in] | filedes | Socket handle. |
[in] | blockAmount | Timeout in milliseconds. |
0 | Success. | |
-1 | Timeout. | |
-1 | Socket is closed. | |
-1 | A signal was received. |
Definition at line 268 of file winscard_msg.c.
References SCARD_S_SUCCESS, and SCardCheckDaemonAvailability().
Referenced by MSGFunctionDemarshall(), SCardControl(), SCardEstablishContextTH(), SCardTransmit(), SHMClientRead(), and SHMProcessEventsContext().
INTERNAL int32_t SHMMessageSend | ( | void * | buffer_void, | |
uint64_t | buffer_size, | |||
int32_t | filedes, | |||
int32_t | blockAmount | |||
) |
Sends a menssage from client to server or vice-versa.
Writes the message in the shared file filedes
.
[in] | buffer_void | Message to be sent. |
[in] | buffer_size | Size of the message to send |
[in] | filedes | Socket handle. |
[in] | blockAmount | Timeout in milliseconds. |
0 | Success | |
-1 | Timeout. | |
-1 | Socket is closed. | |
-1 | A signal was received. |
Definition at line 143 of file winscard_msg.c.
Referenced by ContextThread(), MSGFunctionDemarshall(), SCardEstablishContextTH(), and WrapSHMWrite().
INTERNAL int32_t WrapSHMWrite | ( | uint32_t | command, | |
uint32_t | dwClientID, | |||
uint64_t | size, | |||
uint32_t | blockAmount, | |||
void * | data_void | |||
) |
Wrapper for the SHMMessageSend() 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.
[in] | command | Command to be sent. |
[in] | dwClientID | Client socket handle. |
[in] | size | Size of the message (data ). |
[in] | blockAmount | Timeout to the operation in ms. |
[in] | data_void | Data to be sent. |
Definition at line 412 of file winscard_msg.c.
References rxSharedSegment::date, SCARD_CONTROL_EXTENDED, SCARD_TRANSMIT, SCARD_TRANSMIT_EXTENDED, SHMMessageSend(), and rxSharedSegment::user_id.
Referenced by SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContextTH(), SCardReconnect(), SCardReleaseContext(), SCardStatus(), and SCardTransmit().