eapol/eapol_framework/eapol_symbian/eap_server/src/EapSession.cpp
author hgs
Thu, 16 Sep 2010 13:07:04 +0300
changeset 49 43351a4f2da3
parent 36 c98682f98478
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  EAP-session inside EAP-server.
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
/*
49
hgs
parents: 36
diff changeset
    19
* %version: 34 %
26
hgs
parents:
diff changeset
    20
*/
hgs
parents:
diff changeset
    21
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
#define __REFERENCE_CAPABILITY_NAMES__
hgs
parents:
diff changeset
    24
#define __INCLUDE_CAPABILITY_NAMES__
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#include "EapSession.h"
hgs
parents:
diff changeset
    27
#include "EapServerStrings.h"
hgs
parents:
diff changeset
    28
#include "EapServer.h"
hgs
parents:
diff changeset
    29
#include "EapServerProcessHandler.h"
hgs
parents:
diff changeset
    30
#include "EapServerClientDef.h"
hgs
parents:
diff changeset
    31
#include "abs_eap_am_tools.h"
hgs
parents:
diff changeset
    32
#include "EapTraceSymbian.h"
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
#include "eap_automatic_variable.h"
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
/*
hgs
parents:
diff changeset
    37
    CEapSession
hgs
parents:
diff changeset
    38
*/
hgs
parents:
diff changeset
    39
hgs
parents:
diff changeset
    40
const TInt KMaxMessageLength = 1000000;
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
// construct/destruct
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
CEapSession::CEapSession()
hgs
parents:
diff changeset
    47
: iReceiveActive(EFalse)
hgs
parents:
diff changeset
    48
, iEapProcessHandler(0)
hgs
parents:
diff changeset
    49
, iTools(0)
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
    EAP_TRACE_DEBUG_SYMBIAN((_L("CEapSession::CEapSession(): this=0x%08x"),
hgs
parents:
diff changeset
    52
		this));
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapSession::CEapSession()"));
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
    }
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    59
34
hgs
parents: 31
diff changeset
    60
void CEapSession::ConstructL(CEapServer& /* aServer */, abs_eap_am_tools_c * const tools)
26
hgs
parents:
diff changeset
    61
    {
hgs
parents:
diff changeset
    62
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
    63
		tools,
hgs
parents:
diff changeset
    64
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
    65
		(EAPL("CEapSession::ConstructL(): this=0x%08x\n"),
hgs
parents:
diff changeset
    66
		this));
hgs
parents:
diff changeset
    67
	EAP_TRACE_RETURN_STRING(tools, "returns: CEapSession::ConstructL()");
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
    iTools = tools;
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
    iEapProcessHandler = CEapServerProcessHandler::NewL();
hgs
parents:
diff changeset
    72
    iEapProcessHandler->ConstructL(this, iTools);
hgs
parents:
diff changeset
    73
	CActiveScheduler::Add(iEapProcessHandler);
hgs
parents:
diff changeset
    74
    }
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    77
hgs
parents:
diff changeset
    78
CEapSession::~CEapSession()
hgs
parents:
diff changeset
    79
    {
hgs
parents:
diff changeset
    80
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
    81
		iTools,
hgs
parents:
diff changeset
    82
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
    83
		(EAPL("CEapSession::~CEapSession(): this=0x%08x\n"),
hgs
parents:
diff changeset
    84
		this));
hgs
parents:
diff changeset
    85
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::~CEapSession()");
hgs
parents:
diff changeset
    86
hgs
parents:
diff changeset
    87
    // cancel any receive
hgs
parents:
diff changeset
    88
    CancelReceive();
hgs
parents:
diff changeset
    89
    if (iEapProcessHandler != 0)
hgs
parents:
diff changeset
    90
        {
hgs
parents:
diff changeset
    91
        delete iEapProcessHandler;
hgs
parents:
diff changeset
    92
        iEapProcessHandler = 0;
hgs
parents:
diff changeset
    93
        }
hgs
parents:
diff changeset
    94
    // decrement session count, so server may terminate if no longer needed
hgs
parents:
diff changeset
    95
    Server()->DecrementSessions();
hgs
parents:
diff changeset
    96
    }
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
    99
hgs
parents:
diff changeset
   100
CEapServer* CEapSession::Server() const
hgs
parents:
diff changeset
   101
    /**
hgs
parents:
diff changeset
   102
       Return the EAP-server.
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
       This deliberately hides the ugly casts around the code.
hgs
parents:
diff changeset
   105
    */
