eapol/eapol_framework/wapi_common/src/wapi_ethernet_core.cpp
changeset 17 8840d3e38314
equal deleted inserted replaced
2:1c7bc153c08e 17:8840d3e38314
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : ./accesssec/eapol/eapol_framework/wapi_common/src/wapi_ethernet_core.cpp
       
     4 *  Part of     : WAPI / WAPI       *** Info from the SWAD
       
     5 *  Description : WAPI authentication
       
     6 *  Version     : %version: 15.1.1 % << Don't touch! Updated by Synergy at check-out.
       
     7 *
       
     8 *  Copyright © 2001-2009 Nokia.  All rights reserved.
       
     9 *  This material, including documentation and any related computer
       
    10 *  programs, is protected by copyright controlled by Nokia.  All
       
    11 *  rights are reserved.  Copying, including reproducing, storing,
       
    12 *  adapting or translating, any or all of this material requires the
       
    13 *  prior written consent of Nokia.  This material also contains
       
    14 *  confidential information which may not be disclosed to others
       
    15 *  without the prior written consent of Nokia.
       
    16 * ============================================================================
       
    17 * Template version: 4.1.1
       
    18 */
       
    19 
       
    20 // This is enumeration of WAPI source code.
       
    21 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    22 	#undef EAP_FILE_NUMBER_ENUM
       
    23 	#define EAP_FILE_NUMBER_ENUM 20003
       
    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 
       
    30 #include "eap_am_memory.h"
       
    31 #include "eap_variable_data.h"
       
    32 #include "eap_tools.h"
       
    33 #include "wapi_ethernet_core.h"
       
    34 #include "eapol_ethernet_header.h"
       
    35 #include "eap_buffer.h"
       
    36 #include "eapol_session_key.h"
       
    37 #include "eap_automatic_variable.h"
       
    38 
       
    39 #include "abs_eap_am_mutex.h"
       
    40 
       
    41 
       
    42 //--------------------------------------------------
       
    43 
       
    44 // 
       
    45 EAP_FUNC_EXPORT wapi_ethernet_core_c::~wapi_ethernet_core_c()
       
    46 {
       
    47 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    48 
       
    49 	EAP_TRACE_DEBUG(
       
    50 		m_am_tools, 
       
    51 		TRACE_FLAGS_DEFAULT, 
       
    52 		(EAPL("wapi_ethernet_core_c::~wapi_ethernet_core_c(): this = 0x%08x\n"),
       
    53 		this));
       
    54 
       
    55 	EAP_ASSERT(m_shutdown_was_called == true);
       
    56 
       
    57 	delete m_wapi_core;
       
    58 	m_wapi_core=0;
       
    59 
       
    60 
       
    61 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    62 }
       
    63 
       
    64 //--------------------------------------------------
       
    65 
       
    66 #if defined(_WIN32) && !defined(__GNUC__)
       
    67 	#pragma warning( disable : 4355 ) // 'this' : used in base member initializer list
       
    68 #endif
       
    69 
       
    70 // 
       
    71 EAP_FUNC_EXPORT wapi_ethernet_core_c::wapi_ethernet_core_c(
       
    72 	abs_eap_am_tools_c * const tools,
       
    73 	abs_wapi_ethernet_core_c * const partner,
       
    74 	const bool is_client_when_true)
       
    75 : m_partner(partner)
       
    76 , m_wapi_core(new wapi_session_core_c(tools, this, is_client_when_true))
       
    77 , m_am_tools(tools)
       
    78 , m_is_client(is_client_when_true)
       
    79 , m_is_valid(false)
       
    80 , m_shutdown_was_called(false)
       
    81 {
       
    82 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    83 
       
    84 	EAP_TRACE_DEBUG(
       
    85 		m_am_tools, 
       
    86 		TRACE_FLAGS_DEFAULT, 
       
    87 		(EAPL("wapi_ethernet_core_c::wapi_ethernet_core_c(): %s, this = 0x%08x, compiled %s %s.\n"),
       
    88 		(m_is_client == true) ? "client": "server",
       
    89 		this,
       
    90 		__DATE__,
       
    91 		__TIME__));
       
    92 
       
    93 	if (m_wapi_core != 0
       
    94 		&& m_wapi_core->get_is_valid() == true)
       
    95 	{
       
    96 		set_is_valid();
       
    97 	}
       
    98 
       
    99 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   100 }
       
   101 
       
   102 //--------------------------------------------------
       
   103 
       
   104 //
       
   105 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::packet_process(
       
   106 	const eap_am_network_id_c * const /* receive_network_id */,
       
   107 	eap_general_header_base_c * const packet_data,
       
   108 	const u32_t packet_length)
       
   109 {
       
   110 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   111 	eap_status_e status = eap_status_process_general_error;
       
   112 
       
   113 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n")));
       
   114 
       
   115 	if (m_wapi_core == 0)
       
   116 	{
       
   117 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n")));
       
   118 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   119 	}
       
   120 
       
   121 	if (packet_length < eapol_ethernet_header_rd_c::get_header_length())
       
   122 	{
       
   123 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n")));
       
   124 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   125 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   126 	}
       
   127 
       
   128 	eapol_ethernet_header_wr_c eth_header(
       
   129 		m_am_tools,
       
   130 		packet_data->get_header_buffer(packet_data->get_header_buffer_length()),
       
   131 		packet_data->get_header_buffer_length());
       
   132 
       
   133 	if (eth_header.get_is_valid() == false)
       
   134 	{
       
   135 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   136 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   137 	}
       
   138 
       
   139 	if (packet_length < eth_header.get_data_length())
       
   140 	{
       
   141 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   142 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error);
       
   143 	}
       
   144 
       
   145 	EAP_TRACE_ALWAYS(
       
   146 		m_am_tools,
       
   147 		TRACE_FLAGS_DEFAULT,
       
   148 		(EAPL("-> ETHERNET: %s: type=0x%04x, packet_length 0x%04x\n"),
       
   149 		 (m_is_client == true) ? "client": "server",
       
   150 		 eth_header.get_type(),
       
   151 		 packet_length));
       
   152 
       
   153 	if (m_is_client == true)
       
   154 	{
       
   155 		EAP_TRACE_DATA_ALWAYS(
       
   156 			m_am_tools,
       
   157 			TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
   158 			(EAPL("-> ETHERNET packet client"),
       
   159 			 eth_header.get_header_buffer(eth_header.get_header_buffer_length()),
       
   160 			 packet_length));
       
   161 	}
       
   162 	else
       
   163 	{
       
   164 		EAP_TRACE_DATA_ALWAYS(
       
   165 			m_am_tools,
       
   166 			TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
   167 			(EAPL("-> ETHERNET packet server"),
       
   168 			 eth_header.get_header_buffer(eth_header.get_header_buffer_length()),
       
   169 			 packet_length));
       
   170 	}
       
   171 
       
   172 	if (eth_header.get_type() == eapol_ethernet_type_wapi)
       
   173 	{
       
   174 		eap_am_network_id_c receive_network_id(
       
   175 			m_am_tools,
       
   176 			eth_header.get_source(),
       
   177 			eth_header.get_source_length(),
       
   178 			eth_header.get_destination(),
       
   179 			eth_header.get_destination_length(),
       
   180 			eth_header.get_type(),
       
   181 			false,
       
   182 			false);
       
   183 
       
   184 		eapol_header_wr_c eapol(
       
   185 			m_am_tools,
       
   186 			eth_header.get_eapol_header(),
       
   187 			eth_header.get_data_length());
       
   188 		if (eapol.get_is_valid() == false)
       
   189 		{
       
   190 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   191 			return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   192 		}
       
   193 
       
   194 		status = m_wapi_core->packet_process(
       
   195 			&receive_network_id,
       
   196 			&eapol,
       
   197 			packet_length-eapol_ethernet_header_rd_c::get_header_length());
       
   198 
       
   199 		EAP_GENERAL_HEADER_COPY_ERROR_PARAMETERS(packet_data, &eapol);
       
   200 	}
       
   201 	else
       
   202 	{
       
   203 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Not WAPI supported ethernet type 0x%04x\n"), eth_header.get_type()));
       
   204 		status = eap_status_ethernet_type_not_supported;
       
   205 	}
       
   206 
       
   207 	EAP_TRACE_DEBUG(
       
   208 		m_am_tools,
       
   209 		TRACE_FLAGS_DEFAULT,
       
   210 		(EAPL("####################################################################\n")));
       
   211 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   212 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   213 }
       
   214 
       
   215 //--------------------------------------------------
       
   216 
       
   217 
       
   218 //
       
   219 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::packet_send(
       
   220 	const eap_am_network_id_c * const send_network_id,
       
   221 	eap_buf_chain_wr_c * const sent_packet,
       
   222 	const u32_t header_offset,
       
   223 	const u32_t data_length,
       
   224 	const u32_t buffer_length)
       
   225 {
       
   226 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   227 
       
   228 	EAP_ASSERT(header_offset < sent_packet->get_data_length());
       
   229 	EAP_ASSERT(data_length <= sent_packet->get_data_length());
       
   230 	EAP_ASSERT(sent_packet->get_data_length() <= buffer_length);
       
   231 
       
   232 	if (send_network_id->get_is_valid_data() == false)
       
   233 	{
       
   234 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   235 	}
       
   236 
       
   237 	if (header_offset < eapol_ethernet_header_wr_c::get_header_length())
       
   238 	{
       
   239 		EAP_TRACE_DEBUG(
       
   240 			m_am_tools,
       
   241 			TRACE_FLAGS_DEFAULT,
       
   242 			(EAPL("packet_send: packet buffer corrupted.\n")));
       
   243 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   244 	}
       
   245 
       
   246 	// ****
       
   247 	// TODO: Check these header types for WAPI
       
   248 	eapol_ethernet_header_wr_c eth(
       
   249 		m_am_tools,
       
   250 		sent_packet->get_data_offset(
       
   251 			header_offset-eapol_ethernet_header_wr_c::get_header_length(),
       
   252 			eapol_ethernet_header_wr_c::get_header_length()),
       
   253 		eapol_ethernet_header_wr_c::get_header_length());
       
   254 
       
   255 	if (eth.get_is_valid() == false)
       
   256 	{
       
   257 		EAP_TRACE_DEBUG(
       
   258 			m_am_tools,
       
   259 			TRACE_FLAGS_DEFAULT,
       
   260 			(EAPL("packet_send: packet buffer corrupted.\n")));
       
   261 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
       
   262 	}
       
   263 
       
   264 
       
   265 	eth.set_type(static_cast<eapol_ethernet_type_e>(send_network_id->get_type()));
       
   266 
       
   267 	m_am_tools->memmove(
       
   268 		eth.get_destination(),
       
   269 		send_network_id->get_destination(),
       
   270 		send_network_id->get_destination_length());
       
   271 
       
   272 	m_am_tools->memmove(
       
   273 		eth.get_source(),
       
   274 		send_network_id->get_source(),
       
   275 		send_network_id->get_source_length());
       
   276 
       
   277 
       
   278 	EAP_TRACE_ALWAYS(
       
   279 		m_am_tools,
       
   280 		TRACE_FLAGS_DEFAULT,
       
   281 		(EAPL("<- ETHERNET: %s: type=0x%04x, packet_length 0x%04x\n"),
       
   282 		 (m_is_client == true) ? "client": "server",
       
   283 		 eth.get_type(),
       
   284 		 data_length));
       
   285 
       
   286 	if (m_is_client == true)
       
   287 	{
       
   288 		EAP_TRACE_DATA_ALWAYS(
       
   289 			m_am_tools,
       
   290 			TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
   291 			(EAPL("<- ETHERNET packet client"),
       
   292 			 eth.get_header_buffer(eth.get_header_buffer_length()),
       
   293 			 data_length+eapol_ethernet_header_wr_c::get_header_length()));
       
   294 	}
       
   295 	else
       
   296 	{
       
   297 		EAP_TRACE_DATA_ALWAYS(
       
   298 			m_am_tools,
       
   299 			TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT,
       
   300 			(EAPL("<- ETHERNET packet server"),
       
   301 			 eth.get_header_buffer(eth.get_header_buffer_length()),
       
   302 			 data_length+eapol_ethernet_header_wr_c::get_header_length()));
       
   303 	}
       
   304 
       
   305 	sent_packet->set_is_client(m_is_client);
       
   306 
       
   307 	eap_status_e status = m_partner->packet_send(
       
   308 		send_network_id,
       
   309 		sent_packet,
       
   310 		header_offset-eapol_ethernet_header_wr_c::get_header_length(),
       
   311 		data_length+eapol_ethernet_header_wr_c::get_header_length(),
       
   312 		buffer_length);
       
   313 
       
   314 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   315 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   316 }
       
   317 
       
   318 //--------------------------------------------------
       
   319 
       
   320 //
       
   321 EAP_FUNC_EXPORT u32_t wapi_ethernet_core_c::get_header_offset(
       
   322 	u32_t * const MTU,
       
   323 	u32_t * const trailer_length)
       
   324 {
       
   325 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   326 
       
   327 	// ****
       
   328 	// TODO: Check these for WAPI
       
   329 	const u32_t offset = m_partner->get_header_offset(MTU, trailer_length);
       
   330 	(*MTU) -= eapol_ethernet_header_wr_c::get_header_length();
       
   331 
       
   332 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   333 	return offset+eapol_ethernet_header_wr_c::get_header_length();
       
   334 }
       
   335 
       
   336 //--------------------------------------------------
       
   337 
       
   338 //
       
   339 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::start_authentication(
       
   340 	const eap_am_network_id_c * const receive_network_id,
       
   341 	const bool is_client_when_true)
       
   342 {
       
   343 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   344 
       
   345 	if (m_wapi_core == 0)
       
   346 	{
       
   347 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   348 	}
       
   349 
       
   350 	eap_status_e status = m_wapi_core->restart_authentication(receive_network_id, is_client_when_true, true);
       
   351 
       
   352 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   353 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   354 }
       
   355 
       
   356 //--------------------------------------------------
       
   357 
       
   358 //
       
   359 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::start_reassociation(
       
   360 	const eap_am_network_id_c * const receive_network_id,
       
   361 	const eapol_key_authentication_type_e authentication_type,
       
   362 	const eap_variable_data_c * const BKID)
       
   363 {
       
   364 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   365 
       
   366 	eap_status_e status(eap_status_not_supported);
       
   367 
       
   368 // ****
       
   369 // TODO: Is this needed in WAPI?
       
   370 #if 0
       
   371 	status = m_eapol_core->start_reassociation(
       
   372 		receive_network_id,
       
   373 		authentication_type,
       
   374 		BKID);
       
   375 #endif
       
   376 
       
   377 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   378 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   379 }
       
   380 
       
   381 //--------------------------------------------------
       
   382 
       
   383 //
       
   384 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::read_reassociation_parameters(
       
   385 	const eap_am_network_id_c * const old_receive_network_id, ///< source includes remote address, destination includes local address.
       
   386 	const eap_am_network_id_c * const new_receive_network_id, ///< source includes remote address, destination includes local address.
       
   387 	const eapol_key_authentication_type_e authentication_type,
       
   388 	eap_variable_data_c * const BKID,
       
   389 	const eap_variable_data_c * const received_WAPI_ie,
       
   390 	const eap_variable_data_c * const sent_WAPI_ie)
       
   391 {
       
   392 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   393 
       
   394 	EAP_TRACE_DEBUG(
       
   395 		m_am_tools,
       
   396 		TRACE_FLAGS_DEFAULT,
       
   397 		(EAPL("wapi_ethernet_core_c::read_reassociation_parameters()\n")));
       
   398 
       
   399 	if (m_wapi_core == 0)
       
   400 	{
       
   401 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   402 	}
       
   403 
       
   404 	eap_status_e status = m_wapi_core->read_reassociation_parameters(
       
   405 		old_receive_network_id,
       
   406 		new_receive_network_id,
       
   407 		authentication_type,
       
   408 		BKID,
       
   409 		received_WAPI_ie,
       
   410 		sent_WAPI_ie);
       
   411 
       
   412 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   413 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   414 }
       
   415 
       
   416 //--------------------------------------------------
       
   417 
       
   418 
       
   419 //
       
   420 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::complete_reassociation(
       
   421 	const eapol_wlan_authentication_state_e reassociation_result,
       
   422 	const eap_am_network_id_c * const receive_network_id,
       
   423 	const eapol_key_authentication_type_e authentication_type,
       
   424 	const eap_variable_data_c * const received_WAPI_IE,
       
   425 	const eap_variable_data_c * const sent_WAPI_IE,
       
   426 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite,
       
   427 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite
       
   428 	)
       
   429 {
       
   430 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   431 
       
   432 	eap_status_e status(eap_status_not_supported);
       
   433 
       
   434 	//***
       
   435 	// TODO: Support for this needs to be added to wapi_core_c
       
   436 	/*
       
   437 	status = m_wapi_core->complete_reassociation(
       
   438 		reassociation_result,
       
   439 		receive_network_id,
       
   440 		authentication_type,
       
   441 		received_WAPI_IE,
       
   442 		sent_WAPI_IE,
       
   443 		pairwise_key_cipher_suite,
       
   444 		group_key_cipher_suite);
       
   445 	*/
       
   446 
       
   447 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   448 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   449 }
       
   450 
       
   451 //--------------------------------------------------
       
   452 
       
   453 //
       
   454 EAP_FUNC_EXPORT void wapi_ethernet_core_c::set_is_valid()
       
   455 {
       
   456 	m_is_valid = true;
       
   457 }
       
   458 
       
   459 //--------------------------------------------------
       
   460 
       
   461 //
       
   462 EAP_FUNC_EXPORT bool wapi_ethernet_core_c::get_is_valid()
       
   463 {
       
   464 	return m_is_valid;
       
   465 }
       
   466 
       
   467 //--------------------------------------------------
       
   468 
       
   469 //
       
   470 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::configure()
       
   471 {
       
   472 	EAP_TRACE_DEBUG(
       
   473 		m_am_tools,
       
   474 		TRACE_FLAGS_DEFAULT,
       
   475 		(EAPL("wapi_ethernet_core_c::configure()\n")));
       
   476 
       
   477 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: wapi_ethernet_core_c::configure()");
       
   478 
       
   479 	eap_status_e status = m_wapi_core->configure();
       
   480 
       
   481 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   482 }
       
   483 
       
   484 //--------------------------------------------------
       
   485 
       
   486 //
       
   487 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::shutdown()
       
   488 {
       
   489 	EAP_TRACE_DEBUG(
       
   490 		m_am_tools,
       
   491 		TRACE_FLAGS_DEFAULT,
       
   492 		(EAPL("%s: wapi_ethernet_core_c::shutdown(), m_shutdown_was_called=%d\n"),
       
   493 		(m_is_client == true) ? "client": "server",
       
   494 		m_shutdown_was_called));
       
   495 
       
   496 	if (m_shutdown_was_called == true)
       
   497 	{
       
   498 		// Shutdown function was called already.
       
   499 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   500 	}
       
   501 	m_shutdown_was_called = true;
       
   502 
       
   503 	eap_status_e status(eap_status_ok);
       
   504 
       
   505 	if (m_wapi_core != 0)
       
   506 	{
       
   507 		status = m_wapi_core->shutdown();
       
   508 	}
       
   509 
       
   510 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   511 }
       
   512 
       
   513 //--------------------------------------------------
       
   514 
       
   515 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::packet_data_session_key(
       
   516 	const eap_am_network_id_c * const send_network_id,
       
   517 	const eapol_session_key_c * const key)
       
   518 {
       
   519 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   520 
       
   521 	if (key == 0
       
   522 		|| key->get_is_valid() == false)
       
   523 	{
       
   524 		EAP_TRACE_DEBUG(
       
   525 			m_am_tools,
       
   526 			TRACE_FLAGS_DEFAULT,
       
   527 			(EAPL("ERROR: wapi_ethernet_core_c::packet_data_session_key(), invalid key.\n")));
       
   528 		return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error);
       
   529 	}
       
   530 
       
   531 	EAP_TRACE_DEBUG(
       
   532 		m_am_tools, 
       
   533 		TRACE_FLAGS_DEFAULT, 
       
   534 		(EAPL("wapi_ethernet_core_c::packet_data_session_key(): key_type 0x%02x, key_index %d\n"),
       
   535 		key->get_key_type(),
       
   536 		key->get_key_index()));
       
   537 
       
   538 	EAP_TRACE_DATA_DEBUG(
       
   539 		m_am_tools, 
       
   540 		TRACE_FLAGS_DEFAULT, 
       
   541 		(EAPL("wapi_ethernet_core_c::packet_data_session_key():"),
       
   542 		key->get_key()->get_data(key->get_key()->get_data_length()),
       
   543 		key->get_key()->get_data_length()));
       
   544 
       
   545 	const eap_status_e status = m_partner->packet_data_session_key(
       
   546 		send_network_id,
       
   547 		key);
       
   548 
       
   549 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   550 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   551 }
       
   552 
       
   553 //--------------------------------------------------
       
   554 
       
   555 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::read_configure(
       
   556 	const eap_configuration_field_c * const field,
       
   557 	eap_variable_data_c * const data)
       
   558 {
       
   559 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   560 	const eap_status_e status = m_partner->read_configure(field, data);
       
   561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   562 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   563 }
       
   564 
       
   565 //--------------------------------------------------
       
   566 
       
   567 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::write_configure(
       
   568 	const eap_configuration_field_c * const field,
       
   569 	eap_variable_data_c * const data)
       
   570 {
       
   571 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   572 	const eap_status_e status = m_partner->write_configure(field, data);
       
   573 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   574 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   575 }
       
   576 
       
   577 //--------------------------------------------------
       
   578 
       
   579 EAP_FUNC_EXPORT void wapi_ethernet_core_c::state_notification(
       
   580 	const abs_eap_state_notification_c * const state)
       
   581 {
       
   582 	m_partner->state_notification(state);
       
   583 }
       
   584 
       
   585 //--------------------------------------------------
       
   586 
       
   587 //
       
   588 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::set_timer(
       
   589 	abs_eap_base_timer_c * const p_initializer, 
       
   590 	const u32_t p_id, 
       
   591 	void * const p_data,
       
   592 	const u32_t p_time_ms)
       
   593 {
       
   594 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   595 
       
   596 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   597 
       
   598 	const eap_status_e status = m_partner->set_timer(
       
   599 		p_initializer, 
       
   600 		p_id, 
       
   601 		p_data,
       
   602 		p_time_ms);
       
   603 
       
   604 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   605 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   606 }
       
   607 
       
   608 //--------------------------------------------------
       
   609 
       
   610 //
       
   611 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::cancel_timer(
       
   612 	abs_eap_base_timer_c * const p_initializer, 
       
   613 	const u32_t p_id)
       
   614 {
       
   615 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   616 
       
   617 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   618 
       
   619 	const eap_status_e status = m_partner->cancel_timer(
       
   620 		p_initializer, 
       
   621 		p_id);
       
   622 
       
   623 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   624 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   625 }
       
   626 
       
   627 //--------------------------------------------------
       
   628 
       
   629 //
       
   630 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::cancel_all_timers()
       
   631 {
       
   632 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   633 
       
   634 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   635 
       
   636 	const eap_status_e status = m_partner->cancel_all_timers();
       
   637 
       
   638 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   639 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   640 }
       
   641 
       
   642 //--------------------------------------------------
       
   643 
       
   644 //
       
   645 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::cancel_all_authentication_sessions()
       
   646 {
       
   647 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   648 
       
   649 	EAP_TRACE_DEBUG(
       
   650 		m_am_tools,
       
   651 		TRACE_FLAGS_DEFAULT,
       
   652 		(EAPL("wapi_ethernet_core_c::cancel_all_authentication_sessions()\n")));
       
   653 
       
   654 	eap_status_e status = m_wapi_core->cancel_all_authentication_sessions();
       
   655 
       
   656 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   657 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   658 }
       
   659 
       
   660 //--------------------------------------------------
       
   661 
       
   662 //
       
   663 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::check_bksa_cache(
       
   664 	eap_array_c<eap_am_network_id_c> * const bssid_sta_receive_network_ids,
       
   665 	const eapol_key_authentication_type_e selected_eapol_key_authentication_type,
       
   666 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite,
       
   667 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite
       
   668 	)
       
   669 {
       
   670 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   671 
       
   672 	EAP_TRACE_DEBUG(
       
   673 		m_am_tools,
       
   674 		TRACE_FLAGS_DEFAULT,
       
   675 		(EAPL("wapi_ethernet_core_c::check_bksa_cache()\n")));
       
   676 
       
   677 	eap_status_e status = m_wapi_core->check_bksa_cache(
       
   678 		bssid_sta_receive_network_ids,
       
   679 		selected_eapol_key_authentication_type,
       
   680 		pairwise_key_cipher_suite,
       
   681 		group_key_cipher_suite);
       
   682 
       
   683 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   684 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   685 }
       
   686 
       
   687 //--------------------------------------------------
       
   688 
       
   689 /**
       
   690  * This function removes BKSA from cache.
       
   691  * @param receive_network_id carries the MAC addresses.
       
   692  * MAC address of Authenticator should be in source address.
       
   693  * MAC address of Supplicant should be in destination address.
       
   694  */
       
   695 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::remove_bksa_from_cache(
       
   696 	const eap_am_network_id_c * const receive_network_id)
       
   697 {
       
   698 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   699 
       
   700 	EAP_TRACE_DEBUG(
       
   701 		m_am_tools,
       
   702 		TRACE_FLAGS_DEFAULT,
       
   703 		(EAPL("wapi_ethernet_core_c::remove_bksa_from_cache()\n")));
       
   704 
       
   705 	eap_status_e status = m_wapi_core->remove_bksa_from_cache(
       
   706 		receive_network_id);
       
   707 
       
   708 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   709 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   710 }
       
   711 
       
   712 //--------------------------------------------------
       
   713 
       
   714 /**
       
   715  * Function creates a state for later use. This is for optimazing 4-Way Handshake.
       
   716  * @param receive_network_id carries the MAC addresses.
       
   717  * MAC address of Authenticator should be in source address. MAC address of 
       
   718  * Supplicant should be in destination address.
       
   719  * @param authentication_type is the selected authentication type.
       
   720  */
       
   721 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::create_state(
       
   722 	const eap_am_network_id_c * const receive_network_id,
       
   723 	const eapol_key_authentication_type_e authentication_type
       
   724 	)
       
   725 {
       
   726 	eap_status_e status = eap_status_process_general_error;
       
   727 
       
   728 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   729 
       
   730 	status = m_wapi_core->create_state(
       
   731 		receive_network_id,
       
   732 		authentication_type);
       
   733 
       
   734 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   735 }
       
   736 
       
   737 
       
   738 //--------------------------------------------------
       
   739 
       
   740 /**
       
   741  * @param receive_network_id carries the MAC addresses.
       
   742  * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address.
       
   743  * @param authenticator_RSNA_IE is RSN IE of authenticator. Authenticator sends this in Beacon or Probe message.
       
   744  * @param supplicant_RSNA_IE is RSN IE of supplicant. Supplicant sends this in (re)association request message.
       
   745  * @param eapol_pairwise_cipher is the selected pairwise cipher.
       
   746  * @param eapol_group_cipher is the selected group cipher.
       
   747  */
       
   748 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::association(
       
   749 	const eap_am_network_id_c * const receive_network_id,
       
   750 	const eapol_key_authentication_type_e authentication_type,
       
   751 	const eap_variable_data_c * const wapi_ie_ae,
       
   752 	const eap_variable_data_c * const wapi_ie_asue,
       
   753 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_pairwise_cipher,
       
   754 	const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_group_cipher,
       
   755 	const eap_variable_data_c * const pre_shared_key
       
   756 	)
       
   757 {
       
   758 	eap_status_e status = eap_status_process_general_error;
       
   759 
       
   760 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   761 
       
   762 	status = m_wapi_core->association(
       
   763 		receive_network_id,
       
   764 		authentication_type,
       
   765 		wapi_ie_ae,
       
   766 		wapi_ie_asue,
       
   767 		eapol_pairwise_cipher,
       
   768 		eapol_group_cipher,
       
   769 		pre_shared_key);
       
   770 
       
   771 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   772 }
       
   773 
       
   774 
       
   775 //--------------------------------------------------
       
   776 
       
   777 /**
       
   778  * @param receive_network_id carries the MAC addresses.
       
   779  * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address.
       
   780  */
       
   781 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::disassociation(
       
   782 	const eap_am_network_id_c * const receive_network_id
       
   783 	)
       
   784 {
       
   785 	eap_status_e status = eap_status_process_general_error;
       
   786 
       
   787 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
   788 
       
   789 	status = m_wapi_core->disassociation(
       
   790 		receive_network_id);
       
   791 
       
   792 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   793 }
       
   794 
       
   795 //--------------------------------------------------
       
   796 
       
   797 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::restart_authentication(
       
   798 	const eap_am_network_id_c * const receive_network_id,
       
   799 	const bool is_client_when_true,
       
   800 	const bool force_clean_restart,
       
   801 	const bool from_timer
       
   802 	)
       
   803 {
       
   804 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   805 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   806 
       
   807 	eap_status_e status = m_wapi_core->restart_authentication(
       
   808 		receive_network_id,
       
   809 		is_client_when_true,
       
   810 		force_clean_restart,
       
   811 		from_timer);
       
   812 
       
   813 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   814 }
       
   815 
       
   816 //--------------------------------------------------
       
   817 
       
   818 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::asynchronous_init_remove_wapi_session(
       
   819 	const eap_am_network_id_c * const send_network_id
       
   820 	)
       
   821 {
       
   822 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   823 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   824 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
   825 }
       
   826 //--------------------------------------------------
       
   827 
       
   828 EAP_FUNC_EXPORT eap_status_e wapi_ethernet_core_c::set_session_timeout(
       
   829 	const u32_t session_timeout_ms
       
   830 	)
       
   831 {
       
   832 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   833 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   834 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
   835 }
       
   836 
       
   837 //--------------------------------------------------
       
   838 
       
   839 
       
   840 // End.