eapol/eapol_framework/eapol_common/type/eap_type_all.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 75 
       
    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_am_memory.h"
       
    30 #include "eap_type_all.h"
       
    31 
       
    32 #if defined(USE_EAP_TYPE_GSMSIM)
       
    33 	#include "eap_type_gsmsim.h"
       
    34 	#include "eap_am_type_gsmsim.h"
       
    35 #endif
       
    36 #if defined(USE_AKA_EAP_TYPE)
       
    37 	#include "eap_type_aka.h"
       
    38 #endif
       
    39 #if defined(USE_MSCHAPV2_EAP_TYPE)
       
    40 	#include "eap_type_mschapv2.h"
       
    41 #endif
       
    42 #if defined(USE_SECURID_EAP_TYPE)
       
    43 	#include "eap_type_securid.h"
       
    44 #endif
       
    45 #if defined(USE_LEAP_EAP_TYPE)
       
    46 	#include "eap_type_leap.h"
       
    47 #endif
       
    48 #if defined(USE_TLS_EAP_TYPE) || defined(USE_PEAP_EAP_TYPE)
       
    49 	#include "eap_type_tls_peap.h"
       
    50 	#include "tls_base_record.h"
       
    51 	#include "tls_record.h"
       
    52 	#include "tls_application_eap_core.h"
       
    53 	#include "eap_am_type_tls_peap.h"
       
    54 	#include "tls_am_services.h"
       
    55 	#include "eap_core.h"
       
    56 #endif
       
    57 #if defined(USE_FAST_EAP_TYPE)
       
    58 	#include "eap_type_tls_peap.h"
       
    59 	#include "tls_base_record.h"
       
    60 	#include "tls_record.h"
       
    61 	#include "tls_application_eap_fast.h"
       
    62 	#include "eap_am_type_tls_peap.h"
       
    63 	#include "tls_am_services.h"
       
    64 	#include "eap_core.h"
       
    65 #endif
       
    66 #if defined(USE_SAESIM_EAP_TYPE)
       
    67 	#include "eap_type_saesim_core.h"
       
    68 #endif
       
    69 #if defined(USE_DUMMY_SIM_EAP_TYPE)
       
    70 	#include "eap_type_dummy_sim.h"
       
    71 #endif
       
    72 #if defined(USE_EAP_SIMPLE_CONFIG)
       
    73 	#include "simple_config_am_services.h"
       
    74 	#include "eap_am_type_simple_config.h"
       
    75 	#include "simple_config_base_record.h"
       
    76 	#include "simple_config_record.h"
       
    77 	#include "eap_type_simple_config.h"
       
    78 #endif //#if defined(USE_EAP_SIMPLE_CONFIG)
       
    79 
       
    80 //--------------------------------------------------
       
    81 
       
    82 //
       
    83 EAP_C_FUNC_EXPORT eap_base_type_c * const new_eap_type(
       
    84 	abs_eap_am_tools_c * const tools,
       
    85 	abs_eap_base_type_c * const partner,
       
    86 	const eap_type_value_e eap_type,
       
    87 	const bool is_client_when_true,
       
    88 	const eap_am_network_id_c * const receive_network_id,
       
    89 	abs_eap_configuration_if_c * const configuration_if)
       
    90 {
       
    91 	EAP_TRACE_BEGIN(tools, TRACE_FLAGS_DEFAULT);
       
    92 	eap_base_type_c *type = 0;
       
    93 
       
    94 	if (tools == 0)
       
    95 	{
       
    96 		EAP_TRACE_ERROR(
       
    97 			tools,
       
    98 			TRACE_FLAGS_DEFAULT,
       
    99 			(EAPL("ERROR: new_eap_type(): parameter tools is NULL.\n")));
       
   100 		EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   101 		return 0;
       
   102 	}
       
   103 
       
   104 	if (partner == 0)
       
   105 	{
       
   106 		EAP_TRACE_ERROR(
       
   107 			tools,
       
   108 			TRACE_FLAGS_DEFAULT,
       
   109 			(EAPL("ERROR: new_eap_type(): parameter partner is NULL.\n")));
       
   110 		EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   111 		return 0;
       
   112 	}
       
   113 
       
   114 	if (receive_network_id == 0
       
   115 		|| receive_network_id->get_source() == 0
       
   116 		|| receive_network_id->get_destination() == 0)
       
   117 	{
       
   118 		EAP_TRACE_ERROR(
       
   119 			tools,
       
   120 			TRACE_FLAGS_DEFAULT,
       
   121 			(EAPL("ERROR: new_eap_type(): parameter receive_network_id is NULL.\n")));
       
   122 		EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   123 		EAP_ASSERT_ANYWAY_TOOLS(tools);
       
   124 		return 0;
       
   125 	}
       
   126 
       
   127 #if defined(USE_EAP_TYPE_GSMSIM)
       
   128 	if (eap_type == eap_type_gsmsim)
       
   129 	{
       
   130 		eap_am_type_gsmsim_c * am_type_gsmsim = ::new_eap_am_type_gsmsim(
       
   131 			tools,
       
   132 			partner,
       
   133 			is_client_when_true,
       
   134 			receive_network_id); // Note this function is defined in the platform AM DLL.
       
   135 		if (am_type_gsmsim == 0
       
   136 			|| am_type_gsmsim->get_is_valid() == false)
       
   137 		{
       
   138 			EAP_TRACE_ERROR(
       
   139 				tools,
       
   140 				TRACE_FLAGS_DEFAULT,
       
   141 				(EAPL("ERROR: new_eap_type(): failed.\n")));
       
   142 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   143 			return 0;
       
   144 		}
       
   145 
       
   146 		type = new eap_type_gsmsim_c(
       
   147 			tools,
       
   148 			partner,
       
   149 			am_type_gsmsim,
       
   150 			true,
       
   151 			is_client_when_true,
       
   152 			receive_network_id);
       
   153 	}
       
   154 	else
       
   155 #endif //#if defined(USE_EAP_TYPE_GSMSIM)
       
   156 #if defined(USE_AKA_EAP_TYPE)
       
   157 	if (eap_type == eap_type_aka)
       
   158 	{
       
   159 		eap_am_type_aka_c * am_type_aka = ::new_eap_am_type_aka(
       
   160 			tools,
       
   161 			partner,
       
   162 			is_client_when_true,
       
   163 			receive_network_id); // Note this function is defined in the platform AM DLL.
       
   164 		if (am_type_aka == 0
       
   165 			|| am_type_aka->get_is_valid() == false)
       
   166 		{
       
   167 			delete am_type_aka;
       
   168 			EAP_TRACE_ERROR(
       
   169 				tools,
       
   170 				TRACE_FLAGS_DEFAULT,
       
   171 				(EAPL("ERROR: new_eap_type(): failed.\n")));
       
   172 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   173 			return 0;
       
   174 		}
       
   175 
       
   176 		type = new eap_type_aka_c(
       
   177 			tools,
       
   178 			partner,
       
   179 			am_type_aka,
       
   180 			true,
       
   181 			is_client_when_true,
       
   182 			receive_network_id);
       
   183 	}
       
   184 	else
       
   185 #endif //#if defined(USE_AKA_EAP_TYPE)
       
   186 #if defined(USE_MSCHAPV2_EAP_TYPE)
       
   187 	if (eap_type == eap_type_mschapv2)
       
   188 	{
       
   189 		eap_am_type_mschapv2_c * am_type_mschapv2
       
   190 			= ::new_eap_am_type_mschapv2(
       
   191 				tools,
       
   192 				partner,
       
   193 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   194 		if (am_type_mschapv2 == 0
       
   195 			|| am_type_mschapv2->get_is_valid() == false)
       
   196 		{
       
   197 			delete am_type_mschapv2;
       
   198 			EAP_TRACE_ERROR(
       
   199 				tools,
       
   200 				TRACE_FLAGS_DEFAULT,
       
   201 				(EAPL("ERROR: new_eap_type(): failed.\n")));
       
   202 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   203 			return 0;
       
   204 		}
       
   205 
       
   206 		type = new eap_type_mschapv2_c(
       
   207 			tools,
       
   208 			partner,
       
   209 			am_type_mschapv2,
       
   210 			true,
       
   211 			is_client_when_true,
       
   212 			receive_network_id);
       
   213 	}
       
   214 	else
       
   215 #endif //#if defined(USE_MSCHAPV2_EAP_TYPE)
       
   216 #if defined(USE_SECURID_EAP_TYPE)
       
   217 	if (eap_type == eap_type_generic_token_card)
       
   218 	{
       
   219 		eap_am_type_securid_c * am_type_securid
       
   220 			= ::new_eap_am_type_securid(
       
   221 				tools,
       
   222 				partner,
       
   223 				eap_type,
       
   224 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   225 		if (am_type_securid == 0
       
   226 			|| am_type_securid->get_is_valid() == false)
       
   227 		{
       
   228 			delete am_type_securid;
       
   229 			EAP_TRACE_ERROR(
       
   230 				tools,
       
   231 				TRACE_FLAGS_DEFAULT,
       
   232 				(EAPL("ERROR: new_eap_type(): failed.\n")));
       
   233 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   234 			return 0;
       
   235 		}
       
   236 
       
   237 		type = new eap_type_securid_c(
       
   238 			tools,
       
   239 			partner,
       
   240 			am_type_securid,
       
   241 			true,
       
   242 			eap_type,
       
   243 			is_client_when_true,
       
   244 			receive_network_id);
       
   245 	}
       
   246 	else
       
   247 #endif //#if defined(USE_SECURID_EAP_TYPE)
       
   248 #if defined(USE_LEAP_EAP_TYPE)
       
   249 	if (eap_type == eap_type_leap)
       
   250 	{
       
   251 		eap_am_type_leap_c * am_type_leap
       
   252 			= ::new_eap_am_type_leap(
       
   253 				tools,
       
   254 				partner,
       
   255 				is_client_when_true,
       
   256 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   257 		if (am_type_leap == 0
       
   258 			|| am_type_leap->get_is_valid() == false)
       
   259 		{
       
   260 			EAP_TRACE_ERROR(
       
   261 				tools,
       
   262 				TRACE_FLAGS_DEFAULT,
       
   263 				(EAPL("ERROR: new_eap_type(): failed.\n")));
       
   264 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   265 			return 0;
       
   266 		}
       
   267 
       
   268 		type = new eap_type_leap_c(
       
   269 			tools,
       
   270 			partner,
       
   271 			am_type_leap,
       
   272 			true,
       
   273 			is_client_when_true,
       
   274 			receive_network_id);
       
   275 	}
       
   276 	else
       
   277 #endif //#if defined(USE_LEAP_EAP_TYPE)
       
   278 #if defined(USE_TLS_EAP_TYPE)
       
   279 	if (eap_type == eap_type_tls)
       
   280 	{
       
   281 		eap_am_type_tls_peap_c * am_type_tls_peap
       
   282 			= ::new_eap_am_type_tls_peap(
       
   283 				tools,
       
   284 				partner,
       
   285 				eap_type,
       
   286 				is_client_when_true,
       
   287 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   288 		if (am_type_tls_peap == 0
       
   289 			|| am_type_tls_peap->get_is_valid() == false)
       
   290 		{
       
   291 			EAP_TRACE_ERROR(
       
   292 				tools,
       
   293 				TRACE_FLAGS_DEFAULT,
       
   294 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   295 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   296 			return 0;
       
   297 		}
       
   298 
       
   299 		tls_base_record_c * const tls_record
       
   300 			= new tls_record_c(
       
   301 				tools,
       
   302 				am_type_tls_peap,
       
   303 				false,
       
   304 				0,
       
   305 				false,
       
   306 				is_client_when_true,
       
   307 				eap_type,
       
   308 				receive_network_id);
       
   309 		if (tls_record == 0
       
   310 			|| tls_record->get_is_valid() == false)
       
   311 		{
       
   312 			EAP_TRACE_ERROR(
       
   313 				tools,
       
   314 				TRACE_FLAGS_DEFAULT,
       
   315 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   316 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   317 			return 0;
       
   318 		}
       
   319 
       
   320 		type = new eap_type_tls_peap_c(
       
   321 			tools,
       
   322 			partner,
       
   323 			am_type_tls_peap,
       
   324 			true,
       
   325 			tls_record,
       
   326 			true,
       
   327 			is_client_when_true,
       
   328 			eap_type,
       
   329 			receive_network_id);
       
   330 	}
       
   331 	else
       
   332 #endif //#if defined(USE_TLS_EAP_TYPE)
       
   333 #if defined(USE_PEAP_EAP_TYPE)
       
   334 	if (eap_type == eap_type_peap)
       
   335 	{
       
   336 		eap_am_type_tls_peap_c * am_type_tls_peap
       
   337 			= ::new_eap_am_type_tls_peap(
       
   338 				tools,
       
   339 				partner,
       
   340 				eap_type,
       
   341 				is_client_when_true,
       
   342 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   343 		if (am_type_tls_peap == 0
       
   344 			|| am_type_tls_peap->get_is_valid() == false)
       
   345 		{
       
   346 			EAP_TRACE_ERROR(
       
   347 				tools,
       
   348 				TRACE_FLAGS_DEFAULT,
       
   349 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   350 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   351 			return 0;
       
   352 		}
       
   353 
       
   354 		eap_core_c * const eap_core
       
   355 			= new eap_core_c(
       
   356 				tools,
       
   357 				0,
       
   358 				is_client_when_true,
       
   359 				receive_network_id,
       
   360 				true);
       
   361 		if (eap_core == 0
       
   362 			|| eap_core->get_is_valid() == false)
       
   363 		{
       
   364 			EAP_TRACE_ERROR(
       
   365 				tools,
       
   366 				TRACE_FLAGS_DEFAULT,
       
   367 				(EAPL("ERROR: new eap_core_c(): failed.\n")));
       
   368 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   369 			return 0;
       
   370 		}
       
   371 
       
   372 		tls_base_application_c * const application
       
   373 			= new tls_application_eap_core_c(
       
   374 				tools,
       
   375 				eap_core,
       
   376 				true,
       
   377 				is_client_when_true,
       
   378 				eap_type,
       
   379 				receive_network_id);
       
   380 		if (application == 0
       
   381 			|| application->get_is_valid() == false)
       
   382 		{
       
   383 			EAP_TRACE_ERROR(
       
   384 				tools,
       
   385 				TRACE_FLAGS_DEFAULT,
       
   386 				(EAPL("ERROR: new tls_application_eap_core_c(): failed.\n")));
       
   387 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   388 			return 0;
       
   389 		}
       
   390 
       
   391 		tls_base_record_c * const tls_record
       
   392 			= new tls_record_c(
       
   393 				tools,
       
   394 				am_type_tls_peap,
       
   395 				false,
       
   396 				application,
       
   397 				true,
       
   398 				is_client_when_true,
       
   399 				eap_type,
       
   400 				receive_network_id);
       
   401 		if (tls_record == 0
       
   402 			|| tls_record->get_is_valid() == false)
       
   403 		{
       
   404 			EAP_TRACE_ERROR(
       
   405 				tools,
       
   406 				TRACE_FLAGS_DEFAULT,
       
   407 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   408 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   409 			return 0;
       
   410 		}
       
   411 
       
   412 		type = new eap_type_tls_peap_c(
       
   413 			tools,
       
   414 			partner,
       
   415 			am_type_tls_peap,
       
   416 			true,
       
   417 			tls_record,
       
   418 			true,
       
   419 			is_client_when_true,
       
   420 			eap_type,
       
   421 			receive_network_id);
       
   422 	}
       
   423 	else
       
   424 #endif //#if defined(USE_PEAP_EAP_TYPE)
       
   425 #if defined(USE_TTLS_EAP_TYPE)
       
   426 	if (eap_type == eap_type_ttls)
       
   427 	{
       
   428 		eap_am_type_tls_peap_c * am_type_tls_ttls
       
   429 			= ::new_eap_am_type_tls_peap(
       
   430 				tools,
       
   431 				partner,
       
   432 				eap_type,
       
   433 				is_client_when_true,
       
   434 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   435 		if (am_type_tls_ttls == 0
       
   436 			|| am_type_tls_ttls->get_is_valid() == false)
       
   437 		{
       
   438 			EAP_TRACE_ERROR(
       
   439 				tools,
       
   440 				TRACE_FLAGS_DEFAULT,
       
   441 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   442 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   443 			return 0;
       
   444 		}
       
   445 
       
   446 		eap_core_c * const eap_core
       
   447 			= new eap_core_c(
       
   448 				tools,
       
   449 				0,
       
   450 				is_client_when_true,
       
   451 				receive_network_id,
       
   452 				true);
       
   453 		if (eap_core == 0
       
   454 			|| eap_core->get_is_valid() == false)
       
   455 		{
       
   456 			EAP_TRACE_ERROR(
       
   457 				tools,
       
   458 				TRACE_FLAGS_DEFAULT,
       
   459 				(EAPL("ERROR: new eap_core_c(): failed.\n")));
       
   460 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   461 			return 0;
       
   462 		}
       
   463 
       
   464 		tls_base_application_c * const application
       
   465 			= new tls_application_eap_core_c(
       
   466 				tools,
       
   467 				eap_core,
       
   468 				true,
       
   469 				is_client_when_true,
       
   470 				eap_type,
       
   471 				receive_network_id);
       
   472 		if (application == 0
       
   473 			|| application->get_is_valid() == false)
       
   474 		{
       
   475 			EAP_TRACE_ERROR(
       
   476 				tools,
       
   477 				TRACE_FLAGS_DEFAULT,
       
   478 				(EAPL("ERROR: new tls_application_eap_core_c(): failed.\n")));
       
   479 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   480 			return 0;
       
   481 		}
       
   482 
       
   483 		tls_base_record_c * const tls_record
       
   484 			= new tls_record_c(
       
   485 				tools,
       
   486 				am_type_tls_ttls,
       
   487 				false,
       
   488 				application,
       
   489 				true,
       
   490 				is_client_when_true,
       
   491 				eap_type,
       
   492 				receive_network_id);
       
   493 		if (tls_record == 0
       
   494 			|| tls_record->get_is_valid() == false)
       
   495 		{
       
   496 			EAP_TRACE_ERROR(
       
   497 				tools,
       
   498 				TRACE_FLAGS_DEFAULT,
       
   499 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   500 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   501 			return 0;
       
   502 		}
       
   503 
       
   504 		type = new eap_type_tls_peap_c(
       
   505 			tools,
       
   506 			partner,
       
   507 			am_type_tls_ttls,
       
   508 			true,
       
   509 			tls_record,
       
   510 			true,
       
   511 			is_client_when_true,
       
   512 			eap_type,
       
   513 			receive_network_id);
       
   514 	}
       
   515 	else
       
   516 #endif //#if defined(USE_TTLS_EAP_TYPE)
       
   517 #if defined(USE_SAESIM_EAP_TYPE)
       
   518 	if (eap_type == eap_type_saesim)
       
   519 	{
       
   520 		type = new eap_type_saesim_core_c(tools, partner, is_client_when_true);
       
   521 	}
       
   522 	else
       
   523 #endif
       
   524 #if defined(USE_DUMMY_SIM_EAP_TYPE)
       
   525 	if (eap_type == eap_type_sim)
       
   526 	{
       
   527 		type = new eap_type_dummy_sim_c(tools, partner, is_client_when_true);
       
   528 	}
       
   529 	else
       
   530 #endif
       
   531 #if defined(USE_EAP_EXPANDED_TYPES)
       
   532 #if defined(USE_EAP_SIMPLE_CONFIG)
       
   533 	if (eap_type == eap_expanded_type_simple_config.get_type())
       
   534 	{
       
   535 		eap_am_type_simple_config_c * am_type_simple_config
       
   536 			= ::new_eap_am_type_simple_config(
       
   537 				tools,
       
   538 				partner,
       
   539 				eap_type,
       
   540 				is_client_when_true,
       
   541 				receive_network_id,
       
   542 				configuration_if); // Note this function is defined in the platform AM DLL.
       
   543 		if (am_type_simple_config == 0
       
   544 			|| am_type_simple_config->get_is_valid() == false)
       
   545 		{
       
   546 			EAP_TRACE_ERROR(
       
   547 				tools,
       
   548 				TRACE_FLAGS_DEFAULT,
       
   549 				(EAPL("ERROR: new_eap_am_type_simple_config(): failed.\n")));
       
   550 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   551 			return 0;
       
   552 		}
       
   553 
       
   554 		simple_config_base_record_c * const simple_config_record
       
   555 			= new simple_config_record_c(
       
   556 				tools,
       
   557 				am_type_simple_config,
       
   558 				false,
       
   559 				is_client_when_true,
       
   560 				receive_network_id);
       
   561 		if (simple_config_record == 0
       
   562 			|| simple_config_record->get_is_valid() == false)
       
   563 		{
       
   564 			EAP_TRACE_ERROR(
       
   565 				tools,
       
   566 				TRACE_FLAGS_DEFAULT,
       
   567 				(EAPL("ERROR: simple_config_record_c(): failed.\n")));
       
   568 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   569 			return 0;
       
   570 		}
       
   571 
       
   572 		type = new eap_type_simple_config_c(
       
   573 			tools,
       
   574 			partner,
       
   575 			am_type_simple_config,
       
   576 			true,
       
   577 			simple_config_record,
       
   578 			true,
       
   579 			is_client_when_true,
       
   580 			eap_type,
       
   581 			receive_network_id);
       
   582 	}
       
   583 	else
       
   584 #endif //#if defined(USE_EAP_SIMPLE_CONFIG)
       
   585 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
   586 #if defined(USE_FAST_EAP_TYPE)
       
   587 	if (eap_type == eap_type_fast)
       
   588 	{
       
   589 		eap_am_type_tls_peap_c * am_type_tls_peap
       
   590 			= ::new_eap_am_type_tls_peap(
       
   591 				tools,
       
   592 				partner,
       
   593 				eap_type,
       
   594 				is_client_when_true,
       
   595 				receive_network_id); // Note this function is defined in the platform AM DLL.
       
   596 		if (am_type_tls_peap == 0
       
   597 			|| am_type_tls_peap->get_is_valid() == false)
       
   598 		{
       
   599 			EAP_TRACE_ERROR(
       
   600 				tools,
       
   601 				TRACE_FLAGS_DEFAULT,
       
   602 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   603 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   604 			return 0;
       
   605 		}
       
   606 
       
   607 		eap_core_c * const eap_core
       
   608 			= new eap_core_c(
       
   609 				tools,
       
   610 				0,
       
   611 				is_client_when_true,
       
   612 				receive_network_id,
       
   613 				true);
       
   614 		if (eap_core == 0
       
   615 			|| eap_core->get_is_valid() == false)
       
   616 		{
       
   617 			EAP_TRACE_ERROR(
       
   618 				tools,
       
   619 				TRACE_FLAGS_DEFAULT,
       
   620 				(EAPL("ERROR: new eap_core_c(): failed.\n")));
       
   621 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   622 			return 0;
       
   623 		}
       
   624 
       
   625 		tls_base_application_c * const application
       
   626 			= new tls_application_eap_fast_c(
       
   627 				tools,
       
   628 				eap_core,
       
   629 				true,
       
   630 				is_client_when_true,
       
   631 				eap_type,
       
   632 				receive_network_id,
       
   633 				am_type_tls_peap);
       
   634 		if (application == 0
       
   635 			|| application->get_is_valid() == false)
       
   636 		{
       
   637 			EAP_TRACE_ERROR(
       
   638 				tools,
       
   639 				TRACE_FLAGS_DEFAULT,
       
   640 				(EAPL("ERROR: new tls_application_eap_core_c(): failed.\n")));
       
   641 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   642 			return 0;
       
   643 		}
       
   644 
       
   645 		tls_base_record_c * const tls_record
       
   646 			= new tls_record_c(
       
   647 				tools,
       
   648 				am_type_tls_peap,
       
   649 				false,
       
   650 				application,
       
   651 				true,
       
   652 				is_client_when_true,
       
   653 				eap_type,
       
   654 				receive_network_id);
       
   655 		if (tls_record == 0
       
   656 			|| tls_record->get_is_valid() == false)
       
   657 		{
       
   658 			EAP_TRACE_ERROR(
       
   659 				tools,
       
   660 				TRACE_FLAGS_DEFAULT,
       
   661 				(EAPL("ERROR: new_eap_am_type_tls_peap(): failed.\n")));
       
   662 			EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   663 			return 0;
       
   664 		}
       
   665 
       
   666 		type = new eap_type_tls_peap_c(
       
   667 			tools,
       
   668 			partner,
       
   669 			am_type_tls_peap,
       
   670 			true,
       
   671 			tls_record,
       
   672 			true,
       
   673 			is_client_when_true,
       
   674 			eap_type,
       
   675 			receive_network_id);
       
   676 	}
       
   677 	else
       
   678 #endif //#if defined(USE_FAST_EAP_TYPE)
       
   679 	{
       
   680 		EAP_TRACE_ERROR(
       
   681 			tools,
       
   682 			TRACE_FLAGS_DEFAULT,
       
   683 			(EAPL("ERROR: new_eap_type(): EAP-type=0x%08x not supported in this module.\n"),
       
   684 			convert_eap_type_to_u32_t(eap_type)));
       
   685 	}
       
   686 	EAP_TRACE_END(tools, TRACE_FLAGS_DEFAULT);
       
   687 	return type;
       
   688 }
       
   689 
       
   690 //--------------------------------------------------
       
   691 
       
   692 
       
   693 
       
   694 // End.