History

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.

Johannes Berg committed 12 years ago

Commit ad2b26a1 parent ff5db433 files · +137 −3Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/nl80211.h+29−0
@@ -1686,6 +1686,8 @@ enum nl80211_commands { · 1685 unmodified lines
16861686 *
16871687 * @NL80211_ATTR_OPER_CLASS: operating class
16881688 *
1689+ * @NL80211_ATTR_MAC_MASK: MAC address mask
1690+ *
16891691 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
16901692 * @NL80211_ATTR_MAX: highest attribute number currently defined
16911693 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2041,6 +2043,8 @@ enum nl80211_attrs { · 349 unmodified lines
20412043
20422044 NL80211_ATTR_OPER_CLASS,
20432045
2046+ NL80211_ATTR_MAC_MASK,
2047+
20442048 /* add attributes here, update the policy in nl80211.c */
20452049
20462050 __NL80211_ATTR_AFTER_LAST,
@@ -4139,6 +4143,18 @@ enum nl80211_ap_sme_features { · 2092 unmodified lines
41394143 * See 'macaddr' field in the vif_params (cfg80211.h).
41404144 * @NL80211_FEATURE_TDLS_CHANNEL_SWITCH: Driver supports channel switching when
41414145 * operating as a TDLS peer.
4146+ * @NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR: This device/driver supports using a
4147+ * random MAC address during scan (if the device is unassociated); the
4148+ * %NL80211_SCAN_FLAG_RANDOM_ADDR flag may be set for scans and the MAC
4149+ * address mask/value will be used.
4150+ * @NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR: This device/driver supports
4151+ * using a random MAC address for every scan iteration during scheduled
4152+ * scan (while not associated), the %NL80211_SCAN_FLAG_RANDOM_ADDR may
4153+ * be set for scheduled scan and the MAC address mask/value will be used.
4154+ * @NL80211_FEATURE_ND_RANDOM_MAC_ADDR: This device/driver supports using a
4155+ * random MAC address for every scan iteration during "net detect", i.e.
4156+ * scan in unassociated WoWLAN, the %NL80211_SCAN_FLAG_RANDOM_ADDR may
4157+ * be set for scheduled scan and the MAC address mask/value will be used.
41424158 */
41434159 enum nl80211_feature_flags {
41444160 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
@@ -4170,6 +4186,9 @@ enum nl80211_feature_flags { · 25 unmodified lines
41704186 NL80211_FEATURE_SUPPORTS_WMM_ADMISSION = 1 << 26,
41714187 NL80211_FEATURE_MAC_ON_CREATE = 1 << 27,
41724188 NL80211_FEATURE_TDLS_CHANNEL_SWITCH = 1 << 28,
4189+ NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR = 1 << 29,
4190+ NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR = 1 << 30,
4191+ NL80211_FEATURE_ND_RANDOM_MAC_ADDR = 1 << 31,
41734192 };
41744193
41754194 /**
@@ -4218,11 +4237,21 @@ enum nl80211_connect_failed_reason { · 42 unmodified lines
42184237 * dangerous because will destroy stations performance as a lot of frames
42194238 * will be lost while scanning off-channel, therefore it must be used only
42204239 * when really needed
4240+ * @NL80211_SCAN_FLAG_RANDOM_ADDR: use a random MAC address for this scan (or
4241+ * for scheduled scan: a different one for every scan iteration). When the
4242+ * flag is set, depending on device capabilities the @NL80211_ATTR_MAC and
4243+ * @NL80211_ATTR_MAC_MASK attributes may also be given in which case only
4244+ * the masked bits will be preserved from the MAC address and the remainder
4245+ * randomised. If the attributes are not given full randomisation (46 bits,
4246+ * locally administered 1, multicast 0) is assumed.
4247+ * This flag must not be requested when the feature isn't supported, check
4248+ * the nl80211 feature flags for the device.
42214249 */
42224250 enum nl80211_scan_flags {
42234251 NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0,
42244252 NL80211_SCAN_FLAG_FLUSH = 1<<1,
42254253 NL80211_SCAN_FLAG_AP = 1<<2,
4254+ NL80211_SCAN_FLAG_RANDOM_ADDR = 1<<3,
42264255 };
42274256
42284257 /**