eapol/eapol_framework/eapol_common/core/eapol_message_wlan_authentication.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // This is enumeration of EAPOL source code.
       
    21 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    22 	#undef EAP_FILE_NUMBER_ENUM
       
    23 	#define EAP_FILE_NUMBER_ENUM 575 
       
    24 	#undef EAP_FILE_NUMBER_DATE 
       
    25 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    26 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    27 
       
    28 
       
    29 #include "eapol_message_wlan_authentication.h"
       
    30 #include "eapol_wlan_database_reference.h"
       
    31 #include "eap_am_memory.h"
       
    32 #include "abs_eap_state_notification.h"
       
    33 #include "eap_crypto_api.h"
       
    34 #include "eap_header_string.h"
       
    35 #include "eap_buffer.h"
       
    36 #include "eapol_session_key.h"
       
    37 #include "eapol_handle_tlv_message_data.h"
       
    38 #include "eap_automatic_variable.h"
       
    39 #include "eap_array_algorithms.h"
       
    40 #include "eap_config.h"
       
    41 
       
    42 //--------------------------------------------------
       
    43 
       
    44 #if defined(USE_TEST_WLAN_AUTHENTICATION_MUTEX) && defined(USE_EAPOL_WLAN_AUTHENTICATION_MUTEX)
       
    45 	#error "You cannot define both USE_EAPOL_WLAN_AUTHENTICATION_MUTEX and USE_TEST_WLAN_AUTHENTICATION_MUTEX."
       
    46 #endif
       
    47 
       
    48 #if !defined(USE_TEST_WLAN_AUTHENTICATION_MUTEX) && defined(USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST)
       
    49 	#error "You must define USE_TEST_WLAN_AUTHENTICATION_MUTEX if USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST is used."
       
    50 #endif
       
    51 
       
    52 //--------------------------------------------------
       
    53 
       
    54 /**
       
    55  * This is the timer ID used with abs_eap_am_tools_c::set_timer() and abs_eap_am_tools_c::cancel_timer().
       
    56  */
       
    57 enum eapol_core_timer_id
       
    58 {
       
    59 	EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID,
       
    60 	EAPOL_MESSAGE_TIMER_SEND_DATA_ID,
       
    61 };
       
    62 
       
    63 
       
    64 //--------------------------------------------------
       
    65 
       
    66 EAP_FUNC_EXPORT eapol_message_wlan_authentication_c::~eapol_message_wlan_authentication_c()
       
    67 {
       
    68 }
       
    69 
       
    70 //--------------------------------------------------
       
    71 
       
    72 EAP_FUNC_EXPORT eapol_message_wlan_authentication_c::eapol_message_wlan_authentication_c(
       
    73 	abs_eap_am_tools_c * const tools,
       
    74 	abs_eapol_message_wlan_authentication_c * const partner)
       
    75 	: m_am_tools(tools)
       
    76 	, m_wauth(0)
       
    77 	, m_partner(partner)
       
    78 	, m_wlan_database_reference(tools)
       
    79 	, m_header_offset(0ul)
       
    80 	, m_MTU(0ul)
       
    81 	, m_trailer_length(0ul)
       
    82 	, m_error_code(wlan_eap_if_send_status_ok)
       
    83 	, m_error_function(eapol_tlv_message_type_function_none)
       
    84 	, m_use_asyncronous_test(false)
       
    85 	, m_is_valid(true)
       
    86 {
       
    87 }
       
    88 
       
    89 //--------------------------------------------------
       
    90 
       
    91 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::configure(
       
    92 	const u32_t header_offset,
       
    93 	const u32_t MTU,
       
    94 	const u32_t trailer_length)
       
    95 {
       
    96 	eap_status_e status(eap_status_ok);
       
    97 
       
    98 	//----------------------------------------------------------
       
    99 
       
   100 	m_header_offset = header_offset;
       
   101 	m_MTU = MTU;
       
   102 	m_trailer_length = trailer_length;
       
   103 
       
   104 	//----------------------------------------------------------
       
   105 
       
   106 	// eapol_wlan_authentication_c object uses the tools object.
       
   107 	m_wauth = eapol_wlan_authentication_c::new_eapol_wlan_authentication(
       
   108 		m_am_tools,
       
   109 		this,
       
   110 		true,
       
   111 		this);
       
   112 	if (m_wauth != 0
       
   113 		&& m_wauth->get_is_valid() == true)
       
   114 	{
       
   115 		status = m_wauth->configure();
       
   116 		if (status != eap_status_ok)
       
   117 		{
       
   118 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   119 		}
       
   120 	}
       
   121 	else
       
   122 	{
       
   123 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   124 	}
       
   125 
       
   126 	//----------------------------------------------------------
       
   127 
       
   128 	{
       
   129 		eap_variable_data_c EAPOL_TEST_use_asyncronous_test(m_am_tools);
       
   130 
       
   131 		eap_status_e status = m_wauth->read_configure(
       
   132 			cf_str_EAPOL_TEST_use_message_asyncronous_test.get_field(),
       
   133 			&EAPOL_TEST_use_asyncronous_test);
       
   134 		if (status == eap_status_ok
       
   135 			&& EAPOL_TEST_use_asyncronous_test.get_is_valid_data() == true)
       
   136 		{
       
   137 			u32_t *use_asyncronous_test = reinterpret_cast<u32_t *>(
       
   138 				EAPOL_TEST_use_asyncronous_test.get_data(sizeof(u32_t)));
       
   139 			if (use_asyncronous_test != 0
       
   140 				&& *use_asyncronous_test != 0)
       
   141 			{
       
   142 				m_use_asyncronous_test = true;
       
   143 			}
       
   144 		}
       
   145 	}
       
   146 
       
   147 	//----------------------------------------------------------
       
   148 
       
   149 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   150 }
       
   151 
       
   152 //--------------------------------------------------
       
   153 
       
   154 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::shutdown()
       
   155 {
       
   156 	// After use the eapol_wlan_authentication_c object must be deleted first.
       
   157 	if (m_wauth != 0)
       
   158 	{
       
   159 		m_wauth->shutdown();
       
   160 		delete m_wauth;
       
   161 		m_wauth = 0;
       
   162 	}
       
   163 
       
   164 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   165 }
       
   166 
       
   167 //--------------------------------------------------
       
   168 
       
   169 EAP_FUNC_EXPORT bool eapol_message_wlan_authentication_c::get_is_valid()
       
   170 {
       
   171 	return m_is_valid;
       
   172 }
       
   173 
       
   174 // ----------------------------------------------------------------
       
   175 
       
   176 //
       
   177 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::timer_expired(
       
   178 	const u32_t id, void *data)
       
   179 {
       
   180 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   181 	
       
   182 	EAP_TRACE_DEBUG(
       
   183 		m_am_tools, 
       
   184 		TRACE_FLAGS_DEFAULT, 
       
   185 		(EAPL("TIMER: [0x%08x]->eapol_message_wlan_authentication_c::timer_expired")
       
   186 		 EAPL("(id 0x%02x, data 0x%08x).\n"),
       
   187 		 this, id, data));
       
   188 	
       
   189 #if defined(USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST)
       
   190 
       
   191 	if (id == EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID)
       
   192 	{
       
   193 		EAP_TRACE_DEBUG(
       
   194 			m_am_tools, 
       
   195 			TRACE_FLAGS_DEFAULT, 
       
   196 			(EAPL("TIMER: [0x%08x]->eapol_message_wlan_authentication_c::timer_expired: EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID")
       
   197 			 EAPL("(id 0x%02x, data 0x%08x).\n"),
       
   198 			 this, id, data));
       
   199 	
       
   200 		eapol_handle_tlv_message_data_c * const message = reinterpret_cast<eapol_handle_tlv_message_data_c *>(data);
       
   201 		if (message != 0)
       
   202 		{
       
   203 			eap_status_e status = process_message(message);
       
   204 
       
   205 			(void) EAP_STATUS_RETURN(m_am_tools, status);
       
   206 		}
       
   207 	}
       
   208 	else if (id == EAPOL_MESSAGE_TIMER_SEND_DATA_ID)
       
   209 	{
       
   210 		EAP_TRACE_DEBUG(
       
   211 			m_am_tools, 
       
   212 			TRACE_FLAGS_DEFAULT, 
       
   213 			(EAPL("TIMER: [0x%08x]->eapol_message_wlan_authentication_c::timer_expired: EAPOL_MESSAGE_TIMER_SEND_DATA_ID")
       
   214 			 EAPL("(id 0x%02x, data 0x%08x).\n"),
       
   215 			 this, id, data));
       
   216 	
       
   217 		eapol_handle_tlv_message_data_c * const message = reinterpret_cast<eapol_handle_tlv_message_data_c *>(data);
       
   218 		if (message != 0)
       
   219 		{
       
   220 			wlan_eap_if_send_status_e send_status = m_partner->send_data(
       
   221 				message->get_message_data(),
       
   222 				message->get_message_data_length());
       
   223 
       
   224 			if (send_status != wlan_eap_if_send_status_ok)
       
   225 			{
       
   226 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   227 				(void) EAP_STATUS_RETURN(m_am_tools,
       
   228 					wlan_eap_if_send_status_conversion_c::convert(send_status));
       
   229 			}
       
   230 		}
       
   231 	}
       
   232 
       
   233 #else
       
   234 
       
   235 	EAP_UNREFERENCED_PARAMETER(id);
       
   236 	EAP_UNREFERENCED_PARAMETER(data);
       
   237 
       
   238 #endif
       
   239 
       
   240 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   241 	return eap_status_ok;
       
   242 }
       
   243 
       
   244 // ----------------------------------------------------------------
       
   245 
       
   246 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::timer_delete_data(
       
   247 	const u32_t id, void * data)
       
   248 {
       
   249 
       
   250 #if defined(USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST)
       
   251 
       
   252 	if (id == EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID
       
   253 		|| id == EAPOL_MESSAGE_TIMER_SEND_DATA_ID)
       
   254 	{
       
   255 		eapol_handle_tlv_message_data_c * const message = reinterpret_cast<eapol_handle_tlv_message_data_c *>(data);
       
   256 		if (message != 0)
       
   257 		{
       
   258 			delete message;
       
   259 		}
       
   260 	}
       
   261 
       
   262 #else
       
   263 
       
   264 	EAP_UNREFERENCED_PARAMETER(id);
       
   265 	EAP_UNREFERENCED_PARAMETER(data);
       
   266 
       
   267 #endif
       
   268 
       
   269 	return eap_status_ok;
       
   270 }
       
   271 
       
   272 //--------------------------------------------------
       
   273 
       
   274 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::packet_send(
       
   275 	const eap_am_network_id_c * const send_network_id,
       
   276 	eap_buf_chain_wr_c * const sent_packet,
       
   277 	const u32_t header_offset,
       
   278 	const u32_t data_length,
       
   279 	const u32_t buffer_length)
       
   280 {
       
   281 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   282 
       
   283 	eap_status_e status(eap_status_ok);
       
   284 
       
   285 	if (sent_packet->get_do_length_checks() == true)
       
   286 	{
       
   287 		if (header_offset != m_header_offset)
       
   288 		{
       
   289 			EAP_TRACE_ERROR(
       
   290 				m_am_tools,
       
   291 				TRACE_FLAGS_DEFAULT,
       
   292 				(EAPL("ERROR: packet_send: packet buffer corrupted (header_offset != %d).\n"),
       
   293 				m_header_offset));
       
   294 			EAP_ASSERT_ALWAYS(header_offset == m_header_offset);
       
   295 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   296 		}
       
   297 		else if (header_offset+data_length != sent_packet->get_data_length())
       
   298 		{
       
   299 			EAP_TRACE_ERROR(
       
   300 				m_am_tools,
       
   301 				TRACE_FLAGS_DEFAULT,
       
   302 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   303 				 EAPL("(data_length %d != sent_packet->get_data_length() %d).\n"),
       
   304 				 header_offset+data_length,
       
   305 				 sent_packet->get_data_length()));
       
   306 			EAP_ASSERT_ALWAYS(data_length == sent_packet->get_buffer_length());
       
   307 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   308 		}
       
   309 		else if (header_offset+data_length > buffer_length)
       
   310 		{
       
   311 			EAP_TRACE_ERROR(
       
   312 				m_am_tools,
       
   313 				TRACE_FLAGS_DEFAULT,
       
   314 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   315 				 EAPL("(header_offset+data_length %d > buffer_length %d).\n"),
       
   316 				 header_offset+data_length,
       
   317 				 buffer_length));
       
   318 			EAP_ASSERT_ALWAYS(header_offset+data_length <= buffer_length);
       
   319 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   320 		}
       
   321 		else if (header_offset+data_length > m_MTU)
       
   322 		{
       
   323 			EAP_TRACE_ERROR(
       
   324 				m_am_tools,
       
   325 				TRACE_FLAGS_DEFAULT,
       
   326 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   327 				 EAPL("(header_offset+data_length %d > m_MTU %d).\n"),
       
   328 				 header_offset+data_length,
       
   329 				 m_MTU));
       
   330 			EAP_ASSERT_ALWAYS(header_offset+data_length <= m_MTU);
       
   331 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   332 		}
       
   333 	}
       
   334 	else
       
   335 	{
       
   336 		// Always we need at least the Ethernet header.
       
   337 		if (sent_packet->get_data_length()
       
   338 			< eapol_ethernet_header_wr_c::get_header_length())
       
   339 		{
       
   340 			EAP_TRACE_ERROR(
       
   341 				m_am_tools,
       
   342 				TRACE_FLAGS_DEFAULT,
       
   343 				(EAPL("ERROR: packet_send: packet buffer corrupted ")
       
   344 				 EAPL("(sent_packet->get_data_length() %d < ")
       
   345 				 EAPL("eapol_ethernet_header_wr_c::get_header_length() %d).\n"),
       
   346 				 sent_packet->get_data_length(),
       
   347 				 eapol_ethernet_header_wr_c::get_header_length()));
       
   348 			return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   349 		}
       
   350 	}
       
   351 	
       
   352 	eapol_ethernet_header_wr_c eth(
       
   353 		m_am_tools,
       
   354 		sent_packet->get_data_offset(header_offset, data_length),
       
   355 		data_length);
       
   356 	if (eth.get_is_valid() == false)
       
   357 	{
       
   358 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   359 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   360 	}
       
   361 
       
   362 	
       
   363 	{
       
   364 		// Creates message data composed of Attribute-Value Pairs.
       
   365 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   366 
       
   367 		if (message.get_is_valid() == false)
       
   368 		{
       
   369 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   370 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   371 		}
       
   372 
       
   373 		status = message.add_parameter_data(eapol_tlv_message_type_function_packet_send);
       
   374 		if (status != eap_status_ok)
       
   375 		{
       
   376 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   377 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   378 		}
       
   379 
       
   380 		status = message.add_parameter_data(send_network_id);
       
   381 		if (status != eap_status_ok)
       
   382 		{
       
   383 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   384 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   385 		}
       
   386 
       
   387 		status = message.add_parameter_data(sent_packet);
       
   388 		if (status != eap_status_ok)
       
   389 		{
       
   390 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   391 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   392 		}
       
   393 
       
   394 		status = send_message(&message);
       
   395 		if (status != eap_status_ok)
       
   396 		{
       
   397 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   398 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   399 		}
       
   400 	}
       
   401 	
       
   402 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   403 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   404 }
       
   405 
       
   406 //--------------------------------------------------
       
   407 
       
   408 EAP_FUNC_EXPORT u32_t eapol_message_wlan_authentication_c::get_header_offset(
       
   409 	u32_t * const MTU,
       
   410 	u32_t * const trailer_length)
       
   411 {
       
   412 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   413 
       
   414 	// Header of this module is in the beging of the buffer
       
   415 	// no additional header are used.
       
   416 	*MTU = m_MTU;
       
   417 	*trailer_length = m_trailer_length;
       
   418 
       
   419 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   420 	return m_header_offset;
       
   421 }
       
   422 
       
   423 //--------------------------------------------------
       
   424 
       
   425 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::associate(
       
   426 	eapol_key_802_11_authentication_mode_e authentication_mode)
       
   427 {
       
   428 	eap_status_e status(eap_status_ok);
       
   429 
       
   430 	{
       
   431 		// Creates message data composed of Attribute-Value Pairs.
       
   432 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   433 
       
   434 		if (message.get_is_valid() == false)
       
   435 		{
       
   436 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   437 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   438 		}
       
   439 
       
   440 		status = message.add_parameter_data(eapol_tlv_message_type_function_associate);
       
   441 		if (status != eap_status_ok)
       
   442 		{
       
   443 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   444 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   445 		}
       
   446 
       
   447 		status = message.add_parameter_data(
       
   448 			eapol_tlv_message_type_eapol_key_802_11_authentication_mode,
       
   449 			static_cast<u32_t>(authentication_mode));
       
   450 		if (status != eap_status_ok)
       
   451 		{
       
   452 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   453 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   454 		}
       
   455 
       
   456 		status = send_message(&message);
       
   457 		if (status != eap_status_ok)
       
   458 		{
       
   459 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   460 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   461 		}
       
   462 	}
       
   463 
       
   464 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   465 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   466 }
       
   467 
       
   468 //--------------------------------------------------
       
   469 
       
   470 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::disassociate(
       
   471 	const eap_am_network_id_c * const receive_network_id, ///< source includes remote address, destination includes local address.
       
   472 	const bool self_disassociation)
       
   473 {
       
   474 	eap_status_e status(eap_status_ok);
       
   475 
       
   476 	{
       
   477 		// Creates message data composed of Attribute-Value Pairs.
       
   478 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   479 
       
   480 		if (message.get_is_valid() == false)
       
   481 		{
       
   482 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   483 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   484 		}
       
   485 
       
   486 		status = message.add_parameter_data(eapol_tlv_message_type_function_disassociate);
       
   487 		if (status != eap_status_ok)
       
   488 		{
       
   489 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   490 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   491 		}
       
   492 
       
   493 		status = message.add_parameter_data(receive_network_id);
       
   494 		if (status != eap_status_ok)
       
   495 		{
       
   496 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   497 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   498 		}
       
   499 
       
   500 		status = message.add_parameter_data(self_disassociation);
       
   501 		if (status != eap_status_ok)
       
   502 		{
       
   503 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   504 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   505 		}
       
   506 
       
   507 		status = send_message(&message);
       
   508 		if (status != eap_status_ok)
       
   509 		{
       
   510 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   511 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   512 		}
       
   513 	}
       
   514 
       
   515 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   516 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   517 }
       
   518 
       
   519 //--------------------------------------------------
       
   520 
       
   521 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::packet_data_session_key(
       
   522 	const eap_am_network_id_c * const send_network_id,
       
   523 	const eapol_session_key_c * const key)
       
   524 {
       
   525 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   526 	
       
   527 	eap_status_e status(eap_status_ok);
       
   528 
       
   529 	if (key == 0
       
   530 		|| key->get_is_valid() == false)
       
   531 	{
       
   532 		EAP_TRACE_DEBUG(
       
   533 			m_am_tools,
       
   534 			TRACE_FLAGS_DEFAULT,
       
   535 			(EAPL("ERROR: test_eapol_c::packet_data_session_key(), invalid key.\n")));
       
   536 		return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error);
       
   537 	}
       
   538 	
       
   539 	EAP_TRACE_DEBUG(
       
   540 		m_am_tools,
       
   541 		TRACE_FLAGS_DEFAULT,
       
   542 		(EAPL("test_eapol_c::packet_data_session_key(): key_type 0x%02x, key_index %d\n"),
       
   543 		 key->get_key_type(),
       
   544 		 key->get_key_index()));
       
   545 	
       
   546 	EAP_TRACE_DATA_DEBUG(
       
   547 		m_am_tools,
       
   548 		TRACE_FLAGS_DEFAULT,
       
   549 		(EAPL("test_eapol_c::packet_data_session_key"), 
       
   550 		 key->get_key()->get_data(key->get_key()->get_data_length()),
       
   551 		 key->get_key()->get_data_length()));
       
   552 	
       
   553 	{
       
   554 		// Creates message data composed of Attribute-Value Pairs.
       
   555 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   556 
       
   557 		if (message.get_is_valid() == false)
       
   558 		{
       
   559 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   560 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   561 		}
       
   562 
       
   563 		status = message.add_parameter_data(eapol_tlv_message_type_function_packet_data_session_key);
       
   564 		if (status != eap_status_ok)
       
   565 		{
       
   566 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   567 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   568 		}
       
   569 
       
   570 		status = message.add_parameter_data(send_network_id);
       
   571 		if (status != eap_status_ok)
       
   572 		{
       
   573 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   574 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   575 		}
       
   576 
       
   577 		status = message.add_parameter_data(key);
       
   578 		if (status != eap_status_ok)
       
   579 		{
       
   580 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   581 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   582 		}
       
   583 
       
   584 		status = send_message(&message);
       
   585 		if (status != eap_status_ok)
       
   586 		{
       
   587 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   588 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   589 		}
       
   590 	}
       
   591 
       
   592 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   593 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   594 }
       
   595 
       
   596 //--------------------------------------------------
       
   597 
       
   598 EAP_FUNC_EXPORT void eapol_message_wlan_authentication_c::state_notification(
       
   599 	const abs_eap_state_notification_c * const state)
       
   600 {
       
   601 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   602 
       
   603 	eap_status_e status(eap_status_ok);
       
   604 
       
   605 	{
       
   606 		// Creates message data composed of Attribute-Value Pairs.
       
   607 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   608 
       
   609 		if (message.get_is_valid() == false)
       
   610 		{
       
   611 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   612 			(void)EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   613 			return;
       
   614 		}
       
   615 
       
   616 		status = message.add_parameter_data(eapol_tlv_message_type_function_state_notification);
       
   617 		if (status != eap_status_ok)
       
   618 		{
       
   619 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   620 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   621 			return;
       
   622 		}
       
   623 
       
   624 		status = message.add_parameter_data(state);
       
   625 		if (status != eap_status_ok)
       
   626 		{
       
   627 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   628 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   629 			return;
       
   630 		}
       
   631 
       
   632 		status = send_message(&message);
       
   633 		if (status != eap_status_ok)
       
   634 		{
       
   635 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   636 			(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   637 			return;
       
   638 		}
       
   639 	}
       
   640 	
       
   641 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   642 }
       
   643 
       
   644 //--------------------------------------------------
       
   645 
       
   646 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & /* rogue_ap_list */)
       
   647 {
       
   648 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
   649 }
       
   650 
       
   651 //--------------------------------------------------
       
   652 
       
   653 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::reassociate(
       
   654 	const eap_am_network_id_c * const send_network_id,
       
   655 	const eapol_key_authentication_type_e authentication_type,
       
   656 	const eap_variable_data_c * const PMKID)
       
   657 {
       
   658 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   659 
       
   660 	eap_status_e status(eap_status_ok);
       
   661 
       
   662 	if (PMKID == 0
       
   663 		|| PMKID->get_is_valid() == false)
       
   664 	{
       
   665 		EAP_TRACE_DEBUG(
       
   666 			m_am_tools,
       
   667 			TRACE_FLAGS_DEFAULT,
       
   668 			(EAPL("ERROR: eapol_message_wlan_authentication_c::reassociate(), invalid PMKID.\n")));
       
   669 		return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error);
       
   670 	}
       
   671 	
       
   672 	EAP_TRACE_DATA_DEBUG(
       
   673 		m_am_tools,
       
   674 		TRACE_FLAGS_DEFAULT,
       
   675 		(EAPL("eapol_message_wlan_authentication_c::reassociate"), 
       
   676 		 PMKID->get_data(PMKID->get_data_length()),
       
   677 		 PMKID->get_data_length()));
       
   678 	
       
   679 	{
       
   680 		// Creates message data composed of Attribute-Value Pairs.
       
   681 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   682 
       
   683 		if (message.get_is_valid() == false)
       
   684 		{
       
   685 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   686 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   687 		}
       
   688 
       
   689 		status = message.add_parameter_data(eapol_tlv_message_type_function_reassociate);
       
   690 		if (status != eap_status_ok)
       
   691 		{
       
   692 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   693 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   694 		}
       
   695 
       
   696 		status = message.add_parameter_data(send_network_id);
       
   697 		if (status != eap_status_ok)
       
   698 		{
       
   699 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   700 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   701 		}
       
   702 
       
   703 		status = message.add_parameter_data(
       
   704 			eapol_tlv_message_type_eapol_key_authentication_type,
       
   705 			static_cast<u32_t>(authentication_type));
       
   706 		if (status != eap_status_ok)
       
   707 		{
       
   708 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   709 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   710 		}
       
   711 
       
   712 		status = message.add_parameter_data(PMKID);
       
   713 		if (status != eap_status_ok)
       
   714 		{
       
   715 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   716 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   717 		}
       
   718 
       
   719 		status = send_message(&message);
       
   720 		if (status != eap_status_ok)
       
   721 		{
       
   722 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   723 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   724 		}
       
   725 	}
       
   726 
       
   727 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   728 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   729 }
       
   730 
       
   731 //--------------------------------------------------
       
   732 
       
   733 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::get_wlan_database_reference_values(
       
   734 	eap_variable_data_c * const reference) const
       
   735 {
       
   736 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   737 
       
   738 	if (m_wlan_database_reference.get_is_valid_data() == true
       
   739 		&& m_wlan_database_reference.get_data_length() > 0ul)
       
   740 	{
       
   741 
       
   742 		return reference->set_copy_of_buffer(&m_wlan_database_reference);
       
   743 	}
       
   744 	else
       
   745 	{
       
   746 		EAP_TRACE_ERROR(
       
   747 			m_am_tools,
       
   748 			TRACE_FLAGS_DEFAULT,
       
   749 			(EAPL("ERROR: get_header_offset(): no completed parameters.\n")));
       
   750 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT)
       
   751 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   752 	}
       
   753 }
       
   754 
       
   755 //--------------------------------------------------
       
   756 
       
   757 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::send_error_message(
       
   758 	const eap_status_e function_status,
       
   759 	const eapol_tlv_message_type_function_e function)
       
   760 {
       
   761 	wlan_eap_if_send_status_e error_code = wlan_eap_if_send_status_conversion_c::convert(function_status);
       
   762 
       
   763 	eap_status_e status(eap_status_ok);
       
   764 
       
   765 	{
       
   766 		// Creates message data composed of Attribute-Value Pairs.
       
   767 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   768 
       
   769 		if (message.get_is_valid() == false)
       
   770 		{
       
   771 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   772 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   773 		}
       
   774 
       
   775 		status = message.add_parameter_data(
       
   776 			eapol_tlv_message_type_error,
       
   777 			static_cast<u32_t>(error_code));
       
   778 		if (status != eap_status_ok)
       
   779 		{
       
   780 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   781 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   782 		}
       
   783 
       
   784 		status = message.add_parameter_data(function);
       
   785 		if (status != eap_status_ok)
       
   786 		{
       
   787 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   788 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   789 		}
       
   790 
       
   791 		status = send_message(&message);
       
   792 		if (status != eap_status_ok)
       
   793 		{
       
   794 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   795 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   796 		}
       
   797 	}
       
   798 
       
   799 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   800 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   801 }
       
   802 
       
   803 //--------------------------------------------------
       
   804 
       
   805 #if defined(USE_EAP_SIMPLE_CONFIG)
       
   806 
       
   807 //
       
   808 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::save_simple_config_session(
       
   809 	const simple_config_state_e /* state */,
       
   810 	EAP_TEMPLATE_CONST eap_array_c<simple_config_credential_c> * const credential_array,
       
   811 	const eap_variable_data_c * const /* new_password */,
       
   812 	const simple_config_Device_Password_ID_e /* Device_Password_ID */,
       
   813 	const simple_config_payloads_c * const /* other_configuration */)
       
   814 {
       
   815 	EAP_TRACE_DEBUG(
       
   816 		m_am_tools,
       
   817 		TRACE_FLAGS_DEFAULT,
       
   818 		(EAPL("eapol_message_wlan_authentication_c::save_simple_config_session()\n")));
       
   819 
       
   820 	// Message is formatted as:
       
   821 	// 0                   1                   2                   3   
       
   822 	//  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 
       
   823 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   824 	// |                    Type = Function                            |
       
   825 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   826 	// |                    Length = 4                                 |
       
   827 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   828 	// |                    Value = New_protected_setup_credentials    |
       
   829 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= start of Array of Protected setup credential
       
   830 	// |                    Type = Array                               |
       
   831 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   832 	// |                    Length = 137                               |
       
   833 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ <= start of Array of Protected setup credential value
       
   834 	// |                    Type = Protected setup credential          |
       
   835 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   836 	// |                    Length = 129                               |
       
   837 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   838 	// |                    Type = Unsigned 8 bit integer              |
       
   839 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   840 	// |                    Length = 1                                 |
       
   841 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   842 	// |   u8_t value  |
       
   843 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   844 	// |                    Type = Variable data                       |
       
   845 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   846 	// |                    Length = 12                                |
       
   847 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   848 	// |                    Value = SSID string                        |
       
   849 	// +-+-+-+-                                                 -+-+-+-+
       
   850 	// |                                                               |
       
   851 	// +-+-+-+-                                                 -+-+-+-+
       
   852 	// |                                                               |
       
   853 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   854 	// |                    Type = Unsigned 16 bit integer             |
       
   855 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   856 	// |                    Length = 2                                 |
       
   857 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   858 	// |   u16_t Authentication type   |
       
   859 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   860 	// |                    Type = Unsigned 16 bit integer             |
       
   861 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   862 	// |                    Length = 2                                 |
       
   863 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   864 	// |   u16_t Encryption type       |
       
   865 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= start of Array of Network key
       
   866 	// |                    Type = Array                               |
       
   867 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   868 	// |                    Length = 66                                |
       
   869 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ <= start of Array of Network key value
       
   870 	// |                    Type = Network key                         |
       
   871 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   872 	// |                    Length = 25                                |
       
   873 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   874 	// |                    Type = Unsigned 8 bit integer              |
       
   875 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   876 	// |                    Length = 1                                 |
       
   877 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   878 	// |   u8_t value  |
       
   879 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   880 	// |                    Type = Variable data                       |
       
   881 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   882 	// |                    Length = 8                                 |
       
   883 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   884 	// |                    Value = Network key                        |
       
   885 	// +-+-+-+-                                                 -+-+-+-+
       
   886 	// |                                                               |
       
   887 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   888 	// |                    Type = Network key                         |
       
   889 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   890 	// |                    Length = 25                                |
       
   891 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   892 	// |                    Type = Unsigned 8 bit integer              |
       
   893 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   894 	// |                    Length = 1                                 |
       
   895 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   896 	// |   u8_t value  |
       
   897 	// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
       
   898 	// |                    Type = Variable data                       |
       
   899 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   900 	// |                    Length = 8                                 |
       
   901 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   902 	// |                    Value = Network key                        |
       
   903 	// +-+-+-+-                                                 -+-+-+-+
       
   904 	// |                                                               |
       
   905 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+ <= end of Array of Network key
       
   906 	// |                    Type = Variable data                       |
       
   907 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   908 	// |                    Length = 6                                 |
       
   909 	// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   910 	// |                    Value = MAC address                        |
       
   911 	// +-+-+-+-                        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
   912 	// |                               |
       
   913 	// +#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+#+                                 <= end of Array of Protected setup credential
       
   914 
       
   915 
       
   916 	eap_status_e status(eap_status_ok);
       
   917 
       
   918 	{
       
   919 		// Creates message data composed of Attribute-Value Pairs.
       
   920 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
   921 
       
   922 		if (message.get_is_valid() == false)
       
   923 		{
       
   924 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   925 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   926 		}
       
   927 
       
   928 		status = message.add_parameter_data(eapol_tlv_message_type_function_new_protected_setup_credentials);
       
   929 		if (status != eap_status_ok)
       
   930 		{
       
   931 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   932 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   933 		}
       
   934 
       
   935 		status = message.add_parameter_data(credential_array);
       
   936 		if (status != eap_status_ok)
       
   937 		{
       
   938 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   939 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   940 		}
       
   941 
       
   942 		status = send_message(&message);
       
   943 		if (status != eap_status_ok)
       
   944 		{
       
   945 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   946 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   947 		}
       
   948 	}
       
   949 
       
   950 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   951 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   952 }
       
   953 
       
   954 #endif // #if defined(USE_EAP_SIMPLE_CONFIG)
       
   955 
       
   956 //--------------------------------------------------
       
   957 
       
   958 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::process_message_type_error(
       
   959 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   960 {
       
   961 	eap_status_e status(eap_status_ok);
       
   962 
       
   963 	{
       
   964 		// Error payload is the first in this case.
       
   965 		const eap_tlv_header_c * const error_header = parameters->get_object(eapol_message_payload_index_function);
       
   966 
       
   967 		if (error_header == 0
       
   968 			|| error_header->get_type() != eapol_tlv_message_type_error)
       
   969 		{
       
   970 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   971 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   972 		}
       
   973 
       
   974 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
   975 
       
   976 		if (message_data.get_is_valid() == false)
       
   977 		{
       
   978 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   979 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   980 		}
       
   981 
       
   982 		u32_t value(0ul);
       
   983 
       
   984 		status = message_data.get_parameter_data(error_header, &value);
       
   985 		if (status != eap_status_ok)
       
   986 		{
       
   987 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   988 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   989 		}
       
   990 
       
   991 		m_error_code = static_cast<wlan_eap_if_send_status_e>(value);
       
   992 	}
       
   993 
       
   994 	{
       
   995 		// Fuction payload is the second in this case.
       
   996 		const eap_tlv_header_c * const function_header = parameters->get_object(eapol_message_payload_index_first_parameter);
       
   997 
       
   998 		if (function_header == 0
       
   999 			|| function_header->get_type() != eapol_tlv_message_type_function)
       
  1000 		{
       
  1001 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1002 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1003 		}
       
  1004 
       
  1005 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1006 
       
  1007 		if (message_data.get_is_valid() == false)
       
  1008 		{
       
  1009 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1010 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1011 		}
       
  1012 
       
  1013 		status = message_data.get_parameter_data(function_header, &m_error_function);
       
  1014 		if (status != eap_status_ok)
       
  1015 		{
       
  1016 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1017 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1018 		}
       
  1019 	}
       
  1020 
       
  1021 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1022 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  1023 }
       
  1024 
       
  1025 //--------------------------------------------------
       
  1026 
       
  1027 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::send_message(eapol_handle_tlv_message_data_c * const message)
       
  1028 {
       
  1029 	// Sends message data composed of Attribute-Value Pairs.
       
  1030 
       
  1031 	EAP_TRACE_DATA_DEBUG(
       
  1032 		m_am_tools,
       
  1033 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
  1034 		(EAPL("eapol_message_wlan_authentication_c::send_message()"),
       
  1035 		message->get_message_data(),
       
  1036 		message->get_message_data_length()));
       
  1037 
       
  1038 #if defined(USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST)
       
  1039 
       
  1040 	if (m_use_asyncronous_test == true)
       
  1041 	{
       
  1042 		eap_status_e status(eap_status_ok);
       
  1043 
       
  1044 		eapol_handle_tlv_message_data_c * copy_message = new eapol_handle_tlv_message_data_c(m_am_tools);
       
  1045 
       
  1046 		eap_automatic_variable_c<eapol_handle_tlv_message_data_c> automatic_message(m_am_tools, copy_message);
       
  1047 
       
  1048 		if (copy_message == 0
       
  1049 			|| copy_message->get_is_valid() == false)
       
  1050 		{
       
  1051 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1052 
       
  1053 			status = eap_status_allocation_error;
       
  1054 
       
  1055 			(void) send_error_message(
       
  1056 				status,
       
  1057 				eapol_tlv_message_type_function_none);
       
  1058 
       
  1059 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1060 		}
       
  1061 
       
  1062 		status = copy_message->copy_message_data(
       
  1063 			message->get_message_data_length(),
       
  1064 			message->get_message_data());
       
  1065 		if (status != eap_status_ok)
       
  1066 		{
       
  1067 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1068 
       
  1069 			(void) send_error_message(
       
  1070 				status,
       
  1071 				eapol_tlv_message_type_function_none);
       
  1072 
       
  1073 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1074 		}
       
  1075 
       
  1076 		automatic_message.do_not_free_variable();
       
  1077 
       
  1078 		EAP_TRACE_DEBUG(
       
  1079 			m_am_tools, 
       
  1080 			TRACE_FLAGS_DEFAULT, 
       
  1081 			(EAPL("TIMER: eapol_message_wlan_authentication_c::process_data(): sets EAPOL_MESSAGE_TIMER_SEND_DATA_ID\n")));
       
  1082 	
       
  1083 		status = m_am_tools->am_set_timer(
       
  1084 			this,
       
  1085 			EAPOL_MESSAGE_TIMER_SEND_DATA_ID, 
       
  1086 			copy_message,
       
  1087 			0ul);
       
  1088 
       
  1089 		if (status != eap_status_ok)
       
  1090 		{
       
  1091 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1092 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1093 		}
       
  1094 
       
  1095 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1096 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1097 	}
       
  1098 	else
       
  1099 
       
  1100 #endif
       
  1101 
       
  1102 	{
       
  1103 		wlan_eap_if_send_status_e send_status = m_partner->send_data(
       
  1104 			message->get_message_data(),
       
  1105 			message->get_message_data_length());
       
  1106 		if (send_status != wlan_eap_if_send_status_ok)
       
  1107 		{
       
  1108 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1109 			return EAP_STATUS_RETURN(m_am_tools,
       
  1110 				wlan_eap_if_send_status_conversion_c::convert(send_status));
       
  1111 		}
       
  1112 
       
  1113 
       
  1114 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1115 		return EAP_STATUS_RETURN(m_am_tools,
       
  1116 			wlan_eap_if_send_status_conversion_c::convert(send_status));
       
  1117 	}
       
  1118 }
       
  1119 
       
  1120 //--------------------------------------------------
       
  1121 
       
  1122 EAP_FUNC_EXPORT wlan_eap_if_send_status_e eapol_message_wlan_authentication_c::process_data(const void * const data, const u32_t length)
       
  1123 {
       
  1124 	// Parses message data composed of Attribute-Value Pairs.
       
  1125 
       
  1126 	eap_status_e status(eap_status_ok);
       
  1127 
       
  1128 #if defined(USE_EAPOL_WLAN_AUTHENTICATION_MESSAGE_ASYNCRONOUS_TEST)
       
  1129 
       
  1130 	if (m_use_asyncronous_test == true)
       
  1131 	{
       
  1132 		eapol_handle_tlv_message_data_c * message = new eapol_handle_tlv_message_data_c(m_am_tools);
       
  1133 
       
  1134 		eap_automatic_variable_c<eapol_handle_tlv_message_data_c> automatic_message(m_am_tools, message);
       
  1135 
       
  1136 		if (message == 0
       
  1137 			|| message->get_is_valid() == false)
       
  1138 		{
       
  1139 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1140 
       
  1141 			status = eap_status_allocation_error;
       
  1142 
       
  1143 			(void) send_error_message(
       
  1144 				status,
       
  1145 				eapol_tlv_message_type_function_none);
       
  1146 
       
  1147 			return wlan_eap_if_send_status_conversion_c::convert(
       
  1148 				EAP_STATUS_RETURN(m_am_tools, status));
       
  1149 		}
       
  1150 
       
  1151 		status = message->copy_message_data(length, data);
       
  1152 		if (status != eap_status_ok)
       
  1153 		{
       
  1154 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1155 
       
  1156 			(void) send_error_message(
       
  1157 				status,
       
  1158 				eapol_tlv_message_type_function_none);
       
  1159 
       
  1160 			return wlan_eap_if_send_status_conversion_c::convert(
       
  1161 				EAP_STATUS_RETURN(m_am_tools, status));
       
  1162 		}
       
  1163 
       
  1164 		automatic_message.do_not_free_variable();
       
  1165 
       
  1166 		EAP_TRACE_DEBUG(
       
  1167 			m_am_tools, 
       
  1168 			TRACE_FLAGS_DEFAULT, 
       
  1169 			(EAPL("TIMER: eapol_message_wlan_authentication_c::process_data(): sets EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID\n")));
       
  1170 	
       
  1171 		status = m_am_tools->am_set_timer(
       
  1172 			this,
       
  1173 			EAPOL_MESSAGE_TIMER_PROCESS_DATA_ID, 
       
  1174 			message,
       
  1175 			0ul);
       
  1176 		if (status != eap_status_ok)
       
  1177 		{
       
  1178 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1179 			return wlan_eap_if_send_status_conversion_c::convert(
       
  1180 				EAP_STATUS_RETURN(m_am_tools, status));
       
  1181 		}
       
  1182 	}
       
  1183 	else
       
  1184 
       
  1185 #endif
       
  1186 
       
  1187 	{
       
  1188 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
  1189 
       
  1190 		if (message.get_is_valid() == false)
       
  1191 		{
       
  1192 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1193 
       
  1194 			status = eap_status_allocation_error;
       
  1195 
       
  1196 			(void) send_error_message(
       
  1197 				status,
       
  1198 				eapol_tlv_message_type_function_none);
       
  1199 
       
  1200 			return wlan_eap_if_send_status_conversion_c::convert(
       
  1201 				EAP_STATUS_RETURN(m_am_tools, status));
       
  1202 		}
       
  1203 
       
  1204 		status = message.set_message_data(length, data);
       
  1205 		if (status != eap_status_ok)
       
  1206 		{
       
  1207 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1208 
       
  1209 			(void) send_error_message(
       
  1210 				status,
       
  1211 				eapol_tlv_message_type_function_none);
       
  1212 
       
  1213 			return wlan_eap_if_send_status_conversion_c::convert(
       
  1214 				EAP_STATUS_RETURN(m_am_tools, status));
       
  1215 		}
       
  1216 
       
  1217 		status = process_message(&message);
       
  1218 	}
       
  1219 
       
  1220 	return wlan_eap_if_send_status_conversion_c::convert(
       
  1221 		EAP_STATUS_RETURN(m_am_tools, status));
       
  1222 }
       
  1223 
       
  1224 //--------------------------------------------------
       
  1225 
       
  1226 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::process_message(eapol_handle_tlv_message_data_c * const message)
       
  1227 {
       
  1228 	// Parses message data composed of Attribute-Value Pairs.
       
  1229 
       
  1230 	EAP_TRACE_DATA_DEBUG(
       
  1231 		m_am_tools,
       
  1232 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
  1233 		(EAPL("eapol_message_wlan_authentication_c::process_message()"),
       
  1234 		message->get_message_data(),
       
  1235 		message->get_message_data_length()));
       
  1236 
       
  1237 	eap_array_c<eap_tlv_header_c> parameters(m_am_tools);
       
  1238 
       
  1239 	eap_status_e status = message->parse_message_data(&parameters);
       
  1240 	if (status != eap_status_ok)
       
  1241 	{
       
  1242 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1243 
       
  1244 		(void) send_error_message(
       
  1245 			status,
       
  1246 			eapol_tlv_message_type_function_none);
       
  1247 
       
  1248 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1249 	}
       
  1250 
       
  1251 	if (parameters.get_object_count() == 0)
       
  1252 	{
       
  1253 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1254 
       
  1255 		status = eap_status_illegal_parameter;
       
  1256 
       
  1257 		(void) send_error_message(
       
  1258 			status,
       
  1259 			eapol_tlv_message_type_function_none);
       
  1260 
       
  1261 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1262 	}
       
  1263 
       
  1264 	const eap_tlv_header_c * const function_header = parameters.get_object(eapol_message_payload_index_function);
       
  1265 	if (function_header == 0
       
  1266 		|| (function_header->get_type() != eapol_tlv_message_type_error
       
  1267 			&& function_header->get_type() != eapol_tlv_message_type_function))
       
  1268 	{
       
  1269 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1270 
       
  1271 		status = eap_status_illegal_parameter;
       
  1272 
       
  1273 		(void) send_error_message(
       
  1274 			status,
       
  1275 			eapol_tlv_message_type_function_none);
       
  1276 
       
  1277 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  1278 	}
       
  1279 
       
  1280 	if (function_header->get_type() == eapol_tlv_message_type_error)
       
  1281 	{
       
  1282 		status = process_message_type_error(&parameters);
       
  1283 	}
       
  1284 	else // function_header->get_type() == eapol_tlv_message_type_function
       
  1285 	{
       
  1286 		eapol_tlv_message_type_function_e function(eapol_tlv_message_type_function_none);
       
  1287 
       
  1288 		status = message->get_parameter_data(function_header, &function);
       
  1289 		if (status != eap_status_ok)
       
  1290 		{
       
  1291 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1292 
       
  1293 			(void) send_error_message(
       
  1294 				status,
       
  1295 				eapol_tlv_message_type_function_none);
       
  1296 
       
  1297 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1298 		}
       
  1299 
       
  1300 		switch(function)
       
  1301 		{
       
  1302 		case eapol_tlv_message_type_function_check_pmksa_cache:
       
  1303 			status = check_pmksa_cache(&parameters);
       
  1304 			break;
       
  1305 		case eapol_tlv_message_type_function_start_authentication:
       
  1306 			status = start_authentication(&parameters);
       
  1307 			break;
       
  1308 		case eapol_tlv_message_type_function_complete_association:
       
  1309 			status = complete_association(&parameters);
       
  1310 			break;
       
  1311 		case eapol_tlv_message_type_function_disassociation:
       
  1312 			status = disassociation(&parameters);
       
  1313 			break;
       
  1314 		case eapol_tlv_message_type_function_start_preauthentication:
       
  1315 			status = start_preauthentication(&parameters);
       
  1316 			break;
       
  1317 		case eapol_tlv_message_type_function_start_reassociation:
       
  1318 			status = start_reassociation(&parameters);
       
  1319 			break;
       
  1320 		case eapol_tlv_message_type_function_complete_reassociation:
       
  1321 			status = complete_reassociation(&parameters);
       
  1322 			break;
       
  1323 		case eapol_tlv_message_type_function_start_WPXM_reassociation:
       
  1324 			status = start_WPXM_reassociation(&parameters);
       
  1325 			break;
       
  1326 		case eapol_tlv_message_type_function_complete_WPXM_reassociation:
       
  1327 			status = complete_WPXM_reassociation(&parameters);
       
  1328 			break;
       
  1329 		case eapol_tlv_message_type_function_packet_process:
       
  1330 			status = packet_process(&parameters);
       
  1331 			break;
       
  1332 		case eapol_tlv_message_type_function_tkip_mic_failure:
       
  1333 			status = tkip_mic_failure(&parameters);
       
  1334 			break;
       
  1335 		case eapol_tlv_message_type_function_eap_acknowledge:
       
  1336 			status = eap_acknowledge(&parameters);
       
  1337 			break;
       
  1338 		case eapol_tlv_message_type_function_update_header_offset:
       
  1339 			status = update_header_offset(&parameters);
       
  1340 			break;
       
  1341 		case eapol_tlv_message_type_function_update_wlan_database_reference_values:
       
  1342 			status = update_wlan_database_reference_values(&parameters);
       
  1343 			break;
       
  1344 		default:
       
  1345 			EAP_TRACE_ERROR(
       
  1346 				m_am_tools,
       
  1347 				TRACE_FLAGS_DEFAULT,
       
  1348 				(EAPL("ERROR: process_data(): unknown function %d.\n"),
       
  1349 				 function));
       
  1350 
       
  1351 			status = eap_status_illegal_parameter;
       
  1352 		};
       
  1353 
       
  1354 		if (status != eap_status_ok
       
  1355 			&& status != eap_status_success
       
  1356 			&& status != eap_status_pending_request
       
  1357 			&& status != eap_status_completed_request
       
  1358 			&& status != eap_status_drop_packet_quietly)
       
  1359 		{
       
  1360 			(void) send_error_message(
       
  1361 				status,
       
  1362 				function);
       
  1363 		}
       
  1364 	}
       
  1365 
       
  1366 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1367 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1368 }
       
  1369 
       
  1370 //--------------------------------------------------
       
  1371 
       
  1372 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::check_pmksa_cache(
       
  1373 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1374 {
       
  1375 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1376 
       
  1377 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1378 
       
  1379 	eap_status_e status(eap_status_ok);
       
  1380 
       
  1381 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  1382 
       
  1383 	eap_array_c<eap_am_network_id_c> bssid_sta_receive_network_ids(m_am_tools);
       
  1384 
       
  1385 	{
       
  1386 		const eap_tlv_header_c * const array_of_network_ids
       
  1387 			= parameters->get_object(parameter_index);
       
  1388 
       
  1389 		if (array_of_network_ids == 0
       
  1390 			|| array_of_network_ids->get_type() != eapol_tlv_message_type_array)
       
  1391 		{
       
  1392 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1393 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1394 		}
       
  1395 
       
  1396 		eapol_handle_tlv_message_data_c array_data(m_am_tools);
       
  1397 
       
  1398 		if (array_data.get_is_valid() == false)
       
  1399 		{
       
  1400 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1401 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1402 		}
       
  1403 
       
  1404 		status = array_data.set_message_data(
       
  1405 			array_of_network_ids->get_value_length(),
       
  1406 			array_of_network_ids->get_value(array_of_network_ids->get_value_length()));
       
  1407 
       
  1408 		if (status != eap_status_ok)
       
  1409 		{
       
  1410 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1411 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1412 		}
       
  1413 
       
  1414 		eap_array_c<eap_tlv_header_c> network_ids(m_am_tools);
       
  1415 
       
  1416 		status = array_data.parse_message_data(
       
  1417 			&network_ids);
       
  1418 		if (status != eap_status_ok)
       
  1419 		{
       
  1420 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1421 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1422 		}
       
  1423 
       
  1424 		for (u32_t ind = 0ul; ind < network_ids.get_object_count(); ++ind)
       
  1425 		{
       
  1426 			const eap_tlv_header_c * const header = network_ids.get_object(ind);
       
  1427 
       
  1428 			if (header == 0)
       
  1429 			{
       
  1430 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1431 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1432 			}
       
  1433 
       
  1434 			eap_am_network_id_c * const new_network_id = new eap_am_network_id_c(m_am_tools);
       
  1435 			if (new_network_id == 0)
       
  1436 			{
       
  1437 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1438 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1439 			}
       
  1440 
       
  1441 			eap_automatic_variable_c<eap_am_network_id_c> automatic_new_network_id(m_am_tools, new_network_id);
       
  1442 
       
  1443 			status = array_data.get_parameter_data(header, new_network_id);
       
  1444 			if (status != eap_status_ok)
       
  1445 			{
       
  1446 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1447 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1448 			}
       
  1449 
       
  1450 			automatic_new_network_id.do_not_free_variable();
       
  1451 
       
  1452 			status = bssid_sta_receive_network_ids.add_object(
       
  1453 				new_network_id,
       
  1454 				true);
       
  1455 			if (status != eap_status_ok)
       
  1456 			{
       
  1457 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1458 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1459 			}
       
  1460 
       
  1461 		} // for()
       
  1462 	}
       
  1463 
       
  1464 
       
  1465 	++parameter_index;
       
  1466 
       
  1467 	eapol_key_authentication_type_e selected_eapol_key_authentication_type(eapol_key_authentication_type_none);
       
  1468 
       
  1469 	{
       
  1470 		const eap_tlv_header_c * const authentication_type
       
  1471 			= parameters->get_object(parameter_index);
       
  1472 
       
  1473 		if (authentication_type == 0
       
  1474 			|| authentication_type->get_type() != eapol_tlv_message_type_eapol_key_authentication_type)
       
  1475 		{
       
  1476 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1477 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1478 		}
       
  1479 
       
  1480 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1481 
       
  1482 		if (message_data.get_is_valid() == false)
       
  1483 		{
       
  1484 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1485 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1486 		}
       
  1487 
       
  1488 		u32_t value(0ul);
       
  1489 
       
  1490 		status = message_data.get_parameter_data(authentication_type, &value);
       
  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 		selected_eapol_key_authentication_type = static_cast<eapol_key_authentication_type_e>(value);
       
  1498 	}
       
  1499 
       
  1500 
       
  1501 	++parameter_index;
       
  1502 
       
  1503 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  1504 
       
  1505 	{
       
  1506 		const eap_tlv_header_c * const authentication_type
       
  1507 			= parameters->get_object(parameter_index);
       
  1508 
       
  1509 		if (authentication_type == 0
       
  1510 			|| authentication_type->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  1511 		{
       
  1512 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1513 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1514 		}
       
  1515 
       
  1516 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1517 
       
  1518 		if (message_data.get_is_valid() == false)
       
  1519 		{
       
  1520 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1521 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1522 		}
       
  1523 
       
  1524 		u32_t value(0ul);
       
  1525 
       
  1526 		status = message_data.get_parameter_data(authentication_type, &value);
       
  1527 		if (status != eap_status_ok)
       
  1528 		{
       
  1529 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1530 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1531 		}
       
  1532 
       
  1533 		pairwise_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  1534 	}
       
  1535 
       
  1536 
       
  1537 	++parameter_index;
       
  1538 
       
  1539 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  1540 
       
  1541 	{
       
  1542 		const eap_tlv_header_c * const authentication_type
       
  1543 			= parameters->get_object(parameter_index);
       
  1544 
       
  1545 		if (authentication_type == 0
       
  1546 			|| authentication_type->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  1547 		{
       
  1548 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1549 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1550 		}
       
  1551 
       
  1552 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1553 
       
  1554 		if (message_data.get_is_valid() == false)
       
  1555 		{
       
  1556 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1557 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1558 		}
       
  1559 
       
  1560 		u32_t value(0ul);
       
  1561 
       
  1562 		status = message_data.get_parameter_data(authentication_type, &value);
       
  1563 		if (status != eap_status_ok)
       
  1564 		{
       
  1565 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1566 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1567 		}
       
  1568 
       
  1569 		group_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  1570 	}
       
  1571 
       
  1572 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1573 
       
  1574 	status = m_wauth->check_pmksa_cache(
       
  1575 		&bssid_sta_receive_network_ids,
       
  1576 		selected_eapol_key_authentication_type,
       
  1577 		pairwise_key_cipher_suite,
       
  1578 		group_key_cipher_suite);
       
  1579 
       
  1580 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1581 
       
  1582 	if (status == eap_status_ok
       
  1583 		|| status == eap_status_not_found)
       
  1584 	{
       
  1585 		// Creates message data composed of Attribute-Value Pairs.
       
  1586 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
  1587 
       
  1588 		if (message.get_is_valid() == false)
       
  1589 		{
       
  1590 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1591 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1592 		}
       
  1593 
       
  1594 		status = message.add_parameter_data(
       
  1595 			eapol_tlv_message_type_function_complete_check_pmksa_cache);
       
  1596 		if (status != eap_status_ok)
       
  1597 		{
       
  1598 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1599 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1600 		}
       
  1601 
       
  1602 		u32_t network_id_parameters_size(0ul);
       
  1603 		u32_t ind = 0ul;
       
  1604 
       
  1605 		// Calculates the message size.
       
  1606 		for (ind = 0ul; ind < bssid_sta_receive_network_ids.get_object_count(); ++ind)
       
  1607 		{
       
  1608 			const eap_am_network_id_c * const network_id = bssid_sta_receive_network_ids.get_object(ind);
       
  1609 			if (network_id == 0)
       
  1610 			{
       
  1611 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1612 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1613 			}
       
  1614 
       
  1615 			network_id_parameters_size += 
       
  1616 				eap_tlv_header_c::get_header_length()
       
  1617 				+ message.get_payload_size(network_id);
       
  1618 		}
       
  1619 
       
  1620 		status = message.add_structured_parameter_header(
       
  1621 			eapol_tlv_message_type_array,
       
  1622 			network_id_parameters_size);
       
  1623 		if (status != eap_status_ok)
       
  1624 		{
       
  1625 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1626 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1627 		}
       
  1628 		
       
  1629 		// Adds network ID array objects to message.
       
  1630 		for (ind = 0ul; ind < bssid_sta_receive_network_ids.get_object_count(); ++ind)
       
  1631 		{
       
  1632 			const eap_am_network_id_c * const network_id = bssid_sta_receive_network_ids.get_object(ind);
       
  1633 			if (network_id == 0)
       
  1634 			{
       
  1635 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1636 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1637 			}
       
  1638 
       
  1639 			status = message.add_parameter_data(
       
  1640 				network_id);
       
  1641 			if (status != eap_status_ok)
       
  1642 			{
       
  1643 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1644 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1645 			}
       
  1646 		}
       
  1647 
       
  1648 		status = send_message(&message);
       
  1649 		if (status != eap_status_ok)
       
  1650 		{
       
  1651 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1652 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1653 		}
       
  1654 	}
       
  1655 
       
  1656 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1657 
       
  1658 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1659 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1660 }
       
  1661 
       
  1662 //--------------------------------------------------
       
  1663 
       
  1664 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::start_authentication(
       
  1665 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1666 {
       
  1667 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1668 
       
  1669 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1670 
       
  1671 	eap_status_e status(eap_status_ok);
       
  1672 
       
  1673 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  1674 
       
  1675 	eap_variable_data_c SSID(m_am_tools);
       
  1676 
       
  1677 	if (SSID.get_is_valid() == false)
       
  1678 	{
       
  1679 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1680 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1681 	}
       
  1682 
       
  1683 	{
       
  1684 		const eap_tlv_header_c * const ssid_parameter
       
  1685 			= parameters->get_object(parameter_index);
       
  1686 
       
  1687 		if (ssid_parameter == 0
       
  1688 			|| ssid_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  1689 		{
       
  1690 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1691 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1692 		}
       
  1693 
       
  1694 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1695 
       
  1696 		if (message_data.get_is_valid() == false)
       
  1697 		{
       
  1698 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1699 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1700 		}
       
  1701 
       
  1702 		status = message_data.get_parameter_data(ssid_parameter, &SSID);
       
  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 	++parameter_index;
       
  1712 
       
  1713 	eapol_key_authentication_type_e selected_eapol_key_authentication_type(eapol_key_authentication_type_none);
       
  1714 
       
  1715 	{
       
  1716 		const eap_tlv_header_c * const authentication_type_parameter
       
  1717 			= parameters->get_object(parameter_index);
       
  1718 
       
  1719 		if (authentication_type_parameter == 0
       
  1720 			|| authentication_type_parameter->get_type() != eapol_tlv_message_type_eapol_key_authentication_type)
       
  1721 		{
       
  1722 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1723 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1724 		}
       
  1725 
       
  1726 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1727 
       
  1728 		if (message_data.get_is_valid() == false)
       
  1729 		{
       
  1730 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1731 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1732 		}
       
  1733 
       
  1734 		u32_t value(0ul);
       
  1735 
       
  1736 		status = message_data.get_parameter_data(authentication_type_parameter, &value);
       
  1737 		if (status != eap_status_ok)
       
  1738 		{
       
  1739 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1740 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1741 		}
       
  1742 
       
  1743 		selected_eapol_key_authentication_type = static_cast<eapol_key_authentication_type_e>(value);
       
  1744 	}
       
  1745 
       
  1746 
       
  1747 	++parameter_index;
       
  1748 
       
  1749 	eap_variable_data_c wpa_preshared_key(m_am_tools);
       
  1750 
       
  1751 	{
       
  1752 		const eap_tlv_header_c * const wpa_preshared_key_parameter
       
  1753 			= parameters->get_object(parameter_index);
       
  1754 
       
  1755 		if (wpa_preshared_key_parameter == 0
       
  1756 			|| wpa_preshared_key_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  1757 		{
       
  1758 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1759 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1760 		}
       
  1761 
       
  1762 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1763 
       
  1764 		if (message_data.get_is_valid() == false)
       
  1765 		{
       
  1766 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1767 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1768 		}
       
  1769 
       
  1770 		status = message_data.get_parameter_data(wpa_preshared_key_parameter, &wpa_preshared_key);
       
  1771 		if (status != eap_status_ok)
       
  1772 		{
       
  1773 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1774 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1775 		}
       
  1776 	}
       
  1777 
       
  1778 
       
  1779 	++parameter_index;
       
  1780 
       
  1781 	bool WPA_override_enabled(false);
       
  1782 
       
  1783 	{
       
  1784 		const eap_tlv_header_c * const WPA_override_enabled_parameter
       
  1785 			= parameters->get_object(parameter_index);
       
  1786 
       
  1787 		if (WPA_override_enabled_parameter == 0
       
  1788 			|| WPA_override_enabled_parameter->get_type() != eapol_tlv_message_type_boolean)
       
  1789 		{
       
  1790 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1791 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1792 		}
       
  1793 
       
  1794 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1795 
       
  1796 		if (message_data.get_is_valid() == false)
       
  1797 		{
       
  1798 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1799 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1800 		}
       
  1801 
       
  1802 		u32_t value(0ul);
       
  1803 
       
  1804 		status = message_data.get_parameter_data(WPA_override_enabled_parameter, &value);
       
  1805 		if (status != eap_status_ok)
       
  1806 		{
       
  1807 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1808 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1809 		}
       
  1810 
       
  1811 		WPA_override_enabled = (value == 0) ? false: true;
       
  1812 	}
       
  1813 
       
  1814 
       
  1815 #if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
  1816 
       
  1817 	++parameter_index;
       
  1818 
       
  1819 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1820 
       
  1821 	{
       
  1822 		const eap_tlv_header_c * const receive_network_id_parameter
       
  1823 			= parameters->get_object(parameter_index);
       
  1824 
       
  1825 		if (receive_network_id_parameter == 0
       
  1826 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  1827 		{
       
  1828 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1829 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1830 		}
       
  1831 
       
  1832 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1833 
       
  1834 		if (message_data.get_is_valid() == false)
       
  1835 		{
       
  1836 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1837 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1838 		}
       
  1839 
       
  1840 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  1841 		if (status != eap_status_ok)
       
  1842 		{
       
  1843 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1844 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1845 		}
       
  1846 	}
       
  1847 
       
  1848 #endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
  1849 
       
  1850 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1851 
       
  1852 	status = m_wauth->start_authentication(
       
  1853 		&SSID,
       
  1854 		selected_eapol_key_authentication_type,
       
  1855 		&wpa_preshared_key,
       
  1856 		WPA_override_enabled
       
  1857 #if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
  1858 		, &receive_network_id
       
  1859 #endif //#if defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE)
       
  1860 		);
       
  1861 
       
  1862 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1863 
       
  1864 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1865 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  1866 }
       
  1867 
       
  1868 //--------------------------------------------------
       
  1869 
       
  1870 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::complete_association(
       
  1871 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  1872 {
       
  1873 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1874 
       
  1875 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  1876 
       
  1877 	eap_status_e status(eap_status_ok);
       
  1878 
       
  1879 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  1880 
       
  1881 	eapol_wlan_authentication_state_e association_result(eapol_wlan_authentication_state_none);
       
  1882 
       
  1883 	{
       
  1884 		const eap_tlv_header_c * const association_result_parameter
       
  1885 			= parameters->get_object(parameter_index);
       
  1886 
       
  1887 		if (association_result_parameter == 0
       
  1888 			|| association_result_parameter->get_type() != eapol_tlv_message_type_eapol_wlan_authentication_state)
       
  1889 		{
       
  1890 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1891 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1892 		}
       
  1893 
       
  1894 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1895 
       
  1896 		if (message_data.get_is_valid() == false)
       
  1897 		{
       
  1898 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1899 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1900 		}
       
  1901 
       
  1902 		u32_t value(0ul);
       
  1903 
       
  1904 		status = message_data.get_parameter_data(association_result_parameter, &value);
       
  1905 		if (status != eap_status_ok)
       
  1906 		{
       
  1907 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1908 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1909 		}
       
  1910 
       
  1911 		association_result = static_cast<eapol_wlan_authentication_state_e>(value);
       
  1912 	}
       
  1913 
       
  1914 
       
  1915 	++parameter_index;
       
  1916 
       
  1917 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  1918 
       
  1919 	{
       
  1920 		const eap_tlv_header_c * const receive_network_id_parameter
       
  1921 			= parameters->get_object(parameter_index);
       
  1922 
       
  1923 		if (receive_network_id_parameter == 0
       
  1924 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  1925 		{
       
  1926 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1927 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1928 		}
       
  1929 
       
  1930 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1931 
       
  1932 		if (message_data.get_is_valid() == false)
       
  1933 		{
       
  1934 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1935 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1936 		}
       
  1937 
       
  1938 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  1939 		if (status != eap_status_ok)
       
  1940 		{
       
  1941 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1942 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1943 		}
       
  1944 	}
       
  1945 
       
  1946 
       
  1947 	++parameter_index;
       
  1948 
       
  1949 	eap_variable_data_c received_WPA_IE(m_am_tools);
       
  1950 
       
  1951 	{
       
  1952 		const eap_tlv_header_c * const received_WPA_IE_parameter
       
  1953 			= parameters->get_object(parameter_index);
       
  1954 
       
  1955 		if (received_WPA_IE_parameter == 0
       
  1956 			|| received_WPA_IE_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  1957 		{
       
  1958 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1959 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1960 		}
       
  1961 
       
  1962 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1963 
       
  1964 		if (message_data.get_is_valid() == false)
       
  1965 		{
       
  1966 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1967 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  1968 		}
       
  1969 
       
  1970 		status = message_data.get_parameter_data(received_WPA_IE_parameter, &received_WPA_IE);
       
  1971 		if (status != eap_status_ok)
       
  1972 		{
       
  1973 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1974 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1975 		}
       
  1976 	}
       
  1977 
       
  1978 
       
  1979 	++parameter_index;
       
  1980 
       
  1981 	eap_variable_data_c sent_WPA_IE(m_am_tools);
       
  1982 
       
  1983 	{
       
  1984 		const eap_tlv_header_c * const sent_WPA_IE_parameter
       
  1985 			= parameters->get_object(parameter_index);
       
  1986 
       
  1987 		if (sent_WPA_IE_parameter == 0
       
  1988 			|| sent_WPA_IE_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  1989 		{
       
  1990 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1991 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  1992 		}
       
  1993 
       
  1994 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  1995 
       
  1996 		if (message_data.get_is_valid() == false)
       
  1997 		{
       
  1998 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1999 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2000 		}
       
  2001 
       
  2002 		status = message_data.get_parameter_data(sent_WPA_IE_parameter, &sent_WPA_IE);
       
  2003 		if (status != eap_status_ok)
       
  2004 		{
       
  2005 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2006 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2007 		}
       
  2008 	}
       
  2009 
       
  2010 
       
  2011 	++parameter_index;
       
  2012 
       
  2013 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  2014 
       
  2015 	{
       
  2016 		const eap_tlv_header_c * const pairwise_key_cipher_suite_parameter
       
  2017 			= parameters->get_object(parameter_index);
       
  2018 
       
  2019 		if (pairwise_key_cipher_suite_parameter == 0
       
  2020 			|| pairwise_key_cipher_suite_parameter->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  2021 		{
       
  2022 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2023 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2024 		}
       
  2025 
       
  2026 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2027 
       
  2028 		if (message_data.get_is_valid() == false)
       
  2029 		{
       
  2030 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2031 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2032 		}
       
  2033 
       
  2034 		u32_t value(0ul);
       
  2035 
       
  2036 		status = message_data.get_parameter_data(pairwise_key_cipher_suite_parameter, &value);
       
  2037 		if (status != eap_status_ok)
       
  2038 		{
       
  2039 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2040 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2041 		}
       
  2042 
       
  2043 		pairwise_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  2044 	}
       
  2045 
       
  2046 	++parameter_index;
       
  2047 
       
  2048 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  2049 
       
  2050 	{
       
  2051 		const eap_tlv_header_c * const group_key_cipher_suite_parameter
       
  2052 			= parameters->get_object(parameter_index);
       
  2053 
       
  2054 		if (group_key_cipher_suite_parameter == 0
       
  2055 			|| group_key_cipher_suite_parameter->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  2056 		{
       
  2057 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2058 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2059 		}
       
  2060 
       
  2061 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2062 
       
  2063 		if (message_data.get_is_valid() == false)
       
  2064 		{
       
  2065 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2066 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2067 		}
       
  2068 
       
  2069 		u32_t value(0ul);
       
  2070 
       
  2071 		status = message_data.get_parameter_data(group_key_cipher_suite_parameter, &value);
       
  2072 		if (status != eap_status_ok)
       
  2073 		{
       
  2074 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2075 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2076 		}
       
  2077 
       
  2078 		group_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  2079 	}
       
  2080 
       
  2081 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2082 
       
  2083 	status = m_wauth->complete_association(
       
  2084 		association_result,
       
  2085 		&receive_network_id, ///< source includes remote address, destination includes local address.
       
  2086 		&received_WPA_IE, // WLM must give only the WPA IE to EAPOL
       
  2087 		&sent_WPA_IE,
       
  2088 		pairwise_key_cipher_suite,
       
  2089 		group_key_cipher_suite
       
  2090 		);
       
  2091 
       
  2092 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2093 
       
  2094 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2095 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2096 }
       
  2097 
       
  2098 //--------------------------------------------------
       
  2099 
       
  2100 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::disassociation(
       
  2101 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2102 {
       
  2103 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2104 
       
  2105 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2106 
       
  2107 	eap_status_e status(eap_status_ok);
       
  2108 
       
  2109 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2110 
       
  2111 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  2112 
       
  2113 	{
       
  2114 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2115 			= parameters->get_object(parameter_index);
       
  2116 
       
  2117 		if (receive_network_id_parameter == 0
       
  2118 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2119 		{
       
  2120 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2121 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2122 		}
       
  2123 
       
  2124 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2125 
       
  2126 		if (message_data.get_is_valid() == false)
       
  2127 		{
       
  2128 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2129 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2130 		}
       
  2131 
       
  2132 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  2133 		if (status != eap_status_ok)
       
  2134 		{
       
  2135 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2136 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2137 		}
       
  2138 	}
       
  2139 
       
  2140 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2141 
       
  2142 	status = m_wauth->disassociation(
       
  2143 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  2144 		);
       
  2145 
       
  2146 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2147 
       
  2148 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2149 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2150 }
       
  2151 
       
  2152 //--------------------------------------------------
       
  2153 
       
  2154 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::start_preauthentication(
       
  2155 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2156 {
       
  2157 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2158 
       
  2159 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2160 
       
  2161 	eap_status_e status(eap_status_ok);
       
  2162 
       
  2163 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2164 
       
  2165 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  2166 
       
  2167 	{
       
  2168 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2169 			= parameters->get_object(parameter_index);
       
  2170 
       
  2171 		if (receive_network_id_parameter == 0
       
  2172 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2173 		{
       
  2174 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2175 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2176 		}
       
  2177 
       
  2178 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2179 
       
  2180 		if (message_data.get_is_valid() == false)
       
  2181 		{
       
  2182 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2183 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2184 		}
       
  2185 
       
  2186 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  2187 		if (status != eap_status_ok)
       
  2188 		{
       
  2189 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2190 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2191 		}
       
  2192 	}
       
  2193 
       
  2194 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2195 
       
  2196 	status = m_wauth->start_preauthentication(
       
  2197 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  2198 		);
       
  2199 
       
  2200 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2201 
       
  2202 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2203 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2204 }
       
  2205 
       
  2206 //--------------------------------------------------
       
  2207 
       
  2208 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::start_reassociation(
       
  2209 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2210 {
       
  2211 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2212 
       
  2213 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2214 
       
  2215 	eap_status_e status(eap_status_ok);
       
  2216 
       
  2217 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2218 
       
  2219 	eap_am_network_id_c old_receive_network_id(m_am_tools);
       
  2220 
       
  2221 	{
       
  2222 		const eap_tlv_header_c * const old_receive_network_id_parameter
       
  2223 			= parameters->get_object(parameter_index);
       
  2224 
       
  2225 		if (old_receive_network_id_parameter == 0
       
  2226 			|| old_receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2227 		{
       
  2228 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2229 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2230 		}
       
  2231 
       
  2232 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2233 
       
  2234 		if (message_data.get_is_valid() == false)
       
  2235 		{
       
  2236 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2237 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2238 		}
       
  2239 
       
  2240 		status = message_data.get_parameter_data(old_receive_network_id_parameter, &old_receive_network_id);
       
  2241 		if (status != eap_status_ok)
       
  2242 		{
       
  2243 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2244 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2245 		}
       
  2246 	}
       
  2247 
       
  2248 	++parameter_index;
       
  2249 
       
  2250 	eap_am_network_id_c new_receive_network_id(m_am_tools);
       
  2251 
       
  2252 	{
       
  2253 		const eap_tlv_header_c * const new_receive_network_id_parameter
       
  2254 			= parameters->get_object(parameter_index);
       
  2255 
       
  2256 		if (new_receive_network_id_parameter == 0
       
  2257 			|| new_receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2258 		{
       
  2259 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2260 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2261 		}
       
  2262 
       
  2263 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2264 
       
  2265 		if (message_data.get_is_valid() == false)
       
  2266 		{
       
  2267 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2268 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2269 		}
       
  2270 
       
  2271 		status = message_data.get_parameter_data(new_receive_network_id_parameter, &new_receive_network_id);
       
  2272 		if (status != eap_status_ok)
       
  2273 		{
       
  2274 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2275 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2276 		}
       
  2277 	}
       
  2278 
       
  2279 
       
  2280 	++parameter_index;
       
  2281 
       
  2282 	eapol_key_authentication_type_e selected_eapol_key_authentication_type(eapol_key_authentication_type_none);
       
  2283 
       
  2284 	{
       
  2285 		const eap_tlv_header_c * const authentication_type
       
  2286 			= parameters->get_object(parameter_index);
       
  2287 
       
  2288 		if (authentication_type == 0
       
  2289 			|| authentication_type->get_type() != eapol_tlv_message_type_eapol_key_authentication_type)
       
  2290 		{
       
  2291 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2292 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2293 		}
       
  2294 
       
  2295 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2296 
       
  2297 		if (message_data.get_is_valid() == false)
       
  2298 		{
       
  2299 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2300 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2301 		}
       
  2302 
       
  2303 		u32_t value(0ul);
       
  2304 
       
  2305 		status = message_data.get_parameter_data(authentication_type, &value);
       
  2306 		if (status != eap_status_ok)
       
  2307 		{
       
  2308 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2309 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2310 		}
       
  2311 
       
  2312 		selected_eapol_key_authentication_type = static_cast<eapol_key_authentication_type_e>(value);
       
  2313 	}
       
  2314 
       
  2315 
       
  2316 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2317 
       
  2318 	status = m_wauth->start_reassociation(
       
  2319 		&old_receive_network_id,
       
  2320 		&new_receive_network_id,
       
  2321 		selected_eapol_key_authentication_type);
       
  2322 
       
  2323 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2324 
       
  2325 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2326 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2327 }
       
  2328 
       
  2329 //--------------------------------------------------
       
  2330 
       
  2331 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::complete_reassociation(
       
  2332 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2333 {
       
  2334 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2335 
       
  2336 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2337 
       
  2338 	eap_status_e status(eap_status_ok);
       
  2339 
       
  2340 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2341 
       
  2342 	eapol_wlan_authentication_state_e association_result(eapol_wlan_authentication_state_none);
       
  2343 
       
  2344 	{
       
  2345 		const eap_tlv_header_c * const association_result_parameter
       
  2346 			= parameters->get_object(parameter_index);
       
  2347 
       
  2348 		if (association_result_parameter == 0
       
  2349 			|| association_result_parameter->get_type() != eapol_tlv_message_type_eapol_wlan_authentication_state)
       
  2350 		{
       
  2351 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2352 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2353 		}
       
  2354 
       
  2355 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2356 
       
  2357 		if (message_data.get_is_valid() == false)
       
  2358 		{
       
  2359 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2360 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2361 		}
       
  2362 
       
  2363 		u32_t value(0ul);
       
  2364 
       
  2365 		status = message_data.get_parameter_data(association_result_parameter, &value);
       
  2366 		if (status != eap_status_ok)
       
  2367 		{
       
  2368 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2369 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2370 		}
       
  2371 
       
  2372 		association_result = static_cast<eapol_wlan_authentication_state_e>(value);
       
  2373 	}
       
  2374 
       
  2375 
       
  2376 	++parameter_index;
       
  2377 
       
  2378 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  2379 
       
  2380 	{
       
  2381 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2382 			= parameters->get_object(parameter_index);
       
  2383 
       
  2384 		if (receive_network_id_parameter == 0
       
  2385 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2386 		{
       
  2387 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2388 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2389 		}
       
  2390 
       
  2391 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2392 
       
  2393 		if (message_data.get_is_valid() == false)
       
  2394 		{
       
  2395 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2396 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2397 		}
       
  2398 
       
  2399 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  2400 		if (status != eap_status_ok)
       
  2401 		{
       
  2402 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2403 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2404 		}
       
  2405 	}
       
  2406 
       
  2407 
       
  2408 	++parameter_index;
       
  2409 
       
  2410 	eap_variable_data_c received_WPA_IE(m_am_tools);
       
  2411 
       
  2412 	{
       
  2413 		const eap_tlv_header_c * const received_WPA_IE_parameter
       
  2414 			= parameters->get_object(parameter_index);
       
  2415 
       
  2416 		if (received_WPA_IE_parameter == 0
       
  2417 			|| received_WPA_IE_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  2418 		{
       
  2419 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2420 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2421 		}
       
  2422 
       
  2423 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2424 
       
  2425 		if (message_data.get_is_valid() == false)
       
  2426 		{
       
  2427 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2428 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2429 		}
       
  2430 
       
  2431 		status = message_data.get_parameter_data(received_WPA_IE_parameter, &received_WPA_IE);
       
  2432 		if (status != eap_status_ok)
       
  2433 		{
       
  2434 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2435 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2436 		}
       
  2437 	}
       
  2438 
       
  2439 
       
  2440 	++parameter_index;
       
  2441 
       
  2442 	eap_variable_data_c sent_WPA_IE(m_am_tools);
       
  2443 
       
  2444 	{
       
  2445 		const eap_tlv_header_c * const sent_WPA_IE_parameter
       
  2446 			= parameters->get_object(parameter_index);
       
  2447 
       
  2448 		if (sent_WPA_IE_parameter == 0
       
  2449 			|| sent_WPA_IE_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  2450 		{
       
  2451 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2452 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2453 		}
       
  2454 
       
  2455 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2456 
       
  2457 		if (message_data.get_is_valid() == false)
       
  2458 		{
       
  2459 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2460 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2461 		}
       
  2462 
       
  2463 		status = message_data.get_parameter_data(sent_WPA_IE_parameter, &sent_WPA_IE);
       
  2464 		if (status != eap_status_ok)
       
  2465 		{
       
  2466 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2467 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2468 		}
       
  2469 	}
       
  2470 
       
  2471 
       
  2472 	++parameter_index;
       
  2473 
       
  2474 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  2475 
       
  2476 	{
       
  2477 		const eap_tlv_header_c * const pairwise_key_cipher_suite_parameter
       
  2478 			= parameters->get_object(parameter_index);
       
  2479 
       
  2480 		if (pairwise_key_cipher_suite_parameter == 0
       
  2481 			|| pairwise_key_cipher_suite_parameter->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  2482 		{
       
  2483 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2484 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2485 		}
       
  2486 
       
  2487 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2488 
       
  2489 		if (message_data.get_is_valid() == false)
       
  2490 		{
       
  2491 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2492 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2493 		}
       
  2494 
       
  2495 		u32_t value(0ul);
       
  2496 
       
  2497 		status = message_data.get_parameter_data(pairwise_key_cipher_suite_parameter, &value);
       
  2498 		if (status != eap_status_ok)
       
  2499 		{
       
  2500 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2501 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2502 		}
       
  2503 
       
  2504 		pairwise_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  2505 	}
       
  2506 
       
  2507 	++parameter_index;
       
  2508 
       
  2509 	eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite(eapol_RSNA_key_header_c::eapol_RSNA_cipher_none);
       
  2510 
       
  2511 	{
       
  2512 		const eap_tlv_header_c * const group_key_cipher_suite_parameter
       
  2513 			= parameters->get_object(parameter_index);
       
  2514 
       
  2515 		if (group_key_cipher_suite_parameter == 0
       
  2516 			|| group_key_cipher_suite_parameter->get_type() != eapol_tlv_message_type_RSNA_cipher)
       
  2517 		{
       
  2518 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2519 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2520 		}
       
  2521 
       
  2522 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2523 
       
  2524 		if (message_data.get_is_valid() == false)
       
  2525 		{
       
  2526 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2527 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2528 		}
       
  2529 
       
  2530 		u32_t value(0ul);
       
  2531 
       
  2532 		status = message_data.get_parameter_data(group_key_cipher_suite_parameter, &value);
       
  2533 		if (status != eap_status_ok)
       
  2534 		{
       
  2535 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2536 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2537 		}
       
  2538 
       
  2539 		group_key_cipher_suite = static_cast<eapol_RSNA_key_header_c::eapol_RSNA_cipher_e>(value);
       
  2540 	}
       
  2541 
       
  2542 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2543 
       
  2544 	status = m_wauth->complete_reassociation(
       
  2545 		association_result,
       
  2546 		&receive_network_id, ///< source includes remote address, destination includes local address.
       
  2547 		&received_WPA_IE, // WLM must give only the WPA IE to EAPOL
       
  2548 		&sent_WPA_IE,
       
  2549 		pairwise_key_cipher_suite,
       
  2550 		group_key_cipher_suite
       
  2551 		);
       
  2552 
       
  2553 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2554 
       
  2555 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2556 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2557 }
       
  2558 
       
  2559 //--------------------------------------------------
       
  2560 
       
  2561 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::start_WPXM_reassociation(
       
  2562 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2563 {
       
  2564 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2565 
       
  2566 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2567 
       
  2568 	eap_status_e status(eap_status_ok);
       
  2569 
       
  2570 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2571 
       
  2572 	eap_am_network_id_c old_receive_network_id(m_am_tools);
       
  2573 
       
  2574 	{
       
  2575 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2576 			= parameters->get_object(parameter_index);
       
  2577 
       
  2578 		if (receive_network_id_parameter == 0
       
  2579 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2580 		{
       
  2581 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2582 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2583 		}
       
  2584 
       
  2585 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2586 
       
  2587 		if (message_data.get_is_valid() == false)
       
  2588 		{
       
  2589 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2590 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2591 		}
       
  2592 
       
  2593 		status = message_data.get_parameter_data(receive_network_id_parameter, &old_receive_network_id);
       
  2594 		if (status != eap_status_ok)
       
  2595 		{
       
  2596 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2597 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2598 		}
       
  2599 	}
       
  2600 
       
  2601 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2602 
       
  2603 	++parameter_index;
       
  2604 
       
  2605 	eap_am_network_id_c new_receive_network_id(m_am_tools);
       
  2606 
       
  2607 	{
       
  2608 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2609 			= parameters->get_object(parameter_index);
       
  2610 
       
  2611 		if (receive_network_id_parameter == 0
       
  2612 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2613 		{
       
  2614 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2615 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2616 		}
       
  2617 
       
  2618 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2619 
       
  2620 		if (message_data.get_is_valid() == false)
       
  2621 		{
       
  2622 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2623 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2624 		}
       
  2625 
       
  2626 		status = message_data.get_parameter_data(receive_network_id_parameter, &new_receive_network_id);
       
  2627 		if (status != eap_status_ok)
       
  2628 		{
       
  2629 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2630 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2631 		}
       
  2632 	}
       
  2633 
       
  2634 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2635 
       
  2636 
       
  2637 	++parameter_index;
       
  2638 
       
  2639 	eap_variable_data_c send_reassociation_request_ie(m_am_tools);
       
  2640 
       
  2641 	{
       
  2642 		const eap_tlv_header_c * const send_reassociation_request_ie_parameter
       
  2643 			= parameters->get_object(parameter_index);
       
  2644 
       
  2645 		if (send_reassociation_request_ie_parameter == 0
       
  2646 			|| send_reassociation_request_ie_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  2647 		{
       
  2648 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2649 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2650 		}
       
  2651 
       
  2652 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2653 
       
  2654 		if (message_data.get_is_valid() == false)
       
  2655 		{
       
  2656 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2657 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2658 		}
       
  2659 
       
  2660 		status = message_data.get_parameter_data(send_reassociation_request_ie_parameter, &send_reassociation_request_ie);
       
  2661 		if (status != eap_status_ok)
       
  2662 		{
       
  2663 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2664 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2665 		}
       
  2666 	}
       
  2667 
       
  2668 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2669 
       
  2670 	++parameter_index;
       
  2671 
       
  2672 	eap_variable_data_c received_WPA_ie(m_am_tools);
       
  2673 
       
  2674 	if (parameters->get_object_count() > parameter_index)
       
  2675 	{
       
  2676 		const eap_tlv_header_c * const send_reassociation_request_ie_parameter
       
  2677 			= parameters->get_object(parameter_index);
       
  2678 
       
  2679 		if (send_reassociation_request_ie_parameter != 0
       
  2680 			&& send_reassociation_request_ie_parameter->get_type() == eapol_tlv_message_type_variable_data)
       
  2681 		{
       
  2682 			eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2683 
       
  2684 			if (message_data.get_is_valid() == false)
       
  2685 			{
       
  2686 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2687 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2688 			}
       
  2689 
       
  2690 			status = message_data.get_parameter_data(send_reassociation_request_ie_parameter, &received_WPA_ie);
       
  2691 			if (status != eap_status_ok)
       
  2692 			{
       
  2693 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2694 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  2695 			}
       
  2696 		}
       
  2697 	}
       
  2698 
       
  2699 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2700 
       
  2701 	++parameter_index;
       
  2702 
       
  2703 	eap_variable_data_c sent_WPA_ie(m_am_tools);
       
  2704 
       
  2705 	if (parameters->get_object_count() > parameter_index)
       
  2706 	{
       
  2707 		const eap_tlv_header_c * const send_reassociation_request_ie_parameter
       
  2708 			= parameters->get_object(parameter_index);
       
  2709 
       
  2710 		if (send_reassociation_request_ie_parameter != 0
       
  2711 			&& send_reassociation_request_ie_parameter->get_type() == eapol_tlv_message_type_variable_data)
       
  2712 		{
       
  2713 			eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2714 
       
  2715 			if (message_data.get_is_valid() == false)
       
  2716 			{
       
  2717 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2718 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2719 			}
       
  2720 
       
  2721 			status = message_data.get_parameter_data(send_reassociation_request_ie_parameter, &sent_WPA_ie);
       
  2722 			if (status != eap_status_ok)
       
  2723 			{
       
  2724 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2725 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  2726 			}
       
  2727 		}
       
  2728 	}
       
  2729 
       
  2730 
       
  2731 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2732 
       
  2733 	status = m_wauth->start_WPXM_reassociation(
       
  2734 		&old_receive_network_id,
       
  2735 		&new_receive_network_id,
       
  2736 		&send_reassociation_request_ie,
       
  2737 		&received_WPA_ie, 
       
  2738 		&sent_WPA_ie);
       
  2739 
       
  2740 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2741 
       
  2742 	if (status == eap_status_ok)
       
  2743 	{
       
  2744 		// Creates message data composed of Attribute-Value Pairs.
       
  2745 		eapol_handle_tlv_message_data_c message(m_am_tools);
       
  2746 
       
  2747 		if (message.get_is_valid() == false)
       
  2748 		{
       
  2749 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2750 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2751 		}
       
  2752 
       
  2753 		status = message.add_parameter_data(eapol_tlv_message_type_function_complete_start_WPXM_reassociation);
       
  2754 		if (status != eap_status_ok)
       
  2755 		{
       
  2756 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2757 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2758 		}
       
  2759 
       
  2760 		status = message.add_parameter_data(&new_receive_network_id);
       
  2761 		if (status != eap_status_ok)
       
  2762 		{
       
  2763 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2764 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2765 		}
       
  2766 
       
  2767 		status = message.add_parameter_data(&send_reassociation_request_ie);
       
  2768 		if (status != eap_status_ok)
       
  2769 		{
       
  2770 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2771 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2772 		}
       
  2773 
       
  2774 		status = send_message(&message);
       
  2775 		if (status != eap_status_ok)
       
  2776 		{
       
  2777 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2778 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2779 		}
       
  2780 	}
       
  2781 
       
  2782 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2783 
       
  2784 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2785 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2786 }
       
  2787 
       
  2788 //--------------------------------------------------
       
  2789 
       
  2790 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::complete_WPXM_reassociation(
       
  2791 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2792 {
       
  2793 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2794 
       
  2795 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2796 
       
  2797 	eap_status_e status(eap_status_ok);
       
  2798 
       
  2799 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2800 
       
  2801 	eapol_wlan_authentication_state_e reassociation_result(eapol_wlan_authentication_state_none);
       
  2802 
       
  2803 	{
       
  2804 		const eap_tlv_header_c * const reassociation_result_parameter
       
  2805 			= parameters->get_object(parameter_index);
       
  2806 
       
  2807 		if (reassociation_result_parameter == 0
       
  2808 			|| reassociation_result_parameter->get_type() != eapol_tlv_message_type_eapol_wlan_authentication_state)
       
  2809 		{
       
  2810 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2811 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2812 		}
       
  2813 
       
  2814 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2815 
       
  2816 		if (message_data.get_is_valid() == false)
       
  2817 		{
       
  2818 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2819 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2820 		}
       
  2821 
       
  2822 		u32_t value(0ul);
       
  2823 
       
  2824 		status = message_data.get_parameter_data(reassociation_result_parameter, &value);
       
  2825 		if (status != eap_status_ok)
       
  2826 		{
       
  2827 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2828 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2829 		}
       
  2830 
       
  2831 		reassociation_result = static_cast<eapol_wlan_authentication_state_e>(value);
       
  2832 	}
       
  2833 
       
  2834 
       
  2835 	++parameter_index;
       
  2836 
       
  2837 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  2838 
       
  2839 	{
       
  2840 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2841 			= parameters->get_object(parameter_index);
       
  2842 
       
  2843 		if (receive_network_id_parameter == 0
       
  2844 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2845 		{
       
  2846 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2847 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2848 		}
       
  2849 
       
  2850 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2851 
       
  2852 		if (message_data.get_is_valid() == false)
       
  2853 		{
       
  2854 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2855 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2856 		}
       
  2857 
       
  2858 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  2859 		if (status != eap_status_ok)
       
  2860 		{
       
  2861 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2862 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2863 		}
       
  2864 	}
       
  2865 
       
  2866 
       
  2867 	++parameter_index;
       
  2868 
       
  2869 	eap_variable_data_c received_reassociation_ie(m_am_tools);
       
  2870 
       
  2871 	{
       
  2872 		const eap_tlv_header_c * const received_reassociation_ie_parameter
       
  2873 			= parameters->get_object(parameter_index);
       
  2874 
       
  2875 		if (received_reassociation_ie_parameter == 0
       
  2876 			|| received_reassociation_ie_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  2877 		{
       
  2878 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2879 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2880 		}
       
  2881 
       
  2882 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2883 
       
  2884 		if (message_data.get_is_valid() == false)
       
  2885 		{
       
  2886 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2887 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2888 		}
       
  2889 
       
  2890 		status = message_data.get_parameter_data(received_reassociation_ie_parameter, &received_reassociation_ie);
       
  2891 		if (status != eap_status_ok)
       
  2892 		{
       
  2893 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2894 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2895 		}
       
  2896 	}
       
  2897 
       
  2898 
       
  2899 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2900 
       
  2901 	status = m_wauth->complete_WPXM_reassociation(
       
  2902 		reassociation_result,
       
  2903 		&receive_network_id,
       
  2904 		&received_reassociation_ie);
       
  2905 
       
  2906 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2907 
       
  2908 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2909 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  2910 }
       
  2911 
       
  2912 //--------------------------------------------------
       
  2913 
       
  2914 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::packet_process(
       
  2915 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  2916 {
       
  2917 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2918 
       
  2919 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2920 
       
  2921 	eap_status_e status(eap_status_ok);
       
  2922 
       
  2923 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  2924 
       
  2925 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  2926 
       
  2927 	{
       
  2928 		const eap_tlv_header_c * const receive_network_id_parameter
       
  2929 			= parameters->get_object(parameter_index);
       
  2930 
       
  2931 		if (receive_network_id_parameter == 0
       
  2932 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  2933 		{
       
  2934 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2935 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2936 		}
       
  2937 
       
  2938 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2939 
       
  2940 		if (message_data.get_is_valid() == false)
       
  2941 		{
       
  2942 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2943 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2944 		}
       
  2945 
       
  2946 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  2947 		if (status != eap_status_ok)
       
  2948 		{
       
  2949 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2950 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2951 		}
       
  2952 	}
       
  2953 
       
  2954 
       
  2955 	++parameter_index;
       
  2956 
       
  2957 	eap_variable_data_c packet_data_payload(m_am_tools);
       
  2958 
       
  2959 	{
       
  2960 		const eap_tlv_header_c * const packet_data_parameter
       
  2961 			= parameters->get_object(parameter_index);
       
  2962 
       
  2963 		if (packet_data_parameter == 0
       
  2964 			|| packet_data_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  2965 		{
       
  2966 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2967 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  2968 		}
       
  2969 
       
  2970 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  2971 
       
  2972 		if (message_data.get_is_valid() == false)
       
  2973 		{
       
  2974 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2975 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2976 		}
       
  2977 
       
  2978 		status = message_data.get_parameter_data(packet_data_parameter, &packet_data_payload);
       
  2979 		if (status != eap_status_ok)
       
  2980 		{
       
  2981 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2982 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  2983 		}
       
  2984 	}
       
  2985 
       
  2986 
       
  2987 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  2988 
       
  2989 	eapol_ethernet_header_wr_c eth(
       
  2990 		m_am_tools,
       
  2991 		packet_data_payload.get_data(),
       
  2992 		packet_data_payload.get_data_length());
       
  2993 	if (eth.get_is_valid() == false)
       
  2994 	{
       
  2995 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  2996 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  2997 	}
       
  2998 
       
  2999 	status = m_wauth->packet_process(
       
  3000 		&receive_network_id,
       
  3001 		&eth,
       
  3002 		packet_data_payload.get_data_length()
       
  3003 		);
       
  3004 
       
  3005 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3006 
       
  3007 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3008 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  3009 }
       
  3010 
       
  3011 //--------------------------------------------------
       
  3012 
       
  3013 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::tkip_mic_failure(
       
  3014 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  3015 {
       
  3016 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3017 
       
  3018 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3019 
       
  3020 	eap_status_e status(eap_status_ok);
       
  3021 
       
  3022 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  3023 
       
  3024 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  3025 
       
  3026 	{
       
  3027 		const eap_tlv_header_c * const receive_network_id_parameter
       
  3028 			= parameters->get_object(parameter_index);
       
  3029 
       
  3030 		if (receive_network_id_parameter == 0
       
  3031 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  3032 		{
       
  3033 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3034 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3035 		}
       
  3036 
       
  3037 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3038 
       
  3039 		if (message_data.get_is_valid() == false)
       
  3040 		{
       
  3041 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3042 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3043 		}
       
  3044 
       
  3045 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  3046 		if (status != eap_status_ok)
       
  3047 		{
       
  3048 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3049 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3050 		}
       
  3051 	}
       
  3052 
       
  3053 	++parameter_index;
       
  3054 
       
  3055 	bool fatal_failure_when_true(false);
       
  3056 
       
  3057 	{
       
  3058 		const eap_tlv_header_c * const fatal_failure_when_true_parameter
       
  3059 			= parameters->get_object(parameter_index);
       
  3060 
       
  3061 		if (fatal_failure_when_true_parameter == 0
       
  3062 			|| fatal_failure_when_true_parameter->get_type() != eapol_tlv_message_type_boolean)
       
  3063 		{
       
  3064 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3065 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3066 		}
       
  3067 
       
  3068 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3069 
       
  3070 		if (message_data.get_is_valid() == false)
       
  3071 		{
       
  3072 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3073 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3074 		}
       
  3075 
       
  3076 		u32_t value(0ul);
       
  3077 
       
  3078 		status = message_data.get_parameter_data(fatal_failure_when_true_parameter, &value);
       
  3079 		if (status != eap_status_ok)
       
  3080 		{
       
  3081 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3082 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3083 		}
       
  3084 
       
  3085 		fatal_failure_when_true = (value == 0) ? false: true;
       
  3086 	}
       
  3087 
       
  3088 
       
  3089 	++parameter_index;
       
  3090 
       
  3091 	eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_e tkip_mic_failure_type(eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_group_key);
       
  3092 
       
  3093 	{
       
  3094 		const eap_tlv_header_c * const tkip_mic_failure_type_parameter
       
  3095 			= parameters->get_object(parameter_index);
       
  3096 
       
  3097 		if (tkip_mic_failure_type_parameter == 0
       
  3098 			|| tkip_mic_failure_type_parameter->get_type() != eapol_tlv_message_type_eapol_tkip_mic_failure_type)
       
  3099 		{
       
  3100 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3101 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3102 		}
       
  3103 
       
  3104 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3105 
       
  3106 		if (message_data.get_is_valid() == false)
       
  3107 		{
       
  3108 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3109 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3110 		}
       
  3111 
       
  3112 		u32_t value(0ul);
       
  3113 
       
  3114 		status = message_data.get_parameter_data(tkip_mic_failure_type_parameter, &value);
       
  3115 		if (status != eap_status_ok)
       
  3116 		{
       
  3117 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3118 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3119 		}
       
  3120 
       
  3121 		tkip_mic_failure_type = static_cast<eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_e>(value);
       
  3122 	}
       
  3123 
       
  3124 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3125 
       
  3126 	status = m_wauth->tkip_mic_failure(
       
  3127 		&receive_network_id,
       
  3128 		fatal_failure_when_true,
       
  3129 		tkip_mic_failure_type
       
  3130 		);
       
  3131 
       
  3132 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3133 
       
  3134 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3135 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  3136 }
       
  3137 
       
  3138 //--------------------------------------------------
       
  3139 
       
  3140 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::eap_acknowledge(
       
  3141 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  3142 {
       
  3143 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3144 
       
  3145 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3146 
       
  3147 	eap_status_e status(eap_status_ok);
       
  3148 
       
  3149 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  3150 
       
  3151 	eap_am_network_id_c receive_network_id(m_am_tools);
       
  3152 
       
  3153 	{
       
  3154 		const eap_tlv_header_c * const receive_network_id_parameter
       
  3155 			= parameters->get_object(parameter_index);
       
  3156 
       
  3157 		if (receive_network_id_parameter == 0
       
  3158 			|| receive_network_id_parameter->get_type() != eapol_tlv_message_type_network_id)
       
  3159 		{
       
  3160 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3161 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3162 		}
       
  3163 
       
  3164 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3165 
       
  3166 		if (message_data.get_is_valid() == false)
       
  3167 		{
       
  3168 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3169 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3170 		}
       
  3171 
       
  3172 		status = message_data.get_parameter_data(receive_network_id_parameter, &receive_network_id);
       
  3173 		if (status != eap_status_ok)
       
  3174 		{
       
  3175 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3176 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3177 		}
       
  3178 	}
       
  3179 
       
  3180 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3181 
       
  3182 	status = m_wauth->eap_acknowledge(
       
  3183 		&receive_network_id ///< source includes remote address, destination includes local address.
       
  3184 		);
       
  3185 
       
  3186 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3187 
       
  3188 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3189 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  3190 }
       
  3191 
       
  3192 //--------------------------------------------------
       
  3193 
       
  3194 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::update_header_offset(
       
  3195 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  3196 {
       
  3197 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3198 
       
  3199 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3200 
       
  3201 	eap_status_e status(eap_status_ok);
       
  3202 
       
  3203 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  3204 
       
  3205 	{
       
  3206 		const eap_tlv_header_c * const header_offset_value_parameter
       
  3207 			= parameters->get_object(parameter_index);
       
  3208 
       
  3209 		if (header_offset_value_parameter == 0
       
  3210 			|| header_offset_value_parameter->get_type() != eapol_tlv_message_type_u32_t)
       
  3211 		{
       
  3212 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3213 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3214 		}
       
  3215 
       
  3216 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3217 
       
  3218 		if (message_data.get_is_valid() == false)
       
  3219 		{
       
  3220 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3221 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3222 		}
       
  3223 
       
  3224 		status = message_data.get_parameter_data(header_offset_value_parameter, &m_header_offset);
       
  3225 		if (status != eap_status_ok)
       
  3226 		{
       
  3227 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3228 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3229 		}
       
  3230 	}
       
  3231 
       
  3232 
       
  3233 	++parameter_index;
       
  3234 
       
  3235 	{
       
  3236 		const eap_tlv_header_c * const MTU_value_parameter
       
  3237 			= parameters->get_object(parameter_index);
       
  3238 
       
  3239 		if (MTU_value_parameter == 0
       
  3240 			|| MTU_value_parameter->get_type() != eapol_tlv_message_type_u32_t)
       
  3241 		{
       
  3242 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3243 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3244 		}
       
  3245 
       
  3246 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3247 
       
  3248 		if (message_data.get_is_valid() == false)
       
  3249 		{
       
  3250 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3251 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3252 		}
       
  3253 
       
  3254 		status = message_data.get_parameter_data(MTU_value_parameter, &m_MTU);
       
  3255 		if (status != eap_status_ok)
       
  3256 		{
       
  3257 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3258 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3259 		}
       
  3260 	}
       
  3261 
       
  3262 
       
  3263 	++parameter_index;
       
  3264 
       
  3265 	{
       
  3266 		const eap_tlv_header_c * const trailer_length_parameter
       
  3267 			= parameters->get_object(parameter_index);
       
  3268 
       
  3269 		if (trailer_length_parameter == 0
       
  3270 			|| trailer_length_parameter->get_type() != eapol_tlv_message_type_u32_t)
       
  3271 		{
       
  3272 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3273 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3274 		}
       
  3275 
       
  3276 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3277 
       
  3278 		if (message_data.get_is_valid() == false)
       
  3279 		{
       
  3280 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3281 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3282 		}
       
  3283 
       
  3284 		status = message_data.get_parameter_data(trailer_length_parameter, &m_trailer_length);
       
  3285 		if (status != eap_status_ok)
       
  3286 		{
       
  3287 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3288 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3289 		}
       
  3290 	}
       
  3291 
       
  3292 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3293 
       
  3294 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3295 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  3296 }
       
  3297 
       
  3298 //--------------------------------------------------
       
  3299 
       
  3300 EAP_FUNC_EXPORT eap_status_e eapol_message_wlan_authentication_c::update_wlan_database_reference_values(
       
  3301 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
  3302 {
       
  3303 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3304 
       
  3305 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3306 
       
  3307 	eap_status_e status(eap_status_ok);
       
  3308 
       
  3309 	u32_t parameter_index(eapol_message_payload_index_first_parameter);
       
  3310 
       
  3311 	{
       
  3312 		const eap_tlv_header_c * const reference_parameter
       
  3313 			= parameters->get_object(parameter_index);
       
  3314 
       
  3315 		if (reference_parameter == 0
       
  3316 			|| reference_parameter->get_type() != eapol_tlv_message_type_variable_data)
       
  3317 		{
       
  3318 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3319 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
  3320 		}
       
  3321 
       
  3322 		eapol_handle_tlv_message_data_c message_data(m_am_tools);
       
  3323 
       
  3324 		if (message_data.get_is_valid() == false)
       
  3325 		{
       
  3326 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3327 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3328 		}
       
  3329 
       
  3330 		status = message_data.get_parameter_data(reference_parameter, &m_wlan_database_reference);
       
  3331 		if (status != eap_status_ok)
       
  3332 		{
       
  3333 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3334 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3335 		}
       
  3336 	}
       
  3337 
       
  3338 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  3339 
       
  3340 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3341 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
  3342 }
       
  3343 
       
  3344 //--------------------------------------------------
       
  3345 // End of file.