312 return EAP_STATUS_RETURN(m_am_tools, status); |
312 return EAP_STATUS_RETURN(m_am_tools, status); |
313 } |
313 } |
314 |
314 |
315 //-------------------------------------------------- |
315 //-------------------------------------------------- |
316 |
316 |
317 EAP_FUNC_EXPORT eap_status_e eap_core_c::cancel_asynchronous_init_remove_eap_session() |
317 eap_status_e eap_core_c::cancel_asynchronous_init_remove_eap_session() |
318 { |
318 { |
319 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
319 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
320 |
320 |
321 if (m_partner != 0) |
321 if (m_partner != 0) |
322 { |
322 { |
381 |
381 |
382 // Normally we will remove session after authentication ends. |
382 // Normally we will remove session after authentication ends. |
383 // Remove session only if the stack is not already being deleted |
383 // Remove session only if the stack is not already being deleted |
384 if (m_shutdown_was_called == false) |
384 if (m_shutdown_was_called == false) |
385 { |
385 { |
386 #if defined(USE_EAP_CORE_SIMULATOR_VERSION) |
386 #if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAP_CORE_RESTART_AUTHENTICATION) |
|
387 #error ERROR: USE_EAPOL_KEY_STATE and USE_EAP_CORE_RESTART_AUTHENTICATION cannot be used same time. |
|
388 #endif //#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAP_CORE_RESTART_AUTHENTICATION) |
|
389 |
|
390 #if defined(USE_EAP_CORE_SIMULATOR_VERSION) && defined(USE_EAP_CORE_RESTART_AUTHENTICATION) |
|
391 |
|
392 // Simulator reuses current session. |
|
393 status = restart_authentication( |
|
394 state->get_send_network_id(), |
|
395 m_is_client); |
|
396 if (status != eap_status_ok) |
|
397 { |
|
398 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
399 return EAP_STATUS_RETURN(m_am_tools, status); |
|
400 } |
|
401 |
|
402 #elif defined(USE_EAP_CORE_SIMULATOR_VERSION) && defined(USE_EAPOL_KEY_STATE) |
387 |
403 |
388 EAP_TRACE_DEBUG( |
404 EAP_TRACE_DEBUG( |
389 m_am_tools, |
405 m_am_tools, |
390 TRACE_FLAGS_DEFAULT, |
406 TRACE_FLAGS_DEFAULT, |
391 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
407 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
392 EAPL("Protocol layer %d, EAP-type 0x%02x, State transition from ") |
408 EAPL("Protocol layer %d, EAP type 0x%02x, State transition from ") |
393 EAPL("%d=%s to %d=%s, client %d.\n"), |
409 EAPL("%d=%s to %d=%s, client %d.\n"), |
394 (m_is_client == true) ? "client": "server", |
410 (m_is_client == true) ? "client": "server", |
395 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
411 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
396 state->get_protocol_layer(), |
412 state->get_protocol_layer(), |
397 state->get_protocol(), |
413 state->get_protocol(), |
415 { |
431 { |
416 EAP_TRACE_DEBUG( |
432 EAP_TRACE_DEBUG( |
417 m_am_tools, |
433 m_am_tools, |
418 TRACE_FLAGS_DEFAULT, |
434 TRACE_FLAGS_DEFAULT, |
419 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
435 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
420 EAPL("Protocol layer %d, EAP-type 0x%02x, State transition from ") |
436 EAPL("Protocol layer %d, EAP type 0x%02x, State transition from ") |
421 EAPL("%d=%s to %d=%s, client %d when shutdown was called.\n"), |
437 EAPL("%d=%s to %d=%s, client %d when shutdown was called.\n"), |
422 (m_is_client == true) ? "client": "server", |
438 (m_is_client == true) ? "client": "server", |
423 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
439 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
424 state->get_protocol_layer(), |
440 state->get_protocol_layer(), |
425 state->get_protocol(), |
441 state->get_protocol(), |
442 const abs_eap_state_notification_c * const state) |
458 const abs_eap_state_notification_c * const state) |
443 { |
459 { |
444 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
460 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
445 |
461 |
446 eap_status_string_c status_string; |
462 eap_status_string_c status_string; |
|
463 eap_header_string_c eap_string; |
447 EAP_UNREFERENCED_PARAMETER(status_string); // in release |
464 EAP_UNREFERENCED_PARAMETER(status_string); // in release |
|
465 EAP_UNREFERENCED_PARAMETER(eap_string); // in release |
448 |
466 |
449 EAP_TRACE_DEBUG( |
467 EAP_TRACE_DEBUG( |
450 m_am_tools, |
468 m_am_tools, |
451 TRACE_FLAGS_DEFAULT, |
469 TRACE_FLAGS_DEFAULT, |
452 (EAPL("eap_core_c::state_notification(), %s, %s, protocol_layer %d=%s, protocol %d=%s, EAP-type 0xfe%06x%08x=%s.\n"), |
470 (EAPL("eap_core_c::state_notification(), %s, %s, protocol_layer %d=%s, protocol %d=%s, EAP-type 0x%08x=%s.\n"), |
453 (m_is_client == true) ? "client": "server", |
471 (m_is_client == true) ? "client": "server", |
454 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
472 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
455 state->get_protocol_layer(), |
473 state->get_protocol_layer(), |
456 state->get_protocol_layer_string(), |
474 state->get_protocol_layer_string(), |
457 state->get_protocol(), |
475 state->get_protocol(), |
458 state->get_protocol_string(), |
476 state->get_protocol_string(), |
459 state->get_eap_type().get_vendor_id(), |
477 convert_eap_type_to_u32_t(state->get_eap_type()), |
460 state->get_eap_type().get_vendor_type(), |
478 eap_string.get_eap_type_string(state->get_eap_type()))); |
461 eap_header_string_c::get_eap_type_string(state->get_eap_type()))); |
|
462 |
479 |
463 EAP_TRACE_DEBUG( |
480 EAP_TRACE_DEBUG( |
464 m_am_tools, |
481 m_am_tools, |
465 TRACE_FLAGS_DEFAULT, |
482 TRACE_FLAGS_DEFAULT, |
466 (EAPL("eap_core_c::state_notification(), %s, %s, current_state %d=%s, error %d=%s.\n"), |
483 (EAPL("eap_core_c::state_notification(), %s, %s, current_state %d=%s, error %d=%s.\n"), |
487 { |
504 { |
488 EAP_TRACE_DEBUG( |
505 EAP_TRACE_DEBUG( |
489 m_am_tools, |
506 m_am_tools, |
490 TRACE_FLAGS_DEFAULT, |
507 TRACE_FLAGS_DEFAULT, |
491 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
508 (EAPL("eap_core_c::state_notification(): %s, %s, Ignored notification: ") |
492 EAPL("Protocol layer %d, non-active EAP-type 0x%02x, current EAP type 0x%08x, State transition from ") |
509 EAPL("Protocol layer %d, non-active EAP type 0x%02x, current EAP type 0x%08x, State transition from ") |
493 EAPL("%d=%s to %d=%s, client %d\n"), |
510 EAPL("%d=%s to %d=%s, client %d\n"), |
494 (m_is_client == true) ? "client": "server", |
511 (m_is_client == true) ? "client": "server", |
495 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
512 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
496 state->get_protocol_layer(), |
513 state->get_protocol_layer(), |
497 state->get_protocol(), |
514 state->get_protocol(), |
772 |
789 |
773 EAP_FUNC_EXPORT eap_status_e eap_core_c::cancel_session_timeout() |
790 EAP_FUNC_EXPORT eap_status_e eap_core_c::cancel_session_timeout() |
774 { |
791 { |
775 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
792 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
776 |
793 |
777 eap_status_e status(eap_status_ok); |
794 eap_status_e status = m_partner->cancel_timer( |
778 |
795 this, |
779 if (m_am_tools != 0) |
796 EAP_CORE_SESSION_TIMEOUT_ID); |
780 { |
|
781 status = m_partner->cancel_timer( |
|
782 this, |
|
783 EAP_CORE_SESSION_TIMEOUT_ID); |
|
784 } |
|
785 |
797 |
786 EAP_UNREFERENCED_PARAMETER(status); // in release |
798 EAP_UNREFERENCED_PARAMETER(status); // in release |
787 |
799 |
788 EAP_TRACE_DEBUG( |
800 EAP_TRACE_DEBUG( |
789 m_am_tools, |
801 m_am_tools, |
1298 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
1310 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
1299 return EAP_STATUS_RETURN(m_am_tools, eap_status_drop_packet_quietly); |
1311 return EAP_STATUS_RETURN(m_am_tools, eap_status_drop_packet_quietly); |
1300 } |
1312 } |
1301 } |
1313 } |
1302 #endif //#if defined(USE_EAP_CORE_SERVER) |
1314 #endif //#if defined(USE_EAP_CORE_SERVER) |
1303 else if (((eap.get_code() == eap_code_request |
1315 else if ((eap.get_code() == eap_code_request |
1304 || eap.get_code() == eap_code_response) |
1316 || eap.get_code() == eap_code_response) |
1305 && eap.get_type() == used_eap_type) |
1317 && eap.get_type() == used_eap_type |
1306 || eap.get_code() == eap_code_success |
1318 || eap.get_code() == eap_code_success |
1307 || eap.get_code() == eap_code_failure) |
1319 || eap.get_code() == eap_code_failure) |
1308 { |
1320 { |
1309 // Client and server handles this packet. |
1321 // Client and server handles this packet. |
1310 // Packet is EAP-Request, EAP-Response, EAP-Success or EAP-Failure. |
1322 // Packet is EAP-Request, EAP-Response, EAP-Success or EAP-Failure. |
1510 |
1522 |
1511 |
1523 |
1512 #if defined (_DEBUG) |
1524 #if defined (_DEBUG) |
1513 if (m_retransmission != 0) |
1525 if (m_retransmission != 0) |
1514 { |
1526 { |
|
1527 eap_header_string_c eap_string; |
|
1528 |
1515 EAP_TRACE_DEBUG( |
1529 EAP_TRACE_DEBUG( |
1516 m_am_tools, |
1530 m_am_tools, |
1517 TRACE_FLAGS_DEFAULT, |
1531 TRACE_FLAGS_DEFAULT, |
1518 (EAPL("EAP_Core: eap_core_c::packet_process(): %s, retransmission counter %d, retrans EAP-type %s, retrans EAP-Id %d, current EAP-type %s, current EAP-Id %d, session 0x%08x.\n"), |
1532 (EAPL("EAP_Core: eap_core_c::packet_process(): %s, retransmission counter %d, retrans EAP-type %s, retrans EAP-Id %d, current EAP-type %s, current EAP-Id %d, session 0x%08x.\n"), |
1519 (m_is_client_role == true) ? "client": "server", |
1533 (m_is_client_role == true) ? "client": "server", |
1520 m_retransmission->get_retransmission_counter(), |
1534 m_retransmission->get_retransmission_counter(), |
1521 eap_header_string_c::get_eap_type_string(m_retransmission->get_eap_type()), |
1535 eap_string.get_eap_type_string(m_retransmission->get_eap_type()), |
1522 m_retransmission->get_eap_identifier(), |
1536 m_retransmission->get_eap_identifier(), |
1523 eap_header_string_c::get_eap_type_string(eap.get_type()), |
1537 eap_string.get_eap_type_string(eap.get_type()), |
1524 eap.get_identifier(), |
1538 eap.get_identifier(), |
1525 this)); |
1539 this)); |
1526 } |
1540 } |
1527 else |
1541 else |
1528 { |
1542 { |
2207 (EAPL("TIMER: %s: %s, EAP_CORE_TIMER_RETRANSMISSION_ID cancelled.\n"), |
2221 (EAPL("TIMER: %s: %s, EAP_CORE_TIMER_RETRANSMISSION_ID cancelled.\n"), |
2208 (m_is_client_role == true ? "client": "server"), |
2222 (m_is_client_role == true ? "client": "server"), |
2209 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2223 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2210 )); |
2224 )); |
2211 |
2225 |
2212 if (m_is_client_role == false |
2226 if (m_is_client_role == false) |
2213 && m_partner != 0) |
|
2214 { |
2227 { |
2215 // Only EAP-server uses timer to re-transmits EAP-packets. |
2228 // Only EAP-server uses timer to re-transmits EAP-packets. |
2216 m_partner->cancel_timer(this, EAP_CORE_TIMER_RETRANSMISSION_ID); |
2229 m_partner->cancel_timer(this, EAP_CORE_TIMER_RETRANSMISSION_ID); |
2217 } |
2230 } |
2218 |
2231 |
2389 (EAPL("TIMER: %s: %s, EAP_CORE_FAILURE_RECEIVED_ID cancelled.\n"), |
2402 (EAPL("TIMER: %s: %s, EAP_CORE_FAILURE_RECEIVED_ID cancelled.\n"), |
2390 (m_is_client_role == true ? "client": "server"), |
2403 (m_is_client_role == true ? "client": "server"), |
2391 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2404 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2392 )); |
2405 )); |
2393 |
2406 |
2394 eap_status_e status(eap_status_ok); |
2407 return m_partner->cancel_timer( |
2395 |
2408 this, |
2396 if (m_am_tools != 0) |
2409 EAP_CORE_FAILURE_RECEIVED_ID); |
2397 { |
|
2398 status = m_partner->cancel_timer( |
|
2399 this, |
|
2400 EAP_CORE_FAILURE_RECEIVED_ID); |
|
2401 } |
|
2402 |
|
2403 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2404 } |
2410 } |
2405 |
2411 |
2406 //-------------------------------------------------- |
2412 //-------------------------------------------------- |
2407 |
2413 |
2408 #if defined(USE_EAP_CORE_WAIT_REQUEST_TYPE_TIMER) |
2414 #if defined(USE_EAP_CORE_WAIT_REQUEST_TYPE_TIMER) |
2466 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2472 (m_is_tunneled_eap == true) ? "tunneled": "outer most" |
2467 )); |
2473 )); |
2468 |
2474 |
2469 m_wait_eap_request_type_timeout_set = false; |
2475 m_wait_eap_request_type_timeout_set = false; |
2470 |
2476 |
2471 eap_status_e status(eap_status_ok); |
2477 return m_partner->cancel_timer( |
2472 |
2478 this, |
2473 if (m_am_tools != 0) |
2479 EAP_CORE_WAIT_EAP_REQUEST_TYPE_ID); |
2474 { |
|
2475 m_partner->cancel_timer( |
|
2476 this, |
|
2477 EAP_CORE_WAIT_EAP_REQUEST_TYPE_ID); |
|
2478 } |
|
2479 |
|
2480 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2481 } |
2480 } |
2482 else |
2481 else |
2483 { |
2482 { |
2484 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
2483 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
2485 } |
2484 } |
3013 m_remove_session_timeout = 0ul; |
3012 m_remove_session_timeout = 0ul; |
3014 } |
3013 } |
3015 |
3014 |
3016 //---------------------------------------------------------- |
3015 //---------------------------------------------------------- |
3017 |
3016 |
|
3017 #if defined(USE_EAP_EXPANDED_TYPES) |
3018 { |
3018 { |
3019 eap_variable_data_c use_eap_expanded_type(m_am_tools); |
3019 eap_variable_data_c use_eap_expanded_type(m_am_tools); |
3020 |
3020 |
3021 status = m_partner->read_configure( |
3021 status = m_partner->read_configure( |
3022 cf_str_EAP_CORE_use_eap_expanded_type.get_field(), |
3022 cf_str_EAP_CORE_use_eap_expanded_type.get_field(), |
5400 else |
5401 else |
5401 { |
5402 { |
5402 EAP_TRACE_DEBUG( |
5403 EAP_TRACE_DEBUG( |
5403 m_am_tools, |
5404 m_am_tools, |
5404 TRACE_FLAGS_DEFAULT, |
5405 TRACE_FLAGS_DEFAULT, |
5405 (EAPL("WARNING: %s, %s, EAP-identity is unknown: current EAP-type 0xfe%06x%08x=%s\n"), |
5406 (EAPL("WARNING: %s, %s, EAP-identity is unknown: current EAP-type 0x%08x\n"), |
5406 (m_is_client == true) ? "client": "server", |
5407 (m_is_client == true) ? "client": "server", |
5407 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
5408 (m_is_tunneled_eap == true) ? "tunneled": "outer most", |
5408 m_current_eap_type.get_vendor_id(), |
5409 convert_eap_type_to_u32_t(m_current_eap_type))); |
5409 m_current_eap_type.get_vendor_type(), |
|
5410 eap_header_string_c::get_eap_type_string(m_current_eap_type))); |
|
5411 } |
5410 } |
5412 |
5411 |
5413 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
5412 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
5414 return EAP_STATUS_RETURN_WARNING(m_am_tools, status); |
5413 return EAP_STATUS_RETURN_WARNING(m_am_tools, status); |
5415 } |
5414 } |
5487 return EAP_STATUS_RETURN(m_am_tools, status); |
5486 return EAP_STATUS_RETURN(m_am_tools, status); |
5488 } |
5487 } |
5489 |
5488 |
5490 //-------------------------------------------------- |
5489 //-------------------------------------------------- |
5491 |
5490 |
|
5491 // |
|
5492 EAP_FUNC_EXPORT eap_status_e eap_core_c::cancel_all_timers() |
|
5493 { |
|
5494 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5495 |
|
5496 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
5497 |
|
5498 const eap_status_e status = m_partner->cancel_all_timers(); |
|
5499 |
|
5500 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5501 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5502 } |
|
5503 |
|
5504 //-------------------------------------------------- |
|
5505 |
5492 EAP_FUNC_EXPORT eap_status_e eap_core_c::set_authentication_role(const bool when_true_set_client) |
5506 EAP_FUNC_EXPORT eap_status_e eap_core_c::set_authentication_role(const bool when_true_set_client) |
5493 { |
5507 { |
5494 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
5508 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
5495 |
5509 |
5496 cancel_retransmission(); |
5510 cancel_retransmission(); |