eapol/eapol_framework/eapol_common/type/aka/core/eap_type_aka.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 41 %
    19 * %version: 31.1.4 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
   381 }
   381 }
   382 
   382 
   383 //-----------------------------------------------
   383 //-----------------------------------------------
   384 
   384 
   385 //
   385 //
   386 EAP_FUNC_EXPORT void eap_type_aka_c::initialize_state(
   386 void eap_type_aka_c::initialize_state(
   387 				const eap_type_aka_state_variable_e state,
   387 				const eap_type_aka_state_variable_e state,
   388 				const bool must_be_initiator,
   388 				const bool must_be_initiator,
   389 				const bool must_be_responder,
   389 				const bool must_be_responder,
   390 				const aka_subtype_e type0,
   390 				const aka_subtype_e type0,
   391 				const aka_subtype_e type1,
   391 				const aka_subtype_e type1,
   948 
   948 
   949 	u16_t padding_zero_count = 0u;
   949 	u16_t padding_zero_count = 0u;
   950 	// Add padding zero octets
   950 	// Add padding zero octets
   951 	if ((data_length % 4u) != 0)
   951 	if ((data_length % 4u) != 0)
   952 	{
   952 	{
   953 		padding_zero_count = static_cast<u16_t>(4u - (data_length % 4u));
   953 		padding_zero_count = 4u - (data_length % 4u);
   954 	}
   954 	}
   955 
   955 
   956 	if (RES->get_data_length()+padding_zero_count
   956 	if (RES->get_data_length()+padding_zero_count
   957 		> aka_payload_AT_header_c::get_max_payload_data_length())
   957 		> aka_payload_AT_header_c::get_max_payload_data_length())
   958 	{
   958 	{
   975 	{
   975 	{
   976 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   976 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   977 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   977 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   978 	}
   978 	}
   979 
   979 
   980 	gp_data.reset_header(static_cast<u16_t>(data_length + padding_zero_count));
   980 	gp_data.reset_header(data_length+padding_zero_count);
   981 
   981 
   982 	{
   982 	{
   983 		u8_t *payload_buffer = gp_data.get_data(data_length+padding_zero_count);
   983 		u8_t *payload_buffer = gp_data.get_data(data_length+padding_zero_count);
   984 
   984 
   985 		if (payload_buffer == 0)
   985 		if (payload_buffer == 0)
  1004 
  1004 
  1005 	// Note the reserved field includes the actual length of RES in bits in network order.
  1005 	// Note the reserved field includes the actual length of RES in bits in network order.
  1006 	// It is always multiple of 8 bits.
  1006 	// It is always multiple of 8 bits.
  1007 	gp_data.set_reserved(static_cast<u16_t>(data_length*8ul));
  1007 	gp_data.set_reserved(static_cast<u16_t>(data_length*8ul));
  1008 
  1008 
  1009 	gp_data.set_data_length(static_cast<u16_t>(data_length + padding_zero_count));
  1009 	gp_data.set_data_length(data_length+padding_zero_count);
  1010 
  1010 
  1011 	status = eap_status_ok;
  1011 	status = eap_status_ok;
  1012 
  1012 
  1013 
  1013 
  1014 	gp_data.set_current_payload(data_payload_type);
  1014 	gp_data.set_current_payload(data_payload_type);
  2034 			current_payload,
  2034 			current_payload,
  2035 			payload->get_payload_AT_string(),
  2035 			payload->get_payload_AT_string(),
  2036 			payload->get_payload_length(),
  2036 			payload->get_payload_length(),
  2037 			payload->get_reserved()));
  2037 			payload->get_reserved()));
  2038 
  2038 
  2039 		status = p_aka_payloads->get_counter_too_small()->set_buffer(
  2039 		status = p_aka_payloads->get_COUNTER_TOO_SMALL()->set_buffer(
  2040 			payload, 0, 0u, false, false);
  2040 			payload, 0, 0u, false, false);
  2041 
  2041 
  2042 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2042 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2043 		return EAP_STATUS_RETURN(m_am_tools, status);
  2043 		return EAP_STATUS_RETURN(m_am_tools, status);
  2044 	}
  2044 	}
  2898 	return EAP_STATUS_RETURN(m_am_tools, status);
  2898 	return EAP_STATUS_RETURN(m_am_tools, status);
  2899 }
  2899 }
  2900 
  2900 
  2901 
  2901 
  2902 //--------------------------------------------------
  2902 //--------------------------------------------------
       
  2903 
       
  2904 #if defined(USE_EAP_TRACE)
  2903 
  2905 
  2904 // 
  2906 // 
  2905 EAP_FUNC_EXPORT void eap_type_aka_c::packet_trace(
  2907 EAP_FUNC_EXPORT void eap_type_aka_c::packet_trace(
  2906 	eap_const_string prefix,
  2908 	eap_const_string prefix,
  2907 	const eap_am_network_id_c * const /* receive_network_id */,
  2909 	const eap_am_network_id_c * const /* receive_network_id */,
  3006 	}
  3008 	}
  3007 
  3009 
  3008 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3010 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3009 }
  3011 }
  3010 
  3012 
  3011 
  3013 #endif //#if defined(USE_EAP_TRACE)
  3012 
  3014 
  3013 //--------------------------------------------------
  3015 //--------------------------------------------------
  3014 
  3016 
  3015 // 
  3017 // 
  3016 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_c::get_nai_realm()
  3018 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_c::get_nai_realm()
  5644 		}
  5646 		}
  5645 	}
  5647 	}
  5646 
  5648 
  5647 	//----------------------------------------------------------
  5649 	//----------------------------------------------------------
  5648 
  5650 
       
  5651 #if defined(USE_EAP_EXPANDED_TYPES)
  5649 	{
  5652 	{
  5650 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
  5653 		eap_variable_data_c use_eap_expanded_type(m_am_tools);
  5651 
  5654 
  5652 		eap_status_e status = read_configure(
  5655 		eap_status_e status = read_configure(
  5653 			cf_str_EAP_AKA_use_eap_expanded_type.get_field(),
  5656 			cf_str_EAP_AKA_use_eap_expanded_type.get_field(),
  5677 					m_use_eap_expanded_type = false;
  5680 					m_use_eap_expanded_type = false;
  5678 				}
  5681 				}
  5679 			}
  5682 			}
  5680 		}
  5683 		}
  5681 	}
  5684 	}
       
  5685 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
  5682 
  5686 
  5683 	//----------------------------------------------------------
  5687 	//----------------------------------------------------------
  5684 
  5688 
  5685 	{
  5689 	{
  5686 		(void) read_configure(
  5690 		(void) read_configure(
  5950 
  5954 
  5951 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5955 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5952 	return EAP_STATUS_RETURN(m_am_tools, status);
  5956 	return EAP_STATUS_RETURN(m_am_tools, status);
  5953 }
  5957 }
  5954 
  5958 
       
  5959 //--------------------------------------------------
       
  5960 
       
  5961 //
       
  5962 EAP_FUNC_EXPORT eap_status_e eap_type_aka_c::cancel_all_timers()
       
  5963 {
       
  5964 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5965 
       
  5966 	EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true);
       
  5967 
       
  5968 	const eap_status_e status = get_type_partner()->cancel_all_timers();
       
  5969 
       
  5970 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5971 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  5972 }
       
  5973 
       
  5974 //--------------------------------------------------
  5955 //--------------------------------------------------
  5975 //--------------------------------------------------
  5956 
  5976 
  5957 EAP_FUNC_EXPORT const eap_type_aka_state_variable_parameters_c * eap_type_aka_c::get_state_variable()
  5977 EAP_FUNC_EXPORT const eap_type_aka_state_variable_parameters_c * eap_type_aka_c::get_state_variable()
  5958 {
  5978 {
  5959 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5979 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);