eapol/eapol_framework/eapol_common/type/diameter/src/eap_diameter_avp_code.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 573 
       
    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 
       
    29 #include "eap_diameter_avp_code.h"
       
    30 
       
    31 //--------------------------------------------------
       
    32 
       
    33 EAP_FUNC_EXPORT eap_diameter_avp_code_c::~eap_diameter_avp_code_c()
       
    34 {
       
    35 }
       
    36 
       
    37 //--------------------------------------------------
       
    38 
       
    39 EAP_FUNC_EXPORT eap_diameter_avp_code_c::eap_diameter_avp_code_c()
       
    40 {
       
    41 	m_vendor_id = eap_diameter_vendor_id_of_ietf;
       
    42 	m_vendor_code = static_cast<u32_t>(eap_diameter_avp_code_none);
       
    43 }
       
    44 
       
    45 //--------------------------------------------------
       
    46 
       
    47 EAP_FUNC_EXPORT eap_diameter_avp_code_c::eap_diameter_avp_code_c(
       
    48 	const eap_diameter_vendor_id_e vendor_id,
       
    49 	const u32_t vendor_type)
       
    50 {
       
    51 	m_vendor_id = vendor_id;
       
    52 	m_vendor_code = vendor_type;
       
    53 }
       
    54 
       
    55 //--------------------------------------------------
       
    56 
       
    57 EAP_FUNC_EXPORT eap_diameter_avp_code_c::eap_diameter_avp_code_c(
       
    58 	const eap_diameter_avp_code_of_ietf_e type)
       
    59 {
       
    60 	m_vendor_id = eap_diameter_vendor_id_of_ietf;
       
    61 	m_vendor_code = static_cast<u32_t>(type);
       
    62 }
       
    63 
       
    64 //--------------------------------------------------
       
    65 
       
    66 EAP_FUNC_EXPORT bool eap_diameter_avp_code_c::is_ietf_code(const eap_diameter_avp_code_c avp_code)
       
    67 {
       
    68 	return (avp_code.get_vendor_id() == eap_diameter_vendor_id_of_ietf);
       
    69 }
       
    70 
       
    71 //--------------------------------------------------
       
    72 
       
    73 EAP_FUNC_EXPORT eap_status_e eap_diameter_avp_code_c::get_code_data(
       
    74 	abs_eap_am_tools_c * const am_tools,
       
    75 	eap_diameter_avp_code_of_ietf_e * const type)
       
    76 {
       
    77 	if (type == 0)
       
    78 	{
       
    79 		EAP_UNREFERENCED_PARAMETER(am_tools);
       
    80 		return EAP_STATUS_RETURN(am_tools, eap_status_illegal_parameter);
       
    81 	}
       
    82 
       
    83 	if (m_vendor_id == eap_diameter_vendor_id_of_ietf)
       
    84 	{
       
    85 		*type = static_cast<eap_diameter_avp_code_of_ietf_e>(m_vendor_code);
       
    86 	}
       
    87 	else 
       
    88 	{
       
    89 		// This is EAP type of other vendor than IETF.
       
    90 		// This cannot be denoted in eap_diameter_avp_code_of_ietf_e.
       
    91 		*type = static_cast<eap_diameter_avp_code_of_ietf_e>(eap_diameter_avp_code_none);
       
    92 	}
       
    93 
       
    94 	return EAP_STATUS_RETURN(am_tools, eap_status_ok);
       
    95 }
       
    96 
       
    97 //--------------------------------------------------
       
    98 
       
    99 EAP_FUNC_EXPORT eap_status_e eap_diameter_avp_code_c::get_code_data(
       
   100 	abs_eap_am_tools_c * const am_tools,
       
   101 	eap_diameter_avp_code_c * const type)
       
   102 {
       
   103 	if (type == 0)
       
   104 	{
       
   105 		EAP_UNREFERENCED_PARAMETER(am_tools);
       
   106 		return EAP_STATUS_RETURN(am_tools, eap_status_illegal_parameter);
       
   107 	}
       
   108 
       
   109 	*type = *this;
       
   110 
       
   111 	return EAP_STATUS_RETURN(am_tools, eap_status_ok);
       
   112 }
       
   113 
       
   114 //--------------------------------------------------
       
   115 
       
   116 EAP_FUNC_EXPORT void eap_diameter_avp_code_c::set_code_values(
       
   117 	const eap_diameter_vendor_id_e vendor_id,
       
   118 	const u32_t vendor_type)
       
   119 {
       
   120 	m_vendor_id = vendor_id;
       
   121 	m_vendor_code = vendor_type;
       
   122 }
       
   123 
       
   124 //--------------------------------------------------
       
   125 
       
   126 EAP_FUNC_EXPORT eap_diameter_vendor_id_e eap_diameter_avp_code_c::get_vendor_id() const
       
   127 {
       
   128 	return m_vendor_id;
       
   129 }
       
   130 
       
   131 //--------------------------------------------------
       
   132 
       
   133 EAP_FUNC_EXPORT u32_t eap_diameter_avp_code_c::get_vendor_code() const
       
   134 {
       
   135 	return m_vendor_code;
       
   136 }
       
   137 
       
   138 //--------------------------------------------------
       
   139 
       
   140 EAP_FUNC_EXPORT bool eap_diameter_avp_code_c::operator == (const eap_diameter_avp_code_of_ietf_e right_type_value) const
       
   141 {
       
   142 	if (m_vendor_id != eap_diameter_vendor_id_of_ietf)
       
   143 	{
       
   144 		return false;
       
   145 	}
       
   146 	else if (m_vendor_code != static_cast<u32_t>(right_type_value))
       
   147 	{
       
   148 		return false;
       
   149 	}
       
   150 	else
       
   151 	{
       
   152 		return true;
       
   153 	}
       
   154 }
       
   155 
       
   156 //--------------------------------------------------
       
   157 
       
   158 EAP_FUNC_EXPORT bool eap_diameter_avp_code_c::operator != (const eap_diameter_avp_code_of_ietf_e right_type_value) const
       
   159 {
       
   160 	return !(*this == right_type_value);
       
   161 }
       
   162 
       
   163 //--------------------------------------------------
       
   164 
       
   165 EAP_FUNC_EXPORT bool eap_diameter_avp_code_c::operator == (const eap_diameter_avp_code_c &right_type_value) const
       
   166 {
       
   167 	if (m_vendor_id != right_type_value.get_vendor_id())
       
   168 	{
       
   169 		return false;
       
   170 	}
       
   171 	else if (m_vendor_code != right_type_value.get_vendor_code())
       
   172 	{
       
   173 		return false;
       
   174 	}
       
   175 	else
       
   176 	{
       
   177 		return true;
       
   178 	}
       
   179 }
       
   180 
       
   181 //--------------------------------------------------
       
   182 
       
   183 EAP_FUNC_EXPORT bool eap_diameter_avp_code_c::operator != (const eap_diameter_avp_code_c &right_type_value) const
       
   184 {
       
   185 	return !(*this == right_type_value);
       
   186 }
       
   187 
       
   188 //--------------------------------------------------
       
   189 
       
   190 EAP_FUNC_EXPORT eap_diameter_avp_code_c &eap_diameter_avp_code_c::operator = (const eap_diameter_avp_code_of_ietf_e right_type_value)
       
   191 {
       
   192 	m_vendor_id = eap_diameter_vendor_id_of_ietf; ///< Here we use only 24 least significant bits.
       
   193 	m_vendor_code = static_cast<u32_t>(right_type_value);
       
   194 
       
   195 	return *this;
       
   196 }
       
   197 
       
   198 //--------------------------------------------------
       
   199 
       
   200 EAP_FUNC_EXPORT eap_diameter_avp_code_c &eap_diameter_avp_code_c::operator = (const eap_diameter_avp_code_c &right_type_value)
       
   201 {
       
   202 	m_vendor_id = right_type_value.get_vendor_id(); ///< Here we use only 24 least significant bits.
       
   203 	m_vendor_code = right_type_value.get_vendor_code();
       
   204 
       
   205 	return *this;
       
   206 }
       
   207 
       
   208 //--------------------------------------------------
       
   209 
       
   210 EAP_FUNC_EXPORT eap_diameter_avp_code_c *eap_diameter_avp_code_c::operator & ()
       
   211 {
       
   212 	return this;
       
   213 }
       
   214 
       
   215 //--------------------------------------------------
       
   216 
       
   217 EAP_FUNC_EXPORT const eap_diameter_avp_code_c *eap_diameter_avp_code_c::operator & () const
       
   218 {
       
   219 	return this;
       
   220 }
       
   221 
       
   222 //--------------------------------------------------
       
   223 //--------------------------------------------------
       
   224 //--------------------------------------------------
       
   225 
       
   226 EAP_FUNC_EXPORT const eap_diameter_avp_code_c &eap_static_diameter_vendor_code_c::get_code() const
       
   227 {
       
   228 	return *reinterpret_cast<const eap_diameter_avp_code_c *>(this);
       
   229 }
       
   230 
       
   231 //--------------------------------------------------
       
   232 //--------------------------------------------------
       
   233 //--------------------------------------------------
       
   234 
       
   235 EAP_C_FUNC_EXPORT u32_t convert_eap_diameter_avp_code_to_u32_t(eap_diameter_avp_code_c code)
       
   236 {
       
   237 	// NOTE, this returns only 8 least significant bits of vendor type.
       
   238 	return static_cast<u32_t>(code.get_vendor_id() << sizeof(u8_t)*8ul
       
   239 							  | (0xff & code.get_vendor_code()));
       
   240 }
       
   241 
       
   242 EAP_C_FUNC_EXPORT u64_t convert_eap_diameter_avp_code_to_u64_t(eap_diameter_avp_code_c code)
       
   243 {
       
   244 	return static_cast<u64_t>(code.get_vendor_id()) << sizeof(u32_t)*8ul
       
   245 		| static_cast<u64_t>(code.get_vendor_code());
       
   246 }
       
   247 
       
   248 //--------------------------------------------------
       
   249 //--------------------------------------------------
       
   250 //--------------------------------------------------
       
   251 
       
   252 
       
   253 
       
   254 // End.