summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajeev Kumar Sirasanagandla <rsirasan@codeaurora.org>2017-04-27 20:12:37 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-07-03 03:57:21 -0700
commit5cf19efaee1f1cee025a45eb8b48dbf5f13a4b40 (patch)
tree02bbb118064589492662974fbdbe50ba664cc9af
parentd0a95255fe62ce03ba79fe16bce4b6357d681aa2 (diff)
qcacld-3.0: Code refactor of probe request IE whitelist
Refactor the probe request IE whitelist logic to reuse the existing kernel string api and further modularize the corresponding code. Change-Id: Id1467dddecb6358c28f50f208ca2af5dd92a35c5 CRs-Fixed: 2036801
-rw-r--r--core/hdd/inc/wlan_hdd_main.h2
-rw-r--r--core/hdd/src/wlan_hdd_cfg.c207
-rw-r--r--core/hdd/src/wlan_hdd_cfg80211.c15
-rw-r--r--core/hdd/src/wlan_hdd_main.c46
-rw-r--r--core/hdd/src/wlan_hdd_scan.c119
-rw-r--r--core/hdd/src/wlan_hdd_scan.h2
-rw-r--r--core/mac/inc/sir_api.h8
-rw-r--r--core/sme/inc/csr_api.h2
-rw-r--r--core/sme/src/common/sme_power_save.c4
-rw-r--r--core/sme/src/csr/csr_api_scan.c112
-rw-r--r--core/wma/src/wma_scan_roam.c5
11 files changed, 270 insertions, 252 deletions
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index 18fc70cf3ff9..38b61352e0eb 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -1831,7 +1831,7 @@ struct hdd_context_s {
int user_configured_pkt_filter_rules;
uint32_t no_of_probe_req_ouis;
- struct vendor_oui *probe_req_voui;
+ uint32_t *probe_req_voui;
struct hdd_nud_stats_context nud_stats_context;
uint32_t track_arp_ip;
uint8_t bt_a2dp_active:1;
diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c
index 7698e047a556..060b5fed2ccd 100644
--- a/core/hdd/src/wlan_hdd_cfg.c
+++ b/core/hdd/src/wlan_hdd_cfg.c
@@ -5525,6 +5525,46 @@ static void hdd_per_roam_print_ini_config(hdd_context_t *hdd_ctx)
}
/**
+ * hdd_cfg_print_ie_whitelist_attrs() - print the ie whitelist attrs
+ * @hdd_ctx: pointer to hdd context
+ *
+ * Return: None
+ */
+static void hdd_cfg_print_ie_whitelist_attrs(hdd_context_t *hdd_ctx)
+{
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_WHITELIST_NAME,
+ hdd_ctx->config->probe_req_ie_whitelist);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP0_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_0);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP1_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_1);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP2_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_2);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP3_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_3);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP4_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_4);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP5_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_5);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP6_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_6);
+ hdd_debug("Name = [%s] Value = [%x] ",
+ CFG_PRB_REQ_IE_BIT_MAP7_NAME,
+ hdd_ctx->config->probe_req_ie_bitmap_7);
+ hdd_debug("Name = [%s] Value =[%s]",
+ CFG_PROBE_REQ_OUI_NAME,
+ hdd_ctx->config->probe_req_ouis);
+}
+
+/**
* hdd_cfg_print() - print the hdd configuration
* @iniTable: pointer to hdd context
*
@@ -6234,36 +6274,9 @@ void hdd_cfg_print(hdd_context_t *pHddCtx)
hdd_debug("Name = [%s] value = [%u]",
CFG_FORCE_1X1_NAME,
pHddCtx->config->is_force_1x1);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_WHITELIST_NAME,
- pHddCtx->config->probe_req_ie_whitelist);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP0_NAME,
- pHddCtx->config->probe_req_ie_bitmap_0);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP1_NAME,
- pHddCtx->config->probe_req_ie_bitmap_1);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP2_NAME,
- pHddCtx->config->probe_req_ie_bitmap_2);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP3_NAME,
- pHddCtx->config->probe_req_ie_bitmap_3);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP4_NAME,
- pHddCtx->config->probe_req_ie_bitmap_4);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP5_NAME,
- pHddCtx->config->probe_req_ie_bitmap_5);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP6_NAME,
- pHddCtx->config->probe_req_ie_bitmap_6);
- hdd_debug("Name = [%s] Value = [%x] ",
- CFG_PRB_REQ_IE_BIT_MAP7_NAME,
- pHddCtx->config->probe_req_ie_bitmap_7);
- hdd_debug("Name = [%s] Value =[%s]",
- CFG_PROBE_REQ_OUI_NAME,
- pHddCtx->config->probe_req_ouis);
+
+ hdd_cfg_print_ie_whitelist_attrs(pHddCtx);
+
hdd_debug("Name = [%s] value = [%u]",
CFG_DROPPED_PKT_DISCONNECT_TH_NAME,
pHddCtx->config->pkt_err_disconn_th);
@@ -8168,132 +8181,48 @@ bool hdd_validate_prb_req_ie_bitmap(hdd_context_t *hdd_ctx)
return true;
}
-/**
- * probe_req_voui_convert_to_hex - converts str of 8 chars into two hex values
- * @temp: string to be converted
- * @voui: contains the type and subtype values
- *
- * This function converts the string length of 8 characters into two
- * hexa-decimal values, oui_type and oui_subtype, where oui_type is the
- * hexa decimal value converted from first 6 characters and oui_subtype is
- * hexa decimal value converted from last 2 characters.
- * strings which doesn't match with the specified pattern are ignored.
- *
- * Return: status of conversion
- * true - if conversion is successful
- * false - if conversion is failed
- */
-static bool hdd_probe_req_voui_convert_to_hex(uint8_t *temp,
- struct vendor_oui *voui)
-{
- uint32_t hex_value[4] = {0};
- uint32_t i = 0;
- uint32_t indx = 0;
-
- memset(voui, 0x00, sizeof(*voui));
-
- /* convert string to hex */
- for (i = 0; i < 8; i++) {
- if (temp[i] >= '0' && temp[i] <= '9') {
- hex_value[indx] = (temp[i] - '0') << 4;
- } else if (temp[i] >= 'A' && temp[i] <= 'F') {
- hex_value[indx] = (temp[i] - 'A') + 0xA;
- hex_value[indx] = hex_value[indx] << 4;
- } else {
- /* invalid character in oui */
- return false;
- }
-
- if (temp[i + 1] >= '0' && temp[i + 1] <= '9') {
- hex_value[indx] |= (temp[i + 1] - '0');
- i = i + 1;
- indx = indx + 1;
- } else if (temp[i + 1] >= 'A' && temp[i + 1] <= 'F') {
- hex_value[indx] |= ((temp[i + 1] - 'A') + 0xA);
- i = i + 1;
- indx = indx + 1;
- } else {
- /* invalid character in oui */
- return false;
- }
- }
-
- voui->oui_type = (hex_value[0] | (hex_value[1] << 8) |
- (hex_value[2] << 16));
- voui->oui_subtype = hex_value[3];
-
- hdd_info("OUI_type = %x and OUI_subtype = %x",
- voui->oui_type, voui->oui_subtype);
-
- return true;
-}
-
int hdd_parse_probe_req_ouis(hdd_context_t *hdd_ctx)
{
- struct vendor_oui voui[MAX_PROBE_REQ_OUIS];
- uint8_t *str;
- uint8_t temp[9];
- uint32_t start = 0, end = 0;
+ uint32_t voui[MAX_PROBE_REQ_OUIS];
+ char *str;
+ uint8_t *token;
uint32_t oui_indx = 0;
- uint32_t i = 0;
+ int ret;
+ uint32_t hex_value;
- hdd_ctx->config->probe_req_ouis[MAX_PRB_REQ_VENDOR_OUI_INI_LEN - 1] =
- '\0';
- if (!strlen(hdd_ctx->config->probe_req_ouis)) {
+ str = (char *)(hdd_ctx->config->probe_req_ouis);
+ str[MAX_PRB_REQ_VENDOR_OUI_INI_LEN - 1] = '\0';
+
+ if (!strlen(str)) {
hdd_ctx->no_of_probe_req_ouis = 0;
hdd_ctx->probe_req_voui = NULL;
hdd_info("NO OUIS to parse");
return 0;
}
- str = (uint8_t *)(hdd_ctx->config->probe_req_ouis);
+ token = strsep(&str, " ");
+ while (token) {
+ if (strlen(token) != 8)
+ goto next_token;
- while (str[i] != '\0') {
- if (str[i] == ' ') {
- if ((end - start) != 8) {
- end = start = 0;
- i++;
- continue;
- } else {
- memcpy(temp, &str[i - 8], 8);
- i++;
- temp[8] = '\0';
- if (!hdd_probe_req_voui_convert_to_hex(temp,
- &voui[oui_indx])) {
- end = start = 0;
- continue;
- }
- oui_indx++;
- if (oui_indx >= MAX_PROBE_REQ_OUIS) {
- /*
- * Max number of OUIs supported is 16,
- * ignoring the rest
- */
- hdd_info("Max OUIs-supported: 16");
- break;
- }
- }
- start = end = 0;
- } else {
- i++;
- end++;
- }
- }
+ ret = kstrtouint(token, 16, &hex_value);
+ if (ret)
+ goto next_token;
- if (((end - start) == 8) && oui_indx < MAX_PROBE_REQ_OUIS) {
- memcpy(temp, &str[i - 8], 8);
- temp[8] = '\0';
- if (hdd_probe_req_voui_convert_to_hex(temp,
- &voui[oui_indx]))
- oui_indx++;
+ voui[oui_indx++] = cpu_to_be32(hex_value);
+ if (oui_indx >= MAX_PROBE_REQ_OUIS)
+ break;
+
+ next_token:
+ token = strsep(&str, " ");
}
if (!oui_indx)
- return 0;
+ return -EINVAL;
hdd_ctx->probe_req_voui = qdf_mem_malloc(oui_indx *
sizeof(*hdd_ctx->probe_req_voui));
- if (hdd_ctx->probe_req_voui == NULL) {
+ if (!hdd_ctx->probe_req_voui) {
hdd_err("Not Enough memory for OUI");
hdd_ctx->no_of_probe_req_ouis = 0;
return -ENOMEM;
@@ -8307,7 +8236,7 @@ int hdd_parse_probe_req_ouis(hdd_context_t *hdd_ctx)
void hdd_free_probe_req_ouis(hdd_context_t *hdd_ctx)
{
- struct vendor_oui *probe_req_voui = hdd_ctx->probe_req_voui;
+ uint32_t *probe_req_voui = hdd_ctx->probe_req_voui;
if (probe_req_voui) {
hdd_ctx->probe_req_voui = NULL;
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 588d65beb0e7..3203dcd01f14 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -2037,9 +2037,13 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
hdd_err("Invalid ATTR");
return -EINVAL;
}
- pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg) +
- (pHddCtx->no_of_probe_req_ouis) *
- (sizeof(struct vendor_oui)));
+
+ if (pHddCtx->config->probe_req_ie_whitelist)
+ pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg) +
+ pHddCtx->no_of_probe_req_ouis *
+ sizeof(*pHddCtx->probe_req_voui));
+ else
+ pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg));
if (!pReqMsg) {
hdd_err("qdf_mem_malloc failed");
@@ -2069,11 +2073,10 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
hdd_debug("Oui (%02x:%02x:%02x), vdev_id = %d", pReqMsg->oui[0],
pReqMsg->oui[1], pReqMsg->oui[2], pReqMsg->vdev_id);
- if (pHddCtx->config->probe_req_ie_whitelist)
- wlan_hdd_fill_whitelist_ie_attrs(&pReqMsg->ie_whitelist,
+ wlan_hdd_fill_whitelist_ie_attrs(&pReqMsg->ie_whitelist,
pReqMsg->probe_req_ie_bitmap,
&pReqMsg->num_vendor_oui,
- (struct vendor_oui *)((uint8_t *)pReqMsg +
+ (uint32_t *)((uint8_t *)pReqMsg +
sizeof(*pReqMsg)),
pHddCtx);
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 7ccb7c0542be..4716be10bda0 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -7419,6 +7419,37 @@ list_destroy:
}
/**
+ * ie_whitelist_attrs_init() - initialize ie whitelisting attributes
+ * @hdd_ctx: pointer to hdd context
+ *
+ * Return: status of initialization
+ * 0 - success
+ * negative value - failure
+ */
+static int ie_whitelist_attrs_init(hdd_context_t *hdd_ctx)
+{
+ int ret;
+
+ if (!hdd_ctx->config->probe_req_ie_whitelist)
+ return 0;
+
+ if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) {
+ hdd_err("invalid ie bitmap and ouis: disable ie whitelisting");
+ hdd_ctx->config->probe_req_ie_whitelist = false;
+ return -EINVAL;
+ }
+
+ /* parse ini string probe req oui */
+ ret = hdd_parse_probe_req_ouis(hdd_ctx);
+ if (ret) {
+ hdd_err("parsing error: disable ie whitelisting");
+ hdd_ctx->config->probe_req_ie_whitelist = false;
+ }
+
+ return ret;
+}
+
+/**
* hdd_context_create() - Allocate and inialize HDD context.
* @dev: Device Pointer to the underlying device
*
@@ -7470,20 +7501,7 @@ static hdd_context_t *hdd_context_create(struct device *dev)
goto err_free_config;
}
- if (hdd_ctx->config->probe_req_ie_whitelist) {
- if (hdd_validate_prb_req_ie_bitmap(hdd_ctx)) {
- /* parse ini string probe req oui */
- if (hdd_parse_probe_req_ouis(hdd_ctx)) {
- hdd_err("Error parsing probe req ouis");
- hdd_err("disable probe req ie whitelisting");
- hdd_ctx->config->probe_req_ie_whitelist = false;
- }
- } else {
- hdd_err("invalid probe req ie bitmap and ouis");
- hdd_err("disable probe req ie whitelisting");
- hdd_ctx->config->probe_req_ie_whitelist = false;
- }
- }
+ ie_whitelist_attrs_init(hdd_ctx);
if (hdd_ctx->config->fhostNSOffload)
hdd_ctx->ns_offload_enable = true;
diff --git a/core/hdd/src/wlan_hdd_scan.c b/core/hdd/src/wlan_hdd_scan.c
index 65764ac14680..0e1b90173a2b 100644
--- a/core/hdd/src/wlan_hdd_scan.c
+++ b/core/hdd/src/wlan_hdd_scan.c
@@ -1734,6 +1734,63 @@ static void wlan_hdd_update_scan_rand_attrs(void *scan_req,
#endif
/**
+ * wlan_hdd_populate_ie_whitelist() - Allocate and populate ie whitelist attrs
+ * @adapter: Pointer to adapter
+ * @hdd_ctx: Pointer to hdd ctx info
+ * @scan_req: Pointer to csr scan req
+ * @is_p2p_scan: Used to check for p2p scan type
+ *
+ * After checking adapter mode, connection state and type of scan,
+ * this function allocates memory for csr scan request ie whitelist attrs
+ * and populates with wlan_hdd_fill_whitelist_ie_attrs
+ *
+ * Return: 0 for success, non zero for failure
+ */
+static int wlan_hdd_populate_ie_whitelist(hdd_adapter_t *adapter,
+ hdd_context_t *hdd_ctx,
+ tCsrScanRequest *scan_req,
+ bool is_p2p_scan)
+{
+ hdd_station_ctx_t *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+ if (!hdd_ctx->config->probe_req_ie_whitelist ||
+ adapter->device_mode != QDF_STA_MODE ||
+ is_p2p_scan ||
+ hdd_conn_is_connected(station_ctx))
+ return 0;
+
+ if (hdd_ctx->no_of_probe_req_ouis) {
+ scan_req->voui = qdf_mem_malloc(hdd_ctx->no_of_probe_req_ouis *
+ sizeof(*hdd_ctx->probe_req_voui));
+ if (!scan_req->voui) {
+ hdd_err("Not enough memory for voui");
+ scan_req->num_vendor_oui = 0;
+ return -ENOMEM;
+ }
+ }
+
+ wlan_hdd_fill_whitelist_ie_attrs(&scan_req->ie_whitelist,
+ scan_req->probe_req_ie_bitmap,
+ &scan_req->num_vendor_oui,
+ scan_req->voui,
+ hdd_ctx);
+
+ return 0;
+}
+
+/**
+ * wlan_hdd_free_voui() - Deallocate csr scan req ie whitelist attrs
+ * @scan_req: Pointer to csr scan req
+ *
+ * Return: None
+ */
+static void wlan_hdd_free_voui(tCsrScanRequest *scan_req)
+{
+ if (scan_req->voui)
+ qdf_mem_free(scan_req->voui);
+}
+
+/**
* __wlan_hdd_cfg80211_scan() - API to process cfg80211 scan request
* @wiphy: Pointer to wiphy
* @dev: Pointer to net device
@@ -1753,7 +1810,6 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
- hdd_station_ctx_t *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
struct hdd_config *cfg_param = NULL;
tCsrScanRequest scan_req;
uint8_t *channelList = NULL, i;
@@ -2186,28 +2242,10 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
wlan_hdd_update_scan_rand_attrs((void *)&scan_req, (void *)request,
WLAN_HDD_HOST_SCAN);
- if (pAdapter->device_mode == QDF_STA_MODE &&
- !is_p2p_scan &&
- !hdd_conn_is_connected(station_ctx) &&
- (pHddCtx->config->probe_req_ie_whitelist)) {
- if (pHddCtx->no_of_probe_req_ouis != 0) {
- scan_req.voui = qdf_mem_malloc(
- pHddCtx->no_of_probe_req_ouis *
- sizeof(struct vendor_oui));
- if (!scan_req.voui) {
- hdd_debug("Not enough memory for voui");
- scan_req.num_vendor_oui = 0;
- status = -ENOMEM;
- goto free_mem;
- }
- }
-
- wlan_hdd_fill_whitelist_ie_attrs(&scan_req.ie_whitelist,
- scan_req.probe_req_ie_bitmap,
- &scan_req.num_vendor_oui,
- scan_req.voui,
- pHddCtx);
- }
+ status = wlan_hdd_populate_ie_whitelist(pAdapter, pHddCtx,
+ &scan_req, is_p2p_scan);
+ if (status)
+ goto free_mem;
hdd_update_dbs_scan_ctrl_ext_flag(pHddCtx, &scan_req);
qdf_runtime_pm_prevent_suspend(&pHddCtx->runtime_context.scan);
@@ -2245,8 +2283,7 @@ free_mem:
if (status == 0)
scan_ebusy_cnt = 0;
- if (scan_req.voui)
- qdf_mem_free(scan_req.voui);
+ wlan_hdd_free_voui(&scan_req);
EXIT();
return status;
@@ -3121,8 +3158,8 @@ static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
(pHddCtx->config->probe_req_ie_whitelist))
pPnoRequest =
(tpSirPNOScanReq)qdf_mem_malloc(sizeof(tSirPNOScanReq) +
- (pHddCtx->no_of_probe_req_ouis) *
- (sizeof(struct vendor_oui)));
+ pHddCtx->no_of_probe_req_ouis *
+ sizeof(*pHddCtx->probe_req_voui));
else
pPnoRequest = qdf_mem_malloc(sizeof(tSirPNOScanReq));
@@ -3294,12 +3331,11 @@ static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
wlan_hdd_update_scan_rand_attrs((void *)pPnoRequest, (void *)request,
WLAN_HDD_PNO_SCAN);
- if (pHddCtx->config->probe_req_ie_whitelist &&
- !hdd_conn_is_connected(station_ctx))
+ if (!hdd_conn_is_connected(station_ctx))
wlan_hdd_fill_whitelist_ie_attrs(&pPnoRequest->ie_whitelist,
pPnoRequest->probe_req_ie_bitmap,
&pPnoRequest->num_vendor_oui,
- (struct vendor_oui *)(
+ (uint32_t *)(
(uint8_t *)pPnoRequest +
sizeof(*pPnoRequest)),
pHddCtx);
@@ -3619,11 +3655,18 @@ int hdd_scan_context_init(hdd_context_t *hdd_ctx)
void wlan_hdd_fill_whitelist_ie_attrs(bool *ie_whitelist,
uint32_t *probe_req_ie_bitmap,
uint32_t *num_vendor_oui,
- struct vendor_oui *voui,
+ uint32_t *voui,
hdd_context_t *hdd_ctx)
{
uint32_t i = 0;
+ *num_vendor_oui = 0;
+
+ if (!hdd_ctx->config->probe_req_ie_whitelist) {
+ *ie_whitelist = false;
+ return;
+ }
+
*ie_whitelist = true;
probe_req_ie_bitmap[0] = hdd_ctx->config->probe_req_ie_bitmap_0;
probe_req_ie_bitmap[1] = hdd_ctx->config->probe_req_ie_bitmap_1;
@@ -3634,14 +3677,10 @@ void wlan_hdd_fill_whitelist_ie_attrs(bool *ie_whitelist,
probe_req_ie_bitmap[6] = hdd_ctx->config->probe_req_ie_bitmap_6;
probe_req_ie_bitmap[7] = hdd_ctx->config->probe_req_ie_bitmap_7;
- *num_vendor_oui = 0;
+ if (!hdd_ctx->no_of_probe_req_ouis || !voui)
+ return;
- if ((hdd_ctx->no_of_probe_req_ouis != 0) && (voui != NULL)) {
- *num_vendor_oui = hdd_ctx->no_of_probe_req_ouis;
- for (i = 0; i < hdd_ctx->no_of_probe_req_ouis; i++) {
- voui[i].oui_type = hdd_ctx->probe_req_voui[i].oui_type;
- voui[i].oui_subtype =
- hdd_ctx->probe_req_voui[i].oui_subtype;
- }
- }
+ *num_vendor_oui = hdd_ctx->no_of_probe_req_ouis;
+ for (i = 0; i < hdd_ctx->no_of_probe_req_ouis; i++)
+ voui[i] = hdd_ctx->probe_req_voui[i];
}
diff --git a/core/hdd/src/wlan_hdd_scan.h b/core/hdd/src/wlan_hdd_scan.h
index b5cc3409695a..1384345b7744 100644
--- a/core/hdd/src/wlan_hdd_scan.h
+++ b/core/hdd/src/wlan_hdd_scan.h
@@ -157,7 +157,7 @@ void wlan_hdd_cfg80211_abort_scan(struct wiphy *wiphy,
void wlan_hdd_fill_whitelist_ie_attrs(bool *ie_whitelist,
uint32_t *probe_req_ie_bitmap,
uint32_t *num_vendor_oui,
- struct vendor_oui *voui,
+ uint32_t *voui,
hdd_context_t *hdd_ctx);
/**
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index 6e3e4a7e2733..f505d517d2e4 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -1002,7 +1002,7 @@ typedef struct sSirSmeScanReq {
up to uIEFieldLen (can be 0)
-----------------------------
... variable size upto num_vendor_oui
- struct vendor_oui voui;
+ of type uint32_t
-----------------------------------*/
} tSirSmeScanReq, *tpSirSmeScanReq;
@@ -3139,7 +3139,7 @@ typedef struct sSirPNOScanReq {
bool ie_whitelist;
uint32_t probe_req_ie_bitmap[PROBE_REQ_BITMAP_LEN];
uint32_t num_vendor_oui;
- /* followed by one or more struct vendor_oui */
+ /* followed by one or more vendor ouis of type uint32_t */
} tSirPNOScanReq, *tpSirPNOScanReq;
/* Preferred Network Found Indication */
@@ -4061,7 +4061,7 @@ typedef struct sSirScanOffloadReq {
up to uIEFieldLen (can be 0)
-----------------------------
... variable size upto num_vendor_oui
- struct vendor_oui voui;
+ of type uint32_t
------------------------*/
} tSirScanOffloadReq, *tpSirScanOffloadReq;
@@ -5332,7 +5332,7 @@ typedef struct {
bool ie_whitelist;
uint32_t probe_req_ie_bitmap[PROBE_REQ_BITMAP_LEN];
uint32_t num_vendor_oui;
- /* Followed by 0 or more struct vendor_oui */
+ /* Followed by 0 or more vendor_ouis of type uint32_t */
} tSirScanMacOui, *tpSirScanMacOui;
enum {
diff --git a/core/sme/inc/csr_api.h b/core/sme/inc/csr_api.h
index 60821dc19b36..20ad76afd313 100644
--- a/core/sme/inc/csr_api.h
+++ b/core/sme/inc/csr_api.h
@@ -310,7 +310,7 @@ typedef struct tagCsrScanRequest {
bool ie_whitelist;
uint32_t probe_req_ie_bitmap[PROBE_REQ_BITMAP_LEN];
uint32_t num_vendor_oui;
- struct vendor_oui *voui;
+ uint32_t *voui;
} tCsrScanRequest;
typedef struct tagCsrScanResultInfo {
diff --git a/core/sme/src/common/sme_power_save.c b/core/sme/src/common/sme_power_save.c
index be77d09b01f9..7e006816ca5e 100644
--- a/core/sme/src/common/sme_power_save.c
+++ b/core/sme/src/common/sme_power_save.c
@@ -765,7 +765,7 @@ QDF_STATUS sme_set_ps_preferred_network_list(tHalHandle hal_ctx,
request_buf = qdf_mem_malloc(sizeof(tSirPNOScanReq) +
(request->num_vendor_oui) *
- (sizeof(struct vendor_oui)));
+ (sizeof(uint32_t)));
if (NULL == request_buf) {
QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
@@ -775,7 +775,7 @@ QDF_STATUS sme_set_ps_preferred_network_list(tHalHandle hal_ctx,
qdf_mem_copy(request_buf, request, sizeof(tSirPNOScanReq) +
(request->num_vendor_oui) *
- (sizeof(struct vendor_oui)));
+ (sizeof(uint32_t)));
/*Must translate the mode first */
uc_dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c
index 631243eb083b..5a75460eb7ba 100644
--- a/core/sme/src/csr/csr_api_scan.c
+++ b/core/sme/src/csr/csr_api_scan.c
@@ -5113,6 +5113,39 @@ QDF_STATUS csr_scan_age_results(tpAniSirGlobal pMac,
return status;
}
+/**
+ * csr_populate_ie_whitelist_attrs() - Populates ie whitelist attrs
+ * @msg: pointer to sme scan req
+ * @scan_req: pointer to csr scan req
+ *
+ * This function populates ie whitelisting attributes of the sme scan req
+ * with corresponding whitelisting attrs in csr scan req
+ *
+ * Return: None
+ */
+static void csr_populate_ie_whitelist_attrs(tSirSmeScanReq *msg,
+ tCsrScanRequest *scan_req)
+{
+ msg->ie_whitelist = scan_req->ie_whitelist;
+ msg->num_vendor_oui = scan_req->num_vendor_oui;
+
+ if (!msg->ie_whitelist)
+ return;
+
+ qdf_mem_copy(msg->probe_req_ie_bitmap, scan_req->probe_req_ie_bitmap,
+ PROBE_REQ_BITMAP_LEN * sizeof(uint32_t));
+ msg->oui_field_len = scan_req->num_vendor_oui * sizeof(*scan_req->voui);
+ msg->oui_field_offset = (sizeof(tSirSmeScanReq) -
+ sizeof(msg->channelList.channelNumber) +
+ (sizeof(msg->channelList.channelNumber) *
+ scan_req->ChannelInfo.numOfChannels)) +
+ scan_req->uIEFieldLen;
+
+ if (scan_req->num_vendor_oui != 0)
+ qdf_mem_copy((uint8_t *)msg + msg->oui_field_offset,
+ (uint8_t *)(scan_req->voui), msg->oui_field_len);
+}
+
static QDF_STATUS csr_send_mb_scan_req(tpAniSirGlobal pMac, uint16_t sessionId,
tCsrScanRequest *pScanReq,
struct tag_scanreq_param *pScanReqParam)
@@ -5300,25 +5333,7 @@ static QDF_STATUS csr_send_mb_scan_req(tpAniSirGlobal pMac, uint16_t sessionId,
QDF_MAC_ADDR_SIZE);
}
- pMsg->ie_whitelist = pScanReq->ie_whitelist;
- if (pMsg->ie_whitelist)
- qdf_mem_copy(pMsg->probe_req_ie_bitmap,
- pScanReq->probe_req_ie_bitmap,
- PROBE_REQ_BITMAP_LEN * sizeof(uint32_t));
- pMsg->num_vendor_oui = pScanReq->num_vendor_oui;
- pMsg->oui_field_len = pScanReq->num_vendor_oui *
- sizeof(*pScanReq->voui);
- pMsg->oui_field_offset = (sizeof(tSirSmeScanReq) -
- sizeof(pMsg->channelList.channelNumber) +
- (sizeof(pMsg->channelList.channelNumber) *
- pScanReq->ChannelInfo.numOfChannels)) +
- pScanReq->uIEFieldLen;
-
- if (pScanReq->num_vendor_oui != 0) {
- qdf_mem_copy((uint8_t *)pMsg + pMsg->oui_field_offset,
- (uint8_t *)(pScanReq->voui),
- pMsg->oui_field_len);
- }
+ csr_populate_ie_whitelist_attrs(pMsg, pScanReq);
pMsg->scan_ctrl_flags_ext = pScanReq->scan_ctrl_flags_ext;
@@ -5699,6 +5714,42 @@ static bool csr_scan_filter_given_chnl_band(tpAniSirGlobal mac_ctx,
}
/**
+ * csr_scan_copy_ie_whitelist_attrs() - Copies ie whitelist attrs
+ * @dst_req: pointer to tCsrScanRequest
+ * @src_req: pointer to tCsrScanRequest
+ *
+ * This function makes a copy of ie whitelist attrs
+ *
+ * Return: QDF_STATUS_SUCCESS - for successful allocation and copy
+ * QDF_STATUS_E_NOMEM - when failed to allocate memory
+ */
+static QDF_STATUS csr_scan_copy_ie_whitelist_attrs(tCsrScanRequest *dst_req,
+ tCsrScanRequest *src_req)
+{
+ QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+ if (!src_req->num_vendor_oui) {
+ dst_req->num_vendor_oui = 0;
+ dst_req->voui = NULL;
+ return status;
+ }
+
+ dst_req->voui = qdf_mem_malloc(src_req->num_vendor_oui *
+ sizeof(*dst_req->voui));
+ if (!dst_req->voui) {
+ status = QDF_STATUS_E_NOMEM;
+ dst_req->num_vendor_oui = 0;
+ sme_err("No memory for voui");
+ } else {
+ dst_req->num_vendor_oui = src_req->num_vendor_oui;
+ qdf_mem_copy(dst_req->voui, src_req->voui,
+ src_req->num_vendor_oui * sizeof(*dst_req->voui));
+ }
+
+ return status;
+}
+
+/**
* csr_scan_copy_request() - Function to copy scan request
* @mac_ctx : pointer to Global Mac Structure
* @dst_req: pointer to tCsrScanRequest
@@ -5884,28 +5935,7 @@ QDF_STATUS csr_scan_copy_request(tpAniSirGlobal mac_ctx,
dst_req->scan_id = src_req->scan_id;
dst_req->timestamp = src_req->timestamp;
- if (src_req->num_vendor_oui == 0) {
- dst_req->num_vendor_oui = 0;
- dst_req->voui = NULL;
- } else {
- dst_req->voui = qdf_mem_malloc(src_req->num_vendor_oui *
- sizeof(*dst_req->voui));
- if (!dst_req->voui)
- status = QDF_STATUS_E_NOMEM;
- else
- status = QDF_STATUS_SUCCESS;
-
- if (QDF_IS_STATUS_SUCCESS(status)) {
- dst_req->num_vendor_oui = src_req->num_vendor_oui;
- qdf_mem_copy(dst_req->voui,
- src_req->voui,
- src_req->num_vendor_oui *
- sizeof(*dst_req->voui));
- } else {
- dst_req->num_vendor_oui = 0;
- sme_err("No memory for voui");
- }
- }
+ status = csr_scan_copy_ie_whitelist_attrs(dst_req, src_req);
complete:
if (!QDF_IS_STATUS_SUCCESS(status))
diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c
index 3b0874d921d2..fc00eed5fc54 100644
--- a/core/wma/src/wma_scan_roam.c
+++ b/core/wma/src/wma_scan_roam.c
@@ -3338,8 +3338,7 @@ QDF_STATUS wma_pno_start(tp_wma_handle wma, tpSirPNOScanReq pno)
params->probe_req_ie_bitmap[i] =
pno->probe_req_ie_bitmap[i];
params->num_vendor_oui = pno->num_vendor_oui;
- params->oui_field_len = pno->num_vendor_oui *
- sizeof(struct vendor_oui);
+ params->oui_field_len = pno->num_vendor_oui * sizeof(uint32_t);
params->voui = (uint8_t *)pno;
}
@@ -5779,7 +5778,7 @@ QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, tSirScanMacOui *psetoui)
psetoui->probe_req_ie_bitmap[i];
set_oui.num_vendor_oui = psetoui->num_vendor_oui;
set_oui.oui_field_len = psetoui->num_vendor_oui *
- sizeof(struct vendor_oui);
+ sizeof(uint32_t);
set_oui.voui = (uint8_t *)psetoui;
}