eapol/eapol_framework/eapol_common/common/eap_network_id_selector.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 30 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 #include "eap_am_memory.h"
       
    29 #include "eap_tools.h"
       
    30 #include "eap_am_export.h"
       
    31 #include "eap_variable_data.h"
       
    32 #include "eap_network_id_selector.h"
       
    33 
       
    34 
       
    35 //--------------------------------------------------
       
    36 
       
    37 EAP_FUNC_EXPORT eap_network_id_selector_c::~eap_network_id_selector_c()
       
    38 {
       
    39 }
       
    40 
       
    41 //--------------------------------------------------
       
    42 
       
    43 EAP_FUNC_EXPORT eap_network_id_selector_c::eap_network_id_selector_c(
       
    44 	abs_eap_am_tools_c * const tools)
       
    45 	: eap_variable_data_c(tools)
       
    46 	, m_am_tools(tools)
       
    47 {
       
    48 }
       
    49 
       
    50 //--------------------------------------------------
       
    51 
       
    52 EAP_FUNC_EXPORT eap_network_id_selector_c::eap_network_id_selector_c(
       
    53 	abs_eap_am_tools_c * const tools,
       
    54 	const eap_am_network_id_c * const network_id)
       
    55 	: eap_variable_data_c(tools)
       
    56 	  , m_am_tools(tools)
       
    57 {
       
    58 	if (eap_variable_data_c::get_is_valid() == false)
       
    59 	{
       
    60 		return;
       
    61 	}
       
    62 
       
    63 	eap_status_e status = set_selector(network_id);
       
    64 	if (status != eap_status_ok)
       
    65 	{
       
    66 		return;
       
    67 	}
       
    68 }
       
    69 
       
    70 //--------------------------------------------------
       
    71 
       
    72 EAP_FUNC_EXPORT eap_status_e eap_network_id_selector_c::set_selector(
       
    73 	const eap_am_network_id_c * const network_id)
       
    74 {
       
    75 	eap_status_e status = eap_status_process_general_error;
       
    76 
       
    77 	if (network_id == 0)
       
    78 	{
       
    79 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
       
    80 	}
       
    81 	
       
    82 	// Pre-allocates buffer for ID.
       
    83 	status = set_buffer_length(network_id->get_source_id()->get_data_length() + network_id->get_destination_id()->get_data_length());
       
    84 	if (status != eap_status_ok)
       
    85 	{
       
    86 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    87 	}
       
    88 
       
    89 	status = set_copy_of_buffer(network_id->get_source_id());
       
    90 	if (status != eap_status_ok)
       
    91 	{
       
    92 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    93 	}
       
    94 	
       
    95 	status = add_data(network_id->get_destination_id());
       
    96 	if (status != eap_status_ok)
       
    97 	{
       
    98 		return EAP_STATUS_RETURN(m_am_tools, status);
       
    99 	}
       
   100 	
       
   101 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   102 }
       
   103 
       
   104 //--------------------------------------------------
       
   105 
       
   106 EAP_FUNC_EXPORT eap_network_id_selector_c::eap_network_id_selector_c(
       
   107 	abs_eap_am_tools_c * const tools,
       
   108 	const eap_network_id_selector_c * const selector)
       
   109 	: eap_variable_data_c(tools)
       
   110 	  , m_am_tools(tools)
       
   111 {
       
   112 	eap_status_e status = set_copy_of_buffer(
       
   113 		selector->get_data(selector->get_data_length()),
       
   114 		selector->get_data_length());
       
   115 	if (status != eap_status_ok)
       
   116 	{
       
   117 		return;
       
   118 	}
       
   119 }
       
   120 
       
   121 //--------------------------------------------------
       
   122 
       
   123 EAP_FUNC_EXPORT eap_network_id_selector_c * eap_network_id_selector_c::copy() const
       
   124 {
       
   125 	eap_network_id_selector_c * const new_selector
       
   126 		= new eap_network_id_selector_c(m_am_tools, this);
       
   127 	
       
   128 	return new_selector;
       
   129 }
       
   130 
       
   131 //--------------------------------------------------
       
   132 
       
   133 
       
   134 
       
   135 // End.