software/drivers/sd8887/src/wlan/mlan/mlan_join.c
/**
 *  @brief This function updates RSN IE in the association request.
 *
 *  @param pmpriv       A pointer to mlan_private structure
 *
 *  @param ptlv_rsn_ie       A pointer to rsn_ie TLV
 */
@brief This function updates RSN IE in the association request.
@param pmpriv       A pointer to mlan_private structure

@param ptlv_rsn_ie       A pointer to rsn_ie TLV
@brief This function updates RSN IE in the association request . @param pmpriv A pointer to mlan_private structure @param ptlv_rsn_ie A pointer to rsn_ie TLV
int
wlan_update_rsn_ie(mlan_private *pmpriv, MrvlIEtypes_RsnParamSet_t *ptlv_rsn_ie)
{
	t_u16 *prsn_cap;
	t_u16 *ptr;
	t_u16 *akm_suite_count_ptr;
	t_u16 pmf_mask = 0x00;
	t_u8 *temp;
	t_u16 pairwise_cipher_count = 0;
	t_u16 akm_suite_count = 0;
	t_u16 temp_akm_suite_count = 0;
	int found = 0;
	t_u8 sha_256_oui[4] = { 0x00, 0x0f, 0xac, 0x06 };
	mlan_adapter *pmadapter = pmpriv->adapter;
	int ap_mfpc = 0, ap_mfpr = 0, ret = MLAN_STATUS_SUCCESS;
	pmf_mask =
		(((pmpriv->pmfcfg.mfpc << MFPC_BIT) | (pmpriv->pmfcfg.
						       mfpr << MFPR_BIT)) |
		 (~PMF_MASK));
	ptr = (t_u16 *)(ptlv_rsn_ie->rsn_ie + sizeof(t_u16) + 4 * sizeof(t_u8));
	pairwise_cipher_count = wlan_le16_to_cpu(*ptr);
	ptr = (t_u16 *)(ptlv_rsn_ie->rsn_ie + sizeof(t_u16) + 4 * sizeof(t_u8)
			+ sizeof(t_u16) +
			pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN);
	temp_akm_suite_count = wlan_le16_to_cpu(*ptr);
	akm_suite_count = wlan_le16_to_cpu(*ptr);
	akm_suite_count_ptr = ptr;
	temp = ptlv_rsn_ie->rsn_ie + sizeof(t_u16) + 4 * sizeof(t_u8)
		+ sizeof(t_u16) + pairwise_cipher_count
		* PAIRWISE_CIPHER_SUITE_LEN + sizeof(t_u16);
	if (temp_akm_suite_count > 1) {
		while (temp_akm_suite_count) {
			if (!memcmp
			    (pmadapter, temp, sha_256_oui, AKM_SUITE_LEN)) {
				found = 1;
				break;
			}
			temp += AKM_SUITE_LEN;
			temp_akm_suite_count--;
		}
		if (found) {
			memcpy(pmadapter,
			       ptlv_rsn_ie->rsn_ie + (sizeof(t_u16) +
						      4 * sizeof(t_u8)
						      + sizeof(t_u16) +
						      pairwise_cipher_count *
						      PAIRWISE_CIPHER_SUITE_LEN
						      + sizeof(t_u16)),
			       sha_256_oui, AKM_SUITE_LEN);
			memmove(pmadapter,
				ptlv_rsn_ie->rsn_ie + (sizeof(t_u16) +
						       4 * sizeof(t_u8)
						       + sizeof(t_u16) +
						       pairwise_cipher_count *
						       PAIRWISE_CIPHER_SUITE_LEN
						       + sizeof(t_u16) +
						       AKM_SUITE_LEN),
				ptlv_rsn_ie->rsn_ie + (sizeof(t_u16) +
						       4 * sizeof(t_u8) +
						       sizeof(t_u16) +
						       pairwise_cipher_count *
						       PAIRWISE_CIPHER_SUITE_LEN
						       + sizeof(t_u16) +
						       akm_suite_count *
						       AKM_SUITE_LEN),
				ptlv_rsn_ie->header.len - (sizeof(t_u16) +
							   4 * sizeof(t_u8) +
							   sizeof(t_u16) +
							   pairwise_cipher_count
							   *
							   PAIRWISE_CIPHER_SUITE_LEN
							   + sizeof(t_u16) +
							   akm_suite_count *
							   AKM_SUITE_LEN));
			ptlv_rsn_ie->header.len =
				ptlv_rsn_ie->header.len - (akm_suite_count -
							   1) * AKM_SUITE_LEN;
			akm_suite_count = 1;
			*akm_suite_count_ptr = akm_suite_count;
		}
	}
	ptr = (t_u16 *)(ptlv_rsn_ie->rsn_ie + sizeof(t_u16) + 4 * sizeof(t_u8)
			+ sizeof(t_u16) +
			pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN +
			sizeof(t_u16) + akm_suite_count * AKM_SUITE_LEN);
	prsn_cap = ptr;
	ap_mfpc = ((*prsn_cap & (0x1 << MFPC_BIT)) == (0x1 << MFPC_BIT));
	ap_mfpr = ((*prsn_cap & (0x1 << MFPR_BIT)) == (0x1 << MFPR_BIT));
	if ((!ap_mfpc && !ap_mfpr && pmpriv->pmfcfg.mfpr)
	    || ((!ap_mfpc) && ap_mfpr)
	    || (ap_mfpc && ap_mfpr && (!pmpriv->pmfcfg.mfpc))
		) {
		PRINTM(MERROR,
		       "Mismatch in PMF config of STA and AP, can't associate to AP\n");
		return MLAN_STATUS_FAILURE;
	}
	if ((pmpriv->pmfcfg.mfpr && pmpriv->pmfcfg.mfpc) || pmpriv->pmfcfg.mfpc) {
		*prsn_cap |= PMF_MASK;
		*prsn_cap &= pmf_mask;
	}
	return ret;
}
int wlan_update_rsn_ie ( mlan_private * pmpriv , MrvlIEtypes_RsnParamSet_t * ptlv_rsn_ie ) { t_u16 * prsn_cap ; t_u16 * ptr ; t_u16 * akm_suite_count_ptr ; t_u16 pmf_mask = 0x00 ; t_u8 * temp ; t_u16 pairwise_cipher_count = 0 ; t_u16 akm_suite_count = 0 ; t_u16 temp_akm_suite_count = 0 ; int found = 0 ; t_u8 sha_256_oui [ 4 ] = { 0x00 , 0x0f , 0xac , 0x06 } ; mlan_adapter * pmadapter = pmpriv -> adapter ; int ap_mfpc = 0 , ap_mfpr = 0 , ret = MLAN_STATUS_SUCCESS ; pmf_mask = ( ( ( pmpriv -> pmfcfg . mfpc << MFPC_BIT ) | ( pmpriv -> pmfcfg . mfpr << MFPR_BIT ) ) | ( ~ PMF_MASK ) ) ; ptr = ( t_u16 * ) ( ptlv_rsn_ie -> rsn_ie + sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) ) ; pairwise_cipher_count = wlan_le16_to_cpu ( * ptr ) ; ptr = ( t_u16 * ) ( ptlv_rsn_ie -> rsn_ie + sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN ) ; temp_akm_suite_count = wlan_le16_to_cpu ( * ptr ) ; akm_suite_count = wlan_le16_to_cpu ( * ptr ) ; akm_suite_count_ptr = ptr ; temp = ptlv_rsn_ie -> rsn_ie + sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) ; if ( temp_akm_suite_count > 1 ) { while ( temp_akm_suite_count ) { if ( ! memcmp ( pmadapter , temp , sha_256_oui , AKM_SUITE_LEN ) ) { found = 1 ; break ; } temp += AKM_SUITE_LEN ; temp_akm_suite_count -- ; } if ( found ) { memcpy ( pmadapter , ptlv_rsn_ie -> rsn_ie + ( sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) ) , sha_256_oui , AKM_SUITE_LEN ) ; memmove ( pmadapter , ptlv_rsn_ie -> rsn_ie + ( sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) + AKM_SUITE_LEN ) , ptlv_rsn_ie -> rsn_ie + ( sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) + akm_suite_count * AKM_SUITE_LEN ) , ptlv_rsn_ie -> header . len - ( sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) + akm_suite_count * AKM_SUITE_LEN ) ) ; ptlv_rsn_ie -> header . len = ptlv_rsn_ie -> header . len - ( akm_suite_count - 1 ) * AKM_SUITE_LEN ; akm_suite_count = 1 ; * akm_suite_count_ptr = akm_suite_count ; } } ptr = ( t_u16 * ) ( ptlv_rsn_ie -> rsn_ie + sizeof ( t_u16 ) + 4 * sizeof ( t_u8 ) + sizeof ( t_u16 ) + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN + sizeof ( t_u16 ) + akm_suite_count * AKM_SUITE_LEN ) ; prsn_cap = ptr ; ap_mfpc = ( ( * prsn_cap & ( 0x1 << MFPC_BIT ) ) == ( 0x1 << MFPC_BIT ) ) ; ap_mfpr = ( ( * prsn_cap & ( 0x1 << MFPR_BIT ) ) == ( 0x1 << MFPR_BIT ) ) ; if ( ( ! ap_mfpc && ! ap_mfpr && pmpriv -> pmfcfg . mfpr ) || ( ( ! ap_mfpc ) && ap_mfpr ) || ( ap_mfpc && ap_mfpr && ( ! pmpriv -> pmfcfg . mfpc ) ) ) { PRINTM ( MERROR , " \n " ) ; return MLAN_STATUS_FAILURE ; } if ( ( pmpriv -> pmfcfg . mfpr && pmpriv -> pmfcfg . mfpc ) || pmpriv -> pmfcfg . mfpc ) { * prsn_cap |= PMF_MASK ; * prsn_cap &= pmf_mask ; } return ret ; }
@brief This function updates RSN IE in the association request.
@brief This function updates RSN IE in the association request .
/* prsn_cap = prsn_ie->rsn_ie + 2 bytes version + 4 bytes group_cipher_suite +
	 *            2 bytes pairwise_cipher_count + pairwise_cipher_count * PAIRWISE_CIPHER_SUITE_LEN +
	 *            2 bytes akm_suite_count + akm_suite_count * AKM_SUITE_LEN
	 */ /* Save pointer to akm_suite_count in RSN IE to update it later */ /* ptr now points to the 1st AKM suite */ /* Copy SHA256 as AKM suite */ /* Shift remaining bytes of RSN IE after this */ /* Update akm suite count */