26
|
1 |
/*
|
|
2 |
* Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: EAP and WLAN authentication protocols.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
49
|
19 |
* %version: 22 %
|
26
|
20 |
*/
|
|
21 |
|
|
22 |
#include "EapCoreInterface.h"
|
|
23 |
#include "eap_am_tools.h"
|
|
24 |
#include "EapolUID.h"
|
34
|
25 |
#include "EapPluginTools.h"
|
49
|
26 |
#include "eap_am_message_if.h"
|
26
|
27 |
|
49
|
28 |
EAP_FUNC_EXPORT CEapCoreInterface::CEapCoreInterface(const u32_t MTU):
|
26
|
29 |
iClient(NULL)
|
|
30 |
,iIsValid(FALSE)
|
|
31 |
,iTools(0)
|
|
32 |
,iEapCoreInterface(0)
|
|
33 |
,iServer(0)
|
|
34 |
,iMTU(MTU)
|
|
35 |
{
|
|
36 |
}
|
|
37 |
|
49
|
38 |
EAP_FUNC_EXPORT CEapCoreInterface::~CEapCoreInterface()
|
26
|
39 |
{
|
|
40 |
delete iEapCoreInterface;
|
|
41 |
}
|
|
42 |
|
|
43 |
EAP_FUNC_EXPORT CEapProcessInterface* CEapCoreInterface::ConstrucL(abs_eap_am_tools_c * const tools)
|
|
44 |
{
|
|
45 |
iTools = tools;
|
|
46 |
|
|
47 |
//TInt implementationUid( EAP_CORE_INTERFACEIMPLEMENTATION_IMPLEMENTATION_UID );
|
|
48 |
|
|
49 |
const TUid KimplementationInterfaceUid = { EAP_CORE_INTERFACEIMPLEMENTATION_INTERFACE_UID };
|
|
50 |
|
|
51 |
RImplInfoPtrArray aImplInfoArray;
|
|
52 |
|
|
53 |
CleanupStack::PushL( TCleanupItem( EapPluginTools::CleanupImplArray, &aImplInfoArray ) );
|
|
54 |
|
|
55 |
REComSession::ListImplementationsL(KimplementationInterfaceUid,
|
|
56 |
aImplInfoArray);
|
|
57 |
|
|
58 |
EAP_TRACE_DEBUG(
|
|
59 |
tools,
|
|
60 |
TRACE_FLAGS_DEFAULT,
|
|
61 |
(EAPL("CEapCoreInterface::ConstrucL Implementation %d\n"),aImplInfoArray[0]->ImplementationUid().iUid));
|
|
62 |
|
|
63 |
iServer = CEapProcessInterface::NewL(
|
|
64 |
aImplInfoArray[0]->ImplementationUid().iUid,
|
|
65 |
this);
|
|
66 |
|
|
67 |
EAP_TRACE_DEBUG(
|
|
68 |
tools,
|
|
69 |
TRACE_FLAGS_DEFAULT,
|
|
70 |
(EAPL("CEapCoreInterface::ConstrucL CEapProcessInterface::NewL done\n")));
|
|
71 |
|
|
72 |
iIsValid = TRUE;
|
|
73 |
|
|
74 |
CleanupStack::PopAndDestroy(&aImplInfoArray);
|
|
75 |
|
|
76 |
return iServer;
|
|
77 |
|
|
78 |
}
|
|
79 |
|
49
|
80 |
|
|
81 |
EAP_C_FUNC_EXPORT eap_am_message_if_c * new_eap_am_client_message_if_c(
|
26
|
82 |
abs_eap_am_tools_c * const tools,
|
34
|
83 |
const bool /* is_client_when_true */,
|
26
|
84 |
const u32_t MTU)
|
|
85 |
{
|
|
86 |
CEapCoreInterface * aEapCoreInterface = 0;
|
|
87 |
CEapProcessInterface* aServer =0;
|
|
88 |
|
|
89 |
EAP_TRACE_DEBUG(
|
|
90 |
tools,
|
|
91 |
TRACE_FLAGS_DEFAULT,
|
|
92 |
(EAPL("new_eap_am_client_message_if_c()\n")));
|
|
93 |
|
|
94 |
aEapCoreInterface = new CEapCoreInterface(MTU);
|
|
95 |
if (aEapCoreInterface != 0)
|
|
96 |
{
|
|
97 |
TRAPD( err, aServer = aEapCoreInterface->ConstrucL(tools));
|
|
98 |
if (err)
|
|
99 |
{
|
|
100 |
EAP_TRACE_DEBUG(
|
|
101 |
tools,
|
|
102 |
TRACE_FLAGS_DEFAULT,
|
|
103 |
(EAPL("new_eap_am_client_message_if_c() NO SERVER IF, err = %d\n"),err));
|
|
104 |
|
|
105 |
return 0;
|
|
106 |
}
|
|
107 |
else if(aServer == NULL)
|
|
108 |
{
|
|
109 |
EAP_TRACE_DEBUG(
|
|
110 |
tools,
|
|
111 |
TRACE_FLAGS_DEFAULT,
|
|
112 |
(EAPL("new_eap_am_client_message_if_c() SERVER IF == 0\n")));
|
|
113 |
}
|
|
114 |
else
|
|
115 |
{
|
|
116 |
aServer->SetEnv(tools, MTU);
|
|
117 |
}
|
|
118 |
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
EAP_TRACE_DEBUG(
|
|
123 |
tools,
|
|
124 |
TRACE_FLAGS_DEFAULT,
|
|
125 |
(EAPL("new_eap_am_client_message_if_c() new(ELeave) CEapCoreInterface(MTU) failed\n")));
|
|
126 |
return 0;
|
|
127 |
}
|
|
128 |
return aEapCoreInterface;
|
|
129 |
|
|
130 |
}
|
|
131 |
|
|
132 |
EAP_FUNC_EXPORT bool CEapCoreInterface::get_is_valid()
|
|
133 |
{
|
|
134 |
EAP_TRACE_DEBUG(
|
|
135 |
iTools,
|
|
136 |
TRACE_FLAGS_DEFAULT,
|
|
137 |
(EAPL("CEapCoreInterface::get_is_valid() = %d\n"),iIsValid ));
|
|
138 |
return iIsValid;
|
|
139 |
}
|
|
140 |
|
|
141 |
EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::process_data(const void * const data, const u32_t length)
|
|
142 |
{
|
|
143 |
EAP_TRACE_DEBUG(
|
|
144 |
iTools,
|
|
145 |
TRACE_FLAGS_DEFAULT,
|
|
146 |
(EAPL("CEapCoreInterface::process_data()\n")));
|
|
147 |
|
|
148 |
TInt err = iServer->ProcessData(data, length);
|
|
149 |
|
|
150 |
return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
|
|
151 |
}
|
|
152 |
|
|
153 |
|
|
154 |
EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::configure(
|
|
155 |
const eap_variable_data_c * const client_configuration)
|
|
156 |
{
|
|
157 |
EAP_TRACE_DEBUG(
|
|
158 |
iTools,
|
|
159 |
TRACE_FLAGS_DEFAULT,
|
|
160 |
(EAPL("CEapCoreInterface::configure()\n")));
|
|
161 |
|
|
162 |
TInt err = iServer->Configure(0,0,0, client_configuration->get_data(), client_configuration->get_data_length());
|
|
163 |
|
|
164 |
return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
|
|
165 |
}
|
|
166 |
|
|
167 |
// This is documented in abs_eap_stack_interface_c::shutdown().
|
|
168 |
EAP_FUNC_EXPORT eap_status_e CEapCoreInterface::shutdown()
|
|
169 |
{
|
|
170 |
EAP_TRACE_DEBUG(
|
|
171 |
iTools,
|
|
172 |
TRACE_FLAGS_DEFAULT,
|
|
173 |
(EAPL("CEapCoreInterface::shutdown()\n")));
|
|
174 |
|
|
175 |
TInt err = iServer->Shutdown();
|
|
176 |
|
|
177 |
return EAP_STATUS_RETURN(iTools, iTools->convert_am_error_to_eapol_error(err));
|
|
178 |
}
|
|
179 |
|
|
180 |
EAP_FUNC_EXPORT void CEapCoreInterface::set_partner(abs_eap_am_message_if_c * const client)
|
|
181 |
{
|
|
182 |
EAP_TRACE_DEBUG(
|
|
183 |
iTools,
|
|
184 |
TRACE_FLAGS_DEFAULT,
|
|
185 |
(EAPL("CEapCoreInterface::set_partner()\n")));
|
|
186 |
iClient = client;
|
|
187 |
}
|
|
188 |
|
|
189 |
EAP_FUNC_EXPORT TInt CEapCoreInterface::SendData(
|
|
190 |
const void * const aData,
|
|
191 |
const TInt aLength )
|
|
192 |
{
|
|
193 |
EAP_TRACE_DEBUG(
|
|
194 |
iTools,
|
|
195 |
TRACE_FLAGS_DEFAULT,
|
|
196 |
(EAPL("CEapCoreInterface::SendData()\n")));
|
|
197 |
if (iClient != NULL)
|
|
198 |
{
|
|
199 |
return iClient->send_data( aData, aLength);
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
return KErrNone;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|