wlan: hdd: Add host scan mac-spoofing support
Extend the functionality of spoofing of mac addr
in host initiated scans. Both FW initiated
scans and host initiated scans will be spoofed.
- Check for MAC_SPOOFED_SCAN feature capability flag
- provided spoof mac addr is stored in pHddCtx
- Spoofing request will be deferred till scan is completed
- new spoofed mac addr is updated with FW after scan completion
- 00:00:00 mac addr OUI provided to disable spoofing
Change-Id: I85fad66779f2e4eed0303b938386bd4b90caeda8
CRs-Fixed: 737889
diff --git a/CORE/HDD/src/wlan_hdd_scan.c b/CORE/HDD/src/wlan_hdd_scan.c
index 4366fef..ad57958 100644
--- a/CORE/HDD/src/wlan_hdd_scan.c
+++ b/CORE/HDD/src/wlan_hdd_scan.c
@@ -534,6 +534,64 @@
/**---------------------------------------------------------------------------
+ \brief hdd_processSpoofMacAddrRequest() -
+
+ The function is called from scan completion callback and from
+ cfg80211 vendor command
+
+ \param - pHddCtx - Pointer to the HDD Context.
+
+ \return - 0 for success, non zero for failure
+
+ --------------------------------------------------------------------------*/
+
+VOS_STATUS hdd_processSpoofMacAddrRequest(hdd_context_t *pHddCtx)
+{
+
+ ENTER();
+
+ mutex_lock(&pHddCtx->spoofMacAddr.macSpoofingLock);
+
+ if (pHddCtx->spoofMacAddr.isEnabled) {
+ if (VOS_STATUS_SUCCESS != vos_randomize_n_bytes(
+ (void *)(&pHddCtx->spoofMacAddr.randomMacAddr.bytes[3]),
+ VOS_MAC_ADDR_LAST_3_BYTES)) {
+ hddLog(LOGE, FL("Failed to generate random Mac Addr"));
+ pHddCtx->spoofMacAddr.isEnabled = FALSE;
+ mutex_unlock(&pHddCtx->spoofMacAddr.macSpoofingLock);
+ return VOS_STATUS_E_FAILURE;
+ }
+ }
+
+ hddLog(LOG1, FL("New Mac Addr Generated "MAC_ADDRESS_STR),
+ MAC_ADDR_ARRAY(pHddCtx->spoofMacAddr.randomMacAddr.bytes));
+
+ if (pHddCtx->scan_info.mScanPending != TRUE)
+ {
+ pHddCtx->spoofMacAddr.isReqDeferred = FALSE;
+ hddLog(LOG1, FL("Processing Spoof request now"));
+ /* Inform SME about spoof mac addr request*/
+ if ( eHAL_STATUS_SUCCESS != sme_SpoofMacAddrReq(pHddCtx->hHal,
+ &pHddCtx->spoofMacAddr.randomMacAddr))
+ {
+ hddLog(LOGE, FL("Sending Spoof request failed - Disable spoofing"));
+ pHddCtx->spoofMacAddr.isEnabled = FALSE;
+ }
+ } else
+ {
+ hddLog(LOG1, FL("Scan in Progress. Spoofing Deferred"));
+ pHddCtx->spoofMacAddr.isReqDeferred = TRUE;
+ }
+
+ mutex_unlock(&pHddCtx->spoofMacAddr.macSpoofingLock);
+
+ EXIT();
+
+ return VOS_STATUS_SUCCESS;
+}
+
+/**---------------------------------------------------------------------------
+
\brief hdd_ScanRequestCallback() -
The sme module calls this callback function once it finish the scan request