1 /* |
|
2 * ============================================================================ |
|
3 * Name : ./accesssec/eapol/eapol_framework/wapi_common/src/wapi_wlan_authentication.cpp |
|
4 * Part of : WAPI / WAPI *** Info from the SWAD |
|
5 * Description : WAPI authentication |
|
6 * Version : %version: 18.1.1 % << Don't touch! Updated by Synergy at check-out. |
|
7 * |
|
8 * Copyright © 2001-2009 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * Template version: 4.1.1 |
|
18 */ |
|
19 |
|
20 // This is enumeration of WAPI source code. |
|
21 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
22 #undef EAP_FILE_NUMBER_ENUM |
|
23 #define EAP_FILE_NUMBER_ENUM 20001 |
|
24 #undef EAP_FILE_NUMBER_DATE |
|
25 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
26 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 |
|
31 #include "eap_am_memory.h" |
|
32 |
|
33 #include "eap_am_tools.h" |
|
34 #include "eap_variable_data.h" |
|
35 #include "eap_tools.h" |
|
36 #include "abs_eap_am_mutex.h" |
|
37 |
|
38 #include "wapi_wlan_authentication.h" |
|
39 #include "eapol_ethernet_header.h" |
|
40 #include "wapi_ethernet_core.h" |
|
41 #include "eap_crypto_api.h" |
|
42 #include "eap_header_string.h" |
|
43 #include "abs_eap_state_notification.h" |
|
44 #include "eapol_session_key.h" |
|
45 #include "eap_buffer.h" |
|
46 #include "eap_config.h" |
|
47 #include "eap_array_algorithms.h" |
|
48 #include "eap_state_notification.h" |
|
49 #include "eap_automatic_variable.h" |
|
50 |
|
51 |
|
52 |
|
53 // LOCAL CONSTANTS |
|
54 |
|
55 enum wapi_am_core_timer_id_e |
|
56 { |
|
57 WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID, |
|
58 WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID, |
|
59 WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID, |
|
60 WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID |
|
61 }; |
|
62 |
|
63 #if defined(USE_WAPI_WLAN_AUTHENTICATION_MUTEX) |
|
64 |
|
65 #define WAUTH_ENTER_MUTEX(tools) { tools->enter_global_mutex(); } |
|
66 |
|
67 #define WAUTH_LEAVE_MUTEX(tools) { tools->leave_global_mutex(); } |
|
68 |
|
69 #else |
|
70 |
|
71 #define WAUTH_ENTER_MUTEX(tools) |
|
72 |
|
73 #define WAUTH_LEAVE_MUTEX(tools) |
|
74 |
|
75 #endif //#if defined(USE_WAPI_WLAN_AUTHENTICATION_MUTEX) |
|
76 |
|
77 // ================= MEMBER FUNCTIONS ======================= |
|
78 |
|
79 EAP_FUNC_EXPORT wapi_wlan_authentication_c * wapi_wlan_authentication_c::new_wapi_wlan_authentication( |
|
80 abs_eap_am_tools_c * const tools, |
|
81 abs_wapi_wlan_authentication_c * const partner, |
|
82 const bool is_client_when_true, |
|
83 const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference |
|
84 ) |
|
85 { |
|
86 EAP_TRACE_DEBUG( |
|
87 tools, |
|
88 TRACE_FLAGS_DEFAULT, |
|
89 (EAPL("partner calls: wapi_wlan_authentication_c::new_wapi_wlan_authentication()\n"))); |
|
90 |
|
91 EAP_TRACE_RETURN_STRING(tools, "returns to partner: wapi_wlan_authentication_c::new_wapi_wlan_authentication()"); |
|
92 |
|
93 wapi_am_wlan_authentication_c * m_am_wauth = wapi_am_wlan_authentication_c::new_wapi_am_wlan_authentication( |
|
94 tools, |
|
95 is_client_when_true, |
|
96 wlan_database_reference); |
|
97 if (m_am_wauth == 0 |
|
98 || m_am_wauth->get_is_valid() == false) |
|
99 { |
|
100 // ERROR. |
|
101 if (m_am_wauth != 0) |
|
102 { |
|
103 EAP_TRACE_DEBUG( |
|
104 tools, |
|
105 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
106 (EAPL("calls: wapi_wlan_authentication_c::new_eapol_wlan_authentication(): m_am_wauth->shutdown(): %s.\n"), |
|
107 (is_client_when_true == true) ? "client": "server")); |
|
108 |
|
109 m_am_wauth->shutdown(); |
|
110 delete m_am_wauth; |
|
111 m_am_wauth = 0; |
|
112 } |
|
113 return 0; |
|
114 } |
|
115 |
|
116 wapi_wlan_authentication_c * wauth = new wapi_wlan_authentication_c(tools, partner, m_am_wauth, is_client_when_true); |
|
117 if (wauth == 0 |
|
118 || wauth->get_is_valid() == false) |
|
119 { |
|
120 // ERROR. |
|
121 if (wauth != 0) |
|
122 { |
|
123 wauth->shutdown(); |
|
124 delete wauth; |
|
125 } |
|
126 return 0; |
|
127 } |
|
128 |
|
129 EAP_TRACE_DEBUG( |
|
130 tools, |
|
131 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
132 (EAPL("calls: wapi_wlan_authentication_c::new_wapi_wlan_authentication(): m_am_wauth->set_am_partner(): %s.\n"), |
|
133 (is_client_when_true == true) ? "client": "server")); |
|
134 |
|
135 m_am_wauth->set_am_partner( |
|
136 wauth ); |
|
137 |
|
138 return wauth; |
|
139 } |
|
140 |
|
141 //-------------------------------------------------- |
|
142 |
|
143 EAP_FUNC_EXPORT wapi_wlan_authentication_c::wapi_wlan_authentication_c( |
|
144 abs_eap_am_tools_c * const tools, |
|
145 abs_wapi_wlan_authentication_c * const partner, |
|
146 wapi_am_wlan_authentication_c * const am_wauth, ///< wapi_wlan_authentication_c must always delete the am_wauth object. |
|
147 const bool is_client_when_true) |
|
148 : m_partner(partner) |
|
149 , m_am_wauth(am_wauth) |
|
150 , m_ethernet_core(0) |
|
151 , m_am_tools(tools) |
|
152 , m_preshared_key(tools) |
|
153 , m_authentication_type(eapol_key_authentication_type_none) |
|
154 , m_802_11_authentication_mode(eapol_key_802_11_authentication_mode_none) |
|
155 , m_received_WAPI_IE(tools) |
|
156 , m_sent_WAPI_IE(tools) |
|
157 , m_group_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none) |
|
158 , m_pairwise_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none) |
|
159 , m_authentication_counter(0u) |
|
160 , m_successful_authentications(0u) |
|
161 , m_failed_authentications(0u) |
|
162 , m_is_valid(false) |
|
163 , m_is_client(is_client_when_true) |
|
164 , m_shutdown_was_called(false) |
|
165 #if defined(USE_EAP_ERROR_TESTS) |
|
166 , m_error_probability(0u) |
|
167 , m_randomly_drop_packets_probability(0u) |
|
168 , m_generate_multiple_error_packets(0u) |
|
169 , m_enable_random_errors(false) |
|
170 , m_randomly_drop_packets(false) |
|
171 , m_manipulate_ethernet_header(false) |
|
172 , m_send_original_packet_first(false) |
|
173 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
174 { |
|
175 EAP_TRACE_DEBUG( |
|
176 m_am_tools, |
|
177 TRACE_FLAGS_DEFAULT, |
|
178 (EAPL("starts: wapi_wlan_authentication_c::wapi_wlan_authentication_c(): %s, this = 0x%08x => 0x%08x, compiled %s %s.\n"), |
|
179 (m_is_client == true) ? "client": "server", |
|
180 this, |
|
181 dynamic_cast<abs_eap_base_timer_c *>(this), |
|
182 __DATE__, |
|
183 __TIME__)); |
|
184 |
|
185 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: wapi_wlan_authentication_c::wapi_wlan_authentication_c()"); |
|
186 |
|
187 if (m_am_wauth == 0 |
|
188 || m_am_wauth->get_is_valid() == false) |
|
189 { |
|
190 // ERROR. |
|
191 if (m_am_wauth != 0) |
|
192 { |
|
193 EAP_TRACE_DEBUG( |
|
194 m_am_tools, |
|
195 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
196 (EAPL("calls: wapi_wlan_authentication_c::wapi_wlan_authentication_c(): m_am_wauth->shutdown(): %s.\n"), |
|
197 (is_client_when_true == true) ? "client": "server")); |
|
198 |
|
199 m_am_wauth->shutdown(); |
|
200 delete am_wauth; |
|
201 } |
|
202 return; |
|
203 } |
|
204 |
|
205 if (m_am_tools == 0 |
|
206 || m_am_tools->get_is_valid() == false) |
|
207 { |
|
208 // ERROR. |
|
209 if (m_am_wauth != 0) |
|
210 { |
|
211 EAP_TRACE_DEBUG( |
|
212 m_am_tools, |
|
213 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
214 (EAPL("calls: wapi_wlan_authentication_c::wapi_wlan_authentication_c(): m_am_wauth->shutdown(): %s.\n"), |
|
215 (is_client_when_true == true) ? "client": "server")); |
|
216 |
|
217 m_am_wauth->shutdown(); |
|
218 delete am_wauth; |
|
219 } |
|
220 return; |
|
221 } |
|
222 |
|
223 m_is_valid = true; |
|
224 } |
|
225 |
|
226 //-------------------------------------------------- |
|
227 |
|
228 EAP_FUNC_EXPORT wapi_wlan_authentication_c::~wapi_wlan_authentication_c() |
|
229 { |
|
230 EAP_TRACE_DEBUG( |
|
231 m_am_tools, |
|
232 TRACE_FLAGS_DEFAULT, |
|
233 (EAPL("partner calls: wapi_wlan_authentication_c::~wapi_wlan_authentication_c(): this = 0x%08x\n"), |
|
234 this)); |
|
235 |
|
236 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::~wapi_wlan_authentication_c()"); |
|
237 |
|
238 EAP_ASSERT(m_shutdown_was_called == true); |
|
239 } |
|
240 |
|
241 //-------------------------------------------------- |
|
242 |
|
243 // |
|
244 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::shutdown() |
|
245 { |
|
246 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
247 |
|
248 EAP_TRACE_DEBUG( |
|
249 m_am_tools, |
|
250 TRACE_FLAGS_DEFAULT, |
|
251 (EAPL("partner calls: wapi_wlan_authentication_c::shutdown(); %s, m_shutdown_was_called=%d\n"), |
|
252 (m_is_client == true) ? "client": "server", |
|
253 m_shutdown_was_called)); |
|
254 |
|
255 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::shutdown()"); |
|
256 |
|
257 if (m_shutdown_was_called == true) |
|
258 { |
|
259 // Shutdown was already called once. |
|
260 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
261 } |
|
262 m_shutdown_was_called = true; |
|
263 |
|
264 // Cancel timer |
|
265 cancel_all_timers(); |
|
266 |
|
267 // Delete upper stack if it still exists |
|
268 if (m_ethernet_core != 0) |
|
269 { |
|
270 WAUTH_ENTER_MUTEX(m_am_tools); |
|
271 |
|
272 EAP_TRACE_DEBUG( |
|
273 m_am_tools, |
|
274 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
275 (EAPL("calls eapol: wapi_wlan_authentication_c::shutdown(): m_ethernet_core->shutdown(): %s.\n"), |
|
276 (m_is_client == true) ? "client": "server")); |
|
277 |
|
278 eap_status_e status = m_ethernet_core->shutdown(); |
|
279 EAP_UNREFERENCED_PARAMETER(status); |
|
280 |
|
281 EAP_TRACE_DEBUG( |
|
282 m_am_tools, |
|
283 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
284 (EAPL("returns from eapol: wapi_wlan_authentication_c::shutdown(): m_ethernet_core->shutdown(): %s, status = %s.\n"), |
|
285 (m_is_client == true) ? "client": "server", |
|
286 eap_status_string_c::get_status_string(status))); |
|
287 |
|
288 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
289 |
|
290 delete m_ethernet_core; |
|
291 m_ethernet_core = 0; |
|
292 } |
|
293 |
|
294 // Print some statistics |
|
295 if (m_is_client) |
|
296 { |
|
297 EAP_TRACE_ALWAYS( |
|
298 m_am_tools, |
|
299 TRACE_FLAGS_ALWAYS|TRACE_TEST_VECTORS, |
|
300 (EAPL("wapi_wlan_authentication_c::shutdown(): client authentication SUCCESS %d, FAILED %d, count %d\n"), |
|
301 m_successful_authentications, |
|
302 m_failed_authentications, |
|
303 m_authentication_counter)); |
|
304 } |
|
305 else |
|
306 { |
|
307 EAP_TRACE_ALWAYS( |
|
308 m_am_tools, |
|
309 TRACE_FLAGS_ALWAYS|TRACE_TEST_VECTORS, |
|
310 (EAPL("wapi_wlan_authentication_c::shutdown(): server authentication SUCCESS %d, FAILED %d, count %d\n"), |
|
311 m_successful_authentications, |
|
312 m_failed_authentications, |
|
313 m_authentication_counter)); |
|
314 } |
|
315 |
|
316 |
|
317 if (m_am_wauth != 0) |
|
318 { |
|
319 EAP_TRACE_DEBUG( |
|
320 m_am_tools, |
|
321 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
322 (EAPL("calls: wapi_wlan_authentication_c::shutdown(): m_am_wauth->shutdown(): %s.\n"), |
|
323 (m_is_client == true) ? "client": "server")); |
|
324 |
|
325 m_am_wauth->shutdown(); |
|
326 delete m_am_wauth; |
|
327 m_am_wauth = 0; |
|
328 } |
|
329 |
|
330 EAP_TRACE_DEBUG( |
|
331 m_am_tools, |
|
332 TRACE_FLAGS_DEFAULT, |
|
333 (EAPL("WAUTH EXITING.\n"))); |
|
334 |
|
335 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
336 return eap_status_ok; |
|
337 } |
|
338 |
|
339 //-------------------------------------------------- |
|
340 |
|
341 // |
|
342 eap_status_e wapi_wlan_authentication_c::cancel_all_authentication_sessions() |
|
343 { |
|
344 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
345 |
|
346 EAP_TRACE_DEBUG( |
|
347 m_am_tools, |
|
348 TRACE_FLAGS_DEFAULT, |
|
349 (EAPL("wapi_wlan_authentication_c::cancel_all_authentication_sessions(): %s\n"), |
|
350 (m_is_client == true) ? "client": "server")); |
|
351 |
|
352 eap_status_e status(eap_status_process_general_error); |
|
353 |
|
354 if (m_ethernet_core != 0) |
|
355 { |
|
356 WAUTH_ENTER_MUTEX(m_am_tools); |
|
357 EAP_TRACE_DEBUG( |
|
358 m_am_tools, |
|
359 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
360 (EAPL("calls eapol: wapi_wlan_authentication_c::cancel_all_authentication_sessions(): m_ethernet_core->cancel_all_authentication_sessions(): %s.\n"), |
|
361 (m_is_client == true) ? "client": "server")); |
|
362 status = m_ethernet_core->cancel_all_authentication_sessions(); |
|
363 EAP_TRACE_DEBUG( |
|
364 m_am_tools, |
|
365 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
366 (EAPL("returns from eapol: wapi_wlan_authentication_c::cancel_all_authentication_sessions(): m_ethernet_core->cancel_all_authentication_sessions(): %s, status = %s.\n"), |
|
367 (m_is_client == true) ? "client": "server", |
|
368 eap_status_string_c::get_status_string(status))); |
|
369 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
370 } |
|
371 else |
|
372 { |
|
373 EAP_TRACE_DEBUG( |
|
374 m_am_tools, |
|
375 TRACE_FLAGS_DEFAULT, |
|
376 (EAPL("wapi_wlan_authentication_c::cancel_all_authentication_sessions(): Stack did not exists.\n"))); |
|
377 status = eap_status_process_general_error; |
|
378 } |
|
379 |
|
380 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
381 return EAP_STATUS_RETURN(m_am_tools, status); |
|
382 } |
|
383 |
|
384 //-------------------------------------------------- |
|
385 |
|
386 // |
|
387 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::start_authentication( |
|
388 const eap_variable_data_c * const SSID, |
|
389 const eapol_key_authentication_type_e selected_eapol_key_authentication_type, |
|
390 const eap_variable_data_c * const preshared_key, |
|
391 const bool WAPI_override_enabled, |
|
392 const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address. |
|
393 ) |
|
394 { |
|
395 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
396 |
|
397 EAP_TRACE_DEBUG( |
|
398 m_am_tools, |
|
399 TRACE_FLAGS_DEFAULT, |
|
400 (EAPL("partner calls: wapi_wlan_authentication_c::start_authentication(): %s\n"), |
|
401 (m_is_client == true) ? "client": "server")); |
|
402 |
|
403 EAP_TRACE_DEBUG( |
|
404 m_am_tools, |
|
405 TRACE_FLAGS_DEFAULT, |
|
406 (EAPL("Starting authentication, selected_eapol_key_authentication_type = %d.\n"), |
|
407 selected_eapol_key_authentication_type)); |
|
408 |
|
409 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::start_authentication()"); |
|
410 |
|
411 eap_status_e status(eap_status_ok); |
|
412 |
|
413 status = cancel_all_authentication_sessions(); |
|
414 if (status != eap_status_ok) |
|
415 { |
|
416 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
417 } |
|
418 |
|
419 m_authentication_type = selected_eapol_key_authentication_type; |
|
420 |
|
421 EAP_TRACE_DEBUG( |
|
422 m_am_tools, |
|
423 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
424 (EAPL("calls: wapi_wlan_authentication_c::start_authentication(): m_am_wauth->set_wlan_parameters(): %s.\n"), |
|
425 (m_is_client == true) ? "client": "server")); |
|
426 |
|
427 status = m_am_wauth->set_wlan_parameters( |
|
428 SSID, |
|
429 WAPI_override_enabled, |
|
430 preshared_key, |
|
431 m_authentication_type); |
|
432 if (status != eap_status_ok) |
|
433 { |
|
434 (void) disassociation(0); // Note we have no addresses yet. |
|
435 |
|
436 (void) wapi_indication( |
|
437 0, // Note we have no addresses yet. |
|
438 eapol_wlan_authentication_state_failed_completely); |
|
439 |
|
440 return EAP_STATUS_RETURN(m_am_tools, status); |
|
441 } |
|
442 |
|
443 EAP_TRACE_DEBUG( |
|
444 m_am_tools, |
|
445 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
446 (EAPL("calls: wapi_wlan_authentication_c::start_authentication(): m_am_wauth->reset_wapi_configuration(): %s.\n"), |
|
447 (m_is_client == true) ? "client": "server")); |
|
448 |
|
449 status = m_am_wauth->reset_wapi_configuration(); |
|
450 if (status != eap_status_ok) |
|
451 { |
|
452 (void) disassociation(0); // Note we have no addresses yet. |
|
453 |
|
454 (void) wapi_indication( |
|
455 0, // Note we have no addresses yet. |
|
456 eapol_wlan_authentication_state_failed_completely); |
|
457 |
|
458 return EAP_STATUS_RETURN(m_am_tools, status); |
|
459 } |
|
460 |
|
461 EAP_TRACE_DEBUG( |
|
462 m_am_tools, |
|
463 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
464 (EAPL("calls: wapi_wlan_authentication_c::start_authentication(): m_am_wauth->get_wlan_configuration(): %s.\n"), |
|
465 (m_is_client == true) ? "client": "server")); |
|
466 |
|
467 |
|
468 status = m_am_wauth->get_wlan_configuration( |
|
469 &m_preshared_key); |
|
470 if (status != eap_status_ok) |
|
471 { |
|
472 return EAP_STATUS_RETURN(m_am_tools, status); |
|
473 } |
|
474 |
|
475 // Start new authentication from scratch. |
|
476 // WAPI uses always open 802.11 mode. |
|
477 m_802_11_authentication_mode = eapol_key_802_11_authentication_mode_open; |
|
478 |
|
479 // USE_WAPI_CORE needs to be defined in the common code the |
|
480 // get this if compiled |
|
481 if( m_authentication_type == eapol_key_authentication_type_WAI_PSK ) |
|
482 { |
|
483 EAP_TRACE_ALWAYS( |
|
484 m_am_tools, |
|
485 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
486 (EAPL("start_authentication(): Trying auth mode OPEN and WAI-PSK.\n"))); |
|
487 } |
|
488 else |
|
489 { |
|
490 EAP_TRACE_ALWAYS( |
|
491 m_am_tools, |
|
492 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
493 (EAPL("start_authentication(): Trying auth mode OPEN and WAI certificates.\n"))); |
|
494 } |
|
495 |
|
496 WAUTH_ENTER_MUTEX(m_am_tools); |
|
497 EAP_TRACE_DEBUG( |
|
498 m_am_tools, |
|
499 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
500 (EAPL("calls eapol: wapi_wlan_authentication_c::start_authentication(): m_ethernet_core->create_state(): %s.\n"), |
|
501 (m_is_client == true) ? "client": "server")); |
|
502 status = m_ethernet_core->create_state( |
|
503 receive_network_id, |
|
504 m_authentication_type |
|
505 ); |
|
506 EAP_TRACE_DEBUG( |
|
507 m_am_tools, |
|
508 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
509 (EAPL("returns from eapol: wapi_wlan_authentication_c::start_authentication(): m_ethernet_core->create_state(): %s, status = %s.\n"), |
|
510 (m_is_client == true) ? "client": "server", |
|
511 eap_status_string_c::get_status_string(status))); |
|
512 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
513 |
|
514 |
|
515 EAP_TRACE_DEBUG( |
|
516 m_am_tools, |
|
517 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
518 (EAPL("calls partner: wapi_wlan_authentication_c::start_authentication(): m_partner->associate(%d).\n"), |
|
519 m_802_11_authentication_mode)); |
|
520 |
|
521 status = m_partner->associate(m_802_11_authentication_mode); |
|
522 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
523 |
|
524 EAP_TRACE_DEBUG( |
|
525 m_am_tools, |
|
526 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
527 (EAPL("returns from partner: wapi_wlan_authentication_c::start_authentication(): %s: m_partner->associate(): status = %s\n"), |
|
528 (m_is_client == true) ? "client": "server", |
|
529 eap_status_string_c::get_status_string(status))); |
|
530 |
|
531 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
532 return EAP_STATUS_RETURN(m_am_tools, status); |
|
533 } |
|
534 |
|
535 //-------------------------------------------------- |
|
536 |
|
537 // |
|
538 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::complete_association( |
|
539 const eapol_wlan_authentication_state_e association_result, |
|
540 const eap_am_network_id_c * const receive_network_id, ///< source includes remote address, destination includes local address. |
|
541 const eap_variable_data_c * const received_WAPI_IE, |
|
542 const eap_variable_data_c * const sent_WAPI_IE, |
|
543 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite, |
|
544 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite |
|
545 ) |
|
546 { |
|
547 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
548 |
|
549 EAP_TRACE_DEBUG( |
|
550 m_am_tools, |
|
551 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
552 (EAPL("partner calls: wapi_wlan_authentication_c::complete_association(): %s: association_result=%d\n"), |
|
553 (m_is_client == true) ? "client": "server", |
|
554 association_result)); |
|
555 |
|
556 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::complete_association()"); |
|
557 |
|
558 eap_status_e status(eap_status_ok); |
|
559 |
|
560 // ASSOCIATION UNSUCCESSFUL |
|
561 if (association_result != eapol_wlan_authentication_state_association_ok) |
|
562 { |
|
563 EAP_TRACE_DEBUG( |
|
564 m_am_tools, |
|
565 TRACE_FLAGS_DEFAULT, |
|
566 (EAPL("complete_association: Unsuccessful.\n"))); |
|
567 |
|
568 EAP_TRACE_DATA_DEBUG( |
|
569 m_am_tools, |
|
570 TRACE_FLAGS_DEFAULT, |
|
571 (EAPL("Got AP MAC address"), |
|
572 receive_network_id->get_source(), |
|
573 receive_network_id->get_source_length())); |
|
574 |
|
575 EAP_TRACE_ALWAYS( |
|
576 m_am_tools, |
|
577 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
578 (EAPL("Could not associate to the AP.\n"))); |
|
579 |
|
580 EAP_TRACE_ALWAYS( |
|
581 m_am_tools, |
|
582 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
583 (EAPL("Indication sent to WLM: eap_status_this_ap_failed.\n"))); |
|
584 |
|
585 (void) disassociation(receive_network_id); |
|
586 |
|
587 status = wapi_indication( |
|
588 receive_network_id, |
|
589 eapol_wlan_authentication_state_this_ap_failed); |
|
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 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
597 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
598 |
|
599 } |
|
600 |
|
601 // ASSOCIATION SUCCESSFUL |
|
602 EAP_TRACE_ALWAYS( |
|
603 m_am_tools, |
|
604 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
605 (EAPL("complete_association: Successful.\n"))); |
|
606 |
|
607 // Store parameters |
|
608 |
|
609 if (m_authentication_type == eapol_key_authentication_type_WAI_certificate |
|
610 || m_authentication_type == eapol_key_authentication_type_WAI_PSK) |
|
611 { |
|
612 status = m_received_WAPI_IE.set_copy_of_buffer(received_WAPI_IE); |
|
613 if (status != eap_status_ok) |
|
614 { |
|
615 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
616 return EAP_STATUS_RETURN(m_am_tools, status); |
|
617 } |
|
618 |
|
619 status = m_sent_WAPI_IE.set_copy_of_buffer(sent_WAPI_IE); |
|
620 if (status != eap_status_ok) |
|
621 { |
|
622 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
623 return EAP_STATUS_RETURN(m_am_tools, status); |
|
624 } |
|
625 } |
|
626 |
|
627 m_group_key_cipher_suite = group_key_cipher_suite; |
|
628 |
|
629 m_pairwise_key_cipher_suite = pairwise_key_cipher_suite; |
|
630 |
|
631 eap_variable_data_c * preshared_key = 0; |
|
632 |
|
633 if (m_authentication_type == eapol_key_authentication_type_WAI_PSK) |
|
634 { |
|
635 preshared_key = &m_preshared_key; |
|
636 } |
|
637 |
|
638 EAP_TRACE_DEBUG( |
|
639 m_am_tools, |
|
640 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
641 (EAPL("calls: wapi_wlan_authentication_c::complete_association(): m_am_wauth->association(): %s.\n"), |
|
642 (m_is_client == true) ? "client": "server")); |
|
643 |
|
644 status = m_am_wauth->association(receive_network_id); |
|
645 if (status != eap_status_ok) |
|
646 { |
|
647 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
648 return EAP_STATUS_RETURN(m_am_tools, status); |
|
649 } |
|
650 |
|
651 WAUTH_ENTER_MUTEX(m_am_tools); |
|
652 EAP_TRACE_DEBUG( |
|
653 m_am_tools, |
|
654 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
655 (EAPL("calls eapol: wapi_wlan_authentication_c::complete_association(): m_ethernet_core->association(): %s.\n"), |
|
656 (m_is_client == true) ? "client": "server")); |
|
657 status = m_ethernet_core->association( |
|
658 receive_network_id, |
|
659 m_authentication_type, |
|
660 &m_received_WAPI_IE, |
|
661 &m_sent_WAPI_IE, |
|
662 pairwise_key_cipher_suite, |
|
663 group_key_cipher_suite, |
|
664 preshared_key); |
|
665 EAP_TRACE_DEBUG( |
|
666 m_am_tools, |
|
667 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
668 (EAPL("returns from eapol: wapi_wlan_authentication_c::complete_association(): m_ethernet_core->association(): %s, status = %s.\n"), |
|
669 (m_is_client == true) ? "client": "server", |
|
670 eap_status_string_c::get_status_string(status))); |
|
671 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
672 |
|
673 if (status != eap_status_ok) |
|
674 { |
|
675 |
|
676 EAP_TRACE_ALWAYS( |
|
677 m_am_tools, |
|
678 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
679 (EAPL("m_ethernet_core->association call failed.\n"))); |
|
680 |
|
681 EAP_TRACE_ALWAYS( |
|
682 m_am_tools, |
|
683 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
684 (EAPL("Indication sent to WLM: eap_status_failed_completely.\n"))); |
|
685 |
|
686 EAP_TRACE_DEBUG( |
|
687 m_am_tools, |
|
688 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
689 (EAPL("calls: wapi_wlan_authentication_c::complete_association(): this->disassociation(): %s.\n"), |
|
690 (m_is_client == true) ? "client": "server")); |
|
691 |
|
692 (void) disassociation(receive_network_id); |
|
693 |
|
694 status = wapi_indication( |
|
695 receive_network_id, |
|
696 eapol_wlan_authentication_state_failed_completely); |
|
697 if (status != eap_status_ok) |
|
698 { |
|
699 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
700 return EAP_STATUS_RETURN(m_am_tools, status); |
|
701 } |
|
702 |
|
703 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
704 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
705 } |
|
706 |
|
707 // Start waiting for authentication messages |
|
708 |
|
709 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
710 return EAP_STATUS_RETURN(m_am_tools, status); |
|
711 } |
|
712 |
|
713 //-------------------------------------------------- |
|
714 |
|
715 // |
|
716 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::check_bksa_cache( |
|
717 eap_array_c<eap_am_network_id_c> * const bssid_sta_receive_network_ids, |
|
718 const eapol_key_authentication_type_e selected_eapol_key_authentication_type, |
|
719 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite, |
|
720 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite |
|
721 ) |
|
722 { |
|
723 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
724 |
|
725 EAP_TRACE_DEBUG( |
|
726 m_am_tools, |
|
727 TRACE_FLAGS_DEFAULT, |
|
728 (EAPL("partner calls: wapi_wlan_authentication_c::check_bksa_cache(): %s\n"), |
|
729 (m_is_client == true) ? "client": "server")); |
|
730 |
|
731 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::check_bksa_cache()"); |
|
732 |
|
733 WAUTH_ENTER_MUTEX(m_am_tools); |
|
734 EAP_TRACE_DEBUG( |
|
735 m_am_tools, |
|
736 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
737 (EAPL("calls eapol: wapi_wlan_authentication_c::check_bksa_cache(): m_ethernet_core->check_bksa_cache(): %s.\n"), |
|
738 (m_is_client == true) ? "client": "server")); |
|
739 eap_status_e status = m_ethernet_core->check_bksa_cache( |
|
740 bssid_sta_receive_network_ids, |
|
741 selected_eapol_key_authentication_type, |
|
742 pairwise_key_cipher_suite, |
|
743 group_key_cipher_suite); |
|
744 EAP_TRACE_DEBUG( |
|
745 m_am_tools, |
|
746 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
747 (EAPL("returns from eapol: wapi_wlan_authentication_c::check_bksa_cache(): m_ethernet_core->check_bksa_cache(): %s, status = %s.\n"), |
|
748 (m_is_client == true) ? "client": "server", |
|
749 eap_status_string_c::get_status_string(status))); |
|
750 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
751 |
|
752 if (bssid_sta_receive_network_ids->get_object_count() == 0) |
|
753 { |
|
754 EAP_TRACE_DEBUG( |
|
755 m_am_tools, |
|
756 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
757 (EAPL("WARNING: wapi_wlan_authentication_c::check_bksa_cache(): %s: No BKSA:s found in cache.\n"), |
|
758 (m_is_client == true) ? "client": "server")); |
|
759 } |
|
760 |
|
761 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
762 return EAP_STATUS_RETURN(m_am_tools, status); |
|
763 } |
|
764 |
|
765 //-------------------------------------------------- |
|
766 |
|
767 // |
|
768 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::start_reassociation( |
|
769 const eap_am_network_id_c * const old_receive_network_id, ///< source includes remote address, destination includes local address. |
|
770 const eap_am_network_id_c * const new_receive_network_id, ///< source includes remote address, destination includes local address. |
|
771 const eapol_key_authentication_type_e selected_eapol_key_authentication_type |
|
772 ) |
|
773 { |
|
774 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
775 |
|
776 EAP_TRACE_DEBUG( |
|
777 m_am_tools, |
|
778 TRACE_FLAGS_DEFAULT, |
|
779 (EAPL("partner calls: wapi_wlan_authentication_c::start_reassociation(): %s\n"), |
|
780 (m_is_client == true) ? "client": "server")); |
|
781 |
|
782 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::start_reassociation()"); |
|
783 |
|
784 { |
|
785 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
786 TRACE_FLAGS_DEFAULT, |
|
787 (EAPL("old_receive_network_id source:"), |
|
788 old_receive_network_id->get_source_id()->get_data(), |
|
789 old_receive_network_id->get_source_id()->get_data_length())); |
|
790 |
|
791 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
792 TRACE_FLAGS_DEFAULT, |
|
793 (EAPL("old_receive_network_id destination:"), |
|
794 old_receive_network_id->get_destination_id()->get_data(), |
|
795 old_receive_network_id->get_destination_id()->get_data_length())); |
|
796 |
|
797 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
798 TRACE_FLAGS_DEFAULT, |
|
799 (EAPL("new_receive_network_id source:"), |
|
800 new_receive_network_id->get_source_id()->get_data(), |
|
801 new_receive_network_id->get_source_id()->get_data_length())); |
|
802 |
|
803 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
804 TRACE_FLAGS_DEFAULT, |
|
805 (EAPL("new_receive_network_id destination:"), |
|
806 new_receive_network_id->get_destination_id()->get_data(), |
|
807 new_receive_network_id->get_destination_id()->get_data_length())); |
|
808 } |
|
809 |
|
810 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
811 |
|
812 eap_status_e status = cancel_all_authentication_sessions(); |
|
813 if (status != eap_status_ok) |
|
814 { |
|
815 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
816 } |
|
817 |
|
818 EAP_TRACE_DEBUG( |
|
819 m_am_tools, |
|
820 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
821 (EAPL("calls: wapi_wlan_authentication_c::start_reassociation(): m_am_wauth->reset_wapi_configuration(): %s.\n"), |
|
822 (m_is_client == true) ? "client": "server")); |
|
823 |
|
824 status = m_am_wauth->reset_wapi_configuration(); |
|
825 if (status != eap_status_ok) |
|
826 { |
|
827 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
828 return EAP_STATUS_RETURN(m_am_tools, status); |
|
829 } |
|
830 |
|
831 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
832 |
|
833 eap_variable_data_c reassociation_BKID(m_am_tools); |
|
834 |
|
835 WAUTH_ENTER_MUTEX(m_am_tools); |
|
836 EAP_TRACE_DEBUG( |
|
837 m_am_tools, |
|
838 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
839 (EAPL("calls eapol: wapi_wlan_authentication_c::start_reassociation(): m_ethernet_core->read_reassociation_parameters(): %s.\n"), |
|
840 (m_is_client == true) ? "client": "server")); |
|
841 |
|
842 status = m_ethernet_core->read_reassociation_parameters( |
|
843 old_receive_network_id, |
|
844 new_receive_network_id, |
|
845 selected_eapol_key_authentication_type, |
|
846 &reassociation_BKID, |
|
847 0, |
|
848 0); |
|
849 |
|
850 EAP_TRACE_DEBUG( |
|
851 m_am_tools, |
|
852 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
853 (EAPL("returns from eapol: wapi_wlan_authentication_c::start_reassociation(): m_ethernet_core->read_reassociation_parameters(): %s, status = %s.\n"), |
|
854 (m_is_client == true) ? "client": "server", |
|
855 eap_status_string_c::get_status_string(status))); |
|
856 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
857 |
|
858 if (status == eap_status_ok) |
|
859 { |
|
860 // Here we swap the addresses. |
|
861 eap_am_network_id_c send_network_id( |
|
862 m_am_tools, |
|
863 new_receive_network_id->get_destination_id(), |
|
864 new_receive_network_id->get_source_id(), |
|
865 new_receive_network_id->get_type()); |
|
866 if (send_network_id.get_is_valid_data() == false) |
|
867 { |
|
868 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
869 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
870 } |
|
871 |
|
872 m_authentication_type = selected_eapol_key_authentication_type; |
|
873 |
|
874 EAP_TRACE_DEBUG( |
|
875 m_am_tools, |
|
876 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
877 (EAPL("calls partner: wapi_wlan_authentication_c::start_reassociation(): %s: m_partner->reassociate(): m_authentication_type=%d.\n"), |
|
878 (m_is_client == true) ? "client": "server", |
|
879 m_authentication_type)); |
|
880 |
|
881 status = m_partner->reassociate( |
|
882 &send_network_id, |
|
883 m_authentication_type, |
|
884 &reassociation_BKID); |
|
885 |
|
886 EAP_TRACE_DEBUG( |
|
887 m_am_tools, |
|
888 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
889 (EAPL("returns from partner: wapi_wlan_authentication_c::start_reassociation(): %s: m_partner->reassociate(): status = %s\n"), |
|
890 (m_is_client == true) ? "client": "server", |
|
891 eap_status_string_c::get_status_string(status))); |
|
892 } |
|
893 |
|
894 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
895 return EAP_STATUS_RETURN(m_am_tools, status); |
|
896 } |
|
897 |
|
898 //-------------------------------------------------- |
|
899 |
|
900 // |
|
901 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::complete_reassociation( |
|
902 const eapol_wlan_authentication_state_e reassociation_result, |
|
903 const eap_am_network_id_c * const receive_network_id, |
|
904 const eap_variable_data_c * const received_WAPI_IE, |
|
905 const eap_variable_data_c * const sent_WAPI_IE, |
|
906 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite, |
|
907 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite |
|
908 ) |
|
909 { |
|
910 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
911 |
|
912 EAP_TRACE_DEBUG( |
|
913 m_am_tools, |
|
914 TRACE_FLAGS_DEFAULT, |
|
915 (EAPL("partner calls: wapi_wlan_authentication_c::complete_reassociation(): %s, reassociation_result=%d\n"), |
|
916 (m_is_client == true) ? "client": "server", |
|
917 reassociation_result)); |
|
918 |
|
919 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::complete_reassociation()"); |
|
920 |
|
921 eap_status_e status(eap_status_process_general_error); |
|
922 |
|
923 if (reassociation_result != eapol_wlan_authentication_state_association_ok) |
|
924 { |
|
925 EAP_TRACE_DEBUG( |
|
926 m_am_tools, |
|
927 TRACE_FLAGS_DEFAULT, |
|
928 (EAPL("complete_reassociation: Unsuccessful.\n"))); |
|
929 |
|
930 WAUTH_ENTER_MUTEX(m_am_tools); |
|
931 EAP_TRACE_DEBUG( |
|
932 m_am_tools, |
|
933 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
934 (EAPL("calls eapol: wapi_wlan_authentication_c::complete_reassociation(): m_ethernet_core->remove_bksa_from_cache(): %s.\n"), |
|
935 (m_is_client == true) ? "client": "server")); |
|
936 status = m_ethernet_core->remove_bksa_from_cache( |
|
937 receive_network_id); |
|
938 EAP_TRACE_DEBUG( |
|
939 m_am_tools, |
|
940 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
941 (EAPL("returns from eapol: wapi_wlan_authentication_c::complete_reassociation(): m_ethernet_core->remove_bksa_from_cache(): %s, status = %s.\n"), |
|
942 (m_is_client == true) ? "client": "server", |
|
943 eap_status_string_c::get_status_string(status))); |
|
944 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
945 |
|
946 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
947 return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure); |
|
948 } |
|
949 else |
|
950 { |
|
951 EAP_TRACE_DEBUG( |
|
952 m_am_tools, |
|
953 TRACE_FLAGS_DEFAULT, |
|
954 (EAPL("complete_reassociation: Successful.\n"))); |
|
955 |
|
956 WAUTH_ENTER_MUTEX(m_am_tools); |
|
957 EAP_TRACE_DEBUG( |
|
958 m_am_tools, |
|
959 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
960 (EAPL("calls eapol: wapi_wlan_authentication_c::complete_reassociation(): m_ethernet_core->complete_reassociation(): %s.\n"), |
|
961 (m_is_client == true) ? "client": "server")); |
|
962 status = m_ethernet_core->complete_reassociation( |
|
963 reassociation_result, |
|
964 receive_network_id, |
|
965 m_authentication_type, |
|
966 received_WAPI_IE, |
|
967 sent_WAPI_IE, |
|
968 pairwise_key_cipher_suite, |
|
969 group_key_cipher_suite); |
|
970 EAP_TRACE_DEBUG( |
|
971 m_am_tools, |
|
972 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
973 (EAPL("returns from eapol: wapi_wlan_authentication_c::complete_reassociation(): m_ethernet_core->complete_reassociation(): %s, status = %s.\n"), |
|
974 (m_is_client == true) ? "client": "server", |
|
975 eap_status_string_c::get_status_string(status))); |
|
976 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
977 |
|
978 if (status != eap_status_ok) |
|
979 { |
|
980 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
981 return EAP_STATUS_RETURN(m_am_tools, status); |
|
982 } |
|
983 } |
|
984 |
|
985 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
986 return EAP_STATUS_RETURN(m_am_tools, status); |
|
987 } |
|
988 |
|
989 //-------------------------------------------------- |
|
990 |
|
991 // |
|
992 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::packet_process( |
|
993 const eap_am_network_id_c * const receive_network_id, ///< source includes remote address, destination includes local address. |
|
994 eap_general_header_base_c * const packet_data, |
|
995 const u32_t packet_length) |
|
996 { |
|
997 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
998 |
|
999 EAP_TRACE_DEBUG( |
|
1000 m_am_tools, |
|
1001 TRACE_FLAGS_DEFAULT, |
|
1002 (EAPL("partner calls: wapi_wlan_authentication_c::packet_process(): %s\n"), |
|
1003 (m_is_client == true) ? "client": "server")); |
|
1004 |
|
1005 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::packet_process()"); |
|
1006 |
|
1007 if (packet_length < eapol_ethernet_header_wr_c::get_header_length()) |
|
1008 { |
|
1009 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1010 return EAP_STATUS_RETURN(m_am_tools, eap_status_too_short_message); |
|
1011 } |
|
1012 |
|
1013 eapol_ethernet_header_wr_c eth_header( |
|
1014 m_am_tools, |
|
1015 packet_data->get_header_buffer(packet_length), |
|
1016 packet_length); |
|
1017 |
|
1018 eap_status_e status(eap_status_process_general_error); |
|
1019 |
|
1020 if (eth_header.get_type() == eapol_ethernet_type_wapi) |
|
1021 { |
|
1022 // Forward the packet to the Ethernet layer of the WAPI stack. |
|
1023 // Ignore return value. Failure is signalled using state_notification. |
|
1024 WAUTH_ENTER_MUTEX(m_am_tools); |
|
1025 EAP_TRACE_DEBUG( |
|
1026 m_am_tools, |
|
1027 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1028 (EAPL("calls eapol: wapi_wlan_authentication_c::packet_process(): m_ethernet_core->packet_process(): %s.\n"), |
|
1029 (m_is_client == true) ? "client": "server")); |
|
1030 status = m_ethernet_core->packet_process( |
|
1031 receive_network_id, |
|
1032 ð_header, |
|
1033 packet_length); |
|
1034 EAP_TRACE_DEBUG( |
|
1035 m_am_tools, |
|
1036 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1037 (EAPL("returns from eapol: wapi_wlan_authentication_c::packet_process(): m_ethernet_core->packet_process(): %s, status = %s.\n"), |
|
1038 (m_is_client == true) ? "client": "server", |
|
1039 eap_status_string_c::get_status_string(status))); |
|
1040 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
1041 |
|
1042 EAP_GENERAL_HEADER_COPY_ERROR_PARAMETERS(packet_data, ð_header); |
|
1043 } |
|
1044 else |
|
1045 { |
|
1046 EAP_TRACE_DEBUG( |
|
1047 m_am_tools, |
|
1048 TRACE_FLAGS_DEFAULT, |
|
1049 (EAPL("WAPI: Not supported ethernet type 0x%04x\n"), eth_header.get_type())); |
|
1050 status = eap_status_ethernet_type_not_supported; |
|
1051 } |
|
1052 |
|
1053 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1054 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1055 } |
|
1056 |
|
1057 //-------------------------------------------------- |
|
1058 |
|
1059 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::set_is_valid() |
|
1060 { |
|
1061 m_is_valid = true; |
|
1062 } |
|
1063 |
|
1064 //-------------------------------------------------- |
|
1065 |
|
1066 EAP_FUNC_EXPORT bool wapi_wlan_authentication_c::get_is_valid() |
|
1067 { |
|
1068 return m_is_valid; |
|
1069 } |
|
1070 |
|
1071 //-------------------------------------------------- |
|
1072 |
|
1073 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::increment_authentication_counter() |
|
1074 { |
|
1075 ++m_authentication_counter; |
|
1076 } |
|
1077 |
|
1078 //-------------------------------------------------- |
|
1079 |
|
1080 EAP_FUNC_EXPORT u32_t wapi_wlan_authentication_c::get_authentication_counter() |
|
1081 { |
|
1082 return m_authentication_counter; |
|
1083 } |
|
1084 |
|
1085 //-------------------------------------------------- |
|
1086 |
|
1087 EAP_FUNC_EXPORT bool wapi_wlan_authentication_c::get_is_client() |
|
1088 { |
|
1089 return m_is_client; |
|
1090 } |
|
1091 |
|
1092 //-------------------------------------------------- |
|
1093 |
|
1094 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::packet_data_session_key( |
|
1095 const eap_am_network_id_c * const send_network_id, |
|
1096 const eapol_session_key_c * const key) |
|
1097 { |
|
1098 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1099 eap_status_e status(eap_status_ok); |
|
1100 |
|
1101 EAP_TRACE_DEBUG( |
|
1102 m_am_tools, |
|
1103 TRACE_FLAGS_DEFAULT, |
|
1104 (EAPL("eapol calls: wapi_wlan_authentication_c::packet_data_session_key(): %s\n"), |
|
1105 (m_is_client == true) ? "client": "server")); |
|
1106 |
|
1107 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::packet_data_session_key()"); |
|
1108 |
|
1109 const eap_variable_data_c * const key_data = key->get_key(); |
|
1110 if (key_data == 0) |
|
1111 { |
|
1112 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1113 return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error); |
|
1114 } |
|
1115 |
|
1116 EAP_TRACE_DEBUG(m_am_tools, |
|
1117 TRACE_FLAGS_DEFAULT, |
|
1118 (EAPL("wapi_wlan_authentication_c::packet_data_session_key(): %s: key_type 0x%02x, key_index %d\n"), |
|
1119 (m_is_client == true) ? "client": "server", |
|
1120 key->get_key_type(), |
|
1121 key->get_key_index())); |
|
1122 |
|
1123 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
1124 TRACE_FLAGS_DEFAULT, |
|
1125 (EAPL("packet_data_session_key:"), |
|
1126 key_data->get_data(key_data->get_data_length()), |
|
1127 key_data->get_data_length())); |
|
1128 |
|
1129 EAP_TRACE_DATA_DEBUG( |
|
1130 m_am_tools, |
|
1131 TRACE_FLAGS_DEFAULT, |
|
1132 (EAPL("packet_data_session_key send source"), |
|
1133 send_network_id->get_source(), |
|
1134 send_network_id->get_source_length())); |
|
1135 |
|
1136 EAP_TRACE_DATA_DEBUG( |
|
1137 m_am_tools, |
|
1138 TRACE_FLAGS_DEFAULT, |
|
1139 (EAPL("packet_data_session_key send destination"), |
|
1140 send_network_id->get_destination(), |
|
1141 send_network_id->get_destination_length())); |
|
1142 |
|
1143 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
1144 |
|
1145 EAP_TRACE_DEBUG( |
|
1146 m_am_tools, |
|
1147 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1148 (EAPL("calls partner: wapi_wlan_authentication_c::packet_data_session_key(): %s: m_partner->packet_data_session_key()\n"), |
|
1149 (m_is_client == true) ? "client": "server")); |
|
1150 |
|
1151 status = m_partner->packet_data_session_key(send_network_id, key); |
|
1152 |
|
1153 EAP_TRACE_DEBUG( |
|
1154 m_am_tools, |
|
1155 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1156 (EAPL("returns from partner: wapi_wlan_authentication_c::packet_data_session_key(): %s: m_partner->packet_data_session_key(): status = %s\n"), |
|
1157 (m_is_client == true) ? "client": "server", |
|
1158 eap_status_string_c::get_status_string(status))); |
|
1159 |
|
1160 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1161 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1162 } |
|
1163 |
|
1164 //-------------------------------------------------- |
|
1165 |
|
1166 #if defined(USE_EAP_ERROR_TESTS) |
|
1167 |
|
1168 // |
|
1169 eap_status_e wapi_wlan_authentication_c::random_error( |
|
1170 eap_buf_chain_wr_c * const sent_packet, |
|
1171 const bool forse_error, |
|
1172 const u32_t packet_index) |
|
1173 { |
|
1174 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1175 |
|
1176 eap_status_e status = eap_status_ok; |
|
1177 |
|
1178 crypto_random_c rand(m_am_tools); |
|
1179 u32_t minimum_index = 0; |
|
1180 |
|
1181 sent_packet->set_is_client(false); |
|
1182 |
|
1183 if (m_manipulate_ethernet_header == false) |
|
1184 { |
|
1185 minimum_index = eapol_ethernet_header_wr_c::get_header_length(); |
|
1186 } |
|
1187 |
|
1188 status = m_am_tools->generate_random_error( |
|
1189 sent_packet, |
|
1190 forse_error, |
|
1191 packet_index, |
|
1192 minimum_index, |
|
1193 m_error_probability, |
|
1194 eapol_ethernet_header_wr_c::get_header_length()); |
|
1195 |
|
1196 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1197 return status; |
|
1198 } |
|
1199 |
|
1200 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
1201 |
|
1202 //-------------------------------------------------- |
|
1203 |
|
1204 // |
|
1205 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::packet_send( |
|
1206 const eap_am_network_id_c * const send_network_id, |
|
1207 eap_buf_chain_wr_c * const sent_packet, |
|
1208 const u32_t header_offset, |
|
1209 const u32_t data_length, |
|
1210 const u32_t buffer_length) |
|
1211 { |
|
1212 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1213 |
|
1214 EAP_TRACE_DEBUG( |
|
1215 m_am_tools, |
|
1216 TRACE_FLAGS_DEFAULT, |
|
1217 (EAPL("eapol calls: wapi_wlan_authentication_c::packet_send(data_length=%d): %s.\n"), |
|
1218 data_length, |
|
1219 (m_is_client == true) ? "client": "server")); |
|
1220 |
|
1221 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::packet_send()"); |
|
1222 |
|
1223 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
1224 |
|
1225 if (header_offset != 0u) |
|
1226 { |
|
1227 EAP_TRACE_DEBUG( |
|
1228 m_am_tools, |
|
1229 TRACE_FLAGS_DEFAULT, |
|
1230 (EAPL("packet_send: packet buffer corrupted.\n"))); |
|
1231 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1232 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
1233 } |
|
1234 else if (header_offset+data_length != sent_packet->get_data_length()) |
|
1235 { |
|
1236 EAP_TRACE_DEBUG( |
|
1237 m_am_tools, |
|
1238 TRACE_FLAGS_DEFAULT, |
|
1239 (EAPL("ERROR: packet_send: packet buffer corrupted (data_length != sent_packet->get_data_length()).\n"))); |
|
1240 EAP_ASSERT(data_length == sent_packet->get_buffer_length()); |
|
1241 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1242 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
1243 } |
|
1244 |
|
1245 eap_status_e status(eap_status_ok); |
|
1246 |
|
1247 EAP_TRACE_DEBUG( |
|
1248 m_am_tools, |
|
1249 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1250 (EAPL("calls partner: wapi_wlan_authentication_c::packet_send(): %s: m_partner->packet_send()\n"), |
|
1251 (m_is_client == true) ? "client": "server")); |
|
1252 |
|
1253 |
|
1254 #if defined(USE_EAP_ERROR_TESTS) |
|
1255 |
|
1256 if (m_randomly_drop_packets == true) |
|
1257 { |
|
1258 u32_t random_guard; |
|
1259 crypto_random_c rand(m_am_tools); |
|
1260 status = rand.get_rand_bytes( |
|
1261 reinterpret_cast<u8_t *>(&random_guard), |
|
1262 sizeof(random_guard)); |
|
1263 if (status != eap_status_ok) |
|
1264 { |
|
1265 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1266 } |
|
1267 |
|
1268 // This is simple limiter to the probability of a packet drop. |
|
1269 // probability = m_randomly_drop_packets_probability / (2^32) |
|
1270 if (random_guard < m_randomly_drop_packets_probability) |
|
1271 { |
|
1272 // Drops this packet. |
|
1273 |
|
1274 if (sent_packet->get_stack_address() == 0) |
|
1275 { |
|
1276 // Initialize error testing data. |
|
1277 sent_packet->set_stack_address(this); |
|
1278 m_am_tools->increase_packet_index(); |
|
1279 sent_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1280 } |
|
1281 |
|
1282 EAP_TRACE_DEBUG( |
|
1283 m_am_tools, |
|
1284 TRACE_FLAGS_DEFAULT, |
|
1285 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send packet dropped\n"), |
|
1286 sent_packet->get_stack_address(), |
|
1287 sent_packet->get_send_packet_index())); |
|
1288 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1289 return eap_status_ok; |
|
1290 } |
|
1291 } |
|
1292 |
|
1293 |
|
1294 if (m_send_original_packet_first == true |
|
1295 && m_generate_multiple_error_packets > 0ul) |
|
1296 { |
|
1297 if (sent_packet->get_stack_address() == 0) |
|
1298 { |
|
1299 // Initialize error testing data. |
|
1300 sent_packet->set_stack_address(this); |
|
1301 m_am_tools->increase_packet_index(); |
|
1302 sent_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1303 } |
|
1304 |
|
1305 if (sent_packet->get_is_manipulated() == false) |
|
1306 { |
|
1307 EAP_TRACE_DEBUG( |
|
1308 m_am_tools, |
|
1309 TRACE_FLAGS_DEFAULT, |
|
1310 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original packet\n"), |
|
1311 sent_packet->get_stack_address(), |
|
1312 sent_packet->get_send_packet_index())); |
|
1313 } |
|
1314 else |
|
1315 { |
|
1316 EAP_TRACE_DEBUG( |
|
1317 m_am_tools, |
|
1318 TRACE_FLAGS_DEFAULT, |
|
1319 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original already manipulated packet\n"), |
|
1320 sent_packet->get_stack_address(), |
|
1321 sent_packet->get_send_packet_index())); |
|
1322 } |
|
1323 |
|
1324 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
1325 |
|
1326 |
|
1327 // Here we send the original packet. |
|
1328 status = m_partner->packet_send( |
|
1329 send_network_id, |
|
1330 sent_packet, |
|
1331 header_offset, |
|
1332 data_length, |
|
1333 buffer_length); |
|
1334 |
|
1335 |
|
1336 #if defined(USE_EAP_ERROR_TESTS) |
|
1337 } |
|
1338 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
1339 |
|
1340 |
|
1341 #if defined(USE_EAP_ERROR_TESTS) |
|
1342 |
|
1343 if (m_enable_random_errors == true) |
|
1344 { |
|
1345 if (m_generate_multiple_error_packets > 0ul) |
|
1346 { |
|
1347 // First create a copy of sent packet. Original correct packet will be sent last. |
|
1348 for (u32_t ind = 0ul; ind < m_generate_multiple_error_packets; ind++) |
|
1349 { |
|
1350 eap_buf_chain_wr_c *copy_packet = sent_packet->copy(); |
|
1351 |
|
1352 if (copy_packet != 0 |
|
1353 && copy_packet->get_is_valid_data() == true) |
|
1354 { |
|
1355 m_am_tools->increase_packet_index(); |
|
1356 copy_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1357 |
|
1358 // Make a random error to the copy message. |
|
1359 random_error(copy_packet, true, copy_packet->get_send_packet_index()); |
|
1360 |
|
1361 EAP_TRACE_DEBUG( |
|
1362 m_am_tools, |
|
1363 TRACE_FLAGS_DEFAULT, |
|
1364 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send error packet\n"), |
|
1365 copy_packet->get_stack_address(), |
|
1366 copy_packet->get_send_packet_index())); |
|
1367 |
|
1368 // Here we send the copied and manipulated packet. |
|
1369 status = m_partner->packet_send( |
|
1370 send_network_id, |
|
1371 copy_packet, |
|
1372 header_offset, |
|
1373 data_length, |
|
1374 buffer_length |
|
1375 ); |
|
1376 } |
|
1377 |
|
1378 delete copy_packet; |
|
1379 } |
|
1380 } |
|
1381 else |
|
1382 { |
|
1383 if (sent_packet->get_stack_address() == 0) |
|
1384 { |
|
1385 // Initialize error testing data. |
|
1386 sent_packet->set_stack_address(this); |
|
1387 m_am_tools->increase_packet_index(); |
|
1388 sent_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1389 } |
|
1390 |
|
1391 eap_buf_chain_wr_c *copy_packet = sent_packet->copy(); |
|
1392 |
|
1393 if (copy_packet != 0 |
|
1394 && copy_packet->get_is_valid_data() == true) |
|
1395 { |
|
1396 m_am_tools->increase_packet_index(); |
|
1397 copy_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1398 |
|
1399 // Make a random error to the original message. |
|
1400 random_error(copy_packet, false, copy_packet->get_send_packet_index()); |
|
1401 |
|
1402 if (copy_packet->get_is_manipulated() == true) |
|
1403 { |
|
1404 EAP_TRACE_DEBUG( |
|
1405 m_am_tools, |
|
1406 TRACE_FLAGS_DEFAULT, |
|
1407 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send error packet\n"), |
|
1408 copy_packet->get_stack_address(), |
|
1409 copy_packet->get_send_packet_index())); |
|
1410 |
|
1411 // Here we send the copied and manipulated packet. |
|
1412 status = m_partner->packet_send( |
|
1413 send_network_id, |
|
1414 copy_packet, |
|
1415 header_offset, |
|
1416 data_length, |
|
1417 buffer_length); |
|
1418 } |
|
1419 } |
|
1420 |
|
1421 delete copy_packet; |
|
1422 } |
|
1423 } |
|
1424 |
|
1425 |
|
1426 if (m_send_original_packet_first == false) |
|
1427 { |
|
1428 if (sent_packet->get_stack_address() == 0) |
|
1429 { |
|
1430 // Initialize error testing data. |
|
1431 sent_packet->set_stack_address(this); |
|
1432 m_am_tools->increase_packet_index(); |
|
1433 sent_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1434 } |
|
1435 |
|
1436 if (sent_packet->get_is_manipulated() == false) |
|
1437 { |
|
1438 EAP_TRACE_DEBUG( |
|
1439 m_am_tools, |
|
1440 TRACE_FLAGS_DEFAULT, |
|
1441 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original packet\n"), |
|
1442 sent_packet->get_stack_address(), |
|
1443 sent_packet->get_send_packet_index())); |
|
1444 } |
|
1445 else |
|
1446 { |
|
1447 EAP_TRACE_DEBUG( |
|
1448 m_am_tools, |
|
1449 TRACE_FLAGS_DEFAULT, |
|
1450 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original already manipulated packet\n"), |
|
1451 sent_packet->get_stack_address(), |
|
1452 sent_packet->get_send_packet_index())); |
|
1453 } |
|
1454 |
|
1455 // Here we send the original packet. |
|
1456 status = m_partner->packet_send( |
|
1457 send_network_id, |
|
1458 sent_packet, |
|
1459 header_offset, |
|
1460 data_length, |
|
1461 buffer_length |
|
1462 ); |
|
1463 |
|
1464 //m_am_tools->increase_packet_index(); |
|
1465 } |
|
1466 else if (m_generate_multiple_error_packets == 0ul |
|
1467 || m_enable_random_errors == false) |
|
1468 { |
|
1469 if (sent_packet->get_stack_address() == 0) |
|
1470 { |
|
1471 // Initialize error testing data. |
|
1472 sent_packet->set_stack_address(this); |
|
1473 m_am_tools->increase_packet_index(); |
|
1474 sent_packet->set_send_packet_index(m_am_tools->get_packet_index()); |
|
1475 } |
|
1476 |
|
1477 if (sent_packet->get_is_manipulated() == true) |
|
1478 { |
|
1479 EAP_TRACE_DEBUG( |
|
1480 m_am_tools, |
|
1481 TRACE_FLAGS_DEFAULT, |
|
1482 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send error packet\n"), |
|
1483 sent_packet->get_stack_address(), |
|
1484 sent_packet->get_send_packet_index())); |
|
1485 } |
|
1486 else |
|
1487 { |
|
1488 EAP_TRACE_DEBUG( |
|
1489 m_am_tools, |
|
1490 TRACE_FLAGS_DEFAULT, |
|
1491 (EAPL("TEST: random_error(): packet_index 0x%08x:%lu, Send original packet\n"), |
|
1492 sent_packet->get_stack_address(), |
|
1493 sent_packet->get_send_packet_index())); |
|
1494 } |
|
1495 |
|
1496 // Here we send the original possibly manipulated packet. |
|
1497 status = m_partner->packet_send( |
|
1498 send_network_id, |
|
1499 sent_packet, |
|
1500 header_offset, |
|
1501 data_length, |
|
1502 buffer_length |
|
1503 ); |
|
1504 |
|
1505 //m_am_tools->increase_packet_index(); |
|
1506 } |
|
1507 |
|
1508 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
1509 |
|
1510 EAP_TRACE_DEBUG( |
|
1511 m_am_tools, |
|
1512 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1513 (EAPL("returns from partner: wapi_wlan_authentication_c::packet_send(): %s: m_partner->packet_send(): status = %s\n"), |
|
1514 (m_is_client == true) ? "client": "server", |
|
1515 eap_status_string_c::get_status_string(status))); |
|
1516 |
|
1517 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1518 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1519 } |
|
1520 |
|
1521 //-------------------------------------------------- |
|
1522 |
|
1523 // |
|
1524 eap_status_e wapi_wlan_authentication_c::cancel_timer_this_ap_failed() |
|
1525 { |
|
1526 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1527 |
|
1528 const eap_status_e status = cancel_timer( |
|
1529 this, |
|
1530 WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID); |
|
1531 |
|
1532 EAP_TRACE_DEBUG( |
|
1533 m_am_tools, |
|
1534 TRACE_FLAGS_DEFAULT, |
|
1535 (EAPL("wapi_wlan_authentication_c::cancel_timer_this_ap_failed(): Cancels timer WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID.\n"))); |
|
1536 |
|
1537 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1538 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1539 } |
|
1540 |
|
1541 //-------------------------------------------------- |
|
1542 |
|
1543 // |
|
1544 eap_status_e wapi_wlan_authentication_c::cancel_timer_failed_completely() |
|
1545 { |
|
1546 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1547 |
|
1548 const eap_status_e status = cancel_timer( |
|
1549 this, |
|
1550 WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID); |
|
1551 |
|
1552 EAP_TRACE_DEBUG( |
|
1553 m_am_tools, |
|
1554 TRACE_FLAGS_DEFAULT, |
|
1555 (EAPL("wapi_wlan_authentication_c::cancel_timer_failed_completely(): Cancels timer WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID.\n"))); |
|
1556 |
|
1557 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1558 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1559 } |
|
1560 |
|
1561 //-------------------------------------------------- |
|
1562 |
|
1563 // |
|
1564 eap_status_e wapi_wlan_authentication_c::cancel_timer_no_response() |
|
1565 { |
|
1566 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1567 |
|
1568 const eap_status_e status = cancel_timer( |
|
1569 this, |
|
1570 WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID); |
|
1571 |
|
1572 EAP_TRACE_DEBUG( |
|
1573 m_am_tools, |
|
1574 TRACE_FLAGS_DEFAULT, |
|
1575 (EAPL("wapi_wlan_authentication_c::cancel_timer_no_response(): Cancels timer WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID.\n"))); |
|
1576 |
|
1577 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1578 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1579 } |
|
1580 |
|
1581 //-------------------------------------------------- |
|
1582 |
|
1583 // |
|
1584 eap_status_e wapi_wlan_authentication_c::cancel_timer_authentication_cancelled() |
|
1585 { |
|
1586 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1587 |
|
1588 const eap_status_e status = cancel_timer( |
|
1589 this, |
|
1590 WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID); |
|
1591 |
|
1592 EAP_TRACE_DEBUG( |
|
1593 m_am_tools, |
|
1594 TRACE_FLAGS_DEFAULT, |
|
1595 (EAPL("wapi_wlan_authentication_c::cancel_timer_authentication_cancelled(): Cancels timer WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID.\n"))); |
|
1596 |
|
1597 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1598 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1599 } |
|
1600 |
|
1601 //-------------------------------------------------- |
|
1602 |
|
1603 // |
|
1604 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::state_notification( |
|
1605 const abs_eap_state_notification_c * const state) |
|
1606 { |
|
1607 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1608 |
|
1609 EAP_TRACE_DEBUG( |
|
1610 m_am_tools, |
|
1611 TRACE_FLAGS_DEFAULT, |
|
1612 (EAPL("eapol calls: wapi_wlan_authentication_c::state_notification()\n"))); |
|
1613 |
|
1614 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::state_notification()"); |
|
1615 |
|
1616 if (state == 0 |
|
1617 || state->get_send_network_id() == 0 |
|
1618 || state->get_send_network_id()->get_is_valid_data() == false) |
|
1619 { |
|
1620 EAP_TRACE_DEBUG( |
|
1621 m_am_tools, |
|
1622 TRACE_FLAGS_DEFAULT, |
|
1623 (EAPL("ERROR: Illegal state notification state=0x%08x, state->get_send_network_id()=0x%08x.\n"), |
|
1624 state, |
|
1625 ((state != 0) ? state->get_send_network_id() : 0))); |
|
1626 (void)EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
1627 return; |
|
1628 } |
|
1629 |
|
1630 EAP_TRACE_DATA_DEBUG( |
|
1631 m_am_tools, |
|
1632 TRACE_FLAGS_DEFAULT, |
|
1633 (EAPL(" send source"), |
|
1634 state->get_send_network_id()->get_source(), |
|
1635 state->get_send_network_id()->get_source_length())); |
|
1636 EAP_TRACE_DATA_DEBUG( |
|
1637 m_am_tools, |
|
1638 TRACE_FLAGS_DEFAULT, |
|
1639 (EAPL("send destination"), |
|
1640 state->get_send_network_id()->get_destination(), |
|
1641 state->get_send_network_id()->get_destination_length())); |
|
1642 |
|
1643 // Here we swap the addresses. |
|
1644 eap_am_network_id_c receive_network_id(m_am_tools, |
|
1645 state->get_send_network_id()->get_destination_id(), |
|
1646 state->get_send_network_id()->get_source_id(), |
|
1647 state->get_send_network_id()->get_type()); |
|
1648 |
|
1649 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
1650 |
|
1651 eap_am_network_id_c* send_network_id = new eap_am_network_id_c( |
|
1652 m_am_tools, |
|
1653 state->get_send_network_id()); |
|
1654 |
|
1655 eap_automatic_variable_c<eap_am_network_id_c> |
|
1656 automatic_send_network_id(m_am_tools, send_network_id); |
|
1657 |
|
1658 if (send_network_id == 0 |
|
1659 || send_network_id->get_is_valid_data() == false) |
|
1660 { |
|
1661 EAP_TRACE_DEBUG( |
|
1662 m_am_tools, |
|
1663 TRACE_FLAGS_DEFAULT, |
|
1664 (EAPL("ERROR: No network identity: Indication sent to WLM: eap_status_failed_completely.\n"))); |
|
1665 |
|
1666 (void) cancel_timer_failed_completely(); |
|
1667 |
|
1668 set_timer( |
|
1669 this, |
|
1670 WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID, |
|
1671 send_network_id, |
|
1672 0); |
|
1673 |
|
1674 automatic_send_network_id.do_not_free_variable(); |
|
1675 |
|
1676 EAP_TRACE_DEBUG( |
|
1677 m_am_tools, |
|
1678 TRACE_FLAGS_DEFAULT, |
|
1679 (EAPL("Sets timer ") |
|
1680 EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID.\n"))); |
|
1681 } |
|
1682 |
|
1683 |
|
1684 { |
|
1685 eap_status_string_c status_string; |
|
1686 eap_header_string_c eap_string; |
|
1687 |
|
1688 EAP_TRACE_DEBUG( |
|
1689 m_am_tools, |
|
1690 TRACE_FLAGS_DEFAULT, |
|
1691 (EAPL("wapi_wlan_authentication_c::state_notification() %s: protocol layer %d=%s, protocol %d=%s, 0x%08x=%s\n"), |
|
1692 (state->get_is_client() == true ? "client": "server"), |
|
1693 state->get_protocol_layer(), |
|
1694 state->get_protocol_layer_string(), |
|
1695 state->get_protocol(), |
|
1696 state->get_protocol_string(), |
|
1697 convert_eap_type_to_u32_t(state->get_eap_type()), |
|
1698 eap_string.get_eap_type_string(state->get_eap_type()))); |
|
1699 |
|
1700 EAP_TRACE_DEBUG( |
|
1701 m_am_tools, |
|
1702 TRACE_FLAGS_DEFAULT, |
|
1703 (EAPL("wapi_wlan_authentication_c::state_notification() %s: current state %d=%s, error %d=%s\n"), |
|
1704 (state->get_is_client() == true ? "client": "server"), |
|
1705 state->get_current_state(), |
|
1706 state->get_current_state_string(), |
|
1707 state->get_authentication_error(), |
|
1708 status_string.get_status_string(state->get_authentication_error()))); |
|
1709 } |
|
1710 |
|
1711 #if 0 |
|
1712 EAP_TRACE_DEBUG( |
|
1713 m_am_tools, |
|
1714 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1715 (EAPL("calls partner: wapi_wlan_authentication_c::state_notification(): %s: m_partner->state_notification()\n"), |
|
1716 (m_is_client == true) ? "client": "server")); |
|
1717 |
|
1718 // Calls lower layer. |
|
1719 // Note the optimization prevents most of the state notifications to lower layer. |
|
1720 m_partner->state_notification(state); |
|
1721 |
|
1722 EAP_TRACE_DEBUG( |
|
1723 m_am_tools, |
|
1724 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1725 (EAPL("returns from partner: wapi_wlan_authentication_c::state_notification(): %s: m_partner->state_notification()\n"), |
|
1726 (m_is_client == true) ? "client": "server")); |
|
1727 #endif |
|
1728 |
|
1729 // **** |
|
1730 // TODO: Check if these functionalities are ok for WAPI |
|
1731 // as a treatment for general layer failures; |
|
1732 // WAPI failure has its own protocol layer: eap_protocol_layer_wapi |
|
1733 |
|
1734 if(state->get_protocol_layer() == eap_protocol_layer_general) |
|
1735 { |
|
1736 if (state->get_current_state() == eap_general_state_authentication_cancelled) |
|
1737 { |
|
1738 // Authentication was cancelled. Cannot continue. |
|
1739 cancel_timer_authentication_cancelled(); |
|
1740 |
|
1741 set_timer(this, WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID, send_network_id, 0); |
|
1742 automatic_send_network_id.do_not_free_variable(); |
|
1743 |
|
1744 EAP_TRACE_DEBUG( |
|
1745 m_am_tools, |
|
1746 TRACE_FLAGS_DEFAULT, |
|
1747 (EAPL("Authentication was cancelled. Sets timer ") |
|
1748 EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID.\n"))); |
|
1749 |
|
1750 // This indication is sent synchronously to WLAN engine. That prevent other indications to bypass this indication. |
|
1751 eap_status_e status = wapi_indication( |
|
1752 &receive_network_id, |
|
1753 eapol_wlan_authentication_state_authentication_cancelled); |
|
1754 if (status != eap_status_ok) |
|
1755 { |
|
1756 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1757 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
1758 return; |
|
1759 } |
|
1760 } |
|
1761 else if (state->get_current_state() == eap_general_state_configuration_error) |
|
1762 { |
|
1763 // Configuration error. Cannot continue. |
|
1764 (void) cancel_timer_failed_completely(); |
|
1765 |
|
1766 set_timer(this, WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID, send_network_id, 0); |
|
1767 automatic_send_network_id.do_not_free_variable(); |
|
1768 |
|
1769 EAP_TRACE_DEBUG( |
|
1770 m_am_tools, |
|
1771 TRACE_FLAGS_DEFAULT, |
|
1772 (EAPL("Configuration error. Sets timer ") |
|
1773 EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID.\n"))); |
|
1774 } |
|
1775 else if (state->get_current_state() == eap_general_state_authentication_error) |
|
1776 { |
|
1777 // An authentication error from WAPI stack. |
|
1778 |
|
1779 eap_status_string_c status_string; |
|
1780 eap_header_string_c eap_string; |
|
1781 |
|
1782 EAP_TRACE_ERROR( |
|
1783 m_am_tools, |
|
1784 TRACE_FLAGS_DEFAULT, |
|
1785 (EAPL("ERROR: wapi_wlan_authentication_c::state_notification() %s: protocol layer %d=%s, protocol %d=%s, 0x%08x=%s\n"), |
|
1786 (state->get_is_client() == true ? "client": "server"), |
|
1787 state->get_protocol_layer(), |
|
1788 state->get_protocol_layer_string(), |
|
1789 state->get_protocol(), |
|
1790 state->get_protocol_string(), |
|
1791 convert_eap_type_to_u32_t(state->get_eap_type()), |
|
1792 eap_string.get_eap_type_string(state->get_eap_type()))); |
|
1793 |
|
1794 EAP_TRACE_ERROR( |
|
1795 m_am_tools, |
|
1796 TRACE_FLAGS_DEFAULT, |
|
1797 (EAPL("ERROR: wapi_wlan_authentication_c::state_notification() %s: current state %d=%s, error %d=%s\n"), |
|
1798 (state->get_is_client() == true ? "client": "server"), |
|
1799 state->get_current_state(), |
|
1800 state->get_current_state_string(), |
|
1801 state->get_authentication_error(), |
|
1802 status_string.get_status_string(state->get_authentication_error()))); |
|
1803 |
|
1804 EAP_TRACE_DEBUG( |
|
1805 m_am_tools, |
|
1806 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1807 (EAPL("calls partner: wapi_wlan_authentication_c::state_notification(): %s: m_partner->state_notification()\n"), |
|
1808 (m_is_client == true) ? "client": "server")); |
|
1809 |
|
1810 // Calls lower layer. |
|
1811 // Note the optimization prevents most of the state notifications to lower layer. |
|
1812 m_partner->state_notification(state); |
|
1813 |
|
1814 EAP_TRACE_DEBUG( |
|
1815 m_am_tools, |
|
1816 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1817 (EAPL("returns from partner: wapi_wlan_authentication_c::state_notification(): %s: m_partner->state_notification()\n"), |
|
1818 (m_is_client == true) ? "client": "server")); |
|
1819 |
|
1820 (void) cancel_timer_this_ap_failed(); |
|
1821 |
|
1822 set_timer( |
|
1823 this, |
|
1824 WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID, |
|
1825 send_network_id, |
|
1826 0); |
|
1827 automatic_send_network_id.do_not_free_variable(); |
|
1828 |
|
1829 EAP_TRACE_DEBUG( |
|
1830 m_am_tools, |
|
1831 TRACE_FLAGS_DEFAULT, |
|
1832 (EAPL("Sets timer WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID.\n"))); |
|
1833 } |
|
1834 else if (state->get_current_state() == eap_general_state_immediate_reconnect) |
|
1835 { |
|
1836 // An provision protocol ready. Do immediate reconnect to use the new credentials. |
|
1837 |
|
1838 eap_status_string_c status_string; |
|
1839 eap_header_string_c eap_string; |
|
1840 |
|
1841 EAP_TRACE_DEBUG( |
|
1842 m_am_tools, |
|
1843 TRACE_FLAGS_DEFAULT, |
|
1844 (EAPL("wapi_wlan_authentication_c::state_notification() %s: protocol layer %d=%s, protocol %d=%s, 0x%08x=%s\n"), |
|
1845 (state->get_is_client() == true ? "client": "server"), |
|
1846 state->get_protocol_layer(), |
|
1847 state->get_protocol_layer_string(), |
|
1848 state->get_protocol(), |
|
1849 state->get_protocol_string(), |
|
1850 convert_eap_type_to_u32_t(state->get_eap_type()), |
|
1851 eap_string.get_eap_type_string(state->get_eap_type()))); |
|
1852 |
|
1853 EAP_TRACE_DEBUG( |
|
1854 m_am_tools, |
|
1855 TRACE_FLAGS_DEFAULT, |
|
1856 (EAPL("wapi_wlan_authentication_c::state_notification() %s: current state %d=%s, error %d=%s\n"), |
|
1857 (state->get_is_client() == true ? "client": "server"), |
|
1858 state->get_current_state(), |
|
1859 state->get_current_state_string(), |
|
1860 state->get_authentication_error(), |
|
1861 status_string.get_status_string(state->get_authentication_error()))); |
|
1862 |
|
1863 eap_status_e status = wapi_indication( |
|
1864 &receive_network_id, |
|
1865 eapol_wlan_authentication_state_immediate_reconnect); |
|
1866 if (status != eap_status_ok) |
|
1867 { |
|
1868 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1869 return; |
|
1870 } |
|
1871 } |
|
1872 } |
|
1873 else if(state->get_protocol_layer() == eap_protocol_layer_wai) |
|
1874 { |
|
1875 switch (state->get_current_state()) |
|
1876 { |
|
1877 case eapol_key_state_wapi_authentication_terminated_unsuccessfull: |
|
1878 { |
|
1879 increment_authentication_counter(); |
|
1880 m_failed_authentications++; |
|
1881 |
|
1882 // Consider WAPI layer failures fatal. |
|
1883 EAP_TRACE_ERROR( |
|
1884 m_am_tools, |
|
1885 TRACE_FLAGS_DEFAULT, |
|
1886 (EAPL("ERROR: Unsuccessful authentication on WAI level.\n"))); |
|
1887 |
|
1888 (void) cancel_timer_this_ap_failed(); |
|
1889 |
|
1890 set_timer( |
|
1891 this, |
|
1892 WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID, |
|
1893 send_network_id, |
|
1894 0); |
|
1895 automatic_send_network_id.do_not_free_variable(); |
|
1896 |
|
1897 EAP_TRACE_DEBUG( |
|
1898 m_am_tools, |
|
1899 TRACE_FLAGS_DEFAULT, |
|
1900 (EAPL("Sets timer WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID.\n"))); |
|
1901 } |
|
1902 break; |
|
1903 |
|
1904 case eapol_key_state_wapi_authentication_finished_successfull: |
|
1905 { |
|
1906 // This is used in WAI authentications. |
|
1907 increment_authentication_counter(); |
|
1908 m_successful_authentications++; |
|
1909 |
|
1910 EAP_TRACE_ALWAYS( |
|
1911 m_am_tools, |
|
1912 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1913 (EAPL("WAPI: %s: Authentication SUCCESS\n"), |
|
1914 (m_is_client == true ? "client": "server"))); |
|
1915 |
|
1916 eap_status_e status = wapi_indication( |
|
1917 &receive_network_id, |
|
1918 eapol_wlan_authentication_state_authentication_successfull); |
|
1919 if (status != eap_status_ok) |
|
1920 { |
|
1921 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1922 return; |
|
1923 } |
|
1924 } |
|
1925 break; |
|
1926 |
|
1927 case eapol_key_state_wapi_authentication_running: |
|
1928 { |
|
1929 // This is used in dynamic WAI authentications. |
|
1930 EAP_TRACE_ALWAYS( |
|
1931 m_am_tools, |
|
1932 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1933 (EAPL("WAPI: %s: Authentication RUNNING\n"), |
|
1934 (m_is_client == true ? "client": "server"))); |
|
1935 |
|
1936 eap_status_e status = wapi_indication( |
|
1937 &receive_network_id, |
|
1938 eapol_wlan_authentication_state_wapi_authentication_running); |
|
1939 if (status != eap_status_ok) |
|
1940 { |
|
1941 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1942 return; |
|
1943 } |
|
1944 } |
|
1945 break; |
|
1946 |
|
1947 default: |
|
1948 break; |
|
1949 } |
|
1950 } |
|
1951 |
|
1952 EAP_TRACE_DEBUG( |
|
1953 m_am_tools, |
|
1954 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
1955 (EAPL("calls: wapi_wlan_authentication_c::state_notification(): m_am_wauth->state_notification(): %s.\n"), |
|
1956 (m_is_client == true) ? "client": "server")); |
|
1957 |
|
1958 // AM could have to show some notification to user. |
|
1959 m_am_wauth->state_notification(state); |
|
1960 |
|
1961 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1962 } |
|
1963 |
|
1964 //-------------------------------------------------- |
|
1965 |
|
1966 // |
|
1967 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::timer_expired( |
|
1968 const u32_t id, |
|
1969 void * data) |
|
1970 { |
|
1971 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1972 EAP_TRACE_DEBUG( |
|
1973 m_am_tools, |
|
1974 TRACE_FLAGS_DEFAULT, |
|
1975 (EAPL("eapol calls: wapi_wlan_authentication_c::timer_expired(): id = %d, data = 0x%08x.\n"), |
|
1976 id, |
|
1977 data)); |
|
1978 |
|
1979 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::timer_expired()"); |
|
1980 |
|
1981 |
|
1982 eap_am_network_id_c * const send_network_id = static_cast<eap_am_network_id_c *>(data); |
|
1983 if (send_network_id == 0 |
|
1984 || send_network_id->get_is_valid_data() == false) |
|
1985 { |
|
1986 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
1987 } |
|
1988 |
|
1989 // Here we swap the addresses. |
|
1990 eap_am_network_id_c receive_network_id(m_am_tools, |
|
1991 send_network_id->get_destination_id(), |
|
1992 send_network_id->get_source_id(), |
|
1993 send_network_id->get_type()); |
|
1994 |
|
1995 |
|
1996 switch (id) |
|
1997 { |
|
1998 case WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID: |
|
1999 { |
|
2000 EAP_TRACE_DEBUG( |
|
2001 m_am_tools, |
|
2002 TRACE_FLAGS_DEFAULT, |
|
2003 (EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID elapsed: ") |
|
2004 EAPL("Indication sent to WLM: eap_status_failed_completely.\n"))); |
|
2005 |
|
2006 (void) disassociation_mutex_must_be_reserved(&receive_network_id); |
|
2007 |
|
2008 eap_status_e status = wapi_indication( |
|
2009 &receive_network_id, |
|
2010 eapol_wlan_authentication_state_failed_completely); |
|
2011 if (status != eap_status_ok) |
|
2012 { |
|
2013 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2014 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2015 } |
|
2016 } |
|
2017 break; |
|
2018 |
|
2019 case WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID: |
|
2020 { |
|
2021 EAP_TRACE_DEBUG( |
|
2022 m_am_tools, |
|
2023 TRACE_FLAGS_DEFAULT, |
|
2024 (EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID elapsed: ") |
|
2025 EAPL("Indication sent to WLM: eap_status_this_ap_failed.\n"))); |
|
2026 |
|
2027 (void) disassociation_mutex_must_be_reserved(&receive_network_id); |
|
2028 |
|
2029 eap_status_e status = wapi_indication( |
|
2030 &receive_network_id, |
|
2031 eapol_wlan_authentication_state_this_ap_failed); |
|
2032 if (status != eap_status_ok) |
|
2033 { |
|
2034 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2035 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2036 } |
|
2037 } |
|
2038 break; |
|
2039 |
|
2040 case WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID: |
|
2041 { |
|
2042 EAP_TRACE_DEBUG( |
|
2043 m_am_tools, |
|
2044 TRACE_FLAGS_DEFAULT, |
|
2045 (EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID elapsed: ") |
|
2046 EAPL("Indication sent to WLM: eap_status_no_response.\n"))); |
|
2047 |
|
2048 (void) disassociation_mutex_must_be_reserved(&receive_network_id); |
|
2049 |
|
2050 eap_status_e status = wapi_indication( |
|
2051 &receive_network_id, |
|
2052 eapol_wlan_authentication_state_no_response); |
|
2053 if (status != eap_status_ok) |
|
2054 { |
|
2055 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2056 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2057 } |
|
2058 } |
|
2059 break; |
|
2060 |
|
2061 case WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID: |
|
2062 { |
|
2063 EAP_TRACE_DEBUG( |
|
2064 m_am_tools, |
|
2065 TRACE_FLAGS_DEFAULT, |
|
2066 (EAPL("WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID elapsed: ") |
|
2067 EAPL("Indication sent to WLM: eapol_wlan_authentication_state_authentication_cancelled.\n"))); |
|
2068 |
|
2069 (void) disassociation_mutex_must_be_reserved(&receive_network_id); |
|
2070 } |
|
2071 break; |
|
2072 |
|
2073 default: |
|
2074 break; |
|
2075 } |
|
2076 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
2077 } |
|
2078 |
|
2079 //-------------------------------------------------- |
|
2080 |
|
2081 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::timer_delete_data( |
|
2082 const u32_t id, |
|
2083 void *data) |
|
2084 { |
|
2085 EAP_TRACE_DEBUG( |
|
2086 m_am_tools, |
|
2087 TRACE_FLAGS_DEFAULT, |
|
2088 (EAPL("eapol calls: wapi_wlan_authentication_c::timer_delete_data(): id = %d, data = 0x%08x.\n"), |
|
2089 id, |
|
2090 data)); |
|
2091 |
|
2092 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::timer_delete_data()"); |
|
2093 |
|
2094 eap_am_network_id_c * const send_network_id = static_cast<eap_am_network_id_c *>(data); |
|
2095 if (send_network_id == 0 |
|
2096 || send_network_id->get_is_valid_data() == false) |
|
2097 { |
|
2098 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
2099 } |
|
2100 |
|
2101 switch (id) |
|
2102 { |
|
2103 case WAPI_WLAN_AUTHENTICATION_TIMER_FAILED_COMPLETELY_ID: |
|
2104 case WAPI_WLAN_AUTHENTICATION_TIMER_THIS_AP_FAILED_ID: |
|
2105 case WAPI_WLAN_AUTHENTICATION_TIMER_NO_RESPONSE_ID: |
|
2106 case WAPI_WLAN_AUTHENTICATION_TIMER_AUTHENTICATION_CANCELLED_ID: |
|
2107 delete send_network_id; |
|
2108 break; |
|
2109 default: |
|
2110 { |
|
2111 EAP_TRACE_ERROR( |
|
2112 m_am_tools, |
|
2113 TRACE_FLAGS_DEFAULT, |
|
2114 (EAPL("wapi_wlan_authentication_c::timer_delete_data: deleted unknown timer.\n"))); |
|
2115 (void)EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
2116 } |
|
2117 } |
|
2118 |
|
2119 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
2120 } |
|
2121 |
|
2122 //-------------------------------------------------- |
|
2123 |
|
2124 // |
|
2125 EAP_FUNC_EXPORT u32_t wapi_wlan_authentication_c::get_header_offset( |
|
2126 u32_t * const MTU, |
|
2127 u32_t * const trailer_length) |
|
2128 { |
|
2129 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2130 |
|
2131 EAP_TRACE_DEBUG( |
|
2132 m_am_tools, |
|
2133 TRACE_FLAGS_DEFAULT, |
|
2134 (EAPL("eapol calls: wapi_wlan_authentication_c::get_header_offset()\n"))); |
|
2135 |
|
2136 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::get_header_offset()"); |
|
2137 |
|
2138 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
2139 |
|
2140 EAP_TRACE_DEBUG( |
|
2141 m_am_tools, |
|
2142 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2143 (EAPL("calls partner: wapi_wlan_authentication_c::get_header_offset(): %s: m_partner->get_header_offset()\n"), |
|
2144 (m_is_client == true) ? "client": "server")); |
|
2145 |
|
2146 const u32_t offset = m_partner->get_header_offset(MTU, trailer_length); |
|
2147 |
|
2148 EAP_TRACE_DEBUG( |
|
2149 m_am_tools, |
|
2150 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2151 (EAPL("returns from partner: wapi_wlan_authentication_c::get_header_offset(): %s: m_partner->get_header_offset(): offset = %d\n"), |
|
2152 (m_is_client == true) ? "client": "server", |
|
2153 offset)); |
|
2154 |
|
2155 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2156 return offset; |
|
2157 |
|
2158 } |
|
2159 |
|
2160 //-------------------------------------------------- |
|
2161 |
|
2162 // |
|
2163 eap_status_e wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved( |
|
2164 const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address. |
|
2165 ) |
|
2166 { |
|
2167 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2168 |
|
2169 EAP_TRACE_DEBUG( |
|
2170 m_am_tools, |
|
2171 TRACE_FLAGS_DEFAULT, |
|
2172 (EAPL("eapol calls: wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): %s\n"), |
|
2173 (m_is_client == true) ? "client": "server")); |
|
2174 |
|
2175 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved()"); |
|
2176 |
|
2177 eap_status_e status(eap_status_process_general_error); |
|
2178 |
|
2179 if (m_ethernet_core != 0) |
|
2180 { |
|
2181 EAP_TRACE_DEBUG( |
|
2182 m_am_tools, |
|
2183 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2184 (EAPL("calls eapol: wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): m_ethernet_core->disassociation(): %s.\n"), |
|
2185 (m_is_client == true) ? "client": "server")); |
|
2186 |
|
2187 status = m_ethernet_core->disassociation(receive_network_id); |
|
2188 |
|
2189 EAP_TRACE_DEBUG( |
|
2190 m_am_tools, |
|
2191 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2192 (EAPL("returns from eapol: wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): m_ethernet_core->disassociation(): %s, status = %s.\n"), |
|
2193 (m_is_client == true) ? "client": "server", |
|
2194 eap_status_string_c::get_status_string(status))); |
|
2195 |
|
2196 if (status == eap_status_handler_does_not_exists_error) |
|
2197 { |
|
2198 EAP_TRACE_DEBUG( |
|
2199 m_am_tools, |
|
2200 TRACE_FLAGS_DEFAULT, |
|
2201 (EAPL("wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): Association did not exists.\n"))); |
|
2202 status = eap_status_ok; |
|
2203 } |
|
2204 } |
|
2205 else |
|
2206 { |
|
2207 EAP_TRACE_DEBUG( |
|
2208 m_am_tools, |
|
2209 TRACE_FLAGS_DEFAULT, |
|
2210 (EAPL("wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): Stack did not exists.\n"))); |
|
2211 } |
|
2212 |
|
2213 EAP_TRACE_DEBUG( |
|
2214 m_am_tools, |
|
2215 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2216 (EAPL("calls: wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): m_am_wauth->disassociation(): %s.\n"), |
|
2217 (m_is_client == true) ? "client": "server")); |
|
2218 |
|
2219 // This call indicates the disassociation to adaptation. |
|
2220 status = m_am_wauth->disassociation(receive_network_id); |
|
2221 if (status != eap_status_ok) |
|
2222 { |
|
2223 EAP_TRACE_DEBUG( |
|
2224 m_am_tools, |
|
2225 TRACE_FLAGS_DEFAULT, |
|
2226 (EAPL("wapi_wlan_authentication_c::disassociation_mutex_must_be_reserved(): m_am_wauth->disassociation() failed.\n"))); |
|
2227 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
2228 } |
|
2229 |
|
2230 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2231 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2232 } |
|
2233 |
|
2234 //-------------------------------------------------- |
|
2235 |
|
2236 // |
|
2237 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::disassociation( |
|
2238 const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address. |
|
2239 ) |
|
2240 { |
|
2241 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2242 |
|
2243 EAP_TRACE_DEBUG( |
|
2244 m_am_tools, |
|
2245 TRACE_FLAGS_DEFAULT, |
|
2246 (EAPL("partner calls: wapi_wlan_authentication_c::disassociation(): %s\n"), |
|
2247 (m_is_client == true) ? "client": "server")); |
|
2248 |
|
2249 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::disassociation()"); |
|
2250 |
|
2251 eap_status_e status(eap_status_ok); |
|
2252 |
|
2253 WAUTH_ENTER_MUTEX(m_am_tools); |
|
2254 status = disassociation_mutex_must_be_reserved(receive_network_id); |
|
2255 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
2256 |
|
2257 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2258 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2259 } |
|
2260 |
|
2261 //-------------------------------------------------- |
|
2262 |
|
2263 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::configure() |
|
2264 { |
|
2265 EAP_TRACE_DEBUG( |
|
2266 m_am_tools, |
|
2267 TRACE_FLAGS_DEFAULT, |
|
2268 (EAPL("partner calls: wapi_wlan_authentication_c::configure(): %s\n"), |
|
2269 (m_is_client == true) ? "client": "server")); |
|
2270 |
|
2271 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to partner: wapi_wlan_authentication_c::configure()"); |
|
2272 |
|
2273 //---------------------------------------------------------- |
|
2274 |
|
2275 EAP_TRACE_DEBUG( |
|
2276 m_am_tools, |
|
2277 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2278 (EAPL("calls: wapi_wlan_authentication_c::configure(): m_am_wauth->configure(): %s.\n"), |
|
2279 (m_is_client == true) ? "client": "server")); |
|
2280 |
|
2281 eap_status_e status = m_am_wauth->configure(); |
|
2282 if (status != eap_status_ok) |
|
2283 { |
|
2284 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2285 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2286 } |
|
2287 |
|
2288 //---------------------------------------------------------- |
|
2289 |
|
2290 // Read configuration parameters |
|
2291 |
|
2292 //---------------------------------------------------------- |
|
2293 |
|
2294 { |
|
2295 eap_variable_data_c EAP_TRACE_disable_traces(m_am_tools); |
|
2296 |
|
2297 eap_status_e status = read_configure( |
|
2298 cf_str_EAP_TRACE_disable_traces.get_field(), |
|
2299 &EAP_TRACE_disable_traces); |
|
2300 if (status == eap_status_ok |
|
2301 && EAP_TRACE_disable_traces.get_is_valid_data() == true) |
|
2302 { |
|
2303 u32_t *disable_traces = reinterpret_cast<u32_t *>( |
|
2304 EAP_TRACE_disable_traces.get_data(sizeof(u32_t))); |
|
2305 if (disable_traces != 0 |
|
2306 && *disable_traces != 0) |
|
2307 { |
|
2308 m_am_tools->set_trace_mask(eap_am_tools_c::eap_trace_mask_none); |
|
2309 } |
|
2310 } |
|
2311 } |
|
2312 |
|
2313 //---------------------------------------------------------- |
|
2314 |
|
2315 { |
|
2316 eap_variable_data_c EAP_TRACE_activate_only_trace_masks_always_and_error(m_am_tools); |
|
2317 |
|
2318 eap_status_e status = read_configure( |
|
2319 cf_str_EAP_TRACE_activate_only_trace_masks_always_and_error.get_field(), |
|
2320 &EAP_TRACE_activate_only_trace_masks_always_and_error); |
|
2321 if (status == eap_status_ok |
|
2322 && EAP_TRACE_activate_only_trace_masks_always_and_error.get_is_valid_data() == true) |
|
2323 { |
|
2324 u32_t *activate_trace_mask_always = reinterpret_cast<u32_t *>( |
|
2325 EAP_TRACE_activate_only_trace_masks_always_and_error.get_data(sizeof(u32_t))); |
|
2326 if (activate_trace_mask_always != 0 |
|
2327 && *activate_trace_mask_always != 0) |
|
2328 { |
|
2329 m_am_tools->set_trace_mask( |
|
2330 eap_am_tools_c::eap_trace_mask_always |
|
2331 | eap_am_tools_c::eap_trace_mask_error |
|
2332 ); |
|
2333 } |
|
2334 } |
|
2335 } |
|
2336 |
|
2337 //---------------------------------------------------------- |
|
2338 |
|
2339 { |
|
2340 eap_variable_data_c EAP_TRACE_activate_trace_on_error(m_am_tools); |
|
2341 |
|
2342 eap_status_e status = read_configure( |
|
2343 cf_str_EAP_TRACE_activate_trace_on_error.get_field(), |
|
2344 &EAP_TRACE_activate_trace_on_error); |
|
2345 if (status == eap_status_ok |
|
2346 && EAP_TRACE_activate_trace_on_error.get_is_valid_data() == true) |
|
2347 { |
|
2348 u32_t *activate_trace_on_error = reinterpret_cast<u32_t *>( |
|
2349 EAP_TRACE_activate_trace_on_error.get_data(sizeof(u32_t))); |
|
2350 if (activate_trace_on_error != 0 |
|
2351 && *activate_trace_on_error != 0) |
|
2352 { |
|
2353 m_am_tools->set_activate_trace_on_error(); |
|
2354 } |
|
2355 } |
|
2356 } |
|
2357 |
|
2358 //---------------------------------------------------------- |
|
2359 |
|
2360 { |
|
2361 eap_variable_data_c EAP_TRACE_enable_timer_traces(m_am_tools); |
|
2362 |
|
2363 status = read_configure( |
|
2364 cf_str_EAP_TRACE_enable_timer_traces.get_field(), |
|
2365 &EAP_TRACE_enable_timer_traces); |
|
2366 if (status == eap_status_ok |
|
2367 && EAP_TRACE_enable_timer_traces.get_is_valid_data() == true) |
|
2368 { |
|
2369 u32_t *enable_timer_traces = reinterpret_cast<u32_t *>( |
|
2370 EAP_TRACE_enable_timer_traces.get_data(sizeof(u32_t))); |
|
2371 if (enable_timer_traces != 0 |
|
2372 && *enable_timer_traces != 0) |
|
2373 { |
|
2374 m_am_tools->set_trace_mask( |
|
2375 m_am_tools->get_trace_mask() |
|
2376 | TRACE_FLAGS_TIMER |
|
2377 ); |
|
2378 } |
|
2379 } |
|
2380 } |
|
2381 |
|
2382 //---------------------------------------------------------- |
|
2383 |
|
2384 { |
|
2385 eap_variable_data_c EAP_TRACE_enable_timer_queue_traces(m_am_tools); |
|
2386 |
|
2387 status = read_configure( |
|
2388 cf_str_EAP_TRACE_enable_timer_queue_traces.get_field(), |
|
2389 &EAP_TRACE_enable_timer_queue_traces); |
|
2390 if (status == eap_status_ok |
|
2391 && EAP_TRACE_enable_timer_queue_traces.get_is_valid_data() == true) |
|
2392 { |
|
2393 u32_t *enable_timer_queue_traces = reinterpret_cast<u32_t *>( |
|
2394 EAP_TRACE_enable_timer_queue_traces.get_data(sizeof(u32_t))); |
|
2395 if (enable_timer_queue_traces != 0 |
|
2396 && *enable_timer_queue_traces != 0) |
|
2397 { |
|
2398 m_am_tools->set_trace_mask( |
|
2399 m_am_tools->get_trace_mask() |
|
2400 | TRACE_FLAGS_TIMER_QUEUE |
|
2401 ); |
|
2402 } |
|
2403 } |
|
2404 } |
|
2405 |
|
2406 //---------------------------------------------------------- |
|
2407 |
|
2408 { |
|
2409 eap_variable_data_c EAP_TRACE_enable_ok_return_traces(m_am_tools); |
|
2410 |
|
2411 status = read_configure( |
|
2412 cf_str_EAP_TRACE_enable_ok_return_traces.get_field(), |
|
2413 &EAP_TRACE_enable_ok_return_traces); |
|
2414 if (status == eap_status_ok |
|
2415 && EAP_TRACE_enable_ok_return_traces.get_is_valid_data() == true) |
|
2416 { |
|
2417 u32_t *enable_ok_return_traces = reinterpret_cast<u32_t *>( |
|
2418 EAP_TRACE_enable_ok_return_traces.get_data(sizeof(u32_t))); |
|
2419 if (enable_ok_return_traces != 0 |
|
2420 && *enable_ok_return_traces != 0) |
|
2421 { |
|
2422 m_am_tools->set_trace_mask( |
|
2423 m_am_tools->get_trace_mask() |
|
2424 | TRACE_FLAGS_OK_RETURNS |
|
2425 ); |
|
2426 } |
|
2427 } |
|
2428 } |
|
2429 |
|
2430 //---------------------------------------------------------- |
|
2431 |
|
2432 { |
|
2433 eap_variable_data_c EAP_TRACE_enable_message_data_traces(m_am_tools); |
|
2434 |
|
2435 status = read_configure( |
|
2436 cf_str_EAP_TRACE_enable_message_data_traces.get_field(), |
|
2437 &EAP_TRACE_enable_message_data_traces); |
|
2438 if (status == eap_status_ok |
|
2439 && EAP_TRACE_enable_message_data_traces.get_is_valid_data() == true) |
|
2440 { |
|
2441 u32_t *enable_message_data_traces = reinterpret_cast<u32_t *>( |
|
2442 EAP_TRACE_enable_message_data_traces.get_data(sizeof(u32_t))); |
|
2443 if (enable_message_data_traces != 0 |
|
2444 && *enable_message_data_traces != 0) |
|
2445 { |
|
2446 m_am_tools->set_trace_mask( |
|
2447 m_am_tools->get_trace_mask() |
|
2448 | EAP_TRACE_FLAGS_MESSAGE_DATA |
|
2449 ); |
|
2450 } |
|
2451 } |
|
2452 } |
|
2453 |
|
2454 //---------------------------------------------------------- |
|
2455 |
|
2456 // JPH: temporarily reads setting from configuration file. |
|
2457 { |
|
2458 eap_variable_data_c eapol_key_authentication_type(m_am_tools); |
|
2459 |
|
2460 eap_status_e status = read_configure( |
|
2461 cf_str_EAPOL_key_authentication_type.get_field(), |
|
2462 &eapol_key_authentication_type); |
|
2463 if (status == eap_status_ok |
|
2464 && eapol_key_authentication_type.get_is_valid() == true |
|
2465 && eapol_key_authentication_type.get_data_length() > 0ul |
|
2466 && eapol_key_authentication_type.get_data( |
|
2467 eapol_key_authentication_type.get_data_length()) != 0) |
|
2468 { |
|
2469 if (cf_str_EAPOL_key_authentication_type_config_value_RSNA_EAP.get_field() |
|
2470 ->compare( |
|
2471 m_am_tools, |
|
2472 &eapol_key_authentication_type) == true) |
|
2473 { |
|
2474 m_authentication_type |
|
2475 = eapol_key_authentication_type_RSNA_EAP; |
|
2476 } |
|
2477 else if (cf_str_EAPOL_key_authentication_type_config_value_RSNA_PSK.get_field() |
|
2478 ->compare( |
|
2479 m_am_tools, |
|
2480 &eapol_key_authentication_type) == true) |
|
2481 { |
|
2482 m_authentication_type |
|
2483 = eapol_key_authentication_type_RSNA_PSK; |
|
2484 } |
|
2485 else if (cf_str_EAPOL_key_authentication_type_config_value_WPA_EAP.get_field() |
|
2486 ->compare( |
|
2487 m_am_tools, |
|
2488 &eapol_key_authentication_type) == true) |
|
2489 { |
|
2490 m_authentication_type |
|
2491 = eapol_key_authentication_type_WPA_EAP; |
|
2492 } |
|
2493 else if (cf_str_EAPOL_key_authentication_type_config_value_WPA_PSK.get_field() |
|
2494 ->compare( |
|
2495 m_am_tools, |
|
2496 &eapol_key_authentication_type) == true) |
|
2497 { |
|
2498 m_authentication_type |
|
2499 = eapol_key_authentication_type_WPA_PSK; |
|
2500 } |
|
2501 else if (cf_str_EAPOL_key_authentication_type_config_value_dynamic_WEP.get_field() |
|
2502 ->compare( |
|
2503 m_am_tools, |
|
2504 &eapol_key_authentication_type) == true) |
|
2505 { |
|
2506 m_authentication_type |
|
2507 = eapol_key_authentication_type_802_1X; |
|
2508 } |
|
2509 #if defined(EAP_USE_WPXM) |
|
2510 else if (cf_str_EAPOL_key_authentication_type_config_value_WPXM.get_field() |
|
2511 ->compare( |
|
2512 m_am_tools, |
|
2513 &eapol_key_authentication_type) == true) |
|
2514 { |
|
2515 m_authentication_type |
|
2516 = eapol_key_authentication_type_WPXM; |
|
2517 } |
|
2518 #endif //#if defined(EAP_USE_WPXM) |
|
2519 else if (cf_str_EAPOL_key_authentication_type_config_value_WFA_SC.get_field() |
|
2520 ->compare( |
|
2521 m_am_tools, |
|
2522 &eapol_key_authentication_type) == true) |
|
2523 { |
|
2524 m_authentication_type |
|
2525 = eapol_key_authentication_type_WFA_SC; |
|
2526 } |
|
2527 else if (cf_str_EAPOL_key_authentication_type_config_value_WAI_PSK.get_field() |
|
2528 ->compare( |
|
2529 m_am_tools, |
|
2530 &eapol_key_authentication_type) == true) |
|
2531 { |
|
2532 m_authentication_type |
|
2533 = eapol_key_authentication_type_WAI_PSK; |
|
2534 } |
|
2535 else if (cf_str_EAPOL_key_authentication_type_config_value_WAI_certificate.get_field() |
|
2536 ->compare( |
|
2537 m_am_tools, |
|
2538 &eapol_key_authentication_type) == true) |
|
2539 { |
|
2540 m_authentication_type |
|
2541 = eapol_key_authentication_type_WAI_certificate; |
|
2542 } |
|
2543 } |
|
2544 } |
|
2545 |
|
2546 //---------------------------------------------------------- |
|
2547 |
|
2548 #if defined(USE_EAP_ERROR_TESTS) |
|
2549 |
|
2550 { |
|
2551 { |
|
2552 eap_variable_data_c EAP_ERROR_TEST_randomly_drop_packets(m_am_tools); |
|
2553 |
|
2554 status = read_configure( |
|
2555 cf_str_EAP_ERROR_TEST_randomly_drop_packets.get_field(), |
|
2556 &EAP_ERROR_TEST_randomly_drop_packets); |
|
2557 if (status == eap_status_ok |
|
2558 && EAP_ERROR_TEST_randomly_drop_packets.get_is_valid_data() == true) |
|
2559 { |
|
2560 u32_t *randomly_drop_packets = reinterpret_cast<u32_t *>( |
|
2561 EAP_ERROR_TEST_randomly_drop_packets.get_data(sizeof(u32_t))); |
|
2562 if (randomly_drop_packets != 0 |
|
2563 && *randomly_drop_packets != 0) |
|
2564 { |
|
2565 m_randomly_drop_packets = true; |
|
2566 } |
|
2567 } |
|
2568 } |
|
2569 |
|
2570 { |
|
2571 eap_variable_data_c EAP_ERROR_TEST_randomly_drop_packets_probability(m_am_tools); |
|
2572 |
|
2573 status = read_configure( |
|
2574 cf_str_EAP_ERROR_TEST_randomly_drop_packets_probability.get_field(), |
|
2575 &EAP_ERROR_TEST_randomly_drop_packets_probability); |
|
2576 if (status == eap_status_ok |
|
2577 && EAP_ERROR_TEST_randomly_drop_packets_probability.get_is_valid_data() == true) |
|
2578 { |
|
2579 u32_t *randomly_drop_packets_probability = reinterpret_cast<u32_t *>( |
|
2580 EAP_ERROR_TEST_randomly_drop_packets_probability.get_data(sizeof(u32_t))); |
|
2581 if (randomly_drop_packets_probability != 0) |
|
2582 { |
|
2583 m_randomly_drop_packets_probability = *randomly_drop_packets_probability; |
|
2584 } |
|
2585 } |
|
2586 } |
|
2587 |
|
2588 |
|
2589 { |
|
2590 eap_variable_data_c EAP_ERROR_TEST_enable_random_errors(m_am_tools); |
|
2591 |
|
2592 status = read_configure( |
|
2593 cf_str_EAP_ERROR_TEST_enable_random_errors.get_field(), |
|
2594 &EAP_ERROR_TEST_enable_random_errors); |
|
2595 if (status == eap_status_ok |
|
2596 && EAP_ERROR_TEST_enable_random_errors.get_is_valid_data() == true) |
|
2597 { |
|
2598 u32_t *enable_random_errors = reinterpret_cast<u32_t *>( |
|
2599 EAP_ERROR_TEST_enable_random_errors.get_data(sizeof(u32_t))); |
|
2600 if (enable_random_errors != 0 |
|
2601 && *enable_random_errors != 0) |
|
2602 { |
|
2603 m_enable_random_errors = true; |
|
2604 } |
|
2605 } |
|
2606 } |
|
2607 |
|
2608 { |
|
2609 eap_variable_data_c EAP_ERROR_TEST_send_original_packet_first(m_am_tools); |
|
2610 |
|
2611 status = read_configure( |
|
2612 cf_str_EAP_ERROR_TEST_send_original_packet_first.get_field(), |
|
2613 &EAP_ERROR_TEST_send_original_packet_first); |
|
2614 if (status == eap_status_ok |
|
2615 && EAP_ERROR_TEST_send_original_packet_first.get_is_valid_data() == true) |
|
2616 { |
|
2617 u32_t *send_original_packet_first = reinterpret_cast<u32_t *>( |
|
2618 EAP_ERROR_TEST_send_original_packet_first.get_data(sizeof(u32_t))); |
|
2619 if (send_original_packet_first != 0 |
|
2620 && *send_original_packet_first != 0) |
|
2621 { |
|
2622 m_send_original_packet_first = true; |
|
2623 } |
|
2624 } |
|
2625 } |
|
2626 |
|
2627 { |
|
2628 eap_variable_data_c EAP_ERROR_TEST_generate_multiple_error_packets(m_am_tools); |
|
2629 |
|
2630 status = read_configure( |
|
2631 cf_str_EAP_ERROR_TEST_generate_multiple_error_packets.get_field(), |
|
2632 &EAP_ERROR_TEST_generate_multiple_error_packets); |
|
2633 if (status == eap_status_ok |
|
2634 && EAP_ERROR_TEST_generate_multiple_error_packets.get_is_valid_data() == true) |
|
2635 { |
|
2636 u32_t *generate_multiple_error_packets = reinterpret_cast<u32_t *>( |
|
2637 EAP_ERROR_TEST_generate_multiple_error_packets.get_data(sizeof(u32_t))); |
|
2638 if (generate_multiple_error_packets != 0 |
|
2639 && *generate_multiple_error_packets != 0) |
|
2640 { |
|
2641 m_generate_multiple_error_packets = *generate_multiple_error_packets; |
|
2642 } |
|
2643 } |
|
2644 } |
|
2645 |
|
2646 |
|
2647 { |
|
2648 eap_variable_data_c EAP_ERROR_TEST_manipulate_ethernet_header(m_am_tools); |
|
2649 |
|
2650 status = read_configure( |
|
2651 cf_str_EAP_ERROR_TEST_manipulate_ethernet_header.get_field(), |
|
2652 &EAP_ERROR_TEST_manipulate_ethernet_header); |
|
2653 if (status == eap_status_ok |
|
2654 && EAP_ERROR_TEST_manipulate_ethernet_header.get_is_valid_data() == true) |
|
2655 { |
|
2656 u32_t *manipulate_ethernet_header = reinterpret_cast<u32_t *>( |
|
2657 EAP_ERROR_TEST_manipulate_ethernet_header.get_data(sizeof(u32_t))); |
|
2658 if (manipulate_ethernet_header != 0 |
|
2659 && *manipulate_ethernet_header != 0) |
|
2660 { |
|
2661 m_manipulate_ethernet_header = true; |
|
2662 } |
|
2663 } |
|
2664 } |
|
2665 |
|
2666 { |
|
2667 eap_variable_data_c EAP_ERROR_TEST_error_probability(m_am_tools); |
|
2668 |
|
2669 status = read_configure( |
|
2670 cf_str_EAP_ERROR_TEST_error_probability.get_field(), |
|
2671 &EAP_ERROR_TEST_error_probability); |
|
2672 if (status == eap_status_ok |
|
2673 && EAP_ERROR_TEST_error_probability.get_is_valid_data() == true) |
|
2674 { |
|
2675 u32_t *error_probability = reinterpret_cast<u32_t *>( |
|
2676 EAP_ERROR_TEST_error_probability.get_data(sizeof(u32_t))); |
|
2677 if (error_probability != 0) |
|
2678 { |
|
2679 m_error_probability = *error_probability; |
|
2680 } |
|
2681 } |
|
2682 } |
|
2683 } // if (m_manipulate_only_tunneled_messages == false) |
|
2684 |
|
2685 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
2686 |
|
2687 //---------------------------------------------------------- |
|
2688 |
|
2689 // Create stack if it does not already exist. |
|
2690 status = create_upper_stack(); |
|
2691 |
|
2692 if (status != eap_status_ok) |
|
2693 { |
|
2694 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2695 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2696 } |
|
2697 |
|
2698 // All of the configuration options are optional. |
|
2699 // So we return OK. |
|
2700 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
2701 } |
|
2702 |
|
2703 //-------------------------------------------------- |
|
2704 |
|
2705 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::read_configure( |
|
2706 const eap_configuration_field_c * const field, |
|
2707 eap_variable_data_c * const data) |
|
2708 { |
|
2709 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2710 |
|
2711 EAP_TRACE_DEBUG( |
|
2712 m_am_tools, |
|
2713 TRACE_FLAGS_DEFAULT, |
|
2714 (EAPL("eapol calls: wapi_wlan_authentication_c::read_configure(): %s\n"), |
|
2715 (m_is_client == true) ? "client": "server")); |
|
2716 |
|
2717 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::read_configure()"); |
|
2718 |
|
2719 EAP_ASSERT_ALWAYS(data != 0); |
|
2720 |
|
2721 EAP_TRACE_DEBUG( |
|
2722 m_am_tools, |
|
2723 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2724 (EAPL("calls: wapi_wlan_authentication_c::read_configure(): m_am_wauth->read_configure(): %s.\n"), |
|
2725 (m_is_client == true) ? "client": "server")); |
|
2726 |
|
2727 eap_status_e status = m_am_wauth->read_configure(field, data); |
|
2728 |
|
2729 m_am_tools->trace_configuration( |
|
2730 status, |
|
2731 field, |
|
2732 data); |
|
2733 |
|
2734 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2735 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2736 } |
|
2737 |
|
2738 //-------------------------------------------------- |
|
2739 |
|
2740 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::write_configure( |
|
2741 const eap_configuration_field_c * const field, |
|
2742 eap_variable_data_c * const data) |
|
2743 { |
|
2744 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2745 |
|
2746 EAP_TRACE_DEBUG( |
|
2747 m_am_tools, |
|
2748 TRACE_FLAGS_DEFAULT, |
|
2749 (EAPL("eapol calls: wapi_wlan_authentication_c::write_configure(): %s\n"), |
|
2750 (m_is_client == true) ? "client": "server")); |
|
2751 |
|
2752 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::write_configure()"); |
|
2753 |
|
2754 EAP_TRACE_DEBUG( |
|
2755 m_am_tools, |
|
2756 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2757 (EAPL("calls: wapi_wlan_authentication_c::write_configure(): m_am_wauth->write_configure(): %s.\n"), |
|
2758 (m_is_client == true) ? "client": "server")); |
|
2759 |
|
2760 eap_status_e status = m_am_wauth->write_configure(field, data); |
|
2761 |
|
2762 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2763 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2764 } |
|
2765 |
|
2766 //-------------------------------------------------- |
|
2767 |
|
2768 // |
|
2769 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::set_timer( |
|
2770 abs_eap_base_timer_c * const p_initializer, |
|
2771 const u32_t p_id, |
|
2772 void * const p_data, |
|
2773 const u32_t p_time_ms) |
|
2774 { |
|
2775 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2776 |
|
2777 EAP_TRACE_DEBUG( |
|
2778 m_am_tools, |
|
2779 TRACE_FLAGS_DEFAULT, |
|
2780 (EAPL("eapol calls: wapi_wlan_authentication_c::set_timer(): id = %d, data = 0x%08x, time = %d\n"), |
|
2781 p_id, |
|
2782 p_data, |
|
2783 p_time_ms)); |
|
2784 |
|
2785 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::set_timer()"); |
|
2786 |
|
2787 const eap_status_e status = m_am_tools->am_set_timer( |
|
2788 p_initializer, |
|
2789 p_id, |
|
2790 p_data, |
|
2791 p_time_ms); |
|
2792 |
|
2793 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2794 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2795 } |
|
2796 |
|
2797 //-------------------------------------------------- |
|
2798 |
|
2799 // |
|
2800 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::cancel_timer( |
|
2801 abs_eap_base_timer_c * const p_initializer, |
|
2802 const u32_t p_id) |
|
2803 { |
|
2804 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2805 |
|
2806 EAP_TRACE_DEBUG( |
|
2807 m_am_tools, |
|
2808 TRACE_FLAGS_DEFAULT, |
|
2809 (EAPL("eapol calls: wapi_wlan_authentication_c::cancel_timer(): initializer = 0x%08x, id = %d\n"), |
|
2810 p_initializer, |
|
2811 p_id)); |
|
2812 |
|
2813 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::cancel_timer()"); |
|
2814 |
|
2815 const eap_status_e status = m_am_tools->am_cancel_timer( |
|
2816 p_initializer, |
|
2817 p_id); |
|
2818 |
|
2819 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2820 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2821 } |
|
2822 |
|
2823 //-------------------------------------------------- |
|
2824 |
|
2825 // |
|
2826 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::cancel_all_timers() |
|
2827 { |
|
2828 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2829 |
|
2830 EAP_TRACE_DEBUG( |
|
2831 m_am_tools, |
|
2832 TRACE_FLAGS_DEFAULT, |
|
2833 (EAPL("eapol calls: wapi_wlan_authentication_c::cancel_all_timers()\n"))); |
|
2834 |
|
2835 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::cancel_all_timers()"); |
|
2836 |
|
2837 eap_status_e status = eap_status_ok; |
|
2838 |
|
2839 if (m_am_tools != 0) |
|
2840 { |
|
2841 WAUTH_ENTER_MUTEX(m_am_tools); |
|
2842 status = m_am_tools->am_cancel_all_timers(); |
|
2843 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
2844 } |
|
2845 |
|
2846 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2847 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2848 } |
|
2849 |
|
2850 //-------------------------------------------------- |
|
2851 |
|
2852 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::wapi_indication( |
|
2853 const eap_am_network_id_c * const receive_network_id, ///< source includes remote address, destination includes local address. |
|
2854 const eapol_wlan_authentication_state_e wlan_authentication_state) |
|
2855 { |
|
2856 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2857 |
|
2858 EAP_TRACE_DEBUG( |
|
2859 m_am_tools, |
|
2860 TRACE_FLAGS_DEFAULT, |
|
2861 (EAPL("eapol calls: wapi_wlan_authentication_c::wapi_indication()\n"))); |
|
2862 |
|
2863 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::wapi_indication()"); |
|
2864 |
|
2865 eap_status_e status(eap_status_ok); |
|
2866 |
|
2867 eap_am_network_id_c send_network_id(m_am_tools); |
|
2868 |
|
2869 if (receive_network_id != 0) |
|
2870 { |
|
2871 // Here we swap the addresses. |
|
2872 eap_am_network_id_c tmp_network_id(m_am_tools, |
|
2873 receive_network_id->get_destination_id(), |
|
2874 receive_network_id->get_source_id(), |
|
2875 receive_network_id->get_type()); |
|
2876 |
|
2877 status = send_network_id.set_copy_of_network_id(&tmp_network_id); |
|
2878 if (status != eap_status_ok) |
|
2879 { |
|
2880 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2881 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2882 } |
|
2883 } |
|
2884 |
|
2885 eap_state_notification_c notification( |
|
2886 m_am_tools, |
|
2887 &send_network_id, |
|
2888 m_is_client, |
|
2889 eap_state_notification_generic, |
|
2890 eap_protocol_layer_wapi, // this layer is WAPI notification to WLAN engine. |
|
2891 eap_type_none, |
|
2892 eapol_wlan_authentication_state_none, // Previous state is unknown. |
|
2893 wlan_authentication_state, // The current indicated state. |
|
2894 0UL, |
|
2895 false // This is not applicable here. |
|
2896 ); |
|
2897 |
|
2898 EAP_TRACE_DEBUG( |
|
2899 m_am_tools, |
|
2900 TRACE_FLAGS_DEFAULT, |
|
2901 (EAPL("wapi_wlan_authentication_c::wapi_indication(): Sending state notification to Engine. state=%s=%d\n"), |
|
2902 notification.get_state_string( notification.get_protocol_layer() ,wlan_authentication_state ), |
|
2903 wlan_authentication_state)); |
|
2904 EAP_TRACE_DATA_DEBUG( |
|
2905 m_am_tools, |
|
2906 TRACE_FLAGS_DEFAULT, |
|
2907 (EAPL(" send source"), |
|
2908 send_network_id.get_source(), |
|
2909 send_network_id.get_source_length())); |
|
2910 EAP_TRACE_DATA_DEBUG( |
|
2911 m_am_tools, |
|
2912 TRACE_FLAGS_DEFAULT, |
|
2913 (EAPL("send destination"), |
|
2914 send_network_id.get_destination(), |
|
2915 send_network_id.get_destination_length())); |
|
2916 |
|
2917 EAP_TRACE_DEBUG( |
|
2918 m_am_tools, |
|
2919 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2920 (EAPL("calls partner: wapi_wlan_authentication_c::wapi_indication(): %s: m_partner->state_notification()\n"), |
|
2921 (m_is_client == true) ? "client": "server")); |
|
2922 |
|
2923 m_partner->state_notification(¬ification); |
|
2924 |
|
2925 EAP_TRACE_DEBUG( |
|
2926 m_am_tools, |
|
2927 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2928 (EAPL("returns from partner: wapi_wlan_authentication_c::wapi_indication(): %s: m_partner->state_notification(): status = %s\n"), |
|
2929 (m_is_client == true) ? "client": "server", |
|
2930 eap_status_string_c::get_status_string(status))); |
|
2931 |
|
2932 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2933 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
2934 } |
|
2935 |
|
2936 //-------------------------------------------------- |
|
2937 |
|
2938 EAP_FUNC_EXPORT eap_status_e wapi_wlan_authentication_c::create_upper_stack() |
|
2939 { |
|
2940 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2941 |
|
2942 EAP_TRACE_DEBUG( |
|
2943 m_am_tools, |
|
2944 TRACE_FLAGS_DEFAULT, |
|
2945 (EAPL("eapol calls: wapi_wlan_authentication_c::create_upper_stack()\n"))); |
|
2946 |
|
2947 EAP_TRACE_RETURN_STRING(m_am_tools, "returns to eapol: wapi_wlan_authentication_c::create_upper_stack()"); |
|
2948 |
|
2949 eap_status_e status(eap_status_ok); |
|
2950 |
|
2951 if (m_ethernet_core == 0) |
|
2952 { |
|
2953 m_ethernet_core = new wapi_ethernet_core_c(m_am_tools, this, m_is_client); |
|
2954 if (m_ethernet_core == 0 |
|
2955 || m_ethernet_core->get_is_valid() != true) |
|
2956 { |
|
2957 if (m_ethernet_core != 0) |
|
2958 { |
|
2959 WAUTH_ENTER_MUTEX(m_am_tools); |
|
2960 EAP_TRACE_DEBUG( |
|
2961 m_am_tools, |
|
2962 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2963 (EAPL("calls eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->shutdown(): %s.\n"), |
|
2964 (m_is_client == true) ? "client": "server")); |
|
2965 status = m_ethernet_core->shutdown(); |
|
2966 EAP_TRACE_DEBUG( |
|
2967 m_am_tools, |
|
2968 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2969 (EAPL("returns from eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->shutdown(): %s, status = %s.\n"), |
|
2970 (m_is_client == true) ? "client": "server", |
|
2971 eap_status_string_c::get_status_string(status))); |
|
2972 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
2973 |
|
2974 delete m_ethernet_core; |
|
2975 m_ethernet_core = 0; |
|
2976 } |
|
2977 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Stack creation failed.\n"))); |
|
2978 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2979 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
2980 } |
|
2981 |
|
2982 // Initialise upper stack |
|
2983 WAUTH_ENTER_MUTEX(m_am_tools); |
|
2984 EAP_TRACE_DEBUG( |
|
2985 m_am_tools, |
|
2986 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2987 (EAPL("calls eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->configure(): %s.\n"), |
|
2988 (m_is_client == true) ? "client": "server")); |
|
2989 status = m_ethernet_core->configure(); |
|
2990 EAP_TRACE_DEBUG( |
|
2991 m_am_tools, |
|
2992 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
2993 (EAPL("returns from eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->configure(): %s, status = %s.\n"), |
|
2994 (m_is_client == true) ? "client": "server", |
|
2995 eap_status_string_c::get_status_string(status))); |
|
2996 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
2997 |
|
2998 if (status != eap_status_ok) |
|
2999 { |
|
3000 WAUTH_ENTER_MUTEX(m_am_tools); |
|
3001 EAP_TRACE_DEBUG( |
|
3002 m_am_tools, |
|
3003 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
3004 (EAPL("calls eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->shutdown(): %s.\n"), |
|
3005 (m_is_client == true) ? "client": "server")); |
|
3006 status = m_ethernet_core->shutdown(); |
|
3007 EAP_TRACE_DEBUG( |
|
3008 m_am_tools, |
|
3009 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
3010 (EAPL("returns from eapol: wapi_wlan_authentication_c::create_upper_stack(): m_ethernet_core->shutdown(): %s, status = %s.\n"), |
|
3011 (m_is_client == true) ? "client": "server", |
|
3012 eap_status_string_c::get_status_string(status))); |
|
3013 WAUTH_LEAVE_MUTEX(m_am_tools); |
|
3014 |
|
3015 delete m_ethernet_core; |
|
3016 m_ethernet_core = 0; |
|
3017 |
|
3018 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Stack creation failed.\n"))); |
|
3019 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3020 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
3021 } |
|
3022 } |
|
3023 else |
|
3024 { |
|
3025 status = eap_status_already_exists; |
|
3026 } |
|
3027 |
|
3028 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3029 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3030 } |
|
3031 |
|
3032 //-------------------------------------------------- |
|
3033 |
|
3034 #if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3035 |
|
3036 EAP_FUNC_EXPORT u32_t wapi_wlan_authentication_c::get_wrong_send_packet_index() |
|
3037 { |
|
3038 return 0ul; |
|
3039 } |
|
3040 |
|
3041 #endif //#if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3042 |
|
3043 //-------------------------------------------------- |
|
3044 |
|
3045 #if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3046 |
|
3047 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::reset_authentication_can_succeed() |
|
3048 { |
|
3049 } |
|
3050 |
|
3051 #endif //#if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3052 |
|
3053 //-------------------------------------------------- |
|
3054 |
|
3055 #if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3056 |
|
3057 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::set_authentication_can_succeed() |
|
3058 { |
|
3059 } |
|
3060 |
|
3061 #endif //#if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3062 |
|
3063 //-------------------------------------------------- |
|
3064 |
|
3065 #if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3066 |
|
3067 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::restore_authentication_can_succeed() |
|
3068 { |
|
3069 } |
|
3070 |
|
3071 #endif //#if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3072 |
|
3073 //-------------------------------------------------- |
|
3074 |
|
3075 #if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3076 |
|
3077 EAP_FUNC_EXPORT void wapi_wlan_authentication_c::set_authentication_must_not_succeed( |
|
3078 const u32_t /* wrong_packet_index */, |
|
3079 const u32_t /* packet_index */, |
|
3080 const void * const /* wrong_packet_stack */) |
|
3081 { |
|
3082 } |
|
3083 |
|
3084 #endif //#if defined(USE_TEST_EAPOL_WLAN_AUTHENTICATION) |
|
3085 |
|
3086 //-------------------------------------------------- |
|
3087 |
|
3088 // End of file. |
|