46
|
1 |
/*
|
|
2 |
* Copyright (c) 2001-2006 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 |
/*
|
|
19 |
* %version: 17.1.2.1.1 %
|
|
20 |
*/
|
|
21 |
|
|
22 |
// This is enumeration of EAPOL source code.
|
|
23 |
#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
|
|
24 |
#undef EAP_FILE_NUMBER_ENUM
|
|
25 |
#define EAP_FILE_NUMBER_ENUM 148
|
|
26 |
#undef EAP_FILE_NUMBER_DATE
|
|
27 |
#define EAP_FILE_NUMBER_DATE 1127594498
|
|
28 |
#endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
|
|
29 |
|
|
30 |
|
|
31 |
// INCLUDE FILES
|
|
32 |
|
|
33 |
#include "eap_am_memory.h"
|
|
34 |
|
|
35 |
#include "eap_variable_data.h"
|
|
36 |
#include "eap_tools.h"
|
|
37 |
#include "eap_type_all.h"
|
|
38 |
|
|
39 |
#include "eapol_am_core_symbian.h"
|
|
40 |
#include "eapol_ethernet_header.h"
|
|
41 |
#include "ethernet_core.h"
|
|
42 |
#include "eap_am_tools_symbian.h"
|
|
43 |
#include <EapolToWlmIf.h>
|
|
44 |
#include "EapolDbDefaults.h"
|
|
45 |
#include "EapolDbParameterNames.h"
|
|
46 |
#include "eap_crypto_api.h"
|
|
47 |
#include "eap_header_string.h"
|
|
48 |
#include "eap_am_file_input_symbian.h"
|
|
49 |
#include "eap_rogue_ap_entry.h"
|
|
50 |
#include "abs_eap_state_notification.h"
|
|
51 |
#include "eapol_session_key.h"
|
|
52 |
#include "eap_buffer.h"
|
|
53 |
#include "eap_config.h"
|
|
54 |
|
|
55 |
#if defined(USE_EAP_FILECONFIG)
|
|
56 |
#include "eap_file_config.h"
|
|
57 |
#endif //#if defined(USE_EAP_FILECONFIG)
|
|
58 |
|
|
59 |
#if defined (USE_EAPOL_KEY_STATE)
|
|
60 |
#include "eapol_key_state.h"
|
|
61 |
#endif
|
|
62 |
|
|
63 |
// LOCAL CONSTANTS
|
|
64 |
const TUint KMaxSqlQueryLength = 2048;
|
|
65 |
const TUint KMaxConfigStringLength = 256;
|
|
66 |
const u32_t KMTU = 1500u;
|
|
67 |
const u32_t KTrailerLength = 0;
|
|
68 |
const u32_t KHeaderOffset = 0;
|
|
69 |
const TUint KMaxEapCueLength = 3;
|
|
70 |
|
|
71 |
enum eapol_am_core_timer_id_e
|
|
72 |
{
|
|
73 |
EAPOL_AM_CORE_TIMER_RESTART_AUTHENTICATION_ID,
|
|
74 |
EAPOL_AM_CORE_TIMER_DELETE_STACK_ID,
|
|
75 |
EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID,
|
|
76 |
};
|
|
77 |
|
|
78 |
|
|
79 |
const TUint8 TEST_RSN_IE[] =
|
|
80 |
{
|
|
81 |
0xdd, // information element id, 221 expressed as Hex value
|
|
82 |
0x14, // length in octets, 20 expressed as Hex value
|
|
83 |
0x01, 0x00, // Version 1
|
|
84 |
0x00, 0x0f, 0xac, 0x04, // CCMP as group key cipher suite
|
|
85 |
0x01, 0x00, // pairwise key cipher suite count
|
|
86 |
0x00, 0x0f, 0xac, 0x04, // CCMP as pairwise key cipher suite
|
|
87 |
0x01, 0x00, // authentication count
|
|
88 |
0x00, 0x0f, 0xac, 0x01, // 802.1X authentication
|
|
89 |
0x01, 0x00, // Pre-authentication capabilities
|
|
90 |
};
|
|
91 |
|
|
92 |
// ================= MEMBER FUNCTIONS =======================
|
|
93 |
|
|
94 |
eapol_am_core_symbian_c::eapol_am_core_symbian_c(MEapolToWlmIf * const aPartner,
|
|
95 |
const bool is_client_when_true,
|
|
96 |
const TUint aServerIndex)
|
|
97 |
: CActive(CActive::EPriorityStandard)
|
|
98 |
, m_partner(aPartner)
|
|
99 |
, m_ethernet_core(0)
|
|
100 |
, m_am_tools(0)
|
|
101 |
, m_enable_random_errors(false)
|
|
102 |
, m_error_probability(0u)
|
|
103 |
, m_generate_multiple_error_packets(0u)
|
|
104 |
, m_authentication_counter(0u)
|
|
105 |
, m_successful_authentications(0u)
|
|
106 |
, m_failed_authentications(0u)
|
|
107 |
, m_is_valid(false)
|
|
108 |
, m_is_client(is_client_when_true)
|
|
109 |
, m_eap_index(0u)
|
|
110 |
, m_index_type(ELan)
|
|
111 |
, m_index(aServerIndex)
|
|
112 |
//, m_timer(0)
|
|
113 |
, m_packet_index(0)
|
|
114 |
, m_manipulate_ethernet_header(false)
|
|
115 |
, m_send_original_packet_first(false)
|
|
116 |
, m_authentication_indication_sent(false)
|
|
117 |
, m_unicast_wep_key_received(false)
|
|
118 |
, m_broadcast_wep_key_received(false)
|
|
119 |
, m_block_packet_sends_and_notifications(false)
|
|
120 |
, m_success_indication_sent(false)
|
|
121 |
, m_first_authentication(true)
|
|
122 |
, m_self_disassociated(false)
|
|
123 |
, m_802_11_authentication_mode(EAuthModeOpen)
|
|
124 |
, m_receive_network_id(0)
|
|
125 |
, m_wpa_override_enabled(false)
|
|
126 |
, m_wpa_psk_mode_allowed(false)
|
|
127 |
, m_wpa_psk_mode_active(false)
|
|
128 |
, m_stack_marked_to_be_deleted(false)
|
|
129 |
, m_active_type_is_leap(false)
|
|
130 |
, m_fileconfig(0)
|
|
131 |
{
|
|
132 |
}
|
|
133 |
|
|
134 |
//--------------------------------------------------
|
|
135 |
|
|
136 |
void eapol_am_core_symbian_c::ConstructL()
|
|
137 |
{
|
|
138 |
if (m_partner == 0)
|
|
139 |
{
|
|
140 |
User::Leave(KErrGeneral);
|
|
141 |
}
|
|
142 |
|
|
143 |
// Create tools class
|
|
144 |
m_am_tools = new(ELeave) eap_am_tools_symbian_c(EAP_DEFAULT_TRACE_FILE);
|
|
145 |
if (m_am_tools->get_is_valid() != true)
|
|
146 |
{
|
|
147 |
// The real reason most likely is KErrNoMemory but since that is not sure we'll use KErrGeneral
|
|
148 |
User::Leave(KErrGeneral);
|
|
149 |
}
|
|
150 |
if (m_am_tools->configure() != eap_status_ok)
|
|
151 |
{
|
|
152 |
User::Leave(KErrGeneral);
|
|
153 |
}
|
|
154 |
|
|
155 |
|
|
156 |
EAP_TRACE_DEBUG(
|
|
157 |
m_am_tools,
|
|
158 |
TRACE_FLAGS_DEFAULT,
|
|
159 |
(EAPL("EAPOL INITIALISATION\n")));
|
|
160 |
EAP_TRACE_DEBUG(
|
|
161 |
m_am_tools,
|
|
162 |
TRACE_FLAGS_DEFAULT,
|
|
163 |
(EAPL("====================\n")));
|
|
164 |
|
|
165 |
m_wpa_preshared_key = new (ELeave) eap_variable_data_c(m_am_tools);
|
|
166 |
|
|
167 |
m_ssid = new (ELeave) eap_variable_data_c(m_am_tools);
|
|
168 |
|
|
169 |
m_wpa_psk_password_override = new (ELeave) eap_variable_data_c(m_am_tools);
|
|
170 |
|
|
171 |
// Create/initialise the database
|
|
172 |
OpenDatabaseL(m_database, m_session);
|
|
173 |
|
|
174 |
EAP_TRACE_DEBUG(
|
|
175 |
m_am_tools,
|
|
176 |
TRACE_FLAGS_DEFAULT,
|
|
177 |
(EAPL("Database initialized...\n")));
|
|
178 |
|
|
179 |
#if defined(USE_EAP_FILECONFIG)
|
|
180 |
|
|
181 |
{
|
|
182 |
EAP_TRACE_DEBUG(
|
|
183 |
m_am_tools,
|
|
184 |
TRACE_FLAGS_DEFAULT,
|
|
185 |
(EAPL("Initialize file configuration.\n")));
|
|
186 |
eap_am_file_input_symbian_c fileio(m_am_tools);
|
|
187 |
|
|
188 |
eap_variable_data_c file_name_c_data(m_am_tools);
|
|
189 |
|
|
190 |
eap_status_e status(eap_status_process_general_error);
|
|
191 |
|
|
192 |
{
|
|
193 |
eap_const_string const FILECONFIG_FILENAME_C
|
|
194 |
= "c:\\system\\data\\eap.conf";
|
|
195 |
|
|
196 |
status = file_name_c_data.set_copy_of_buffer(
|
|
197 |
FILECONFIG_FILENAME_C,
|
|
198 |
m_am_tools->strlen(FILECONFIG_FILENAME_C));
|
|
199 |
if (status != eap_status_ok)
|
|
200 |
{
|
|
201 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
202 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
203 |
}
|
|
204 |
|
|
205 |
status = file_name_c_data.add_end_null();
|
|
206 |
if (status != eap_status_ok)
|
|
207 |
{
|
|
208 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
209 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
210 |
}
|
|
211 |
}
|
|
212 |
|
|
213 |
eap_variable_data_c file_name_z_data(m_am_tools);
|
|
214 |
|
|
215 |
{
|
|
216 |
eap_const_string const FILECONFIG_FILENAME_Z
|
|
217 |
= "z:\\private\\101F8EC5\\eap.conf";
|
|
218 |
|
|
219 |
status = file_name_z_data.set_copy_of_buffer(
|
|
220 |
FILECONFIG_FILENAME_Z,
|
|
221 |
m_am_tools->strlen(FILECONFIG_FILENAME_Z));
|
|
222 |
if (status != eap_status_ok)
|
|
223 |
{
|
|
224 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
225 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
226 |
}
|
|
227 |
|
|
228 |
status = file_name_z_data.add_end_null();
|
|
229 |
if (status != eap_status_ok)
|
|
230 |
{
|
|
231 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
232 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
233 |
}
|
|
234 |
}
|
|
235 |
|
|
236 |
if (status == eap_status_ok)
|
|
237 |
{
|
|
238 |
// First try open from C: disk.
|
|
239 |
status = fileio.file_open(
|
|
240 |
&file_name_c_data,
|
|
241 |
eap_file_io_direction_read);
|
|
242 |
if (status == eap_status_ok)
|
|
243 |
{
|
|
244 |
EAP_TRACE_DEBUG(
|
|
245 |
m_am_tools,
|
|
246 |
TRACE_FLAGS_DEFAULT,
|
|
247 |
(EAPL("Opens configure file %s\n"),
|
|
248 |
file_name_c_data.get_data(file_name_c_data.get_data_length())));
|
|
249 |
}
|
|
250 |
else if (status != eap_status_ok)
|
|
251 |
{
|
|
252 |
// Second try open from Z: disk.
|
|
253 |
status = fileio.file_open(
|
|
254 |
&file_name_z_data,
|
|
255 |
eap_file_io_direction_read);
|
|
256 |
if (status == eap_status_ok)
|
|
257 |
{
|
|
258 |
EAP_TRACE_DEBUG(
|
|
259 |
m_am_tools,
|
|
260 |
TRACE_FLAGS_DEFAULT,
|
|
261 |
(EAPL("Opens configure file %s\n"),
|
|
262 |
file_name_z_data.get_data(file_name_z_data.get_data_length())));
|
|
263 |
}
|
|
264 |
}
|
|
265 |
|
|
266 |
if (status == eap_status_ok)
|
|
267 |
{
|
|
268 |
// Some of the files were opened.
|
|
269 |
|
|
270 |
m_fileconfig = new eap_file_config_c(m_am_tools);
|
|
271 |
if (m_fileconfig != 0
|
|
272 |
&& m_fileconfig->get_is_valid() == true)
|
|
273 |
{
|
|
274 |
status = m_fileconfig->configure(&fileio);
|
|
275 |
if (status != eap_status_ok)
|
|
276 |
{
|
|
277 |
EAP_TRACE_DEBUG(
|
|
278 |
m_am_tools,
|
|
279 |
TRACE_FLAGS_DEFAULT,
|
|
280 |
(EAPL("ERROR: Configure read from %s failed.\n"),
|
|
281 |
file_name_c_data.get_data(file_name_c_data.get_data_length())));
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
EAP_TRACE_DEBUG(
|
|
286 |
m_am_tools,
|
|
287 |
TRACE_FLAGS_DEFAULT,
|
|
288 |
(EAPL("Configure read from %s\n"),
|
|
289 |
file_name_c_data.get_data(file_name_c_data.get_data_length())));
|
|
290 |
}
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
// No file configuration.
|
|
295 |
delete m_fileconfig;
|
|
296 |
m_fileconfig = 0;
|
|
297 |
|
|
298 |
EAP_TRACE_DEBUG(
|
|
299 |
m_am_tools,
|
|
300 |
TRACE_FLAGS_DEFAULT,
|
|
301 |
(EAPL("ERROR: Cannot create configure object for file %s\n"),
|
|
302 |
file_name_c_data.get_data(file_name_c_data.get_data_length())));
|
|
303 |
}
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
EAP_TRACE_DEBUG(
|
|
308 |
m_am_tools,
|
|
309 |
TRACE_FLAGS_DEFAULT,
|
|
310 |
(EAPL("ERROR: Cannot open configure file neither %s nor %s\n"),
|
|
311 |
file_name_c_data.get_data(file_name_c_data.get_data_length()),
|
|
312 |
file_name_z_data.get_data(file_name_z_data.get_data_length())));
|
|
313 |
}
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
#endif //#if defined(USE_EAP_FILECONFIG)
|
|
318 |
|
|
319 |
#if !defined(USE_EAP_HARDWARE_TRACE)
|
|
320 |
{
|
|
321 |
// Disable traces.
|
|
322 |
m_am_tools->set_trace_mask(eap_am_tools_c::eap_trace_mask_none);
|
|
323 |
|
|
324 |
eap_variable_data_c trace_output_file(m_am_tools);
|
|
325 |
|
|
326 |
eap_status_e status = read_configure(
|
|
327 |
cf_str_EAP_TRACE_output_file_name.get_field(),
|
|
328 |
&trace_output_file);
|
|
329 |
if (status == eap_status_ok
|
|
330 |
&& trace_output_file.get_is_valid_data() == true)
|
|
331 |
{
|
|
332 |
status = m_am_tools->set_trace_file_name(&trace_output_file);
|
|
333 |
if (status == eap_status_ok)
|
|
334 |
{
|
|
335 |
// OK, set the default trace mask.
|
|
336 |
m_am_tools->set_trace_mask(
|
|
337 |
eap_am_tools_c::eap_trace_mask_debug
|
|
338 |
| eap_am_tools_c::eap_trace_mask_always
|
|
339 |
| eap_am_tools_c::eap_trace_mask_error);
|
|
340 |
}
|
|
341 |
}
|
|
342 |
}
|
|
343 |
#endif //#if defined(USE_EAP_HARDWARE_TRACE)
|
|
344 |
|
|
345 |
|
|
346 |
{
|
|
347 |
eap_status_e status = configure();
|
|
348 |
if (status != eap_status_ok)
|
|
349 |
{
|
|
350 |
User::Leave(KErrGeneral);
|
|
351 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
352 |
}
|
|
353 |
}
|
|
354 |
|
|
355 |
EAP_TRACE_DEBUG(
|
|
356 |
m_am_tools,
|
|
357 |
TRACE_FLAGS_DEFAULT,
|
|
358 |
(EAPL("Configured EAPOL AM...\n")));
|
|
359 |
|
|
360 |
EAP_TRACE_DEBUG(
|
|
361 |
m_am_tools,
|
|
362 |
TRACE_FLAGS_DEFAULT,
|
|
363 |
(EAPL("Created timer...\n")));
|
|
364 |
|
|
365 |
// SERVER TEST CODE
|
|
366 |
if (m_is_client == false)
|
|
367 |
{
|
|
368 |
TRAPD(err, ReadEAPSettingsL());
|
|
369 |
if (err != KErrNone)
|
|
370 |
{
|
|
371 |
// Setting reading from CommDB failed. Use default values instead (only EAP-SIM).
|
|
372 |
|
|
373 |
// SIM
|
|
374 |
_LIT(KSIM, "18");
|
|
375 |
TEap* sim = new(ELeave) TEap;
|
|
376 |
CleanupStack::PushL(sim);
|
|
377 |
sim->Enabled = ETrue;
|
|
378 |
sim->UID.Copy(KSIM);
|
|
379 |
User::LeaveIfError(m_iap_eap_array.Append(sim));
|
|
380 |
CleanupStack::Pop(sim);
|
|
381 |
}
|
|
382 |
|
|
383 |
}
|
|
384 |
|
|
385 |
EAP_TRACE_DEBUG(
|
|
386 |
m_am_tools,
|
|
387 |
TRACE_FLAGS_DEFAULT,
|
|
388 |
(EAPL("========================\n")));
|
|
389 |
|
|
390 |
set_is_valid();
|
|
391 |
|
|
392 |
}
|
|
393 |
|
|
394 |
|
|
395 |
//--------------------------------------------------
|
|
396 |
|
|
397 |
eapol_am_core_symbian_c* eapol_am_core_symbian_c::NewL(MEapolToWlmIf * const aPartner,
|
|
398 |
const bool aIsClient,
|
|
399 |
const TUint aServerIndex)
|
|
400 |
{
|
|
401 |
eapol_am_core_symbian_c* self = new(ELeave) eapol_am_core_symbian_c(aPartner, aIsClient, aServerIndex);
|
|
402 |
CleanupStack::PushL(self);
|
|
403 |
self->ConstructL();
|
|
404 |
|
|
405 |
if (self->get_is_valid() != true)
|
|
406 |
{
|
|
407 |
User::Leave(KErrGeneral);
|
|
408 |
}
|
|
409 |
|
|
410 |
CleanupStack::Pop();
|
|
411 |
return self;
|
|
412 |
}
|
|
413 |
|
|
414 |
//--------------------------------------------------
|
|
415 |
|
|
416 |
eapol_am_core_symbian_c::~eapol_am_core_symbian_c()
|
|
417 |
{
|
|
418 |
|
|
419 |
#if defined(USE_EAP_FILECONFIG)
|
|
420 |
delete m_fileconfig;
|
|
421 |
m_fileconfig = 0;
|
|
422 |
#endif //#if defined(USE_EAP_FILECONFIG)
|
|
423 |
|
|
424 |
shutdown();
|
|
425 |
}
|
|
426 |
|
|
427 |
//--------------------------------------------------
|
|
428 |
|
|
429 |
//
|
|
430 |
eap_status_e eapol_am_core_symbian_c::shutdown()
|
|
431 |
{
|
|
432 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
433 |
|
|
434 |
EAP_TRACE_DEBUG(
|
|
435 |
m_am_tools,
|
|
436 |
TRACE_FLAGS_DEFAULT,
|
|
437 |
(EAPL("eapol_am_core_symbian_c::shutdown()\n")));
|
|
438 |
|
|
439 |
// Cancel timer
|
|
440 |
cancel_all_timers();
|
|
441 |
|
|
442 |
// Delete upper stack if it still exists
|
|
443 |
if (m_ethernet_core != 0)
|
|
444 |
{
|
|
445 |
m_ethernet_core->shutdown();
|
|
446 |
delete m_ethernet_core;
|
|
447 |
}
|
|
448 |
|
|
449 |
delete m_wpa_preshared_key;
|
|
450 |
|
|
451 |
delete m_ssid;
|
|
452 |
|
|
453 |
delete m_wpa_psk_password_override;
|
|
454 |
|
|
455 |
delete m_receive_network_id;
|
|
456 |
|
|
457 |
m_database.Close();
|
|
458 |
m_session.Close();
|
|
459 |
|
|
460 |
// Print some statistics
|
|
461 |
if (m_is_client)
|
|
462 |
{
|
|
463 |
EAP_TRACE_ALWAYS(
|
|
464 |
m_am_tools,
|
|
465 |
TRACE_FLAGS_ALWAYS|TRACE_TEST_VECTORS,
|
|
466 |
(EAPL("client authentication SUCCESS %d, FAILED %d, count %d\n"),
|
|
467 |
m_successful_authentications,
|
|
468 |
m_failed_authentications,
|
|
469 |
m_authentication_counter));
|
|
470 |
}
|
|
471 |
else
|
|
472 |
{
|
|
473 |
EAP_TRACE_ALWAYS(
|
|
474 |
m_am_tools,
|
|
475 |
TRACE_FLAGS_ALWAYS|TRACE_TEST_VECTORS,
|
|
476 |
(EAPL("server authentication SUCCESS %d, FAILED %d, count %d\n"),
|
|
477 |
m_successful_authentications,
|
|
478 |
m_failed_authentications,
|
|
479 |
m_authentication_counter));
|
|
480 |
}
|
|
481 |
|
|
482 |
EAP_TRACE_DEBUG(
|
|
483 |
m_am_tools,
|
|
484 |
TRACE_FLAGS_DEFAULT,
|
|
485 |
(EAPL("EAPOL EXITING.\n")));
|
|
486 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
487 |
|
|
488 |
// Finally delete tools. No logging is allowed after this.
|
|
489 |
if (m_am_tools != 0)
|
|
490 |
{
|
|
491 |
m_am_tools->shutdown();
|
|
492 |
delete m_am_tools;
|
|
493 |
}
|
|
494 |
|
|
495 |
|
|
496 |
// Unload all loaded plugins
|
|
497 |
// NOTE this must be after the m_am_tools->shutdown() call.
|
|
498 |
// m_am_tools->shutdown() will run virtual functions of some plugins.
|
|
499 |
for(int i = 0; i < m_plugin_if_array.Count(); i++)
|
|
500 |
{
|
|
501 |
delete m_plugin_if_array[i];
|
|
502 |
}
|
|
503 |
|
|
504 |
m_plugin_if_array.Close();
|
|
505 |
m_eap_type_array.Close();
|
|
506 |
|
|
507 |
// Delete the IAP EAP type info array
|
|
508 |
m_iap_eap_array.ResetAndDestroy();
|
|
509 |
|
|
510 |
|
|
511 |
return eap_status_ok;
|
|
512 |
}
|
|
513 |
|
|
514 |
//--------------------------------------------------
|
|
515 |
|
|
516 |
//
|
|
517 |
void eapol_am_core_symbian_c::RunL()
|
|
518 |
{
|
|
519 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
520 |
EAP_TRACE_DEBUG(
|
|
521 |
m_am_tools,
|
|
522 |
TRACE_FLAGS_DEFAULT,
|
|
523 |
(EAPL("eapol_am_core_symbian_c::RunL(): iStatus.Int() = %d\n"),
|
|
524 |
iStatus.Int()));
|
|
525 |
|
|
526 |
if (iStatus.Int() != KErrNone)
|
|
527 |
{
|
|
528 |
return;
|
|
529 |
}
|
|
530 |
|
|
531 |
// Authentication cancelled.
|
|
532 |
EAP_TRACE_ALWAYS(
|
|
533 |
m_am_tools,
|
|
534 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
535 |
(EAPL("Authentication cancelled.\n")));
|
|
536 |
|
|
537 |
// Set block on.
|
|
538 |
m_block_packet_sends_and_notifications = true;
|
|
539 |
|
|
540 |
// Reset flags
|
|
541 |
m_success_indication_sent = false;
|
|
542 |
m_unicast_wep_key_received = false;
|
|
543 |
m_broadcast_wep_key_received = false;
|
|
544 |
m_authentication_indication_sent = false;
|
|
545 |
|
|
546 |
m_stack_marked_to_be_deleted = true;
|
|
547 |
set_timer(this, EAPOL_AM_CORE_TIMER_DELETE_STACK_ID, 0, 0);
|
|
548 |
|
|
549 |
// reset index
|
|
550 |
m_eap_index = 0;
|
|
551 |
|
|
552 |
EAP_TRACE_ALWAYS(
|
|
553 |
m_am_tools,
|
|
554 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
555 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
556 |
|
|
557 |
m_partner->EapIndication(EFailedCompletely);
|
|
558 |
|
|
559 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
560 |
}
|
|
561 |
|
|
562 |
//--------------------------------------------------
|
|
563 |
|
|
564 |
//
|
|
565 |
void eapol_am_core_symbian_c::DoCancel()
|
|
566 |
{
|
|
567 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
568 |
|
|
569 |
EAP_TRACE_DEBUG(
|
|
570 |
m_am_tools,
|
|
571 |
TRACE_FLAGS_DEFAULT,
|
|
572 |
(EAPL("eapol_am_core_symbian_c::DoCancel()\n")));
|
|
573 |
|
|
574 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
575 |
}
|
|
576 |
|
|
577 |
//--------------------------------------------------
|
|
578 |
|
|
579 |
//
|
|
580 |
TInt eapol_am_core_symbian_c::Start(const TIndexType aIndexType,
|
|
581 |
const TUint aIndex,
|
|
582 |
const TSSID& aSSID,
|
|
583 |
const TBool aWPAOverrideEnabled,
|
|
584 |
const TUint8* aWPAPSK,
|
|
585 |
const TUint aWPAPSKLength)
|
|
586 |
{
|
|
587 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
588 |
|
|
589 |
EAP_TRACE_DEBUG(
|
|
590 |
m_am_tools,
|
|
591 |
TRACE_FLAGS_DEFAULT,
|
|
592 |
(EAPL("eapol_am_core_symbian_c::Start()\n")));
|
|
593 |
|
|
594 |
EAP_TRACE_DEBUG(
|
|
595 |
m_am_tools,
|
|
596 |
TRACE_FLAGS_DEFAULT,
|
|
597 |
(EAPL("STARTING AUTHENTICATION.\n")));
|
|
598 |
|
|
599 |
eap_status_e status(eap_status_ok);
|
|
600 |
|
|
601 |
if (m_ethernet_core != 0)
|
|
602 |
{
|
|
603 |
EAP_TRACE_DEBUG(
|
|
604 |
m_am_tools,
|
|
605 |
TRACE_FLAGS_DEFAULT,
|
|
606 |
(EAPL("Deleting previously used stack.\n")));
|
|
607 |
|
|
608 |
// It is an error to call start without calling disassociated
|
|
609 |
if (m_stack_marked_to_be_deleted == false)
|
|
610 |
{
|
|
611 |
EAP_TRACE_ERROR(
|
|
612 |
m_am_tools,
|
|
613 |
TRACE_FLAGS_DEFAULT,
|
|
614 |
(EAPL("eapol_am_core_symbian_c::Start called twice!\n")));
|
|
615 |
return KErrAlreadyExists;
|
|
616 |
}
|
|
617 |
|
|
618 |
// The previously used stack is perhaps still waiting for deletion.
|
|
619 |
cancel_timer(this, EAPOL_AM_CORE_TIMER_DELETE_STACK_ID);
|
|
620 |
|
|
621 |
// Delete stack
|
|
622 |
m_ethernet_core->shutdown();
|
|
623 |
delete m_ethernet_core;
|
|
624 |
m_ethernet_core = 0;
|
|
625 |
|
|
626 |
m_stack_marked_to_be_deleted = false;
|
|
627 |
}
|
|
628 |
|
|
629 |
// Clear packet send and notification blocking.
|
|
630 |
m_block_packet_sends_and_notifications = false;
|
|
631 |
|
|
632 |
// Store SSID. This is needed for WPA PSK calculation.
|
|
633 |
if (aSSID.ssidLength > 0)
|
|
634 |
{
|
|
635 |
status = m_ssid->set_copy_of_buffer(aSSID.ssid, aSSID.ssidLength);
|
|
636 |
if (status != eap_status_ok)
|
|
637 |
{
|
|
638 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// Store WPAPSK. This is needed for WPA PSK mode in Easy WLAN.
|
|
643 |
if (aWPAPSKLength > 0
|
|
644 |
&& aWPAPSK != 0)
|
|
645 |
{
|
|
646 |
status = m_wpa_psk_password_override->set_copy_of_buffer(aWPAPSK, aWPAPSKLength);
|
|
647 |
if (status != eap_status_ok)
|
|
648 |
{
|
|
649 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
650 |
}
|
|
651 |
}
|
|
652 |
|
|
653 |
if (aWPAOverrideEnabled)
|
|
654 |
{
|
|
655 |
m_wpa_override_enabled = true;
|
|
656 |
}
|
|
657 |
else
|
|
658 |
{
|
|
659 |
m_wpa_override_enabled = false;
|
|
660 |
}
|
|
661 |
|
|
662 |
///////////////////////////////////
|
|
663 |
// Get EAP parameters from CommDbIf
|
|
664 |
///////////////////////////////////
|
|
665 |
m_index_type = aIndexType;
|
|
666 |
m_index = aIndex;
|
|
667 |
|
|
668 |
TRAPD(err, ReadEAPSettingsL());
|
|
669 |
if (err != KErrNone)
|
|
670 |
{
|
|
671 |
EAP_TRACE_ERROR(
|
|
672 |
m_am_tools,
|
|
673 |
TRACE_FLAGS_DEFAULT,
|
|
674 |
(EAPL("EAP settings reading from CommDb failed or cancelled(err %d).\n"), err));
|
|
675 |
m_partner->EapIndication(EFailedCompletely);
|
|
676 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
677 |
return err;
|
|
678 |
}
|
|
679 |
|
|
680 |
// Start new authentication from scratch.
|
|
681 |
m_unicast_wep_key_received = false;
|
|
682 |
m_broadcast_wep_key_received = false;
|
|
683 |
m_wpa_psk_mode_active = false;
|
|
684 |
|
|
685 |
if (m_wpa_psk_mode_allowed == false
|
|
686 |
|| m_wpa_preshared_key->get_data_length() == 0)
|
|
687 |
{
|
|
688 |
// Check the first enabled type
|
|
689 |
TEap* eapType = 0;
|
|
690 |
TInt i(0);
|
|
691 |
for (i = 0; i < m_iap_eap_array.Count(); i++)
|
|
692 |
{
|
|
693 |
// Check if type is enabled
|
|
694 |
eapType = m_iap_eap_array[i];
|
|
695 |
if (eapType->Enabled == 1)
|
|
696 |
{
|
|
697 |
break;
|
|
698 |
}
|
|
699 |
}
|
|
700 |
if (i >= m_iap_eap_array.Count())
|
|
701 |
{
|
|
702 |
// No enabled EAP types.
|
|
703 |
EAP_TRACE_ALWAYS(
|
|
704 |
m_am_tools,
|
|
705 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
706 |
(EAPL("No enabled EAP types.\n")));
|
|
707 |
EAP_TRACE_ALWAYS(
|
|
708 |
m_am_tools,
|
|
709 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
710 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
711 |
|
|
712 |
m_partner->EapIndication(EFailedCompletely);
|
|
713 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
714 |
return KErrNone;
|
|
715 |
}
|
|
716 |
|
|
717 |
// reset index (start from the first enabled EAP type)
|
|
718 |
m_eap_index = i;
|
|
719 |
|
|
720 |
// Check if the first enabled type is LEAP.
|
|
721 |
TLex8 tmp(eapType->UID);
|
|
722 |
TInt type(0);
|
|
723 |
tmp.Val(type);
|
|
724 |
|
|
725 |
switch (type)
|
|
726 |
{
|
|
727 |
case eap_type_leap:
|
|
728 |
if (m_security_mode != Wpa
|
|
729 |
&& m_security_mode != Wpa2Only)
|
|
730 |
{
|
|
731 |
m_802_11_authentication_mode = EAuthModeLeap;
|
|
732 |
|
|
733 |
EAP_TRACE_ALWAYS(
|
|
734 |
m_am_tools,
|
|
735 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
736 |
(EAPL("Start: Trying auth mode LEAP.\n")));
|
|
737 |
}
|
|
738 |
else
|
|
739 |
{
|
|
740 |
// If security mode is WPA or WPA2 then even LEAP uses open authentication!
|
|
741 |
m_802_11_authentication_mode = EAuthModeOpen;
|
|
742 |
|
|
743 |
EAP_TRACE_ALWAYS(
|
|
744 |
m_am_tools,
|
|
745 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
746 |
(EAPL("Start: Trying auth mode OPEN (LEAP in WPA mode).\n")));
|
|
747 |
}
|
|
748 |
|
|
749 |
m_active_type_is_leap = true;
|
|
750 |
break;
|
|
751 |
default:
|
|
752 |
m_802_11_authentication_mode = EAuthModeOpen;
|
|
753 |
|
|
754 |
EAP_TRACE_ALWAYS(
|
|
755 |
m_am_tools,
|
|
756 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
757 |
(EAPL("Start: Trying auth mode OPEN.\n")));
|
|
758 |
|
|
759 |
m_active_type_is_leap = false;
|
|
760 |
break;
|
|
761 |
}
|
|
762 |
}
|
|
763 |
else
|
|
764 |
{
|
|
765 |
// WPA Pre-shared key mode
|
|
766 |
m_active_type_is_leap = false;
|
|
767 |
m_wpa_psk_mode_active = true;
|
|
768 |
m_802_11_authentication_mode = EAuthModeOpen;
|
|
769 |
|
|
770 |
EAP_TRACE_ALWAYS(
|
|
771 |
m_am_tools,
|
|
772 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
773 |
(EAPL("Start: Trying auth mode OPEN.\n")));
|
|
774 |
}
|
|
775 |
|
|
776 |
// Ignore return value. Result comes with CompleteAssociation call.
|
|
777 |
m_partner->Associate(m_802_11_authentication_mode);
|
|
778 |
|
|
779 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
780 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
781 |
}
|
|
782 |
|
|
783 |
//--------------------------------------------------
|
|
784 |
|
|
785 |
//
|
|
786 |
TInt eapol_am_core_symbian_c::CompleteAssociation(
|
|
787 |
const TInt aResult,
|
|
788 |
const TMacAddress& aLocalAddress,
|
|
789 |
const TMacAddress& aRemoteAddress,
|
|
790 |
const TUint8* const aReceivedWPAIE, // WLM must give only the WPA IE to EAPOL
|
|
791 |
const TUint aReceivedWPAIELength,
|
|
792 |
const TUint8* const aSentWPAIE,
|
|
793 |
const TUint aSentWPAIELength,
|
|
794 |
const TWPACipherSuite aGroupKeyCipherSuite,
|
|
795 |
const TWPACipherSuite aPairwiseKeyCipherSuite
|
|
796 |
)
|
|
797 |
{
|
|
798 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
799 |
|
|
800 |
EAP_TRACE_ALWAYS(
|
|
801 |
m_am_tools,
|
|
802 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
803 |
(EAPL("eapol_am_core_symbian_c::CompleteAssociation(): aResult %d\n"),
|
|
804 |
aResult));
|
|
805 |
|
|
806 |
eap_status_e status(eap_status_ok);
|
|
807 |
|
|
808 |
// ASSOCIATION UNSUCCESSFUL
|
|
809 |
if (aResult != KErrNone)
|
|
810 |
{
|
|
811 |
EAP_TRACE_DEBUG(
|
|
812 |
m_am_tools,
|
|
813 |
TRACE_FLAGS_DEFAULT,
|
|
814 |
(EAPL("CompleteAssociation: Unsuccessful.\n")));
|
|
815 |
|
|
816 |
EAP_TRACE_DATA_DEBUG(
|
|
817 |
m_am_tools,
|
|
818 |
TRACE_FLAGS_DEFAULT,
|
|
819 |
(EAPL("Got AP MAC address"),
|
|
820 |
aRemoteAddress.iMacAddress,
|
|
821 |
KMacAddressLength));
|
|
822 |
|
|
823 |
// Report rogue AP if we tried LEAP and it failed
|
|
824 |
if (m_802_11_authentication_mode == EAuthModeLeap)
|
|
825 |
{
|
|
826 |
// Only add rogue AP if the error code is correct
|
|
827 |
if (aResult == E802Dot11StatusAuthAlgorithmNotSupported)
|
|
828 |
{
|
|
829 |
eap_rogue_ap_entry_c rogue_entry(m_am_tools);
|
|
830 |
|
|
831 |
rogue_entry.set_mac_address(static_cast<const u8_t *>(aRemoteAddress.iMacAddress));
|
|
832 |
rogue_entry.set_rogue_reason(rogue_ap_association_failed);
|
|
833 |
|
|
834 |
eap_array_c<eap_rogue_ap_entry_c> rogue_list(m_am_tools);
|
|
835 |
status = rogue_list.add_object(&rogue_entry, false);
|
|
836 |
if (status == eap_status_ok)
|
|
837 |
{
|
|
838 |
status = add_rogue_ap(rogue_list);
|
|
839 |
// Ignore return value on purpose - it's not fatal if this fails
|
|
840 |
}
|
|
841 |
}
|
|
842 |
}
|
|
843 |
|
|
844 |
if (m_wpa_psk_mode_active == false)
|
|
845 |
{
|
|
846 |
if (aResult == E802Dot11StatusAuthAlgorithmNotSupported
|
|
847 |
&& m_security_mode != Wpa
|
|
848 |
&& m_security_mode != Wpa2Only) // If security mode is WPA or WPA2 then only OPEN auth should be used
|
|
849 |
{
|
|
850 |
// Association failed because we had wrong authentication type.
|
|
851 |
// Try to find next allowed type that uses different authentication type
|
|
852 |
m_eap_index++;
|
|
853 |
|
|
854 |
TEap* eapType;
|
|
855 |
TBool found(EFalse);
|
|
856 |
TInt i(0);
|
|
857 |
for (i = m_eap_index; i < m_iap_eap_array.Count(); i++)
|
|
858 |
{
|
|
859 |
// Check if type is enabled
|
|
860 |
eapType = m_iap_eap_array[i];
|
|
861 |
if (eapType->Enabled == 1)
|
|
862 |
{
|
|
863 |
TLex8 tmp(eapType->UID);
|
|
864 |
TInt type(0);
|
|
865 |
tmp.Val(type);
|
|
866 |
|
|
867 |
switch (type)
|
|
868 |
{
|
|
869 |
case eap_type_leap:
|
|
870 |
if (m_802_11_authentication_mode != EAuthModeLeap)
|
|
871 |
{
|
|
872 |
// This type will do; it uses different authentication mode.
|
|
873 |
EAP_TRACE_ALWAYS(
|
|
874 |
m_am_tools,
|
|
875 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
876 |
(EAPL("CompleteAssociation: Changed auth mode to LEAP.\n")));
|
|
877 |
|
|
878 |
m_802_11_authentication_mode = EAuthModeLeap;
|
|
879 |
m_active_type_is_leap = true;
|
|
880 |
found = ETrue;
|
|
881 |
}
|
|
882 |
break;
|
|
883 |
default:
|
|
884 |
if (m_802_11_authentication_mode != EAuthModeOpen)
|
|
885 |
{
|
|
886 |
// This type will do; it uses different authentication mode.
|
|
887 |
EAP_TRACE_ALWAYS(
|
|
888 |
m_am_tools,
|
|
889 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
890 |
(EAPL("CompleteAssociation: Changed auth mode to OPEN.\n")));
|
|
891 |
|
|
892 |
m_802_11_authentication_mode = EAuthModeOpen;
|
|
893 |
m_active_type_is_leap = false;
|
|
894 |
found = ETrue;
|
|
895 |
}
|
|
896 |
break;
|
|
897 |
}
|
|
898 |
if (found)
|
|
899 |
{
|
|
900 |
break;
|
|
901 |
}
|
|
902 |
}
|
|
903 |
}
|
|
904 |
|
|
905 |
m_eap_index = i;
|
|
906 |
|
|
907 |
if (i >= m_iap_eap_array.Count())
|
|
908 |
{
|
|
909 |
// All the remaining allowed types had the same authentication mode.
|
|
910 |
// Give up this AP.
|
|
911 |
EAP_TRACE_ALWAYS(
|
|
912 |
m_am_tools,
|
|
913 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
914 |
(EAPL("Could not associate to the AP. Tried all types.\n")));
|
|
915 |
|
|
916 |
EAP_TRACE_ALWAYS(
|
|
917 |
m_am_tools,
|
|
918 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
919 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
920 |
|
|
921 |
m_partner->EapIndication(EThisAPFailed);
|
|
922 |
return KErrNone;
|
|
923 |
|
|
924 |
}
|
|
925 |
|
|
926 |
// We found a type with different authentication mode. Try it.
|
|
927 |
|
|
928 |
// Ignore return value. Result comes with CompleteAssociation call.
|
|
929 |
m_partner->Associate(m_802_11_authentication_mode);
|
|
930 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
931 |
return KErrNone;
|
|
932 |
}
|
|
933 |
else
|
|
934 |
{
|
|
935 |
EAP_TRACE_ALWAYS(
|
|
936 |
m_am_tools,
|
|
937 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
938 |
(EAPL("Could not associate to the AP (error %d).\n"), aResult));
|
|
939 |
|
|
940 |
EAP_TRACE_ALWAYS(
|
|
941 |
m_am_tools,
|
|
942 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
943 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
944 |
|
|
945 |
m_partner->EapIndication(EThisAPFailed);
|
|
946 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
947 |
return KErrNone;
|
|
948 |
}
|
|
949 |
}
|
|
950 |
else
|
|
951 |
{
|
|
952 |
EAP_TRACE_ALWAYS(
|
|
953 |
m_am_tools,
|
|
954 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
955 |
(EAPL("Could not associate to the AP with WPA pre-shared-key.\n")));
|
|
956 |
|
|
957 |
EAP_TRACE_ALWAYS(
|
|
958 |
m_am_tools,
|
|
959 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
960 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
961 |
|
|
962 |
m_partner->EapIndication(EThisAPFailed);
|
|
963 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
964 |
return KErrNone;
|
|
965 |
}
|
|
966 |
}
|
|
967 |
|
|
968 |
// ASSOCIATION SUCCESSFUL
|
|
969 |
EAP_TRACE_ALWAYS(
|
|
970 |
m_am_tools,
|
|
971 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
972 |
(EAPL("CompleteAssociation: Successful.\n")));
|
|
973 |
|
|
974 |
// Store parameters
|
|
975 |
m_local_address = aLocalAddress;
|
|
976 |
|
|
977 |
m_remote_address = aRemoteAddress;
|
|
978 |
|
|
979 |
m_received_wpa_ie = aReceivedWPAIE;
|
|
980 |
|
|
981 |
m_received_wpa_ie_length = aReceivedWPAIELength;
|
|
982 |
|
|
983 |
m_sent_wpa_ie = aSentWPAIE;
|
|
984 |
|
|
985 |
m_sent_wpa_ie_length = aSentWPAIELength;
|
|
986 |
|
|
987 |
m_group_key_cipher_suite = aGroupKeyCipherSuite;
|
|
988 |
|
|
989 |
m_pairwise_key_cipher_suite = aPairwiseKeyCipherSuite;
|
|
990 |
|
|
991 |
// Create stack if it does not already exist.
|
|
992 |
status = create_upper_stack();
|
|
993 |
if (status != eap_status_ok
|
|
994 |
&& status != eap_status_already_exists)
|
|
995 |
{
|
|
996 |
EAP_TRACE_ALWAYS(
|
|
997 |
m_am_tools,
|
|
998 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
999 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1000 |
|
|
1001 |
m_partner->EapIndication(EFailedCompletely);
|
|
1002 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1003 |
return KErrNone;
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
// First create stack object and then copy it to heap object. This is because
|
|
1007 |
// eap_am_network_id_c does not have a constructor that copies the buffers.
|
|
1008 |
eap_am_network_id_c receive_network_id(
|
|
1009 |
m_am_tools,
|
|
1010 |
&aRemoteAddress,
|
|
1011 |
sizeof(TMacAddress),
|
|
1012 |
&aLocalAddress,
|
|
1013 |
sizeof(TMacAddress),
|
|
1014 |
eapol_ethernet_type_pae,
|
|
1015 |
false,
|
|
1016 |
false);
|
|
1017 |
|
|
1018 |
delete m_receive_network_id;
|
|
1019 |
m_receive_network_id = new eap_am_network_id_c(
|
|
1020 |
m_am_tools);
|
|
1021 |
|
|
1022 |
if (m_receive_network_id == 0)
|
|
1023 |
{
|
|
1024 |
EAP_TRACE_ALWAYS(
|
|
1025 |
m_am_tools,
|
|
1026 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1027 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1028 |
|
|
1029 |
m_partner->EapIndication(EFailedCompletely);
|
|
1030 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1031 |
return KErrNone;
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
status = m_receive_network_id->set_copy_of_network_id(&receive_network_id);
|
|
1035 |
if (status != eap_status_ok)
|
|
1036 |
{
|
|
1037 |
EAP_TRACE_ALWAYS(
|
|
1038 |
m_am_tools,
|
|
1039 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1040 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1041 |
|
|
1042 |
m_partner->EapIndication(EFailedCompletely);
|
|
1043 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1044 |
return KErrNone;
|
|
1045 |
}
|
|
1046 |
|
|
1047 |
|
|
1048 |
#if defined (USE_EAPOL_KEY_STATE)
|
|
1049 |
|
|
1050 |
// Initialise EAPOL key state
|
|
1051 |
|
|
1052 |
eapol_key_authentication_type_e authentication_type(eapol_key_authentication_type_dynamic_WEP);
|
|
1053 |
|
|
1054 |
if (aReceivedWPAIE !=0
|
|
1055 |
&& aSentWPAIE != 0)
|
|
1056 |
{
|
|
1057 |
// WPA (in wpa or 802.1x security mode)
|
|
1058 |
if (m_wpa_psk_mode_allowed == false)
|
|
1059 |
{
|
|
1060 |
authentication_type = eapol_key_authentication_type_WPA_EAP;
|
|
1061 |
}
|
|
1062 |
else
|
|
1063 |
{
|
|
1064 |
m_wpa_psk_mode_active = true;
|
|
1065 |
authentication_type = eapol_key_authentication_type_WPA_PSK;
|
|
1066 |
}
|
|
1067 |
|
|
1068 |
}
|
|
1069 |
else
|
|
1070 |
{
|
|
1071 |
// Non-wpa mode
|
|
1072 |
authentication_type = eapol_key_authentication_type_dynamic_WEP;
|
|
1073 |
}
|
|
1074 |
|
|
1075 |
eap_variable_data_c authenticator_RSNA_IE(m_am_tools);
|
|
1076 |
eap_variable_data_c supplicant_RSNA_IE(m_am_tools);
|
|
1077 |
|
|
1078 |
// Note: the default values here are only for 802.1x mode. In that mode
|
|
1079 |
// we don't know the WEP key length beforehand so we will have to guess.
|
|
1080 |
// It does not matter in this case if we guess wrong - only thing that matters
|
|
1081 |
// is that it is WEP.
|
|
1082 |
eapol_RSNA_key_header_c::eapol_RSNA_cipher_e
|
|
1083 |
eapol_pairwise_cipher(eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_40);
|
|
1084 |
eapol_RSNA_key_header_c::eapol_RSNA_cipher_e
|
|
1085 |
eapol_group_cipher(eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_40);
|
|
1086 |
|
|
1087 |
// WPA mode is active if information elements are valid
|
|
1088 |
if (aReceivedWPAIE != 0
|
|
1089 |
&& aSentWPAIE != 0)
|
|
1090 |
{
|
|
1091 |
status = authenticator_RSNA_IE.set_copy_of_buffer(aReceivedWPAIE, aReceivedWPAIELength);
|
|
1092 |
if (status != eap_status_ok)
|
|
1093 |
{
|
|
1094 |
EAP_TRACE_ALWAYS(
|
|
1095 |
m_am_tools,
|
|
1096 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1097 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1098 |
|
|
1099 |
m_partner->EapIndication(EFailedCompletely);
|
|
1100 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1101 |
return KErrNoMemory;
|
|
1102 |
}
|
|
1103 |
status = supplicant_RSNA_IE.set_copy_of_buffer(aSentWPAIE, aSentWPAIELength);
|
|
1104 |
if (status != eap_status_ok)
|
|
1105 |
{
|
|
1106 |
EAP_TRACE_ALWAYS(
|
|
1107 |
m_am_tools,
|
|
1108 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1109 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1110 |
|
|
1111 |
m_partner->EapIndication(EFailedCompletely);
|
|
1112 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1113 |
return KErrNoMemory;
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
switch (aGroupKeyCipherSuite)
|
|
1117 |
{
|
|
1118 |
case ENoCipherSuite:
|
|
1119 |
eapol_group_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_none;
|
|
1120 |
break;
|
|
1121 |
case EWEP40:
|
|
1122 |
eapol_group_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_40;
|
|
1123 |
break;
|
|
1124 |
case EWEP104:
|
|
1125 |
eapol_group_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_104;
|
|
1126 |
break;
|
|
1127 |
case ETKIP:
|
|
1128 |
eapol_group_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_TKIP;
|
|
1129 |
break;
|
|
1130 |
case ECCMP:
|
|
1131 |
eapol_group_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP;
|
|
1132 |
break;
|
|
1133 |
case EWRAP:
|
|
1134 |
default:
|
|
1135 |
User::Panic(_L("EAPOL"), KErrNotSupported);
|
|
1136 |
}
|
|
1137 |
|
|
1138 |
switch (aPairwiseKeyCipherSuite)
|
|
1139 |
{
|
|
1140 |
case ENoCipherSuite:
|
|
1141 |
eapol_pairwise_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_none;
|
|
1142 |
break;
|
|
1143 |
case EWEP40:
|
|
1144 |
eapol_pairwise_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_40;
|
|
1145 |
break;
|
|
1146 |
case EWEP104:
|
|
1147 |
eapol_pairwise_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_WEP_104;
|
|
1148 |
break;
|
|
1149 |
case ETKIP:
|
|
1150 |
eapol_pairwise_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_TKIP;
|
|
1151 |
break;
|
|
1152 |
case ECCMP:
|
|
1153 |
eapol_pairwise_cipher = eapol_RSNA_key_header_c::eapol_RSNA_cipher_CCMP;
|
|
1154 |
break;
|
|
1155 |
case EWRAP:
|
|
1156 |
default:
|
|
1157 |
User::Panic(_L("EAPOL"), KErrNotSupported);
|
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
|
|
1161 |
if (authentication_type == eapol_key_authentication_type_WPA_PSK)
|
|
1162 |
{
|
|
1163 |
status = m_ethernet_core->association(
|
|
1164 |
m_receive_network_id,
|
|
1165 |
authentication_type,
|
|
1166 |
&authenticator_RSNA_IE,
|
|
1167 |
&supplicant_RSNA_IE,
|
|
1168 |
eapol_pairwise_cipher,
|
|
1169 |
eapol_group_cipher,
|
|
1170 |
m_wpa_preshared_key);
|
|
1171 |
}
|
|
1172 |
else
|
|
1173 |
{
|
|
1174 |
status = m_ethernet_core->association(
|
|
1175 |
m_receive_network_id,
|
|
1176 |
authentication_type,
|
|
1177 |
&authenticator_RSNA_IE,
|
|
1178 |
&supplicant_RSNA_IE,
|
|
1179 |
eapol_pairwise_cipher,
|
|
1180 |
eapol_group_cipher,
|
|
1181 |
0);
|
|
1182 |
}
|
|
1183 |
if (status != eap_status_ok)
|
|
1184 |
{
|
|
1185 |
|
|
1186 |
EAP_TRACE_ALWAYS(
|
|
1187 |
m_am_tools,
|
|
1188 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1189 |
(EAPL("m_ethernet_core->association call failed.\n")));
|
|
1190 |
|
|
1191 |
EAP_TRACE_ALWAYS(
|
|
1192 |
m_am_tools,
|
|
1193 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1194 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1195 |
|
|
1196 |
m_partner->EapIndication(EFailedCompletely);
|
|
1197 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1198 |
return KErrGeneral;
|
|
1199 |
}
|
|
1200 |
|
|
1201 |
#endif // USE_EAPOL_KEY_STATE
|
|
1202 |
|
|
1203 |
if (m_wpa_psk_mode_active == false)
|
|
1204 |
{
|
|
1205 |
// Start authentication if mode is not pre-shared key. If mode is pre-shared key then
|
|
1206 |
// just wait for EAPOL-Key frames.
|
|
1207 |
status = m_ethernet_core->start_authentication(m_receive_network_id, m_is_client);
|
|
1208 |
}
|
|
1209 |
|
|
1210 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1211 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
1212 |
}
|
|
1213 |
|
|
1214 |
//--------------------------------------------------
|
|
1215 |
|
|
1216 |
//
|
|
1217 |
TInt eapol_am_core_symbian_c::ReceivePacket(const TUint aLength, const TUint8* const aPacket)
|
|
1218 |
{
|
|
1219 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1220 |
|
|
1221 |
EAP_TRACE_DEBUG(
|
|
1222 |
m_am_tools,
|
|
1223 |
TRACE_FLAGS_DEFAULT,
|
|
1224 |
(EAPL("eapol_am_core_symbian_c::ReceivePacket()\n")));
|
|
1225 |
|
|
1226 |
if (aLength < eapol_ethernet_header_wr_c::get_header_length())
|
|
1227 |
{
|
|
1228 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1229 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, eap_status_too_short_message));
|
|
1230 |
}
|
|
1231 |
|
|
1232 |
eapol_ethernet_header_wr_c eth_header(m_am_tools, aPacket, aLength);
|
|
1233 |
eap_am_network_id_c receive_network_id(
|
|
1234 |
m_am_tools,
|
|
1235 |
eth_header.get_source(),
|
|
1236 |
eth_header.get_source_length(),
|
|
1237 |
eth_header.get_destination(),
|
|
1238 |
eth_header.get_destination_length(),
|
|
1239 |
eth_header.get_type(),
|
|
1240 |
false,
|
|
1241 |
false);
|
|
1242 |
eap_status_e status(eap_status_process_general_error);
|
|
1243 |
if (eth_header.get_type() == eapol_ethernet_type_pae)
|
|
1244 |
{
|
|
1245 |
status = create_upper_stack();
|
|
1246 |
if (status != eap_status_ok
|
|
1247 |
&& status != eap_status_already_exists)
|
|
1248 |
{
|
|
1249 |
EAP_TRACE_DEBUG(
|
|
1250 |
m_am_tools,
|
|
1251 |
TRACE_FLAGS_DEFAULT,
|
|
1252 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1253 |
m_partner->EapIndication(EFailedCompletely);
|
|
1254 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1255 |
return KErrNone;
|
|
1256 |
}
|
|
1257 |
|
|
1258 |
#if defined (USE_EAPOL_KEY_STATE)
|
|
1259 |
if (m_is_client == false
|
|
1260 |
&& status != eap_status_already_exists)
|
|
1261 |
{
|
|
1262 |
// If we are server we need to do associate here.
|
|
1263 |
eapol_key_authentication_type_e authentication_type(
|
|
1264 |
eapol_key_authentication_type_WPA_EAP);
|
|
1265 |
|
|
1266 |
eap_variable_data_c authenticator_RSNA_IE(m_am_tools);
|
|
1267 |
eap_variable_data_c supplicant_RSNA_IE(m_am_tools);
|
|
1268 |
|
|
1269 |
status = authenticator_RSNA_IE.set_buffer(TEST_RSN_IE, sizeof(TEST_RSN_IE), false, false);
|
|
1270 |
if (status != eap_status_ok)
|
|
1271 |
{
|
|
1272 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1273 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
1274 |
}
|
|
1275 |
|
|
1276 |
status = supplicant_RSNA_IE.set_buffer(TEST_RSN_IE, sizeof(TEST_RSN_IE), false, false);
|
|
1277 |
if (status != eap_status_ok)
|
|
1278 |
{
|
|
1279 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1280 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
1281 |
}
|
|
1282 |
|
|
1283 |
eapol_RSNA_key_header_c::eapol_RSNA_cipher_e
|
|
1284 |
eapol_pairwise_cipher(eapol_RSNA_key_header_c::eapol_RSNA_cipher_TKIP);
|
|
1285 |
eapol_RSNA_key_header_c::eapol_RSNA_cipher_e
|
|
1286 |
eapol_group_cipher(eapol_RSNA_key_header_c::eapol_RSNA_cipher_TKIP);
|
|
1287 |
|
|
1288 |
|
|
1289 |
if (authentication_type == eapol_key_authentication_type_WPA_PSK)
|
|
1290 |
{
|
|
1291 |
status = m_ethernet_core->association(
|
|
1292 |
&receive_network_id,
|
|
1293 |
authentication_type,
|
|
1294 |
&authenticator_RSNA_IE,
|
|
1295 |
&supplicant_RSNA_IE,
|
|
1296 |
eapol_pairwise_cipher,
|
|
1297 |
eapol_group_cipher,
|
|
1298 |
m_wpa_preshared_key);
|
|
1299 |
}
|
|
1300 |
else
|
|
1301 |
{
|
|
1302 |
status = m_ethernet_core->association(
|
|
1303 |
&receive_network_id,
|
|
1304 |
authentication_type,
|
|
1305 |
&authenticator_RSNA_IE,
|
|
1306 |
&supplicant_RSNA_IE,
|
|
1307 |
eapol_pairwise_cipher,
|
|
1308 |
eapol_group_cipher,
|
|
1309 |
0);
|
|
1310 |
}
|
|
1311 |
|
|
1312 |
}
|
|
1313 |
#endif // USE_EAPOL_KEY_STATE
|
|
1314 |
|
|
1315 |
// Forward the packet to the Ethernet layer of the EAPOL stack. Ignore return value. Failure is signalled using state_notification.
|
|
1316 |
status = m_ethernet_core->packet_process(
|
|
1317 |
&receive_network_id,
|
|
1318 |
ð_header,
|
|
1319 |
aLength);
|
|
1320 |
|
|
1321 |
}
|
|
1322 |
else
|
|
1323 |
{
|
|
1324 |
EAP_TRACE_DEBUG(
|
|
1325 |
m_am_tools,
|
|
1326 |
TRACE_FLAGS_DEFAULT,
|
|
1327 |
(EAPL("Not supported ethernet type 0x%04x\n"), eth_header.get_type()));
|
|
1328 |
status = eap_status_ethernet_type_not_supported;
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
status = eap_status_ok;
|
|
1332 |
|
|
1333 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1334 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
1335 |
}
|
|
1336 |
|
|
1337 |
//--------------------------------------------------
|
|
1338 |
|
|
1339 |
void eapol_am_core_symbian_c::set_is_valid()
|
|
1340 |
{
|
|
1341 |
m_is_valid = true;
|
|
1342 |
}
|
|
1343 |
|
|
1344 |
bool eapol_am_core_symbian_c::get_is_valid()
|
|
1345 |
{
|
|
1346 |
return m_is_valid;
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
void eapol_am_core_symbian_c::increment_authentication_counter()
|
|
1350 |
{
|
|
1351 |
++m_authentication_counter;
|
|
1352 |
}
|
|
1353 |
|
|
1354 |
u32_t eapol_am_core_symbian_c::get_authentication_counter()
|
|
1355 |
{
|
|
1356 |
return m_authentication_counter;
|
|
1357 |
}
|
|
1358 |
|
|
1359 |
bool eapol_am_core_symbian_c::get_is_client()
|
|
1360 |
{
|
|
1361 |
return m_is_client;
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
|
|
1365 |
//--------------------------------------------------
|
|
1366 |
|
|
1367 |
//
|
|
1368 |
eap_status_e eapol_am_core_symbian_c::packet_data_crypto_keys(
|
|
1369 |
const eap_am_network_id_c * const /*send_network_id*/,
|
|
1370 |
const eap_variable_data_c * const /*master_session_key*/)
|
|
1371 |
{
|
|
1372 |
// Not needed in Symbian version
|
|
1373 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1374 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1375 |
return eap_status_ok;
|
|
1376 |
}
|
|
1377 |
|
|
1378 |
//--------------------------------------------------
|
|
1379 |
|
|
1380 |
eap_status_e eapol_am_core_symbian_c::packet_data_session_key(
|
|
1381 |
const eap_am_network_id_c * const /*send_network_id*/,
|
|
1382 |
const eapol_session_key_c * const key)
|
|
1383 |
{
|
|
1384 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1385 |
TInt status(KErrNone);
|
|
1386 |
|
|
1387 |
const eap_variable_data_c * const key_data = key->get_key();
|
|
1388 |
if (key_data == 0)
|
|
1389 |
{
|
|
1390 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1391 |
return eap_status_key_error;
|
|
1392 |
}
|
|
1393 |
|
|
1394 |
EAP_TRACE_DEBUG(m_am_tools,
|
|
1395 |
TRACE_FLAGS_DEFAULT,
|
|
1396 |
(EAPL("packet_data_session_key: index: %d, type %d\n"),
|
|
1397 |
key->get_key_index(),
|
|
1398 |
key->get_key_type()));
|
|
1399 |
|
|
1400 |
EAP_TRACE_DATA_DEBUG(m_am_tools,
|
|
1401 |
TRACE_FLAGS_DEFAULT,
|
|
1402 |
(EAPL("packet_data_session_key:"),
|
|
1403 |
key_data->get_data(key_data->get_data_length()),
|
|
1404 |
key_data->get_data_length()));
|
|
1405 |
|
|
1406 |
switch (key->get_key_type())
|
|
1407 |
{
|
|
1408 |
case eapol_key_type_broadcast:
|
|
1409 |
EAP_TRACE_DEBUG(
|
|
1410 |
m_am_tools,
|
|
1411 |
TRACE_FLAGS_DEFAULT,
|
|
1412 |
(EAPL("eapol_am_core_symbian_c::packet_data_session_key: Got rc4_broadcast key.\n")));
|
|
1413 |
|
|
1414 |
status = m_partner->SetCipherKey(
|
|
1415 |
ERC4Broadcast,
|
|
1416 |
static_cast<TUint8> (key->get_key_index()),
|
|
1417 |
key_data->get_data(key_data->get_data_length()),
|
|
1418 |
key_data->get_data_length());
|
|
1419 |
m_broadcast_wep_key_received = true;
|
|
1420 |
break;
|
|
1421 |
case eapol_key_type_unicast:
|
|
1422 |
EAP_TRACE_DEBUG(
|
|
1423 |
m_am_tools,
|
|
1424 |
TRACE_FLAGS_DEFAULT,
|
|
1425 |
(EAPL("eapol_am_core_symbian_c::packet_data_session_key: Got rc4_unicast key.\n")));
|
|
1426 |
|
|
1427 |
status = m_partner->SetCipherKey(
|
|
1428 |
ERC4Unicast,
|
|
1429 |
static_cast<TUint8> (key->get_key_index()),
|
|
1430 |
key_data->get_data(key_data->get_data_length()),
|
|
1431 |
key_data->get_data_length());
|
|
1432 |
m_unicast_wep_key_received = true;
|
|
1433 |
break;
|
|
1434 |
default:
|
|
1435 |
EAP_TRACE_ERROR(
|
|
1436 |
m_am_tools,
|
|
1437 |
TRACE_FLAGS_DEFAULT,
|
|
1438 |
(EAPL("eapol_am_core_symbian_c::packet_data_session_key: Got unsupported key, type %d.\n"),
|
|
1439 |
key->get_key_type()));
|
|
1440 |
status = KErrNotSupported;
|
|
1441 |
break;
|
|
1442 |
}
|
|
1443 |
|
|
1444 |
if (m_unicast_wep_key_received == true
|
|
1445 |
&& m_broadcast_wep_key_received == true
|
|
1446 |
&& m_success_indication_sent == false)
|
|
1447 |
{
|
|
1448 |
// Signal success because we have received one unicast (pairwise) key and one broadcast (group) key.
|
|
1449 |
// If there are more keys coming later they are saved also.
|
|
1450 |
if (m_active_type_is_leap == true)
|
|
1451 |
{
|
|
1452 |
// Leap was successful
|
|
1453 |
EAP_TRACE_DEBUG(
|
|
1454 |
m_am_tools,
|
|
1455 |
TRACE_FLAGS_DEFAULT,
|
|
1456 |
(EAPL("Indication sent to WLM: ELeapSuccess.\n")));
|
|
1457 |
m_partner->EapIndication(ELeapSuccess);
|
|
1458 |
}
|
|
1459 |
else
|
|
1460 |
{
|
|
1461 |
// some other type was successful
|
|
1462 |
EAP_TRACE_DEBUG(
|
|
1463 |
m_am_tools,
|
|
1464 |
TRACE_FLAGS_DEFAULT,
|
|
1465 |
(EAPL("Indication sent to WLM: ESuccess.\n")));
|
|
1466 |
m_partner->EapIndication(ESuccess);
|
|
1467 |
}
|
|
1468 |
|
|
1469 |
m_success_indication_sent = true;
|
|
1470 |
m_first_authentication = false;
|
|
1471 |
}
|
|
1472 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1473 |
return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(status));
|
|
1474 |
}
|
|
1475 |
|
|
1476 |
//--------------------------------------------------
|
|
1477 |
|
|
1478 |
//
|
|
1479 |
|
|
1480 |
eap_status_e eapol_am_core_symbian_c::packet_send(
|
|
1481 |
const eap_am_network_id_c * const /*send_network_id*/,
|
|
1482 |
eap_buf_chain_wr_c * const sent_packet,
|
|
1483 |
const u32_t header_offset,
|
|
1484 |
const u32_t data_length,
|
|
1485 |
const u32_t /*buffer_length*/)
|
|
1486 |
{
|
|
1487 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1488 |
|
|
1489 |
EAP_TRACE_DEBUG(
|
|
1490 |
m_am_tools,
|
|
1491 |
TRACE_FLAGS_DEFAULT,
|
|
1492 |
(EAPL("eapol_am_core_symbian_c::packet_send(data_length=%d).\n"),
|
|
1493 |
data_length));
|
|
1494 |
|
|
1495 |
if (header_offset != 0u)
|
|
1496 |
{
|
|
1497 |
EAP_TRACE_DEBUG(
|
|
1498 |
m_am_tools,
|
|
1499 |
TRACE_FLAGS_DEFAULT,
|
|
1500 |
(EAPL("packet_send: packet buffer corrupted.\n")));
|
|
1501 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1502 |
return eap_status_process_general_error;
|
|
1503 |
}
|
|
1504 |
else if (header_offset+data_length != sent_packet->get_data_length())
|
|
1505 |
{
|
|
1506 |
EAP_TRACE_DEBUG(
|
|
1507 |
m_am_tools,
|
|
1508 |
TRACE_FLAGS_DEFAULT,
|
|
1509 |
(EAPL("ERROR: packet_send: packet buffer corrupted (data_length != sent_packet->get_data_length()).\n")));
|
|
1510 |
EAP_ASSERT(data_length == sent_packet->get_buffer_length());
|
|
1511 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1512 |
return eap_status_process_general_error;
|
|
1513 |
}
|
|
1514 |
|
|
1515 |
if (m_block_packet_sends_and_notifications == true)
|
|
1516 |
{
|
|
1517 |
// Packet sending block is active. This happens when disassociated has been called.
|
|
1518 |
// start_authentication clears the block.
|
|
1519 |
EAP_TRACE_DEBUG(
|
|
1520 |
m_am_tools,
|
|
1521 |
TRACE_FLAGS_DEFAULT,
|
|
1522 |
(EAPL("packet_send: packet ignored because Disassociated() was called.\n")));
|
|
1523 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1524 |
return eap_status_ok;
|
|
1525 |
}
|
|
1526 |
|
|
1527 |
TInt status(KErrNone);
|
|
1528 |
if (m_send_original_packet_first == true)
|
|
1529 |
{
|
|
1530 |
if (m_enable_random_errors == true)
|
|
1531 |
{
|
|
1532 |
EAP_TRACE_DEBUG(
|
|
1533 |
m_am_tools,
|
|
1534 |
TRACE_FLAGS_DEFAULT,
|
|
1535 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original packet\n"),
|
|
1536 |
this,
|
|
1537 |
m_packet_index));
|
|
1538 |
}
|
|
1539 |
|
|
1540 |
u8_t * const packet_data = sent_packet->get_data_offset(header_offset, data_length);
|
|
1541 |
if (packet_data == 0)
|
|
1542 |
{
|
|
1543 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1544 |
return eap_status_buffer_too_short;
|
|
1545 |
}
|
|
1546 |
|
|
1547 |
// Here we send the original packet.
|
|
1548 |
status = m_partner->EapPacketSend(
|
|
1549 |
data_length,
|
|
1550 |
static_cast<TUint8*>(packet_data));
|
|
1551 |
++m_packet_index;
|
|
1552 |
}
|
|
1553 |
|
|
1554 |
if (m_enable_random_errors == true
|
|
1555 |
&& status == KErrNone)
|
|
1556 |
{
|
|
1557 |
if (m_generate_multiple_error_packets > 0ul)
|
|
1558 |
{
|
|
1559 |
// First create a copy of sent packet. Original correct packet will will be sent last.
|
|
1560 |
for (u32_t ind = 0ul; ind < m_generate_multiple_error_packets; ind++)
|
|
1561 |
{
|
|
1562 |
eap_buf_chain_wr_c *copy_packet = sent_packet->copy();
|
|
1563 |
|
|
1564 |
if (copy_packet != 0
|
|
1565 |
&& copy_packet->get_is_valid_data() == true)
|
|
1566 |
{
|
|
1567 |
// Make a random error to the copy message.
|
|
1568 |
random_error(copy_packet, true, m_packet_index);
|
|
1569 |
|
|
1570 |
EAP_TRACE_DEBUG(
|
|
1571 |
m_am_tools,
|
|
1572 |
TRACE_FLAGS_DEFAULT,
|
|
1573 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send error packet\n"),
|
|
1574 |
this,
|
|
1575 |
m_packet_index));
|
|
1576 |
|
|
1577 |
u8_t * const packet_data = copy_packet->get_data_offset(header_offset, data_length);
|
|
1578 |
if (packet_data == 0)
|
|
1579 |
{
|
|
1580 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1581 |
return eap_status_buffer_too_short;
|
|
1582 |
}
|
|
1583 |
|
|
1584 |
// Here we send the copied and manipulated packet.
|
|
1585 |
status = m_partner->EapPacketSend(
|
|
1586 |
data_length,
|
|
1587 |
static_cast<TUint8*>(packet_data));
|
|
1588 |
|
|
1589 |
++m_packet_index;
|
|
1590 |
}
|
|
1591 |
delete copy_packet;
|
|
1592 |
}
|
|
1593 |
}
|
|
1594 |
else
|
|
1595 |
{
|
|
1596 |
// Make a random error to the original message.
|
|
1597 |
random_error(sent_packet, false, m_packet_index);
|
|
1598 |
|
|
1599 |
if (sent_packet->get_is_manipulated() == true)
|
|
1600 |
{
|
|
1601 |
EAP_TRACE_DEBUG(
|
|
1602 |
m_am_tools,
|
|
1603 |
TRACE_FLAGS_DEFAULT,
|
|
1604 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send error packet\n"),
|
|
1605 |
this,
|
|
1606 |
m_packet_index));
|
|
1607 |
}
|
|
1608 |
}
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
|
|
1612 |
if (m_send_original_packet_first == false
|
|
1613 |
&& status == KErrNone)
|
|
1614 |
{
|
|
1615 |
if (m_enable_random_errors == true)
|
|
1616 |
{
|
|
1617 |
EAP_TRACE_DEBUG(
|
|
1618 |
m_am_tools,
|
|
1619 |
TRACE_FLAGS_DEFAULT,
|
|
1620 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original packet\n"),
|
|
1621 |
this,
|
|
1622 |
m_packet_index));
|
|
1623 |
}
|
|
1624 |
|
|
1625 |
u8_t * const packet_data = sent_packet->get_data_offset(header_offset, data_length);
|
|
1626 |
if (packet_data == 0)
|
|
1627 |
{
|
|
1628 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1629 |
return eap_status_buffer_too_short;
|
|
1630 |
}
|
|
1631 |
|
|
1632 |
// Here we send the original packet.
|
|
1633 |
status = m_partner->EapPacketSend(
|
|
1634 |
data_length,
|
|
1635 |
static_cast<TUint8*>(packet_data));
|
|
1636 |
++m_packet_index;
|
|
1637 |
}
|
|
1638 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1639 |
|
|
1640 |
return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(status));
|
|
1641 |
}
|
|
1642 |
|
|
1643 |
//--------------------------------------------------
|
|
1644 |
|
|
1645 |
//
|
|
1646 |
eap_status_e eapol_am_core_symbian_c::reassociate(
|
|
1647 |
const eap_am_network_id_c * const /* send_network_id */,
|
|
1648 |
const eapol_key_authentication_type_e /* authentication_type */,
|
|
1649 |
const eap_variable_data_c * const /* PMKID */,
|
|
1650 |
const eap_variable_data_c * const /* WPXM_WPXK1 */,
|
|
1651 |
const eap_variable_data_c * const /* WPXM_WPXK2 */)
|
|
1652 |
{
|
|
1653 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
|
|
1654 |
}
|
|
1655 |
|
|
1656 |
//--------------------------------------------------
|
|
1657 |
|
|
1658 |
//
|
|
1659 |
void eapol_am_core_symbian_c::state_notification(const abs_eap_state_notification_c * const state)
|
|
1660 |
{
|
|
1661 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1662 |
|
|
1663 |
if(state->get_protocol_layer() == eap_protocol_layer_general)
|
|
1664 |
{
|
|
1665 |
if (state->get_current_state() == eap_general_state_authentication_cancelled)
|
|
1666 |
{
|
|
1667 |
// Authentication was cancelled. Cannot continue.
|
|
1668 |
EAP_TRACE_DEBUG(
|
|
1669 |
m_am_tools,
|
|
1670 |
TRACE_FLAGS_DEFAULT,
|
|
1671 |
(EAPL("Authentication was cancelled. Sets timer EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID.\n")));
|
|
1672 |
|
|
1673 |
set_timer(this, EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID, 0, 0);
|
|
1674 |
}
|
|
1675 |
else if (state->get_current_state() == eap_general_state_configuration_error)
|
|
1676 |
{
|
|
1677 |
// Configuration error. Cannot continue.
|
|
1678 |
EAP_TRACE_DEBUG(
|
|
1679 |
m_am_tools,
|
|
1680 |
TRACE_FLAGS_DEFAULT,
|
|
1681 |
(EAPL("Configuration error. Sets timer EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID.\n")));
|
|
1682 |
|
|
1683 |
set_timer(this, EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID, 0, 0);
|
|
1684 |
}
|
|
1685 |
}
|
|
1686 |
|
|
1687 |
|
|
1688 |
if (m_block_packet_sends_and_notifications == true)
|
|
1689 |
{
|
|
1690 |
// Notification block is active.
|
|
1691 |
EAP_TRACE_DEBUG(
|
|
1692 |
m_am_tools,
|
|
1693 |
TRACE_FLAGS_DEFAULT,
|
|
1694 |
(EAPL("state_notification: notification ignored because Disassociated() was called.\n")));
|
|
1695 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1696 |
return;
|
|
1697 |
}
|
|
1698 |
|
|
1699 |
|
|
1700 |
// Check if this is EAP layer notification
|
|
1701 |
if(state->get_protocol_layer() == eap_protocol_layer_eap)
|
|
1702 |
{
|
|
1703 |
switch (state->get_current_state())
|
|
1704 |
{
|
|
1705 |
case eap_state_none:
|
|
1706 |
break;
|
|
1707 |
case eap_state_identity_request_sent:
|
|
1708 |
// This is for server only so no need to notify WLM.
|
|
1709 |
break;
|
|
1710 |
case eap_state_identity_request_received:
|
|
1711 |
if (m_authentication_indication_sent == false)
|
|
1712 |
{
|
|
1713 |
EAP_TRACE_DEBUG(
|
|
1714 |
m_am_tools,
|
|
1715 |
TRACE_FLAGS_DEFAULT,
|
|
1716 |
(EAPL("Indication sent to WLM: EAuthenticating.\n")));
|
|
1717 |
m_partner->EapIndication(EAuthenticating);
|
|
1718 |
m_authentication_indication_sent = true;
|
|
1719 |
}
|
|
1720 |
break;
|
|
1721 |
case eap_state_identity_response_received:
|
|
1722 |
// This is for server only so no need to notify WLM.
|
|
1723 |
break;
|
|
1724 |
case eap_state_authentication_finished_successfully:
|
|
1725 |
{
|
|
1726 |
|
|
1727 |
increment_authentication_counter();
|
|
1728 |
m_successful_authentications++;
|
|
1729 |
|
|
1730 |
if (m_wpa_psk_mode_active == false)
|
|
1731 |
{
|
|
1732 |
TEap eap;
|
|
1733 |
eap.Enabled = ETrue;
|
|
1734 |
eap.UID.Num(static_cast<TInt>(state->get_eap_type()));
|
|
1735 |
|
|
1736 |
// This moves the successful type to be the top priority type in IAP settings.
|
|
1737 |
TRAPD(err, SetToTopPriorityL(&eap));
|
|
1738 |
if (err != KErrNone)
|
|
1739 |
{
|
|
1740 |
// Just log the error.
|
|
1741 |
EAP_TRACE_DEBUG(
|
|
1742 |
m_am_tools,
|
|
1743 |
TRACE_FLAGS_DEFAULT,
|
|
1744 |
(EAPL("state_notification: SetToTopPriorityL leaved!\n")));
|
|
1745 |
}
|
|
1746 |
|
|
1747 |
// Move the active eap type index to the first type
|
|
1748 |
m_eap_index = 0;
|
|
1749 |
}
|
|
1750 |
|
|
1751 |
|
|
1752 |
}
|
|
1753 |
break;
|
|
1754 |
case eap_state_authentication_terminated_unsuccessfully:
|
|
1755 |
{
|
|
1756 |
if (m_wpa_psk_mode_active == false)
|
|
1757 |
{
|
|
1758 |
// Set index to next type.
|
|
1759 |
m_eap_index++;
|
|
1760 |
}
|
|
1761 |
|
|
1762 |
increment_authentication_counter();
|
|
1763 |
m_failed_authentications++;
|
|
1764 |
|
|
1765 |
// Restart authentication
|
|
1766 |
eap_am_network_id_c* send_network_id = new eap_am_network_id_c(m_am_tools, state->get_send_network_id());
|
|
1767 |
if (send_network_id == 0
|
|
1768 |
|| send_network_id->get_is_valid_data() == false)
|
|
1769 |
{
|
|
1770 |
delete send_network_id;
|
|
1771 |
EAP_TRACE_DEBUG(
|
|
1772 |
m_am_tools,
|
|
1773 |
TRACE_FLAGS_DEFAULT,
|
|
1774 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1775 |
m_partner->EapIndication(EFailedCompletely);
|
|
1776 |
break;
|
|
1777 |
}
|
|
1778 |
set_timer(this, EAPOL_AM_CORE_TIMER_RESTART_AUTHENTICATION_ID, send_network_id, 0);
|
|
1779 |
|
|
1780 |
}
|
|
1781 |
break;
|
|
1782 |
default:
|
|
1783 |
break;
|
|
1784 |
}
|
|
1785 |
}
|
|
1786 |
else
|
|
1787 |
{
|
|
1788 |
if(state->get_protocol_layer() == eap_protocol_layer_eapol)
|
|
1789 |
{
|
|
1790 |
switch (state->get_current_state())
|
|
1791 |
{
|
|
1792 |
case eapol_state_no_start_response:
|
|
1793 |
EAP_TRACE_DEBUG(
|
|
1794 |
m_am_tools,
|
|
1795 |
TRACE_FLAGS_DEFAULT,
|
|
1796 |
(EAPL("Indication sent to WLM: ENoResponse.\n")));
|
|
1797 |
m_partner->EapIndication(ENoResponse);
|
|
1798 |
break;
|
|
1799 |
default:
|
|
1800 |
break;
|
|
1801 |
}
|
|
1802 |
}
|
|
1803 |
else if(state->get_protocol_layer() == eap_protocol_layer_eapol_key)
|
|
1804 |
{
|
|
1805 |
switch (state->get_current_state())
|
|
1806 |
{
|
|
1807 |
case eapol_key_state_802_11i_authentication_terminated_unsuccessfull:
|
|
1808 |
{
|
|
1809 |
increment_authentication_counter();
|
|
1810 |
m_failed_authentications++;
|
|
1811 |
|
|
1812 |
// Consider EAPOL layer failures fatal.
|
|
1813 |
EAP_TRACE_ERROR(
|
|
1814 |
m_am_tools,
|
|
1815 |
TRACE_FLAGS_DEFAULT,
|
|
1816 |
(EAPL("ERROR: Unsuccessful authentication on EAPOL level.\n")));
|
|
1817 |
EAP_TRACE_DEBUG(
|
|
1818 |
m_am_tools,
|
|
1819 |
TRACE_FLAGS_DEFAULT,
|
|
1820 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
1821 |
m_partner->EapIndication(EThisAPFailed);
|
|
1822 |
}
|
|
1823 |
break;
|
|
1824 |
case eapol_key_state_802_11i_authentication_finished_successfull:
|
|
1825 |
{
|
|
1826 |
EAP_TRACE_ALWAYS(
|
|
1827 |
m_am_tools,
|
|
1828 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
1829 |
(EAPL("EAPOL_KEY: %s: Authentication SUCCESS\n"),
|
|
1830 |
(m_is_client == true ? "client": "server")));
|
|
1831 |
}
|
|
1832 |
break;
|
|
1833 |
default:
|
|
1834 |
break;
|
|
1835 |
}
|
|
1836 |
}
|
|
1837 |
}
|
|
1838 |
|
|
1839 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1840 |
}
|
|
1841 |
|
|
1842 |
//--------------------------------------------------
|
|
1843 |
|
|
1844 |
//
|
|
1845 |
|
|
1846 |
eap_status_e eapol_am_core_symbian_c::timer_expired(
|
|
1847 |
const u32_t id, void * /* data */)
|
|
1848 |
{
|
|
1849 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1850 |
EAP_TRACE_DEBUG(
|
|
1851 |
m_am_tools,
|
|
1852 |
TRACE_FLAGS_DEFAULT,
|
|
1853 |
(EAPL("eapol_am_core_symbian_c::TimerExpired id = %d.\n"),
|
|
1854 |
id));
|
|
1855 |
|
|
1856 |
switch (id)
|
|
1857 |
{
|
|
1858 |
case EAPOL_AM_CORE_TIMER_RESTART_AUTHENTICATION_ID:
|
|
1859 |
{
|
|
1860 |
EAP_TRACE_DEBUG(
|
|
1861 |
m_am_tools,
|
|
1862 |
TRACE_FLAGS_DEFAULT,
|
|
1863 |
(EAPL("EAPOL_AM_CORE_TIMER_RESTART_AUTHENTICATION_ID elapsed: Stopping stack.\n")));
|
|
1864 |
|
|
1865 |
// Stop stack. Do this only if Ethernet core still exists.
|
|
1866 |
if (m_ethernet_core != 0)
|
|
1867 |
{
|
|
1868 |
m_ethernet_core->shutdown();
|
|
1869 |
delete m_ethernet_core;
|
|
1870 |
m_ethernet_core = 0;
|
|
1871 |
}
|
|
1872 |
if (m_wpa_psk_mode_active == true)
|
|
1873 |
{
|
|
1874 |
// PSK mode active - cannot restart. Just fail.
|
|
1875 |
EAP_TRACE_DEBUG(
|
|
1876 |
m_am_tools,
|
|
1877 |
TRACE_FLAGS_DEFAULT,
|
|
1878 |
(EAPL("WPA PSK mode failed.\n")));
|
|
1879 |
EAP_TRACE_DEBUG(
|
|
1880 |
m_am_tools,
|
|
1881 |
TRACE_FLAGS_DEFAULT,
|
|
1882 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
1883 |
m_partner->EapIndication(EThisAPFailed);
|
|
1884 |
break;
|
|
1885 |
|
|
1886 |
}
|
|
1887 |
|
|
1888 |
EAP_TRACE_DEBUG(
|
|
1889 |
m_am_tools,
|
|
1890 |
TRACE_FLAGS_DEFAULT,
|
|
1891 |
(EAPL("Checking if more types.\n")));
|
|
1892 |
|
|
1893 |
TInt i;
|
|
1894 |
TEap *eapType = 0;
|
|
1895 |
// Search for more EAP types to try
|
|
1896 |
for (i = m_eap_index; i < m_iap_eap_array.Count(); i++)
|
|
1897 |
{
|
|
1898 |
// Find the next enabled EAP type (highest priority)
|
|
1899 |
eapType = m_iap_eap_array[i];
|
|
1900 |
if (eapType->Enabled == 1)
|
|
1901 |
{
|
|
1902 |
break;
|
|
1903 |
}
|
|
1904 |
}
|
|
1905 |
// Update index to point to next type to be tried
|
|
1906 |
m_eap_index = i;
|
|
1907 |
|
|
1908 |
if (i >= m_iap_eap_array.Count())
|
|
1909 |
{
|
|
1910 |
EAP_TRACE_DEBUG(
|
|
1911 |
m_am_tools,
|
|
1912 |
TRACE_FLAGS_DEFAULT,
|
|
1913 |
(EAPL("No more configured EAP types to try.\n")));
|
|
1914 |
|
|
1915 |
// No point in trying to restart authentication because there isn't any more
|
|
1916 |
// EAP types left to try...
|
|
1917 |
EAP_TRACE_DEBUG(
|
|
1918 |
m_am_tools,
|
|
1919 |
TRACE_FLAGS_DEFAULT,
|
|
1920 |
(EAPL("Indication sent to WLM: EThisAPFailed.\n")));
|
|
1921 |
m_partner->EapIndication(EThisAPFailed);
|
|
1922 |
break;
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
// Check if authentication mode must be changed
|
|
1926 |
TLex8 tmp(eapType->UID);
|
|
1927 |
TInt type(0);
|
|
1928 |
tmp.Val(type);
|
|
1929 |
|
|
1930 |
EAP_TRACE_DEBUG(
|
|
1931 |
m_am_tools,
|
|
1932 |
TRACE_FLAGS_DEFAULT,
|
|
1933 |
(EAPL("Found new type to try: %d.\n"), type));
|
|
1934 |
|
|
1935 |
switch (type)
|
|
1936 |
{
|
|
1937 |
case eap_type_leap:
|
|
1938 |
m_active_type_is_leap = true;
|
|
1939 |
if (m_802_11_authentication_mode != EAuthModeLeap
|
|
1940 |
&& m_security_mode != Wpa
|
|
1941 |
&& m_security_mode != Wpa2Only) // In WPA or WPA2 even LEAP uses open authentication
|
|
1942 |
{
|
|
1943 |
// New type is LEAP and the old was something else:
|
|
1944 |
// must reassociate with correct authentication mode.
|
|
1945 |
m_self_disassociated = true;
|
|
1946 |
TInt result = m_partner->Disassociate();
|
|
1947 |
if (result != KErrNone)
|
|
1948 |
{
|
|
1949 |
// Probably unrecoverable error
|
|
1950 |
EAP_TRACE_DEBUG(
|
|
1951 |
m_am_tools,
|
|
1952 |
TRACE_FLAGS_DEFAULT,
|
|
1953 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1954 |
m_partner->EapIndication(EFailedCompletely);
|
|
1955 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1956 |
return eap_status_ok;
|
|
1957 |
}
|
|
1958 |
|
|
1959 |
EAP_TRACE_DEBUG(
|
|
1960 |
m_am_tools,
|
|
1961 |
TRACE_FLAGS_DEFAULT,
|
|
1962 |
(EAPL("TimerExpired: Changing auth type to LEAP.\n")));
|
|
1963 |
|
|
1964 |
m_802_11_authentication_mode = EAuthModeLeap;
|
|
1965 |
|
|
1966 |
m_partner->Associate(EAuthModeLeap);
|
|
1967 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1968 |
return eap_status_ok;
|
|
1969 |
}
|
|
1970 |
break;
|
|
1971 |
default:
|
|
1972 |
m_active_type_is_leap = false;
|
|
1973 |
if (m_802_11_authentication_mode != EAuthModeOpen
|
|
1974 |
&& m_security_mode != Wpa
|
|
1975 |
&& m_security_mode != Wpa2Only) // In WPA or WPA2 even LEAP uses open authentication)
|
|
1976 |
{
|
|
1977 |
// New type is non-LEAP and the old was LEAP:
|
|
1978 |
// must reassociate with correct authentication mode
|
|
1979 |
m_self_disassociated = true;
|
|
1980 |
TInt result = m_partner->Disassociate();
|
|
1981 |
if (result != KErrNone)
|
|
1982 |
{
|
|
1983 |
// Probably unrecoverable error
|
|
1984 |
EAP_TRACE_DEBUG(
|
|
1985 |
m_am_tools,
|
|
1986 |
TRACE_FLAGS_DEFAULT,
|
|
1987 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
1988 |
|
|
1989 |
m_partner->EapIndication(EFailedCompletely);
|
|
1990 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
1991 |
return eap_status_ok;
|
|
1992 |
}
|
|
1993 |
|
|
1994 |
EAP_TRACE_DEBUG(
|
|
1995 |
m_am_tools,
|
|
1996 |
TRACE_FLAGS_DEFAULT,
|
|
1997 |
(EAPL("TimerExpired: Changing auth type to OPEN.\n")));
|
|
1998 |
|
|
1999 |
m_802_11_authentication_mode = EAuthModeOpen;
|
|
2000 |
|
|
2001 |
m_partner->Associate(EAuthModeOpen);
|
|
2002 |
|
|
2003 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2004 |
return eap_status_ok;
|
|
2005 |
}
|
|
2006 |
break;
|
|
2007 |
}
|
|
2008 |
|
|
2009 |
EAP_TRACE_DEBUG(
|
|
2010 |
m_am_tools,
|
|
2011 |
TRACE_FLAGS_DEFAULT,
|
|
2012 |
(EAPL("TimerExpired: No need to change auth type.\n")));
|
|
2013 |
|
|
2014 |
if (CompleteAssociation(
|
|
2015 |
KErrNone,
|
|
2016 |
m_local_address,
|
|
2017 |
m_remote_address,
|
|
2018 |
m_received_wpa_ie,
|
|
2019 |
m_received_wpa_ie_length,
|
|
2020 |
m_sent_wpa_ie,
|
|
2021 |
m_sent_wpa_ie_length,
|
|
2022 |
m_group_key_cipher_suite,
|
|
2023 |
m_pairwise_key_cipher_suite) != KErrNone)
|
|
2024 |
{
|
|
2025 |
// Probably unrecoverable error
|
|
2026 |
EAP_TRACE_DEBUG(
|
|
2027 |
m_am_tools,
|
|
2028 |
TRACE_FLAGS_DEFAULT,
|
|
2029 |
(EAPL("Indication sent to WLM: EFailedCompletely.\n")));
|
|
2030 |
m_partner->EapIndication(EFailedCompletely);
|
|
2031 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2032 |
return eap_status_ok;
|
|
2033 |
}
|
|
2034 |
}
|
|
2035 |
break;
|
|
2036 |
|
|
2037 |
case EAPOL_AM_CORE_TIMER_DELETE_STACK_ID:
|
|
2038 |
{
|
|
2039 |
EAP_TRACE_DEBUG(
|
|
2040 |
m_am_tools,
|
|
2041 |
TRACE_FLAGS_DEFAULT,
|
|
2042 |
(EAPL("EAPOL_AM_CORE_TIMER_DELETE_STACK_ID elapsed: Delete stack.\n")));
|
|
2043 |
|
|
2044 |
cancel_all_timers();
|
|
2045 |
|
|
2046 |
// Delete stack
|
|
2047 |
if (m_ethernet_core != 0)
|
|
2048 |
{
|
|
2049 |
m_ethernet_core->shutdown();
|
|
2050 |
delete m_ethernet_core;
|
|
2051 |
m_ethernet_core = 0;
|
|
2052 |
}
|
|
2053 |
m_stack_marked_to_be_deleted = false;
|
|
2054 |
|
|
2055 |
// Re-activates timer queue.
|
|
2056 |
eap_status_e status = m_am_tools->re_activate_timer_queue();
|
|
2057 |
if (status != eap_status_ok)
|
|
2058 |
{
|
|
2059 |
EAP_TRACE_DEBUG(
|
|
2060 |
m_am_tools,
|
|
2061 |
TRACE_FLAGS_DEFAULT,
|
|
2062 |
(EAPL("ERROR: re_activate_timer_queue() failed, status = %d\n")));
|
|
2063 |
}
|
|
2064 |
}
|
|
2065 |
break;
|
|
2066 |
|
|
2067 |
case EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID:
|
|
2068 |
{
|
|
2069 |
EAP_TRACE_DEBUG(
|
|
2070 |
m_am_tools,
|
|
2071 |
TRACE_FLAGS_DEFAULT,
|
|
2072 |
(EAPL("EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID elapsed: Indication sent to WLM: EFailedCompletely.\n")));
|
|
2073 |
|
|
2074 |
m_partner->EapIndication(EFailedCompletely);
|
|
2075 |
}
|
|
2076 |
break;
|
|
2077 |
|
|
2078 |
default:
|
|
2079 |
break;
|
|
2080 |
}
|
|
2081 |
return eap_status_ok;
|
|
2082 |
}
|
|
2083 |
|
|
2084 |
eap_status_e eapol_am_core_symbian_c::timer_delete_data(
|
|
2085 |
const u32_t id, void *data)
|
|
2086 |
{
|
|
2087 |
switch (id)
|
|
2088 |
{
|
|
2089 |
case EAPOL_AM_CORE_TIMER_RESTART_AUTHENTICATION_ID:
|
|
2090 |
{
|
|
2091 |
eap_am_network_id_c* tmp = static_cast<eap_am_network_id_c*>(data);
|
|
2092 |
delete tmp;
|
|
2093 |
}
|
|
2094 |
break;
|
|
2095 |
case EAPOL_AM_CORE_TIMER_DELETE_STACK_ID:
|
|
2096 |
break;
|
|
2097 |
case EAPOL_AM_CORE_TIMER_FAILED_COMPLETELY_ID:
|
|
2098 |
break;
|
|
2099 |
|
|
2100 |
default:
|
|
2101 |
{
|
|
2102 |
EAP_TRACE_ERROR(
|
|
2103 |
m_am_tools,
|
|
2104 |
TRACE_FLAGS_DEFAULT,
|
|
2105 |
(EAPL("eapol_am_core_symbian_c::timer_delete_data: deleted unknown timer.\n")));
|
|
2106 |
(void)EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
|
|
2107 |
}
|
|
2108 |
}
|
|
2109 |
return eap_status_ok;
|
|
2110 |
}
|
|
2111 |
//--------------------------------------------------
|
|
2112 |
|
|
2113 |
//
|
|
2114 |
u32_t eapol_am_core_symbian_c::get_header_offset(
|
|
2115 |
u32_t * const MTU,
|
|
2116 |
u32_t * const trailer_length)
|
|
2117 |
{
|
|
2118 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2119 |
*MTU = KMTU;
|
|
2120 |
*trailer_length = KTrailerLength;
|
|
2121 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2122 |
return KHeaderOffset;
|
|
2123 |
}
|
|
2124 |
|
|
2125 |
//--------------------------------------------------
|
|
2126 |
|
|
2127 |
//
|
|
2128 |
eap_status_e eapol_am_core_symbian_c::unload_module(const eap_type_value_e type)
|
|
2129 |
{
|
|
2130 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2131 |
eap_status_e status(eap_status_type_does_not_exists_error);
|
|
2132 |
TInt index = m_eap_type_array.Find(type);
|
|
2133 |
if (index != KErrNotFound)
|
|
2134 |
{
|
|
2135 |
delete m_plugin_if_array[index];
|
|
2136 |
m_plugin_if_array.Remove(index);
|
|
2137 |
m_eap_type_array.Remove(index);
|
|
2138 |
status = eap_status_ok;
|
|
2139 |
}
|
|
2140 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2141 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
2142 |
}
|
|
2143 |
|
|
2144 |
//--------------------------------------------------
|
|
2145 |
|
|
2146 |
//
|
|
2147 |
eap_status_e eapol_am_core_symbian_c::eap_acknowledge(const eap_am_network_id_c * const receive_network_id)
|
|
2148 |
{
|
|
2149 |
// Any Network Protocol packet is accepted as a success indication.
|
|
2150 |
// This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)".
|
|
2151 |
|
|
2152 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2153 |
|
|
2154 |
eap_status_e status = m_ethernet_core->eap_acknowledge(receive_network_id);
|
|
2155 |
|
|
2156 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2157 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
2158 |
}
|
|
2159 |
|
|
2160 |
//--------------------------------------------------
|
|
2161 |
|
|
2162 |
//
|
|
2163 |
eap_status_e eapol_am_core_symbian_c::load_module(
|
|
2164 |
const eap_type_value_e type,
|
|
2165 |
const eap_type_value_e tunneling_type,
|
|
2166 |
abs_eap_base_type_c * const partner,
|
|
2167 |
eap_base_type_c ** const eap_type_if,
|
|
2168 |
const bool is_client_when_true,
|
|
2169 |
const eap_am_network_id_c * const receive_network_id)
|
|
2170 |
{
|
|
2171 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2172 |
|
|
2173 |
EAP_TRACE_DEBUG(
|
|
2174 |
m_am_tools,
|
|
2175 |
TRACE_FLAGS_DEFAULT,
|
|
2176 |
(EAPL("eapol_am_core_symbian_c::load_module(type %d=%s, tunneling_type %d=%s)\n"),
|
|
2177 |
static_cast<TInt>(type),
|
|
2178 |
eap_header_string_c::get_eap_type_string(type),
|
|
2179 |
static_cast<TInt>(tunneling_type),
|
|
2180 |
eap_header_string_c::get_eap_type_string(tunneling_type)));
|
|
2181 |
|
|
2182 |
eap_status_e status = eap_status_process_general_error;
|
|
2183 |
TBuf8<KMaxEapCueLength> cue;
|
|
2184 |
cue.Num(static_cast<TInt>(convert_eap_type_to_u32_t(type)));
|
|
2185 |
CEapType* eapType = 0;
|
|
2186 |
TInt error(KErrNone);
|
|
2187 |
|
|
2188 |
// Check if this EAP type has already been loaded
|
|
2189 |
TInt eapArrayIndex = m_eap_type_array.Find(type);
|
|
2190 |
if (eapArrayIndex != KErrNotFound)
|
|
2191 |
{
|
|
2192 |
// Yep. It was loaded already.
|
|
2193 |
eapType = m_plugin_if_array[eapArrayIndex];
|
|
2194 |
}
|
|
2195 |
else
|
|
2196 |
{
|
|
2197 |
// We must have a trap here since the EAPOL core knows nothing about Symbian.
|
|
2198 |
TRAP(error, (eapType = CEapType::NewL(cue, m_index_type, m_index)));
|
|
2199 |
if (error != KErrNone
|
|
2200 |
|| eapType == 0)
|
|
2201 |
{
|
|
2202 |
// Interface not found or implementation creation function failed
|
|
2203 |
EAP_TRACE_DEBUG(
|
|
2204 |
m_am_tools,
|
|
2205 |
TRACE_FLAGS_DEFAULT,
|
|
2206 |
(EAPL("ECom could not find/initiate implementation.\n")));
|
|
2207 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
|
|
2208 |
}
|
|
2209 |
}
|
|
2210 |
// Set the tunneling type
|
|
2211 |
eapType->SetTunnelingType(convert_eap_type_to_u32_t(tunneling_type));
|
|
2212 |
|
|
2213 |
// Create the EAP protocol interface implementation.
|
|
2214 |
TRAP(error, (*eap_type_if = eapType->GetStackInterfaceL(m_am_tools, partner, is_client_when_true, receive_network_id)));
|
|
2215 |
|
|
2216 |
if (error != KErrNone
|
|
2217 |
|| *eap_type_if == 0
|
|
2218 |
|| (*eap_type_if)->get_is_valid() == false)
|
|
2219 |
{
|
|
2220 |
EAP_TRACE_DEBUG(
|
|
2221 |
m_am_tools,
|
|
2222 |
TRACE_FLAGS_DEFAULT,
|
|
2223 |
(EAPL("Could not create EAP type interface instance. Error: %d\n"), error));
|
|
2224 |
|
|
2225 |
status = eap_status_allocation_error;
|
|
2226 |
// Unload DLL (two ways, depending whether this type was already loaded...)
|
|
2227 |
if (eapArrayIndex == KErrNotFound)
|
|
2228 |
{
|
|
2229 |
// No need to call shutdown here because GetStackInterfaceL has done it.
|
|
2230 |
delete eapType;
|
|
2231 |
}
|
|
2232 |
else
|
|
2233 |
{
|
|
2234 |
unload_module(type);
|
|
2235 |
}
|
|
2236 |
// Note: even in error cases eap_core_c deletes eap_type_if
|
|
2237 |
}
|
|
2238 |
else
|
|
2239 |
{
|
|
2240 |
status = eap_status_ok;
|
|
2241 |
if (eapArrayIndex == KErrNotFound)
|
|
2242 |
{
|
|
2243 |
// Add plugin information to the member arrays. There is no need to store eap_type pointer because
|
|
2244 |
// the stack takes care of its deletion.
|
|
2245 |
if (m_plugin_if_array.Append(eapType) != KErrNone)
|
|
2246 |
{
|
|
2247 |
delete eapType;
|
|
2248 |
status = eap_status_allocation_error;
|
|
2249 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2250 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
2251 |
}
|
|
2252 |
if (m_eap_type_array.Append(type) != KErrNone)
|
|
2253 |
{
|
|
2254 |
// Remove the eap type added just previously
|
|
2255 |
m_plugin_if_array.Remove(m_plugin_if_array.Count() - 1);
|
|
2256 |
delete eapType;
|
|
2257 |
status = eap_status_allocation_error;
|
|
2258 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2259 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
2260 |
}
|
|
2261 |
}
|
|
2262 |
}
|
|
2263 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2264 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
2265 |
}
|
|
2266 |
|
|
2267 |
//--------------------------------------------------
|
|
2268 |
|
|
2269 |
//
|
|
2270 |
TInt eapol_am_core_symbian_c::Disassociated()
|
|
2271 |
{
|
|
2272 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2273 |
|
|
2274 |
EAP_TRACE_DEBUG(
|
|
2275 |
m_am_tools,
|
|
2276 |
TRACE_FLAGS_DEFAULT,
|
|
2277 |
(EAPL("eapol_am_core_symbian_c::Disassociated()\n")));
|
|
2278 |
|
|
2279 |
if (m_self_disassociated == true)
|
|
2280 |
{
|
|
2281 |
// We were expecting this. No need to reset state.
|
|
2282 |
m_self_disassociated = false;
|
|
2283 |
return KErrNone;
|
|
2284 |
}
|
|
2285 |
|
|
2286 |
EAP_TRACE_DEBUG(
|
|
2287 |
m_am_tools,
|
|
2288 |
TRACE_FLAGS_DEFAULT,
|
|
2289 |
(EAPL("eapol_am_core_symbian_c::Disassociated.\n")));
|
|
2290 |
|
|
2291 |
eap_status_e status(eap_status_ok);
|
|
2292 |
|
|
2293 |
// Set block on.
|
|
2294 |
m_block_packet_sends_and_notifications = true;
|
|
2295 |
|
|
2296 |
// Reset flags
|
|
2297 |
m_success_indication_sent = false;
|
|
2298 |
m_unicast_wep_key_received = false;
|
|
2299 |
m_broadcast_wep_key_received = false;
|
|
2300 |
m_authentication_indication_sent = false;
|
|
2301 |
|
|
2302 |
if (m_ethernet_core != 0)
|
|
2303 |
{
|
|
2304 |
EAP_TRACE_DEBUG(
|
|
2305 |
m_am_tools,
|
|
2306 |
TRACE_FLAGS_DEFAULT,
|
|
2307 |
(EAPL("Stack exists. Set EAPOL_AM_CORE_TIMER_DELETE_STACK_ID timer.\n")));
|
|
2308 |
|
|
2309 |
m_stack_marked_to_be_deleted = true;
|
|
2310 |
set_timer(this, EAPOL_AM_CORE_TIMER_DELETE_STACK_ID, 0, 0);
|
|
2311 |
}
|
|
2312 |
else
|
|
2313 |
{
|
|
2314 |
EAP_TRACE_DEBUG(
|
|
2315 |
m_am_tools,
|
|
2316 |
TRACE_FLAGS_DEFAULT,
|
|
2317 |
(EAPL("Stack did not exists. EAPOL_AM_CORE_TIMER_DELETE_STACK_ID timer not set.\n")));
|
|
2318 |
}
|
|
2319 |
|
|
2320 |
// reset index
|
|
2321 |
m_eap_index = 0;
|
|
2322 |
|
|
2323 |
|
|
2324 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2325 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
2326 |
}
|
|
2327 |
|
|
2328 |
//--------------------------------------------------
|
|
2329 |
|
|
2330 |
//
|
|
2331 |
TInt eapol_am_core_symbian_c::SendWPAMICFailureReport(
|
|
2332 |
TBool aFatalMICFailure,
|
|
2333 |
const TMICFailureType aMICFailureType)
|
|
2334 |
{
|
|
2335 |
EAP_TRACE_ALWAYS(
|
|
2336 |
m_am_tools,
|
|
2337 |
TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
|
|
2338 |
(EAPL("eapol_am_core_symbian_c::SendWPAMICFailureReport(%d, %d).\n"),
|
|
2339 |
aFatalMICFailure,
|
|
2340 |
aMICFailureType));
|
|
2341 |
|
|
2342 |
bool fatal_failure_when_true = true;
|
|
2343 |
|
|
2344 |
if (!aFatalMICFailure)
|
|
2345 |
{
|
|
2346 |
fatal_failure_when_true = false;
|
|
2347 |
}
|
|
2348 |
|
|
2349 |
eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_e tkip_mic_failure_type
|
|
2350 |
= eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_pairwise_key;
|
|
2351 |
|
|
2352 |
if (aMICFailureType == EGroupKey)
|
|
2353 |
{
|
|
2354 |
tkip_mic_failure_type
|
|
2355 |
= eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_group_key;
|
|
2356 |
}
|
|
2357 |
|
|
2358 |
const eap_status_e status = m_ethernet_core->tkip_mic_failure(
|
|
2359 |
m_receive_network_id,
|
|
2360 |
fatal_failure_when_true,
|
|
2361 |
tkip_mic_failure_type);
|
|
2362 |
|
|
2363 |
return m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status));
|
|
2364 |
}
|
|
2365 |
|
|
2366 |
|
|
2367 |
//--------------------------------------------------
|
|
2368 |
|
|
2369 |
//
|
|
2370 |
void eapol_am_core_symbian_c::ReadEAPSettingsL()
|
|
2371 |
{
|
|
2372 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2373 |
|
|
2374 |
EAP_TRACE_DEBUG(
|
|
2375 |
m_am_tools,
|
|
2376 |
TRACE_FLAGS_DEFAULT,
|
|
2377 |
(EAPL("eapol_am_core_symbian_c::ReadEAPSettingsL()\n")));
|
|
2378 |
|
|
2379 |
eap_status_e status(eap_status_ok);
|
|
2380 |
|
|
2381 |
// Delete old IAP settings
|
|
2382 |
m_iap_eap_array.ResetAndDestroy();
|
|
2383 |
if (m_index_type == ELan)
|
|
2384 |
{
|
|
2385 |
EAP_TRACE_DEBUG(
|
|
2386 |
m_am_tools,
|
|
2387 |
TRACE_FLAGS_DEFAULT,
|
|
2388 |
(EAPL("Beginning to read IAP settings - Type: %d, Index: %d.\n"), m_index_type, m_index));
|
|
2389 |
|
|
2390 |
CWLanSettings* wlan = new(ELeave) CWLanSettings;
|
|
2391 |
CleanupStack::PushL(wlan);
|
|
2392 |
SWLANSettings wlanSettings;
|
|
2393 |
if (wlan->Connect() != KErrNone)
|
|
2394 |
{
|
|
2395 |
// Could not connect to CommDB
|
|
2396 |
User::Leave(KErrCouldNotConnect);
|
|
2397 |
}
|
|
2398 |
|
|
2399 |
EAP_TRACE_DEBUG(
|
|
2400 |
m_am_tools,
|
|
2401 |
TRACE_FLAGS_DEFAULT, (EAPL("Connected to CommDbIf.\n")));
|
|
2402 |
|
|
2403 |
if (wlan->GetWlanSettingsForService(m_index, wlanSettings) != KErrNone)
|
|
2404 |
{
|
|
2405 |
wlan->Disconnect();
|
|
2406 |
User::Leave(KErrUnknown);
|
|
2407 |
}
|
|
2408 |
|
|
2409 |
EAP_TRACE_DEBUG(
|
|
2410 |
m_am_tools,
|
|
2411 |
TRACE_FLAGS_DEFAULT,
|
|
2412 |
(EAPL("Got WLAN settings.\n")));
|
|
2413 |
|
|
2414 |
wlan->GetEapDataL(m_iap_eap_array);
|
|
2415 |
|
|
2416 |
EAP_TRACE_DEBUG(
|
|
2417 |
m_am_tools,
|
|
2418 |
TRACE_FLAGS_DEFAULT,
|
|
2419 |
(EAPL("Got EAP data:\n")));
|
|
2420 |
|
|
2421 |
for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
|
|
2422 |
{
|
|
2423 |
EAP_TRACE_DEBUG(
|
|
2424 |
m_am_tools,
|
|
2425 |
TRACE_FLAGS_DEFAULT,
|
|
2426 |
(EAPL("EAP type %d\n"),
|
|
2427 |
i));
|
|
2428 |
|
|
2429 |
TLex8 tmp(m_iap_eap_array[i]->UID);
|
|
2430 |
TInt val(0);
|
|
2431 |
tmp.Val(val);
|
|
2432 |
|
|
2433 |
EAP_TRACE_DEBUG(
|
|
2434 |
m_am_tools,
|
|
2435 |
TRACE_FLAGS_DEFAULT,
|
|
2436 |
(EAPL(" UID: %d\n"), val));
|
|
2437 |
EAP_TRACE_DEBUG(
|
|
2438 |
m_am_tools,
|
|
2439 |
TRACE_FLAGS_DEFAULT,
|
|
2440 |
(EAPL(" Enabled: %d\n"),
|
|
2441 |
m_iap_eap_array[i]->Enabled));
|
|
2442 |
}
|
|
2443 |
|
|
2444 |
EAP_TRACE_DEBUG(
|
|
2445 |
m_am_tools,
|
|
2446 |
TRACE_FLAGS_DEFAULT,
|
|
2447 |
(EAPL("End EAP data:\n")));
|
|
2448 |
|
|
2449 |
if (m_iap_eap_array.Count() == 0)
|
|
2450 |
{
|
|
2451 |
// The EAP field was empty. Allow all types.
|
|
2452 |
|
|
2453 |
EAP_TRACE_DEBUG(
|
|
2454 |
m_am_tools,
|
|
2455 |
TRACE_FLAGS_DEFAULT,
|
|
2456 |
(EAPL("Empty EAP field -> enable all types.\n")));
|
|
2457 |
|
|
2458 |
RImplInfoPtrArray eapArray;
|
|
2459 |
|
|
2460 |
REComSession::ListImplementationsL(KEapTypeInterfaceUid, eapArray);
|
|
2461 |
|
|
2462 |
TEap *eap;
|
|
2463 |
for (TInt i = 0; i < eapArray.Count(); i++)
|
|
2464 |
{
|
|
2465 |
eap = new(ELeave) TEap;
|
|
2466 |
eap->UID.Copy(eapArray[i]->DataType());
|
|
2467 |
eap->Enabled = ETrue;
|
|
2468 |
m_iap_eap_array.Append(eap);
|
|
2469 |
}
|
|
2470 |
|
|
2471 |
eapArray.ResetAndDestroy();
|
|
2472 |
}
|
|
2473 |
|
|
2474 |
// Get security mode
|
|
2475 |
if (m_wpa_override_enabled == false)
|
|
2476 |
{
|
|
2477 |
m_security_mode = static_cast<EWlanSecurityMode>(wlanSettings.SecurityMode);
|
|
2478 |
|
|
2479 |
if (wlanSettings.EnableWpaPsk)
|
|
2480 |
{
|
|
2481 |
m_wpa_psk_mode_allowed = true;
|
|
2482 |
}
|
|
2483 |
else
|
|
2484 |
{
|
|
2485 |
m_wpa_psk_mode_allowed = false;
|
|
2486 |
}
|
|
2487 |
}
|
|
2488 |
else
|
|
2489 |
{
|
|
2490 |
// WPA override is enabled
|
|
2491 |
m_security_mode = Wpa;
|
|
2492 |
if (m_wpa_psk_password_override->get_is_valid_data() == true
|
|
2493 |
&& m_wpa_psk_password_override->get_data_length() > 0)
|
|
2494 |
{
|
|
2495 |
m_wpa_psk_mode_allowed = true;
|
|
2496 |
}
|
|
2497 |
else
|
|
2498 |
{
|
|
2499 |
m_wpa_psk_mode_allowed = false;
|
|
2500 |
}
|
|
2501 |
}
|
|
2502 |
|
|
2503 |
|
|
2504 |
// Get WPA or WPA2 pre shared key & SSID
|
|
2505 |
if ((m_security_mode == Wlan8021x
|
|
2506 |
|| m_security_mode == Wpa
|
|
2507 |
|| m_security_mode == Wpa2Only)
|
|
2508 |
&& m_wpa_psk_mode_allowed == true
|
|
2509 |
&& m_is_client == true)
|
|
2510 |
{
|
|
2511 |
eap_variable_data_c * password = new eap_variable_data_c(m_am_tools);
|
|
2512 |
if (password == 0)
|
|
2513 |
{
|
|
2514 |
wlan->Disconnect();
|
|
2515 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2516 |
User::Leave(KErrNoMemory);
|
|
2517 |
}
|
|
2518 |
eap_variable_data_c * ssid = new eap_variable_data_c(m_am_tools);
|
|
2519 |
if (ssid == 0)
|
|
2520 |
{
|
|
2521 |
delete password;
|
|
2522 |
wlan->Disconnect();
|
|
2523 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2524 |
User::Leave(KErrNoMemory);
|
|
2525 |
}
|
|
2526 |
|
|
2527 |
// When using easy WLAN there might be WPA PSK override
|
|
2528 |
if (m_wpa_psk_password_override->get_is_valid_data() == true
|
|
2529 |
&& m_wpa_psk_password_override->get_data_length() > 0)
|
|
2530 |
{
|
|
2531 |
// Use WPA PSK override
|
|
2532 |
status = password->set_copy_of_buffer(
|
|
2533 |
m_wpa_psk_password_override->get_data(m_wpa_psk_password_override->get_data_length()),
|
|
2534 |
m_wpa_psk_password_override->get_data_length());
|
|
2535 |
if (status != eap_status_ok)
|
|
2536 |
{
|
|
2537 |
delete password;
|
|
2538 |
delete ssid;
|
|
2539 |
wlan->Disconnect();
|
|
2540 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2541 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2542 |
}
|
|
2543 |
}
|
|
2544 |
else
|
|
2545 |
{
|
|
2546 |
status = password->set_copy_of_buffer(wlanSettings.WPAPreSharedKey.Ptr(), wlanSettings.WPAPreSharedKey.Size());
|
|
2547 |
if (status != eap_status_ok)
|
|
2548 |
{
|
|
2549 |
delete password;
|
|
2550 |
delete ssid;
|
|
2551 |
wlan->Disconnect();
|
|
2552 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2553 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2554 |
}
|
|
2555 |
}
|
|
2556 |
|
|
2557 |
TBuf8<KMaxSSIDLength> tmp;
|
|
2558 |
tmp.Copy(wlanSettings.SSID);
|
|
2559 |
status = ssid->set_copy_of_buffer(tmp.Ptr(), tmp.Size());
|
|
2560 |
if (status != eap_status_ok)
|
|
2561 |
{
|
|
2562 |
delete password;
|
|
2563 |
delete ssid;
|
|
2564 |
wlan->Disconnect();
|
|
2565 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2566 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2567 |
}
|
|
2568 |
|
|
2569 |
crypto_wpa_psk_password_hash_c password_hash(m_am_tools);
|
|
2570 |
|
|
2571 |
if (ssid->get_data_length() == 0)
|
|
2572 |
{
|
|
2573 |
status = ssid->set_copy_of_buffer(m_ssid);
|
|
2574 |
if (status != eap_status_ok)
|
|
2575 |
{
|
|
2576 |
delete password;
|
|
2577 |
delete ssid;
|
|
2578 |
wlan->Disconnect();
|
|
2579 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2580 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2581 |
}
|
|
2582 |
}
|
|
2583 |
|
|
2584 |
TPSKEntry pskEntry;
|
|
2585 |
|
|
2586 |
pskEntry.indexType = m_index_type;
|
|
2587 |
pskEntry.index = m_index;
|
|
2588 |
|
|
2589 |
TPtr8 ssidPtr(
|
|
2590 |
ssid->get_data(ssid->get_data_length()),
|
|
2591 |
ssid->get_data_length(),
|
|
2592 |
ssid->get_data_length()
|
|
2593 |
);
|
|
2594 |
|
|
2595 |
TInt err(KErrNone);
|
|
2596 |
|
|
2597 |
if (m_wpa_psk_password_override->get_is_valid_data() == false
|
|
2598 |
|| m_wpa_psk_password_override->get_data_length() == 0)
|
|
2599 |
{
|
|
2600 |
// Retrieve saved PSK only when override is not in effect
|
|
2601 |
TRAP(err, RetrievePSKL(pskEntry));
|
|
2602 |
}
|
|
2603 |
|
|
2604 |
if (err != KErrNone
|
|
2605 |
|| pskEntry.ssid.Compare(ssidPtr) != 0
|
|
2606 |
|| pskEntry.password.Compare(wlanSettings.WPAPreSharedKey) != 0)
|
|
2607 |
{
|
|
2608 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("No previous PSK found...\n")));
|
|
2609 |
// No previous PSK or parameters were changed. We need to calculate
|
|
2610 |
// PSK again
|
|
2611 |
|
|
2612 |
status = password_hash.password_hash(
|
|
2613 |
password,
|
|
2614 |
ssid,
|
|
2615 |
m_wpa_preshared_key,
|
|
2616 |
0,
|
|
2617 |
0);
|
|
2618 |
|
|
2619 |
if (status != eap_status_ok)
|
|
2620 |
{
|
|
2621 |
delete password;
|
|
2622 |
delete ssid;
|
|
2623 |
wlan->Disconnect();
|
|
2624 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2625 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2626 |
// return;
|
|
2627 |
}
|
|
2628 |
|
|
2629 |
if (m_wpa_psk_password_override->get_is_valid_data() == false
|
|
2630 |
|| m_wpa_psk_password_override->get_data_length() == 0)
|
|
2631 |
{
|
|
2632 |
// Save new PSK (only if psk override is not in effect)
|
|
2633 |
pskEntry.ssid.Copy(ssidPtr);
|
|
2634 |
|
|
2635 |
pskEntry.password.Copy(wlanSettings.WPAPreSharedKey);
|
|
2636 |
|
|
2637 |
pskEntry.psk.Copy(
|
|
2638 |
m_wpa_preshared_key->get_data(m_wpa_preshared_key->get_data_length()),
|
|
2639 |
m_wpa_preshared_key->get_data_length()
|
|
2640 |
);
|
|
2641 |
|
|
2642 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Saving PSK.\n")));
|
|
2643 |
SavePSKL(pskEntry);
|
|
2644 |
}
|
|
2645 |
}
|
|
2646 |
else
|
|
2647 |
{
|
|
2648 |
// Copy retrieved psk to member variable
|
|
2649 |
status = m_wpa_preshared_key->set_copy_of_buffer(pskEntry.psk.Ptr(), pskEntry.psk.Size());
|
|
2650 |
if (status != eap_status_ok)
|
|
2651 |
{
|
|
2652 |
delete password;
|
|
2653 |
delete ssid;
|
|
2654 |
wlan->Disconnect();
|
|
2655 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2656 |
User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
|
|
2657 |
}
|
|
2658 |
}
|
|
2659 |
delete password;
|
|
2660 |
delete ssid;
|
|
2661 |
}
|
|
2662 |
|
|
2663 |
wlan->Disconnect();
|
|
2664 |
CleanupStack::PopAndDestroy(wlan);
|
|
2665 |
if (m_security_mode != Wlan8021x
|
|
2666 |
&& m_security_mode != Wpa
|
|
2667 |
&& m_security_mode != Wpa2Only)
|
|
2668 |
{
|
|
2669 |
// Unsupported mode
|
|
2670 |
User::Leave(KErrNotSupported);
|
|
2671 |
}
|
|
2672 |
}
|
|
2673 |
else
|
|
2674 |
{
|
|
2675 |
// At the moment only LAN bearer is supported.
|
|
2676 |
User::Leave(KErrNotSupported);
|
|
2677 |
}
|
|
2678 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2679 |
}
|
|
2680 |
|
|
2681 |
//--------------------------------------------------
|
|
2682 |
|
|
2683 |
void eapol_am_core_symbian_c::SetToTopPriorityL(const TEap* const aEapType)
|
|
2684 |
{
|
|
2685 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2686 |
|
|
2687 |
EAP_TRACE_DEBUG(
|
|
2688 |
m_am_tools,
|
|
2689 |
TRACE_FLAGS_DEFAULT,
|
|
2690 |
(EAPL("eapol_am_core_symbian_c::SetToTopPriorityL()\n")));
|
|
2691 |
|
|
2692 |
if (m_index_type == ELan)
|
|
2693 |
{
|
|
2694 |
TInt i(0);
|
|
2695 |
TBuf8<3> uid;
|
|
2696 |
for (i = 0; i < m_iap_eap_array.Count(); i++)
|
|
2697 |
{
|
|
2698 |
TEap* eap = m_iap_eap_array[i];
|
|
2699 |
if (eap->UID[0] == '0')
|
|
2700 |
{
|
|
2701 |
// Cut the leading zero
|
|
2702 |
uid.Copy(eap->UID.Right(eap->UID.Length()-1));
|
|
2703 |
}
|
|
2704 |
else
|
|
2705 |
{
|
|
2706 |
uid.Copy(eap->UID);
|
|
2707 |
}
|
|
2708 |
if (eap->Enabled == aEapType->Enabled
|
|
2709 |
&& uid.Compare(aEapType->UID) == 0)
|
|
2710 |
{
|
|
2711 |
// Found
|
|
2712 |
break;
|
|
2713 |
}
|
|
2714 |
}
|
|
2715 |
if (i >= m_iap_eap_array.Count())
|
|
2716 |
{
|
|
2717 |
// This should never happen
|
|
2718 |
User::Leave(KErrNotFound);
|
|
2719 |
}
|
|
2720 |
|
|
2721 |
TLex8 tmp(aEapType->UID);
|
|
2722 |
TInt val(0);
|
|
2723 |
tmp.Val(val);
|
|
2724 |
|
|
2725 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Setting to top priority:\n")));
|
|
2726 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Old index: %d\n"), i));
|
|
2727 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL(" UID: %d\n"), val));
|
|
2728 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL(" Enabled: %d\n"), aEapType->Enabled));
|
|
2729 |
|
|
2730 |
if (i == 0)
|
|
2731 |
{
|
|
2732 |
// Already at the highest priority
|
|
2733 |
return;
|
|
2734 |
}
|
|
2735 |
|
|
2736 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Beginning to write IAP EAP settings - Type: %d, Index: %d.\n"), m_index_type, m_index));
|
|
2737 |
|
|
2738 |
CWLanSettings* wlan = new(ELeave) CWLanSettings;
|
|
2739 |
CleanupStack::PushL(wlan);
|
|
2740 |
SWLANSettings wlanSettings;
|
|
2741 |
if (wlan->Connect() != KErrNone)
|
|
2742 |
{
|
|
2743 |
// Could not connect to CommDB
|
|
2744 |
User::Leave(KErrCouldNotConnect);
|
|
2745 |
}
|
|
2746 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Connected to CommDbIf.\n")));
|
|
2747 |
if (wlan->GetWlanSettingsForService(m_index, wlanSettings) != KErrNone)
|
|
2748 |
{
|
|
2749 |
wlan->Disconnect();
|
|
2750 |
User::Leave(KErrUnknown);
|
|
2751 |
}
|
|
2752 |
EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got WLAN settings.\n")));
|
|
2753 |
|
|
2754 |
// Change the order
|
|
2755 |
TEap* eap = m_iap_eap_array[i];
|
|
2756 |
|
|
2757 |
m_iap_eap_array.Remove(i); // This does not delete the object
|
|
2758 |
|
|
2759 |
m_iap_eap_array.Insert(eap, 0);
|
|
2760 |
|
|
2761 |
wlan->SetEapDataL(m_iap_eap_array);
|
|
2762 |
|
|
2763 |
wlan->Disconnect();
|
|
2764 |
|
|
2765 |
CleanupStack::PopAndDestroy(wlan);
|
|
2766 |
}
|
|
2767 |
else
|
|
2768 |
{
|
|
2769 |
// At the moment only LAN bearer is supported.
|
|
2770 |
User::Leave(KErrNotSupported);
|
|
2771 |
}
|
|
2772 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2773 |
}
|
|
2774 |
|
|
2775 |
//--------------------------------------------------
|
|
2776 |
|
|
2777 |
eap_status_e eapol_am_core_symbian_c::configure()
|
|
2778 |
{
|
|
2779 |
EAP_TRACE_DEBUG(
|
|
2780 |
m_am_tools,
|
|
2781 |
TRACE_FLAGS_DEFAULT,
|
|
2782 |
(EAPL("eapol_am_core_symbian_c::configure()\n")));
|
|
2783 |
|
|
2784 |
|
|
2785 |
//----------------------------------------------------------
|
|
2786 |
|
|
2787 |
#if defined(USE_EAP_ERROR_TESTS)
|
|
2788 |
|
|
2789 |
{
|
|
2790 |
eap_variable_data_c EAP_ERROR_TEST_enable_random_errors(m_am_tools);
|
|
2791 |
|
|
2792 |
eap_status_e status = read_configure(
|
|
2793 |
cf_str_EAP_ERROR_TEST_enable_random_errors.get_field(),
|
|
2794 |
&EAP_ERROR_TEST_enable_random_errors);
|
|
2795 |
if (status == eap_status_ok
|
|
2796 |
&& EAP_ERROR_TEST_enable_random_errors.get_is_valid_data() == true)
|
|
2797 |
{
|
|
2798 |
u32_t *enable_random_errors = reinterpret_cast<u32_t *>(
|
|
2799 |
EAP_ERROR_TEST_enable_random_errors.get_data(sizeof(u32_t));
|
|
2800 |
if (enable_random_errors != 0
|
|
2801 |
&& *enable_random_errors != 0)
|
|
2802 |
{
|
|
2803 |
m_enable_random_errors = true;
|
|
2804 |
}
|
|
2805 |
}
|
|
2806 |
}
|
|
2807 |
|
|
2808 |
{
|
|
2809 |
eap_variable_data_c EAP_ERROR_TEST_send_original_packet_first(m_am_tools);
|
|
2810 |
|
|
2811 |
eap_status_e status = read_configure(
|
|
2812 |
cf_str_EAP_ERROR_TEST_send_original_packet_first.get_field(),
|
|
2813 |
&EAP_ERROR_TEST_send_original_packet_first);
|
|
2814 |
if (status == eap_status_ok
|
|
2815 |
&& EAP_ERROR_TEST_send_original_packet_first.get_is_valid_data() == true)
|
|
2816 |
{
|
|
2817 |
u32_t *send_original_packet_first = reinterpret_cast<u32_t *>(
|
|
2818 |
EAP_ERROR_TEST_send_original_packet_first.get_data(sizeof(u32_t));
|
|
2819 |
if (send_original_packet_first != 0
|
|
2820 |
&& *send_original_packet_first != 0)
|
|
2821 |
{
|
|
2822 |
m_send_original_packet_first = true;
|
|
2823 |
}
|
|
2824 |
}
|
|
2825 |
}
|
|
2826 |
|
|
2827 |
{
|
|
2828 |
eap_variable_data_c EAP_ERROR_TEST_generate_multiple_error_packets(m_am_tools);
|
|
2829 |
|
|
2830 |
eap_status_e status = read_configure(
|
|
2831 |
cf_str_EAP_ERROR_TEST_generate_multiple_error_packets.get_field(),
|
|
2832 |
&EAP_ERROR_TEST_generate_multiple_error_packets);
|
|
2833 |
if (status == eap_status_ok
|
|
2834 |
&& EAP_ERROR_TEST_generate_multiple_error_packets.get_is_valid_data() == true)
|
|
2835 |
{
|
|
2836 |
u32_t *generate_multiple_error_packets = reinterpret_cast<u32_t *>(
|
|
2837 |
EAP_ERROR_TEST_generate_multiple_error_packets.get_data(sizeof(u32_t));
|
|
2838 |
if (generate_multiple_error_packets != 0
|
|
2839 |
&& *generate_multiple_error_packets != 0)
|
|
2840 |
{
|
|
2841 |
m_generate_multiple_error_packets = *generate_multiple_error_packets;
|
|
2842 |
}
|
|
2843 |
}
|
|
2844 |
}
|
|
2845 |
|
|
2846 |
|
|
2847 |
{
|
|
2848 |
eap_variable_data_c EAP_ERROR_TEST_manipulate_ethernet_header(m_am_tools);
|
|
2849 |
|
|
2850 |
eap_status_e status = read_configure(
|
|
2851 |
cf_str_EAP_ERROR_TEST_manipulate_ethernet_header.get_field(),
|
|
2852 |
&EAP_ERROR_TEST_manipulate_ethernet_header);
|
|
2853 |
if (status == eap_status_ok
|
|
2854 |
&& EAP_ERROR_TEST_manipulate_ethernet_header.get_is_valid_data() == true)
|
|
2855 |
{
|
|
2856 |
u32_t *manipulate_ethernet_header = reinterpret_cast<u32_t *>(
|
|
2857 |
EAP_ERROR_TEST_manipulate_ethernet_header.get_data(sizeof(u32_t));
|
|
2858 |
if (manipulate_ethernet_header != 0
|
|
2859 |
&& *manipulate_ethernet_header != 0)
|
|
2860 |
{
|
|
2861 |
m_manipulate_ethernet_header = true;
|
|
2862 |
}
|
|
2863 |
}
|
|
2864 |
}
|
|
2865 |
|
|
2866 |
{
|
|
2867 |
eap_variable_data_c EAP_ERROR_TEST_error_probability(m_am_tools);
|
|
2868 |
|
|
2869 |
eap_status_e status = read_configure(
|
|
2870 |
cf_str_EAP_ERROR_TEST_error_probability.get_field(),
|
|
2871 |
&EAP_ERROR_TEST_error_probability);
|
|
2872 |
if (status == eap_status_ok
|
|
2873 |
&& EAP_ERROR_TEST_error_probability.get_is_valid_data() == true)
|
|
2874 |
{
|
|
2875 |
u32_t *error_probability = reinterpret_cast<u32_t *>(
|
|
2876 |
EAP_ERROR_TEST_error_probability.get_data(sizeof(u32_t));
|
|
2877 |
if (error_probability != 0)
|
|
2878 |
{
|
|
2879 |
m_error_probability = *error_probability;
|
|
2880 |
}
|
|
2881 |
}
|
|
2882 |
}
|
|
2883 |
|
|
2884 |
{
|
|
2885 |
eap_variable_data_c EAP_disable_function_traces(m_am_tools);
|
|
2886 |
|
|
2887 |
eap_status_e status = read_configure(
|
|
2888 |
cf_str_EAP_TRACE_enable_function_traces.get_field(),
|
|
2889 |
&EAP_disable_function_traces);
|
|
2890 |
if (status == eap_status_ok
|
|
2891 |
&& EAP_disable_function_traces.get_is_valid_data() == true)
|
|
2892 |
{
|
|
2893 |
u32_t *disable_function_traces = reinterpret_cast<u32_t *>(
|
|
2894 |
EAP_disable_function_traces.get_data(sizeof(u32_t));
|
|
2895 |
if (disable_function_traces != 0
|
|
2896 |
&& *disable_function_traces != 0)
|
|
2897 |
{
|
|
2898 |
m_am_tools->set_trace_mask(
|
|
2899 |
m_am_tools->get_trace_mask()
|
|
2900 |
| eap_am_tools_c::eap_trace_mask_functions
|
|
2901 |
);
|
|
2902 |
}
|
|
2903 |
}
|
|
2904 |
}
|
|
2905 |
|
|
2906 |
#endif //#if defined(USE_EAP_ERROR_TESTS)
|
|
2907 |
|
|
2908 |
|
|
2909 |
//----------------------------------------------------------
|
|
2910 |
|
|
2911 |
{
|
|
2912 |
eap_variable_data_c EAP_TRACE_disable_traces(m_am_tools);
|
|
2913 |
|
|
2914 |
eap_status_e status = read_configure(
|
|
2915 |
cf_str_EAP_TRACE_disable_traces.get_field(),
|
|
2916 |
&EAP_TRACE_disable_traces);
|
|
2917 |
if (status == eap_status_ok
|
|
2918 |
&& EAP_TRACE_disable_traces.get_is_valid_data() == true)
|
|
2919 |
{
|
|
2920 |
u32_t *disable_traces = reinterpret_cast<u32_t *>(
|
|
2921 |
EAP_TRACE_disable_traces.get_data(sizeof(u32_t)));
|
|
2922 |
if (disable_traces != 0
|
|
2923 |
&& *disable_traces != 0)
|
|
2924 |
{
|
|
2925 |
m_am_tools->set_trace_mask(eap_am_tools_c::eap_trace_mask_none);
|
|
2926 |
}
|
|
2927 |
else
|
|
2928 |
{
|
|
2929 |
// OK, set the default trace mask.
|
|
2930 |
m_am_tools->set_trace_mask(
|
|
2931 |
eap_am_tools_c::eap_trace_mask_debug
|
|
2932 |
| eap_am_tools_c::eap_trace_mask_always
|
|
2933 |
| eap_am_tools_c::eap_trace_mask_error);
|
|
2934 |
}
|
|
2935 |
}
|
|
2936 |
}
|
|
2937 |
|
|
2938 |
//----------------------------------------------------------
|
|
2939 |
|
|
2940 |
{
|
|
2941 |
eap_variable_data_c EAP_TRACE_activate_only_trace_masks_always_and_error(m_am_tools);
|
|
2942 |
|
|
2943 |
eap_status_e status = read_configure(
|
|
2944 |
cf_str_EAP_TRACE_activate_only_trace_masks_always_and_error.get_field(),
|
|
2945 |
&EAP_TRACE_activate_only_trace_masks_always_and_error);
|
|
2946 |
if (status == eap_status_ok
|
|
2947 |
&& EAP_TRACE_activate_only_trace_masks_always_and_error.get_is_valid_data() == true)
|
|
2948 |
{
|
|
2949 |
u32_t *activate_trace_mask_always
|
|
2950 |
= reinterpret_cast<u32_t *>(
|
|
2951 |
EAP_TRACE_activate_only_trace_masks_always_and_error.get_data(
|
|
2952 |
sizeof(u32_t)));
|
|
2953 |
if (activate_trace_mask_always != 0
|
|
2954 |
&& *activate_trace_mask_always != 0)
|
|
2955 |
{
|
|
2956 |
m_am_tools->set_trace_mask(
|
|
2957 |
eap_am_tools_c::eap_trace_mask_always
|
|
2958 |
| eap_am_tools_c::eap_trace_mask_error
|
|
2959 |
);
|
|
2960 |
}
|
|
2961 |
}
|
|
2962 |
}
|
|
2963 |
|
|
2964 |
//----------------------------------------------------------
|
|
2965 |
|
|
2966 |
{
|
|
2967 |
eap_variable_data_c EAP_TRACE_activate_trace_on_error(m_am_tools);
|
|
2968 |
|
|
2969 |
eap_status_e status = read_configure(
|
|
2970 |
cf_str_EAP_TRACE_activate_trace_on_error.get_field(),
|
|
2971 |
&EAP_TRACE_activate_trace_on_error);
|
|
2972 |
if (status == eap_status_ok
|
|
2973 |
&& EAP_TRACE_activate_trace_on_error.get_is_valid_data() == true)
|
|
2974 |
{
|
|
2975 |
u32_t *activate_trace_on_error = reinterpret_cast<u32_t *>(
|
|
2976 |
EAP_TRACE_activate_trace_on_error.get_data(sizeof(u32_t)));
|
|
2977 |
if (activate_trace_on_error != 0
|
|
2978 |
&& *activate_trace_on_error != 0)
|
|
2979 |
{
|
|
2980 |
m_am_tools->set_activate_trace_on_error();
|
|
2981 |
}
|
|
2982 |
}
|
|
2983 |
}
|
|
2984 |
|
|
2985 |
//----------------------------------------------------------
|
|
2986 |
|
|
2987 |
// All of the configuration options are optional.
|
|
2988 |
// So we return OK.
|
|
2989 |
return eap_status_ok;
|
|
2990 |
}
|
|
2991 |
|
|
2992 |
//--------------------------------------------------
|
|
2993 |
|
|
2994 |
eap_status_e eapol_am_core_symbian_c::read_configure(
|
|
2995 |
const eap_configuration_field_c * const field,
|
|
2996 |
eap_variable_data_c * const data)
|
|
2997 |
{
|
|
2998 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
2999 |
EAP_ASSERT_ALWAYS(data != NULL);
|
|
3000 |
|
|
3001 |
// To remove compilation warning in UREL due to KMaxConfigStringLength.
|
|
3002 |
if(field->get_field_length() > KMaxConfigStringLength)
|
|
3003 |
{
|
|
3004 |
return eap_status_process_general_error;
|
|
3005 |
}
|
|
3006 |
|
|
3007 |
// Trap must be set here because the OS independent portion of EAPOL
|
|
3008 |
// that calls this function does not know anything about Symbian.
|
|
3009 |
eap_status_e status(eap_status_ok);
|
|
3010 |
|
|
3011 |
// Check if the wanted parameter is default type
|
|
3012 |
|
|
3013 |
eap_variable_data_c wanted_field(m_am_tools);
|
|
3014 |
eap_variable_data_c type_field(m_am_tools);
|
|
3015 |
eap_variable_data_c type_field_server(m_am_tools);
|
|
3016 |
|
|
3017 |
status = wanted_field.set_buffer(
|
|
3018 |
field->get_field(),
|
|
3019 |
field->get_field_length(),
|
|
3020 |
false,
|
|
3021 |
false);
|
|
3022 |
if (status != eap_status_ok)
|
|
3023 |
{
|
|
3024 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3025 |
return status;
|
|
3026 |
}
|
|
3027 |
|
|
3028 |
status = type_field.set_buffer(
|
|
3029 |
cf_str_EAP_default_type_u32_t.get_field()->get_field(),
|
|
3030 |
cf_str_EAP_default_type_u32_t.get_field()->get_field_length(),
|
|
3031 |
false,
|
|
3032 |
false);
|
|
3033 |
if (status != eap_status_ok)
|
|
3034 |
{
|
|
3035 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3036 |
return status;
|
|
3037 |
}
|
|
3038 |
|
|
3039 |
status = type_field_server.set_buffer(
|
|
3040 |
cf_str_EAP_server_default_type_u32_t.get_field()->get_field(),
|
|
3041 |
cf_str_EAP_server_default_type_u32_t.get_field()->get_field_length(),
|
|
3042 |
false,
|
|
3043 |
false);
|
|
3044 |
if (status != eap_status_ok)
|
|
3045 |
{
|
|
3046 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3047 |
return status;
|
|
3048 |
}
|
|
3049 |
|
|
3050 |
if (!wanted_field.compare(&type_field)
|
|
3051 |
|| !wanted_field.compare(&type_field_server))
|
|
3052 |
{
|
|
3053 |
TInt i;
|
|
3054 |
// We need to return here the next EAP type we should try
|
|
3055 |
for (i = m_eap_index; i < m_iap_eap_array.Count(); i++)
|
|
3056 |
{
|
|
3057 |
// Find the first enabled EAP type (highest priority)
|
|
3058 |
TEap *eapType = m_iap_eap_array[i];
|
|
3059 |
if (eapType->Enabled == 1)
|
|
3060 |
{
|
|
3061 |
// Convert the string to integer
|
|
3062 |
TLex8 tmp(eapType->UID);
|
|
3063 |
TInt val(0);
|
|
3064 |
tmp.Val(val);
|
|
3065 |
status = data->set_copy_of_buffer(reinterpret_cast<u8_t *>(&val), sizeof(TUint));
|
|
3066 |
if (status != eap_status_ok)
|
|
3067 |
{
|
|
3068 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3069 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
|
|
3070 |
}
|
|
3071 |
|
|
3072 |
EAP_TRACE_DEBUG(
|
|
3073 |
m_am_tools,
|
|
3074 |
TRACE_FLAGS_DEFAULT,
|
|
3075 |
(EAPL("EAPOL: Trying EAP type: %d.\n"), val));
|
|
3076 |
break;
|
|
3077 |
}
|
|
3078 |
}
|
|
3079 |
m_eap_index = i;
|
|
3080 |
if (i >= m_iap_eap_array.Count())
|
|
3081 |
{
|
|
3082 |
// Not found
|
|
3083 |
// Send WLM notification because there is no way that the authentication
|
|
3084 |
// can be successful if we don't have any EAP types to use...
|
|
3085 |
if (m_is_client)
|
|
3086 |
{
|
|
3087 |
EAP_TRACE_ERROR(
|
|
3088 |
m_am_tools,
|
|
3089 |
TRACE_FLAGS_DEFAULT,
|
|
3090 |
(EAPL("ERROR: No configured EAP types or all tried unsuccessfully.\n")));
|
|
3091 |
}
|
|
3092 |
|
|
3093 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3094 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
|
|
3095 |
}
|
|
3096 |
|
|
3097 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3098 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3099 |
}
|
|
3100 |
|
|
3101 |
// It was something else than EAP type. Read it from DB.
|
|
3102 |
TRAPD(err, read_configureL(
|
|
3103 |
field->get_field(),
|
|
3104 |
field->get_field_length(),
|
|
3105 |
data));
|
|
3106 |
if (err != KErrNone)
|
|
3107 |
{
|
|
3108 |
status = m_am_tools->convert_am_error_to_eapol_error(err);
|
|
3109 |
|
|
3110 |
#if defined(USE_EAP_FILECONFIG)
|
|
3111 |
if (m_fileconfig != 0
|
|
3112 |
&& m_fileconfig->get_is_valid() == true)
|
|
3113 |
{
|
|
3114 |
// Here we could try the final configuration option.
|
|
3115 |
status = m_fileconfig->read_configure(
|
|
3116 |
field,
|
|
3117 |
data);
|
|
3118 |
}
|
|
3119 |
#endif //#if defined(USE_EAP_FILECONFIG)
|
|
3120 |
}
|
|
3121 |
|
|
3122 |
m_am_tools->trace_configuration(
|
|
3123 |
status,
|
|
3124 |
field,
|
|
3125 |
data);
|
|
3126 |
|
|
3127 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3128 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3129 |
}
|
|
3130 |
|
|
3131 |
//--------------------------------------------------
|
|
3132 |
|
|
3133 |
void eapol_am_core_symbian_c::read_configureL(
|
|
3134 |
eap_config_string field,
|
|
3135 |
const u32_t /*field_length*/,
|
|
3136 |
eap_variable_data_c * const data)
|
|
3137 |
{
|
|
3138 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3139 |
|
|
3140 |
// Create a buffer for the ascii strings - initialised with the argument
|
|
3141 |
HBufC8* asciibuf = HBufC8::NewLC(128);
|
|
3142 |
TPtr8 asciiString = asciibuf->Des();
|
|
3143 |
asciiString.Copy(reinterpret_cast<const unsigned char *>(field));
|
|
3144 |
|
|
3145 |
// Buffer for unicode parameter
|
|
3146 |
HBufC* unicodebuf = HBufC::NewLC(128);
|
|
3147 |
TPtr unicodeString = unicodebuf->Des();
|
|
3148 |
|
|
3149 |
// Convert to unicode
|
|
3150 |
unicodeString.Copy(asciiString);
|
|
3151 |
|
|
3152 |
// Now do the database query
|
|
3153 |
HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
|
|
3154 |
TPtr sqlStatement = buf->Des();
|
|
3155 |
_LIT(KSQLQueryRow, "SELECT %S FROM eapol");
|
|
3156 |
sqlStatement.Format(KSQLQueryRow, &unicodeString);
|
|
3157 |
|
|
3158 |
RDbView view;
|
|
3159 |
User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
|
|
3160 |
CleanupClosePushL(view);
|
|
3161 |
User::LeaveIfError(view.EvaluateAll());
|
|
3162 |
if (view.FirstL())
|
|
3163 |
{
|
|
3164 |
eap_status_e status(eap_status_process_general_error);
|
|
3165 |
view.GetL();
|
|
3166 |
switch (view.ColType(1))
|
|
3167 |
{
|
|
3168 |
case EDbColText:
|
|
3169 |
{
|
|
3170 |
unicodeString = view.ColDes(1);
|
|
3171 |
// Convert to 8-bit
|
|
3172 |
asciiString.Copy(unicodeString);
|
|
3173 |
if (asciiString.Size() > 0)
|
|
3174 |
{
|
|
3175 |
status = data->set_copy_of_buffer(asciiString.Ptr(), asciiString.Size());
|
|
3176 |
if (status != eap_status_ok)
|
|
3177 |
{
|
|
3178 |
User::Leave(KErrNoMemory);
|
|
3179 |
}
|
|
3180 |
}
|
|
3181 |
else
|
|
3182 |
{
|
|
3183 |
// Empty field. Do nothing...data remains invalid
|
|
3184 |
// and the stack knows what to do hopefully.
|
|
3185 |
break;
|
|
3186 |
}
|
|
3187 |
}
|
|
3188 |
break;
|
|
3189 |
case EDbColUint32:
|
|
3190 |
{
|
|
3191 |
TUint value;
|
|
3192 |
value = view.ColUint32(1);
|
|
3193 |
status = data->set_copy_of_buffer((const unsigned char *) &value, sizeof(value));
|
|
3194 |
if (status != eap_status_ok)
|
|
3195 |
{
|
|
3196 |
User::Leave(KErrNoMemory);
|
|
3197 |
}
|
|
3198 |
}
|
|
3199 |
break;
|
|
3200 |
default:
|
|
3201 |
EAP_TRACE_DEBUG(
|
|
3202 |
m_am_tools,
|
|
3203 |
TRACE_FLAGS_DEFAULT,
|
|
3204 |
(EAPL("read_configureL: Unexpected column type.\n")));
|
|
3205 |
User::Panic(_L("EAPOL"), 1);
|
|
3206 |
}
|
|
3207 |
}
|
|
3208 |
else
|
|
3209 |
{
|
|
3210 |
// Could not find parameter
|
|
3211 |
EAP_TRACE_DEBUG(
|
|
3212 |
m_am_tools,
|
|
3213 |
TRACE_FLAGS_DEFAULT,
|
|
3214 |
(EAPL("read_configureL: Could not find configuration parameter.\n")));
|
|
3215 |
User::Leave(KErrNotFound);
|
|
3216 |
}
|
|
3217 |
|
|
3218 |
// Close database
|
|
3219 |
CleanupStack::PopAndDestroy(4); // session & 3 buffers
|
|
3220 |
|
|
3221 |
|
|
3222 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3223 |
}
|
|
3224 |
|
|
3225 |
//--------------------------------------------------
|
|
3226 |
|
|
3227 |
eap_status_e eapol_am_core_symbian_c::write_configure(
|
|
3228 |
const eap_configuration_field_c * const /*field*/,
|
|
3229 |
eap_variable_data_c * const /*data*/)
|
|
3230 |
{
|
|
3231 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3232 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3233 |
return eap_status_not_supported;
|
|
3234 |
}
|
|
3235 |
|
|
3236 |
//--------------------------------------------------
|
|
3237 |
|
|
3238 |
//
|
|
3239 |
eap_status_e eapol_am_core_symbian_c::set_timer(
|
|
3240 |
abs_eap_base_timer_c * const p_initializer,
|
|
3241 |
const u32_t p_id,
|
|
3242 |
void * const p_data,
|
|
3243 |
const u32_t p_time_ms)
|
|
3244 |
{
|
|
3245 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3246 |
|
|
3247 |
const eap_status_e status = m_am_tools->am_set_timer(
|
|
3248 |
p_initializer,
|
|
3249 |
p_id,
|
|
3250 |
p_data,
|
|
3251 |
p_time_ms);
|
|
3252 |
|
|
3253 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3254 |
return status;
|
|
3255 |
}
|
|
3256 |
|
|
3257 |
//--------------------------------------------------
|
|
3258 |
|
|
3259 |
//
|
|
3260 |
eap_status_e eapol_am_core_symbian_c::cancel_timer(
|
|
3261 |
abs_eap_base_timer_c * const p_initializer,
|
|
3262 |
const u32_t p_id)
|
|
3263 |
{
|
|
3264 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3265 |
|
|
3266 |
const eap_status_e status = m_am_tools->am_cancel_timer(
|
|
3267 |
p_initializer,
|
|
3268 |
p_id);
|
|
3269 |
|
|
3270 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3271 |
return status;
|
|
3272 |
}
|
|
3273 |
|
|
3274 |
//--------------------------------------------------
|
|
3275 |
|
|
3276 |
//
|
|
3277 |
eap_status_e eapol_am_core_symbian_c::cancel_all_timers()
|
|
3278 |
{
|
|
3279 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3280 |
|
|
3281 |
const eap_status_e status = m_am_tools->am_cancel_all_timers();
|
|
3282 |
|
|
3283 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3284 |
return status;
|
|
3285 |
}
|
|
3286 |
|
|
3287 |
//--------------------------------------------------
|
|
3288 |
|
|
3289 |
eap_status_e eapol_am_core_symbian_c::check_is_valid_eap_type(const eap_type_value_e eap_type)
|
|
3290 |
{
|
|
3291 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3292 |
|
|
3293 |
TEap *eapType = 0;
|
|
3294 |
|
|
3295 |
eap_status_e status(eap_status_illegal_eap_type);
|
|
3296 |
|
|
3297 |
for (int i = 0; i < m_iap_eap_array.Count(); i++)
|
|
3298 |
{
|
|
3299 |
// Try next EAP type
|
|
3300 |
eapType = m_iap_eap_array[i];
|
|
3301 |
if (eapType->Enabled == 1)
|
|
3302 |
{
|
|
3303 |
// Convert the string to integer
|
|
3304 |
TLex8 tmp(eapType->UID);
|
|
3305 |
TInt val(0);
|
|
3306 |
tmp.Val(val);
|
|
3307 |
if (eap_type == static_cast<eap_type_ietf_values_e>(val))
|
|
3308 |
{
|
|
3309 |
// Allowed
|
|
3310 |
status = eap_status_ok;
|
|
3311 |
break;
|
|
3312 |
}
|
|
3313 |
}
|
|
3314 |
}
|
|
3315 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3316 |
|
|
3317 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3318 |
}
|
|
3319 |
|
|
3320 |
//--------------------------------------------------
|
|
3321 |
|
|
3322 |
eap_status_e eapol_am_core_symbian_c::get_eap_type_list(
|
|
3323 |
eap_array_c<eap_type_value_e> * const eap_type_list)
|
|
3324 |
{
|
|
3325 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3326 |
|
|
3327 |
TEap *eapType = 0;
|
|
3328 |
|
|
3329 |
eap_status_e status(eap_status_illegal_eap_type);
|
|
3330 |
|
|
3331 |
status = eap_type_list->reset();
|
|
3332 |
if (status != eap_status_ok)
|
|
3333 |
{
|
|
3334 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3335 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3336 |
}
|
|
3337 |
|
|
3338 |
for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
|
|
3339 |
{
|
|
3340 |
// Check if type is enabled
|
|
3341 |
eapType = m_iap_eap_array[i];
|
|
3342 |
if (eapType->Enabled == 1)
|
|
3343 |
{
|
|
3344 |
TLex8 tmp(eapType->UID);
|
|
3345 |
TInt val(0);
|
|
3346 |
tmp.Val(val);
|
|
3347 |
|
|
3348 |
eap_type_value_e * const eap_type = new eap_type_value_e(
|
|
3349 |
static_cast<eap_type_ietf_values_e>(val));
|
|
3350 |
if (eap_type == 0)
|
|
3351 |
{
|
|
3352 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3353 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
|
|
3354 |
}
|
|
3355 |
|
|
3356 |
status = eap_type_list->add_object(eap_type, true);
|
|
3357 |
if (status != eap_status_ok)
|
|
3358 |
{
|
|
3359 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3360 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3361 |
}
|
|
3362 |
}
|
|
3363 |
}
|
|
3364 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3365 |
return eap_status_ok;
|
|
3366 |
}
|
|
3367 |
|
|
3368 |
//--------------------------------------------------
|
|
3369 |
|
|
3370 |
void eapol_am_core_symbian_c::TryOpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession)
|
|
3371 |
{
|
|
3372 |
EAP_TRACE_DEBUG(
|
|
3373 |
m_am_tools,
|
|
3374 |
TRACE_FLAGS_DEFAULT,
|
|
3375 |
(EAPL("eapol_am_core_symbian_c::TryOpenDatabaseL()\n")));
|
|
3376 |
|
|
3377 |
// 1. Open/create a database
|
|
3378 |
|
|
3379 |
// Connect to the DBMS server.
|
|
3380 |
User::LeaveIfError(aSession.Connect());
|
|
3381 |
CleanupClosePushL(aSession);
|
|
3382 |
// aSession and aDatabase are pushed to the cleanup stack even though they may be member
|
|
3383 |
// variables of the calling class and would be closed in the destructor anyway. This ensures
|
|
3384 |
// that if they are not member variables they will be closed. Closing the handle twice
|
|
3385 |
// does no harm.
|
|
3386 |
|
|
3387 |
#ifdef SYMBIAN_SECURE_DBMS
|
|
3388 |
|
|
3389 |
// Create the secure shared database (if necessary) with the specified secure policy.
|
|
3390 |
// Database will be created in the data caging path for DBMS (C:\private\100012a5).
|
|
3391 |
|
|
3392 |
TInt err = aDatabase.Create(aSession, KDatabaseName, KSecureUIDFormat);
|
|
3393 |
|
|
3394 |
EAP_TRACE_DEBUG(
|
|
3395 |
m_am_tools,
|
|
3396 |
TRACE_FLAGS_DEFAULT,
|
|
3397 |
(EAPL("TryOpenDatabaseL() - Created Secure DB for eapol.dat. err=%d\n"), err ));
|
|
3398 |
|
|
3399 |
if(err == KErrNone)
|
|
3400 |
{
|
|
3401 |
aDatabase.Close();
|
|
3402 |
|
|
3403 |
} else if (err != KErrAlreadyExists)
|
|
3404 |
{
|
|
3405 |
User::LeaveIfError(err);
|
|
3406 |
}
|
|
3407 |
|
|
3408 |
User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName, KSecureUIDFormat));
|
|
3409 |
CleanupClosePushL(aDatabase);
|
|
3410 |
|
|
3411 |
#else
|
|
3412 |
// For non-secured database. The database will be created in the old location (c:\system\data).
|
|
3413 |
|
|
3414 |
RFs fsSession;
|
|
3415 |
User::LeaveIfError(fsSession.Connect());
|
|
3416 |
CleanupClosePushL(fsSession);
|
|
3417 |
|
|
3418 |
// Create the database (if necessary)
|
|
3419 |
TInt err = aDatabase.Create(fsSession, KDatabaseName);
|
|
3420 |
|
|
3421 |
EAP_TRACE_DEBUG(
|
|
3422 |
m_am_tools,
|
|
3423 |
TRACE_FLAGS_DEFAULT,
|
|
3424 |
(EAPL("TryOpenDatabaseL() - Created Non-Secure DB for eapol.dat. err=%d\n"), err ));
|
|
3425 |
|
|
3426 |
if(err == KErrNone)
|
|
3427 |
{
|
|
3428 |
aDatabase.Close();
|
|
3429 |
|
|
3430 |
} else if (err != KErrAlreadyExists)
|
|
3431 |
{
|
|
3432 |
User::LeaveIfError(err);
|
|
3433 |
}
|
|
3434 |
CleanupStack::PopAndDestroy(); // close fsSession
|
|
3435 |
|
|
3436 |
User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName));
|
|
3437 |
CleanupClosePushL(aDatabase);
|
|
3438 |
|
|
3439 |
#endif // #ifdef SYMBIAN_SECURE_DBMS
|
|
3440 |
|
|
3441 |
HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
|
|
3442 |
TPtr sqlStatement = buf->Des();
|
|
3443 |
|
|
3444 |
// 2. Create the table for pre-shared keys in database (ignore error if exists)
|
|
3445 |
|
|
3446 |
//// NAME /////////////////////////////////////////////////// TYPE ////////////// Constant ///////
|
|
3447 |
//| ServiceType | UNSIGNED INTEGER | KServiceType |//
|
|
3448 |
//| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |//
|
|
3449 |
//| SSID | VARBINARY(255) | KSSID |//
|
|
3450 |
//| Password | VARBINARY(255) | KPassword |//
|
|
3451 |
//| PSK | VARBINARY(255) | KPSK |//
|
|
3452 |
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
3453 |
|
|
3454 |
_LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \
|
|
3455 |
%S UNSIGNED INTEGER, \
|
|
3456 |
%S VARBINARY(255), \
|
|
3457 |
%S VARBINARY(255), \
|
|
3458 |
%S VARBINARY(255))");
|
|
3459 |
|
|
3460 |
sqlStatement.Format(KSQLCreateTable2, &KEapolPSKTableName,
|
|
3461 |
&KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK);
|
|
3462 |
|
|
3463 |
err = aDatabase.Execute(sqlStatement);
|
|
3464 |
if (err != KErrNone && err != KErrAlreadyExists)
|
|
3465 |
{
|
|
3466 |
User::Leave(err);
|
|
3467 |
}
|
|
3468 |
|
|
3469 |
CleanupStack::PopAndDestroy(); // buf
|
|
3470 |
CleanupStack::Pop(2); // database, session
|
|
3471 |
|
|
3472 |
// If compacting is not done the database will start growing
|
|
3473 |
aDatabase.Compact();
|
|
3474 |
}
|
|
3475 |
|
|
3476 |
//--------------------------------------------------
|
|
3477 |
|
|
3478 |
void eapol_am_core_symbian_c::OpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession)
|
|
3479 |
{
|
|
3480 |
EAP_TRACE_DEBUG(
|
|
3481 |
m_am_tools,
|
|
3482 |
TRACE_FLAGS_DEFAULT,
|
|
3483 |
(EAPL("eapol_am_core_symbian_c::OpenDatabaseL()\n")));
|
|
3484 |
|
|
3485 |
// Create the database (if necessary)
|
|
3486 |
TRAPD(err, TryOpenDatabaseL(aDatabase, aSession));
|
|
3487 |
if (err != KErrNone)
|
|
3488 |
{
|
|
3489 |
// Because of error remove the database file.
|
|
3490 |
RFs fsDataBaseFile;
|
|
3491 |
User::LeaveIfError(fsDataBaseFile.Connect());
|
|
3492 |
CleanupClosePushL(fsDataBaseFile);
|
|
3493 |
err = fsDataBaseFile.Delete(KDatabaseName);
|
|
3494 |
if(err != KErrNone)
|
|
3495 |
{
|
|
3496 |
User::Leave(KErrCorrupt);
|
|
3497 |
}
|
|
3498 |
CleanupStack::PopAndDestroy(); // close fsDataBaseFile
|
|
3499 |
|
|
3500 |
// Try open database again. This will leave if fails second time.
|
|
3501 |
TryOpenDatabaseL(aDatabase, aSession);
|
|
3502 |
}
|
|
3503 |
}
|
|
3504 |
|
|
3505 |
//--------------------------------------------------
|
|
3506 |
|
|
3507 |
eap_status_e eapol_am_core_symbian_c::random_error(
|
|
3508 |
eap_buf_chain_wr_c * const sent_packet,
|
|
3509 |
const bool forse_error,
|
|
3510 |
const u32_t packet_index)
|
|
3511 |
{
|
|
3512 |
EAP_UNREFERENCED_PARAMETER(packet_index);
|
|
3513 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3514 |
|
|
3515 |
EAP_TRACE_DEBUG(
|
|
3516 |
m_am_tools,
|
|
3517 |
TRACE_FLAGS_DEFAULT,
|
|
3518 |
(EAPL("eapol_am_core_symbian_c::random_error()\n")));
|
|
3519 |
|
|
3520 |
eap_status_e status(eap_status_ok);
|
|
3521 |
u8_t *data = sent_packet->get_data(sent_packet->get_data_length());
|
|
3522 |
|
|
3523 |
crypto_random_c rand(m_am_tools);
|
|
3524 |
u32_t random_guard(0);
|
|
3525 |
bool error_generated(false);
|
|
3526 |
u32_t minimum_index(0);
|
|
3527 |
|
|
3528 |
if (m_manipulate_ethernet_header == false)
|
|
3529 |
{
|
|
3530 |
minimum_index = eapol_ethernet_header_wr_c::get_header_length();
|
|
3531 |
}
|
|
3532 |
|
|
3533 |
for (u32_t ind = minimum_index; ind < sent_packet->get_data_length(); ind++)
|
|
3534 |
{
|
|
3535 |
status = rand.get_rand_bytes(
|
|
3536 |
reinterpret_cast<u8_t *>(&random_guard),
|
|
3537 |
sizeof(random_guard));
|
|
3538 |
if (status != eap_status_ok)
|
|
3539 |
{
|
|
3540 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3541 |
}
|
|
3542 |
|
|
3543 |
// This is simple limiter to the probability of an error.
|
|
3544 |
// probability = m_error_probability / (2^32)
|
|
3545 |
if (random_guard < m_error_probability)
|
|
3546 |
{
|
|
3547 |
u8_t rnd(0);
|
|
3548 |
u8_t previous_data(0);
|
|
3549 |
// Create an error.
|
|
3550 |
status = rand.get_rand_bytes(
|
|
3551 |
&rnd,
|
|
3552 |
sizeof(rnd));
|
|
3553 |
if (status != eap_status_ok)
|
|
3554 |
{
|
|
3555 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3556 |
}
|
|
3557 |
|
|
3558 |
previous_data = data[ind];
|
|
3559 |
data[ind] ^= rnd;
|
|
3560 |
|
|
3561 |
if (previous_data != data[ind])
|
|
3562 |
{
|
|
3563 |
error_generated = true;
|
|
3564 |
sent_packet->set_random_error_type(eap_random_error_type_manipulate_byte);
|
|
3565 |
|
|
3566 |
EAP_TRACE_DEBUG(
|
|
3567 |
m_am_tools,
|
|
3568 |
TRACE_FLAGS_DEFAULT,
|
|
3569 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, data[0x%04x] changed from 0x%02x to 0x%02x.\n"),
|
|
3570 |
this,
|
|
3571 |
packet_index,
|
|
3572 |
ind,
|
|
3573 |
previous_data,
|
|
3574 |
data[ind]));
|
|
3575 |
}
|
|
3576 |
}
|
|
3577 |
}
|
|
3578 |
|
|
3579 |
if (error_generated == false
|
|
3580 |
&& forse_error == true
|
|
3581 |
&& sent_packet->get_data_length() > 0ul)
|
|
3582 |
{
|
|
3583 |
// Generate one error.
|
|
3584 |
|
|
3585 |
// Random error type.
|
|
3586 |
eap_random_error_type error_type = eap_random_error_type_none_keep_this_last_case;
|
|
3587 |
status = rand.get_rand_bytes(
|
|
3588 |
reinterpret_cast<u8_t *>(&error_type),
|
|
3589 |
sizeof(error_type));
|
|
3590 |
if (status != eap_status_ok)
|
|
3591 |
{
|
|
3592 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3593 |
}
|
|
3594 |
|
|
3595 |
error_type = static_cast<eap_random_error_type>(
|
|
3596 |
static_cast<u32_t>(error_type % static_cast<u32_t>(
|
|
3597 |
eap_random_error_type_none_keep_this_last_case)));
|
|
3598 |
|
|
3599 |
sent_packet->set_random_error_type(error_type);
|
|
3600 |
|
|
3601 |
switch(error_type)
|
|
3602 |
{
|
|
3603 |
case eap_random_error_type_manipulate_byte:
|
|
3604 |
{
|
|
3605 |
u32_t rnd_index(0);
|
|
3606 |
u8_t previous_data(0);
|
|
3607 |
u32_t index(0);
|
|
3608 |
|
|
3609 |
do
|
|
3610 |
{
|
|
3611 |
do
|
|
3612 |
{
|
|
3613 |
// Create an error index.
|
|
3614 |
status = rand.get_rand_bytes(
|
|
3615 |
reinterpret_cast<u8_t *>(&rnd_index),
|
|
3616 |
sizeof(rnd_index));
|
|
3617 |
if (status != eap_status_ok)
|
|
3618 |
{
|
|
3619 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3620 |
}
|
|
3621 |
|
|
3622 |
index = (rnd_index % (sent_packet->get_data_length() - minimum_index))
|
|
3623 |
+ minimum_index;
|
|
3624 |
}
|
|
3625 |
while(index < minimum_index
|
|
3626 |
|| index > sent_packet->get_buffer_length());
|
|
3627 |
|
|
3628 |
u8_t rnd(0);
|
|
3629 |
// Create an error.
|
|
3630 |
status = rand.get_rand_bytes(
|
|
3631 |
&rnd,
|
|
3632 |
sizeof(rnd));
|
|
3633 |
if (status != eap_status_ok)
|
|
3634 |
{
|
|
3635 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3636 |
}
|
|
3637 |
|
|
3638 |
previous_data = data[index];
|
|
3639 |
data[index] ^= rnd;
|
|
3640 |
}
|
|
3641 |
while(previous_data == data[index]);
|
|
3642 |
|
|
3643 |
EAP_TRACE_DEBUG(
|
|
3644 |
m_am_tools,
|
|
3645 |
TRACE_FLAGS_DEFAULT,
|
|
3646 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, data[0x%04x] changed from 0x%02x to 0x%02x.\n"),
|
|
3647 |
this,
|
|
3648 |
packet_index,
|
|
3649 |
index,
|
|
3650 |
previous_data,
|
|
3651 |
data[index]));
|
|
3652 |
|
|
3653 |
error_generated = true;
|
|
3654 |
}
|
|
3655 |
break;
|
|
3656 |
case eap_random_error_type_change_packet_length_longer:
|
|
3657 |
{
|
|
3658 |
u8_t delta_length(0);
|
|
3659 |
i32_t new_length(0);
|
|
3660 |
|
|
3661 |
do
|
|
3662 |
{
|
|
3663 |
status = rand.get_rand_bytes(
|
|
3664 |
reinterpret_cast<u8_t *>(&delta_length),
|
|
3665 |
sizeof(delta_length));
|
|
3666 |
if (status != eap_status_ok)
|
|
3667 |
{
|
|
3668 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3669 |
}
|
|
3670 |
|
|
3671 |
new_length = static_cast<i32_t>(sent_packet->get_data_length()
|
|
3672 |
+ static_cast<i32_t>(delta_length));
|
|
3673 |
}
|
|
3674 |
while (new_length < static_cast<i32_t>(
|
|
3675 |
eapol_ethernet_header_wr_c::get_header_length())
|
|
3676 |
|| new_length > static_cast<i32_t>(sent_packet->get_buffer_length()));
|
|
3677 |
|
|
3678 |
EAP_TRACE_DEBUG(
|
|
3679 |
m_am_tools,
|
|
3680 |
TRACE_FLAGS_DEFAULT,
|
|
3681 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, packet length changed from %lu to %lu.\n"),
|
|
3682 |
this,
|
|
3683 |
packet_index,
|
|
3684 |
sent_packet->get_data_length(),
|
|
3685 |
new_length));
|
|
3686 |
|
|
3687 |
sent_packet->set_data_length(new_length);
|
|
3688 |
|
|
3689 |
error_generated = true;
|
|
3690 |
}
|
|
3691 |
break;
|
|
3692 |
case eap_random_error_type_change_packet_length_shorter:
|
|
3693 |
{
|
|
3694 |
u8_t delta_length(0);
|
|
3695 |
i32_t new_length(0);
|
|
3696 |
|
|
3697 |
do
|
|
3698 |
{
|
|
3699 |
status = rand.get_rand_bytes(
|
|
3700 |
reinterpret_cast<u8_t *>(&delta_length),
|
|
3701 |
sizeof(delta_length));
|
|
3702 |
if (status != eap_status_ok)
|
|
3703 |
{
|
|
3704 |
return EAP_STATUS_RETURN(m_am_tools, status);
|
|
3705 |
}
|
|
3706 |
|
|
3707 |
delta_length %= static_cast<i32_t>(
|
|
3708 |
sent_packet->get_data_length()
|
|
3709 |
- static_cast<i32_t>(eapol_ethernet_header_wr_c::get_header_length()));
|
|
3710 |
|
|
3711 |
if (delta_length == 0)
|
|
3712 |
{
|
|
3713 |
continue;
|
|
3714 |
}
|
|
3715 |
|
|
3716 |
new_length = static_cast<i32_t>(
|
|
3717 |
sent_packet->get_data_length() - static_cast<i32_t>(delta_length));
|
|
3718 |
}
|
|
3719 |
while (new_length < static_cast<i32_t>(
|
|
3720 |
eapol_ethernet_header_wr_c::get_header_length())
|
|
3721 |
|| new_length > static_cast<i32_t>(sent_packet->get_buffer_length()));
|
|
3722 |
|
|
3723 |
EAP_TRACE_DEBUG(
|
|
3724 |
m_am_tools,
|
|
3725 |
TRACE_FLAGS_DEFAULT,
|
|
3726 |
(EAPL("TEST: random_error(): packet_index 0x%08x:%lu, packet length changed from %lu to %lu.\n"),
|
|
3727 |
this,
|
|
3728 |
packet_index,
|
|
3729 |
sent_packet->get_data_length(),
|
|
3730 |
new_length));
|
|
3731 |
|
|
3732 |
sent_packet->set_data_length(new_length);
|
|
3733 |
|
|
3734 |
error_generated = true;
|
|
3735 |
}
|
|
3736 |
break;
|
|
3737 |
default:
|
|
3738 |
User::Panic(_L("EAPOL"), 1);
|
|
3739 |
break;
|
|
3740 |
}
|
|
3741 |
}
|
|
3742 |
|
|
3743 |
if (error_generated == true)
|
|
3744 |
{
|
|
3745 |
sent_packet->set_is_manipulated();
|
|
3746 |
}
|
|
3747 |
|
|
3748 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3749 |
return status;
|
|
3750 |
}
|
|
3751 |
|
|
3752 |
//--------------------------------------------------
|
|
3753 |
|
|
3754 |
eap_status_e eapol_am_core_symbian_c::create_upper_stack()
|
|
3755 |
{
|
|
3756 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3757 |
|
|
3758 |
EAP_TRACE_DEBUG(
|
|
3759 |
m_am_tools,
|
|
3760 |
TRACE_FLAGS_DEFAULT,
|
|
3761 |
(EAPL("eapol_am_core_symbian_c::create_upper_stack()\n")));
|
|
3762 |
|
|
3763 |
eap_status_e status(eap_status_ok);
|
|
3764 |
|
|
3765 |
if (m_ethernet_core == 0)
|
|
3766 |
{
|
|
3767 |
m_ethernet_core = new ethernet_core_c(m_am_tools, this, m_is_client);
|
|
3768 |
if (m_ethernet_core == 0
|
|
3769 |
|| m_ethernet_core->get_is_valid() != true)
|
|
3770 |
{
|
|
3771 |
if (m_ethernet_core != 0)
|
|
3772 |
{
|
|
3773 |
m_ethernet_core->shutdown();
|
|
3774 |
delete m_ethernet_core;
|
|
3775 |
m_ethernet_core = 0;
|
|
3776 |
}
|
|
3777 |
EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Stack creation failed.\n")));
|
|
3778 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3779 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
|
|
3780 |
}
|
|
3781 |
|
|
3782 |
// Initialise upper stack
|
|
3783 |
status = m_ethernet_core->configure();
|
|
3784 |
|
|
3785 |
if (status != eap_status_ok)
|
|
3786 |
{
|
|
3787 |
m_ethernet_core->shutdown();
|
|
3788 |
delete m_ethernet_core;
|
|
3789 |
m_ethernet_core = 0;
|
|
3790 |
|
|
3791 |
EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Stack creation failed.\n")));
|
|
3792 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3793 |
return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
|
|
3794 |
}
|
|
3795 |
}
|
|
3796 |
else
|
|
3797 |
{
|
|
3798 |
status = eap_status_already_exists;
|
|
3799 |
}
|
|
3800 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3801 |
return status;
|
|
3802 |
}
|
|
3803 |
|
|
3804 |
//--------------------------------------------------
|
|
3805 |
|
|
3806 |
eap_status_e eapol_am_core_symbian_c::add_rogue_ap(
|
|
3807 |
eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list)
|
|
3808 |
{
|
|
3809 |
EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3810 |
|
|
3811 |
EAP_TRACE_DEBUG(
|
|
3812 |
m_am_tools,
|
|
3813 |
TRACE_FLAGS_DEFAULT,
|
|
3814 |
(EAPL("eapol_am_core_symbian_c::add_rogue_ap()\n")));
|
|
3815 |
|
|
3816 |
TInt err(KErrNone);
|
|
3817 |
eap_rogue_ap_entry_c* entry = 0;
|
|
3818 |
|
|
3819 |
TMacAddress mac;
|
|
3820 |
|
|
3821 |
TRogueType type;
|
|
3822 |
|
|
3823 |
for (u32_t i = 0; i < rogue_ap_list.get_object_count(); i++)
|
|
3824 |
{
|
|
3825 |
entry = rogue_ap_list.get_object(i);
|
|
3826 |
|
|
3827 |
entry->get_mac_address(mac.iMacAddress);
|
|
3828 |
|
|
3829 |
EAP_TRACE_DEBUG(
|
|
3830 |
m_am_tools,
|
|
3831 |
TRACE_FLAGS_DEFAULT,
|
|
3832 |
(EAPL("Adding rogue AP - type: %d\n"),
|
|
3833 |
entry->get_rogue_reason()));
|
|
3834 |
EAP_TRACE_DATA_DEBUG(
|
|
3835 |
m_am_tools,
|
|
3836 |
TRACE_FLAGS_DEFAULT,
|
|
3837 |
(EAPL("Rogue MAC address"),
|
|
3838 |
mac.iMacAddress,
|
|
3839 |
KMacAddressLength));
|
|
3840 |
|
|
3841 |
switch (entry->get_rogue_reason())
|
|
3842 |
{
|
|
3843 |
case rogue_ap_none:
|
|
3844 |
// Ignore this
|
|
3845 |
continue;
|
|
3846 |
case rogue_ap_association_failed:
|
|
3847 |
type = EInvalidAuthenticationType;
|
|
3848 |
break;
|
|
3849 |
case rogue_ap_timeout:
|
|
3850 |
type = EAuthenticationTimeout;
|
|
3851 |
break;
|
|
3852 |
case rogue_ap_challenge_to_client_failed:
|
|
3853 |
type = EChallengeFromAPFailed;
|
|
3854 |
break;
|
|
3855 |
case rogue_ap_challenge_to_ap_failed:
|
|
3856 |
type = EChallengeToAPFailed;
|
|
3857 |
break;
|
|
3858 |
default:
|
|
3859 |
// ignore others
|
|
3860 |
continue;
|
|
3861 |
}
|
|
3862 |
|
|
3863 |
err = m_partner->AddRogueAP(mac, type);
|
|
3864 |
if (err != KErrNone)
|
|
3865 |
{
|
|
3866 |
break;
|
|
3867 |
}
|
|
3868 |
}
|
|
3869 |
EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
|
|
3870 |
return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
|
|
3871 |
}
|
|
3872 |
|
|
3873 |
//--------------------------------------------------
|
|
3874 |
|
|
3875 |
void eapol_am_core_symbian_c::RetrievePSKL(TPSKEntry& entry)
|
|
3876 |
{
|
|
3877 |
HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
|
|
3878 |
TPtr sqlStatement = sqlbuf->Des();
|
|
3879 |
|
|
3880 |
RDbView view;
|
|
3881 |
|
|
3882 |
_LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d");
|
|
3883 |
|
|
3884 |
sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK,
|
|
3885 |
&KEapolPSKTableName, &KServiceType, entry.indexType, &KServiceIndex, entry.index);
|
|
3886 |
|
|
3887 |
User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
|
|
3888 |
CleanupClosePushL(view);
|
|
3889 |
User::LeaveIfError(view.EvaluateAll());
|
|
3890 |
|
|
3891 |
TInt rows = view.CountL();
|
|
3892 |
|
|
3893 |
if (rows == 0)
|
|
3894 |
{
|
|
3895 |
// No saved PSK
|
|
3896 |
User::Leave(KErrNotFound);
|
|
3897 |
}
|
|
3898 |
view.FirstL();
|
|
3899 |
view.GetL();
|
|
3900 |
|
|
3901 |
entry.ssid.Copy(view.ColDes8(3));
|
|
3902 |
entry.password.Copy(view.ColDes8(4));
|
|
3903 |
entry.psk.Copy(view.ColDes8(5));
|
|
3904 |
|
|
3905 |
CleanupStack::PopAndDestroy(2); // view, buf
|
|
3906 |
}
|
|
3907 |
|
|
3908 |
//--------------------------------------------------
|
|
3909 |
|
|
3910 |
void eapol_am_core_symbian_c::SavePSKL(TPSKEntry& entry)
|
|
3911 |
{
|
|
3912 |
// Connect to CommDBif so that we can delete PSK entries that have no IAP associated anymore.
|
|
3913 |
CWLanSettings* wlan = new(ELeave) CWLanSettings;
|
|
3914 |
CleanupStack::PushL(wlan);
|
|
3915 |
|
|
3916 |
SWLANSettings wlanSettings;
|
|
3917 |
|
|
3918 |
if (wlan->Connect() != KErrNone)
|
|
3919 |
{
|
|
3920 |
// Could not connect to CommDB
|
|
3921 |
User::Leave(KErrCouldNotConnect);
|
|
3922 |
}
|
|
3923 |
|
|
3924 |
HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
|
|
3925 |
TPtr sqlStatement = sqlbuf->Des();
|
|
3926 |
|
|
3927 |
RDbView view;
|
|
3928 |
|
|
3929 |
_LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S");
|
|
3930 |
|
|
3931 |
sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK,
|
|
3932 |
&KEapolPSKTableName);
|
|
3933 |
|
|
3934 |
User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
|
|
3935 |
CleanupClosePushL(view);
|
|
3936 |
User::LeaveIfError(view.EvaluateAll());
|
|
3937 |
|
|
3938 |
// Get column set so we get the correct column numbers
|
|
3939 |
CDbColSet* colSet = view.ColSetL();
|
|
3940 |
CleanupStack::PushL(colSet);
|
|
3941 |
|
|
3942 |
// Delete old row and also rows that have no associated IAP settings.
|
|
3943 |
if (view.FirstL())
|
|
3944 |
{
|
|
3945 |
do {
|
|
3946 |
view.GetL();
|
|
3947 |
|
|
3948 |
if ((wlan->GetWlanSettingsForService(view.ColUint32(colSet->ColNo(KServiceIndex)), wlanSettings) != KErrNone)
|
|
3949 |
|| (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(entry.indexType)
|
|
3950 |
&& view.ColUint32(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(entry.index)))
|
|
3951 |
{
|
|
3952 |
// Not found or current IAP
|
|
3953 |
view.DeleteL();
|
|
3954 |
}
|
|
3955 |
|
|
3956 |
} while (view.NextL() != EFalse);
|
|
3957 |
}
|
|
3958 |
|
|
3959 |
wlan->Disconnect();
|
|
3960 |
|
|
3961 |
view.InsertL();
|
|
3962 |
|
|
3963 |
view.SetColL(colSet->ColNo(KServiceType), (TUint)entry.indexType);
|
|
3964 |
view.SetColL(colSet->ColNo(KServiceIndex), (TUint)entry.index);
|
|
3965 |
view.SetColL(colSet->ColNo(KSSID), entry.ssid);
|
|
3966 |
view.SetColL(colSet->ColNo(KPassword), entry.password);
|
|
3967 |
view.SetColL(colSet->ColNo(KPSK), entry.psk);
|
|
3968 |
|
|
3969 |
view.PutL();
|
|
3970 |
|
|
3971 |
CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
|
|
3972 |
|
|
3973 |
CleanupStack::PopAndDestroy(3); // CWLanSettings, session, database
|
|
3974 |
|
|
3975 |
}
|
|
3976 |
|
|
3977 |
|
|
3978 |
//--------------------------------------------------
|
|
3979 |
|
|
3980 |
|
|
3981 |
// End of file
|