소스 검색

qcacld-3.0: Cleanup get IE pointer from out, eid or ext_id APIs

Cleanup duplicate APIs for get ie pointer from EID or OUI or EXT_ID
and use wlan_utils exposed by qcacmn.

Change-Id: Iacbf041c9c49b2aedeffecba3427e9334cb70dcc
CRs-Fixed: 2105377
Naveen Rawat 7 년 전
부모
커밋
08db88f684

+ 5 - 7
core/hdd/inc/wlan_hdd_wext.h

@@ -283,22 +283,23 @@ struct ccp_freq_chan_map {
 #define WLAN_KEEP_ALIVE_NULL_PKT              1
 
 #define wlan_hdd_get_wps_ie_ptr(ie, ie_len) \
-	wlan_hdd_get_vendor_oui_ie_ptr(WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE, \
+	wlan_get_vendor_ie_ptr_from_oui(WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE, \
 	ie, ie_len)
 
 #define wlan_hdd_get_p2p_ie_ptr(ie, ie_len) \
-	wlan_hdd_get_vendor_oui_ie_ptr(P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE, \
+	wlan_get_vendor_ie_ptr_from_oui(P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE, \
 	ie, ie_len)
 
 #ifdef WLAN_FEATURE_WFD
 #define wlan_hdd_get_wfd_ie_ptr(ie, ie_len) \
-	wlan_hdd_get_vendor_oui_ie_ptr(WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE, \
+	wlan_get_vendor_ie_ptr_from_oui(WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE, \
 	ie, ie_len)
 #endif
 
 #define wlan_hdd_get_mbo_ie_ptr(ie, ie_len) \
-	wlan_hdd_get_vendor_oui_ie_ptr(MBO_OUI_TYPE, MBO_OUI_TYPE_SIZE, \
+	wlan_get_vendor_ie_ptr_from_oui(MBO_OUI_TYPE, MBO_OUI_TYPE_SIZE, \
 	ie, ie_len)
+
 /*
  * Defines for fw_test command
  */
@@ -380,9 +381,6 @@ int wlan_hdd_get_linkspeed_for_peermac(struct hdd_adapter *adapter,
 				       uint32_t *linkspeed);
 void hdd_clear_roam_profile_ie(struct hdd_adapter *pAdapter);
 
-uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
-					uint8_t *ie, int ie_len);
-
 QDF_STATUS wlan_hdd_get_class_astats(struct hdd_adapter *pAdapter);
 
 QDF_STATUS wlan_hdd_get_station_stats(struct hdd_adapter *pAdapter);

+ 1 - 0
core/hdd/src/wlan_hdd_assoc.c

@@ -65,6 +65,7 @@
 #include <cdp_txrx_handle.h>
 #include "wlan_pmo_ucfg_api.h"
 #include "wlan_hdd_tsf.h"
+#include "wlan_utility.h"
 
 /* These are needed to recognize WPA and RSN suite types */
 #define HDD_WPA_OUI_SIZE 4

+ 10 - 35
core/hdd/src/wlan_hdd_cfg80211.c

@@ -12739,34 +12739,9 @@ void wlan_hdd_cfg80211_set_key_wapi(struct hdd_adapter *pAdapter, uint8_t key_in
 }
 #endif /* FEATURE_WLAN_WAPI */
 
-uint8_t *wlan_hdd_cfg80211_get_ie_ptr(const uint8_t *ies_ptr, int length,
-				      uint8_t eid)
-{
-	int left = length;
-	uint8_t *ptr = (uint8_t *)ies_ptr;
-	uint8_t elem_id, elem_len;
-
-	while (left >= 2) {
-		elem_id = ptr[0];
-		elem_len = ptr[1];
-		left -= 2;
-		if (elem_len > left) {
-			hdd_err("Invalid IEs eid: %d elem_len: %d left: %d",
-			       eid, elem_len, left);
-			return NULL;
-		}
-		if (elem_id == eid)
-			return ptr;
-
-		left -= elem_len;
-		ptr += (elem_len + 2);
-	}
-	return NULL;
-}
-
 bool wlan_hdd_is_ap_supports_immediate_power_save(uint8_t *ies, int length)
 {
-	uint8_t *vendor_ie;
+	const uint8_t *vendor_ie;
 
 	if (length < 2) {
 		hdd_debug("bss size is less than expected");
@@ -12776,7 +12751,7 @@ bool wlan_hdd_is_ap_supports_immediate_power_save(uint8_t *ies, int length)
 		hdd_debug("invalid IE pointer");
 		return true;
 	}
-	vendor_ie = wlan_hdd_get_vendor_oui_ie_ptr(VENDOR1_AP_OUI_TYPE,
+	vendor_ie = wlan_get_vendor_ie_ptr_from_oui(VENDOR1_AP_OUI_TYPE,
 				VENDOR1_AP_OUI_TYPE_SIZE, ies, length);
 	if (vendor_ie) {
 		hdd_debug("AP can't support immediate powersave. defer it");
@@ -16997,19 +16972,18 @@ static int wlan_hdd_cfg80211_set_privacy_ibss(struct hdd_adapter *pAdapter,
 	pHddStaCtx->ibss_enc_key_installed = 0;
 
 	if (params->ie_len && (NULL != params->ie)) {
-		if (wlan_hdd_cfg80211_get_ie_ptr(params->ie,
-					 params->ie_len, WLAN_EID_RSN)) {
+		if (wlan_get_ie_ptr_from_eid(WLAN_EID_RSN, params->ie,
+					     params->ie_len)) {
 			pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
 			encryptionType = eCSR_ENCRYPT_TYPE_AES;
 		} else if (hdd_is_wpaie_present(params->ie, params->ie_len)) {
 			tDot11fIEWPA dot11WPAIE;
 			tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
-			u8 *ie;
+			const u8 *ie;
 
 			memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
-			ie = wlan_hdd_cfg80211_get_ie_ptr(params->ie,
-							  params->ie_len,
-							  DOT11F_EID_WPA);
+			ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_WPA,
+						params->ie, params->ie_len);
 			if (NULL != ie) {
 				pWextState->wpaVersion =
 					IW_AUTH_WPA_VERSION_WPA;
@@ -17018,8 +16992,9 @@ static int wlan_hdd_cfg80211_set_privacy_ibss(struct hdd_adapter *pAdapter,
 				 * and four byte WiFi OUI
 				 */
 				dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
-						     &ie[2 + 4], ie[1] - 4,
-						     &dot11WPAIE, false);
+						     (uint8_t *)&ie[2 + 4],
+						     ie[1] - 4, &dot11WPAIE,
+						     false);
 				/*
 				 * Extract the multicast cipher, the
 				 * encType for unicast cipher for

+ 0 - 2
core/hdd/src/wlan_hdd_cfg80211.h

@@ -312,8 +312,6 @@ void *wlan_hdd_change_country_code_cb(void *pAdapter);
 void hdd_select_cbmode(struct hdd_adapter *pAdapter, uint8_t operationChannel,
 		       struct ch_params *ch_params);
 
-uint8_t *wlan_hdd_cfg80211_get_ie_ptr(const uint8_t *ies_ptr, int length,
-				      uint8_t eid);
 /**
  * wlan_hdd_is_ap_supports_immediate_power_save() - to find certain vendor APs
  *				which do not support immediate power-save.

+ 3 - 2
core/hdd/src/wlan_hdd_he.c

@@ -26,6 +26,7 @@
 #include "wlan_hdd_main.h"
 #include "wlan_hdd_he.h"
 #include "wma_he.h"
+#include "wlan_utility.h"
 
 /**
  * hdd_he_wni_cfg_to_string() - return string conversion of HE WNI CFG
@@ -244,9 +245,9 @@ void hdd_update_tgt_he_cap(struct hdd_context *hdd_ctx,
 
 void wlan_hdd_check_11ax_support(beacon_data_t *beacon, tsap_Config_t *config)
 {
-	uint8_t *ie;
+	const uint8_t *ie;
 
-	ie = wlan_hdd_get_vendor_oui_ie_ptr(HE_CAP_OUI_TYPE, HE_CAP_OUI_SIZE,
+	ie = wlan_get_vendor_ie_ptr_from_oui(HE_CAP_OUI_TYPE, HE_CAP_OUI_SIZE,
 					    beacon->tail, beacon->tail_len);
 	if (ie)
 		config->SapHw_mode = eCSR_DOT11_MODE_11ax;

+ 33 - 38
core/hdd/src/wlan_hdd_hostapd.c

@@ -85,6 +85,7 @@
 #include "wlan_hdd_he.h"
 #include "wlan_dfs_tgt_api.h"
 #include <wlan_reg_ucfg_api.h>
+#include "wlan_utility.h"
 
 #define    IS_UP(_dev) \
 	(((_dev)->flags & (IFF_RUNNING|IFF_UP)) == (IFF_RUNNING|IFF_UP))
@@ -6811,10 +6812,10 @@ static bool wlan_hdd_get_sap_obss(struct hdd_adapter *pHostapdAdapter)
 	tDot11fIEHTCaps dot11_ht_cap_ie = {0};
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(pHostapdAdapter);
 	beacon_data_t *beacon = pHostapdAdapter->sessionCtx.ap.beacon;
-	uint8_t *ie = NULL;
+	const uint8_t *ie = NULL;
 
-	ie = wlan_hdd_cfg80211_get_ie_ptr(beacon->tail, beacon->tail_len,
-						WLAN_EID_HT_CAPABILITY);
+	ie = wlan_get_ie_ptr_from_eid(WLAN_EID_HT_CAPABILITY,
+					beacon->tail, beacon->tail_len);
 	if (ie && ie[1]) {
 		qdf_mem_copy(ht_cap_ie, &ie[2], DOT11F_IE_HTCAPS_MAX_LEN);
 		dot11f_unpack_ie_ht_caps((tpAniSirGlobal)hdd_ctx->hHal,
@@ -7023,8 +7024,8 @@ int wlan_hdd_set_channel(struct wiphy *wiphy,
  *
  * Return: none
  */
-static void wlan_hdd_check_11gmode(u8 *pIe, u8 *require_ht, u8 *require_vht,
-				   u8 *pCheckRatesfor11g,
+static void wlan_hdd_check_11gmode(const u8 *pIe, u8 *require_ht,
+				   u8 *require_vht, u8 *pCheckRatesfor11g,
 				   eCsrPhyMode *pSapHw_mode)
 {
 	u8 i, num_rates = pIe[0];
@@ -7449,21 +7450,21 @@ static void wlan_hdd_set_sap_hwmode(struct hdd_adapter *pHostapdAdapter)
 		(struct ieee80211_mgmt *)pBeacon->head;
 	u8 checkRatesfor11g = true;
 	u8 require_ht = false, require_vht = false;
-	u8 *pIe = NULL;
+	const u8 *pIe = NULL;
 
 	pConfig->SapHw_mode = eCSR_DOT11_MODE_11b;
 
-	pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
-					   pBeacon->head_len,
-					   WLAN_EID_SUPP_RATES);
+	pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_HT_CAPABILITY,
+				       &pMgmt_frame->u.beacon.variable[0],
+				       pBeacon->head_len);
 	if (pIe != NULL) {
 		pIe += 1;
 		wlan_hdd_check_11gmode(pIe, &require_ht, &require_vht,
 			&checkRatesfor11g, &pConfig->SapHw_mode);
 	}
 
-	pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
-					   WLAN_EID_EXT_SUPP_RATES);
+	pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_EXT_SUPP_RATES,
+					pBeacon->tail, pBeacon->tail_len);
 	if (pIe != NULL) {
 		pIe += 1;
 		wlan_hdd_check_11gmode(pIe, &require_ht, &require_vht,
@@ -7473,18 +7474,16 @@ static void wlan_hdd_set_sap_hwmode(struct hdd_adapter *pHostapdAdapter)
 	if (pConfig->channel > 14)
 		pConfig->SapHw_mode = eCSR_DOT11_MODE_11a;
 
-	pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
-					   WLAN_EID_HT_CAPABILITY);
-
+	pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_HT_CAPABILITY,
+					pBeacon->tail, pBeacon->tail_len);
 	if (pIe) {
 		pConfig->SapHw_mode = eCSR_DOT11_MODE_11n;
 		if (require_ht)
 			pConfig->SapHw_mode = eCSR_DOT11_MODE_11n_ONLY;
 	}
 
-	pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
-					   WLAN_EID_VHT_CAPABILITY);
-
+	pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_VHT_CAPABILITY,
+					pBeacon->tail, pBeacon->tail_len);
 	if (pIe) {
 		pConfig->SapHw_mode = eCSR_DOT11_MODE_11ac;
 		if (require_vht)
@@ -7494,7 +7493,6 @@ static void wlan_hdd_set_sap_hwmode(struct hdd_adapter *pHostapdAdapter)
 	wlan_hdd_check_11ax_support(pBeacon, pConfig);
 
 	hdd_info("SAP hw_mode: %d", pConfig->SapHw_mode);
-
 }
 
 /**
@@ -7799,7 +7797,7 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 	tsap_Config_t *pConfig;
 	beacon_data_t *pBeacon = NULL;
 	struct ieee80211_mgmt *pMgmt_frame;
-	uint8_t *pIe = NULL;
+	const uint8_t *pIe = NULL;
 	uint16_t capab_info;
 	eCsrAuthType RSNAuthType;
 	eCsrEncryptionType RSNEncryptType;
@@ -7893,10 +7891,8 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 		pConfig->dtim_period);
 
 	if (pHostapdAdapter->device_mode == QDF_SAP_MODE) {
-		pIe =
-			wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail,
-						     pBeacon->tail_len,
-						     WLAN_EID_COUNTRY);
+		pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_COUNTRY,
+					pBeacon->tail, pBeacon->tail_len);
 		if (pIe) {
 			pConfig->ieee80211d = 1;
 			qdf_mem_copy(pConfig->countryCode, &pIe[2], 3);
@@ -8009,8 +8005,8 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 
 	pConfig->RSNWPAReqIELength = 0;
 	memset(&pConfig->RSNWPAReqIE[0], 0, sizeof(pConfig->RSNWPAReqIE));
-	pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
-					   WLAN_EID_RSN);
+	pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_RSN, pBeacon->tail,
+				       pBeacon->tail_len);
 	if (pIe && pIe[1]) {
 		pConfig->RSNWPAReqIELength = pIe[1] + 2;
 		if (pConfig->RSNWPAReqIELength < sizeof(pConfig->RSNWPAReqIE))
@@ -8045,7 +8041,7 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 		}
 	}
 
-	pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
+	pIe = wlan_get_vendor_ie_ptr_from_oui(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
 					     pBeacon->tail, pBeacon->tail_len);
 
 	if (pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) {
@@ -8146,10 +8142,9 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 		pConfig->cc_switch_mode = iniConfig->WlanMccToSccSwitchMode;
 #endif
 
-	pIe =
-		wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE,
-					       WPA_OUI_TYPE_SIZE, pBeacon->tail,
-					       pBeacon->tail_len);
+	pIe = wlan_get_vendor_ie_ptr_from_oui(BLACKLIST_OUI_TYPE,
+					      WPA_OUI_TYPE_SIZE, pBeacon->tail,
+					      pBeacon->tail_len);
 
 	/* pIe for black list is following form:
 	 * type    : 1 byte
@@ -8173,7 +8168,7 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 			acl_entry++;
 		}
 	}
-	pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE,
+	pIe = wlan_get_vendor_ie_ptr_from_oui(WHITELIST_OUI_TYPE,
 			WPA_OUI_TYPE_SIZE, pBeacon->tail,
 			pBeacon->tail_len);
 
@@ -8202,9 +8197,9 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 	}
 	if (!hdd_ctx->config->force_sap_acs &&
 	    !(ssid && (0 == qdf_mem_cmp(ssid, PRE_CAC_SSID, ssid_len)))) {
-		pIe = wlan_hdd_cfg80211_get_ie_ptr(
-				&pMgmt_frame->u.beacon.variable[0],
-				pBeacon->head_len, WLAN_EID_SUPP_RATES);
+		pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_SUPP_RATES,
+					&pMgmt_frame->u.beacon.variable[0],
+					pBeacon->head_len);
 
 		if (pIe != NULL) {
 			pIe++;
@@ -8219,9 +8214,9 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 				}
 			}
 		}
-		pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail,
-				pBeacon->tail_len,
-				WLAN_EID_EXT_SUPP_RATES);
+		pIe = wlan_get_ie_ptr_from_eid(WLAN_EID_EXT_SUPP_RATES,
+					       pBeacon->tail,
+					       pBeacon->tail_len);
 		if (pIe != NULL) {
 			pIe++;
 			pConfig->extended_rates.numRates = pIe[0];
@@ -8253,7 +8248,7 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *pHostapdAdapter,
 	 * Default: enable QOS for SAP unless WMM IE not present for 11bga
 	 */
 	sme_config->csrConfig.WMMSupportMode = eCsrRoamWmmAuto;
-	pIe = wlan_hdd_get_vendor_oui_ie_ptr(WMM_OUI_TYPE, WMM_OUI_TYPE_SIZE,
+	pIe = wlan_get_vendor_ie_ptr_from_oui(WMM_OUI_TYPE, WMM_OUI_TYPE_SIZE,
 					pBeacon->tail, pBeacon->tail_len);
 	if (!pIe && (pConfig->SapHw_mode == eCSR_DOT11_MODE_11a ||
 		pConfig->SapHw_mode == eCSR_DOT11_MODE_11g ||

+ 4 - 2
core/hdd/src/wlan_hdd_scan.c

@@ -54,6 +54,8 @@
 #include <qca_vendor.h>
 #include <wlan_cfg80211_scan.h>
 
+#include "wlan_utility.h"
+
 #define MAX_RATES                       12
 #define HDD_WAKE_LOCK_SCAN_DURATION (5 * 1000) /* in msec */
 
@@ -380,8 +382,8 @@ static int wlan_hdd_update_scan_ies(struct hdd_adapter *adapter,
 
 		switch (elem_id) {
 		case DOT11F_EID_EXTCAP:
-			if (!wlan_hdd_cfg80211_get_ie_ptr(scan_ie, *scan_ie_len,
-							DOT11F_EID_EXTCAP))
+			if (!wlan_get_ie_ptr_from_eid(DOT11F_EID_EXTCAP,
+						      scan_ie, *scan_ie_len))
 				add_ie = true;
 			break;
 		case IE_EID_VENDOR:

+ 0 - 43
core/hdd/src/wlan_hdd_wext.c

@@ -4221,49 +4221,6 @@ void hdd_clear_roam_profile_ie(struct hdd_adapter *pAdapter)
 	EXIT();
 }
 
-/**
- * wlan_hdd_get_vendor_oui_ie_ptr() - Find a vendor OUI
- * @oui: The OUI that is being searched for
- * @oui_size: The length of @oui
- * @ie: The set of IEs within which we're trying to find @oui
- * @ie_len: The length of @ie
- *
- * This function will scan the IEs contained within @ie looking for @oui.
- *
- * Return: Pointer to @oui embedded within @ie if it is present, NULL
- * if @oui is not present within @ie.
- */
-uint8_t *wlan_hdd_get_vendor_oui_ie_ptr(uint8_t *oui, uint8_t oui_size,
-					uint8_t *ie, int ie_len)
-{
-	int left = ie_len;
-	uint8_t *ptr = ie;
-	uint8_t elem_id, elem_len;
-	uint8_t eid = 0xDD;
-
-	if (NULL == ie || 0 == ie_len)
-		return NULL;
-
-	while (left >= 2) {
-		elem_id = ptr[0];
-		elem_len = ptr[1];
-		left -= 2;
-		if (elem_len > left) {
-			hdd_err("Invalid IEs eid: %d elem_len: %d left: %d",
-				eid, elem_len, left);
-			return NULL;
-		}
-		if ((elem_id == eid) && (elem_len >= oui_size)) {
-			if (memcmp(&ptr[2], oui, oui_size) == 0)
-				return ptr;
-		}
-
-		left -= elem_len;
-		ptr += (elem_len + 2);
-	}
-	return NULL;
-}
-
 /**
  * hdd_get_ldpc() - Get adapter LDPC
  * @adapter: adapter being queried

+ 0 - 46
core/mac/src/cfg/cfg_api.c

@@ -899,49 +899,3 @@ static void notify(tpAniSirGlobal pMac, uint16_t cfgId, uint32_t ntfMask)
 
 } /*** end notify() ***/
 
-/**
- * cfg_get_vendor_ie_ptr_from_oui() - returns IE pointer in IE buffer given its
- * OUI and OUI size
- * @mac_ctx:    mac context.
- * @oui:        OUI string.
- * @oui_size:   length of OUI string
- *              One can provide multiple line descriptions
- *              for arguments.
- * @ie:         ie buffer
- * @ie_len:     length of ie buffer
- *
- * This function parses the IE buffer and finds the given OUI and returns its
- * pointer
- *
- * Return: pointer of given OUI IE else NULL
- */
-uint8_t *cfg_get_vendor_ie_ptr_from_oui(tpAniSirGlobal mac_ctx,
-					uint8_t *oui,
-					uint8_t oui_size,
-					uint8_t *ie,
-					uint16_t ie_len)
-{
-	int32_t left = ie_len;
-	uint8_t *ptr = ie;
-	uint8_t elem_id, elem_len;
-
-	while (left >= 2) {
-		elem_id  = ptr[0];
-		elem_len = ptr[1];
-		left -= 2;
-		if (elem_len > left) {
-			pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
-				elem_id, elem_len, left);
-			return NULL;
-		}
-		if (SIR_MAC_EID_VENDOR == elem_id) {
-			if (memcmp(&ptr[2], oui, oui_size) == 0)
-				return ptr;
-		}
-
-		left -= elem_len;
-		ptr += (elem_len + 2);
-	}
-	return NULL;
-}
-

+ 0 - 6
core/mac/src/include/cfg_api.h

@@ -122,10 +122,4 @@ void cfg_cleanup(tpAniSirGlobal pMac);
 
 extern uint8_t *g_cfg_param_name[];
 
-uint8_t *cfg_get_vendor_ie_ptr_from_oui(tpAniSirGlobal mac_ctx,
-					uint8_t *oui,
-					uint8_t oui_size,
-					uint8_t *ie,
-					uint16_t ie_len);
-
 #endif /* __CFGAPI_H */

+ 2 - 1
core/mac/src/pe/lim/lim_assoc_utils.c

@@ -61,6 +61,7 @@
 #include "qdf_types.h"
 #include "wma_types.h"
 #include "lim_types.h"
+#include "wlan_utility.h"
 
 /**
  * lim_cmp_ssid() - utility function to compare SSIDs
@@ -2094,7 +2095,7 @@ lim_add_sta(tpAniSirGlobal mac_ctx,
 	tpSirAssocReq assoc_req;
 	uint8_t i, nw_type_11b = 0;
 	tLimIbssPeerNode *peer_node; /* for IBSS mode */
-	uint8_t *p2p_ie = NULL;
+	const uint8_t *p2p_ie = NULL;
 
 	sir_copy_mac_addr(sta_mac, session_entry->selfMacAddr);
 

+ 43 - 7
core/mac/src/pe/lim/lim_p2p.c

@@ -53,6 +53,7 @@
 #include "lim_session_utils.h"
 #include "wma_types.h"
 #include "lim_types.h"
+#include "wlan_utility.h"
 
 #define   PROBE_RSP_IE_OFFSET    36
 #define   BSSID_OFFSET           16
@@ -551,6 +552,41 @@ static inline void lim_check_rmf_and_set_protected(tpAniSirGlobal mac_ctx,
 }
 #endif
 
+/* function to parse IEs withing P2P IE */
+static const uint8_t *lim_parse_p2p_ie(const uint8_t *ie, int len, uint8_t eid)
+{
+	int left = len;
+	const uint8_t *ptr = ie;
+	uint8_t elem_id, size_of_len_field = 0;
+	uint16_t elem_len;
+
+	/* IE should be at least len(eid + len) = 3 */
+	while (left >= 3) {
+		elem_id = ptr[0];
+		if (elem_id == SIR_P2P_NOA_ATTR) {
+			elem_len = ((uint16_t) ptr[1]) | (ptr[2] << 8);
+			size_of_len_field = 2;
+		} else {
+			elem_len = ptr[1];
+			size_of_len_field = 1;
+		}
+
+		left -= (size_of_len_field + 1);
+		if (elem_len > left) {
+			pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
+				eid, elem_len, left);
+			return NULL;
+		}
+
+		if (elem_id == eid)
+			return ptr;
+
+		left -= elem_len;
+		ptr += (elem_len + (size_of_len_field + 1));
+	}
+	return NULL;
+}
+
 /**
  * lim_send_p2p_action_frame() - Process action frame request
  * @mac_ctx:  Pointer to mac context
@@ -575,7 +611,7 @@ void lim_send_p2p_action_frame(tpAniSirGlobal mac_ctx,
 	uint8_t orig_len = 0;
 	uint8_t *p2p_ie = NULL;
 	tpPESession session_entry = NULL;
-	uint8_t *presence_noa_attr = NULL;
+	const uint8_t *presence_noa_attr = NULL;
 	uint8_t *tmp_p2p_ie = NULL;
 	uint16_t remain_len = 0;
 	uint8_t sme_session_id = 0;
@@ -596,7 +632,7 @@ void lim_send_p2p_action_frame(tpAniSirGlobal mac_ctx,
 	if ((SIR_MAC_MGMT_FRAME == fc->type) &&
 		(SIR_MAC_MGMT_PROBE_RSP == fc->subType)) {
 		/* get proper offset for Probe RSP */
-		p2p_ie = limGetP2pIEPtr(mac_ctx,
+		p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx,
 				(uint8_t *) mb_msg->data +
 				PROBE_RSP_IE_OFFSET,
 				msg_len - PROBE_RSP_IE_OFFSET);
@@ -606,12 +642,12 @@ void lim_send_p2p_action_frame(tpAniSirGlobal mac_ctx,
 				msg_len - (p2p_ie -
 				(uint8_t *) mb_msg->data);
 			if (remain_len > 2) {
-				tmp_p2p_ie = limGetP2pIEPtr(mac_ctx,
+				tmp_p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx,
 					p2p_ie + SIR_MAC_MAX_IE_LENGTH + 2,
 					remain_len);
 			}
 			if (tmp_p2p_ie) {
-				p2p_ie = tmp_p2p_ie;
+				p2p_ie = (uint8_t *)tmp_p2p_ie;
 				tmp_p2p_ie = NULL;
 			} else {
 				break;
@@ -630,7 +666,7 @@ void lim_send_p2p_action_frame(tpAniSirGlobal mac_ctx,
 			action_hdr->OuiSubType)) {
 
 			/* In case of Presence RSP response */
-			p2p_ie = limGetP2pIEPtr(mac_ctx,
+			p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx,
 				(uint8_t *)mb_msg->data +
 				ACTION_OFFSET +
 				sizeof(tSirMacP2PActionFrameHdr),
@@ -639,9 +675,9 @@ void lim_send_p2p_action_frame(tpAniSirGlobal mac_ctx,
 			if (NULL != p2p_ie) {
 				/* extract the presence of NoA attribute inside
 				 * P2P IE */
-				presence_noa_attr =  lim_get_ie_ptr_new(mac_ctx,
+				presence_noa_attr =  lim_parse_p2p_ie(
 					p2p_ie + SIR_P2P_IE_HEADER_LEN,
-					p2p_ie[1], SIR_P2P_NOA_ATTR, TWO_BYTE);
+					p2p_ie[1], SIR_P2P_NOA_ATTR);
 			}
 		}
 	}

+ 8 - 6
core/mac/src/pe/lim/lim_process_assoc_req_frame.c

@@ -49,6 +49,7 @@
 
 #include "qdf_types.h"
 #include "cds_utils.h"
+#include "wlan_utility.h"
 
 /**
  * lim_convert_supported_channels - Parses channel support IE
@@ -745,7 +746,7 @@ static bool lim_chk_n_process_wpa_rsn_ie(tpAniSirGlobal mac_ctx,
 					 tpSirAssocReq assoc_req,
 					 uint8_t sub_type, bool *pmf_connection)
 {
-	uint8_t *wps_ie = NULL;
+	const uint8_t *wps_ie = NULL;
 	tDot11fIEWPA dot11f_ie_wpa;
 	tDot11fIERSN dot11f_ie_rsn;
 	tSirRetStatus status = eSIR_SUCCESS;
@@ -1837,9 +1838,10 @@ void lim_process_assoc_req_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 	if ((session->access_policy_vendor_ie) &&
 		(session->access_policy ==
 		LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
-		if (!cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
-			&session->access_policy_vendor_ie[2],
-			3, frm_body + LIM_ASSOC_REQ_IE_OFFSET, frame_len)) {
+		if (!wlan_get_vendor_ie_ptr_from_oui(
+				&session->access_policy_vendor_ie[2],
+				3, frm_body + LIM_ASSOC_REQ_IE_OFFSET,
+				 frame_len)) {
 			pe_err("Vendor ie not present and access policy is %x, Rejected association",
 				session->access_policy);
 			lim_send_assoc_rsp_mgmt_frame(mac_ctx,
@@ -2040,7 +2042,7 @@ error:
  */
 static void lim_fill_assoc_ind_wapi_info(tpAniSirGlobal mac_ctx,
 	tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
-	uint8_t *wpsie)
+	const uint8_t *wpsie)
 {
 	if (assoc_req->wapiPresent && (NULL == wpsie)) {
 		pe_debug("Received WAPI IE length in Assoc Req is %d",
@@ -2194,7 +2196,7 @@ void lim_send_mlm_assoc_ind(tpAniSirGlobal mac_ctx,
 	uint16_t temp, rsn_len;
 	uint32_t phy_mode;
 	uint8_t sub_type;
-	uint8_t *wpsie = NULL;
+	const uint8_t *wpsie = NULL;
 	uint8_t maxidx, i;
 	uint32_t tmp;
 

+ 2 - 1
core/mac/src/pe/lim/lim_process_probe_req_frame.c

@@ -48,6 +48,7 @@
 #include "parser_api.h"
 #include "lim_ft_defs.h"
 #include "lim_session.h"
+#include "wlan_utility.h"
 
 void
 
@@ -375,7 +376,7 @@ lim_process_probe_req_frame(tpAniSirGlobal mac_ctx, uint8_t *rx_pkt_info,
 		if ((session->access_policy_vendor_ie) &&
 			(session->access_policy ==
 			LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
-			if (!cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+			if (!wlan_get_vendor_ie_ptr_from_oui(
 				&session->access_policy_vendor_ie[2],
 				3, body_ptr, frame_len)) {
 				pe_warn("Vendor IE is not present and access policy is: %x dropping probe request",

+ 10 - 11
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -65,6 +65,7 @@
 #include <lim_ft.h>
 #include "cds_regdomain.h"
 #include "lim_process_fils.h"
+#include "wlan_utility.h"
 
 /*
  * This overhead is time for sending NOA start to host in case of GO/sending
@@ -1496,7 +1497,7 @@ __lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 	uint16_t sme_transaction_id = 0;
 	int8_t local_power_constraint = 0, reg_max = 0;
 	uint16_t ie_len;
-	uint8_t *vendor_ie;
+	const uint8_t *vendor_ie;
 	tSirBssDescription *bss_desc;
 	struct vdev_type_nss *vdev_type_nss;
 
@@ -1643,7 +1644,7 @@ __lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 		ie_len = (bss_desc->length + sizeof(bss_desc->length) -
 			 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
 
-		vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+		vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
 				SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
 				((uint8_t *)&bss_desc->ieFields), ie_len);
 
@@ -4742,7 +4743,7 @@ static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
 	struct set_ie_param *ie_params;
 	struct scheduler_msg msg = {0};
 	tSirRetStatus rc = eSIR_SUCCESS;
-	uint8_t *p_ie = NULL;
+	const uint8_t *p_ie = NULL;
 	tHtCaps *p_ht_cap;
 	int i;
 
@@ -4769,9 +4770,8 @@ static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
 				ie_params->ie_len);
 
 		if (NSS_1x1_MODE == i) {
-			p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
-					ie_params->ie_len,
-					DOT11F_EID_HTCAPS, ONE_BYTE);
+			p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
+					ie_params->ie_ptr, ie_params->ie_len);
 			if (NULL == p_ie) {
 				qdf_mem_free(ie_params->ie_ptr);
 				qdf_mem_free(ie_params);
@@ -4814,7 +4814,7 @@ static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
 	struct set_ie_param *ie_params;
 	struct scheduler_msg msg = {0};
 	tSirRetStatus rc = eSIR_SUCCESS;
-	uint8_t *p_ie = NULL;
+	const uint8_t *p_ie = NULL;
 	tSirMacVHTCapabilityInfo *vht_cap;
 	int i;
 	tSirVhtMcsInfo *vht_mcs;
@@ -4843,9 +4843,8 @@ static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
 				ie_params->ie_len);
 
 		if (NSS_1x1_MODE == i) {
-			p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
-					ie_params->ie_len,
-					DOT11F_EID_VHTCAPS, ONE_BYTE);
+			p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
+					ie_params->ie_ptr, ie_params->ie_len);
 			if (NULL == p_ie) {
 				qdf_mem_free(ie_params->ie_ptr);
 				qdf_mem_free(ie_params);
@@ -5552,7 +5551,7 @@ lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
 	 * 2. per spec, beacon oui ie might be set twice and original one
 	 * shall be updated.
 	 */
-	vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
+	vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
 			MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
 	if (vendor_ie) {
 		QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);

+ 8 - 9
core/mac/src/pe/lim/lim_prop_exts_utils.c

@@ -54,6 +54,7 @@
 #include "lim_ft_defs.h"
 #include "lim_session.h"
 #include "wma.h"
+#include "wlan_utility.h"
 
 #define LIM_GET_NOISE_MAX_TRY 5
 
@@ -159,14 +160,13 @@ static bool
 lim_check_vendor_ap_present(tpAniSirGlobal mac_ctx, uint8_t *ie,
 			    uint16_t ie_len)
 {
-	uint8_t *ptr = NULL;
+	const uint8_t *ptr = NULL;
 	uint8_t elem_len;
 	uint8_t elem_data[SIR_MAC_VENDOR_AP_2_DATA_LEN];
 
-	if (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
-					   SIR_MAC_VENDOR_AP_1_OUI,
-					   SIR_MAC_VENDOR_AP_1_OUI_LEN,
-					   ie, ie_len)) {
+	if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_VENDOR_AP_1_OUI,
+					    SIR_MAC_VENDOR_AP_1_OUI_LEN,
+					    ie, ie_len)) {
 		pe_debug("In lim_check_vendor_ap_present match Vendor AP 1");
 		QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
 				SIR_MAC_VENDOR_AP_1_OUI,
@@ -177,10 +177,9 @@ lim_check_vendor_ap_present(tpAniSirGlobal mac_ctx, uint8_t *ie,
 	/*
 	 * for SIR_MAC_VENDOR_AP_2_OUI check for Vendor IE Data also
 	 */
-	ptr = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
-					     SIR_MAC_VENDOR_AP_2_OUI,
-					     SIR_MAC_VENDOR_AP_2_OUI_LEN,
-					     ie, ie_len);
+	ptr = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_VENDOR_AP_2_OUI,
+					      SIR_MAC_VENDOR_AP_2_OUI_LEN,
+					      ie, ie_len);
 	if (!ptr)
 		return false;
 

+ 3 - 2
core/mac/src/pe/lim/lim_send_frames_host_roam.c

@@ -51,6 +51,7 @@
 #include "rrm_api.h"
 
 #include "wma_types.h"
+#include "wlan_utility.h"
 
 /**
  * lim_send_reassoc_req_with_ft_ies_mgmt_frame() - Send Reassoc Req with FTIEs.
@@ -81,7 +82,7 @@ void lim_send_reassoc_req_with_ft_ies_mgmt_frame(tpAniSirGlobal mac_ctx,
 	uint8_t *body;
 	uint16_t add_ie_len;
 	uint8_t *add_ie;
-	uint8_t *wps_ie = NULL;
+	const uint8_t *wps_ie = NULL;
 	uint8_t tx_flag = 0;
 	uint8_t sme_sessionid = 0;
 	bool vht_enabled = false;
@@ -551,7 +552,7 @@ void lim_send_reassoc_req_mgmt_frame(tpAniSirGlobal pMac,
 	QDF_STATUS qdf_status;
 	uint16_t nAddIELen;
 	uint8_t *pAddIE;
-	uint8_t *wpsIe = NULL;
+	const uint8_t *wpsIe = NULL;
 	uint8_t txFlag = 0;
 	uint8_t PowerCapsPopulated = false;
 	uint8_t smeSessionId = 0;

+ 6 - 7
core/mac/src/pe/lim/lim_send_management_frames.c

@@ -65,6 +65,7 @@
 #include <cdp_txrx_cmn.h>
 #include <cdp_txrx_peer_ops.h>
 #include "lim_process_fils.h"
+#include "wlan_utility.h"
 
 /**
  *
@@ -220,7 +221,7 @@ lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
 	QDF_STATUS qdf_status;
 	tpPESession pesession;
 	uint8_t sessionid;
-	uint8_t *p2pie = NULL;
+	const uint8_t *p2pie = NULL;
 	uint8_t txflag = 0;
 	uint8_t sme_sessionid = 0;
 	bool is_vht_enabled = false;
@@ -556,7 +557,7 @@ lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
 	uint32_t wps_ap = 0, tmp;
 	uint8_t tx_flag = 0;
 	uint8_t *add_ie = NULL;
-	uint8_t *p2p_ie = NULL;
+	const uint8_t *p2p_ie = NULL;
 	uint8_t noalen = 0;
 	uint8_t total_noalen = 0;
 	uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
@@ -1660,7 +1661,7 @@ lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
 	QDF_STATUS qdf_status;
 	uint16_t add_ie_len;
 	uint8_t *add_ie;
-	uint8_t *wps_ie = NULL;
+	const uint8_t *wps_ie = NULL;
 	uint8_t power_caps = false;
 	uint8_t tx_flag = 0;
 	uint8_t sme_sessionid = 0;
@@ -1942,11 +1943,9 @@ lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
 		if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
 			bcn_ie = pe_session->beacon + ie_offset;
 			bcn_ie_len = pe_session->bcnLen - ie_offset;
-			p_ext_cap = lim_get_ie_ptr_new(mac_ctx,
-							bcn_ie,
-							bcn_ie_len,
+			p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
 							DOT11F_EID_EXTCAP,
-							ONE_BYTE);
+							bcn_ie, bcn_ie_len);
 			lim_update_extcap_struct(mac_ctx, p_ext_cap,
 							&bcn_ext_cap);
 			lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,

+ 2 - 1
core/mac/src/pe/lim/lim_send_sme_rsp_messages.c

@@ -60,6 +60,7 @@
 #include "nan_datapath.h"
 #include "lim_assoc_utils.h"
 #include "wlan_reg_services_api.h"
+#include "wlan_utility.h"
 
 #ifdef CONVERGED_TDLS_ENABLE
 #include "wlan_tdls_tgt_api.h"
@@ -385,7 +386,7 @@ static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
 		bss_ie_len = lim_get_ielen_from_bss_description(
 				&join_reassoc_req->bssDescription);
 		bss_ies = &join_reassoc_req->bssDescription.ieFields;
-		is_vendor_ap_1_present = (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+		is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
 			SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
 			bss_ies, bss_ie_len) != NULL);
 

+ 14 - 46
core/mac/src/pe/lim/lim_utils.c

@@ -63,6 +63,7 @@
 #ifdef WLAN_FEATURE_11AX_BSS_COLOR
 #include "wma_he.h"
 #endif
+#include "wlan_utility.h"
 
 #ifdef WLAN_FEATURE_11W
 #include "wni_cfg.h"
@@ -5722,38 +5723,6 @@ void lim_diag_event_report(tpAniSirGlobal pMac, uint16_t eventType,
 
 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
 
-uint8_t *lim_get_ie_ptr_new(tpAniSirGlobal pMac, uint8_t *pIes, int length,
-				 uint8_t eid, eSizeOfLenField size_of_len_field)
-{
-	int left = length;
-	uint8_t *ptr = pIes;
-	uint8_t elem_id;
-	uint16_t elem_len;
-
-	while (left >= (size_of_len_field + 1)) {
-		elem_id = ptr[0];
-		if (size_of_len_field == TWO_BYTE) {
-			elem_len = ((uint16_t) ptr[1]) | (ptr[2] << 8);
-		} else {
-			elem_len = ptr[1];
-		}
-
-		left -= (size_of_len_field + 1);
-		if (elem_len > left) {
-			pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
-				eid, elem_len, left);
-			return NULL;
-		}
-		if (elem_id == eid) {
-			return ptr;
-		}
-
-		left -= elem_len;
-		ptr += (elem_len + (size_of_len_field + 1));
-	}
-	return NULL;
-}
-
 /* Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream */
 
 uint8_t lim_build_p2p_ie(tpAniSirGlobal pMac, uint8_t *ie, uint8_t *data,
@@ -6160,12 +6129,12 @@ lim_set_protected_bit(tpAniSirGlobal pMac,
 void lim_set_ht_caps(tpAniSirGlobal p_mac, tpPESession p_session_entry,
 		uint8_t *p_ie_start, uint32_t num_bytes)
 {
-	uint8_t *p_ie = NULL;
+	const uint8_t *p_ie = NULL;
 	tDot11fIEHTCaps dot11_ht_cap = {0,};
 
 	populate_dot11f_ht_caps(p_mac, p_session_entry, &dot11_ht_cap);
-	p_ie = lim_get_ie_ptr_new(p_mac, p_ie_start, num_bytes,
-			DOT11F_EID_HTCAPS, ONE_BYTE);
+	p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
+					p_ie_start, num_bytes);
 	pe_debug("p_ie: %p dot11_ht_cap.supportedMCSSet[0]: 0x%x",
 		p_ie, dot11_ht_cap.supportedMCSSet[0]);
 	if (p_ie) {
@@ -6235,13 +6204,12 @@ void lim_set_ht_caps(tpAniSirGlobal p_mac, tpPESession p_session_entry,
 void lim_set_vht_caps(tpAniSirGlobal p_mac, tpPESession p_session_entry,
 		      uint8_t *p_ie_start, uint32_t num_bytes)
 {
-	uint8_t              *p_ie = NULL;
+	const uint8_t       *p_ie = NULL;
 	tDot11fIEVHTCaps     dot11_vht_cap;
 
 	populate_dot11f_vht_caps(p_mac, p_session_entry, &dot11_vht_cap);
-	p_ie = lim_get_ie_ptr_new(p_mac, p_ie_start, num_bytes,
-				  DOT11F_EID_VHTCAPS, ONE_BYTE);
-
+	p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS, p_ie_start,
+					num_bytes);
 	if (p_ie) {
 		tSirMacVHTCapabilityInfo *vht_cap =
 					(tSirMacVHTCapabilityInfo *) &p_ie[2];
@@ -7394,12 +7362,12 @@ void lim_update_stads_he_caps(tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp,
 
 void lim_update_usr_he_cap(tpAniSirGlobal mac_ctx, tpPESession session)
 {
-	uint8_t *vendor_ie;
-	uint8_t *he_cap_data;
+	const uint8_t *vendor_ie;
+	const uint8_t *he_cap_data;
 	tSirAddIeParams *add_ie = &session->addIeParams;
 	tDot11fIEvendor_he_cap *he_cap = &session->he_config;
 
-	vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+	vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
 			HE_CAP_OUI_TYPE, HE_CAP_OUI_SIZE,
 			add_ie->probeRespBCNData_buff,
 			add_ie->probeRespBCNDataLen);
@@ -7427,12 +7395,12 @@ void lim_update_usr_he_cap(tpAniSirGlobal mac_ctx, tpPESession session)
 void lim_decide_he_op(tpAniSirGlobal mac_ctx, tpAddBssParams add_bss,
 		      tpPESession session)
 {
-	uint8_t *vendor_ie;
+	const uint8_t *vendor_ie;
 	uint32_t he_op;
 	tDot11fIEvendor_he_op *he_ops = &add_bss->he_op;
 	tSirAddIeParams *add_ie = &session->addIeParams;
 
-	vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+	vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
 			HE_OP_OUI_TYPE, HE_OP_OUI_SIZE,
 			add_ie->probeRespBCNData_buff,
 			add_ie->probeRespBCNDataLen);
@@ -7679,13 +7647,13 @@ void lim_update_chan_he_capable(tpAniSirGlobal mac, tpSwitchChannelParams chan)
 void lim_set_he_caps(tpAniSirGlobal mac, tpPESession session, uint8_t *ie_start,
 		     uint32_t num_bytes)
 {
-	uint8_t *ie = NULL;
+	const uint8_t *ie = NULL;
 	tDot11fIEvendor_he_cap dot11_cap;
 	struct he_capability_info *he_cap;
 
 	populate_dot11f_he_caps(mac, session, &dot11_cap);
 	lim_log_he_cap(mac, &dot11_cap);
-	ie = cfg_get_vendor_ie_ptr_from_oui(mac, HE_CAP_OUI_TYPE,
+	ie = wlan_get_vendor_ie_ptr_from_oui(HE_CAP_OUI_TYPE,
 			HE_CAP_OUI_SIZE, ie_start, num_bytes);
 
 	if (ie) {

+ 2 - 5
core/mac/src/pe/lim/lim_utils.h

@@ -482,15 +482,12 @@ tpPESession lim_is_ibss_session_active(tpAniSirGlobal pMac);
 tpPESession lim_is_ap_session_active(tpAniSirGlobal pMac);
 void lim_handle_heart_beat_failure_timeout(tpAniSirGlobal pMac);
 
-uint8_t *lim_get_ie_ptr_new(tpAniSirGlobal pMac, uint8_t *pIes, int length,
-		uint8_t eid, eSizeOfLenField size_of_len_field);
-
 #define limGetWscIEPtr(pMac, ie, ie_len) \
-	cfg_get_vendor_ie_ptr_from_oui(pMac, SIR_MAC_WSC_OUI, \
+	wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_WSC_OUI, \
 			SIR_MAC_WSC_OUI_SIZE, ie, ie_len)
 
 #define limGetP2pIEPtr(pMac, ie, ie_len) \
-	cfg_get_vendor_ie_ptr_from_oui(pMac, SIR_MAC_P2P_OUI, \
+	wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_P2P_OUI, \
 			SIR_MAC_P2P_OUI_SIZE, ie, ie_len)
 
 uint8_t lim_get_noa_attr_stream_in_mult_p2p_ies(tpAniSirGlobal pMac,

+ 2 - 1
core/mac/src/pe/sch/sch_beacon_gen.c

@@ -50,6 +50,7 @@
 #include "sch_api.h"
 
 #include "parser_api.h"
+#include "wlan_utility.h"
 
 
 const uint8_t p2p_oui[] = { 0x50, 0x6F, 0x9A, 0x9 };
@@ -114,7 +115,7 @@ sch_append_addn_ie(tpAniSirGlobal mac_ctx, tpPESession session,
 
 	qdf_mem_copy(&add_ie[0], addn_ie, addn_ielen);
 
-	p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0], addn_ielen);
+	p2p_ie = (uint8_t *)limGetP2pIEPtr(mac_ctx, &add_ie[0], addn_ielen);
 	if ((p2p_ie != NULL) && !mac_ctx->beacon_offload) {
 		/* get NoA attribute stream P2P IE */
 		noa_len = lim_get_noa_attr_stream(mac_ctx, noa_strm, session);

+ 16 - 17
core/mac/src/sys/legacy/src/utils/src/parser_api.c

@@ -50,6 +50,7 @@
 #include "cds_regdomain.h"
 #include "qdf_crypto.h"
 #include "lim_process_fils.h"
+#include "wlan_utility.h"
 
 /* ////////////////////////////////////////////////////////////////////// */
 void swap_bit_field16(uint16_t in, uint16_t *out)
@@ -269,7 +270,7 @@ populate_dot11f_chan_switch_wrapper(tpAniSirGlobal pMac,
 				    tDot11fIEChannelSwitchWrapper *pDot11f,
 				    tpPESession psessionEntry)
 {
-	uint8_t *ie_ptr = NULL;
+	const uint8_t *ie_ptr = NULL;
 
 	/*
 	 * The new country subelement is present only when
@@ -303,17 +304,16 @@ populate_dot11f_chan_switch_wrapper(tpAniSirGlobal pMac,
 	/*
 	 * Add the VHT Transmit power Envelope Sublement.
 	 */
-	ie_ptr = lim_get_ie_ptr_new(pMac,
-		psessionEntry->addIeParams.probeRespBCNData_buff,
-		psessionEntry->addIeParams.probeRespBCNDataLen,
-		DOT11F_EID_VHT_TRANSMIT_POWER_ENV, ONE_BYTE);
+	ie_ptr = wlan_get_ie_ptr_from_eid(
+			DOT11F_EID_VHT_TRANSMIT_POWER_ENV,
+			psessionEntry->addIeParams.probeRespBCNData_buff,
+			psessionEntry->addIeParams.probeRespBCNDataLen);
 	if (ie_ptr) {
 		/* Ignore EID field */
-		ie_ptr++;
 		pDot11f->vht_transmit_power_env.present = 1;
-		pDot11f->vht_transmit_power_env.num_bytes = *ie_ptr++;
+		pDot11f->vht_transmit_power_env.num_bytes = ie_ptr[1];
 		qdf_mem_copy(pDot11f->vht_transmit_power_env.bytes,
-			ie_ptr, pDot11f->vht_transmit_power_env.num_bytes);
+			&ie_ptr[2], pDot11f->vht_transmit_power_env.num_bytes);
 	}
 
 }
@@ -5680,16 +5680,16 @@ tSirRetStatus populate_dot11f_assoc_res_wsc_ie(tpAniSirGlobal pMac,
 					       tpSirAssocReq pRcvdAssocReq)
 {
 	tDot11fIEWscAssocReq parsedWscAssocReq = { 0, };
-	uint8_t *wscIe;
+	const uint8_t *wscIe;
 
-	wscIe =
-		limGetWscIEPtr(pMac, pRcvdAssocReq->addIE.addIEdata,
+	wscIe = limGetWscIEPtr(pMac, pRcvdAssocReq->addIE.addIEdata,
 			       pRcvdAssocReq->addIE.length);
 	if (wscIe != NULL) {
 		/* retreive WSC IE from given AssocReq */
-		dot11f_unpack_ie_wsc_assoc_req(pMac, wscIe + 2 + 4,     /* EID, length, OUI */
-					       wscIe[1] - 4, /* length without OUI */
-					       &parsedWscAssocReq, false);
+		dot11f_unpack_ie_wsc_assoc_req(pMac,
+			(uint8_t *)wscIe + 2 + 4, /* EID, length, OUI */
+			wscIe[1] - 4, /* length without OUI */
+			&parsedWscAssocReq, false);
 		pDot11f->present = 1;
 		/* version has to be 0x10 */
 		pDot11f->Version.present = 1;
@@ -5729,10 +5729,9 @@ tSirRetStatus populate_dot11_assoc_res_p2p_ie(tpAniSirGlobal pMac,
 					      tDot11fIEP2PAssocRes *pDot11f,
 					      tpSirAssocReq pRcvdAssocReq)
 {
-	uint8_t *p2pIe;
+	const uint8_t *p2pIe;
 
-	p2pIe =
-		limGetP2pIEPtr(pMac, pRcvdAssocReq->addIE.addIEdata,
+	p2pIe = limGetP2pIEPtr(pMac, pRcvdAssocReq->addIE.addIEdata,
 			       pRcvdAssocReq->addIE.length);
 	if (p2pIe != NULL) {
 		pDot11f->present = 1;

+ 1 - 1
core/sap/src/sap_ch_select.c

@@ -350,7 +350,7 @@ static void sap_process_avoid_ie(tHalHandle hal,
 	while (node) {
 		total_ie_len =
 			GET_IE_LEN_IN_BSS_DESC(node->BssDescriptor.length);
-		temp_ptr = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+		temp_ptr = wlan_get_vendor_ie_ptr_from_oui(
 				SIR_MAC_QCOM_VENDOR_OUI,
 				SIR_MAC_QCOM_VENDOR_SIZE,
 				((uint8_t *)&node->BssDescriptor.ieFields),

+ 1 - 1
core/sap/src/sap_fsm.c

@@ -2353,7 +2353,7 @@ QDF_STATUS sap_signal_hdd_event(ptSapContext sap_ctx,
 			qdf_mem_copy(&reassoc_complete->ies[len],
 				     csr_roaminfo->paddIE,
 				     csr_roaminfo->addIELen);
-			if (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
+			if (wlan_get_vendor_ie_ptr_from_oui(
 			    SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE,
 			    csr_roaminfo->paddIE, csr_roaminfo->addIELen)) {
 				reassoc_complete->staType = eSTA_TYPE_P2P_CLI;