eapol/eapol_framework/eapol_common/core/eap_core_server_message_if.cpp
changeset 26 9abfd4f00d37
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 29 %
       
    20 */
       
    21 
       
    22 // This is enumeration of EAPOL source code.
       
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    24 	#undef EAP_FILE_NUMBER_ENUM
       
    25 	#define EAP_FILE_NUMBER_ENUM 48 
       
    26 	#undef EAP_FILE_NUMBER_DATE 
       
    27 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    29 
       
    30 
       
    31 
       
    32 #include "eap_am_memory.h"
       
    33 #include "eap_tools.h"
       
    34 #include "eap_core_server_message_if.h"
       
    35 #include "eap_crypto_api.h"
       
    36 #include "eap_state_notification.h"
       
    37 #include "eap_automatic_variable.h"
       
    38 #include "eap_network_id_selector.h"
       
    39 #include "eap_config.h"
       
    40 #include "eap_buffer.h"
       
    41 #include "eapol_session_key.h"
       
    42 #include "eap_master_session_key.h"
       
    43 #include "eap_am_stack.h"
       
    44 
       
    45 //--------------------------------------------------
       
    46 
       
    47 // 
       
    48 EAP_FUNC_EXPORT eap_core_server_message_if_c::~eap_core_server_message_if_c()
       
    49 {
       
    50 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    51 
       
    52 	EAP_TRACE_DEBUG(
       
    53 		m_am_tools, 
       
    54 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
    55 		(EAPL("eap_core_server_message_if_c::~eap_core_server_message_if_c(): this = 0x%08x\n"),
       
    56 		this));
       
    57 
       
    58 	EAP_ASSERT(m_shutdown_was_called == true);
       
    59 
       
    60 	delete m_eap_core;
       
    61 	delete m_am_stack;
       
    62 
       
    63 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    64 }
       
    65 
       
    66 //--------------------------------------------------
       
    67 
       
    68 #if defined(_WIN32) && !defined(__GNUC__)
       
    69 	#pragma warning( disable : 4355 ) // 'this' : used in base member initializer list
       
    70 #endif
       
    71 
       
    72 // 
       
    73 EAP_FUNC_EXPORT eap_core_server_message_if_c::eap_core_server_message_if_c(
       
    74 	abs_eap_am_tools_c * const tools,
       
    75 	const bool is_client_when_true,
       
    76 	const u32_t MTU)
       
    77 	: m_partner(0)
       
    78 	, m_eap_core(eap_session_core_base_c::new_eap_session_core_c(tools, this, is_client_when_true, MTU))
       
    79 	, m_am_stack(new_eap_am_stack_c(tools, is_client_when_true))
       
    80 	, m_am_tools(tools)
       
    81 	, m_eap_header_offset(0u)
       
    82 	, m_MTU(MTU)
       
    83 	, m_trailer_length(0u)
       
    84 	, m_error_code(eap_status_ok)
       
    85 	, m_error_function(eap_tlv_message_type_function_none)
       
    86 	, m_is_client(is_client_when_true)
       
    87 	, m_is_valid(false)
       
    88 	, m_shutdown_was_called(false)
       
    89 {
       
    90 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    91 
       
    92 	EAP_TRACE_DEBUG(
       
    93 		m_am_tools, 
       
    94 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
    95 		(EAPL("eap_core_server_message_if_c::eap_core_server_message_if_c(): %s, this = 0x%08x => 0x%08x, compiled %s %s.\n"),
       
    96 		(m_is_client == true) ? "client": "server",
       
    97 		this,
       
    98 		dynamic_cast<abs_eap_base_timer_c *>(this),
       
    99 		__DATE__,
       
   100 		__TIME__));
       
   101 
       
   102 	if (m_eap_core != 0
       
   103 		&& m_eap_core->get_is_valid() == true
       
   104 		&& m_am_stack != 0
       
   105 		&& m_am_stack->get_is_valid() == true)
       
   106 	{
       
   107 		set_is_valid();
       
   108 	}
       
   109 
       
   110 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   111 }
       
   112 
       
   113 //--------------------------------------------------
       
   114 
       
   115 //
       
   116 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::configure(
       
   117 	const eap_variable_data_c * const client_configuration)
       
   118 {
       
   119 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   120 
       
   121 	EAP_TRACE_DEBUG(
       
   122 		m_am_tools,
       
   123 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   124 		(EAPL("%s: eap_core_server_message_if_c::configure()\n"),
       
   125 		(m_is_client == true) ? "client": "server"));
       
   126 
       
   127 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::configure()");
       
   128 
       
   129 	eap_status_e status(eap_status_process_general_error);
       
   130 
       
   131 	m_eap_header_offset = 0ul;
       
   132 	m_trailer_length = 0ul;
       
   133 
       
   134 	if (m_am_stack != 0)
       
   135 	{
       
   136 		status = m_am_stack->set_partner(
       
   137 			this
       
   138 #if defined(USE_EAP_SIMPLE_CONFIG)
       
   139 			, this
       
   140 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
       
   141 			);
       
   142 		if (status != eap_status_ok)
       
   143 		{
       
   144 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   145 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   146 		}
       
   147 
       
   148 		status = m_am_stack->configure(client_configuration);
       
   149 		if (status != eap_status_ok)
       
   150 		{
       
   151 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   152 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   153 		}
       
   154 	}
       
   155 	
       
   156 	if (m_eap_core != 0)
       
   157 	{
       
   158 		status = m_eap_core->configure();
       
   159 		if (status != eap_status_ok)
       
   160 		{
       
   161 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   162 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   163 		}
       
   164 	}
       
   165 
       
   166 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   167 }
       
   168 
       
   169 //--------------------------------------------------
       
   170 
       
   171 //
       
   172 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::shutdown()
       
   173 {
       
   174 	EAP_TRACE_DEBUG(
       
   175 		m_am_tools,
       
   176 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   177 		(EAPL("%s: eap_core_server_message_if_c::shutdown(), m_shutdown_was_called=%d\n"),
       
   178 		(m_is_client == true) ? "client": "server",
       
   179 		m_shutdown_was_called));
       
   180 
       
   181 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::shutdown()");
       
   182 
       
   183 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   184 
       
   185 	if (m_shutdown_was_called == true)
       
   186 	{
       
   187 		// Shutdown function was called already.
       
   188 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   189 	}
       
   190 	m_shutdown_was_called = true;
       
   191 
       
   192 	if (m_eap_core != 0)
       
   193 	{
       
   194 		(void) m_eap_core->shutdown();
       
   195 	}
       
   196 
       
   197 	if (m_am_stack != 0)
       
   198 	{
       
   199 		(void) m_am_stack->shutdown();
       
   200 	}
       
   201 
       
   202 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   203 }
       
   204 
       
   205 //--------------------------------------------------
       
   206 
       
   207 //
       
   208 EAP_FUNC_EXPORT void eap_core_server_message_if_c::set_partner(abs_eap_am_message_if_c * const partner)
       
   209 {
       
   210 	m_partner = partner;
       
   211 }
       
   212 
       
   213 //--------------------------------------------------
       
   214 
       
   215 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::send_error_message(
       
   216 	const eap_status_e error_code,
       
   217 	const eap_tlv_message_type_function_e function)
       
   218 {
       
   219 	eap_status_e status(eap_status_ok);
       
   220 
       
   221 	{
       
   222 		// Creates message data composed of Attribute-Value Pairs.
       
   223 		eap_process_tlv_message_data_c message(m_am_tools);
       
   224 
       
   225 		if (message.get_is_valid() == false)
       
   226 		{
       
   227 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   228 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   229 		}
       
   230 
       
   231 		status = message.add_parameter_data(
       
   232 			eap_tlv_message_type_error,
       
   233 			static_cast<u32_t>(error_code));
       
   234 		if (status != eap_status_ok)
       
   235 		{
       
   236 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   237 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   238 		}
       
   239 
       
   240 		status = message.add_parameter_data(function);
       
   241 		if (status != eap_status_ok)
       
   242 		{
       
   243 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   244 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   245 		}
       
   246 
       
   247 		status = send_message(&message);
       
   248 		if (status != eap_status_ok)
       
   249 		{
       
   250 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   251 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   252 		}
       
   253 	}
       
   254 
       
   255 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   256 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   257 }
       
   258 
       
   259 //--------------------------------------------------
       
   260 
       
   261 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::send_message(eap_process_tlv_message_data_c * const message)
       
   262 {
       
   263 	// Sends message data composed of Attribute-Value Pairs.
       
   264 
       
   265 	EAP_TRACE_DATA_DEBUG(
       
   266 		m_am_tools,
       
   267 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   268 		(EAPL("eap_core_client_message_if_c::send_message()"),
       
   269 		message->get_message_data(),
       
   270 		message->get_message_data_length()));
       
   271 
       
   272 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_client_message_if_c::send_message()");
       
   273 
       
   274 
       
   275 	{
       
   276 		eap_status_e send_status = m_partner->send_data(
       
   277 			message->get_message_data(),
       
   278 			message->get_message_data_length());
       
   279 		if (send_status != eap_status_ok)
       
   280 		{
       
   281 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   282 			return EAP_STATUS_RETURN(m_am_tools, send_status);
       
   283 		}
       
   284 
       
   285 
       
   286 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   287 		return EAP_STATUS_RETURN(m_am_tools, send_status);
       
   288 	}
       
   289 
       
   290 }
       
   291 
       
   292 //--------------------------------------------------
       
   293 
       
   294 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::process_message_type_error(
       
   295 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   296 {
       
   297 	eap_status_e status(eap_status_ok);
       
   298 
       
   299 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   300 
       
   301 	if (message_data.get_is_valid() == false)
       
   302 	{
       
   303 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   304 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   305 	}
       
   306 
       
   307 	// Error payload is the first in this case.
       
   308 	status = message_data.read_parameter_data(parameters, eap_message_payload_index_function, eap_tlv_message_type_error, &m_error_code);
       
   309 	if (status != eap_status_ok)
       
   310 	{
       
   311 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   312 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   313 	}
       
   314 
       
   315 	// Fuction payload is the second in this case.
       
   316 	status = message_data.read_parameter_data(parameters, eap_message_payload_index_first_parameter, &m_error_function);
       
   317 	if (status != eap_status_ok)
       
   318 	{
       
   319 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   320 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   321 	}
       
   322 
       
   323 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   324 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   325 }
       
   326 
       
   327 //--------------------------------------------------
       
   328 
       
   329 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::process_message(eap_process_tlv_message_data_c * const message)
       
   330 {
       
   331 	// Parses message data composed of Attribute-Value Pairs.
       
   332 
       
   333 	EAP_TRACE_DATA_DEBUG(
       
   334 		m_am_tools,
       
   335 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   336 		(EAPL("eap_core_server_message_if_c::process_message()"),
       
   337 		message->get_message_data(),
       
   338 		message->get_message_data_length()));
       
   339 
       
   340 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::process_message()");
       
   341 
       
   342 	eap_array_c<eap_tlv_header_c> parameters(m_am_tools);
       
   343 
       
   344 	eap_status_e status = message->parse_message_data(&parameters);
       
   345 	if (status != eap_status_ok)
       
   346 	{
       
   347 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   348 
       
   349 		(void) send_error_message(
       
   350 			status,
       
   351 			eap_tlv_message_type_function_none);
       
   352 
       
   353 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   354 	}
       
   355 
       
   356 	if (parameters.get_object_count() == 0)
       
   357 	{
       
   358 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   359 
       
   360 		status = eap_status_illegal_parameter;
       
   361 
       
   362 		(void) send_error_message(
       
   363 			status,
       
   364 			eap_tlv_message_type_function_none);
       
   365 
       
   366 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   367 	}
       
   368 
       
   369 	const eap_tlv_header_c * const function_header = parameters.get_object(eap_message_payload_index_function);
       
   370 	if (function_header == 0
       
   371 		|| (function_header->get_type() != eap_tlv_message_type_error
       
   372 			&& function_header->get_type() != eap_tlv_message_type_function))
       
   373 	{
       
   374 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   375 
       
   376 		status = eap_status_illegal_parameter;
       
   377 
       
   378 		(void) send_error_message(
       
   379 			status,
       
   380 			eap_tlv_message_type_function_none);
       
   381 
       
   382 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   383 	}
       
   384 
       
   385 	if (function_header->get_type() == eap_tlv_message_type_error)
       
   386 	{
       
   387 		status = process_message_type_error(&parameters);
       
   388 	}
       
   389 	else // function_header->get_type() == eap_tlv_message_type_function
       
   390 	{
       
   391 		eap_tlv_message_type_function_e function(eap_tlv_message_type_function_none);
       
   392 
       
   393 		status = message->get_parameter_data(function_header, &function);
       
   394 		if (status != eap_status_ok)
       
   395 		{
       
   396 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   397 
       
   398 			(void) send_error_message(
       
   399 				status,
       
   400 				eap_tlv_message_type_function_none);
       
   401 
       
   402 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   403 		}
       
   404 
       
   405 		switch(function)
       
   406 		{
       
   407 		case eap_tlv_message_type_function_create_eap_session:
       
   408 			status = create_eap_session(&parameters);
       
   409 			break;
       
   410 		case eap_tlv_message_type_function_remove_eap_session:
       
   411 			status = remove_eap_session(&parameters);
       
   412 			break;
       
   413 		case eap_tlv_message_type_function_send_eap_identity_request:
       
   414 			status = send_eap_identity_request(&parameters);
       
   415 			break;
       
   416 		case eap_tlv_message_type_function_packet_process:
       
   417 			status = packet_process(&parameters);
       
   418 			break;
       
   419 		case eap_tlv_message_type_function_eap_acknowledge:
       
   420 			status = eap_acknowledge(&parameters);
       
   421 			break;
       
   422 		case eap_tlv_message_type_function_set_eap_database_reference_values:
       
   423 			status = set_eap_database_reference_values(&parameters);
       
   424 			break;
       
   425 		case eap_tlv_message_type_function_eap_mtu:
       
   426 			status = eap_mtu(&parameters);
       
   427 			break;
       
   428 		case eap_tlv_message_type_function_get_802_11_authentication_mode:
       
   429 			status = get_802_11_authentication_mode(&parameters);
       
   430 			break;
       
   431 		default:
       
   432 			EAP_TRACE_ERROR(
       
   433 				m_am_tools,
       
   434 				TRACE_FLAGS_DEFAULT,
       
   435 				(EAPL("ERROR: process_data(): unknown function %d.\n"),
       
   436 				 function));
       
   437 
       
   438 			status = eap_status_illegal_parameter;
       
   439 
       
   440 			EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
   441 		};
       
   442 
       
   443 		if (status != eap_status_ok
       
   444 			&& status != eap_status_success
       
   445 			&& status != eap_status_pending_request
       
   446 			&& status != eap_status_completed_request
       
   447 			&& status != eap_status_drop_packet_quietly)
       
   448 		{
       
   449 			(void) send_error_message(
       
   450 				status,
       
   451 				function);
       
   452 		}
       
   453 	}
       
   454 
       
   455 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   456 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   457 }
       
   458 
       
   459 //--------------------------------------------------
       
   460 
       
   461 /// Function receives the data message from lower layer.
       
   462 /// Data is formatted to Attribute-Value Pairs.
       
   463 /// Look at eap_tlv_header_c and eap_tlv_message_data_c.
       
   464 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::process_data(const void * const data, const u32_t length)
       
   465 {
       
   466 	eap_status_e status(eap_status_process_general_error);
       
   467 
       
   468 	{
       
   469 		eap_process_tlv_message_data_c message(m_am_tools);
       
   470 
       
   471 		if (message.get_is_valid() == false)
       
   472 		{
       
   473 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   474 
       
   475 			status = eap_status_allocation_error;
       
   476 
       
   477 			(void) send_error_message(
       
   478 				status,
       
   479 				eap_tlv_message_type_function_none);
       
   480 
       
   481 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   482 		}
       
   483 
       
   484 		status = message.set_message_data(length, data);
       
   485 		if (status != eap_status_ok)
       
   486 		{
       
   487 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   488 
       
   489 			(void) send_error_message(
       
   490 				status,
       
   491 				eap_tlv_message_type_function_none);
       
   492 
       
   493 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   494 		}
       
   495 
       
   496 		status = process_message(&message);
       
   497 	}
       
   498 
       
   499 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   500 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   501 }
       
   502 
       
   503 //--------------------------------------------------
       
   504 
       
   505 //
       
   506 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::packet_send(
       
   507 	const eap_am_network_id_c * const send_network_id,
       
   508 	eap_buf_chain_wr_c * const sent_packet,
       
   509 	const u32_t header_offset,
       
   510 	const u32_t data_length,
       
   511 	const u32_t buffer_length)
       
   512 {
       
   513 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   514 
       
   515 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   516 	EAP_ASSERT(header_offset < sent_packet->get_data_length());
       
   517 	EAP_ASSERT(data_length <= sent_packet->get_data_length());
       
   518 	EAP_ASSERT(sent_packet->get_data_length() <= buffer_length);
       
   519 
       
   520 	eap_status_e status(eap_status_process_general_error);
       
   521 
       
   522 	if (sent_packet->get_do_length_checks() == true)
       
   523 	{
       
   524 		if (header_offset != 0ul)
       
   525 		{
       
   526 			EAP_TRACE_ERROR(
       
   527 				m_am_tools,
       
   528 				TRACE_FLAGS_DEFAULT,
       
   529 				(EAPL("ERROR: packet_send: packet buffer corrupted (header_offset != %d).\n"),
       
   530 				0ul));
       
   531 			EAP_ASSERT_ALWAYS(header_offset == 0ul);
       
   532 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   533 		}
       
   534 		else if (header_offset+data_length != sent_packet->get_data_length())
       
   535 		{
       
   536 			EAP_TRACE_ERROR(
       
   537 				m_am_tools,
       
   538 				TRACE_FLAGS_DEFAULT,
       
   539 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   540 				 EAPL("(data_length %d != sent_packet->get_data_length() %d).\n"),
       
   541 				 header_offset+data_length,
       
   542 				 sent_packet->get_data_length()));
       
   543 			EAP_ASSERT_ALWAYS(data_length == sent_packet->get_buffer_length());
       
   544 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   545 		}
       
   546 		else if (header_offset+data_length > buffer_length)
       
   547 		{
       
   548 			EAP_TRACE_ERROR(
       
   549 				m_am_tools,
       
   550 				TRACE_FLAGS_DEFAULT,
       
   551 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   552 				 EAPL("(header_offset+data_length %d > buffer_length %d).\n"),
       
   553 				 header_offset+data_length,
       
   554 				 buffer_length));
       
   555 			EAP_ASSERT_ALWAYS(header_offset+data_length <= buffer_length);
       
   556 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   557 		}
       
   558 		else if (header_offset+data_length > m_MTU)
       
   559 		{
       
   560 			EAP_TRACE_ERROR(
       
   561 				m_am_tools,
       
   562 				TRACE_FLAGS_DEFAULT,
       
   563 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   564 				 EAPL("(header_offset+data_length %d > m_MTU %d).\n"),
       
   565 				 header_offset+data_length,
       
   566 				 m_MTU));
       
   567 			EAP_ASSERT_ALWAYS(header_offset+data_length <= m_MTU);
       
   568 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   569 		}
       
   570 	}
       
   571 	else
       
   572 	{
       
   573 		// Always we need at least the EAP header.
       
   574 		if (sent_packet->get_data_length()
       
   575 			< eap_header_base_c::get_header_length())
       
   576 		{
       
   577 			EAP_TRACE_ERROR(
       
   578 				m_am_tools,
       
   579 				TRACE_FLAGS_DEFAULT,
       
   580 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   581 				 EAPL("(sent_packet->get_data_length() %d < ")
       
   582 				 EAPL("eap_header_base_c::get_header_length() %d).\n"),
       
   583 				 sent_packet->get_data_length(),
       
   584 				 eap_header_base_c::get_header_length()));
       
   585 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   586 		}
       
   587 	}
       
   588 	
       
   589 	{
       
   590 		// Creates message data composed of Attribute-Value Pairs.
       
   591 		eap_process_tlv_message_data_c message(m_am_tools);
       
   592 
       
   593 		if (message.get_is_valid() == false)
       
   594 		{
       
   595 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   596 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   597 		}
       
   598 
       
   599 		status = message.add_parameter_data(eap_tlv_message_type_function_packet_send);
       
   600 		if (status != eap_status_ok)
       
   601 		{
       
   602 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   603 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   604 		}
       
   605 
       
   606 		status = message.add_parameter_data(send_network_id);
       
   607 		if (status != eap_status_ok)
       
   608 		{
       
   609 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   610 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   611 		}
       
   612 
       
   613 		status = message.add_parameter_data(sent_packet);
       
   614 		if (status != eap_status_ok)
       
   615 		{
       
   616 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   617 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   618 		}
       
   619 
       
   620 		status = send_message(&message);
       
   621 		if (status != eap_status_ok)
       
   622 		{
       
   623 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   624 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   625 		}
       
   626 	}
       
   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 u32_t eap_core_server_message_if_c::get_header_offset(
       
   636 	u32_t * const MTU,
       
   637 	u32_t * const trailer_length)
       
   638 {
       
   639 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   640 
       
   641 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   642 
       
   643 	const u32_t offset = 0ul;
       
   644 
       
   645 	*MTU = m_MTU;
       
   646 	*trailer_length = m_trailer_length;
       
   647 
       
   648 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   649 	return offset;
       
   650 }
       
   651 
       
   652 //--------------------------------------------------
       
   653 
       
   654 //
       
   655 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::load_module(
       
   656 	const eap_type_value_e type,
       
   657 	const eap_type_value_e tunneling_type,
       
   658 	abs_eap_base_type_c * const partner,
       
   659 	eap_base_type_c ** const eap_type,
       
   660 	const bool is_client_when_true,
       
   661 	const eap_am_network_id_c * const receive_network_id)
       
   662 {
       
   663 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   664 
       
   665 	eap_status_e status = m_am_stack->load_module(
       
   666 		type,
       
   667 		tunneling_type,
       
   668 		partner,
       
   669 		eap_type,
       
   670 		is_client_when_true,
       
   671 		receive_network_id);
       
   672 
       
   673 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   674 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   675 }
       
   676 
       
   677 //--------------------------------------------------
       
   678 
       
   679 //
       
   680 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::unload_module(const eap_type_value_e type)
       
   681 {
       
   682 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   683 
       
   684 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   685 
       
   686 	eap_status_e status(eap_status_process_general_error);
       
   687 
       
   688 	EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
   689 
       
   690 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   691 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   692 }
       
   693 
       
   694 //--------------------------------------------------
       
   695 
       
   696 //
       
   697 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::packet_data_crypto_keys(
       
   698 	const eap_am_network_id_c * const send_network_id,
       
   699 	const eap_master_session_key_c * const master_session_key
       
   700 	)
       
   701 {
       
   702 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   703 
       
   704 	EAP_TRACE_DEBUG(
       
   705 		m_am_tools,
       
   706 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   707 		(EAPL("%s: eap_core_server_message_if_c::packet_data_crypto_keys()\n"),
       
   708 		(m_is_client == true) ? "client": "server"));
       
   709 
       
   710 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::packet_data_crypto_keys()");
       
   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 	if (master_session_key == 0
       
   717 		|| master_session_key->get_is_valid() == false)
       
   718 	{
       
   719 		EAP_TRACE_DEBUG(
       
   720 			m_am_tools,
       
   721 			TRACE_FLAGS_DEFAULT,
       
   722 			(EAPL("ERROR: eap_core_server_message_if_c::packet_data_crypto_keys(), invalid key.\n")));
       
   723 		return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error);
       
   724 	}
       
   725 	
       
   726 	EAP_TRACE_DATA_DEBUG(
       
   727 		m_am_tools,
       
   728 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   729 		(EAPL("eap_core_server_message_if_c::packet_data_crypto_keys(): master_session_key"), 
       
   730 		 master_session_key->get_data(),
       
   731 		 master_session_key->get_data_length()));
       
   732 	
       
   733 	{
       
   734 		// Creates message data composed of Attribute-Value Pairs.
       
   735 		eap_process_tlv_message_data_c message(m_am_tools);
       
   736 
       
   737 		if (message.get_is_valid() == false)
       
   738 		{
       
   739 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   740 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   741 		}
       
   742 
       
   743 		status = message.add_parameter_data(eap_tlv_message_type_function_packet_data_crypto_keys);
       
   744 		if (status != eap_status_ok)
       
   745 		{
       
   746 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   747 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   748 		}
       
   749 
       
   750 		status = message.add_parameter_data(send_network_id);
       
   751 		if (status != eap_status_ok)
       
   752 		{
       
   753 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   754 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   755 		}
       
   756 
       
   757 		// This adds only the EAP-type.
       
   758 		status = message.add_parameter_data(master_session_key->get_eap_type());
       
   759 		if (status != eap_status_ok)
       
   760 		{
       
   761 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   762 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   763 		}
       
   764 
       
   765 		// This adds only the eap_variable_data.
       
   766 		status = message.add_parameter_data(master_session_key);
       
   767 		if (status != eap_status_ok)
       
   768 		{
       
   769 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   770 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   771 		}
       
   772 
       
   773 		status = send_message(&message);
       
   774 		if (status != eap_status_ok)
       
   775 		{
       
   776 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   777 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   778 		}
       
   779 	}
       
   780 
       
   781 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   782 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   783 }
       
   784 
       
   785 //--------------------------------------------------
       
   786 
       
   787 //
       
   788 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::complete_get_802_11_authentication_mode(
       
   789 	const eap_status_e completion_status,
       
   790 	const eap_am_network_id_c * const receive_network_id,
       
   791 	const eapol_key_802_11_authentication_mode_e mode)
       
   792 {
       
   793 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   794 
       
   795 	EAP_TRACE_DEBUG(
       
   796 		m_am_tools,
       
   797 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   798 		(EAPL("%s: eap_core_server_message_if_c::complete_get_802_11_authentication_mode()\n"),
       
   799 		(m_is_client == true) ? "client": "server"));
       
   800 
       
   801 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::complete_get_802_11_authentication_mode()");
       
   802 
       
   803 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   804 
       
   805 	eap_status_e status(eap_status_process_general_error);
       
   806 
       
   807 	{
       
   808 		// Creates message data composed of Attribute-Value Pairs.
       
   809 		eap_process_tlv_message_data_c message(m_am_tools);
       
   810 
       
   811 		if (message.get_is_valid() == 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 		status = message.add_parameter_data(eap_tlv_message_type_function_complete_get_802_11_authentication_mode);
       
   818 		if (status != eap_status_ok)
       
   819 		{
       
   820 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   821 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   822 		}
       
   823 
       
   824 		status = message.add_parameter_data(completion_status);
       
   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 		status = message.add_parameter_data(receive_network_id);
       
   832 		if (status != eap_status_ok)
       
   833 		{
       
   834 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   835 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   836 		}
       
   837 
       
   838 		status = message.add_parameter_data(mode);
       
   839 		if (status != eap_status_ok)
       
   840 		{
       
   841 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   842 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   843 		}
       
   844 
       
   845 		status = send_message(&message);
       
   846 		if (status != eap_status_ok)
       
   847 		{
       
   848 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   849 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   850 		}
       
   851 	}
       
   852 
       
   853 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   854 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   855 }
       
   856 
       
   857 //--------------------------------------------------
       
   858 
       
   859 //
       
   860 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::complete_remove_eap_session(
       
   861 	const bool complete_to_lower_layer,
       
   862 	const eap_am_network_id_c * const receive_network_id)
       
   863 {
       
   864 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   865 
       
   866 	EAP_TRACE_DEBUG(
       
   867 		m_am_tools,
       
   868 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   869 		(EAPL("%s: eap_core_server_message_if_c::complete_remove_eap_session(): complete_to_lower_layer=%s\n"),
       
   870 		(m_is_client == true) ? "client": "server",
       
   871 		(complete_to_lower_layer == true) ? "true": "false"));
       
   872 
       
   873 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::complete_remove_eap_session()");
       
   874 
       
   875 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   876 
       
   877 	eap_status_e status(eap_status_process_general_error);
       
   878 
       
   879 	{
       
   880 		// Creates message data composed of Attribute-Value Pairs.
       
   881 		eap_process_tlv_message_data_c message(m_am_tools);
       
   882 
       
   883 		if (message.get_is_valid() == false)
       
   884 		{
       
   885 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   886 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   887 		}
       
   888 
       
   889 		status = message.add_parameter_data(eap_tlv_message_type_function_complete_remove_eap_session);
       
   890 		if (status != eap_status_ok)
       
   891 		{
       
   892 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   893 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   894 		}
       
   895 
       
   896 		status = message.add_parameter_data(complete_to_lower_layer);
       
   897 		if (status != eap_status_ok)
       
   898 		{
       
   899 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   900 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   901 		}
       
   902 
       
   903 		status = message.add_parameter_data(receive_network_id);
       
   904 		if (status != eap_status_ok)
       
   905 		{
       
   906 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   907 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   908 		}
       
   909 
       
   910 		status = send_message(&message);
       
   911 		if (status != eap_status_ok)
       
   912 		{
       
   913 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   914 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   915 		}
       
   916 	}
       
   917 
       
   918 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   919 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   920 }
       
   921 
       
   922 //--------------------------------------------------
       
   923 
       
   924 //
       
   925 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::read_configure(
       
   926 	const eap_configuration_field_c * const field,
       
   927 	eap_variable_data_c * const data)
       
   928 {
       
   929 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   930 
       
   931 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   932 
       
   933 	eap_status_e status = m_am_stack->read_configure(
       
   934 		field,
       
   935 		data);
       
   936 
       
   937 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   938 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   939 }
       
   940 
       
   941 //--------------------------------------------------
       
   942 
       
   943 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::write_configure(
       
   944 	const eap_configuration_field_c * const field,
       
   945 	eap_variable_data_c * const data)
       
   946 {
       
   947 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   948 
       
   949 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   950 
       
   951 	eap_status_e status(eap_status_process_general_error);
       
   952 
       
   953 	EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
   954 
       
   955 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   956 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   957 }
       
   958 
       
   959 //--------------------------------------------------
       
   960 
       
   961 //
       
   962 EAP_FUNC_EXPORT void eap_core_server_message_if_c::set_is_valid()
       
   963 {
       
   964 	m_is_valid = true;
       
   965 }
       
   966 
       
   967 //--------------------------------------------------
       
   968 
       
   969 //
       
   970 EAP_FUNC_EXPORT bool eap_core_server_message_if_c::get_is_valid()
       
   971 {
       
   972 	return m_is_valid;
       
   973 }
       
   974 
       
   975 //--------------------------------------------------
       
   976 
       
   977 //
       
   978 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::timer_expired(
       
   979 	const u32_t id, void *data)
       
   980 {
       
   981 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   982 
       
   983 	EAP_TRACE_DEBUG(
       
   984 		m_am_tools,
       
   985 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   986 		(EAPL("TIMER: %s: [0x%08x]->eap_core_server_message_if_c::timer_expired(id 0x%02x, data 0x%08x).\n"),
       
   987 		 (m_is_client == true) ? "client": "server",
       
   988 		 this,
       
   989 		 id,
       
   990 		 data));
       
   991 
       
   992 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::timer_expired()");
       
   993 
       
   994 
       
   995 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   996 }
       
   997 
       
   998 //--------------------------------------------------
       
   999 
       
  1000 //
       
  1001 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::timer_delete_data(
       
  1002 	const u32_t id, void *data)
       
  1003 {
       
  1004 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1005 
       
  1006 	EAP_TRACE_DEBUG(
       
  1007 		m_am_tools,
       
  1008 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
  1009 		(EAPL("TIMER: %s: [0x%08x]->eap_core_server_message_if_c::timer_delete_data(id 0x%02x, data 0x%08x).\n"),
       
  1010 		(m_is_client == true) ? "client": "server",
       
  1011 		this, id, data));
       
  1012 
       
  1013 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::timer_delete_data()");
       
  1014 
       
  1015 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1016 }
       
  1017 
       
  1018 //--------------------------------------------------
       
  1019 
       
  1020 EAP_FUNC_EXPORT void eap_core_server_message_if_c::state_notification(
       
  1021 	const abs_eap_state_notification_c * const state)
       
  1022 {
       
  1023 	eap_status_e status(eap_status_process_general_error);
       
  1024 
       
  1025 	EAP_TRACE_DEBUG(
       
  1026 		m_am_tools, 
       
  1027 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1028 		(EAPL("%s: eap_core_server_message_if_c::state_notification()\n"),
       
  1029 		 (m_is_client == true) ? "client": "server"));
       
  1030 
       
  1031 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::state_notification()");
       
  1032 
       
  1033 	{
       
  1034 		// Creates message data composed of Attribute-Value Pairs.
       
  1035 		eap_process_tlv_message_data_c message(m_am_tools);
       
  1036 
       
  1037 		if (message.get_is_valid() == false)
       
  1038 		{
       
  1039 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1040 			(void)EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1041 			return;
       
  1042 		}
       
  1043 
       
  1044 		status = message.add_parameter_data(eap_tlv_message_type_function_state_notification);
       
  1045 		if (status != eap_status_ok)
       
  1046 		{
       
  1047 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1048 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1049 			return;
       
  1050 		}
       
  1051 
       
  1052 		status = message.add_parameter_data(state);
       
  1053 		if (status != eap_status_ok)
       
  1054 		{
       
  1055 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1056 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1057 			return;
       
  1058 		}
       
  1059 
       
  1060 		status = send_message(&message);
       
  1061 		if (status != eap_status_ok)
       
  1062 		{
       
  1063 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1064 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1065 			return;
       
  1066 		}
       
  1067 	}
       
  1068 }
       
  1069 
       
  1070 //--------------------------------------------------
       
  1071 
       
  1072 //
       
  1073 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::asynchronous_init_remove_eap_session(
       
  1074 	const eap_am_network_id_c * const /* send_network_id */)
       
  1075 {
       
  1076 	// eap_core_server_message_if_c object does not support asynchronous_init_remove_eap_session().
       
  1077 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
  1078 }
       
  1079 
       
  1080 //--------------------------------------------------
       
  1081 
       
  1082 //
       
  1083 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::asynchronous_start_authentication(
       
  1084 	const eap_am_network_id_c * const /* receive_network_id */,
       
  1085 	const bool /* is_client_when_true */)
       
  1086 {
       
  1087 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
  1088 }
       
  1089 
       
  1090 //--------------------------------------------------
       
  1091 
       
  1092 //
       
  1093 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::restart_authentication(
       
  1094 	const eap_am_network_id_c * const send_network_id,
       
  1095 	const bool is_client_when_true,
       
  1096 	const bool force_clean_restart,
       
  1097 	const bool from_timer)
       
  1098 {
       
  1099 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1100 
       
  1101 	EAP_TRACE_DEBUG(
       
  1102 		m_am_tools,
       
  1103 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
  1104 		(EAPL("%s: eap_core_server_message_if_c::restart_authentication()\n"),
       
  1105 		(m_is_client == true) ? "client": "server"));
       
  1106 
       
  1107 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::restart_authentication()");
       
  1108 
       
  1109 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1110 
       
  1111 	eap_status_e status(eap_status_process_general_error);
       
  1112 
       
  1113 	{
       
  1114 		// Creates message data composed of Attribute-Value Pairs.
       
  1115 		eap_process_tlv_message_data_c message(m_am_tools);
       
  1116 
       
  1117 		if (message.get_is_valid() == false)
       
  1118 		{
       
  1119 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1120 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1121 		}
       
  1122 
       
  1123 		status = message.add_parameter_data(eap_tlv_message_type_function_restart_authentication);
       
  1124 		if (status != eap_status_ok)
       
  1125 		{
       
  1126 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1127 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1128 		}
       
  1129 
       
  1130 		status = message.add_parameter_data(send_network_id);
       
  1131 		if (status != eap_status_ok)
       
  1132 		{
       
  1133 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1134 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1135 		}
       
  1136 
       
  1137 		status = message.add_parameter_data(is_client_when_true);
       
  1138 		if (status != eap_status_ok)
       
  1139 		{
       
  1140 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1141 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1142 		}
       
  1143 
       
  1144 		status = message.add_parameter_data(force_clean_restart);
       
  1145 		if (status != eap_status_ok)
       
  1146 		{
       
  1147 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1148 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1149 		}
       
  1150 
       
  1151 		status = message.add_parameter_data(from_timer);
       
  1152 		if (status != eap_status_ok)
       
  1153 		{
       
  1154 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1155 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1156 		}
       
  1157 
       
  1158 		status = send_message(&message);
       
  1159 		if (status != eap_status_ok)
       
  1160 		{
       
  1161 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1162 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1163 		}
       
  1164 	}
       
  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_core_server_message_if_c::set_timer(
       
  1174 	abs_eap_base_timer_c * const p_initializer, 
       
  1175 	const u32_t p_id, 
       
  1176 	void * const p_data,
       
  1177 	const u32_t p_time_ms)
       
  1178 {
       
  1179 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1180 
       
  1181 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1182 
       
  1183 	eap_status_e status = m_am_stack->set_timer(
       
  1184 		p_initializer, 
       
  1185 		p_id, 
       
  1186 		p_data,
       
  1187 		p_time_ms);
       
  1188 
       
  1189 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1190 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1191 }
       
  1192 
       
  1193 //--------------------------------------------------
       
  1194 
       
  1195 //
       
  1196 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::cancel_timer(
       
  1197 	abs_eap_base_timer_c * const p_initializer, 
       
  1198 	const u32_t p_id)
       
  1199 {
       
  1200 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1201 
       
  1202 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1203 
       
  1204 	eap_status_e status(eap_status_ok);
       
  1205 
       
  1206 	if (m_am_stack != 0)
       
  1207 	{
       
  1208 		status = m_am_stack->cancel_timer(
       
  1209 			p_initializer, 
       
  1210 			p_id);
       
  1211 	}
       
  1212 
       
  1213 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1214 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1215 }
       
  1216 
       
  1217 //--------------------------------------------------
       
  1218 
       
  1219 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::check_is_valid_eap_type(
       
  1220 	const eap_type_value_e eap_type)
       
  1221 {
       
  1222 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1223 
       
  1224 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1225 
       
  1226 	eap_status_e status = m_am_stack->check_is_valid_eap_type(eap_type);
       
  1227 
       
  1228 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1229 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1230 }
       
  1231 
       
  1232 //--------------------------------------------------
       
  1233 
       
  1234 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::get_eap_type_list(
       
  1235 	eap_array_c<eap_type_value_e> * const eap_type_list)
       
  1236 {
       
  1237 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1238 
       
  1239 	eap_status_e status = m_am_stack->get_eap_type_list(eap_type_list);
       
  1240 
       
  1241 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1242 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1243 }
       
  1244 
       
  1245 //--------------------------------------------------
       
  1246 
       
  1247 /// @see abs_eap_core_c::add_rogue_ap().
       
  1248 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::add_rogue_ap(
       
  1249 	eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list)
       
  1250 {
       
  1251 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1252 
       
  1253 	EAP_TRACE_DEBUG(
       
  1254 		m_am_tools, 
       
  1255 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1256 		(EAPL("%s: eap_core_server_message_if_c::add_rogue_ap(): Does nothing.\n"),
       
  1257 		 (m_is_client == true) ? "client": "server"));
       
  1258 
       
  1259 	eap_status_e status(eap_status_ok);
       
  1260 
       
  1261 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1262 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1263 }
       
  1264 
       
  1265 //--------------------------------------------------
       
  1266 
       
  1267 //
       
  1268 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::set_session_timeout(
       
  1269 	const u32_t /* session_timeout_ms */)
       
  1270 {
       
  1271 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1272 
       
  1273 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  1274 
       
  1275 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1276 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
  1277 }
       
  1278 
       
  1279 //--------------------------------------------------
       
  1280 
       
  1281 eap_status_e eap_core_server_message_if_c::create_eap_session(
       
  1282 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1283 {
       
  1284 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1285 
       
  1286 	EAP_TRACE_DEBUG(
       
  1287 		m_am_tools, 
       
  1288 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1289 		(EAPL("%s: eap_core_server_message_if_c::create_eap_session()\n"),
       
  1290 		 (m_is_client == true) ? "client": "server"));
       
  1291 
       
  1292 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::create_eap_session()");
       
  1293 
       
  1294 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1295 
       
  1296 	eap_status_e status(eap_status_ok);
       
  1297 
       
  1298 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1299 
       
  1300 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1301 
       
  1302 	if (message_data.get_is_valid() == false)
       
  1303 	{
       
  1304 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1305 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1306 	}
       
  1307 
       
  1308 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1309 
       
  1310 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1311 
       
  1312 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1313 	if (status != eap_status_ok)
       
  1314 	{
       
  1315 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1316 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1317 	}
       
  1318 
       
  1319 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1320 
       
  1321 	status = m_eap_core->create_eap_session(
       
  1322 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  1323 		);
       
  1324 
       
  1325 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1326 
       
  1327 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1328 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1329 }
       
  1330 
       
  1331 //--------------------------------------------------
       
  1332 
       
  1333 eap_status_e eap_core_server_message_if_c::remove_eap_session(
       
  1334 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1335 {
       
  1336 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1337 
       
  1338 	EAP_TRACE_DEBUG(
       
  1339 		m_am_tools, 
       
  1340 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1341 		(EAPL("%s: eap_core_server_message_if_c::remove_eap_session()\n"),
       
  1342 		 (m_is_client == true) ? "client": "server"));
       
  1343 
       
  1344 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::remove_eap_session()");
       
  1345 
       
  1346 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1347 
       
  1348 	eap_status_e status(eap_status_ok);
       
  1349 
       
  1350 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1351 
       
  1352 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1353 
       
  1354 	if (message_data.get_is_valid() == false)
       
  1355 	{
       
  1356 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1357 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1358 	}
       
  1359 
       
  1360 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1361 
       
  1362 	bool complete_to_lower_layer(false);
       
  1363 
       
  1364 	status = message_data.read_parameter_data(parameters, parameter_index, &complete_to_lower_layer);
       
  1365 	if (status != eap_status_ok)
       
  1366 	{
       
  1367 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1368 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1369 	}
       
  1370 
       
  1371 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1372 
       
  1373 	++parameter_index;
       
  1374 
       
  1375 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1376 
       
  1377 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1378 	if (status != eap_status_ok)
       
  1379 	{
       
  1380 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1381 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1382 	}
       
  1383 
       
  1384 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1385 
       
  1386 	status = m_eap_core->remove_eap_session(
       
  1387 		complete_to_lower_layer,
       
  1388 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  1389 		);
       
  1390 
       
  1391 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1392 
       
  1393 	// This is a new function to synchronize EAP-client and EAP-server.
       
  1394 	eap_status_e completion_status = complete_remove_eap_session(
       
  1395 		complete_to_lower_layer,
       
  1396 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  1397 		);
       
  1398 
       
  1399 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1400 
       
  1401 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1402 	return EAP_STATUS_RETURN(m_am_tools, completion_status);
       
  1403 }
       
  1404 
       
  1405 //--------------------------------------------------
       
  1406 
       
  1407 eap_status_e eap_core_server_message_if_c::send_eap_identity_request(
       
  1408 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1409 {
       
  1410 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1411 
       
  1412 	EAP_TRACE_DEBUG(
       
  1413 		m_am_tools, 
       
  1414 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1415 		(EAPL("%s: eap_core_server_message_if_c::send_eap_identity_request()\n"),
       
  1416 		 (m_is_client == true) ? "client": "server"));
       
  1417 
       
  1418 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::send_eap_identity_request()");
       
  1419 
       
  1420 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1421 
       
  1422 	eap_status_e status(eap_status_ok);
       
  1423 
       
  1424 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1425 
       
  1426 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1427 
       
  1428 	if (message_data.get_is_valid() == false)
       
  1429 	{
       
  1430 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1431 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1432 	}
       
  1433 
       
  1434 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1435 
       
  1436 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1437 
       
  1438 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1439 	if (status != eap_status_ok)
       
  1440 	{
       
  1441 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1442 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1443 	}
       
  1444 
       
  1445 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1446 
       
  1447 	status = m_eap_core->send_eap_identity_request(
       
  1448 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  1449 		);
       
  1450 
       
  1451 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1452 
       
  1453 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1454 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1455 }
       
  1456 
       
  1457 //--------------------------------------------------
       
  1458 
       
  1459 eap_status_e eap_core_server_message_if_c::packet_process(
       
  1460 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1461 {
       
  1462 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1463 
       
  1464 	EAP_TRACE_DEBUG(
       
  1465 		m_am_tools, 
       
  1466 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1467 		(EAPL("%s: eap_core_server_message_if_c::packet_process()\n"),
       
  1468 		 (m_is_client == true) ? "client": "server"));
       
  1469 
       
  1470 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::packet_process()");
       
  1471 
       
  1472 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1473 
       
  1474 	eap_status_e status(eap_status_ok);
       
  1475 
       
  1476 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1477 
       
  1478 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1479 
       
  1480 	if (message_data.get_is_valid() == false)
       
  1481 	{
       
  1482 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1483 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1484 	}
       
  1485 
       
  1486 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1487 
       
  1488 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1489 
       
  1490 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1491 	if (status != eap_status_ok)
       
  1492 	{
       
  1493 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1494 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1495 	}
       
  1496 
       
  1497 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1498 
       
  1499 	++parameter_index;
       
  1500 
       
  1501 	eap_variable_data_c packet_data_payload(m_am_tools);
       
  1502 
       
  1503 	status = message_data.read_parameter_data(parameters, parameter_index, &packet_data_payload);
       
  1504 	if (status != eap_status_ok)
       
  1505 	{
       
  1506 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1507 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1508 	}
       
  1509 
       
  1510 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1511 
       
  1512 	eap_header_wr_c eap(
       
  1513 		m_am_tools,
       
  1514 		packet_data_payload.get_data(),
       
  1515 		packet_data_payload.get_data_length());
       
  1516 	if (eap.get_is_valid() == false)
       
  1517 	{
       
  1518 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1519 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1520 	}
       
  1521 
       
  1522 	status = m_eap_core->packet_process(
       
  1523 		&receive_network_id,
       
  1524 		&eap,
       
  1525 		packet_data_payload.get_data_length()
       
  1526 		);
       
  1527 
       
  1528 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1529 
       
  1530 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1531 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1532 }
       
  1533 
       
  1534 //--------------------------------------------------
       
  1535 
       
  1536 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::eap_acknowledge(
       
  1537 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1538 {
       
  1539 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1540 
       
  1541 	EAP_TRACE_DEBUG(
       
  1542 		m_am_tools, 
       
  1543 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1544 		(EAPL("%s: eap_core_server_message_if_c::eap_acknowledge()\n"),
       
  1545 		 (m_is_client == true) ? "client": "server"));
       
  1546 
       
  1547 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::eap_acknowledge()");
       
  1548 
       
  1549 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1550 
       
  1551 	eap_status_e status(eap_status_ok);
       
  1552 
       
  1553 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1554 
       
  1555 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1556 
       
  1557 	if (message_data.get_is_valid() == false)
       
  1558 	{
       
  1559 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1560 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1561 	}
       
  1562 
       
  1563 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1564 
       
  1565 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1566 
       
  1567 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1568 	if (status != eap_status_ok)
       
  1569 	{
       
  1570 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1571 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1572 	}
       
  1573 
       
  1574 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1575 
       
  1576 	status = m_eap_core->eap_acknowledge(
       
  1577 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  1578 		);
       
  1579 
       
  1580 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1581 
       
  1582 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1583 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1584 }
       
  1585 
       
  1586 //--------------------------------------------------
       
  1587 
       
  1588 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::eap_mtu(
       
  1589 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1590 {
       
  1591 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1592 
       
  1593 	EAP_TRACE_DEBUG(
       
  1594 		m_am_tools, 
       
  1595 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1596 		(EAPL("%s: eap_core_server_message_if_c::eap_mtu()\n"),
       
  1597 		 (m_is_client == true) ? "client": "server"));
       
  1598 
       
  1599 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::eap_mtu()");
       
  1600 
       
  1601 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1602 
       
  1603 	eap_status_e status(eap_status_ok);
       
  1604 
       
  1605 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1606 
       
  1607 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1608 
       
  1609 	if (message_data.get_is_valid() == false)
       
  1610 	{
       
  1611 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1612 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1613 	}
       
  1614 
       
  1615 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1616 
       
  1617 	status = message_data.read_parameter_data(parameters, parameter_index, &m_MTU);
       
  1618 	if (status != eap_status_ok)
       
  1619 	{
       
  1620 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1621 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1622 	}
       
  1623 
       
  1624 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1625 
       
  1626 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1627 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1628 }
       
  1629 
       
  1630 //--------------------------------------------------
       
  1631 
       
  1632 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::get_802_11_authentication_mode(
       
  1633 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1634 {
       
  1635 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1636 
       
  1637 	EAP_TRACE_DEBUG(
       
  1638 		m_am_tools, 
       
  1639 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1640 		(EAPL("%s: eap_core_server_message_if_c::get_802_11_authentication_mode()\n"),
       
  1641 		 (m_is_client == true) ? "client": "server"));
       
  1642 
       
  1643 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::get_802_11_authentication_mode()");
       
  1644 
       
  1645 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1646 
       
  1647 	eap_status_e status(eap_status_ok);
       
  1648 
       
  1649 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1650 
       
  1651 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1652 
       
  1653 	if (message_data.get_is_valid() == false)
       
  1654 	{
       
  1655 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1656 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1657 	}
       
  1658 
       
  1659 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1660 
       
  1661 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1662 
       
  1663 	status = message_data.read_parameter_data(parameters, parameter_index, &receive_network_id);
       
  1664 	if (status != eap_status_ok)
       
  1665 	{
       
  1666 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1667 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1668 	}
       
  1669 
       
  1670 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1671 
       
  1672 	++parameter_index;
       
  1673 
       
  1674 	eapol_key_authentication_type_e authentication_type(eapol_key_authentication_type_none);
       
  1675 
       
  1676 	status = message_data.read_parameter_data(parameters, parameter_index, &authentication_type);
       
  1677 	if (status != eap_status_ok)
       
  1678 	{
       
  1679 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1680 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1681 	}
       
  1682 
       
  1683 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1684 
       
  1685 	++parameter_index;
       
  1686 
       
  1687 	eap_variable_data_c SSID(m_am_tools);
       
  1688 
       
  1689 	status = message_data.read_parameter_data(parameters, parameter_index, &SSID);
       
  1690 	if (status != eap_status_ok)
       
  1691 	{
       
  1692 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1693 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1694 	}
       
  1695 
       
  1696 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1697 
       
  1698 	++parameter_index;
       
  1699 
       
  1700 	eap_variable_data_c preshared_key(m_am_tools);
       
  1701 
       
  1702 	status = message_data.read_parameter_data(parameters, parameter_index, &preshared_key);
       
  1703 	if (status != eap_status_ok)
       
  1704 	{
       
  1705 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1706 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1707 	}
       
  1708 
       
  1709 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1710 
       
  1711 	if (authentication_type == eapol_key_authentication_type_WPS)
       
  1712 	{
       
  1713 		// Save SSID and pre-shared key for WPS to memory store.
       
  1714 		eap_variable_data_c memory_store_key(m_am_tools);
       
  1715 
       
  1716 		eap_status_e status = memory_store_key.set_copy_of_buffer(
       
  1717 			EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY,
       
  1718 			sizeof(EAP_WPS_CONFIGURATION_MEMORY_STORE_KEY));
       
  1719 		if (status != eap_status_ok)
       
  1720 		{
       
  1721 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1722 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1723 		}
       
  1724 
       
  1725 		status = memory_store_key.add_data(
       
  1726 			&m_is_client,
       
  1727 			sizeof(m_is_client));
       
  1728 		if (status != eap_status_ok)
       
  1729 		{
       
  1730 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1731 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1732 		}
       
  1733 
       
  1734 		eap_network_id_selector_c state_selector(
       
  1735 			m_am_tools,
       
  1736 			&receive_network_id);
       
  1737 
       
  1738 		status = memory_store_key.add_data(
       
  1739 			&state_selector);
       
  1740 		if (status != eap_status_ok)
       
  1741 		{
       
  1742 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1743 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1744 		}
       
  1745 
       
  1746 		eap_tlv_message_data_c tlv_data(m_am_tools);
       
  1747 
       
  1748 		status = tlv_data.add_message_data(
       
  1749 			eap_type_protected_setup_stored_preshared_key,
       
  1750 			preshared_key.get_data_length(),
       
  1751 			preshared_key.get_data());
       
  1752 		if (status != eap_status_ok)
       
  1753 		{
       
  1754 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1755 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1756 		}
       
  1757 
       
  1758 		status = tlv_data.add_message_data(
       
  1759 			eap_type_protected_setup_stored_ssid,
       
  1760 			SSID.get_data_length(),
       
  1761 			SSID.get_data());
       
  1762 		if (status != eap_status_ok)
       
  1763 		{
       
  1764 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1765 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1766 		}
       
  1767 
       
  1768 		status = m_am_tools->memory_store_remove_data(&memory_store_key);
       
  1769 		if (status != eap_status_ok
       
  1770 			&& status != eap_status_not_found)
       
  1771 		{
       
  1772 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1773 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1774 		}
       
  1775 
       
  1776 		status = m_am_tools->memory_store_add_data(
       
  1777 			&memory_store_key,
       
  1778 			&tlv_data,
       
  1779 			eap_type_default_credential_timeout);
       
  1780 		if (status != eap_status_ok)
       
  1781 		{
       
  1782 			EAP_TRACE_ERROR(
       
  1783 				m_am_tools,
       
  1784 				TRACE_FLAGS_ERROR,
       
  1785 				(EAPL("eap_core_server_message_if_c::get_802_11_authentication_mode(): cannot store WPS credentials\n")));
       
  1786 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1787 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1788 		}
       
  1789 	}
       
  1790 
       
  1791 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1792 
       
  1793 	status = m_am_stack->get_802_11_authentication_mode(
       
  1794 		&receive_network_id, ///< source includes remote address, destination includes local address.
       
  1795 		authentication_type);
       
  1796 
       
  1797 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1798 
       
  1799 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1800 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1801 }
       
  1802 
       
  1803 //--------------------------------------------------
       
  1804 
       
  1805 eap_status_e eap_core_server_message_if_c::set_eap_database_reference_values(
       
  1806 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1807 {
       
  1808 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1809 
       
  1810 	EAP_TRACE_DEBUG(
       
  1811 		m_am_tools, 
       
  1812 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1813 		(EAPL("%s: eap_core_server_message_if_c::set_eap_database_reference_values()\n"),
       
  1814 		 (m_is_client == true) ? "client": "server"));
       
  1815 
       
  1816 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::set_eap_database_reference_values()");
       
  1817 
       
  1818 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1819 
       
  1820 	eap_status_e status(eap_status_ok);
       
  1821 
       
  1822 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
  1823 
       
  1824 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
  1825 
       
  1826 	if (message_data.get_is_valid() == false)
       
  1827 	{
       
  1828 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1829 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1830 	}
       
  1831 
       
  1832 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1833 
       
  1834 	eap_variable_data_c reference(m_am_tools);
       
  1835 
       
  1836 	status = message_data.read_parameter_data(parameters, parameter_index, &reference);
       
  1837 	if (status != eap_status_ok)
       
  1838 	{
       
  1839 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1840 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1841 	}
       
  1842 
       
  1843 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1844 
       
  1845 	status = m_am_stack->set_eap_database_reference_values(
       
  1846 		&reference
       
  1847 		);
       
  1848 
       
  1849 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1850 
       
  1851 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1852 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1853 }
       
  1854 
       
  1855 //--------------------------------------------------
       
  1856 
       
  1857 #if defined(USE_EAP_SIMPLE_CONFIG)
       
  1858 
       
  1859 EAP_FUNC_EXPORT eap_status_e eap_core_server_message_if_c::save_simple_config_session(
       
  1860 	const simple_config_state_e state,
       
  1861 	EAP_TEMPLATE_CONST eap_array_c<simple_config_credential_c> * const credential_array,
       
  1862 	const eap_variable_data_c * const new_password,
       
  1863 	const simple_config_Device_Password_ID_e Device_Password_ID,
       
  1864 	const simple_config_payloads_c * const other_configuration)
       
  1865 {
       
  1866 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1867 
       
  1868 	EAP_TRACE_DEBUG(
       
  1869 		m_am_tools, 
       
  1870 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
  1871 		(EAPL("%s: eap_core_server_message_if_c::save_simple_config_session()\n"),
       
  1872 		 (m_is_client == true) ? "client": "server"));
       
  1873 
       
  1874 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_core_server_message_if_c::save_simple_config_session()");
       
  1875 
       
  1876 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1877 
       
  1878 	// Message is formatted as:
       
  1879 	// 0                   1                   2                   3   
       
  1880 	//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
       
  1881 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1882 	// |                    Type = Function                            |
       
  1883 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1884 	// |                    Length = 4                                 |
       
  1885 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1886 	// |                    Value = New_protected_setup_credentials    |
       
  1887 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= start of Array of Protected setup credential
       
  1888 	// |                    Type = Array                               |
       
  1889 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1890 	// |                    Length = 137                               |
       
  1891 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ <= start of Array of Protected setup credential value
       
  1892 	// |                    Type = Protected setup credential          |
       
  1893 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1894 	// |                    Length = 129                               |
       
  1895 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1896 	// |                    Type = Unsigned 8 bit integer              |
       
  1897 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1898 	// |                    Length = 1                                 |
       
  1899 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1900 	// |   u8_t value  |
       
  1901 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1902 	// |                    Type = Variable data                       |
       
  1903 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1904 	// |                    Length = 12                                |
       
  1905 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1906 	// |                    Value = SSID string                        |
       
  1907 	// +-+-+-+-                                                 -+-+-+-+
       
  1908 	// |                                                               |
       
  1909 	// +-+-+-+-                                                 -+-+-+-+
       
  1910 	// |                                                               |
       
  1911 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1912 	// |                    Type = Unsigned 16 bit integer             |
       
  1913 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1914 	// |                    Length = 2                                 |
       
  1915 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1916 	// |   u16_t Authentication type   |
       
  1917 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1918 	// |                    Type = Unsigned 16 bit integer             |
       
  1919 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1920 	// |                    Length = 2                                 |
       
  1921 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1922 	// |   u16_t Encryption type       |
       
  1923 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= start of Array of Network key
       
  1924 	// |                    Type = Array                               |
       
  1925 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1926 	// |                    Length = 66                                |
       
  1927 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ <= start of Array of Network key value
       
  1928 	// |                    Type = Network key                         |
       
  1929 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1930 	// |                    Length = 25                                |
       
  1931 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1932 	// |                    Type = Unsigned 8 bit integer              |
       
  1933 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1934 	// |                    Length = 1                                 |
       
  1935 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1936 	// |   u8_t value  |
       
  1937 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1938 	// |                    Type = Variable data                       |
       
  1939 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1940 	// |                    Length = 8                                 |
       
  1941 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1942 	// |                    Value = Network key                        |
       
  1943 	// +-+-+-+-                                                 -+-+-+-+
       
  1944 	// |                                                               |
       
  1945 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1946 	// |                    Type = Network key                         |
       
  1947 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1948 	// |                    Length = 25                                |
       
  1949 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1950 	// |                    Type = Unsigned 8 bit integer              |
       
  1951 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1952 	// |                    Length = 1                                 |
       
  1953 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1954 	// |   u8_t value  |
       
  1955 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
  1956 	// |                    Type = Variable data                       |
       
  1957 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1958 	// |                    Length = 8                                 |
       
  1959 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1960 	// |                    Value = Network key                        |
       
  1961 	// +-+-+-+-                                                 -+-+-+-+
       
  1962 	// |                                                               |
       
  1963 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= end of Array of Network key
       
  1964 	// |                    Type = Variable data                       |
       
  1965 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1966 	// |                    Length = 6                                 |
       
  1967 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1968 	// |                    Value = MAC address                        |
       
  1969 	// +-+-+-+-                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
  1970 	// |                               |
       
  1971 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+                                 <= end of Array of Protected setup credential
       
  1972 
       
  1973 
       
  1974 	eap_status_e status(eap_status_ok);
       
  1975 
       
  1976 	{
       
  1977 		// Creates message data composed of Attribute-Value Pairs.
       
  1978 		eap_process_tlv_message_data_c message(m_am_tools);
       
  1979 
       
  1980 		if (message.get_is_valid() == false)
       
  1981 		{
       
  1982 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1983 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1984 		}
       
  1985 
       
  1986 		status = message.add_parameter_data(eap_tlv_message_type_function_new_protected_setup_credentials);
       
  1987 		if (status != eap_status_ok)
       
  1988 		{
       
  1989 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1990 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1991 		}
       
  1992 
       
  1993 		status = message.add_parameter_data(credential_array);
       
  1994 		if (status != eap_status_ok)
       
  1995 		{
       
  1996 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1997 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1998 		}
       
  1999 
       
  2000 		status = send_message(&message);
       
  2001 		if (status != eap_status_ok)
       
  2002 		{
       
  2003 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2004 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2005 		}
       
  2006 	}
       
  2007 
       
  2008 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2009 
       
  2010 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2011 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2012 }
       
  2013 
       
  2014 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
       
  2015 
       
  2016 //--------------------------------------------------
       
  2017 
       
  2018 eap_am_message_if_c * eap_am_message_if_c::new_eap_am_server_message_if_c(
       
  2019 	abs_eap_am_tools_c * const tools,
       
  2020 	const bool is_client_when_true,
       
  2021 	const u32_t MTU)
       
  2022 {
       
  2023 	eap_am_message_if_c * server = new eap_core_server_message_if_c(
       
  2024 		tools,
       
  2025 		is_client_when_true,
       
  2026 		MTU);
       
  2027 
       
  2028 	eap_automatic_variable_c<eap_am_message_if_c> automatic_server(
       
  2029 		tools,
       
  2030 		server);
       
  2031 
       
  2032 	if (server == 0
       
  2033 		|| server->get_is_valid() == false)
       
  2034 	{
       
  2035 		// ERROR.
       
  2036 		if (server != 0)
       
  2037 		{
       
  2038 			EAP_TRACE_DEBUG(
       
  2039 				tools,
       
  2040 				TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, 
       
  2041 				(EAPL("ERROR: calls: eap_am_message_if_c::new_eap_am_server_message_if_c(): server->shutdown(): %s.\n"),
       
  2042 				(is_client_when_true == true) ? "client": "server"));
       
  2043 
       
  2044 			server->shutdown();
       
  2045 		}
       
  2046 
       
  2047 		return 0;
       
  2048 	}
       
  2049 
       
  2050 	automatic_server.do_not_free_variable();
       
  2051 
       
  2052 	return server;
       
  2053 }
       
  2054 
       
  2055 //--------------------------------------------------
       
  2056 // End.