eapol/eapol_framework/eapol_common/type/tls_peap/tls/src/tls_peap_tlv_header.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: %
    19 * %version: 8 %
    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
   237 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   237 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   238 	
   238 	
   239 	EAP_ASSERT(flag_tlv_type_data != 0);
   239 	EAP_ASSERT(flag_tlv_type_data != 0);
   240 	
   240 	
   241 	flag_tlv_type_data[0] = static_cast<u8_t>(
   241 	flag_tlv_type_data[0] = static_cast<u8_t>(
   242 		(flag_tlv_type_data[0] & (m_flag_mask_mandatory_tlv|m_flag_mask_reserved))
   242 		flag_tlv_type_data[0] & (m_flag_mask_mandatory_tlv|m_flag_mask_reserved)
   243 		| (((type & 0xff00) >> 8) & ~(m_flag_mask_mandatory_tlv|m_flag_mask_reserved)));
   243 		| ((type & 0xff00) >> 8) & ~(m_flag_mask_mandatory_tlv|m_flag_mask_reserved));
   244 
       
   245 	flag_tlv_type_data[1] = static_cast<u8_t>(type & 0x00ff);
   244 	flag_tlv_type_data[1] = static_cast<u8_t>(type & 0x00ff);
   246 }
   245 }
   247 
   246 
   248 /**
   247 /**
   249  * This function sets the TLV reserved flag.
   248  * This function sets the TLV reserved flag.
   253 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   252 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   254 	EAP_ASSERT(flag_tlv_type_data != 0);
   253 	EAP_ASSERT(flag_tlv_type_data != 0);
   255 	
   254 	
   256 	if (reserved == true)
   255 	if (reserved == true)
   257 	{
   256 	{
   258 		flag_tlv_type_data[0] = static_cast<u8_t>(flag_tlv_type_data[0] | m_flag_mask_reserved);
   257 		flag_tlv_type_data[0] |= m_flag_mask_reserved;
   259 	}
   258 	}
   260 	else
   259 	else
   261 	{
   260 	{
   262 		flag_tlv_type_data[0] = static_cast<u8_t>(flag_tlv_type_data[0] & ~m_flag_mask_reserved);
   261 		flag_tlv_type_data[0] &= ~m_flag_mask_reserved;
   263 	}
   262 	}
   264 }
   263 }
   265 
   264 
   266 /**
   265 /**
   267  * This function sets the TLV manadtory flag.
   266  * This function sets the TLV manadtory flag.
   271 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   270 	u8_t * const flag_tlv_type_data = get_header_offset(m_flags_and_tlv_type_offset, sizeof(u16_t));
   272 	EAP_ASSERT(flag_tlv_type_data != 0);
   271 	EAP_ASSERT(flag_tlv_type_data != 0);
   273 	
   272 	
   274 	if (mandatory_when_true == true)
   273 	if (mandatory_when_true == true)
   275 	{
   274 	{
   276 		flag_tlv_type_data[0] = static_cast<u8_t>(flag_tlv_type_data[0] | m_flag_mask_mandatory_tlv);
   275 		flag_tlv_type_data[0] |= m_flag_mask_mandatory_tlv;
   277 	}
   276 	}
   278 	else
   277 	else
   279 	{
   278 	{
   280 		flag_tlv_type_data[0] = static_cast<u8_t>(flag_tlv_type_data[0] & ~m_flag_mask_mandatory_tlv);
   279 		flag_tlv_type_data[0] &= ~m_flag_mask_mandatory_tlv;
   281 	}
   280 	}
   282 }
   281 }
   283 
   282 
   284 /**
   283 /**
   285  * This function sets the TLV data length.
   284  * This function sets the TLV data length.