eapol/eapol_framework/eapol_common/core/eap_general_settings_client_message_if.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     1 /*
       
     2 * Copyright (c) 2001-2010 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:  Class creates and reads the messages used in EAP-general settings interface on the client side.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 11 %
       
    20 */
       
    21 
       
    22 // This is enumeration of EAPOL source code.
       
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    24 	#undef EAP_FILE_NUMBER_ENUM
       
    25 	#define EAP_FILE_NUMBER_ENUM 767 
       
    26 	#undef EAP_FILE_NUMBER_DATE 
       
    27 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    28 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    29 
       
    30 #include "eap_am_tools.h"
       
    31 #include "eap_tools.h"
       
    32 #include "eap_am_export.h"
       
    33 #include "eap_am_assert.h"
       
    34 #include "eap_general_settings_client_message_if.h"
       
    35 #include "abs_eap_plugin_message.h"
       
    36 #include "abs_eap_am_message_if.h"
       
    37 #include "eap_am_message_if.h"
       
    38 #include "eap_automatic_variable.h"
       
    39 #include "eap_process_tlv_message_data.h"
       
    40 #include "eap_method_settings.h"
       
    41 #include "eap_am_network_id.h"
       
    42 #include "abs_eap_general_settings_message.h"
       
    43 
       
    44 //--------------------------------------------------
       
    45 
       
    46 EAP_FUNC_EXPORT eap_general_settings_client_message_if_c::~eap_general_settings_client_message_if_c()
       
    47 {
       
    48 	delete m_client_if;
       
    49 	m_client_if = 0;
       
    50 }
       
    51 
       
    52 //--------------------------------------------------
       
    53 
       
    54 EAP_FUNC_EXPORT eap_general_settings_client_message_if_c::eap_general_settings_client_message_if_c(
       
    55 	abs_eap_am_tools_c * const tools,
       
    56 	eap_am_message_if_c * const client_if,
       
    57 	abs_eap_general_settings_message_c * const partner)
       
    58 : m_am_tools(tools)
       
    59 , m_client_if(client_if)
       
    60 , m_partner(partner)
       
    61 , m_is_valid(false)
       
    62 , m_error_code(eap_status_ok)
       
    63 , m_error_function(eap_tlv_message_type_function_none)
       
    64 {
       
    65 	if (m_am_tools == 0
       
    66 		|| m_am_tools->get_is_valid() == false
       
    67 		|| m_client_if == 0
       
    68 		|| m_client_if->get_is_valid() == false
       
    69 		|| m_partner == 0)
       
    70 	{
       
    71 		return;
       
    72 	}
       
    73 
       
    74 	m_is_valid = true;
       
    75 }
       
    76 
       
    77 //--------------------------------------------------
       
    78 
       
    79 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::reset()
       
    80 {
       
    81 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
    82 }
       
    83 
       
    84 //--------------------------------------------------
       
    85 
       
    86 // This is documented in abs_eap_stack_interface_c::configure().
       
    87 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::configure()
       
    88 {
       
    89 	eap_status_e status(eap_status_process_general_error);
       
    90 
       
    91 	if (m_client_if != 0)
       
    92 	{
       
    93 		status = m_client_if->configure(0);
       
    94 	}
       
    95 
       
    96 	return EAP_STATUS_RETURN(m_am_tools, status);
       
    97 }
       
    98 
       
    99 //--------------------------------------------------
       
   100 
       
   101 // This is documented in abs_eap_stack_interface_c::shutdown().
       
   102 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::shutdown()
       
   103 {
       
   104 	eap_status_e status(eap_status_process_general_error);
       
   105 
       
   106 	if (m_client_if != 0)
       
   107 	{
       
   108 		status = m_client_if->shutdown();
       
   109 	}
       
   110 
       
   111 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   112 }
       
   113 
       
   114 //--------------------------------------------------
       
   115 
       
   116 // This is documented in abs_eap_stack_interface_c::get_is_valid().
       
   117 EAP_FUNC_EXPORT bool eap_general_settings_client_message_if_c::get_is_valid()
       
   118 {
       
   119 	return m_is_valid;
       
   120 }
       
   121 
       
   122 //--------------------------------------------------
       
   123 
       
   124 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::process_message(eap_process_tlv_message_data_c * const message)
       
   125 {
       
   126 	// Process message data composed of Attribute-Value Pairs.
       
   127 	EAP_TRACE_DEBUG(
       
   128 		m_am_tools, 
       
   129 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   130 		(EAPL("eap_general_settings_client_message_if_c::process_message(): this = 0x%08x, m_client_if=0x%08x.\n"),
       
   131 		this,
       
   132 		m_client_if));
       
   133 
       
   134 
       
   135 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::send_message()");
       
   136 
       
   137 	EAP_TRACE_DATA_DEBUG(
       
   138 		m_am_tools,
       
   139 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   140 		(EAPL("eap_general_settings_client_message_if_c::process_message()"),
       
   141 		message->get_message_data(),
       
   142 		message->get_message_data_length()));
       
   143 
       
   144 	eap_status_e send_status = m_client_if->process_data(
       
   145 		message->get_message_data(),
       
   146 		message->get_message_data_length());
       
   147 
       
   148 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   149 	return EAP_STATUS_RETURN(m_am_tools, send_status);
       
   150 }
       
   151 
       
   152 //--------------------------------------------------
       
   153 
       
   154 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::set_eap_methods(const eap_method_settings_c * const internal_settings)
       
   155 {
       
   156 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   157 
       
   158 	eap_status_e status(eap_status_process_general_error);
       
   159 
       
   160 	EAP_TRACE_DEBUG(
       
   161 		m_am_tools, 
       
   162 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   163 		(EAPL("eap_general_settings_client_message_if_c::set_eap_methods(): this = 0x%08x.\n"),
       
   164 		this));
       
   165 
       
   166 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::set_eap_methods()");
       
   167 
       
   168 	{
       
   169 		// Creates message data composed of Attribute-Value Pairs.
       
   170 		eap_process_tlv_message_data_c message(m_am_tools);
       
   171 
       
   172 		if (message.get_is_valid() == false)
       
   173 		{
       
   174 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   175 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   176 		}
       
   177 
       
   178 		status = message.add_parameter_data(eap_tlv_message_type_function_general_settings_set_eap_methods);
       
   179 		if (status != eap_status_ok)
       
   180 		{
       
   181 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   182 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   183 		}
       
   184 
       
   185 		status = message.add_parameter_data(internal_settings);
       
   186 		if (status != eap_status_ok)
       
   187 		{
       
   188 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   189 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   190 		}
       
   191 
       
   192 		status = process_message(&message);
       
   193 	}
       
   194 
       
   195 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   196 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   197 }
       
   198 
       
   199 //--------------------------------------------------
       
   200 
       
   201 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::get_eap_methods(const eap_method_settings_c * const internal_settings)
       
   202 {
       
   203 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   204 
       
   205 	eap_status_e status(eap_status_process_general_error);
       
   206 
       
   207 	EAP_TRACE_DEBUG(
       
   208 		m_am_tools, 
       
   209 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   210 		(EAPL("eap_general_settings_client_message_if_c::get_eap_methods(): this = 0x%08x.\n"),
       
   211 		this));
       
   212 
       
   213 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::get_eap_methods()");
       
   214 
       
   215 	{
       
   216 		// Creates message data composed of Attribute-Value Pairs.
       
   217 		eap_process_tlv_message_data_c message(m_am_tools);
       
   218 
       
   219 		if (message.get_is_valid() == false)
       
   220 		{
       
   221 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   222 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   223 		}
       
   224 
       
   225 		status = message.add_parameter_data(eap_tlv_message_type_function_general_settings_get_eap_methods);
       
   226 		if (status != eap_status_ok)
       
   227 		{
       
   228 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   229 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   230 		}
       
   231 
       
   232 		status = message.add_parameter_data(internal_settings);
       
   233 		if (status != eap_status_ok)
       
   234 		{
       
   235 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   236 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   237 		}
       
   238 
       
   239 		status = process_message(&message);
       
   240 	}
       
   241 
       
   242 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   243 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   244 }
       
   245 
       
   246 //--------------------------------------------------
       
   247 
       
   248 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::get_certificate_lists(const eap_method_settings_c * const internal_settings)
       
   249 {
       
   250 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   251 
       
   252 	eap_status_e status(eap_status_process_general_error);
       
   253 
       
   254 	EAP_TRACE_DEBUG(
       
   255 		m_am_tools, 
       
   256 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   257 		(EAPL("eap_general_settings_client_message_if_c::get_certificate_lists(): this = 0x%08x.\n"),
       
   258 		this));
       
   259 
       
   260 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::get_certificate_lists()");
       
   261 
       
   262 	{
       
   263 		// Creates message data composed of Attribute-Value Pairs.
       
   264 		eap_process_tlv_message_data_c message(m_am_tools);
       
   265 
       
   266 		if (message.get_is_valid() == false)
       
   267 		{
       
   268 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   269 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   270 		}
       
   271 
       
   272 		status = message.add_parameter_data(eap_tlv_message_type_function_general_settings_get_certificate_lists);
       
   273 		if (status != eap_status_ok)
       
   274 		{
       
   275 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   276 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   277 		}
       
   278 
       
   279 		status = message.add_parameter_data(internal_settings);
       
   280 		if (status != eap_status_ok)
       
   281 		{
       
   282 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   283 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   284 		}
       
   285 
       
   286 		status = process_message(&message);
       
   287 	}
       
   288 
       
   289 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   290 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   291 }
       
   292 
       
   293 //--------------------------------------------------
       
   294 
       
   295 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::delete_all_eap_settings(const eap_method_settings_c * const internal_settings)
       
   296 {
       
   297 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   298 
       
   299 	eap_status_e status(eap_status_process_general_error);
       
   300 
       
   301 	EAP_TRACE_DEBUG(
       
   302 		m_am_tools, 
       
   303 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   304 		(EAPL("eap_general_settings_client_message_if_c::delete_all_eap_settings(): this = 0x%08x.\n"),
       
   305 		this));
       
   306 
       
   307 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::delete_all_eap_settings()");
       
   308 
       
   309 	{
       
   310 		// Creates message data composed of Attribute-Value Pairs.
       
   311 		eap_process_tlv_message_data_c message(m_am_tools);
       
   312 
       
   313 		if (message.get_is_valid() == false)
       
   314 		{
       
   315 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   316 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   317 		}
       
   318 
       
   319 		status = message.add_parameter_data(eap_tlv_message_type_function_general_settings_delete_all_eap_settings);
       
   320 		if (status != eap_status_ok)
       
   321 		{
       
   322 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   323 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   324 		}
       
   325 
       
   326 		status = message.add_parameter_data(internal_settings);
       
   327 		if (status != eap_status_ok)
       
   328 		{
       
   329 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   330 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   331 		}
       
   332 
       
   333 		status = process_message(&message);
       
   334 	}
       
   335 
       
   336 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   337 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   338 }
       
   339 
       
   340 //--------------------------------------------------
       
   341 
       
   342 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::copy_all_eap_settings(const eap_method_settings_c * const internal_settings)
       
   343 {
       
   344 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   345 
       
   346 	eap_status_e status(eap_status_process_general_error);
       
   347 
       
   348 	EAP_TRACE_DEBUG(
       
   349 		m_am_tools, 
       
   350 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   351 		(EAPL("eap_general_settings_client_message_if_c::copy_all_eap_settings(): this = 0x%08x.\n"),
       
   352 		this));
       
   353 
       
   354 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::copy_all_eap_settings()");
       
   355 
       
   356 	{
       
   357 		// Creates message data composed of Attribute-Value Pairs.
       
   358 		eap_process_tlv_message_data_c message(m_am_tools);
       
   359 
       
   360 		if (message.get_is_valid() == false)
       
   361 		{
       
   362 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   363 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   364 		}
       
   365 
       
   366 		status = message.add_parameter_data(eap_tlv_message_type_function_general_settings_copy_all_eap_settings);
       
   367 		if (status != eap_status_ok)
       
   368 		{
       
   369 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   370 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   371 		}
       
   372 
       
   373 		status = message.add_parameter_data(internal_settings);
       
   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 = process_message(&message);
       
   381 	}
       
   382 
       
   383 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   384 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   385 }
       
   386 
       
   387 //--------------------------------------------------
       
   388 
       
   389 eap_status_e eap_general_settings_client_message_if_c::complete_set_eap_methods(
       
   390 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   391 {
       
   392 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   393 
       
   394 	EAP_TRACE_DEBUG(
       
   395 		m_am_tools, 
       
   396 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   397 		(EAPL("eap_general_settings_client_message_if_c::complete_set_eap_methods(): this = 0x%08x.\n"),
       
   398 		this));
       
   399 
       
   400 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::complete_set_eap_methods()");
       
   401 
       
   402 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   403 
       
   404 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
   405 
       
   406 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   407 
       
   408 	if (message_data.get_is_valid() == false)
       
   409 	{
       
   410 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   411 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   412 	}
       
   413 
       
   414 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   415 
       
   416 	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);
       
   417 
       
   418 	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);
       
   419 
       
   420 	if (internal_settings == 0)
       
   421 	{
       
   422 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   423 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   424 	}
       
   425 
       
   426 	eap_status_e status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
       
   427 	if (status != eap_status_ok)
       
   428 	{
       
   429 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   430 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   431 	}
       
   432 
       
   433 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   434 
       
   435 	status = m_partner->complete_set_eap_methods(
       
   436 		internal_settings->m_completion_status);
       
   437 
       
   438 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   439 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   440 }
       
   441 
       
   442 //--------------------------------------------------
       
   443 
       
   444 eap_status_e eap_general_settings_client_message_if_c::complete_get_eap_methods(
       
   445 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   446 {
       
   447 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   448 
       
   449 	EAP_TRACE_DEBUG(
       
   450 		m_am_tools, 
       
   451 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   452 		(EAPL("eap_general_settings_client_message_if_c::complete_get_eap_methods(): this = 0x%08x.\n"),
       
   453 		this));
       
   454 
       
   455 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::complete_get_eap_methods()");
       
   456 
       
   457 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   458 
       
   459 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
   460 
       
   461 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   462 
       
   463 	if (message_data.get_is_valid() == false)
       
   464 	{
       
   465 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   466 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   467 	}
       
   468 
       
   469 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   470 
       
   471 	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);
       
   472 
       
   473 	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);
       
   474 
       
   475 	if (internal_settings == 0)
       
   476 	{
       
   477 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   478 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   479 	}
       
   480 
       
   481 	eap_status_e status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
       
   482 	if (status != eap_status_ok)
       
   483 	{
       
   484 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   485 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   486 	}
       
   487 
       
   488 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   489 
       
   490 	status = m_partner->complete_get_eap_methods(
       
   491 		internal_settings);
       
   492 
       
   493 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   494 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   495 }
       
   496 
       
   497 //--------------------------------------------------
       
   498 
       
   499 eap_status_e eap_general_settings_client_message_if_c::complete_get_certificate_lists(
       
   500 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   501 {
       
   502 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   503 
       
   504 	EAP_TRACE_DEBUG(
       
   505 		m_am_tools, 
       
   506 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   507 		(EAPL("eap_general_settings_client_message_if_c::complete_get_certificate_lists(): this = 0x%08x.\n"),
       
   508 		this));
       
   509 
       
   510 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::complete_get_certificate_lists()");
       
   511 
       
   512 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   513 
       
   514 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
   515 
       
   516 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   517 
       
   518 	if (message_data.get_is_valid() == false)
       
   519 	{
       
   520 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   521 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   522 	}
       
   523 
       
   524 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   525 
       
   526 	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);
       
   527 
       
   528 	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);
       
   529 
       
   530 	if (internal_settings == 0)
       
   531 	{
       
   532 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   533 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   534 	}
       
   535 
       
   536 	eap_status_e status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
       
   537 	if (status != eap_status_ok)
       
   538 	{
       
   539 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   540 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   541 	}
       
   542 
       
   543 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   544 
       
   545 	status = m_partner->complete_get_certificate_lists(
       
   546 		internal_settings);
       
   547 
       
   548 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   549 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   550 }
       
   551 
       
   552 //--------------------------------------------------
       
   553 
       
   554 eap_status_e eap_general_settings_client_message_if_c::complete_delete_all_eap_settings(
       
   555 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   556 {
       
   557 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   558 
       
   559 	EAP_TRACE_DEBUG(
       
   560 		m_am_tools, 
       
   561 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   562 		(EAPL("eap_general_settings_client_message_if_c::complete_delete_all_eap_settings(): this = 0x%08x.\n"),
       
   563 		this));
       
   564 
       
   565 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::complete_delete_all_eap_settings()");
       
   566 
       
   567 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   568 
       
   569 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
   570 
       
   571 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   572 
       
   573 	if (message_data.get_is_valid() == false)
       
   574 	{
       
   575 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   576 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   577 	}
       
   578 
       
   579 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   580 
       
   581 	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);
       
   582 
       
   583 	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);
       
   584 
       
   585 	if (internal_settings == 0)
       
   586 	{
       
   587 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   588 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   589 	}
       
   590 
       
   591 	eap_status_e status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
       
   592 	if (status != eap_status_ok)
       
   593 	{
       
   594 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   595 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   596 	}
       
   597 
       
   598 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   599 
       
   600 	status = m_partner->complete_delete_all_eap_settings(
       
   601 		internal_settings->m_completion_status);
       
   602 
       
   603 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   604 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   605 }
       
   606 
       
   607 //--------------------------------------------------
       
   608 
       
   609 eap_status_e eap_general_settings_client_message_if_c::complete_copy_all_eap_settings(
       
   610 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   611 {
       
   612 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   613 
       
   614 	EAP_TRACE_DEBUG(
       
   615 		m_am_tools, 
       
   616 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   617 		(EAPL("eap_general_settings_client_message_if_c::complete_copy_all_eap_settings(): this = 0x%08x.\n"),
       
   618 		this));
       
   619 
       
   620 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::complete_copy_all_eap_settings()");
       
   621 
       
   622 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   623 
       
   624 	u32_t parameter_index(eap_message_payload_index_first_parameter);
       
   625 
       
   626 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   627 
       
   628 	if (message_data.get_is_valid() == false)
       
   629 	{
       
   630 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   631 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   632 	}
       
   633 
       
   634 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   635 
       
   636 	eap_method_settings_c * const internal_settings = new eap_method_settings_c(m_am_tools);
       
   637 
       
   638 	eap_automatic_variable_c<eap_method_settings_c> automatic_internal_settings(m_am_tools, internal_settings);
       
   639 
       
   640 	if (internal_settings == 0)
       
   641 	{
       
   642 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   643 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   644 	}
       
   645 
       
   646 	eap_status_e status = message_data.read_parameter_data(parameters, parameter_index, internal_settings);
       
   647 	if (status != eap_status_ok)
       
   648 	{
       
   649 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   650 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   651 	}
       
   652 
       
   653 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
   654 
       
   655 	status = m_partner->complete_copy_all_eap_settings(
       
   656 		internal_settings->m_completion_status);
       
   657 
       
   658 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   659 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   660 }
       
   661 
       
   662 //--------------------------------------------------
       
   663 
       
   664 eap_status_e eap_general_settings_client_message_if_c::process_message_type_error(
       
   665 	EAP_TEMPLATE_CONST eap_array_c<eap_tlv_header_c> * const parameters)
       
   666 {
       
   667 	EAP_TRACE_DEBUG(
       
   668 		m_am_tools, 
       
   669 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   670 		(EAPL("eap_general_settings_client_message_if_c::process_message_type_error(): this = 0x%08x.\n"),
       
   671 		this));
       
   672 
       
   673 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::process_message_type_error()");
       
   674 
       
   675 	eap_status_e status(eap_status_ok);
       
   676 
       
   677 	eap_process_tlv_message_data_c message_data(m_am_tools);
       
   678 
       
   679 	if (message_data.get_is_valid() == false)
       
   680 	{
       
   681 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   682 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   683 	}
       
   684 
       
   685 	// Error payload is the first in this case.
       
   686 	status = message_data.read_parameter_data(parameters, eap_message_payload_index_function, eap_tlv_message_type_error, &m_error_code);
       
   687 	if (status != eap_status_ok)
       
   688 	{
       
   689 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   690 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   691 	}
       
   692 
       
   693 	// Fuction payload is the second in this case.
       
   694 	status = message_data.read_parameter_data(parameters, eap_message_payload_index_first_parameter, &m_error_function);
       
   695 
       
   696 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   697 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   698 }
       
   699 
       
   700 //--------------------------------------------------
       
   701 
       
   702 EAP_FUNC_EXPORT eap_status_e eap_general_settings_client_message_if_c::send_data(const void * const data, const u32_t length)
       
   703 {
       
   704 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   705 
       
   706 	EAP_TRACE_DEBUG(
       
   707 		m_am_tools, 
       
   708 		EAP_TRACE_FLAGS_MESSAGE_DATA, 
       
   709 		(EAPL("eap_general_settings_client_message_if_c::send_data(): this = 0x%08x.\n"),
       
   710 		this));
       
   711 
       
   712 	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, EAP_TRACE_FLAGS_MESSAGE_DATA, "returns: eap_general_settings_client_message_if_c::send_data()");
       
   713 
       
   714 	eap_status_e status(eap_status_process_general_error);
       
   715 
       
   716 	// Parses message data composed of Attribute-Value Pairs.
       
   717 	eap_process_tlv_message_data_c message(m_am_tools);
       
   718 
       
   719 	if (message.get_is_valid() == false)
       
   720 	{
       
   721 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   722 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   723 	}
       
   724 
       
   725 	status = message.set_message_data(length, data);
       
   726 	if (status != eap_status_ok)
       
   727 	{
       
   728 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   729 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   730 	}
       
   731 
       
   732 	EAP_TRACE_DATA_DEBUG(
       
   733 		m_am_tools,
       
   734 		EAP_TRACE_FLAGS_MESSAGE_DATA,
       
   735 		(EAPL("eap_general_settings_client_message_if_c::send_data()"),
       
   736 		message.get_message_data(),
       
   737 		message.get_message_data_length()));
       
   738 
       
   739 	eap_array_c<eap_tlv_header_c> parameters(m_am_tools);
       
   740 
       
   741 	status = message.parse_message_data(&parameters);
       
   742 	if (status != eap_status_ok)
       
   743 	{
       
   744 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   745 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   746 	}
       
   747 
       
   748 	if (parameters.get_object_count() == 0)
       
   749 	{
       
   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 	const eap_tlv_header_c * const function_header = parameters.get_object(eap_message_payload_index_function);
       
   755 	if (function_header == 0
       
   756 		|| (function_header->get_type() != eap_tlv_message_type_error
       
   757 			&& function_header->get_type() != eap_tlv_message_type_function))
       
   758 	{
       
   759 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   760 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   761 	}
       
   762 
       
   763 	if (function_header->get_type() == eap_tlv_message_type_error)
       
   764 	{
       
   765 		status = process_message_type_error(&parameters);
       
   766 	}
       
   767 	else
       
   768 	{
       
   769 		eap_tlv_message_type_function_e function(eap_tlv_message_type_function_none);
       
   770 
       
   771 		status = message.get_parameter_data(function_header, &function);
       
   772 		if (status != eap_status_ok)
       
   773 		{
       
   774 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   775 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   776 		}
       
   777 
       
   778 		switch(function)
       
   779 		{
       
   780 		case eap_tlv_message_type_function_general_settings_complete_set_eap_methods:
       
   781 			status = complete_set_eap_methods(&parameters);
       
   782 			break;
       
   783 		case eap_tlv_message_type_function_general_settings_complete_get_eap_methods:
       
   784 			status = complete_get_eap_methods(&parameters);
       
   785 			break;
       
   786 		case eap_tlv_message_type_function_general_settings_complete_get_certificate_lists:
       
   787 			status = complete_get_certificate_lists(&parameters);
       
   788 			break;
       
   789 		case eap_tlv_message_type_function_general_settings_complete_delete_all_eap_settings:
       
   790 			status = complete_delete_all_eap_settings(&parameters);
       
   791 			break;
       
   792 		case eap_tlv_message_type_function_general_settings_complete_copy_all_eap_settings:
       
   793 			status = complete_copy_all_eap_settings(&parameters);
       
   794 			break;
       
   795 		default:
       
   796 			EAP_TRACE_ERROR(
       
   797 				m_am_tools,
       
   798 				TRACE_FLAGS_DEFAULT,
       
   799 				(EAPL("ERROR: send_data(): unknown function %d.\n"),
       
   800 				 function));
       
   801 
       
   802 			EAP_ASSERT_ANYWAY_TOOLS(m_am_tools);
       
   803 
       
   804 			status = eap_status_illegal_parameter;
       
   805 		};
       
   806 	}
       
   807 
       
   808 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   809 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   810 }
       
   811 
       
   812 //--------------------------------------------------
       
   813 // End.