hgs
parents:
diff changeset
   106
    {
hgs
parents:
diff changeset
   107
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   108
		iTools,
hgs
parents:
diff changeset
   109
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   110
		(EAPL("CEapSession::Server(): this=0x%08x\n"),
hgs
parents:
diff changeset
   111
		this));
hgs
parents:
diff changeset
   112
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::Server()");
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
    return const_cast<CEapServer*>(static_cast<const CEapServer*>(CSession2::Server()));
hgs
parents:
diff changeset
   115
    }
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   118
hgs
parents:
diff changeset
   119
void CEapSession::CheckCapabilityL(
hgs
parents:
diff changeset
   120
	const RMessage2& aMessage,
hgs
parents:
diff changeset
   121
	const TBool aMustHaveCapabilityWhenTrue,
hgs
parents:
diff changeset
   122
	const TCapability aCapability,
hgs
parents:
diff changeset
   123
	const char *aDiagnostic)
hgs
parents:
diff changeset
   124
{
hgs
parents:
diff changeset
   125
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   126
		iTools,
hgs
parents:
diff changeset
   127
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   128
		(EAPL("CEapSession::CheckCapabilityL(): this=0x%08x: aMessage.Function()=%d=%s\n"),
hgs
parents:
diff changeset
   129
		this,
hgs
parents:
diff changeset
   130
		aMessage.Function(),
hgs
parents:
diff changeset
   131
		EapServerStrings::GetEapRequestsString(aMessage.Function())));
hgs
parents:
diff changeset
   132
hgs
parents:
diff changeset
   133
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::CheckCapabilityL()");
hgs
parents:
diff changeset
   134
hgs
parents:
diff changeset
   135
	if (aMustHaveCapabilityWhenTrue != aMessage.HasCapability(aCapability, aDiagnostic))
hgs
parents:
diff changeset
   136
	{
hgs
parents:
diff changeset
   137
		// Capability check failed.
hgs
parents:
diff changeset
   138
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   139
			iTools,
hgs
parents:
diff changeset
   140
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   141
			(EAPL("ERROR: CEapSession::CheckCapability(): aMessage.Function()=%d=%s, failed capability check: %d=%s, %s\n"),
hgs
parents:
diff changeset
   142
			aMessage.Function(),
hgs
parents:
diff changeset
   143
			EapServerStrings::GetEapRequestsString(aMessage.Function()),
hgs
parents:
diff changeset
   144
			aCapability,
hgs
parents:
diff changeset
   145
			CapabilityNames[aCapability],
hgs
parents:
diff changeset
   146
			aDiagnostic));
hgs
parents:
diff changeset
   147
		Server()->PanicClient(EBadRequest);
hgs
parents:
diff changeset
   148
		User::Leave(EBadRequest);
hgs
parents:
diff changeset
   149
	}
hgs
parents:
diff changeset
   150
	else
hgs
parents:
diff changeset
   151
	{
hgs
parents:
diff changeset
   152
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   153
			iTools,
hgs
parents:
diff changeset
   154
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   155
			(EAPL("CEapSession::CheckCapability(): aMessage.Function()=%d=%s, OK capability check: %d=%s\n"),
hgs
parents:
diff changeset
   156
			aMessage.Function(),
hgs
parents:
diff changeset
   157
			EapServerStrings::GetEapRequestsString(aMessage.Function()),
hgs
parents:
diff changeset
   158
			aCapability,
hgs
parents:
diff changeset
   159
			CapabilityNames[aCapability]));
hgs
parents:
diff changeset
   160
	}
hgs
parents:
diff changeset
   161
}
hgs
parents:
diff changeset
   162
hgs
parents:
diff changeset
   163
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   164
hgs
parents:
diff changeset
   165
// service dispatcher - from CSharableSession
hgs
parents:
diff changeset
   166
hgs
parents:
diff changeset
   167
void CEapSession::ServiceL(const RMessage2& aMessage)
hgs
parents:
diff changeset
   168
    {
hgs
parents:
diff changeset
   169
hgs
parents:
diff changeset
   170
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   171
		iTools,
hgs
parents:
diff changeset
   172
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   173
		(EAPL("-start--------------------------------------------------------------------\n")));
hgs
parents:
diff changeset
   174
hgs
parents:
diff changeset
   175
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   176
		iTools,
hgs
parents:
diff changeset
   177
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   178
		(EAPL("CEapSession::ServiceL(): this=0x%08x: starts, aMessage.Function()=%d=%s\n"),
hgs
parents:
diff changeset
   179
		this,
hgs
parents:
diff changeset
   180
		aMessage.Function(),
hgs
parents:
diff changeset
   181
		EapServerStrings::GetEapRequestsString(aMessage.Function())));
