Search Linux Wireless

[RFC 13/15] nl80211: add ssid filtering support to the periodic scan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Parse and add ssids information to the periodic scan request.

Signed-off-by: Luciano Coelho <luciano.coelho@xxxxxxxxx>
---
 net/wireless/nl80211.c |   38 +++++++++++++++++++++++++++++++++-----
 1 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d5b9047..5ae5935 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3004,10 +3004,11 @@ static int nl80211_start_periodic(struct sk_buff *skb,
 	struct cfg80211_periodic_request *request;
 	struct cfg80211_registered_device *rdev;
 	struct net_device *dev;
+	struct cfg80211_ssid *ssid;
 	struct ieee80211_channel *channel;
 	struct nlattr *attr;
 	struct wiphy *wiphy;
-	int err, tmp, n_channels, i;
+	int err, tmp, n_ssids = 0, n_channels, i;
 	enum ieee80211_band band;
 
 	printk("nl80211_start_periodic\n");
@@ -3048,7 +3049,17 @@ static int nl80211_start_periodic(struct sk_buff *skb,
 				n_channels += wiphy->bands[band]->n_channels;
 	}
 
+	if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
+		nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp)
+			n_ssids++;
+
+	if (n_ssids > wiphy->max_periodic_ssids) {
+		err = -EINVAL;
+		goto out ;
+	}
+
 	request = kzalloc(sizeof(*request)
+			  + sizeof(*ssid) * n_ssids
 			  + sizeof(channel) * n_channels,
 			  GFP_KERNEL);
 	if (!request) {
@@ -3056,10 +3067,9 @@ static int nl80211_start_periodic(struct sk_buff *skb,
 		goto out;
 	}
 
-	request->dev = dev;
-	request->wiphy = &rdev->wiphy;
-
-	rdev->periodic_req = request;
+	if (n_ssids)
+		request->ssids = (void *)&request->channels[n_channels];
+	request->n_ssids = n_ssids;
 
 	i = 0;
 	if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
@@ -3108,6 +3118,24 @@ static int nl80211_start_periodic(struct sk_buff *skb,
 
 	request->n_channels = i;
 
+	i = 0;
+	if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
+		nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {
+			if (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) {
+				err = -EINVAL;
+				goto out_free;
+			}
+			memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));
+			request->ssids[i].ssid_len = nla_len(attr);
+			i++;
+		}
+	}
+
+	request->dev = dev;
+	request->wiphy = &rdev->wiphy;
+
+	rdev->periodic_req = request;
+
 	err = rdev->ops->periodic_start(&rdev->wiphy, dev, request);
 	if (err) {
 out_free:
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux