|
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 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 149 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 |
|
29 #include "eap_am_memory.h" |
|
30 #include "eap_variable_data.h" |
|
31 #include "eap_tools.h" |
|
32 #include "eap_type_all.h" |
|
33 #include "eapol_am_core_symbian_simulator.h" |
|
34 #include "eapol_ethernet_header.h" |
|
35 #include <EapType.h> |
|
36 |
|
37 |
|
38 //-------------------------------------------------- |
|
39 |
|
40 // |
|
41 EAP_FUNC_EXPORT eapol_am_core_symbian_c::~eapol_am_core_symbian_c() |
|
42 { |
|
43 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
44 |
|
45 EAP_ASSERT(m_shutdown_was_called == true); |
|
46 |
|
47 m_am_tools->enter_global_mutex(); |
|
48 delete m_ethernet_core; |
|
49 m_am_tools->leave_global_mutex(); |
|
50 |
|
51 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
52 } |
|
53 |
|
54 //-------------------------------------------------- |
|
55 |
|
56 // |
|
57 EAP_FUNC_EXPORT eapol_am_core_symbian_c::eapol_am_core_symbian_c( |
|
58 abs_eap_am_tools_c * const tools, |
|
59 abs_eapol_am_core_symbian_c * const partner, |
|
60 const bool is_client_when_true) |
|
61 : m_partner(partner) |
|
62 , m_ethernet_core(new ethernet_core_c(tools, this, is_client_when_true)) |
|
63 , m_am_tools(tools) |
|
64 , m_own_address(tools) |
|
65 , m_authentication_counter(0u) |
|
66 , m_error_probability(0u) |
|
67 , m_is_valid(false) |
|
68 , m_is_client(is_client_when_true) |
|
69 , m_enable_random_errors(false) |
|
70 , m_shutdown_was_called(false) |
|
71 { |
|
72 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
73 |
|
74 m_am_tools->enter_global_mutex(); |
|
75 if (m_ethernet_core != 0 |
|
76 && m_ethernet_core->get_is_valid() == true) |
|
77 { |
|
78 set_is_valid(); |
|
79 } |
|
80 m_am_tools->leave_global_mutex(); |
|
81 |
|
82 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
83 } |
|
84 |
|
85 //-------------------------------------------------- |
|
86 |
|
87 // |
|
88 EAP_FUNC_EXPORT eap_base_type_c * eapol_am_core_symbian_c::load_type(const eap_type_value_e /*type*/) |
|
89 { |
|
90 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
91 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
92 return 0; |
|
93 } |
|
94 |
|
95 //-------------------------------------------------- |
|
96 |
|
97 #if defined(USE_EAPOL_LLC_INTERFACE) |
|
98 |
|
99 // |
|
100 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::packet_process( |
|
101 RMBufChain& aPdu) |
|
102 { |
|
103 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
104 eap_status_e status = eap_status_process_general_error; |
|
105 |
|
106 const u32_t packet_length = aPdu.Length(); |
|
107 |
|
108 if (packet_length < eapol_ethernet_header_wr_c::get_header_length()) |
|
109 { |
|
110 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
111 return eap_status_too_short_message; |
|
112 } |
|
113 |
|
114 eapol_ethernet_header_wr_c eth_header(aPdu.First()->Ptr()); |
|
115 |
|
116 if (eth_header.get_type() == eapol_ethernet_type_pae) |
|
117 { |
|
118 u8_t packet_buffer[EAP_MEM_GUARDS(EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH)]; |
|
119 eap_buf_chain_rd_c response_packet( |
|
120 eap_read_buffer, m_am_tools, packet_buffer, sizeof(packet_buffer), false); |
|
121 u32_t offset = 0u; |
|
122 RMBuf *buf = aPdu.First(); |
|
123 |
|
124 while(buf != 0) |
|
125 { |
|
126 m_am_tools->memmove(packet_buffer+offset, buf->Ptr(), buf->Length()); |
|
127 offset += buf->Length(); |
|
128 buf = buf->Next(); |
|
129 } |
|
130 |
|
131 eapol_ethernet_header_wr_c eth_header(packet_buffer); |
|
132 |
|
133 eap_am_network_id_c receive_network_id( |
|
134 m_am_tools, |
|
135 eth_header.get_source()->get_address(), |
|
136 eth_header.get_source()->get_address_length(), |
|
137 eth_header.get_destination()->get_address(), |
|
138 eth_header.get_destination()->get_address_length(), |
|
139 eth_header.get_type(), |
|
140 false, |
|
141 false); |
|
142 |
|
143 if (m_own_address.get_data_length() != receive_network_id.get_destination_id()->get_data_length() |
|
144 || m_am_tools->memcmp( |
|
145 m_own_address.get_data(m_own_address.get_data_length()), |
|
146 receive_network_id.get_destination_id()->get_data(receive_network_id.get_destination_id()->get_data_length()), |
|
147 receive_network_id.get_destination_id()->get_data_length())) |
|
148 { |
|
149 return eap_status_wrong_network_id; |
|
150 } |
|
151 |
|
152 if (m_ethernet_core == 0) |
|
153 { |
|
154 return eap_status_allocation_error; |
|
155 } |
|
156 |
|
157 if (packet_length < eapol_ethernet_header_rd_c::get_header_length()) |
|
158 { |
|
159 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
160 return eap_status_process_illegal_packet_error; |
|
161 } |
|
162 |
|
163 m_am_tools->enter_global_mutex(); |
|
164 status = m_ethernet_core->packet_process( |
|
165 &receive_network_id, |
|
166 ð_header, |
|
167 packet_length, |
|
168 NULL); |
|
169 m_am_tools->leave_global_mutex(); |
|
170 } |
|
171 else |
|
172 { |
|
173 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Not supported ethernet type 0x%04x\n"), eth_header.get_type())); |
|
174 status = eap_status_ethernet_type_not_supported; |
|
175 } |
|
176 |
|
177 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
178 return status; |
|
179 } |
|
180 |
|
181 #endif //#if defined(USE_EAPOL_LLC_INTERFACE) |
|
182 |
|
183 //-------------------------------------------------- |
|
184 |
|
185 // |
|
186 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::packet_process( |
|
187 const eap_am_network_id_c * const receive_network_id, |
|
188 eapol_ethernet_header_wr_c * const eth_header, |
|
189 const u32_t packet_length) |
|
190 { |
|
191 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
192 eap_status_e status = eap_status_process_general_error; |
|
193 |
|
194 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eapol_am_core_symbian_c::packet_process(): Received packet addresses:\n"))); |
|
195 |
|
196 if (m_ethernet_core == 0) |
|
197 { |
|
198 return eap_status_allocation_error; |
|
199 } |
|
200 |
|
201 if (packet_length < eapol_ethernet_header_rd_c::get_header_length()) |
|
202 { |
|
203 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
204 return eap_status_process_illegal_packet_error; |
|
205 } |
|
206 |
|
207 if (eth_header->get_type() == eapol_ethernet_type_pae) |
|
208 { |
|
209 m_am_tools->enter_global_mutex(); |
|
210 status = m_ethernet_core->packet_process( |
|
211 receive_network_id, |
|
212 eth_header, |
|
213 packet_length); |
|
214 m_am_tools->leave_global_mutex(); |
|
215 } |
|
216 else |
|
217 { |
|
218 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Not supported ethernet type 0x%04x\n"), eth_header->get_type())); |
|
219 status = eap_status_ethernet_type_not_supported; |
|
220 } |
|
221 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
222 return status; |
|
223 } |
|
224 |
|
225 //-------------------------------------------------- |
|
226 |
|
227 #include "eap_crypto_api.h" |
|
228 |
|
229 // |
|
230 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::random_error( |
|
231 eap_buf_chain_wr_c * const sent_packet) |
|
232 { |
|
233 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
234 |
|
235 eap_status_e status = eap_status_ok; |
|
236 u32_t ind = 0u; |
|
237 u8_t *data = sent_packet->get_data(sent_packet->get_data_length()); |
|
238 |
|
239 crypto_random_c rand(m_am_tools); |
|
240 u32_t random_guard; |
|
241 |
|
242 for (ind = 0u; ind < sent_packet->get_data_length(); ind++) |
|
243 { |
|
244 status = rand.get_rand_bytes( |
|
245 reinterpret_cast<u8_t *>(&random_guard, |
|
246 sizeof(random_guard)); |
|
247 if (status != eap_status_ok) |
|
248 { |
|
249 return EAP_STATUS_RETURN(m_am_tools, status); |
|
250 } |
|
251 |
|
252 // This is simple limiter to the probability of an error. |
|
253 // probability = m_error_probability / (2^32) |
|
254 if (random_guard < m_error_probability) |
|
255 { |
|
256 u8_t rnd; |
|
257 u8_t previous_data; |
|
258 // Create an error. |
|
259 status = rand.get_rand_bytes( |
|
260 &rnd, |
|
261 sizeof(rnd)); |
|
262 if (status != eap_status_ok) |
|
263 { |
|
264 return EAP_STATUS_RETURN(m_am_tools, status); |
|
265 } |
|
266 |
|
267 previous_data = data[ind]; |
|
268 data[ind] ^= rnd; |
|
269 |
|
270 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TEST: random_error() data[0x%x] changed from 0x%02x to 0x%02x.\n"), |
|
271 ind, previous_data, data[ind])); |
|
272 } |
|
273 } |
|
274 |
|
275 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
276 return status; |
|
277 } |
|
278 |
|
279 //-------------------------------------------------- |
|
280 |
|
281 // |
|
282 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::packet_send( |
|
283 const eap_am_network_id_c * const send_network_id, |
|
284 eap_buf_chain_wr_c * const sent_packet, |
|
285 const u32_t header_offset, |
|
286 const u32_t data_length, |
|
287 const u32_t buffer_length) |
|
288 { |
|
289 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
290 |
|
291 if (header_offset != 0u) |
|
292 { |
|
293 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("packet_send: packet buffer corrupted.\n"))); |
|
294 return eap_status_process_general_error; |
|
295 } |
|
296 else if (header_offset+data_length != sent_packet->get_data_length()) |
|
297 { |
|
298 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: packet_send: packet buffer corrupted (data_length != sent_packet->get_data_length()).\n"))); |
|
299 EAP_ASSERT_ALWAYS(data_length == sent_packet->get_buffer_length()); |
|
300 return eap_status_process_general_error; |
|
301 } |
|
302 |
|
303 eap_status_e status = eap_status_process_general_error; |
|
304 |
|
305 if (m_enable_random_errors == true) |
|
306 { |
|
307 // Make a random error to the message. |
|
308 random_error(sent_packet); |
|
309 } |
|
310 |
|
311 status = m_partner->packet_send( |
|
312 send_network_id, |
|
313 sent_packet, |
|
314 header_offset, |
|
315 data_length, |
|
316 buffer_length, |
|
317 this, |
|
318 true, |
|
319 0ul); |
|
320 |
|
321 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
322 return status; |
|
323 } |
|
324 |
|
325 //-------------------------------------------------- |
|
326 |
|
327 // |
|
328 EAP_FUNC_EXPORT u32_t eapol_am_core_symbian_c::get_header_offset( |
|
329 u32_t * const MTU, |
|
330 u32_t * const trailer_length) |
|
331 { |
|
332 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
333 const u32_t offset = m_partner->get_header_offset(MTU, trailer_length); |
|
334 // (*MTU) |
|
335 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
336 return offset; |
|
337 } |
|
338 |
|
339 //-------------------------------------------------- |
|
340 |
|
341 // |
|
342 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::unload_module(const eap_type_value_e type) |
|
343 { |
|
344 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
345 eap_status_e status = eap_status_process_general_error; |
|
346 TInt index = m_eap_type_array.Find(type); |
|
347 if (index != KErrNotFound) |
|
348 { |
|
349 delete m_plugin_if_array[index]; |
|
350 m_plugin_if_array.Remove(index); |
|
351 m_eap_type_array.Remove(index); |
|
352 status = eap_status_ok; |
|
353 } |
|
354 |
|
355 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
356 return status; |
|
357 } |
|
358 |
|
359 //-------------------------------------------------- |
|
360 |
|
361 // |
|
362 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::eap_acknowledge(const eap_am_network_id_c * const receive_network_id) |
|
363 { |
|
364 // Any Network Protocol packet is accepted as a success indication. |
|
365 // This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)". |
|
366 |
|
367 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
368 |
|
369 if (m_ethernet_core == 0) |
|
370 { |
|
371 return eap_status_allocation_error; |
|
372 } |
|
373 |
|
374 m_am_tools->enter_global_mutex(); |
|
375 eap_status_e status = m_ethernet_core->eap_acknowledge(receive_network_id); |
|
376 m_am_tools->leave_global_mutex(); |
|
377 |
|
378 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
379 |
|
380 return status; |
|
381 } |
|
382 |
|
383 //-------------------------------------------------- |
|
384 |
|
385 // |
|
386 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::load_module( |
|
387 const eap_type_value_e type, |
|
388 const eap_type_value_e /* tunneling_type */, |
|
389 abs_eap_base_type_c * const partner, |
|
390 eap_base_type_c ** const eap_type_if, |
|
391 const bool is_client_when_true, |
|
392 const eap_am_network_id_c * const receive_network_id) |
|
393 { |
|
394 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
395 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eapol_am_core_symbian_c::load_module(%d)\n"), type)); |
|
396 eap_status_e status = eap_status_process_general_error; |
|
397 TBuf8<3> cue; |
|
398 cue.Num(type); |
|
399 CEapType *eapType = NULL; |
|
400 TInt error; |
|
401 // NOTE: This works now only with test_eapol simulator. In the future the index & indextype parameters |
|
402 // are received from WLM. |
|
403 if (is_client_when_true) |
|
404 { |
|
405 // We must have a trap here since the EAPOL core knows nothing about Symbian. |
|
406 TRAP(error, (eapType = CEapType::NewL(cue, ELan, 666))); |
|
407 } else { |
|
408 TRAP(error, (eapType = CEapType::NewL(cue, ELan, 667))); |
|
409 } |
|
410 |
|
411 if (error != KErrNone) |
|
412 { |
|
413 // Interface not found or implementation creation function failed |
|
414 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ECom could not find/initiate implementation.\n"))); |
|
415 return eap_status_allocation_error; |
|
416 } |
|
417 // Create the EAP protocol interface implementation. |
|
418 TRAP(error, (*eap_type_if = eapType->GetStackInterfaceL(m_am_tools, partner, is_client_when_true, receive_network_id))); |
|
419 |
|
420 if (error != KErrNone || |
|
421 *eap_type_if == 0 || |
|
422 (*eap_type_if)->get_is_valid() == false) |
|
423 { |
|
424 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Could not create EAP type interface instance.\n"))); |
|
425 status = eap_status_allocation_error; |
|
426 // Unload DLL |
|
427 delete eapType; |
|
428 } |
|
429 else |
|
430 { |
|
431 status = eap_status_ok; |
|
432 // Add plugin information to the member arrays. There is no need to store eap_type pointer because |
|
433 // the stack takes care of its deletion. |
|
434 m_plugin_if_array.Append(eapType); |
|
435 m_eap_type_array.Append(type); |
|
436 |
|
437 } |
|
438 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
439 return status; |
|
440 } |
|
441 |
|
442 //-------------------------------------------------- |
|
443 |
|
444 // |
|
445 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::start_authentication( |
|
446 const eap_am_network_id_c * const receive_network_id, |
|
447 const bool is_client_when_true) |
|
448 { |
|
449 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
450 |
|
451 if (m_ethernet_core == 0) |
|
452 { |
|
453 return eap_status_allocation_error; |
|
454 } |
|
455 |
|
456 m_am_tools->enter_global_mutex(); |
|
457 eap_status_e status = m_ethernet_core->start_authentication(receive_network_id, is_client_when_true); |
|
458 m_am_tools->leave_global_mutex(); |
|
459 |
|
460 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
461 return status; |
|
462 } |
|
463 |
|
464 //-------------------------------------------------- |
|
465 |
|
466 // |
|
467 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::send_logoff(const eap_am_network_id_c * const receive_network_id) |
|
468 { |
|
469 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
470 |
|
471 if (m_ethernet_core == 0) |
|
472 { |
|
473 return eap_status_allocation_error; |
|
474 } |
|
475 |
|
476 m_am_tools->enter_global_mutex(); |
|
477 eap_status_e status = m_ethernet_core->send_logoff(receive_network_id); |
|
478 m_am_tools->leave_global_mutex(); |
|
479 |
|
480 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
481 return status; |
|
482 } |
|
483 |
|
484 //-------------------------------------------------- |
|
485 |
|
486 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::configure() |
|
487 { |
|
488 m_am_tools->enter_global_mutex(); |
|
489 eap_status_e status = m_ethernet_core->configure(); |
|
490 m_am_tools->leave_global_mutex(); |
|
491 |
|
492 |
|
493 //---------------------------------------------------------- |
|
494 |
|
495 { |
|
496 eap_variable_data_c EAP_TRACE_disable_traces(m_am_tools); |
|
497 |
|
498 status = read_configure( |
|
499 cf_str_EAP_TRACE_disable_traces.get_field(), |
|
500 &EAP_TRACE_disable_traces); |
|
501 if (status == eap_status_ok |
|
502 && EAP_TRACE_disable_traces.get_is_valid() == true) |
|
503 { |
|
504 u32_t *disable_traces = reinterpret_cast<u32_t *>(EAP_TRACE_disable_traces.get_data(sizeof(u32_t)); |
|
505 if (disable_traces != 0 |
|
506 && *disable_traces != 0) |
|
507 { |
|
508 m_am_tools->set_trace_mask( |
|
509 eap_am_tools_c::eap_trace_mask_always |
|
510 | eap_am_tools_c::eap_trace_mask_error |
|
511 ); |
|
512 } |
|
513 } |
|
514 } |
|
515 |
|
516 //---------------------------------------------------------- |
|
517 |
|
518 { |
|
519 eap_variable_data_c EAP_TRACE_enable_function_traces(m_am_tools); |
|
520 |
|
521 status = read_configure( |
|
522 cf_str_EAP_TRACE_enable_function_traces.get_field(), |
|
523 &EAP_TRACE_enable_function_traces); |
|
524 if (status == eap_status_ok |
|
525 && EAP_TRACE_enable_function_traces.get_is_valid() == true) |
|
526 { |
|
527 u32_t *enable_function_traces = reinterpret_cast<u32_t *>(EAP_TRACE_enable_function_traces.get_data(sizeof(u32_t)); |
|
528 if (enable_function_traces != 0 |
|
529 && *enable_function_traces != 0) |
|
530 { |
|
531 m_am_tools->set_trace_mask( |
|
532 m_am_tools->get_trace_mask() |
|
533 | eap_am_tools_c::eap_trace_mask_functions |
|
534 ); |
|
535 } |
|
536 } |
|
537 } |
|
538 |
|
539 //---------------------------------------------------------- |
|
540 |
|
541 { |
|
542 eap_variable_data_c EAP_ERROR_TEST_enable_random_errors(m_am_tools); |
|
543 |
|
544 status = read_configure( |
|
545 cf_str_EAP_ERROR_TEST_enable_random_errors.get_field(), |
|
546 &EAP_ERROR_TEST_enable_random_errors); |
|
547 if (status == eap_status_ok |
|
548 && EAP_ERROR_TEST_enable_random_errors.get_is_valid() == true) |
|
549 { |
|
550 u32_t *enable_random_errors = reinterpret_cast<u32_t *>(EAP_ERROR_TEST_enable_random_errors.get_data(sizeof(u32_t)); |
|
551 if (enable_random_errors != 0 |
|
552 && *enable_random_errors != 0) |
|
553 { |
|
554 m_enable_random_errors = true; |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 //---------------------------------------------------------- |
|
560 |
|
561 { |
|
562 eap_variable_data_c EAP_ERROR_TEST_error_probability(m_am_tools); |
|
563 |
|
564 status = read_configure( |
|
565 cf_str_EAP_ERROR_TEST_error_probability.get_field(), |
|
566 &EAP_ERROR_TEST_error_probability); |
|
567 if (status == eap_status_ok |
|
568 && EAP_ERROR_TEST_error_probability.get_is_valid() == true) |
|
569 { |
|
570 u32_t *error_probability = reinterpret_cast<u32_t *>(EAP_ERROR_TEST_error_probability.get_data(sizeof(u32_t)); |
|
571 if (error_probability != 0) |
|
572 { |
|
573 m_error_probability = *error_probability; |
|
574 } |
|
575 } |
|
576 } |
|
577 |
|
578 //---------------------------------------------------------- |
|
579 |
|
580 { |
|
581 eap_variable_data_c trace_output_file(m_am_tools); |
|
582 |
|
583 eap_status_e status = read_configure( |
|
584 cf_str_EAP_TRACE_output_file_name.get_field(), |
|
585 &trace_output_file); |
|
586 if (status == eap_status_ok |
|
587 && trace_output_file.get_is_valid() == true) |
|
588 { |
|
589 status = m_am_tools->set_trace_file_name(&trace_output_file); |
|
590 if (status != eap_status_ok) |
|
591 { |
|
592 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
593 return EAP_STATUS_RETURN(m_am_tools, status); |
|
594 } |
|
595 } |
|
596 } |
|
597 |
|
598 //---------------------------------------------------------- |
|
599 |
|
600 { |
|
601 eap_variable_data_c EAP_TRACE_activate_only_trace_masks_always_and_error(m_am_tools); |
|
602 |
|
603 status = read_configure( |
|
604 cf_str_EAP_TRACE_activate_only_trace_masks_always_and_error.get_field(), |
|
605 &EAP_TRACE_activate_only_trace_masks_always_and_error); |
|
606 if (status == eap_status_ok |
|
607 && EAP_TRACE_activate_only_trace_masks_always_and_error.get_is_valid() == true) |
|
608 { |
|
609 u32_t *activate_trace_mask_always |
|
610 = reinterpret_cast<u32_t *>(EAP_TRACE_activate_only_trace_masks_always_and_error.get_data(sizeof(u32_t)); |
|
611 if (activate_trace_mask_always != 0 |
|
612 && *activate_trace_mask_always != 0) |
|
613 { |
|
614 m_am_tools->set_trace_mask( |
|
615 eap_am_tools_c::eap_trace_mask_always |
|
616 | eap_am_tools_c::eap_trace_mask_error |
|
617 ); |
|
618 } |
|
619 } |
|
620 } |
|
621 |
|
622 //---------------------------------------------------------- |
|
623 |
|
624 { |
|
625 eap_variable_data_c EAP_TRACE_activate_trace_on_error(m_am_tools); |
|
626 |
|
627 status = read_configure( |
|
628 cf_str_EAP_TRACE_activate_trace_on_error.get_field(), |
|
629 &EAP_TRACE_activate_trace_on_error); |
|
630 if (status == eap_status_ok |
|
631 && EAP_TRACE_activate_trace_on_error.get_is_valid() == true) |
|
632 { |
|
633 u32_t *activate_trace_on_error = reinterpret_cast<u32_t *>(EAP_TRACE_activate_trace_on_error.get_data(sizeof(u32_t)); |
|
634 if (activate_trace_on_error != 0 |
|
635 && *activate_trace_on_error != 0) |
|
636 { |
|
637 m_am_tools->set_activate_trace_on_error(); |
|
638 } |
|
639 } |
|
640 } |
|
641 |
|
642 //---------------------------------------------------------- |
|
643 |
|
644 |
|
645 return eap_status_ok; |
|
646 } |
|
647 |
|
648 //-------------------------------------------------- |
|
649 |
|
650 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::shutdown() |
|
651 { |
|
652 m_am_tools->enter_global_mutex(); |
|
653 m_ethernet_core->shutdown(); |
|
654 m_am_tools->leave_global_mutex(); |
|
655 |
|
656 // Unload all loaded plugins |
|
657 for(int i = 0; i < m_plugin_if_array.Count(); i++) |
|
658 { |
|
659 delete m_plugin_if_array[i]; |
|
660 } |
|
661 m_plugin_if_array.Close(); |
|
662 m_eap_type_array.Close(); |
|
663 |
|
664 m_shutdown_was_called = true; |
|
665 |
|
666 return eap_status_ok; |
|
667 } |
|
668 |
|
669 //-------------------------------------------------- |
|
670 |
|
671 // |
|
672 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::packet_data_crypto_keys( |
|
673 const eap_am_network_id_c * const send_network_id, |
|
674 const eap_master_session_key_c * const master_session_key |
|
675 ) |
|
676 { |
|
677 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
678 |
|
679 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
680 |
|
681 const eap_status_e status = m_partner->packet_data_crypto_keys(send_network_id, master_session_key); |
|
682 |
|
683 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
684 return status; |
|
685 } |
|
686 |
|
687 //-------------------------------------------------- |
|
688 eap_status_e eapol_am_core_symbian_c::packet_data_session_key( |
|
689 const eap_am_network_id_c * const /*send_network_id*/, |
|
690 const eapol_session_key_c * const /*key*/) |
|
691 { |
|
692 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
693 switch (key_type) |
|
694 { |
|
695 case eapol_key_type_wep_broadcast: |
|
696 // m_partner->SetWepKey(key, key_length, key_index) |
|
697 break; |
|
698 case eapol_key_type_wep_unicast: |
|
699 //m_partner->SetWepKey(key, key_length, key_index | 0x80) |
|
700 break; |
|
701 default: |
|
702 return eap_status_not_supported; |
|
703 } |
|
704 //TInt status = m_partner->SetKey(EWepKey, master_session_length, master_session_key) |
|
705 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
706 return eap_status_ok; |
|
707 } |
|
708 |
|
709 |
|
710 |
|
711 //-------------------------------------------------- |
|
712 |
|
713 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::read_configure( |
|
714 const eap_configuration_field_c * const field, |
|
715 eap_variable_data_c * const data) |
|
716 { |
|
717 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
718 const eap_status_e status = m_partner->read_configure(field, data); |
|
719 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
720 return status; |
|
721 } |
|
722 |
|
723 //-------------------------------------------------- |
|
724 |
|
725 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::write_configure( |
|
726 const eap_configuration_field_c * const field, |
|
727 eap_variable_data_c * const data) |
|
728 { |
|
729 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
730 const eap_status_e status = m_partner->write_configure(field, data); |
|
731 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
732 return status; |
|
733 } |
|
734 |
|
735 //-------------------------------------------------- |
|
736 |
|
737 // |
|
738 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::set_timer( |
|
739 abs_eap_base_timer_c * const p_initializer, |
|
740 const u32_t p_id, |
|
741 void * const p_data, |
|
742 const u32_t p_time_ms) |
|
743 { |
|
744 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
745 |
|
746 EAP_UNREFERENCED_PARAMETER(p_initializer); |
|
747 EAP_UNREFERENCED_PARAMETER(p_id); |
|
748 EAP_UNREFERENCED_PARAMETER(p_data); |
|
749 EAP_UNREFERENCED_PARAMETER(p_time_ms); |
|
750 |
|
751 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
752 |
|
753 const eap_status_e status = m_am_tools->am_set_timer( |
|
754 p_initializer, |
|
755 p_id, |
|
756 p_data, |
|
757 p_time_ms); |
|
758 |
|
759 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
760 return EAP_STATUS_RETURN(m_am_tools, status); |
|
761 } |
|
762 |
|
763 //-------------------------------------------------- |
|
764 |
|
765 // |
|
766 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::cancel_timer( |
|
767 abs_eap_base_timer_c * const p_initializer, |
|
768 const u32_t p_id) |
|
769 { |
|
770 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
771 |
|
772 EAP_UNREFERENCED_PARAMETER(p_initializer); |
|
773 EAP_UNREFERENCED_PARAMETER(p_id); |
|
774 |
|
775 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
776 |
|
777 const eap_status_e status = m_am_tools->am_cancel_timer( |
|
778 p_initializer, |
|
779 p_id); |
|
780 |
|
781 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
782 return EAP_STATUS_RETURN(m_am_tools, status); |
|
783 } |
|
784 |
|
785 //-------------------------------------------------- |
|
786 |
|
787 // |
|
788 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::cancel_all_timers() |
|
789 { |
|
790 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
791 |
|
792 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
793 |
|
794 const eap_status_e status = m_am_tools->am_cancel_all_timers(); |
|
795 |
|
796 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
797 return EAP_STATUS_RETURN(m_am_tools, status); |
|
798 } |
|
799 |
|
800 //-------------------------------------------------- |
|
801 |
|
802 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::check_is_valid_eap_type(const eap_type_value_e /*eap_type*/) |
|
803 { |
|
804 |
|
805 #if defined(USE_EAP_TYPE_GSMSIM) |
|
806 if (eap_type == eap_type_gsmsim) |
|
807 { |
|
808 return eap_status_ok; |
|
809 } |
|
810 else |
|
811 #endif |
|
812 #if defined(USE_SAESIM_EAP_TYPE) |
|
813 if (eap_type == eap_type_saesim) |
|
814 { |
|
815 return eap_status_ok; |
|
816 } |
|
817 else |
|
818 #endif |
|
819 #if defined(USE_DUMMY_SIM_EAP_TYPE) |
|
820 if (eap_type == eap_type_sim) |
|
821 { |
|
822 return eap_status_ok; |
|
823 } |
|
824 else |
|
825 #endif |
|
826 { |
|
827 return eap_status_illegal_eap_type; |
|
828 } |
|
829 |
|
830 } |
|
831 |
|
832 //-------------------------------------------------- |
|
833 |
|
834 EAP_FUNC_EXPORT eap_status_e eapol_am_core_symbian_c::get_eap_type_list( |
|
835 eap_array_c<eap_type_value_e> * const eap_type_list) |
|
836 { |
|
837 eap_type_value_e eap_type = eap_type_none; |
|
838 |
|
839 eap_type_list->reset(); |
|
840 |
|
841 eap_status_e status = eap_status_type_does_not_exists_error; |
|
842 |
|
843 #if defined(USE_TLS_EAP_TYPE) |
|
844 { |
|
845 eap_type = eap_type_tls; |
|
846 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
847 if (status != eap_status_ok) |
|
848 { |
|
849 return EAP_STATUS_RETURN(m_am_tools, status); |
|
850 } |
|
851 } |
|
852 #endif |
|
853 #if defined(USE_PEAP_EAP_TYPE) |
|
854 { |
|
855 eap_type = eap_type_peap; |
|
856 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
857 if (status != eap_status_ok) |
|
858 { |
|
859 return EAP_STATUS_RETURN(m_am_tools, status); |
|
860 } |
|
861 } |
|
862 #endif |
|
863 #if defined(USE_EAP_TYPE_GSMSIM) |
|
864 { |
|
865 eap_type = eap_type_gsmsim; |
|
866 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
867 if (status != eap_status_ok) |
|
868 { |
|
869 return EAP_STATUS_RETURN(m_am_tools, status); |
|
870 } |
|
871 } |
|
872 #endif |
|
873 #if defined(USE_SAESIM_EAP_TYPE) |
|
874 { |
|
875 eap_type = eap_type_saesim; |
|
876 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
877 if (status != eap_status_ok) |
|
878 { |
|
879 return EAP_STATUS_RETURN(m_am_tools, status); |
|
880 } |
|
881 } |
|
882 #endif |
|
883 #if defined(USE_MSCHAPV2_EAP_TYPE) |
|
884 { |
|
885 eap_type = eap_type_mschapv2; |
|
886 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
887 if (status != eap_status_ok) |
|
888 { |
|
889 return EAP_STATUS_RETURN(m_am_tools, status); |
|
890 } |
|
891 } |
|
892 #endif |
|
893 #if defined(USE_DUMMY_SIM_EAP_TYPE) |
|
894 { |
|
895 eap_type = eap_type_sim; |
|
896 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
897 if (status != eap_status_ok) |
|
898 { |
|
899 return EAP_STATUS_RETURN(m_am_tools, status); |
|
900 } |
|
901 } |
|
902 #endif |
|
903 |
|
904 if (eap_type == eap_type_none) |
|
905 { |
|
906 status = eap_type_list->add_data(&eap_type, sizeof(eap_type)); |
|
907 } |
|
908 |
|
909 return EAP_STATUS_RETURN(m_am_tools, status); |
|
910 } |
|
911 |
|
912 //-------------------------------------------------- |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 // End. |