aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/cfg80211.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-06-12 15:39:05 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-11-19 12:45:52 -0500
commitad2b26abc157460ca6fac1a53a2bfeade283adfa (patch)
tree81f73219cf0132dca99028fe1a8f4a26805d5247 /include/net/cfg80211.h
parentff5db4392c75e005882dd93641b2caa436437dd6 (diff)
cfg80211: allow drivers to support random MAC addresses for scan
Add the necessary feature flags and a scan flag to support using random MAC addresses for scan while unassociated. The configuration for this supports an arbitrary MAC address value and mask, so that any kind of configuration (e.g. fixed OUI or full 46-bit random) can be requested. Full 46-bit random is the default when no other configuration is passed. Also add a small helper function to use the addr/mask correctly. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'include/net/cfg80211.h')
-rw-r--r--include/net/cfg80211.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 05aae22e92a5..bb748c4da5af 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1437,6 +1437,10 @@ struct cfg80211_ssid {
1437 * @aborted: (internal) scan request was notified as aborted 1437 * @aborted: (internal) scan request was notified as aborted
1438 * @notified: (internal) scan request was notified as done or aborted 1438 * @notified: (internal) scan request was notified as done or aborted
1439 * @no_cck: used to send probe requests at non CCK rate in 2GHz band 1439 * @no_cck: used to send probe requests at non CCK rate in 2GHz band
1440 * @mac_addr: MAC address used with randomisation
1441 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1442 * are 0 in the mask should be randomised, bits that are 1 should
1443 * be taken from the @mac_addr
1440 */ 1444 */
1441struct cfg80211_scan_request { 1445struct cfg80211_scan_request {
1442 struct cfg80211_ssid *ssids; 1446 struct cfg80211_ssid *ssids;
@@ -1451,6 +1455,9 @@ struct cfg80211_scan_request {
1451 1455
1452 struct wireless_dev *wdev; 1456 struct wireless_dev *wdev;
1453 1457
1458 u8 mac_addr[ETH_ALEN] __aligned(2);
1459 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1460
1454 /* internal */ 1461 /* internal */
1455 struct wiphy *wiphy; 1462 struct wiphy *wiphy;
1456 unsigned long scan_start; 1463 unsigned long scan_start;
@@ -1461,6 +1468,17 @@ struct cfg80211_scan_request {
1461 struct ieee80211_channel *channels[0]; 1468 struct ieee80211_channel *channels[0];
1462}; 1469};
1463 1470
1471static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
1472{
1473 int i;
1474
1475 get_random_bytes(buf, ETH_ALEN);
1476 for (i = 0; i < ETH_ALEN; i++) {
1477 buf[i] &= ~mask[i];
1478 buf[i] |= addr[i] & mask[i];
1479 }
1480}
1481
1464/** 1482/**
1465 * struct cfg80211_match_set - sets of attributes to match 1483 * struct cfg80211_match_set - sets of attributes to match
1466 * 1484 *
@@ -1494,6 +1512,10 @@ struct cfg80211_match_set {
1494 * @channels: channels to scan 1512 * @channels: channels to scan
1495 * @min_rssi_thold: for drivers only supporting a single threshold, this 1513 * @min_rssi_thold: for drivers only supporting a single threshold, this
1496 * contains the minimum over all matchsets 1514 * contains the minimum over all matchsets
1515 * @mac_addr: MAC address used with randomisation
1516 * @mac_addr_mask: MAC address mask used with randomisation, bits that
1517 * are 0 in the mask should be randomised, bits that are 1 should
1518 * be taken from the @mac_addr
1497 */ 1519 */
1498struct cfg80211_sched_scan_request { 1520struct cfg80211_sched_scan_request {
1499 struct cfg80211_ssid *ssids; 1521 struct cfg80211_ssid *ssids;
@@ -1508,6 +1530,9 @@ struct cfg80211_sched_scan_request {
1508 int n_match_sets; 1530 int n_match_sets;
1509 s32 min_rssi_thold; 1531 s32 min_rssi_thold;
1510 1532
1533 u8 mac_addr[ETH_ALEN] __aligned(2);
1534 u8 mac_addr_mask[ETH_ALEN] __aligned(2);
1535
1511 /* internal */ 1536 /* internal */
1512 struct wiphy *wiphy; 1537 struct wiphy *wiphy;
1513 struct net_device *dev; 1538 struct net_device *dev;