Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

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 "misc.h"
#include "pcsclite.h"
#include "winscard.h"
#include "debug.h"
#include "winscard_msg.h"
#include "sys_generic.h"

Go to the source code of this file.

Functions

INTERNAL int SHMClientRead (psharedSegmentMsg msgStruct, DWORD dwClientID, int blockamount)
 Wrapper for the SHMMessageReceive() function. More...

INTERNAL int SHMClientSetupSession (PDWORD pdwClientID)
 Prepares a communication channel for the client to talk to the server. More...

INTERNAL int SHMClientCloseSession (DWORD dwClientID)
 Closes the socket used by the client to communicate with the server. More...

INTERNAL int SHMMessageSend (void *buffer_void, size_t buffer_size, int filedes, int blockAmount)
 Sends a menssage from client to server or vice-versa. More...

INTERNAL int SHMMessageReceive (void *buffer_void, size_t buffer_size, int filedes, int blockAmount)
 Called by the Client to get the reponse from the server or vice-versa. More...

INTERNAL int WrapSHMWrite (unsigned int command, DWORD dwClientID, unsigned int size, unsigned int blockAmount, void *data_void)
 Wrapper for the SHMMessageSend() function. More...

INTERNAL void SHMCleanupSharedSegment (int sockValue, const char *pcFilePath)
 Closes the communications channel used by the server to talk to the clients. 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 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.

am[in] sockValue Socket to be closed.
am[in] pcFilePath File used by the socket.

Definition at line 449 of file winscard_msg.c.

References SHMCleanupSharedSegment, and SYS_CloseFile.

Referenced by SHMCleanupSharedSegment.

INTERNAL int SHMClientCloseSession DWORD    dwClientID
 

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

am[in] dwClientID Client socket handle to be closed.
Return values:
0  Success.

Definition at line 121 of file winscard_msg.c.

References SHMClientCloseSession, and SYS_CloseFile.

Referenced by SHMClientCloseSession.

INTERNAL int SHMClientRead psharedSegmentMsg    msgStruct,
DWORD    dwClientID,
int    blockamount
 

Wrapper for the SHMMessageReceive() function.

Called by clients to read the server responses.

am[out] msgStruct Message read.
am[in] dwClientID Client socket handle.
am[in] blockamount Timeout in milliseconds.
Returns:
Same error codes as SHMMessageReceive().

Definition at line 56 of file winscard_msg.c.

References SHMClientRead, and SHMMessageReceive.

Referenced by SHMClientRead.

INTERNAL int SHMClientSetupSession PDWORD    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.

am[out] pdwClientID Client Connection ID.
Return values:
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 74 of file winscard_msg.c.

References SHMClientSetupSession, and SYS_CloseFile.

Referenced by SHMClientSetupSession.

INTERNAL int SHMMessageReceive void *    buffer_void,
size_t    buffer_size,
int    filedes,
int    blockAmount
 

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

Reads the message from the file filedes.

am[out] buffer_void Message read.
am[in] buffer_size Size to read
am[in] filedes Socket handle.
am[in] blockAmount Timeout in milliseconds.
Return values:
0  Success.
-1  Timeout.
-1  Socket is closed.
-1  A signal was received.

Definition at line 267 of file winscard_msg.c.

References SHMMessageReceive.

Referenced by SHMClientRead, and SHMMessageReceive.

INTERNAL int SHMMessageSend void *    buffer_void,
size_t    buffer_size,
int    filedes,
int    blockAmount
 

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

Writes the message in the shared file filedes.

am[in] buffer_void Message to be sent.
am[in] buffer_size Size of the message to send
am[in] filedes Socket handle.
am[in] blockAmount Timeout in milliseconds.
Return values:
0  Success
-1  Timeout.
-1  Socket is closed.
-1  A signal was received.

Definition at line 142 of file winscard_msg.c.

References SHMMessageSend.

Referenced by SHMMessageSend, and WrapSHMWrite.

INTERNAL int WrapSHMWrite unsigned int    command,
DWORD    dwClientID,
unsigned int    size,
unsigned int    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.

am[in] command Command to be sent.
am[in] dwClientID Client socket handle.
am[in] size Size of the message (\p data).
am[in] blockAmount Timeout to the operation in ms.
am[in] data_void Data to be sent.
Returns:
Same error codes as SHMMessageSend().

Definition at line 392 of file winscard_msg.c.

References rxSharedSegment::command, rxSharedSegment::data, rxSharedSegment::date, rxSharedSegment::group_id, rxSharedSegment::mtype, SHMMessageSend, rxSharedSegment::user_id, and WrapSHMWrite.

Referenced by WrapSHMWrite.


Generated on Mon Nov 24 20:31:19 2008 for pcsc-lite by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002