[PATCH 2/5] nl80211: Handle MAC address randomization in scan

Ilan Peer ilan.peer
Sun Dec 28 22:41:05 PST 2014


1. Process supported driver capabilities.
2. Populate scan request with MAC address randomization data

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/drivers/driver_nl80211_capa.c | 13 +++++++++++++
 src/drivers/driver_nl80211_scan.c | 21 +++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
index 657f38c..bd58c41 100644
--- a/src/drivers/driver_nl80211_capa.c
+++ b/src/drivers/driver_nl80211_capa.c
@@ -76,6 +76,8 @@ struct wiphy_info_data {
 	unsigned int set_qos_map_supported:1;
 	unsigned int have_low_prio_scan:1;
 	unsigned int wmm_ac_supported:1;
+	unsigned int mac_addr_rand_scan_supported:1;
+	unsigned int mac_addr_rand_sched_scan_supported:1;
 };
 
 
@@ -381,6 +383,12 @@ static void wiphy_info_feature_flags(struct wiphy_info_data *info,
 
 	if (flags & NL80211_FEATURE_TX_POWER_INSERTION)
 		capa->rrm_flags |= WPA_DRIVER_FLAGS_TX_POWER_INSERTION;
+
+	if (flags & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR)
+		info->mac_addr_rand_scan_supported = 1;
+
+	if (flags & NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR)
+		info->mac_addr_rand_sched_scan_supported = 1;
 }
 
 
@@ -630,6 +638,11 @@ static int wpa_driver_nl80211_get_info(struct wpa_driver_nl80211_data *drv,
 		drv->capa.flags |= WPA_DRIVER_FLAGS_AP_CSA;
 	drv->capa.wmm_ac_supported = info->wmm_ac_supported;
 
+	drv->capa.mac_addr_rand_sched_scan_supported =
+		info->mac_addr_rand_sched_scan_supported;
+	drv->capa.mac_addr_rand_scan_supported =
+		info->mac_addr_rand_scan_supported;
+
 	return 0;
 }
 
diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c
index 89f2279..767262a 100644
--- a/src/drivers/driver_nl80211_scan.c
+++ b/src/drivers/driver_nl80211_scan.c
@@ -171,6 +171,27 @@ nl80211_scan_common(struct i802_bss *bss, u8 cmd,
 		scan_flags |= NL80211_SCAN_FLAG_LOW_PRIORITY;
 	}
 
+	if (params->mac_addr_rand) {
+		if ((params->mac_addr && !params->mac_addr_mask) ||
+		    (!params->mac_addr && params->mac_addr_mask)) {
+			wpa_printf(MSG_WARNING,
+				   "nl80211: invalid mac addr or mask");
+			goto fail;
+		}
+
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: Add NL80211_SCAN_FLAG_RANDOM_ADDR");
+		scan_flags |= NL80211_SCAN_FLAG_RANDOM_ADDR;
+
+		if (params->mac_addr) {
+			if (nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN,
+				    params->mac_addr) ||
+			    nla_put(msg, NL80211_ATTR_MAC_MASK, ETH_ALEN,
+				    params->mac_addr_mask))
+				goto fail;
+		}
+	}
+
 	if (scan_flags &&
 	    nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, scan_flags))
 		goto fail;
-- 
1.8.3.2




More information about the Hostap mailing list