eapol/eapol_framework/eapol_common/type/radius/core/eap_radius_session.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 111 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 
       
    29 #include "eap_am_memory.h"
       
    30 #include "eap_tools.h"
       
    31 #include "eap_radius_session.h"
       
    32 #include "eap_state_notification.h"
       
    33 #include "eap_network_id_selector.h"
       
    34 #include "abs_eap_am_mutex.h"
       
    35 #include "eap_config.h"
       
    36 #include "eap_core.h"
       
    37 #include "eap_buffer.h"
       
    38 #include "eap_automatic_variable.h"
       
    39 
       
    40 
       
    41 //--------------------------------------------------
       
    42 
       
    43 // 
       
    44 EAP_FUNC_EXPORT eap_radius_session_c::~eap_radius_session_c()
       
    45 {
       
    46 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    47 
       
    48 	EAP_TRACE_DEBUG(
       
    49 		m_am_tools, 
       
    50 		TRACE_FLAGS_DEFAULT, 
       
    51 		(EAPL("eap_radius_session_c::~eap_radius_session_c(): this = 0x%08x => 0x%08x.\n"),
       
    52 		this,
       
    53 		dynamic_cast<abs_eap_base_timer_c *>(this)));
       
    54 
       
    55 	EAP_ASSERT(m_shutdown_was_called == true);
       
    56 
       
    57 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    58 }
       
    59 
       
    60 //--------------------------------------------------
       
    61 
       
    62 #if defined(_WIN32) && !defined(__GNUC__)
       
    63 	#pragma warning( disable : 4355 ) // 'this' : used in base member initializer list
       
    64 #endif
       
    65 
       
    66 // 
       
    67 EAP_FUNC_EXPORT eap_radius_session_c::eap_radius_session_c(
       
    68 	abs_eap_am_tools_c * const tools,
       
    69 	abs_eap_radius_session_c * const partner,
       
    70 	const bool is_client_when_true,
       
    71 	const eap_radius_variable_data_c * const user_name,
       
    72 	const eap_radius_variable_data_c * const nas_ip_address)
       
    73 	: m_partner(partner)
       
    74 	, m_am_tools(tools)
       
    75 	, m_eap_core(0)
       
    76 	, m_master_session_key(tools, eap_type_none)
       
    77 	, m_request_authenticator(tools)
       
    78 	, m_shared_secret(tools)
       
    79 	, m_identifier(0ul)
       
    80 	, m_user_name(0)
       
    81 	, m_nas_ip_address(0)
       
    82 	, m_state(eap_state_none)
       
    83 	, m_remove_session_timeout(EAP_RADIUS_SESSION_REMOVE_SESSION_TIMEOUT)
       
    84 	, m_is_client(is_client_when_true)
       
    85 	, m_is_valid(false)
       
    86 	, m_shutdown_was_called(false)
       
    87 {
       
    88 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    89 
       
    90 	EAP_TRACE_DEBUG(
       
    91 		m_am_tools, 
       
    92 		TRACE_FLAGS_DEFAULT, 
       
    93 		(EAPL("eap_radius_session_c::eap_radius_session_c(): this = 0x%08x => 0x%08x.\n"),
       
    94 		this,
       
    95 		dynamic_cast<abs_eap_base_timer_c *>(this)));
       
    96 
       
    97 	if (user_name == 0
       
    98 		|| nas_ip_address == 0)
       
    99 	{
       
   100 		return;
       
   101 	}
       
   102 
       
   103 	m_user_name = user_name->copy();
       
   104 	m_nas_ip_address = nas_ip_address->copy();
       
   105 
       
   106 	if (m_user_name == 0
       
   107 		|| m_nas_ip_address == 0)
       
   108 	{
       
   109 		return;
       
   110 	}
       
   111 
       
   112 
       
   113 	set_is_valid();
       
   114 
       
   115 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   116 }
       
   117 
       
   118 //--------------------------------------------------
       
   119 
       
   120 //
       
   121 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::save_request_data(
       
   122 	const void * const data,
       
   123 	const u32_t data_length,
       
   124 	const u8_t identifier)
       
   125 {
       
   126 	m_identifier = identifier;
       
   127 
       
   128 	eap_status_e status = m_request_authenticator.set_copy_of_buffer(
       
   129 		data,
       
   130 		data_length);
       
   131 
       
   132 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   133 }
       
   134 
       
   135 //--------------------------------------------------
       
   136 
       
   137 //
       
   138 EAP_FUNC_EXPORT u8_t eap_radius_session_c::get_identifier()
       
   139 {
       
   140 	return m_identifier;
       
   141 }
       
   142 
       
   143 //--------------------------------------------------
       
   144 
       
   145 //
       
   146 EAP_FUNC_EXPORT const eap_variable_data_c * eap_radius_session_c::get_shared_secret() const
       
   147 {
       
   148 	return &m_shared_secret;
       
   149 }
       
   150 
       
   151 //--------------------------------------------------
       
   152 
       
   153 //
       
   154 EAP_FUNC_EXPORT const eap_variable_data_c * eap_radius_session_c::get_request_authenticator()
       
   155 {
       
   156 	return &m_request_authenticator;
       
   157 }
       
   158 
       
   159 //--------------------------------------------------
       
   160 
       
   161 //
       
   162 EAP_FUNC_EXPORT const eap_radius_variable_data_c * eap_radius_session_c::get_user_name()
       
   163 {
       
   164 	return m_user_name;
       
   165 }
       
   166 
       
   167 //--------------------------------------------------
       
   168 
       
   169 //
       
   170 EAP_FUNC_EXPORT eap_state_variable_e eap_radius_session_c::get_state()
       
   171 {
       
   172 	return m_state;
       
   173 }
       
   174 
       
   175 //--------------------------------------------------
       
   176 
       
   177 //
       
   178 EAP_FUNC_EXPORT eap_variable_data_c * eap_radius_session_c::get_master_session_key()
       
   179 {
       
   180 	return &m_master_session_key;
       
   181 }
       
   182 
       
   183 //--------------------------------------------------
       
   184 
       
   185 //
       
   186 EAP_FUNC_EXPORT void eap_radius_session_c::object_increase_reference_count()
       
   187 {
       
   188 }
       
   189 
       
   190 //--------------------------------------------------
       
   191 
       
   192 //
       
   193 EAP_FUNC_EXPORT u32_t eap_radius_session_c::object_decrease_reference_count()
       
   194 {
       
   195 	return 0u;
       
   196 }
       
   197 
       
   198 //--------------------------------------------------
       
   199 
       
   200 //
       
   201 EAP_FUNC_EXPORT abs_eap_radius_session_c * eap_radius_session_c::get_partner()
       
   202 {
       
   203 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   204 
       
   205 	return m_partner;
       
   206 }
       
   207 
       
   208 //--------------------------------------------------
       
   209 
       
   210 //
       
   211 EAP_FUNC_EXPORT void eap_radius_session_c::set_is_valid()
       
   212 {
       
   213 	m_is_valid = true;
       
   214 }
       
   215 
       
   216 //--------------------------------------------------
       
   217 
       
   218 //
       
   219 EAP_FUNC_EXPORT bool eap_radius_session_c::get_is_valid()
       
   220 {
       
   221 	return m_is_valid;
       
   222 }
       
   223 
       
   224 //--------------------------------------------------
       
   225 
       
   226 //
       
   227 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::load_module(
       
   228 	const eap_type_value_e type,
       
   229 	const eap_type_value_e tunneling_type,
       
   230 	abs_eap_base_type_c * const partner,
       
   231 	eap_base_type_c ** const eap_type,
       
   232 	const bool is_client_when_true,
       
   233 	const eap_am_network_id_c * const receive_network_id)
       
   234 {
       
   235 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   236 
       
   237 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   238 
       
   239 	eap_status_e status = m_partner->load_module(
       
   240 		type,
       
   241 		tunneling_type,
       
   242 		partner,
       
   243 		eap_type,
       
   244 		is_client_when_true,
       
   245 		receive_network_id);
       
   246 
       
   247 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   248 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   249 }
       
   250 
       
   251 //--------------------------------------------------
       
   252 
       
   253 //
       
   254 EAP_FUNC_EXPORT eap_core_c * eap_radius_session_c::create_new_session(
       
   255 	const eap_am_network_id_c * const receive_network_id)
       
   256 {
       
   257 	eap_status_e status = eap_status_process_general_error;
       
   258 
       
   259 	if (m_eap_core != 0)
       
   260 	{
       
   261 		m_eap_core->shutdown();
       
   262 	}
       
   263 	delete m_eap_core;
       
   264 	m_eap_core = 0;
       
   265 
       
   266 	// Create a new session.
       
   267 	m_eap_core = new eap_core_c(
       
   268 		m_am_tools,
       
   269 		this,
       
   270 		m_is_client,
       
   271 		receive_network_id,
       
   272 		false);
       
   273 
       
   274 	if (m_eap_core == 0)
       
   275 	{
       
   276 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   277 		(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   278 		return 0;
       
   279 	}
       
   280 
       
   281 	if (m_eap_core->get_is_valid() == false)
       
   282 	{
       
   283 		m_eap_core->shutdown();
       
   284 		delete m_eap_core;
       
   285 		m_eap_core = 0;
       
   286 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   287 		(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   288 		return 0;
       
   289 	}
       
   290 
       
   291 	status = m_eap_core->configure();
       
   292 	if (status != eap_status_ok)
       
   293 	{
       
   294 		m_eap_core->shutdown();
       
   295 		delete m_eap_core;
       
   296 		m_eap_core = 0;
       
   297 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   298 		(void) EAP_STATUS_RETURN(m_am_tools, status);
       
   299 		return 0;
       
   300 	}
       
   301 
       
   302 	return m_eap_core;
       
   303 }
       
   304 
       
   305 //--------------------------------------------------
       
   306 
       
   307 //
       
   308 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::reset()
       
   309 {
       
   310 	if (m_eap_core != 0)
       
   311 	{
       
   312 		m_eap_core->shutdown();
       
   313 	}
       
   314 	delete m_eap_core;
       
   315 	m_eap_core = 0;
       
   316 
       
   317 	m_master_session_key.reset();
       
   318 
       
   319 	m_request_authenticator.reset();
       
   320 
       
   321 	m_identifier = 0ul;
       
   322 
       
   323 	m_state = eap_state_none;
       
   324 
       
   325 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   326 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   327 }
       
   328 
       
   329 //--------------------------------------------------
       
   330 
       
   331 //
       
   332 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::packet_process(
       
   333 	const eap_am_network_id_c * const receive_network_id,
       
   334 	eap_general_header_base_c * const packet_data,
       
   335 	const u32_t packet_length)
       
   336 {
       
   337 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   338 
       
   339 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   340 
       
   341 	eap_status_e status = eap_status_process_general_error;
       
   342 
       
   343 	// Each EAP authentication session includes own eap_core_c object.
       
   344 	// EAP authentication sessions are separated by eap_am_network_id_c object.
       
   345 
       
   346 	if (packet_data == 0
       
   347 		|| packet_length < eap_header_base_c::get_header_length())
       
   348 	{
       
   349 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   350 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   351 	}
       
   352 
       
   353 	if (receive_network_id == 0
       
   354 		|| receive_network_id->get_is_valid_data() == false)
       
   355 	{
       
   356 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   357 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   358 	}
       
   359 
       
   360 	eap_header_wr_c eap(
       
   361 		m_am_tools,
       
   362 		packet_data->get_header_buffer(packet_data->get_header_buffer_length()),
       
   363 		packet_data->get_header_buffer_length());
       
   364 
       
   365 	if (eap.get_is_valid() == false)
       
   366 	{
       
   367 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   368 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   369 	}
       
   370 
       
   371 	if (packet_length < eap.get_length())
       
   372 	{
       
   373 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   374 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   375 	}
       
   376 
       
   377 	if (eap.get_code() == eap_code_none)
       
   378 	{
       
   379 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   380 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   381 	}
       
   382 
       
   383 	EAP_TRACE_DEBUG(
       
   384 		m_am_tools, 
       
   385 		TRACE_FLAGS_DEFAULT, 
       
   386 		(EAPL("-> EAP_session: %s, code=0x%02x=%s, identifier=0x%02x, ")
       
   387 		 EAPL("length=0x%04x, type=0x%08x=%s, packet length 0x%04x\n"),
       
   388 		(m_is_client == true) ? "client": "server",
       
   389 		eap.get_code(),
       
   390 		eap.get_code_string(),
       
   391 		eap.get_identifier(),
       
   392 		eap.get_length(),
       
   393 		convert_eap_type_to_u32_t(eap.get_type()),
       
   394 		eap.get_type_string(),
       
   395 		packet_length));
       
   396 
       
   397 	// Here we swap the addresses.
       
   398 	eap_am_network_id_c send_network_id(m_am_tools,
       
   399 		receive_network_id->get_destination_id(),
       
   400 		receive_network_id->get_source_id(),
       
   401 		receive_network_id->get_type());
       
   402 	if (send_network_id.get_is_valid_data() == false)
       
   403 	{
       
   404 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   405 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   406 	}
       
   407 
       
   408 	eap_network_id_selector_c selector(
       
   409 		m_am_tools,
       
   410 		&send_network_id);
       
   411 	if (selector.get_is_valid() == false)
       
   412 	{
       
   413 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   414 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   415 	}
       
   416 
       
   417 	if (m_eap_core != 0
       
   418 		&& m_eap_core->get_marked_removed() == true)
       
   419 	{
       
   420 		if (eap.get_code() == eap_code_request
       
   421 			|| eap.get_code() == eap_code_response)
       
   422 		{
       
   423 			// Only EAP-Request or EAP-Response resets the session.
       
   424 			// This reset is delayed.
       
   425 			reset();
       
   426 		}
       
   427 	}
       
   428 
       
   429 	if (m_eap_core == 0)
       
   430 	{
       
   431 		// Create a new session.
       
   432 		m_eap_core = create_new_session(receive_network_id);
       
   433 	}
       
   434 
       
   435 	if (m_eap_core != 0)
       
   436 	{
       
   437 		status = m_eap_core->packet_process(
       
   438 			receive_network_id,
       
   439 			&eap,
       
   440 			packet_length);
       
   441 	}
       
   442 	else
       
   443 	{
       
   444 		status = eap_status_illegal_eap_type;
       
   445 	}
       
   446 
       
   447 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   448 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   449 }
       
   450 
       
   451 //--------------------------------------------------
       
   452 
       
   453 //
       
   454 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::packet_send(
       
   455 	const eap_am_network_id_c * const send_network_id,
       
   456 	eap_buf_chain_wr_c * const sent_packet,
       
   457 	const u32_t header_offset,
       
   458 	const u32_t data_length,
       
   459 	const u32_t buffer_length)
       
   460 {
       
   461 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   462 
       
   463 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   464 
       
   465 	eap_header_wr_c eap(
       
   466 		m_am_tools,
       
   467 		sent_packet->get_data_offset(header_offset, data_length),
       
   468 		data_length);
       
   469 
       
   470 	if (eap.get_is_valid() == false)
       
   471 	{
       
   472 		EAP_TRACE_DEBUG(
       
   473 			m_am_tools, 
       
   474 			TRACE_FLAGS_DEFAULT, 
       
   475 			(EAPL("packet_send: packet buffer corrupted.\n")));
       
   476 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   477 		return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   478 	}
       
   479 
       
   480 	EAP_ASSERT(header_offset < sent_packet->get_data_length());
       
   481 	EAP_ASSERT(data_length <= sent_packet->get_data_length());
       
   482 	EAP_ASSERT(sent_packet->get_data_length() <= buffer_length);
       
   483 
       
   484 	EAP_TRACE_DEBUG(
       
   485 		m_am_tools, 
       
   486 		TRACE_FLAGS_DEFAULT, 
       
   487 		(EAPL("<- EAP_session: %s, code=0x%02x=%s, identifier=0x%02x, ")
       
   488 		 EAPL("length=0x%04x, type=0x%08x=%s, packet length 0x%04x\n"),
       
   489 		(m_is_client == true) ? "client": "server",
       
   490 		eap.get_code(),
       
   491 		eap.get_code_string(),
       
   492 		eap.get_identifier(),
       
   493 		eap.get_length(),
       
   494 		convert_eap_type_to_u32_t(eap.get_type()),
       
   495 		eap.get_type_string(),
       
   496 		data_length));
       
   497 
       
   498 	eap_status_e status = m_partner->packet_send(
       
   499 		send_network_id,
       
   500 		sent_packet,
       
   501 		header_offset,
       
   502 		data_length,
       
   503 		buffer_length,
       
   504 		this);
       
   505 
       
   506 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   507 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   508 }
       
   509 
       
   510 //--------------------------------------------------
       
   511 
       
   512 //
       
   513 EAP_FUNC_EXPORT u32_t eap_radius_session_c::get_header_offset(
       
   514 	u32_t * const MTU,
       
   515 	u32_t * const trailer_length)
       
   516 {
       
   517 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   518 
       
   519 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   520 
       
   521 	const u32_t offset = m_partner->get_header_offset(MTU, trailer_length);
       
   522 
       
   523 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   524 	return offset;
       
   525 }
       
   526 
       
   527 //--------------------------------------------------
       
   528 
       
   529 //
       
   530 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::configure()
       
   531 {
       
   532 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   533 
       
   534 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   535 
       
   536 
       
   537 	{
       
   538 		eap_configuration_field_c * const field
       
   539 			=  cf_str_EAP_RADIUS_SERVER_shared_secret.get_field()->copy(
       
   540 				m_am_tools,
       
   541 				cf_str_EAP_RADIUS_SERVER_client.get_field(),
       
   542 				m_nas_ip_address->get_payload_buffer());
       
   543 
       
   544 		eap_automatic_variable_c<eap_configuration_field_c>
       
   545 			automatic_field(m_am_tools, field);
       
   546 
       
   547 		eap_status_e status = read_configure(
       
   548 			field,
       
   549 			&m_shared_secret);
       
   550 		if (status == eap_status_ok
       
   551 			&& m_shared_secret.get_is_valid_data() == true)
       
   552 		{
       
   553 			// OK shared secret is configured.
       
   554 		}
       
   555 		else
       
   556 		{
       
   557 			EAP_TRACE_DATA_DEBUG(
       
   558 				m_am_tools, 
       
   559 				TRACE_FLAGS_DEFAULT, 
       
   560 				(EAPL("ERROR: unknown radius client (IP)"), 
       
   561 				 m_nas_ip_address->get_payload_buffer()->get_data(), 
       
   562 				 m_nas_ip_address->get_payload_buffer()->get_data_length()));
       
   563 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   564 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
       
   565 		}
       
   566 	}
       
   567 
       
   568 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   569 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   570 }
       
   571 
       
   572 //--------------------------------------------------
       
   573 
       
   574 //
       
   575 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::shutdown_operation(
       
   576 	eap_core_c * const core,
       
   577 	abs_eap_am_tools_c * const m_am_tools)
       
   578 {
       
   579 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   580 
       
   581 	eap_status_e status = core->shutdown();
       
   582 
       
   583 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   584 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   585 }
       
   586 
       
   587 //--------------------------------------------------
       
   588 
       
   589 //
       
   590 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::shutdown()
       
   591 {
       
   592 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   593 
       
   594 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   595 
       
   596 	EAP_TRACE_DEBUG(
       
   597 		m_am_tools, 
       
   598 		TRACE_FLAGS_DEFAULT, 
       
   599 		(EAPL("eap_radius_session_c::shutdown(): this = 0x%08x => 0x%08x.\n"),
       
   600 		this,
       
   601 		dynamic_cast<abs_eap_base_timer_c *>(this)));
       
   602 
       
   603 	if (m_shutdown_was_called == true)
       
   604 	{
       
   605 		// Shutdown function was called already.
       
   606 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   607 	}
       
   608 	m_shutdown_was_called = true;
       
   609 
       
   610 	eap_status_e status = m_eap_core->shutdown();
       
   611 	delete m_eap_core;
       
   612 	m_eap_core = 0;
       
   613 
       
   614 	delete m_user_name;
       
   615 	m_user_name = 0;
       
   616 
       
   617 	delete m_nas_ip_address;
       
   618 	m_nas_ip_address = 0;
       
   619 
       
   620 	m_partner->cancel_timer(this, EAP_RADIUS_SESSION_REMOVE_SESSION_ID);
       
   621 
       
   622 	EAP_TRACE_DEBUG(
       
   623 		m_am_tools, 
       
   624 		TRACE_FLAGS_DEFAULT, 
       
   625 		(EAPL("TIMER: EAP_RADIUS_SESSION_REMOVE_SESSION_ID cancelled, %s.\n"),
       
   626 		 (m_is_client == true) ? "client": "server"));
       
   627 
       
   628 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   629 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   630 }
       
   631 
       
   632 //--------------------------------------------------
       
   633 
       
   634 //
       
   635 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::unload_module(const eap_type_value_e type)
       
   636 {
       
   637 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   638 
       
   639 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   640 
       
   641 	const eap_status_e status = m_partner->unload_module(type);
       
   642 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   643 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   644 }
       
   645 
       
   646 //--------------------------------------------------
       
   647 
       
   648 //
       
   649 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::eap_acknowledge(
       
   650 	const eap_am_network_id_c * const receive_network_id)
       
   651 {
       
   652 	// Any Network Protocol packet is accepted as a success indication.
       
   653 	// This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)".
       
   654 
       
   655 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   656 
       
   657 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   658 
       
   659 	eap_status_e status = eap_status_process_general_error;
       
   660 
       
   661 	if (receive_network_id == 0)
       
   662 	{
       
   663 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   664 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   665 	}
       
   666 
       
   667 	// Here we swap the addresses.
       
   668 	eap_am_network_id_c send_network_id(m_am_tools,
       
   669 		receive_network_id->get_destination_id(),
       
   670 		receive_network_id->get_source_id(),
       
   671 		receive_network_id->get_type());
       
   672 	if (send_network_id.get_is_valid_data() == false)
       
   673 	{
       
   674 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   675 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   676 	}
       
   677 
       
   678 	eap_network_id_selector_c selector(
       
   679 		m_am_tools,
       
   680 		&send_network_id);
       
   681 	if (selector.get_is_valid() == false)
       
   682 	{
       
   683 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   684 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   685 	}
       
   686 
       
   687 	if (m_eap_core != 0)
       
   688 	{
       
   689 		status = m_eap_core->eap_acknowledge(
       
   690 			receive_network_id);
       
   691 	}
       
   692 	else
       
   693 	{
       
   694 		// Here we do not care of missing session.
       
   695 		// Acknowledge is meaningfull only for existing session.
       
   696 		status = eap_status_ok;
       
   697 	}
       
   698 
       
   699 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   700 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   701 }
       
   702 
       
   703 //--------------------------------------------------
       
   704 
       
   705 //
       
   706 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::restart_authentication(
       
   707 	const eap_am_network_id_c * const send_network_id,
       
   708 	const bool is_client_when_true)
       
   709 {
       
   710 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   711 
       
   712 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   713 
       
   714 	eap_status_e status = eap_status_process_general_error;
       
   715 
       
   716 	eap_network_id_selector_c selector(
       
   717 		m_am_tools,
       
   718 		send_network_id);
       
   719 	if (selector.get_is_valid() == false)
       
   720 	{
       
   721 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   722 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   723 	}
       
   724 
       
   725 	if (m_eap_core != 0)
       
   726 	{
       
   727 		status = m_eap_core->restart_authentication(send_network_id, is_client_when_true);
       
   728 	}
       
   729 
       
   730 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   731 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   732 }
       
   733 
       
   734 //--------------------------------------------------
       
   735 
       
   736 //
       
   737 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::restart_authentication(
       
   738 	const eap_am_network_id_c * const receive_network_id,
       
   739 	const bool /* is_client_when_true */,
       
   740 	const bool force_clean_restart,
       
   741 	const bool /* from_timer */)
       
   742 {
       
   743 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   744 
       
   745 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   746 
       
   747 	eap_status_e status = eap_status_process_general_error;
       
   748 
       
   749 	// Here we swap the addresses.
       
   750 	eap_am_network_id_c send_network_id(m_am_tools,
       
   751 		receive_network_id->get_destination_id(),
       
   752 		receive_network_id->get_source_id(),
       
   753 		receive_network_id->get_type());
       
   754 	if (send_network_id.get_is_valid_data() == false)
       
   755 	{
       
   756 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   757 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   758 	}
       
   759 
       
   760 	eap_network_id_selector_c selector(
       
   761 		m_am_tools,
       
   762 		&send_network_id);
       
   763 	if (selector.get_is_valid() == false)
       
   764 	{
       
   765 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   766 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   767 	}
       
   768 
       
   769 	if (m_eap_core == 0)
       
   770 	{
       
   771 		// Create a new session.
       
   772 		m_eap_core = create_new_session(receive_network_id);
       
   773 	}
       
   774 
       
   775 	if (m_eap_core != 0)
       
   776 	{
       
   777 		status = m_partner->restart_authentication(
       
   778 			receive_network_id,
       
   779 			m_is_client,
       
   780 			force_clean_restart);
       
   781 	}
       
   782 
       
   783 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   784 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   785 }
       
   786 
       
   787 //--------------------------------------------------
       
   788 
       
   789 #if defined(USE_EAP_CORE_SERVER)
       
   790 
       
   791 //
       
   792 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::send_eap_identity_request(
       
   793 	const eap_am_network_id_c * const receive_network_id)
       
   794 {
       
   795 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   796 
       
   797 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   798 
       
   799 	eap_status_e status = eap_status_process_general_error;
       
   800 
       
   801 	EAP_TRACE_DEBUG(
       
   802 		m_am_tools, 
       
   803 		TRACE_FLAGS_DEFAULT, 
       
   804 		(EAPL("eap_radius_session_c::send_eap_identity_request()\n")));
       
   805 
       
   806 	// Here we swap the addresses.
       
   807 	eap_am_network_id_c send_network_id(m_am_tools,
       
   808 		receive_network_id->get_destination_id(),
       
   809 		receive_network_id->get_source_id(),
       
   810 		receive_network_id->get_type());
       
   811 	if (send_network_id.get_is_valid_data() == false)
       
   812 	{
       
   813 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   814 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   815 	}
       
   816 
       
   817 	eap_network_id_selector_c selector(
       
   818 		m_am_tools,
       
   819 		&send_network_id);
       
   820 	if (selector.get_is_valid() == false)
       
   821 	{
       
   822 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   823 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   824 	}
       
   825 
       
   826 	if (m_eap_core == 0)
       
   827 	{
       
   828 		// Create a new session.
       
   829 		m_eap_core = create_new_session(receive_network_id);
       
   830 	}
       
   831 
       
   832 	if (m_eap_core != 0)
       
   833 	{
       
   834 		status = m_eap_core->send_eap_identity_request(receive_network_id);
       
   835 		(void) EAP_STATUS_RETURN(m_am_tools, status);
       
   836 	}
       
   837 
       
   838 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   839 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   840 }
       
   841 
       
   842 #endif //#if defined(USE_EAP_CORE_SERVER)
       
   843 
       
   844 //--------------------------------------------------
       
   845 
       
   846 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::packet_data_crypto_keys(
       
   847 	const eap_am_network_id_c * const send_network_id,
       
   848 	const eap_master_session_key_c * const master_session_key
       
   849 	)
       
   850 {
       
   851 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   852 
       
   853 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   854 
       
   855 	const eap_status_e status = m_master_session_key.set_copy(
       
   856 		master_session_key);
       
   857 
       
   858 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   859 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   860 }
       
   861 
       
   862 //--------------------------------------------------
       
   863 
       
   864 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::read_configure(
       
   865 	const eap_configuration_field_c * const field,
       
   866 	eap_variable_data_c * const data)
       
   867 {
       
   868 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   869 
       
   870 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   871 
       
   872 	const eap_status_e status = m_partner->read_configure(field, data);
       
   873 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   874 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   875 }
       
   876 
       
   877 //--------------------------------------------------
       
   878 
       
   879 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::write_configure(
       
   880 	const eap_configuration_field_c * const field,
       
   881 	eap_variable_data_c * const data)
       
   882 {
       
   883 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   884 
       
   885 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   886 
       
   887 	const eap_status_e status = m_partner->write_configure(field, data);
       
   888 
       
   889 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   890 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   891 }
       
   892 
       
   893 //--------------------------------------------------
       
   894 
       
   895 //
       
   896 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::timer_expired(
       
   897 	const u32_t id, void *data)
       
   898 {
       
   899 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   900 
       
   901 	EAP_TRACE_DEBUG(
       
   902 		m_am_tools, 
       
   903 		TRACE_FLAGS_DEFAULT, 
       
   904 		(EAPL("TIMER: [0x%08x]->eap_radius_session_c::")
       
   905 		 EAPL("timer_expired(id 0x%02x, data 0x%08x), %s.\n"),
       
   906 		 this,
       
   907 		 id,
       
   908 		 data,
       
   909 		 (m_is_client == true) ? "client": "server"));
       
   910 
       
   911 	if (id == EAP_RADIUS_SESSION_REMOVE_SESSION_ID)
       
   912 	{
       
   913 		EAP_TRACE_DEBUG(
       
   914 			m_am_tools, 
       
   915 			TRACE_FLAGS_DEFAULT, 
       
   916 			(EAPL("TIMER: EAP_RADIUS_SESSION_REMOVE_SESSION_ID elapsed, %s.\n"),
       
   917 			 (m_is_client == true) ? "client": "server"));
       
   918 
       
   919 		reset();
       
   920 	}
       
   921 
       
   922 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   923 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   924 }
       
   925 
       
   926 //--------------------------------------------------
       
   927 
       
   928 //
       
   929 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::timer_delete_data(
       
   930 	const u32_t id, void *data)
       
   931 {
       
   932 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   933 
       
   934 	EAP_TRACE_DEBUG(
       
   935 		m_am_tools, 
       
   936 		TRACE_FLAGS_DEFAULT, 
       
   937 		(EAPL("TIMER: [0x%08x]->eap_radius_session_c::")
       
   938 		 EAPL("timer_delete_data(id 0x%02x, data 0x%08x).\n"),
       
   939 		this, id, data));
       
   940 
       
   941 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   942 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   943 }
       
   944 
       
   945 //--------------------------------------------------
       
   946 
       
   947 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::synchronous_remove_eap_session(
       
   948 	const eap_am_network_id_c * const receive_network_id)
       
   949 {
       
   950 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   951 
       
   952 	// Here we swap the addresses.
       
   953 	eap_am_network_id_c send_network_id(
       
   954 		m_am_tools,
       
   955 		receive_network_id->get_destination_id(),
       
   956 		receive_network_id->get_source_id(),
       
   957 		receive_network_id->get_type());
       
   958 	if (send_network_id.get_is_valid_data() == false)
       
   959 	{
       
   960 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   961 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   962 	}
       
   963 
       
   964 	eap_network_id_selector_c selector(
       
   965 		m_am_tools,
       
   966 		&send_network_id);
       
   967 	if (selector.get_is_valid() == false)
       
   968 	{
       
   969 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   970 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   971 	}
       
   972 
       
   973 	reset();
       
   974 
       
   975 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   976 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   977 }
       
   978 
       
   979 //--------------------------------------------------
       
   980 
       
   981 //
       
   982 eap_status_e eap_radius_session_c::asynchronous_init_remove_eap_session(
       
   983 	const eap_am_network_id_c * const send_network_id)
       
   984 {
       
   985 	EAP_TRACE_DEBUG(
       
   986 		m_am_tools, 
       
   987 		TRACE_FLAGS_DEFAULT, 
       
   988 		(EAPL("eap_radius_session_c::asynchronous_init_remove_eap_session(): %s.\n"),
       
   989 		 (m_is_client == true) ? "client": "server"));
       
   990 
       
   991 		eap_network_id_selector_c state_selector(
       
   992 			m_am_tools,
       
   993 			send_network_id);
       
   994 		if (state_selector.get_is_valid() == false)
       
   995 		{
       
   996 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   997 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   998 		}
       
   999 
       
  1000 		eap_status_e status = asynchronous_init_remove_eap_session(
       
  1001 			&state_selector);
       
  1002 
       
  1003 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1004 }
       
  1005 
       
  1006 //--------------------------------------------------
       
  1007 
       
  1008 //
       
  1009 eap_status_e eap_radius_session_c::asynchronous_init_remove_eap_session(
       
  1010 	const eap_network_id_selector_c * const state_selector)
       
  1011 {
       
  1012 	EAP_TRACE_DEBUG(
       
  1013 		m_am_tools, 
       
  1014 		TRACE_FLAGS_DEFAULT, 
       
  1015 		(EAPL("eap_radius_session_c::asynchronous_init_remove_eap_session(): %s.\n"),
       
  1016 		 (m_is_client == true) ? "client": "server"));
       
  1017 
       
  1018 	// NOTE: we cannot call directly synchronous_remove_eap_session(), because we will
       
  1019 	// return from here to removed object.
       
  1020 
       
  1021 	eap_status_e status = eap_status_process_general_error;
       
  1022 
       
  1023 	if (m_eap_core != 0)
       
  1024 	{
       
  1025 		m_eap_core->set_marked_removed();
       
  1026 
       
  1027 		status = m_partner->set_timer(
       
  1028 			this,
       
  1029 			EAP_RADIUS_SESSION_REMOVE_SESSION_ID, 
       
  1030 			0,
       
  1031 			m_remove_session_timeout);
       
  1032 		if (status != eap_status_ok)
       
  1033 		{
       
  1034 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1035 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1036 		}
       
  1037 
       
  1038 		EAP_TRACE_DEBUG(
       
  1039 			m_am_tools, 
       
  1040 			TRACE_FLAGS_DEFAULT, 
       
  1041 			(EAPL("eap_radius_session_c::asynchronous_init_remove_eap_session()")
       
  1042 			 EAPL(": %s: EAP_RADIUS_SESSION_REMOVE_SESSION_ID timer set.\n"),
       
  1043 			 (m_is_client == true) ? "client": "server"));
       
  1044 	}
       
  1045 	else
       
  1046 	{
       
  1047 		// Not found, cannot remove.
       
  1048 		EAP_TRACE_DEBUG(
       
  1049 			m_am_tools, 
       
  1050 			TRACE_FLAGS_DEFAULT, 
       
  1051 			(EAPL("ERROR: eap_radius_session_c::asynchronous_init_remove_eap_session()")
       
  1052 			 EAPL(": %s: failed session not found.\n"),
       
  1053 			 (m_is_client == true) ? "client": "server"));
       
  1054 
       
  1055 		status = eap_status_ok;
       
  1056 	}
       
  1057 
       
  1058 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1059 }
       
  1060 
       
  1061 //--------------------------------------------------
       
  1062 
       
  1063 EAP_FUNC_EXPORT void eap_radius_session_c::state_notification(
       
  1064 	const abs_eap_state_notification_c * const state)
       
  1065 {
       
  1066 	if (state->get_protocol_layer() == eap_protocol_layer_eap)
       
  1067 	{
       
  1068 		if (m_state == eap_state_authentication_terminated_unsuccessfully)
       
  1069 		{
       
  1070 			EAP_TRACE_DEBUG(
       
  1071 				m_am_tools, 
       
  1072 				TRACE_FLAGS_DEFAULT, 
       
  1073 				(EAPL("ERROR: session already failed.\n")));
       
  1074 			return;
       
  1075 		}
       
  1076 
       
  1077 		m_state = static_cast<eap_state_variable_e>(state->get_current_state());
       
  1078 
       
  1079 		if (state->get_current_state() == eap_state_identity_response_received)
       
  1080 		{
       
  1081 			EAP_TRACE_DEBUG(
       
  1082 				m_am_tools, 
       
  1083 				TRACE_FLAGS_DEFAULT, 
       
  1084 				(EAPL("EAP-Response/Identity received:\n")));
       
  1085 		}
       
  1086 		else if (state->get_current_state() == eap_state_identity_request_received)
       
  1087 		{
       
  1088 			EAP_TRACE_DEBUG(
       
  1089 				m_am_tools, 
       
  1090 				TRACE_FLAGS_DEFAULT, 
       
  1091 				(EAPL("EAP-Request/Identity received:\n")));
       
  1092 		}
       
  1093 		else if (state->get_current_state() == eap_state_authentication_terminated_unsuccessfully)
       
  1094 		{
       
  1095 			EAP_TRACE_DEBUG(
       
  1096 				m_am_tools,
       
  1097 				TRACE_FLAGS_DEFAULT,
       
  1098 				(EAPL("radius_server_c::state_notification(): ")
       
  1099 				 EAPL("Protocol layer %d, EAP type 0x%02x, State transition from ")
       
  1100 				 EAPL("%d=%s to %d=%s, client %d when shutdown was called.\n"),
       
  1101 				 state->get_protocol_layer(), 
       
  1102 				 state->get_protocol(), 
       
  1103 				 state->get_previous_state(), 
       
  1104 				 state->get_previous_state_string(), 
       
  1105 				 state->get_current_state(), 
       
  1106 				 state->get_current_state_string(),
       
  1107 				 state->get_is_client()));
       
  1108 		}
       
  1109 		else if (state->get_current_state() == eap_state_authentication_finished_successfully)
       
  1110 		{
       
  1111 			EAP_TRACE_DEBUG(
       
  1112 				m_am_tools,
       
  1113 				TRACE_FLAGS_DEFAULT,
       
  1114 				(EAPL("radius_server_c::state_notification(): ")
       
  1115 				 EAPL("Protocol layer %d, EAP type 0x%02x, State transition from ")
       
  1116 				 EAPL("%d=%s to %d=%s, client %d when shutdown was called.\n"),
       
  1117 				 state->get_protocol_layer(), 
       
  1118 				 state->get_protocol(), 
       
  1119 				 state->get_previous_state(), 
       
  1120 				 state->get_previous_state_string(), 
       
  1121 				 state->get_current_state(), 
       
  1122 				 state->get_current_state_string(),
       
  1123 				 state->get_is_client()));
       
  1124 		}
       
  1125 	}
       
  1126 }
       
  1127 
       
  1128 //--------------------------------------------------
       
  1129 
       
  1130 //
       
  1131 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::set_timer(
       
  1132 	abs_eap_base_timer_c * const p_initializer, 
       
  1133 	const u32_t p_id, 
       
  1134 	void * const p_data,
       
  1135 	const u32_t p_time_ms)
       
  1136 {
       
  1137 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1138 
       
  1139 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1140 
       
  1141 	const eap_status_e status = m_partner->set_timer(
       
  1142 		p_initializer, 
       
  1143 		p_id, 
       
  1144 		p_data,
       
  1145 		p_time_ms);
       
  1146 
       
  1147 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1148 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1149 }
       
  1150 
       
  1151 //--------------------------------------------------
       
  1152 
       
  1153 //
       
  1154 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::cancel_timer(
       
  1155 	abs_eap_base_timer_c * const p_initializer, 
       
  1156 	const u32_t p_id)
       
  1157 {
       
  1158 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1159 
       
  1160 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1161 
       
  1162 	const eap_status_e status = m_partner->cancel_timer(
       
  1163 		p_initializer, 
       
  1164 		p_id);
       
  1165 
       
  1166 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1167 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1168 }
       
  1169 
       
  1170 //--------------------------------------------------
       
  1171 
       
  1172 //
       
  1173 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::cancel_all_timers()
       
  1174 {
       
  1175 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1176 
       
  1177 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1178 
       
  1179 	const eap_status_e status = m_partner->cancel_all_timers();
       
  1180 
       
  1181 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1182 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1183 }
       
  1184 
       
  1185 //--------------------------------------------------
       
  1186 
       
  1187 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::check_is_valid_eap_type(
       
  1188 	const eap_type_value_e eap_type)
       
  1189 {
       
  1190 	eap_status_e status = m_partner->check_is_valid_eap_type(eap_type);
       
  1191 
       
  1192 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1193 }
       
  1194 
       
  1195 //--------------------------------------------------
       
  1196 
       
  1197 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::get_eap_type_list(
       
  1198 	eap_array_c<eap_type_value_e> * const eap_type_list)
       
  1199 {
       
  1200 	eap_status_e status = m_partner->get_eap_type_list(eap_type_list);
       
  1201 
       
  1202 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1203 }
       
  1204 
       
  1205 //--------------------------------------------------
       
  1206 
       
  1207 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::add_rogue_ap(
       
  1208 	eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list)
       
  1209 {
       
  1210 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1211 
       
  1212 	const eap_status_e status = m_partner->add_rogue_ap(rogue_ap_list);
       
  1213 
       
  1214 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1215 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1216 }
       
  1217 
       
  1218 //--------------------------------------------------
       
  1219 
       
  1220 //
       
  1221 EAP_FUNC_EXPORT eap_status_e eap_radius_session_c::set_session_timeout(
       
  1222 	const u32_t /* session_timeout_ms */)
       
  1223 {
       
  1224 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1225 
       
  1226 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1227 
       
  1228 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1229 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
  1230 }
       
  1231 
       
  1232 //--------------------------------------------------
       
  1233 
       
  1234 
       
  1235 
       
  1236 // End.