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