eapol/eapol_framework/wapi_common/src/wai_message_payloads.cpp
changeset 18 7aac0b9e8906
parent 17 8840d3e38314
child 20 8b3129ac4c0f
equal deleted inserted replaced
17:8840d3e38314 18:7aac0b9e8906
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : ./accesssec/eapol/eapol_framework/wapi_common/src/wai_message_payloads.cpp
       
     4 *  Part of     : WAPI / WAPI       *** Info from the SWAD
       
     5 *  Description : WAPI authentication
       
     6 *  Version     : %version: 35 % << 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 709 
       
    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 #if defined(USE_WAPI_CORE)
       
    30 
       
    31 
       
    32 #include "eap_am_memory.h"
       
    33 #include "wai_message_payloads.h"
       
    34 #include "wai_message.h"
       
    35 #include "abs_eap_am_tools.h"
       
    36 #include "eap_tools.h"
       
    37 #include "eap_array_algorithms.h"
       
    38 #include "eap_automatic_variable.h"
       
    39 #include "eap_crypto_api.h"
       
    40 #include "wapi_strings.h"
       
    41 
       
    42 //--------------------------------------------------
       
    43 
       
    44 EAP_FUNC_EXPORT wai_message_payloads_c::~wai_message_payloads_c()
       
    45 {
       
    46 }
       
    47 
       
    48 //--------------------------------------------------
       
    49 
       
    50 #if defined(_WIN32) && !defined(__GNUC__)
       
    51 	#pragma warning( disable : 4355 ) // 'this' : used in base member initializer list
       
    52 #endif
       
    53 
       
    54 EAP_FUNC_EXPORT wai_message_payloads_c::wai_message_payloads_c(
       
    55 	abs_eap_am_tools_c * const tools,
       
    56 	const bool true_when_is_client)
       
    57 	: m_am_tools(tools)
       
    58 	, m_message(tools)
       
    59 	, m_wai_protocol_packet_header(tools, 0, 0ul)
       
    60 	, m_payload_map(tools, this)
       
    61 	, m_read_payloads(tools)
       
    62 	, m_payload_index(0ul)
       
    63 	, m_is_client(true_when_is_client)
       
    64 	, m_is_valid(false)
       
    65 {
       
    66 	m_is_valid = true;
       
    67 }
       
    68 
       
    69 //--------------------------------------------------
       
    70 
       
    71 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::initialise_header()
       
    72 {
       
    73 	EAP_TRACE_DEBUG(
       
    74 		m_am_tools,
       
    75 		TRACE_FLAGS_DEFAULT,
       
    76 		(EAPL("WAI:     message_function: wai_message_payloads_c::initialise_header()\n")));
       
    77 
       
    78 	eap_status_e status = m_message.init(m_wai_protocol_packet_header.get_header_length());
       
    79 	if (status != eap_status_ok)
       
    80 	{
       
    81 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    82 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    83 	}
       
    84 
       
    85 	status = m_message.set_data_length(m_wai_protocol_packet_header.get_header_length());
       
    86 	if (status != eap_status_ok)
       
    87 	{
       
    88 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    89 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    90 	}
       
    91 
       
    92 	status = m_wai_protocol_packet_header.set_header_buffer(
       
    93 		m_message.get_data(),
       
    94 		m_message.get_data_length());
       
    95 	if (status != eap_status_ok)
       
    96 	{
       
    97 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
    98 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    99 	}
       
   100 
       
   101 	status = m_wai_protocol_packet_header.reset_header();
       
   102 	if (status != eap_status_ok)
       
   103 	{
       
   104 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   105 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   106 	}
       
   107 
       
   108 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   109 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   110 }
       
   111 
       
   112 //--------------------------------------------------
       
   113 
       
   114 EAP_FUNC_EXPORT const wai_protocol_packet_header_c * wai_message_payloads_c::get_wai_protocol_packet_header() const
       
   115 {
       
   116 	EAP_ASSERT_TOOLS(m_am_tools, (m_message.get_is_valid_data() == true));
       
   117 
       
   118 	return &m_wai_protocol_packet_header;
       
   119 }
       
   120 
       
   121 //--------------------------------------------------
       
   122 
       
   123 EAP_FUNC_EXPORT wai_protocol_packet_header_c * wai_message_payloads_c::get_wai_protocol_packet_header_writable()
       
   124 {
       
   125 	EAP_ASSERT_TOOLS(m_am_tools, (m_message.get_is_valid_data() == true));
       
   126 
       
   127 	return &m_wai_protocol_packet_header;
       
   128 }
       
   129 
       
   130 //--------------------------------------------------
       
   131 
       
   132 EAP_FUNC_EXPORT wai_variable_data_c * wai_message_payloads_c::get_tlv_pointer(
       
   133 	const wai_payload_type_e current_payload,
       
   134 	u32_t index) const
       
   135 {
       
   136 	eap_variable_data_c selector(m_am_tools);
       
   137 
       
   138 	if (selector.get_is_valid() == false)
       
   139 	{
       
   140 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   141 		(void) EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   142 		return 0;
       
   143 	}
       
   144 
       
   145 	selector.set_buffer(
       
   146 		&current_payload,
       
   147 		sizeof(current_payload),
       
   148 		false,
       
   149 		false);
       
   150 
       
   151 	wai_variable_data_c *payload = m_payload_map.get_handler(&selector);
       
   152 
       
   153 	while (index != 0ul && payload != 0)
       
   154 	{
       
   155 		--index;
       
   156 		payload = payload->get_next_payload_with_same_tlv_type();
       
   157 	}
       
   158 
       
   159 	return payload;
       
   160 }
       
   161 
       
   162 //--------------------------------------------------
       
   163 
       
   164 EAP_FUNC_EXPORT wai_variable_data_c * wai_message_payloads_c::get_tlv_pointer(
       
   165 	const wai_payload_type_e current_payload) const
       
   166 {
       
   167 	return get_tlv_pointer(current_payload, 0ul);
       
   168 }
       
   169 
       
   170 //--------------------------------------------------
       
   171 
       
   172 EAP_FUNC_EXPORT u32_t wai_message_payloads_c::get_tlv_count() const
       
   173 {
       
   174 	return m_read_payloads.get_object_count();
       
   175 }
       
   176 
       
   177 //--------------------------------------------------
       
   178 
       
   179 EAP_FUNC_EXPORT wai_variable_data_c * wai_message_payloads_c::get_tlv(
       
   180 	const u32_t tlv_index) const
       
   181 {
       
   182 	wai_variable_data_c *payload = m_read_payloads.get_object(tlv_index);
       
   183 
       
   184 	EAP_TRACE_DEBUG(
       
   185 		m_am_tools,
       
   186 		TRACE_FLAGS_DEFAULT,
       
   187 		(EAPL("WAI:     message_function: wai_message_payloads_c::get_tlv(index %d, count %d) = %s\n"),
       
   188 		tlv_index,
       
   189 		m_read_payloads.get_object_count(),
       
   190 		payload->get_wai_payload_type_string()));
       
   191 
       
   192 	return payload;
       
   193 }
       
   194 
       
   195 //--------------------------------------------------
       
   196 
       
   197 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::insert_payload(
       
   198 	const wai_variable_data_c * const new_payload)
       
   199 {
       
   200 	wai_variable_data_c * const copy_payload = new_payload->copy();
       
   201 	if (copy_payload == 0)
       
   202 	{
       
   203 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   204 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   205 	}
       
   206 
       
   207 	return m_read_payloads.add_object(copy_payload, true);
       
   208 }
       
   209 
       
   210 //--------------------------------------------------
       
   211 
       
   212 #if 0
       
   213 
       
   214 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::check_payloads_existense(
       
   215 	const wai_payload_type_e * const needed_payloads,
       
   216 	const u32_t count_of_needed_payloads) const
       
   217 {
       
   218 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   219 
       
   220 	EAP_TRACE_DEBUG(
       
   221 		m_am_tools,
       
   222 		TRACE_FLAGS_DEFAULT,
       
   223 		(EAPL("WAI:     message_function: wai_message_payloads_c::check_payloads_existense()\n")));
       
   224 
       
   225 	for (u32_t ind = 0ul; ind < count_of_needed_payloads; ind++)
       
   226 	{
       
   227 		const wai_payload_type_e required_avp_code = needed_payloads[ind];
       
   228 		if (required_avp_code == 0)
       
   229 		{
       
   230 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   231 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   232 		}
       
   233 
       
   234 		if (get_tlv_pointer(required_avp_code) == 0)
       
   235 		{
       
   236 			EAP_TRACE_DEBUG(
       
   237 				m_am_tools, 
       
   238 				TRACE_FLAGS_DEFAULT, 
       
   239 				(EAPL("not received TLV 0x%08x.\n"),
       
   240 				 required_avp_code));
       
   241 
       
   242 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   243 			return EAP_STATUS_RETURN(m_am_tools, eap_status_not_found);
       
   244 		}
       
   245 	}
       
   246 
       
   247 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   248 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   249 }
       
   250 
       
   251 #endif
       
   252 
       
   253 //--------------------------------------------------
       
   254 
       
   255 #if 0
       
   256 
       
   257 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::check_payloads_existense(
       
   258 	EAP_TEMPLATE_CONST eap_array_c<wai_payload_type_e> * const needed_payloads) const
       
   259 {
       
   260 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   261 
       
   262 	EAP_TRACE_DEBUG(
       
   263 		m_am_tools,
       
   264 		TRACE_FLAGS_DEFAULT,
       
   265 		(EAPL("WAI:     message_function: wai_message_payloads_c::check_payloads_existense()\n")));
       
   266 
       
   267 	for (u32_t ind = 0ul; ind < needed_payloads->get_object_count(); ind++)
       
   268 	{
       
   269 		const wai_payload_type_e * const required_avp_code = needed_payloads->get_object(ind);
       
   270 		if (required_avp_code == 0)
       
   271 		{
       
   272 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   273 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   274 		}
       
   275 
       
   276 		if (get_tlv_pointer(*required_avp_code) == 0)
       
   277 		{
       
   278 			EAP_TRACE_DEBUG(
       
   279 				m_am_tools, 
       
   280 				TRACE_FLAGS_DEFAULT, 
       
   281 				(EAPL("not received TLV 0x%08x.\n"),
       
   282 				 *required_avp_code));
       
   283 
       
   284 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   285 			return EAP_STATUS_RETURN(m_am_tools, eap_status_not_found);
       
   286 		}
       
   287 	}
       
   288 
       
   289 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   290 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   291 }
       
   292 
       
   293 #endif
       
   294 
       
   295 //--------------------------------------------------
       
   296 
       
   297 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::copy_tlv(
       
   298 	const wai_message_payloads_c * const source,
       
   299 	const wai_payload_type_e tlv)
       
   300 {
       
   301 	EAP_TRACE_DEBUG(
       
   302 		m_am_tools,
       
   303 		TRACE_FLAGS_DEFAULT,
       
   304 		(EAPL("WAI:     message_function: wai_message_payloads_c::copy_tlv(TLV 0x%08x)\n"),
       
   305 		tlv));
       
   306 
       
   307 	const wai_variable_data_c * const payload
       
   308 		= source->get_tlv_pointer(tlv, 0ul);
       
   309 	if (payload == 0)
       
   310 	{
       
   311 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   312 		return EAP_STATUS_RETURN(m_am_tools, eap_status_missing_payload);
       
   313 	}
       
   314 
       
   315 	eap_status_e status = add_tlv(
       
   316 		payload->copy());
       
   317 	if (status != eap_status_ok)
       
   318 	{
       
   319 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   320 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   321 	}
       
   322 
       
   323 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   324 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   325 }
       
   326 
       
   327 //--------------------------------------------------
       
   328 
       
   329 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::add_tlv(
       
   330 	wai_variable_data_c * const new_payload)
       
   331 {
       
   332 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   333 
       
   334 	EAP_TRACE_DEBUG(
       
   335 		m_am_tools,
       
   336 		TRACE_FLAGS_DEFAULT,
       
   337 		(EAPL("WAI:     message_function: wai_message_payloads_c::add_tlv(): %s\n"),
       
   338 		wapi_strings_c::get_wai_payload_type_string(new_payload->get_payload_type())));
       
   339 
       
   340 	if (new_payload == 0)
       
   341 	{
       
   342 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   343 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   344 	}
       
   345 
       
   346 	WAI_VARIABLE_DATA_TRACE(m_am_tools, "wai_message_payloads_c::add_tlv()", new_payload, m_is_client);
       
   347 
       
   348 	wai_variable_data_c * const copy_payload = new_payload->copy();
       
   349 	if (copy_payload == 0)
       
   350 	{
       
   351 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   352 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   353 	}
       
   354 
       
   355 	WAI_VARIABLE_DATA_TRACE(m_am_tools, "wai_message_payloads_c::add_tlv() copy", copy_payload, m_is_client);
       
   356 
       
   357 	eap_status_e status(eap_status_process_general_error);
       
   358 
       
   359 	eap_automatic_variable_c<wai_variable_data_c>
       
   360 		automatic_new_payload(m_am_tools, copy_payload);
       
   361 
       
   362 	const wai_payload_type_e new_payload_type(copy_payload->get_payload_type());
       
   363 		
       
   364 	wai_variable_data_c *old_payload = get_tlv_pointer(
       
   365 		new_payload_type);
       
   366 
       
   367 	{
       
   368 		eap_variable_data_c selector(m_am_tools);
       
   369 
       
   370 		if (selector.get_is_valid() == false)
       
   371 		{
       
   372 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   373 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   374 		}
       
   375 
       
   376 		status = selector.set_copy_of_buffer(
       
   377 			&new_payload_type,
       
   378 			sizeof(new_payload_type));
       
   379 		if (status != eap_status_ok)
       
   380 		{
       
   381 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   382 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   383 		}
       
   384 		
       
   385 		if (old_payload == 0)
       
   386 		{
       
   387 			status = m_payload_map.add_handler(&selector, copy_payload);
       
   388 			if (status != eap_status_ok)
       
   389 			{
       
   390 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   391 				return EAP_STATUS_RETURN(m_am_tools, status);
       
   392 			}
       
   393 		}
       
   394 		else
       
   395 		{
       
   396 			// Cannot add dublicate payload to m_payload_map.
       
   397 			// Instead we add apointer to the next payload with the same tlv type.
       
   398 			old_payload->add_next_payload_with_same_tlv_type(copy_payload);
       
   399 		}
       
   400 
       
   401 		automatic_new_payload.do_not_free_variable();
       
   402 
       
   403 		// Note the same payload object is added to m_read_payloads as to m_payload_map.
       
   404 		status = m_read_payloads.add_object(copy_payload, false);
       
   405 		if (status != eap_status_ok)
       
   406 		{
       
   407 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   408 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   409 		}
       
   410 	}
       
   411 
       
   412 	status = m_wai_protocol_packet_header.set_length(m_wai_protocol_packet_header.get_length() + copy_payload->get_data_length());
       
   413 	if (status != eap_status_ok)
       
   414 	{
       
   415 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   416 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   417 	}
       
   418 
       
   419 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   420 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   421 }
       
   422 
       
   423 //--------------------------------------------------
       
   424 
       
   425 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::copy_tlv_data(
       
   426 	const wai_payload_type_e current_payload,
       
   427 	const void * const data,
       
   428 	const u32_t data_length)
       
   429 {
       
   430 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   431 
       
   432 	EAP_TRACE_DEBUG(
       
   433 		m_am_tools,
       
   434 		TRACE_FLAGS_DEFAULT,
       
   435 		(EAPL("WAI:     message_function: wai_message_payloads_c::copy_tlv_data(TLV 0x%08x)\n"),
       
   436 		current_payload));
       
   437 
       
   438 	eap_status_e status(eap_status_process_general_error);
       
   439 
       
   440 	wai_variable_data_c new_payload(m_am_tools);
       
   441 	if (new_payload.get_is_valid() == false)
       
   442 	{
       
   443 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   444 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
   445 	}
       
   446 
       
   447 	status = new_payload.set_copy_of_buffer(
       
   448 		current_payload,
       
   449 		data,
       
   450 		data_length);
       
   451 	if (status != eap_status_ok)
       
   452 	{
       
   453 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   454 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   455 	}
       
   456 	
       
   457 	status = add_tlv(&new_payload);
       
   458 	if (status != eap_status_ok)
       
   459 	{
       
   460 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   461 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   462 	}
       
   463 
       
   464 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   465 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   466 }
       
   467 
       
   468 //--------------------------------------------------
       
   469 
       
   470 EAP_FUNC_EXPORT bool wai_message_payloads_c::get_is_valid() const
       
   471 {
       
   472 	return m_is_valid;
       
   473 }
       
   474 
       
   475 //--------------------------------------------------
       
   476 
       
   477 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::parse_generic_payload(
       
   478 	const wai_payload_type_e payload_type,
       
   479 	const wai_variable_data_c * const wai_data,
       
   480 	u32_t * const prev_payload_length)
       
   481 {
       
   482 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   483 
       
   484 	eap_status_e status(eap_status_process_general_error);
       
   485 
       
   486 	if (wai_data == 0
       
   487 		|| wai_data->get_is_valid() == false)
       
   488 	{
       
   489 		EAP_TRACE_ERROR(
       
   490 			m_am_tools,
       
   491 			TRACE_FLAGS_ERROR,
       
   492 			(EAPL("ERROR: wai_message_payloads_c::parse_generic_payload(): illegal wai_data=0x%08x")
       
   493 			 EAPL("current header 0x%08x=%s.\n"),
       
   494 			 wai_data,
       
   495 			 payload_type,
       
   496 			 wapi_strings_c::get_wai_payload_type_string(payload_type)));
       
   497 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   498 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
   499 	}
       
   500 
       
   501 	const u32_t data_length(wai_data->get_data_length());
       
   502 	const u32_t type_length(wai_data->get_type_header_length() + wai_data->get_type_data_length());
       
   503 	const u8_t * const data = wai_data->get_data(type_length);
       
   504 
       
   505 	*prev_payload_length = 0ul;
       
   506 
       
   507 	if (data_length < type_length)
       
   508 	{
       
   509 		EAP_TRACE_ERROR(
       
   510 			m_am_tools,
       
   511 			TRACE_FLAGS_ERROR,
       
   512 			(EAPL("ERROR: wai_message_payloads_c::parse_generic_payload(0x%08x): wai_data=0x%08x")
       
   513 			 EAPL("current header 0x%08x=%s, required length 0x%08x, packet length too less 0x%08x.\n"),
       
   514 			 data,
       
   515 			 wai_data,
       
   516 			 payload_type,
       
   517 			 wapi_strings_c::get_wai_payload_type_string(payload_type),
       
   518 			 type_length,
       
   519 			 data_length));
       
   520 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   521 		return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   522 	}
       
   523 
       
   524 	if (data == 0)
       
   525 	{
       
   526 		EAP_TRACE_ERROR(
       
   527 			m_am_tools, 
       
   528 			TRACE_FLAGS_ERROR, 
       
   529 			(EAPL("ERROR: wai_message_payloads_c::parse_generic_payload(0x%08x): wai_data=0x%08x")
       
   530 			 EAPL("current header 0x%08x=%s, type length 0x%04x, data buffer incorrect.\n"),
       
   531 			 data,
       
   532 			 wai_data,
       
   533 			 payload_type,
       
   534 			 wapi_strings_c::get_wai_payload_type_string(payload_type),
       
   535 			 type_length));
       
   536 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   537 		return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   538 	}
       
   539 
       
   540 	WAI_VARIABLE_DATA_TRACE(m_am_tools, "Parse WAI-TLV payload", wai_data, m_is_client);
       
   541 
       
   542 	status = copy_tlv_data(
       
   543 		wai_data->get_payload_type(),
       
   544 		data,
       
   545 		data_length);
       
   546 	if (status != eap_status_ok)
       
   547 	{
       
   548 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   549 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   550 	}
       
   551 
       
   552 	*prev_payload_length = type_length;
       
   553 
       
   554 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   555 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   556 }
       
   557 
       
   558 //--------------------------------------------------
       
   559 
       
   560 //
       
   561 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::parse_wai_payloads(
       
   562 	void * const message_buffer,
       
   563 	const u32_t buffer_length,
       
   564 	u32_t * const padding_length)
       
   565 {
       
   566 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   567 
       
   568 	EAP_TRACE_DEBUG(
       
   569 		m_am_tools,
       
   570 		TRACE_FLAGS_DEFAULT,
       
   571 		(EAPL("WAI:     message_function: wai_message_payloads_c::parse_wai_payloads()\n")));
       
   572 
       
   573 	eap_status_e status = eap_status_header_corrupted;
       
   574 
       
   575 	*padding_length = 0ul;
       
   576 
       
   577 	if (buffer_length == 0)
       
   578 	{
       
   579 		// Empty payload.
       
   580 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   581 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   582 	}
       
   583 
       
   584 	u32_t remaining_data_length(buffer_length);
       
   585 	u32_t remaining_data_offset(0ul);
       
   586 
       
   587 
       
   588 	status = m_message.set_copy_of_buffer(message_buffer, remaining_data_length);
       
   589 	if (status != eap_status_ok)
       
   590 	{
       
   591 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   592 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   593 	}
       
   594 
       
   595 	status = m_wai_protocol_packet_header.set_header_buffer(
       
   596 		m_message.get_data(),
       
   597 		m_message.get_data_length());
       
   598 	if (status != eap_status_ok)
       
   599 	{
       
   600 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   601 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   602 	}
       
   603 
       
   604 	status = m_wai_protocol_packet_header.check_header();
       
   605 	if (status != eap_status_ok)
       
   606 	{
       
   607 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   608 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   609 	}
       
   610 
       
   611 	remaining_data_length -= m_wai_protocol_packet_header.get_header_length();
       
   612 	remaining_data_offset += m_wai_protocol_packet_header.get_header_length();
       
   613 
       
   614 	EAP_TRACE_DATA_DEBUG(
       
   615 		m_am_tools,
       
   616 		TRACE_FLAGS_DEFAULT,
       
   617 		(EAPL("parse_wai_payloads"),
       
   618 		 m_message.get_data(),
       
   619 		 m_message.get_data_length()));
       
   620 
       
   621 	const wai_payload_type_e * required_payloads = 0;
       
   622 
       
   623 	switch(m_wai_protocol_packet_header.get_subtype())
       
   624 	{
       
   625 
       
   626 	case wai_protocol_subtype_pre_authentication_start:
       
   627 	case wai_protocol_subtype_stakey_request:
       
   628 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   629 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
   630 
       
   631 	case wai_protocol_subtype_authentication_activation:
       
   632 		required_payloads = required_payloads_authentication_activation;
       
   633 		break;
       
   634 	case wai_protocol_subtype_access_authentication_request:
       
   635 		required_payloads = required_payloads_access_authentication_request;
       
   636 		break;
       
   637 	case wai_protocol_subtype_access_authentication_response:
       
   638 		required_payloads = required_payloads_access_authentication_response;
       
   639 		break;
       
   640 	case wai_protocol_subtype_certificate_authentication_request:
       
   641 		required_payloads = required_payloads_certificate_authentication_request;
       
   642 		break;
       
   643 	case wai_protocol_subtype_certificate_authentication_response:
       
   644 		required_payloads = required_payloads_certificate_authentication_response;
       
   645 		break;
       
   646 	case wai_protocol_subtype_unicast_key_negotiation_request:
       
   647 		required_payloads = required_payloads_unicast_key_negotiation_request;
       
   648 		break;
       
   649 	case wai_protocol_subtype_unicast_key_negotiation_response:
       
   650 		required_payloads = required_payloads_unicast_key_negotiation_response;
       
   651 		break;
       
   652 	case wai_protocol_subtype_unicast_key_negotiation_confirmation:
       
   653 		required_payloads = required_payloads_unicast_key_negotiation_confirmation;
       
   654 		break;
       
   655 	case wai_protocol_subtype_multicast_key_announcement:
       
   656 		required_payloads = required_payloads_multicast_key_announcement;
       
   657 		break;
       
   658 	case wai_protocol_subtype_multicast_key_announcement_response:
       
   659 		required_payloads = required_payloads_multicast_key_announcement_response;
       
   660 		break;
       
   661 	default:
       
   662 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   663 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
       
   664 
       
   665 	}; // switch()
       
   666 
       
   667 
       
   668 	u32_t payload_index(0ul);
       
   669 
       
   670 	wai_variable_data_c payload(
       
   671 		m_am_tools);
       
   672 
       
   673 	status = payload.set_buffer(
       
   674 		required_payloads[payload_index],
       
   675 		m_wai_protocol_packet_header.get_data(m_wai_protocol_packet_header.get_data_length()),
       
   676 		m_wai_protocol_packet_header.get_data_length());
       
   677 	if (status != eap_status_ok)
       
   678 	{
       
   679 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   680 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   681 	}
       
   682 
       
   683 
       
   684 	if (payload.get_is_valid() == true
       
   685 		&& required_payloads[payload_index] >= wai_tlv_type_first_known
       
   686 		&& required_payloads[payload_index] <= wai_tlv_type_last_known)
       
   687 	{
       
   688 		if (remaining_data_length < payload.get_data_length())
       
   689 		{
       
   690 			EAP_TRACE_ERROR(
       
   691 				m_am_tools,
       
   692 				TRACE_FLAGS_ERROR,
       
   693 				(EAPL("ERROR: wai_message_payloads_c::parse_wai_payloads(0x%08x): ")
       
   694 				 EAPL("current payload 0x%08x=%s, buffer length 0x%04x.\n"),
       
   695 				 payload.get_data(0ul),
       
   696 				 required_payloads[payload_index],
       
   697 				 wapi_strings_c::get_wai_payload_type_string(required_payloads[payload_index]),
       
   698 				 remaining_data_length));
       
   699 			EAP_TRACE_ERROR(
       
   700 				m_am_tools,
       
   701 				TRACE_FLAGS_ERROR,
       
   702 				(EAPL("ERROR: wai_message_payloads_c::parse_wai_payloads(): ")
       
   703 				 EAPL("WAI-payload header is corrupted.\n")));
       
   704 			EAP_TRACE_DATA_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("payload"),
       
   705 				payload.get_data(remaining_data_length),
       
   706 				remaining_data_length));
       
   707 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   708 			return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   709 		}
       
   710 
       
   711 		u32_t prev_payload_length(0ul);
       
   712 
       
   713 		status = parse_generic_payload(
       
   714 			required_payloads[payload_index],
       
   715 			&payload,
       
   716 			&prev_payload_length);
       
   717 		if (status != eap_status_ok)
       
   718 		{
       
   719 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   720 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   721 		}
       
   722 
       
   723 		bool optional_payload_is_included(false);
       
   724 
       
   725 		{
       
   726 			// Check whether the optional payload is included.
       
   727 
       
   728 			const u8_t * const flag = payload.get_data(sizeof(*flag));
       
   729 			if (flag == 0)
       
   730 			{
       
   731 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   732 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   733 			}
       
   734 
       
   735 			if (((*flag) & wai_data_flag_mask_Optional_Field) != 0)
       
   736 			{
       
   737 				optional_payload_is_included = true;
       
   738 			}
       
   739 		}
       
   740 
       
   741 		if (remaining_data_length < prev_payload_length)
       
   742 		{
       
   743 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   744 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   745 		}
       
   746 
       
   747 		remaining_data_length -= prev_payload_length;
       
   748 		remaining_data_offset += prev_payload_length;
       
   749 
       
   750 		++payload_index;
       
   751 		if (required_payloads[payload_index] == wai_payload_type_terminator)
       
   752 		{
       
   753 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   754 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   755 		}
       
   756 
       
   757 		if (optional_payload_is_included == false
       
   758 			&& required_payloads[payload_index] == wai_payload_type_optional)
       
   759 		{
       
   760 			++payload_index;
       
   761 			if (required_payloads[payload_index] == wai_payload_type_terminator)
       
   762 			{
       
   763 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   764 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   765 			}
       
   766 		}
       
   767 
       
   768 		status = payload.set_buffer(
       
   769 			required_payloads[payload_index],
       
   770 			m_message.get_data_offset(remaining_data_offset, remaining_data_length),
       
   771 			remaining_data_length);
       
   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 		u32_t type_length(payload.get_type_header_length() + payload.get_type_data_length());
       
   779 
       
   780 		while(remaining_data_length > 0ul
       
   781 			&& remaining_data_length >= type_length
       
   782 			&& payload.get_is_valid() == true)
       
   783 		{
       
   784 			status = parse_generic_payload(
       
   785 				required_payloads[payload_index],
       
   786 				&payload,
       
   787 				&prev_payload_length);
       
   788 			if (status != eap_status_ok)
       
   789 			{
       
   790 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   791 				return EAP_STATUS_RETURN(m_am_tools, status);
       
   792 			}
       
   793 
       
   794 			if (remaining_data_length < prev_payload_length
       
   795 				|| prev_payload_length == 0)
       
   796 			{
       
   797 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   798 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   799 			}
       
   800 
       
   801 			remaining_data_length -= prev_payload_length;
       
   802 			remaining_data_offset += prev_payload_length;
       
   803 
       
   804 #if 1
       
   805 			if (required_payloads[payload_index] != wai_payload_type_optional)
       
   806 			{
       
   807 				++payload_index;
       
   808 			}
       
   809 			else
       
   810 			{
       
   811 				EAP_TRACE_DEBUG(
       
   812 					m_am_tools,
       
   813 					TRACE_FLAGS_DEFAULT,
       
   814 					(EAPL("WAI:     message_function: wai_message_payloads_c::parse_wai_payloads(): parse optional payload.\n")));
       
   815 			}
       
   816 #else
       
   817 			if (optional_payload_is_included == false
       
   818 				|| required_payloads[payload_index] != wai_payload_type_optional)
       
   819 			{
       
   820 				++payload_index;
       
   821 				if (required_payloads[payload_index] == wai_payload_type_terminator)
       
   822 				{
       
   823 					break;
       
   824 				}
       
   825 
       
   826 				if (optional_payload_is_included == false
       
   827 					&& required_payloads[payload_index] == wai_payload_type_optional)
       
   828 				{
       
   829 					++payload_index;
       
   830 					if (required_payloads[payload_index] == wai_payload_type_terminator)
       
   831 					{
       
   832 						break;
       
   833 					}
       
   834 				}
       
   835 			}
       
   836 #endif
       
   837 
       
   838 			status = payload.set_buffer(
       
   839 				required_payloads[payload_index],
       
   840 				m_message.get_data_offset(remaining_data_offset, remaining_data_length),
       
   841 				remaining_data_length);
       
   842 			if (status != eap_status_ok)
       
   843 			{
       
   844 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   845 				return EAP_STATUS_RETURN(m_am_tools, status);
       
   846 			}
       
   847 
       
   848 			type_length = (payload.get_type_header_length() + payload.get_type_data_length());
       
   849 
       
   850 		} // while()
       
   851 
       
   852 
       
   853 		if (remaining_data_length != 0u)
       
   854 		{
       
   855 			EAP_TRACE_ERROR(
       
   856 				m_am_tools,
       
   857 				TRACE_FLAGS_ERROR,
       
   858 				(EAPL("ERROR: wai_message_payloads_c::parse_wai_payloads(): ")
       
   859 				 EAPL("WAI-header is corrupted. Buffer length and payload ")
       
   860 				 EAPL("length does not match. %lu illegal bytes.\n"),
       
   861 				 remaining_data_length));
       
   862 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   863 			return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   864 		}
       
   865 	}
       
   866 	else
       
   867 	{
       
   868 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   869 		return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted);
       
   870 	}
       
   871 
       
   872 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   873 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   874 }
       
   875 
       
   876 //--------------------------------------------------
       
   877 
       
   878 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::create_wai_tlv_message(
       
   879 	wai_message_c * const new_wai_message_data,
       
   880 	const bool add_payloads) const
       
   881 {
       
   882 	EAP_TRACE_DEBUG(
       
   883 		m_am_tools,
       
   884 		TRACE_FLAGS_DEFAULT,
       
   885 		(EAPL("WAI:     message_function: wai_message_payloads_c::create_wai_tlv_message()\n")));
       
   886 
       
   887 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: wai_message_payloads_c::create_wai_tlv_message()");
       
   888 
       
   889 	eap_status_e status(eap_status_process_general_error);
       
   890 
       
   891 	if (add_payloads == false)
       
   892 	{
       
   893 		status = new_wai_message_data->reset();
       
   894 		if (status != eap_status_ok)
       
   895 		{
       
   896 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   897 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   898 		}
       
   899 
       
   900 		status = new_wai_message_data->get_wai_message_data_writable()->add_data(
       
   901 			m_wai_protocol_packet_header.get_header_buffer(m_wai_protocol_packet_header.get_header_length()),
       
   902 			m_wai_protocol_packet_header.get_header_length());
       
   903 		if (status != eap_status_ok)
       
   904 		{
       
   905 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   906 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   907 		}
       
   908 	}
       
   909 
       
   910 	const u32_t tlv_count(get_tlv_count());
       
   911 	u32_t tlv_index(0ul);
       
   912 
       
   913 	while (tlv_index < tlv_count)
       
   914 	{
       
   915 		wai_variable_data_c * wai_data = get_tlv(tlv_index);
       
   916 		if (wai_data == 0)
       
   917 		{
       
   918 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   919 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_payload);
       
   920 		}
       
   921 
       
   922 		status = new_wai_message_data->get_wai_message_data_writable()->add_data(wai_data->get_full_tlv_buffer());
       
   923 		if (status != eap_status_ok)
       
   924 		{
       
   925 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   926 			return EAP_STATUS_RETURN(m_am_tools, status);
       
   927 		}
       
   928 
       
   929 		WAI_VARIABLE_DATA_TRACE(m_am_tools, "Added WAI-TLV payload", wai_data, m_is_client);
       
   930 
       
   931 		++tlv_index;
       
   932 
       
   933 		EAP_TRACE_DEBUG(
       
   934 			m_am_tools,
       
   935 			TRACE_FLAGS_DEFAULT,
       
   936 			(EAPL("WAI:     message_function: wai_message_payloads_c::create_wai_tlv_message(): index %d\n"),
       
   937 			tlv_index));
       
   938 
       
   939 	}
       
   940 
       
   941 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   942 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   943 }
       
   944 
       
   945 //--------------------------------------------------
       
   946 
       
   947 EAP_FUNC_EXPORT eap_status_e wai_message_payloads_c::reset()
       
   948 {
       
   949 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   950 
       
   951 	eap_status_e status = m_message.reset_start_offset_and_data_length();
       
   952 	if (status != eap_status_ok)
       
   953 	{
       
   954 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   955 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   956 	}
       
   957 		
       
   958 	status = m_payload_map.reset();
       
   959 	if (status != eap_status_ok)
       
   960 	{
       
   961 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   962 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   963 	}
       
   964 
       
   965 	status = m_read_payloads.reset();
       
   966 	if (status != eap_status_ok)
       
   967 	{
       
   968 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   969 		return EAP_STATUS_RETURN(m_am_tools, status);
       
   970 	}
       
   971 
       
   972 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   973 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
       
   974 }
       
   975 
       
   976 //--------------------------------------------------
       
   977 
       
   978 EAP_FUNC_EXPORT wai_message_payloads_c * wai_message_payloads_c::copy() const
       
   979 {
       
   980 	EAP_TRACE_DEBUG(
       
   981 		m_am_tools,
       
   982 		TRACE_FLAGS_DEFAULT,
       
   983 		(EAPL("WAI:     message_function: wai_message_payloads_c::copy()\n")));
       
   984 
       
   985 	wai_message_payloads_c * copy_payloads = new wai_message_payloads_c(m_am_tools, m_is_client);
       
   986 
       
   987 	if (copy_payloads == 0
       
   988 		|| copy_payloads->get_is_valid() == false)
       
   989 	{
       
   990 		delete copy_payloads;
       
   991 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   992 		return 0;
       
   993 	}
       
   994 
       
   995 	eap_status_e status(eap_status_process_general_error);
       
   996 
       
   997 	const u32_t tlv_count(get_tlv_count());
       
   998 	u32_t tlv_index(0ul);
       
   999 
       
  1000 	while (tlv_index < tlv_count)
       
  1001 	{
       
  1002 		wai_variable_data_c * wai_data = get_tlv(tlv_index);
       
  1003 		if (wai_data == 0)
       
  1004 		{
       
  1005 			delete copy_payloads;
       
  1006 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1007 			return 0;
       
  1008 		}
       
  1009 
       
  1010 		status = copy_payloads->add_tlv(
       
  1011 			wai_data->copy());
       
  1012 
       
  1013 		if (status != eap_status_ok)
       
  1014 		{
       
  1015 			delete copy_payloads;
       
  1016 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1017 			return 0;
       
  1018 		}
       
  1019 
       
  1020 		++tlv_index;
       
  1021 	}
       
  1022 
       
  1023 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1024 	return copy_payloads;
       
  1025 }
       
  1026 
       
  1027 //--------------------------------------------------
       
  1028 
       
  1029 #endif //#if defined(USE_WAPI_CORE)
       
  1030 
       
  1031 // End.