hgs
parents:
diff changeset
   182
hgs
parents:
diff changeset
   183
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::ServiceL()");
hgs
parents:
diff changeset
   184
hgs
parents:
diff changeset
   185
hgs
parents:
diff changeset
   186
	{
27
9660a5eb236f 201021_1
hgs
parents: 26
diff changeset
   187
#if 0
9660a5eb236f 201021_1
hgs
parents: 26
diff changeset
   188
		// Add this later.
26
hgs
parents:
diff changeset
   189
		CheckCapabilityL(
hgs
parents:
diff changeset
   190
			aMessage,
hgs
parents:
diff changeset
   191
			ETrue,
hgs
parents:
diff changeset
   192
			ECapabilityNetworkControl,
hgs
parents:
diff changeset
   193
			"EAP-SERVER: Missing ECapabilityNetworkControl");
27
9660a5eb236f 201021_1
hgs
parents: 26
diff changeset
   194
#endif
26
hgs
parents:
diff changeset
   195
hgs
parents:
diff changeset
   196
		CheckCapabilityL(
hgs
parents:
diff changeset
   197
			aMessage,
hgs
parents:
diff changeset
   198
			ETrue,
hgs
parents:
diff changeset
   199
			ECapabilityReadDeviceData,
hgs
parents:
diff changeset
   200
			"EAP-SERVER: Missing ECapabilityReadDeviceData");
hgs
parents:
diff changeset
   201
hgs
parents:
diff changeset
   202
		CheckCapabilityL(
hgs
parents:
diff changeset
   203
			aMessage,
hgs
parents:
diff changeset
   204
			ETrue,
31
hgs
parents: 27
diff changeset
   205
			ECapabilityWriteDeviceData,
hgs
parents: 27
diff changeset
   206
			"EAP-SERVER: Missing ECapabilityWriteDeviceData");
26
hgs
parents:
diff changeset
   207
	}
hgs
parents:
diff changeset
   208
hgs
parents:
diff changeset
   209
hgs
parents:
diff changeset
   210
	if (aMessage.Function() == EEapIfCancelReceive)
hgs
parents:
diff changeset
   211
	{
hgs
parents:
diff changeset
   212
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   213
			iTools,
hgs
parents:
diff changeset
   214
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   215
			(EAPL("CEapSession::ServiceL(): aMessage.Function()=%d=%s, calls CancelReceive()\n"),
hgs
parents:
diff changeset
   216
			aMessage.Function(),
hgs
parents:
diff changeset
   217
			EapServerStrings::GetEapRequestsString(aMessage.Function())));
hgs
parents:
diff changeset
   218
        CancelReceive();
hgs
parents:
diff changeset
   219
		return;
hgs
parents:
diff changeset
   220
	}
hgs
parents:
diff changeset
   221
hgs
parents:
diff changeset
   222
	// length of passed descriptor (1st parameter passed from client)
hgs
parents:
diff changeset
   223
	TInt deslen = aMessage.GetDesLength(0);
hgs
parents:
diff changeset
   224
hgs
parents:
diff changeset
   225
	if (deslen > KMaxMessageLength)
hgs
parents:
diff changeset
   226
	{
hgs
parents:
diff changeset
   227
		Server()->PanicClient(EBadRequest);
hgs
parents:
diff changeset
   228
		return;
hgs
parents:
diff changeset
   229
	}
hgs
parents:
diff changeset
   230
hgs
parents:
diff changeset
   231
	// Passed data will be saved in this descriptor.
hgs
parents:
diff changeset
   232
	RBuf8 buffer;
hgs
parents:
diff changeset
   233
hgs
parents:
diff changeset
   234
	// Max length set to the value of "deslen", but current length is zero
hgs
parents:
diff changeset
   235
	buffer.CreateL(deslen);
hgs
parents:
diff changeset
   236
hgs
parents:
diff changeset
   237
	// Do the right cleanup if anything subsequently goes wrong
hgs
parents:
diff changeset
   238
	buffer.CleanupClosePushL();
hgs
parents:
diff changeset
   239
hgs
parents:
diff changeset
   240
	// Copy the client's descriptor data into our buffer.
hgs
parents:
diff changeset
   241
	aMessage.ReadL(0,buffer,0);
hgs
parents:
diff changeset
   242
hgs
parents:
diff changeset
   243
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   244
		iTools,
hgs
parents:
diff changeset
   245
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   246
		(EAPL("CEapSession::ServiceL(): calls buffer.Length()\n")));
hgs
parents:
diff changeset
   247
hgs
parents:
diff changeset
   248
	TUint aLength = buffer.Length();
hgs
parents:
diff changeset
   249
hgs
parents:
diff changeset
   250
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   251
		iTools,
hgs
parents:
diff changeset
   252
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   253
		(EAPL("CEapSession::ServiceL(): calls buffer.Ptr(): aLength=%d\n"),
hgs
parents:
diff changeset
   254
		aLength));
hgs
parents:
diff changeset
   255
hgs
parents:
diff changeset
   256
	const void * aData = buffer.Ptr();
hgs
parents:
diff changeset
   257
hgs
parents:
diff changeset
   258
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   259
		iTools,
hgs
parents:
diff changeset
   260
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   261
		(EAPL("CEapSession::ServiceL(): aData=0x%08x, aLength=%d\n"),
hgs
parents:
diff changeset
   262
		aData,
hgs
parents:
diff changeset
   263
		aLength));
hgs
parents:
diff changeset
   264
hgs
parents:
diff changeset
   265
	EAP_TRACE_DATA_DEBUG(
hgs
parents:
diff changeset
   266
		iTools,
36
hgs
parents: 34
diff changeset
   267
		EAP_TRACE_FLAGS_NEVER,
26
hgs
parents:
diff changeset
   268
		(EAPL("CEapSession::ServiceL()"),
hgs
parents:
diff changeset
   269
		aData,
hgs
parents:
diff changeset
   270
		aLength));
hgs
parents:
diff changeset
   271
hgs
parents:
diff changeset
   272
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   273
		iTools,
hgs
parents:
diff changeset
   274
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   275
		(EAPL("CEapSession::ServiceL(): switch aMessage.Function()=%d=%s, iEapProcessHandler=0x%08x\n"),
hgs
parents:
diff changeset
   276
		aMessage.Function(),
hgs
parents:
diff changeset
   277
		EapServerStrings::GetEapRequestsString(aMessage.Function()),
hgs
parents:
diff changeset
   278
		iEapProcessHandler));
hgs
parents:
diff changeset
   279
hgs
parents:
diff changeset
   280
hgs
parents:
diff changeset
   281
    switch (aMessage.Function())
hgs
parents:
diff changeset
   282
        {
hgs
parents:
diff changeset
   283
    case EEapCoreIfNew:
hgs
parents:
diff changeset
   284
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   285
			iTools,
hgs
parents:
diff changeset
   286
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   287
			(EAPL("CEapSession::ServiceL(): EEapCoreIfNew\n")));
hgs
parents:
diff changeset
   288
        ReceiveAll();
hgs
parents:
diff changeset
   289
        iEapProcessHandler->SaveMessage(EEapCoreIfNew, aData, aLength);
hgs
parents:
diff changeset
   290
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   291
        break;
hgs
parents:
diff changeset
   292
    case EEapPluginNew:
hgs
parents:
diff changeset
   293
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   294
			iTools,
hgs
parents:
diff changeset
   295
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   296
			(EAPL("CEapSession::ServiceL(): EEapPluginNew\n")));
hgs
parents:
diff changeset
   297
        iEapProcessHandler->SaveMessage(EEapPluginNew, aData, aLength);
hgs
parents:
diff changeset
   298
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   299
        break;
hgs
parents:
diff changeset
   300
    case EEapSettingsNew:
hgs
parents:
diff changeset
   301
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   302
			iTools,
hgs
parents:
diff changeset
   303
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   304
			(EAPL("CEapSession::ServiceL(): EEapSettingsNew\n")));
hgs
parents:
diff changeset
   305
        iEapProcessHandler->SaveMessage(EEapSettingsNew, aData, aLength);
hgs
parents:
diff changeset
   306
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   307
        break;
hgs
parents:
diff changeset
   308
    case EEapPacStoreNew:
hgs
parents:
diff changeset
   309
        EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   310
            iTools,
hgs
parents:
diff changeset
   311
            TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   312
            (EAPL("CEapSession::ServiceL(): EEapPacStoreNew\n")));
hgs
parents:
diff changeset
   313
        iEapProcessHandler->SaveMessage(EEapPacStoreNew, aData, aLength);
hgs
parents:
diff changeset
   314
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   315
        break;
hgs
parents:
diff changeset
   316
    case EWapiCoreIfNew:
hgs
parents:
diff changeset
   317
        EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   318
            iTools,
hgs
parents:
diff changeset
   319
            TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   320
            (EAPL("CEapSession::ServiceL(): EWapiCoreIfNew\n")));
hgs
parents:
diff changeset
   321
        ReceiveAll();
