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 <stddef.h>
#include <stdlib.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"
#include "eventhandler.h"
#include "simclist.h"
Include dependency graph for winscard_svc.c:

Go to the source code of this file.

Data Structures

struct  _psContext

Defines

#define READ_BODY(v)
#define WRITE_BODY(v)   ret = SHMMessageSend(&v, sizeof(v), filedes, PCSCLITE_WRITE_TIMEOUT);

Typedefs

typedef struct _psContext SCONTEXT

Functions

static LONG MSGCheckHandleAssociation (SCARDHANDLE, SCONTEXT *)
static LONG MSGAddContext (SCARDCONTEXT, SCONTEXT *)
static LONG MSGRemoveContext (SCARDCONTEXT, SCONTEXT *)
static LONG MSGAddHandle (SCARDCONTEXT, SCARDHANDLE, SCONTEXT *)
static LONG MSGRemoveHandle (SCARDHANDLE, SCONTEXT *)
static LONG MSGCleanupClient (SCONTEXT *)
static void ContextThread (LPVOID pdwIndex)
static int contextsListhContext_seeker (const void *el, const void *key)
LONG ContextsInitialize (unsigned int customMaxThreadCounter, unsigned int customMaxThreadCardHandles)
void ContextsDeinitialize (void)
LONG CreateContextThread (uint32_t *pdwClientID)
 Creates threads to handle messages received from Clients.
LONG MSGSignalClient (uint32_t filedes, LONG rv)

Variables

static unsigned int contextMaxThreadCounter = PCSC_MAX_CONTEXT_THREADS
 Represents an Application Context on the Server side.
static unsigned int contextMaxCardHandles = PCSC_MAX_CONTEXT_CARD_HANDLES
static list_t contextsList
READER_STATE readerStates [PCSCLITE_MAX_READERS_CONTEXTS]
static const char * CommandsText []
 Handles messages received from Clients.

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.


Define Documentation

#define READ_BODY (  ) 
Value:
if (header.size != sizeof(v)) { goto wrong_length; } \
    ret = SHMMessageReceive(&v, sizeof(v), filedes, PCSCLITE_READ_TIMEOUT); \
    if (ret < 0) { Log2(PCSC_LOG_DEBUG, "Client die: %d", filedes); goto exit; }

Definition at line 254 of file winscard_svc.c.


Function Documentation

LONG CreateContextThread ( uint32_t *  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 135 of file winscard_svc.c.

References contextMaxThreadCounter, _psContext::dwClientID, _psContext::pthThread, SCARD_E_NO_MEMORY, SCARD_S_SUCCESS, and SYS_CloseFile().

Referenced by SVCServiceRunLoop().

Here is the call graph for this function:


Variable Documentation

const char* CommandsText[] [static]
Initial value:
 {
    "NULL",
    "ESTABLISH_CONTEXT",    
    "RELEASE_CONTEXT",
    "LIST_READERS",
    "CONNECT",
    "RECONNECT",            
    "DISCONNECT",
    "BEGIN_TRANSACTION",
    "END_TRANSACTION",
    "TRANSMIT",
    "CONTROL",              
    "STATUS",
    "GET_STATUS_CHANGE",
    "CANCEL",
    "CANCEL_TRANSACTION",
    "GET_ATTRIB",           
    "SET_ATTRIB",
    "CMD_VERSION",
    "CMD_GET_READERS_STATE",
    "CMD_WAIT_READER_STATE_CHANGE",
    "CMD_STOP_WAITING_READER_STATE_CHANGE", 
    "NULL"
}

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 SCONTEXT *.

Definition at line 229 of file winscard_svc.c.

unsigned int contextMaxThreadCounter = PCSC_MAX_CONTEXT_THREADS [static]

Represents an Application Context on the Server side.

An Application Context contains Channels (hCard).

Definition at line 50 of file winscard_svc.c.

Referenced by CreateContextThread().


Generated on Fri Dec 11 15:52:50 2009 for pcsc-lite by  doxygen 1.6.1