#include "config.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stddef.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 an Application Context on the Server side. More... | |
Functions | |
static LONG | MSGCheckHandleAssociation (SCARDHANDLE, DWORD) |
static LONG | MSGFunctionDemarshall (psharedSegmentMsg msgStruct, DWORD dwContextIndex) |
Find out which message was sent by the Client and execute the right task. | |
static LONG | MSGAddContext (SCARDCONTEXT, DWORD) |
static LONG | MSGRemoveContext (SCARDCONTEXT, DWORD) |
static LONG | MSGAddHandle (SCARDCONTEXT, SCARDHANDLE, DWORD) |
static LONG | MSGRemoveHandle (SCARDHANDLE, DWORD) |
static LONG | MSGCleanupClient (DWORD) |
static void | ContextThread (LPVOID dwIndex) |
Handles messages received from Clients. | |
LONG | ContextsInitialize (void) |
LONG | CreateContextThread (uint32_t *pdwClientID) |
Creates threads to handle messages received from Clients. | |
Variables | |
static struct _psContext | psContext [PCSCLITE_MAX_APPLICATIONS_CONTEXTS] |
Represents an Application Context on the Server side. |
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.
static void ContextThread | ( | LPVOID | dwIndex | ) | [static] |
Handles messages received from Clients.
For each Client message a new instance of this thread is created.
[in] | dwIndex | Index of an avaiable Application Context slot in psContext . |
Definition at line 126 of file winscard_svc.c.
References CMD_VERSION, version_struct::major, version_struct::minor, MSGFunctionDemarshall(), PCSCLITE_SERVER_ATTEMPTS, _psContext::protocol_minor, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, psContext, SCARD_CONTROL_EXTENDED, SCARD_E_NO_SERVICE, SCARD_S_SUCCESS, SCARD_TRANSMIT_EXTENDED, SHMClientCloseSession(), SHMMessageSend(), and SHMProcessEventsContext().
Referenced by CreateContextThread().
LONG CreateContextThread | ( | uint32_t * | pdwClientID | ) |
Creates threads to handle messages received from Clients.
[in] | pdwClientID | Connection ID used to reference the Client. |
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 78 of file winscard_svc.c.
References ContextThread(), _psContext::dwClientID, PCSCLITE_MAX_APPLICATIONS_CONTEXTS, psContext, SCARD_E_NO_MEMORY, SCARD_F_INTERNAL_ERROR, SCARD_S_SUCCESS, and SYS_CloseFile().
Referenced by SVCServiceRunLoop().
static LONG MSGFunctionDemarshall | ( | psharedSegmentMsg | msgStruct, | |
DWORD | dwContextIndex | |||
) | [static] |
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
.
[in] | msgStruct | Message to be demarshalled and executed. |
[in] | dwContextIndex |
Definition at line 256 of file winscard_svc.c.
References SCARD_IO_REQUEST::cbPciLength, _psContext::dwClientID, SCARD_IO_REQUEST::dwProtocol, MAX_BUFFER_SIZE_EXTENDED, PCSCLITE_MAX_MESSAGE_SIZE, PCSCLITE_SERVER_ATTEMPTS, psContext, SCARD_BEGIN_TRANSACTION, SCARD_CONNECT, SCARD_CONTROL, SCARD_CONTROL_EXTENDED, SCARD_DISCONNECT, SCARD_END_TRANSACTION, SCARD_ESTABLISH_CONTEXT, SCARD_GET_ATTRIB, SCARD_RECONNECT, SCARD_RELEASE_CONTEXT, SCARD_S_SUCCESS, SCARD_SET_ATTRIB, SCARD_STATUS, SCARD_TRANSMIT, SCARD_TRANSMIT_EXTENDED, SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContext(), SCardGetAttrib(), SCardReconnect(), SCardReleaseContext(), SCardSetAttrib(), SCardStatus(), SCardTransmit(), SHMMessageReceive(), and SHMMessageSend().
Referenced by ContextThread().
struct _psContext psContext[PCSCLITE_MAX_APPLICATIONS_CONTEXTS] [static] |
Represents an Application Context on the Server side.
An Application Context contains Channels (hCard
).
Referenced by ContextThread(), CreateContextThread(), and MSGFunctionDemarshall().