hgs
parents:
diff changeset
   322
        iEapProcessHandler->SaveMessage(EWapiCoreIfNew, aData, aLength);
hgs
parents:
diff changeset
   323
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   324
        break;
hgs
parents:
diff changeset
   325
    case EWapiSettingsNew:
hgs
parents:
diff changeset
   326
        EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   327
            iTools,
hgs
parents:
diff changeset
   328
            TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   329
            (EAPL("CEapSession::ServiceL(): EWapiSettingsNew\n")));
hgs
parents:
diff changeset
   330
        ReceiveAll();
hgs
parents:
diff changeset
   331
        iEapProcessHandler->SaveMessage(EWapiSettingsNew, aData, aLength);
hgs
parents:
diff changeset
   332
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   333
        break;
hgs
parents:
diff changeset
   334
    case EEapCoreProcessData:
hgs
parents:
diff changeset
   335
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   336
			iTools,
hgs
parents:
diff changeset
   337
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   338
			(EAPL("CEapSession::ServiceL(): EEapCoreProcessData\n")));
hgs
parents:
diff changeset
   339
        // Read message
hgs
parents:
diff changeset
   340
        iEapProcessHandler->SaveMessage(EEapCoreProcessData, aData, aLength);
hgs
parents:
diff changeset
   341
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   342
        break;
hgs
parents:
diff changeset
   343
    case EEapPluginProcessData:
hgs
parents:
diff changeset
   344
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   345
			iTools,
hgs
parents:
diff changeset
   346
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   347
			(EAPL("CEapSession::ServiceL(): EEapPluginProcessData\n")));
hgs
parents:
diff changeset
   348
        iEapProcessHandler->SaveMessage(EEapPluginProcessData, aData, aLength);
hgs
parents:
diff changeset
   349
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   350
        break;
hgs
parents:
diff changeset
   351
    case EEapSettingsProcessData:
hgs
parents:
diff changeset
   352
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   353
			iTools,
hgs
parents:
diff changeset
   354
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   355
			(EAPL("CEapSession::ServiceL(): EEapSettingsProcessData\n")));
hgs
parents:
diff changeset
   356
        iEapProcessHandler->SaveMessage(EEapSettingsProcessData, aData, aLength);
hgs
parents:
diff changeset
   357
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   358
        break;
hgs
parents:
diff changeset
   359
    case EEapPacStoreProcessData:
hgs
parents:
diff changeset
   360
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   361
			iTools,
hgs
parents:
diff changeset
   362
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   363
			(EAPL("CEapSession::ServiceL(): EEapPacStoreProcessData\n")));
hgs
parents:
diff changeset
   364
        iEapProcessHandler->SaveMessage(EEapPacStoreProcessData, aData, aLength);
hgs
parents:
diff changeset
   365
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   366
        break;
hgs
parents:
diff changeset
   367
    case EWapiCoreProcessData:
hgs
parents:
diff changeset
   368
        EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   369
            iTools,
hgs
parents:
diff changeset
   370
            TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   371
            (EAPL("CEapSession::ServiceL(): EWapiCoreProcessData\n")));
hgs
parents:
diff changeset
   372
        iEapProcessHandler->SaveMessage(EWapiCoreProcessData, aData, aLength);
hgs
parents:
diff changeset
   373
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   374
        break;
hgs
parents:
diff changeset
   375
    case EWapiSettingsProcessData:
hgs
parents:
diff changeset
   376
        EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   377
            iTools,
hgs
parents:
diff changeset
   378
            TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   379
            (EAPL("CEapSession::ServiceL(): EWapiSettingsProcessData\n")));
hgs
parents:
diff changeset
   380
        iEapProcessHandler->SaveMessage(EWapiSettingsProcessData, aData, aLength);
hgs
parents:
diff changeset
   381
        aMessage.Complete(KErrNone);
hgs
parents:
diff changeset
   382
        break;
hgs
parents:
diff changeset
   383
    case EEapIfReqReceive: // TAny& aBuffer - async
hgs
parents:
diff changeset
   384
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   385
			iTools,
hgs
parents:
diff changeset
   386
			TRACE_FLAGS_DEFAULT,
49
hgs
parents: 36
diff changeset
   387
			(EAPL("CEapSession::ServiceL(): EEapIfReqReceive, iReceiveMessage=0x%08x\n"),
hgs
parents: 36
diff changeset
   388
			&iReceiveMessage));
hgs
parents: 36
diff changeset
   389
26
hgs
parents:
diff changeset
   390
        __ASSERT_DEBUG(!iReceiveActive, Server()->PanicClient(EReceiveReceiveAlreadyActive));
