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.
INTERNAL int SHMClientSetupSession (PDWORD pdwClientID)
 Prepares a communication channel for the client to talk to the server.
INTERNAL int SHMClientCloseSession (DWORD dwClientID)
 Closes the socket used by the client to communicate with the server.
INTERNAL int SHMMessageSend (psharedSegmentMsg msgStruct, int filedes, int blockAmount)
 Sends a menssage from client to server or vice-versa.
INTERNAL int SHMMessageReceive (psharedSegmentMsg msgStruct, int filedes, int blockAmount)
 Called by the Client to get the reponse from the server or vice-versa.
INTERNAL int WrapSHMWrite (unsigned int command, DWORD dwClientID, unsigned int size, unsigned int blockAmount, void *data)
 Wrapper for the SHMMessageSend() function.
INTERNAL void SHMCleanupSharedSegment (int sockValue, char *pcFilePath)
 Closes the communications channel used by the server to talk to the clients.


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,
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.

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

Definition at line 420 of file winscard_msg.c.

References SYS_CloseFile(), and SYS_Unlink().

Referenced by SHMInitializeCommonSegment().

INTERNAL int SHMClientCloseSession ( DWORD  dwClientID  ) 

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

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

Definition at line 118 of file winscard_msg.c.

References SYS_CloseFile().

Referenced by SCardRemoveContext(), and SCardUnload().

INTERNAL int SHMClientRead ( psharedSegmentMsg  msgStruct,
DWORD  dwClientID,
int  blockamount 
)

Wrapper for the SHMMessageReceive() function.

Called by clients to read the server responses.

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

Definition at line 56 of file winscard_msg.c.

References SHMMessageReceive().

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

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.

Parameters:
[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 Log2, PCSCLITE_CSOCK_NAME, and SYS_CloseFile().

Referenced by SCardEstablishContextTH().

INTERNAL int SHMMessageReceive ( psharedSegmentMsg  msgStruct,
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.

Parameters:
[out] msgStruct Message read.
[in] filedes Socket handle.
[in] blockAmount Timeout in milliseconds.
Return values:
0 Success.
-1 Timeout.
-1 Socket is closed.
-1 A signal was received.

Definition at line 264 of file winscard_msg.c.

References Log2.

Referenced by SCardEstablishContextTH(), SHMClientRead(), and SHMProcessEventsContext().

INTERNAL int SHMMessageSend ( psharedSegmentMsg  msgStruct,
int  filedes,
int  blockAmount 
)

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

Writes the message in the shared file filedes.

Parameters:
[in] msgStruct Message to be sent.
[in] filedes Socket handle.
[in] blockAmount Timeout in milliseconds.
Return values:
0 Success
-1 Timeout.
-1 Socket is closed.
-1 A signal was received.

Definition at line 138 of file winscard_msg.c.

References Log2.

Referenced by ContextThread(), SCardEstablishContextTH(), and WrapSHMWrite().

INTERNAL int WrapSHMWrite ( unsigned int  command,
DWORD  dwClientID,
unsigned int  size,
unsigned int  blockAmount,
void *  data 
)

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.

Parameters:
[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 Data to be sent.
Returns:
Same error codes as SHMMessageSend().

Definition at line 391 of file winscard_msg.c.

References SHMMessageSend(), SYS_GetGID(), and SYS_GetUID().

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


Generated on Sat Jan 6 09:29:29 2007 for pcsc-lite by  doxygen 1.4.7