winscard_svc.c File Reference

This demarshalls functions over the message queue and keeps track of clients and their handles. More...

#include "config.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
#include "pcscd.h"
#include "winscard.h"
#include "debuglog.h"
#include "winscard_msg.h"
#include "winscard_svc.h"
#include "sys_generic.h"
#include "thread_generic.h"
#include "readerfactory.h"

Go to the source code of this file.

Data Structures

struct  _psContext
 Represents the an Application Context on the Server side. More...

Functions

LONG MSGCheckHandleAssociation (SCARDHANDLE, DWORD)
LONG MSGFunctionDemarshall (psharedSegmentMsg msgStruct, DWORD dwContextIndex)
 Find out which message was sent by the Client and execute the right task.
LONG MSGAddContext (SCARDCONTEXT, DWORD)
LONG MSGRemoveContext (SCARDCONTEXT, DWORD)
LONG MSGAddHandle (SCARDCONTEXT, SCARDHANDLE, DWORD)
LONG MSGRemoveHandle (SCARDHANDLE, DWORD)
LONG MSGCleanupClient (DWORD)
static void ContextThread (LPVOID dwIndex)
 Handles messages received from Clients.
LONG ContextsInitialize (void)
LONG CreateContextThread (PDWORD pdwClientID)
 Creates threads to handle messages received from Clients.

Variables

static struct _psContext psContext [PCSCLITE_MAX_APPLICATIONS_CONTEXTS]
 Represents the an Application Context on the Server side.


Detailed Description

This demarshalls functions over the message queue and keeps track of clients and their handles.

Each Client message is deald by creating a thread (CreateContextThread). The thread establishes reands and demarshalls the message and calls the appropriate function to threat it.

Definition in file winscard_svc.c.


Function Documentation

static void ContextThread ( LPVOID  dwIndex  )  [static]

Handles messages received from Clients.

For each Client message a new instance of this thread is created.

Parameters:
[in] dwIndex Index of an avaiable Application Context slot in psContext.

Definition at line 124 of file winscard_svc.c.

References rxSharedSegment::command, rxSharedSegment::data, version_struct::major, version_struct::minor, MSGFunctionDemarshall(), rxSharedSegment::mtype, PCSCLITE_SERVER_ATTEMPTS, _psContext::protocol_major, _psContext::protocol_minor, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, psContext, version_struct::rv, SCARD_E_NO_SERVICE, SHMMessageSend(), and SHMProcessEventsContext().

Referenced by CreateContextThread().

LONG CreateContextThread ( PDWORD  pdwClientID  ) 

Creates threads to handle messages received from Clients.

Parameters:
[in] pdwClientID Connection ID used to reference the Client.
Returns:
Error code.
Return values:
SCARD_S_SUCCESS Success.
SCARD_F_INTERNAL_ERROR Exceded the maximum number of simultaneous Application Contexts.
SCARD_E_NO_MEMORY Error creating the Context Thread.

Definition at line 77 of file winscard_svc.c.

References ContextThread(), _psContext::dwClientID, PCSCLITE_MAX_APPLICATIONS_CONTEXTS, psContext, SCARD_E_NO_MEMORY, SCARD_F_INTERNAL_ERROR, SYS_CloseFile(), and SYS_ThreadCreate().

Referenced by SVCServiceRunLoop().

LONG MSGFunctionDemarshall ( psharedSegmentMsg  msgStruct,
DWORD  dwContextIndex 
)

Find out which message was sent by the Client and execute the right task.

According to the command type sent by the client (pcsc_msg_commands), cast the message data to the correct struct so that is can be demarshalled. Then call the appropriate function to handle the request.

Possible structs are: establish_struct release_struct connect_struct reconnect_struct disconnect_struct begin_struct cancel_struct end_struct status_struct transmit_struct control_struct getset_struct.

Parameters:
[in] msgStruct Message to be demarshalled and executed.
[in] dwContextIndex 

Definition at line 246 of file winscard_svc.c.

References getset_struct::cbAttrLen, control_struct_extended::cbRecvLength, control_struct::cbRecvLength, control_struct_extended::cbSendLength, transmit_struct_extended::cbSendLength, control_struct::cbSendLength, transmit_struct::cbSendLength, rxSharedSegment::command, control_struct_extended::data, transmit_struct_extended::data, rxSharedSegment::data, getset_struct::dwAttrId, control_struct::dwBytesReturned, _psContext::dwClientID, control_struct_extended::dwControlCode, control_struct::dwControlCode, end_struct::dwDisposition, disconnect_struct::dwDisposition, reconnect_struct::dwInitialization, reconnect_struct::dwPreferredProtocols, connect_struct::dwPreferredProtocols, establish_struct::dwScope, reconnect_struct::dwShareMode, connect_struct::dwShareMode, control_struct_extended::hCard, transmit_struct_extended::hCard, getset_struct::hCard, control_struct::hCard, transmit_struct::hCard, status_struct::hCard, cancel_struct::hCard, end_struct::hCard, begin_struct::hCard, disconnect_struct::hCard, reconnect_struct::hCard, connect_struct::hContext, release_struct::hContext, MAX_BUFFER_SIZE_EXTENDED, status_struct::mszReaderNames, status_struct::pbAtr, getset_struct::pbAttr, control_struct::pbRecvBuffer, transmit_struct::pbRecvBuffer, control_struct::pbSendBuffer, transmit_struct::pbSendBuffer, status_struct::pcbAtrLen, transmit_struct_extended::pcbRecvLength, transmit_struct::pcbRecvLength, status_struct::pcchReaderLen, PCSCLITE_MAX_MESSAGE_SIZE, PCSCLITE_SERVER_ATTEMPTS, reconnect_struct::pdwActiveProtocol, connect_struct::pdwActiveProtocol, control_struct_extended::pdwBytesReturned, status_struct::pdwProtocol, status_struct::pdwState, connect_struct::phCard, establish_struct::phContext, transmit_struct_extended::pioRecvPci, transmit_struct::pioRecvPci, transmit_struct_extended::pioSendPci, transmit_struct::pioSendPci, psContext, control_struct_extended::rv, transmit_struct_extended::rv, getset_struct::rv, control_struct::rv, transmit_struct::rv, status_struct::rv, cancel_struct::rv, end_struct::rv, begin_struct::rv, disconnect_struct::rv, reconnect_struct::rv, connect_struct::rv, release_struct::rv, establish_struct::rv, SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContext(), SCardGetAttrib(), SCardReconnect(), SCardReleaseContext(), SCardSetAttrib(), SCardStatus(), SCardTransmit(), SHMMessageReceive(), SHMMessageSend(), control_struct_extended::size, transmit_struct_extended::size, and connect_struct::szReader.

Referenced by ContextThread().


Variable Documentation

struct _psContext psContext[PCSCLITE_MAX_APPLICATIONS_CONTEXTS] [static]

Represents the an Application Context on the Server side.

An Application Context contains Channels (hCard).

Referenced by ContextThread(), CreateContextThread(), and MSGFunctionDemarshall().


Generated on Wed Oct 8 02:23:55 2008 for pcsc-lite by  doxygen 1.5.6