49
hgs
parents: 36
diff changeset
   391
26
hgs
parents:
diff changeset
   392
        // remember receive request
hgs
parents:
diff changeset
   393
        iReceiveMessage = aMessage;
hgs
parents:
diff changeset
   394
        iReceiveActive=ETrue;
49
hgs
parents: 36
diff changeset
   395
hgs
parents: 36
diff changeset
   396
		iEapProcessHandler->Activate(EapServerProcessHandlerState_Send);
hgs
parents: 36
diff changeset
   397
26
hgs
parents:
diff changeset
   398
        break;
hgs
parents:
diff changeset
   399
    case EEapIfCancelReceive:
hgs
parents:
diff changeset
   400
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   401
			iTools,
hgs
parents:
diff changeset
   402
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   403
			(EAPL("CEapSession::ServiceL(): EEapIfCancelReceive\n")));
hgs
parents:
diff changeset
   404
        CancelReceive();
hgs
parents:
diff changeset
   405
        break;
hgs
parents:
diff changeset
   406
    default:
hgs
parents:
diff changeset
   407
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   408
			iTools,
hgs
parents:
diff changeset
   409
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   410
			(EAPL("ERROR: CEapSession::ServiceL(): unknown aMessage.Function()=%d=%s, calls Server()->PanicClient()\n"),
hgs
parents:
diff changeset
   411
			aMessage.Function(),
hgs
parents:
diff changeset
   412
			EapServerStrings::GetEapRequestsString(aMessage.Function())));
hgs
parents:
diff changeset
   413
hgs
parents:
diff changeset
   414
		Server()->PanicClient(EBadRequest);
hgs
parents:
diff changeset
   415
        };
hgs
parents:
diff changeset
   416
hgs
parents:
diff changeset
   417
	CleanupStack::PopAndDestroy(&buffer);
hgs
parents:
diff changeset
   418
hgs
parents:
diff changeset
   419
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   420
		iTools,
hgs
parents:
diff changeset
   421
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   422
		(EAPL("CEapSession::ServiceL(): ends aMessage.Function()=%d=%s\n"),
hgs
parents:
diff changeset
   423
		aMessage.Function(),
hgs
parents:
diff changeset
   424
		EapServerStrings::GetEapRequestsString(aMessage.Function())));
hgs
parents:
diff changeset
   425
hgs
parents:
diff changeset
   426
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   427
		iTools,
hgs
parents:
diff changeset
   428
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   429
		(EAPL("-end----------------------------------------------------------------------\n")));
hgs
parents:
diff changeset
   430
    }
hgs
parents:
diff changeset
   431
hgs
parents:
diff changeset
   432
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   433
hgs
parents:
diff changeset
   434
void CEapSession::ReceiveAll()
hgs
parents:
diff changeset
   435
    {
hgs
parents:
diff changeset
   436
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   437
		iTools,
hgs
parents:
diff changeset
   438
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   439
		(EAPL("CEapSession::ReceiveAll(): this=0x%08x\n"),
hgs
parents:
diff changeset
   440
		this));
hgs
parents:
diff changeset
   441
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::ReceiveAll()");
hgs
parents:
diff changeset
   442
hgs
parents:
diff changeset
   443
    }
hgs
parents:
diff changeset
   444
hgs
parents:
diff changeset
   445
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   446
hgs
parents:
diff changeset
   447
void CEapSession::Receive(RMessage2& aBuffer)
hgs
parents:
diff changeset
   448
    {
hgs
parents:
diff changeset
   449
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   450
		iTools,
hgs
parents:
diff changeset
   451
		TRACE_FLAGS_DEFAULT,
49
hgs
parents: 36
diff changeset
   452
		(EAPL("CEapSession::Receive(): this=0x%08x, iReceiveMessage=0x%08x\n"),
hgs
parents: 36
diff changeset
   453
		this,
hgs
parents: 36
diff changeset
   454
		&iReceiveMessage));
26
hgs
parents:
diff changeset
   455
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::Receive()");
hgs
parents:
diff changeset
   456
hgs
parents:
diff changeset
   457
    __ASSERT_DEBUG(!iReceiveActive,Server()->PanicClient(EReceiveReceiveAlreadyActive));
hgs
parents:
diff changeset
   458
hgs
parents:
diff changeset
   459
    // remember receive request
hgs
parents:
diff changeset
   460
    iReceiveMessage = aBuffer;
hgs
parents:
diff changeset
   461
    iReceiveActive=ETrue;
hgs
parents:
diff changeset
   462
    }
hgs
parents:
diff changeset
   463
hgs
parents:
diff changeset
   464
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   465
hgs
parents:
diff changeset
   466
void CEapSession::CancelReceive()
hgs
parents:
diff changeset
   467
    {
hgs
parents:
diff changeset
   468
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   469
		iTools,
hgs
parents:
diff changeset
   470
		TRACE_FLAGS_DEFAULT,
49
hgs
parents: 36
diff changeset
   471
		(EAPL("CEapSession::CancelReceive(): this=0x%08x, iReceiveMessage=0x%08x\n"),
hgs
parents: 36
diff changeset
   472
		this,
hgs
parents: 36
diff changeset
   473
		&iReceiveMessage));
26
hgs
parents:
diff changeset
   474
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::CancelReceive()");
hgs
parents:
diff changeset
   475
hgs
parents:
diff changeset
   476
    if (!iReceiveActive)
hgs
parents:
diff changeset
   477
	{
hgs
parents:
diff changeset
   478
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   479
			iTools,
hgs
parents:
diff changeset
   480
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   481
			(EAPL("CEapSession::CancelReceive(): No receive active\n")));
hgs
parents:
diff changeset
   482
        return;
hgs
parents:
diff changeset
   483
	}
hgs
parents:
diff changeset
   484
hgs
parents:
diff changeset
   485
    iReceiveMessage.Complete(KErrCancel);
hgs
parents:
diff changeset
   486
    iReceiveActive=EFalse;
hgs
parents:
diff changeset
   487
    }
hgs
parents:
diff changeset
   488
hgs
parents:
diff changeset
   489
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   490
hgs
parents:
diff changeset
   491
TBool CEapSession::GetReceiveActive()
hgs
parents:
diff changeset
   492
{
hgs
parents:
diff changeset
   493
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   494
		iTools,
hgs
parents:
diff changeset
   495
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   496
		(EAPL("CEapSession::GetReceiveActive(): this=0x%08x: iReceiveActive=%d\n"),
hgs
parents:
diff changeset
   497
		this,
hgs
parents:
diff changeset
   498
		iReceiveActive));
hgs
parents:
diff changeset
   499
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::GetReceiveActive()");
hgs
parents:
diff changeset
   500
hgs
parents:
diff changeset
   501
	return iReceiveActive;
hgs
parents:
diff changeset
   502
}
hgs
parents:
diff changeset
   503
hgs
parents:
diff changeset
   504
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   505
hgs
parents:
diff changeset
   506
eap_status_e CEapSession::SendData(EapMessageBuffer * const message)
49
hgs
parents: 36
diff changeset
   507
{
26
hgs
parents:
diff changeset
   508
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   509
		iTools,
hgs
parents:
diff changeset
   510
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   511
		(EAPL("CEapSession::SendData(): this=0x%08x: message->GetRequestType()=%d=%s, message->GetData()->Length()=%d\n"),
hgs
parents:
diff changeset
   512
		this,
hgs
parents:
diff changeset
   513
		message->GetRequestType(),
hgs
parents:
diff changeset
   514
		EapServerStrings::GetEapRequestsString(message->GetRequestType()),
hgs
parents:
diff changeset
   515
		message->GetData()->Length()));
hgs
parents:
diff changeset
   516
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::SendData()");
hgs
parents:
diff changeset
   517
49
hgs
parents: 36
diff changeset
   518
	if (!iReceiveActive)
26
hgs
parents:
diff changeset
   519
	{
hgs
parents:
diff changeset
   520
		EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   521
			iTools,
hgs
parents:
diff changeset
   522
			TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   523
			(EAPL("CEapSession::SendData(): No receive active\n")));
49
hgs
parents: 36
diff changeset
   524
		return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(KErrCancel));
26
hgs
parents:
diff changeset
   525
	}
hgs
parents:
diff changeset
   526
49
hgs
parents: 36
diff changeset
   527
	TInt error(KErrNone);
26
hgs
parents:
diff changeset
   528
hgs
parents:
diff changeset
   529
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   530
		iTools,
hgs
parents:
diff changeset
   531
		TRACE_FLAGS_DEFAULT,
hgs
parents:
diff changeset
   532
		(EAPL("CEapSession::SendData(): calls iReceiveMessage.Write()\n")));
hgs
parents:
diff changeset
   533
hgs
parents:
diff changeset
   534
	error = iReceiveMessage.Write(0, message->GetData()->Des());
hgs
parents:
diff changeset
   535
hgs
parents:
diff changeset
   536
	EAP_TRACE_DEBUG(
hgs
parents:
diff changeset
   537
		iTools,
hgs
parents:
diff changeset
   538
		TRACE_FLAGS_DEFAULT,
49
hgs
parents: 36
diff changeset
   539
		(EAPL("CEapSession::SendData(): calls iReceiveMessage.Complete(): Write() error=%d, iReceiveMessage=0x%08x\n"),
hgs
parents: 36
diff changeset
   540
		error,
hgs
parents: 36
diff changeset
   541
		&iReceiveMessage));
hgs
parents: 36
diff changeset
   542
hgs
parents: 36
diff changeset
   543
	iReceiveMessage.Complete(KErrNone);
hgs
parents: 36
diff changeset
   544
	iReceiveActive=EFalse;
hgs
parents: 36
diff changeset
   545
hgs
parents: 36
diff changeset
   546
	return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(error));
hgs
parents: 36
diff changeset
   547
}
hgs
parents: 36
diff changeset
   548
hgs
parents: 36
diff changeset
   549
// -----------------------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   550
hgs
parents: 36
diff changeset
   551
TInt CEapSession::AddReadyHandler(CEapServerProcessHandler * const handler)
hgs
parents: 36
diff changeset
   552
{
hgs
parents: 36
diff changeset
   553
	EAP_TRACE_DEBUG(
hgs
parents: 36
diff changeset
   554
		iTools,
hgs
parents: 36
diff changeset
   555
		TRACE_FLAGS_DEFAULT,
hgs
parents: 36
diff changeset
   556
		(EAPL("CEapSession::AddReadyHandler(): this=0x%08x: handler=0x%08x\n"),
hgs
parents: 36
diff changeset
   557
		this,
hgs
parents: 36
diff changeset
   558
		handler));
hgs
parents: 36
diff changeset
   559
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::AddReadyHandler()");
hgs
parents: 36
diff changeset
   560
hgs
parents: 36
diff changeset
   561
	return Server()->AddReadyHandler(handler);
hgs
parents: 36
diff changeset
   562
}
hgs
parents: 36
diff changeset
   563
hgs
parents: 36
diff changeset
   564
// -----------------------------------------------------------------------------------------
26
hgs
parents:
diff changeset
   565
49
hgs
parents: 36
diff changeset
   566
TInt CEapSession::CompleteReadyHandler(CEapServerProcessHandler * const handler)
hgs
parents: 36
diff changeset
   567
{
hgs
parents: 36
diff changeset
   568
	EAP_TRACE_DEBUG(
hgs
parents: 36
diff changeset
   569
		iTools,
hgs
parents: 36
diff changeset
   570
		TRACE_FLAGS_DEFAULT,
hgs
parents: 36
diff changeset
   571
		(EAPL("CEapSession::CompleteReadyHandler(): this=0x%08x: handler=0x%08x\n"),
hgs
parents: 36
diff changeset
   572
		this,
hgs
parents: 36
diff changeset
   573
		handler));
hgs
parents: 36
diff changeset
   574
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::CompleteReadyHandler()");
hgs
parents: 36
diff changeset
   575
hgs
parents: 36
diff changeset
   576
	return Server()->CompleteReadyHandler(handler);
hgs
parents: 36
diff changeset
   577
}
26
hgs
parents:
diff changeset
   578
49
hgs
parents: 36
diff changeset
   579
// -----------------------------------------------------------------------------------------
hgs
parents: 36
diff changeset
   580
hgs
parents: 36
diff changeset
   581
TInt CEapSession::CancelReadyHandler(CEapServerProcessHandler * const handler)
hgs
parents: 36
diff changeset
   582
{
hgs
parents: 36
diff changeset
   583
	EAP_TRACE_DEBUG(
hgs
parents: 36
diff changeset
   584
		iTools,
hgs
parents: 36
diff changeset
   585
		TRACE_FLAGS_DEFAULT,
hgs
parents: 36
diff changeset
   586
		(EAPL("CEapSession::CancelReadyHandler(): this=0x%08x: handler=0x%08x\n"),
hgs
parents: 36
diff changeset
   587
		this,
hgs
parents: 36
diff changeset
   588
		handler));
hgs
parents: 36
diff changeset
   589
	EAP_TRACE_RETURN_STRING(iTools, "returns: CEapSession::CancelReadyHandler()");
hgs
parents: 36
diff changeset
   590
hgs
parents: 36
diff changeset
   591
	return Server()->CancelReadyHandler(handler);
hgs
parents: 36
diff changeset
   592
}
26
hgs
parents:
diff changeset
   593
hgs
parents:
diff changeset
   594
// -----------------------------------------------------------------------------------------
hgs
parents:
diff changeset
   595
// end