blob: a56287bb550c0223db1ee7dc7f87a93466a38714 [file] [log] [blame]
Johannes Berg2a519312009-02-10 21:25:55 +01001/*
2 * cfg80211 scan result handling
3 *
4 * Copyright 2008 Johannes Berg <johannes@sipsolutions.net>
5 */
6#include <linux/kernel.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09007#include <linux/slab.h>
Johannes Berg2a519312009-02-10 21:25:55 +01008#include <linux/module.h>
9#include <linux/netdevice.h>
10#include <linux/wireless.h>
11#include <linux/nl80211.h>
12#include <linux/etherdevice.h>
13#include <net/arp.h>
14#include <net/cfg80211.h>
Johannes Berg262eb9b22011-07-13 10:39:09 +020015#include <net/cfg80211-wext.h>
Johannes Berg2a519312009-02-10 21:25:55 +010016#include <net/iw_handler.h>
17#include "core.h"
18#include "nl80211.h"
Johannes Berga9a11622009-07-27 12:01:53 +020019#include "wext-compat.h"
Hila Gonene35e4d22012-06-27 17:19:42 +030020#include "rdev-ops.h"
Johannes Berg2a519312009-02-10 21:25:55 +010021
Rajkumar Manoharanf9616e02012-04-13 16:38:40 +053022#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)
Johannes Berg2a519312009-02-10 21:25:55 +010023
Amitkumar Karware8e27c62012-10-11 21:03:33 -070024static void bss_release(struct kref *ref)
25{
Johannes Berg9caf0362012-11-29 01:25:20 +010026 struct cfg80211_bss_ies *ies;
Amitkumar Karware8e27c62012-10-11 21:03:33 -070027 struct cfg80211_internal_bss *bss;
28
29 bss = container_of(ref, struct cfg80211_internal_bss, ref);
Johannes Bergb629ea32012-11-28 22:14:56 +010030
31 if (WARN_ON(atomic_read(&bss->hold)))
32 return;
33
Johannes Berg9caf0362012-11-29 01:25:20 +010034 ies = (void *)rcu_access_pointer(bss->pub.beacon_ies);
35 if (ies)
36 kfree_rcu(ies, rcu_head);
37 ies = (void *)rcu_access_pointer(bss->pub.proberesp_ies);
38 if (ies)
39 kfree_rcu(ies, rcu_head);
Amitkumar Karware8e27c62012-10-11 21:03:33 -070040
Amitkumar Karware8e27c62012-10-11 21:03:33 -070041 kfree(bss);
42}
43
Amitkumar Karware8e27c62012-10-11 21:03:33 -070044static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
45 struct cfg80211_internal_bss *bss)
46{
Johannes Berg4b1af472013-02-01 01:05:43 +010047 lockdep_assert_held(&dev->bss_lock);
48
Amitkumar Karware8e27c62012-10-11 21:03:33 -070049 list_del_init(&bss->list);
50 rb_erase(&bss->rbn, &dev->bss_tree);
51 kref_put(&bss->ref, bss_release);
52}
53
Sam Leffler15d60302012-10-11 21:03:34 -070054static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev,
55 unsigned long expire_time)
56{
57 struct cfg80211_internal_bss *bss, *tmp;
58 bool expired = false;
59
Johannes Berg4b1af472013-02-01 01:05:43 +010060 lockdep_assert_held(&dev->bss_lock);
61
Sam Leffler15d60302012-10-11 21:03:34 -070062 list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
63 if (atomic_read(&bss->hold))
64 continue;
65 if (!time_after(expire_time, bss->ts))
66 continue;
67
68 __cfg80211_unlink_bss(dev, bss);
69 expired = true;
70 }
71
72 if (expired)
73 dev->bss_generation++;
74}
75
Johannes Berg01a0ac42009-08-20 21:36:16 +020076void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
Johannes Berg2a519312009-02-10 21:25:55 +010077{
Johannes Berg667503d2009-07-07 03:56:11 +020078 struct cfg80211_scan_request *request;
Johannes Bergfd014282012-06-18 19:17:03 +020079 struct wireless_dev *wdev;
Johannes Berg3d23e342009-09-29 23:27:28 +020080#ifdef CONFIG_CFG80211_WEXT
Johannes Berg2a519312009-02-10 21:25:55 +010081 union iwreq_data wrqu;
82#endif
83
Johannes Berg01a0ac42009-08-20 21:36:16 +020084 ASSERT_RDEV_LOCK(rdev);
85
Johannes Berg667503d2009-07-07 03:56:11 +020086 request = rdev->scan_req;
87
Johannes Berg01a0ac42009-08-20 21:36:16 +020088 if (!request)
89 return;
90
Johannes Bergfd014282012-06-18 19:17:03 +020091 wdev = request->wdev;
Johannes Berg2a519312009-02-10 21:25:55 +010092
Johannes Berg6829c872009-07-02 09:13:27 +020093 /*
94 * This must be before sending the other events!
95 * Otherwise, wpa_supplicant gets completely confused with
96 * wext events.
97 */
Johannes Bergfd014282012-06-18 19:17:03 +020098 if (wdev->netdev)
99 cfg80211_sme_scan_done(wdev->netdev);
Johannes Berg6829c872009-07-02 09:13:27 +0200100
Sam Leffler15d60302012-10-11 21:03:34 -0700101 if (request->aborted) {
Johannes Bergfd014282012-06-18 19:17:03 +0200102 nl80211_send_scan_aborted(rdev, wdev);
Sam Leffler15d60302012-10-11 21:03:34 -0700103 } else {
104 if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
105 /* flush entries from previous scans */
106 spin_lock_bh(&rdev->bss_lock);
107 __cfg80211_bss_expire(rdev, request->scan_start);
108 spin_unlock_bh(&rdev->bss_lock);
109 }
Johannes Bergfd014282012-06-18 19:17:03 +0200110 nl80211_send_scan_done(rdev, wdev);
Sam Leffler15d60302012-10-11 21:03:34 -0700111 }
Johannes Berg2a519312009-02-10 21:25:55 +0100112
Johannes Berg3d23e342009-09-29 23:27:28 +0200113#ifdef CONFIG_CFG80211_WEXT
Johannes Bergfd014282012-06-18 19:17:03 +0200114 if (wdev->netdev && !request->aborted) {
Johannes Berg2a519312009-02-10 21:25:55 +0100115 memset(&wrqu, 0, sizeof(wrqu));
116
Johannes Bergfd014282012-06-18 19:17:03 +0200117 wireless_send_event(wdev->netdev, SIOCGIWSCAN, &wrqu, NULL);
Johannes Berg2a519312009-02-10 21:25:55 +0100118 }
119#endif
120
Johannes Bergfd014282012-06-18 19:17:03 +0200121 if (wdev->netdev)
122 dev_put(wdev->netdev);
Johannes Berg2a519312009-02-10 21:25:55 +0100123
Johannes Berg36e6fea2009-08-12 22:21:21 +0200124 rdev->scan_req = NULL;
Johannes Berg01a0ac42009-08-20 21:36:16 +0200125
126 /*
127 * OK. If this is invoked with "leak" then we can't
128 * free this ... but we've cleaned it up anyway. The
129 * driver failed to call the scan_done callback, so
130 * all bets are off, it might still be trying to use
131 * the scan request or not ... if it accesses the dev
132 * in there (it shouldn't anyway) then it may crash.
133 */
134 if (!leak)
135 kfree(request);
Johannes Berg2a519312009-02-10 21:25:55 +0100136}
Johannes Berg667503d2009-07-07 03:56:11 +0200137
Johannes Berg36e6fea2009-08-12 22:21:21 +0200138void __cfg80211_scan_done(struct work_struct *wk)
139{
140 struct cfg80211_registered_device *rdev;
141
142 rdev = container_of(wk, struct cfg80211_registered_device,
143 scan_done_wk);
144
145 cfg80211_lock_rdev(rdev);
Johannes Berg01a0ac42009-08-20 21:36:16 +0200146 ___cfg80211_scan_done(rdev, false);
Johannes Berg36e6fea2009-08-12 22:21:21 +0200147 cfg80211_unlock_rdev(rdev);
148}
149
Johannes Berg667503d2009-07-07 03:56:11 +0200150void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted)
151{
Beni Lev4ee3e062012-08-27 12:49:39 +0300152 trace_cfg80211_scan_done(request, aborted);
Johannes Berg667503d2009-07-07 03:56:11 +0200153 WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req);
154
155 request->aborted = aborted;
Alban Browaeyse60d7442009-11-25 15:13:00 +0100156 queue_work(cfg80211_wq, &wiphy_to_dev(request->wiphy)->scan_done_wk);
Johannes Berg667503d2009-07-07 03:56:11 +0200157}
Johannes Berg2a519312009-02-10 21:25:55 +0100158EXPORT_SYMBOL(cfg80211_scan_done);
159
Luciano Coelho807f8a82011-05-11 17:09:35 +0300160void __cfg80211_sched_scan_results(struct work_struct *wk)
161{
162 struct cfg80211_registered_device *rdev;
Sam Leffler15d60302012-10-11 21:03:34 -0700163 struct cfg80211_sched_scan_request *request;
Luciano Coelho807f8a82011-05-11 17:09:35 +0300164
165 rdev = container_of(wk, struct cfg80211_registered_device,
166 sched_scan_results_wk);
167
Sam Leffler15d60302012-10-11 21:03:34 -0700168 request = rdev->sched_scan_req;
169
Luciano Coelhoc10841c2011-06-30 08:32:41 +0300170 mutex_lock(&rdev->sched_scan_mtx);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300171
172 /* we don't have sched_scan_req anymore if the scan is stopping */
Sam Leffler15d60302012-10-11 21:03:34 -0700173 if (request) {
174 if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
175 /* flush entries from previous scans */
176 spin_lock_bh(&rdev->bss_lock);
177 __cfg80211_bss_expire(rdev, request->scan_start);
178 spin_unlock_bh(&rdev->bss_lock);
179 request->scan_start =
180 jiffies + msecs_to_jiffies(request->interval);
181 }
182 nl80211_send_sched_scan_results(rdev, request->dev);
183 }
Luciano Coelho807f8a82011-05-11 17:09:35 +0300184
Luciano Coelhoc10841c2011-06-30 08:32:41 +0300185 mutex_unlock(&rdev->sched_scan_mtx);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300186}
187
188void cfg80211_sched_scan_results(struct wiphy *wiphy)
189{
Beni Lev4ee3e062012-08-27 12:49:39 +0300190 trace_cfg80211_sched_scan_results(wiphy);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300191 /* ignore if we're not scanning */
192 if (wiphy_to_dev(wiphy)->sched_scan_req)
193 queue_work(cfg80211_wq,
194 &wiphy_to_dev(wiphy)->sched_scan_results_wk);
195}
196EXPORT_SYMBOL(cfg80211_sched_scan_results);
197
Luciano Coelho85a99942011-05-12 16:28:29 +0300198void cfg80211_sched_scan_stopped(struct wiphy *wiphy)
Luciano Coelho807f8a82011-05-11 17:09:35 +0300199{
Luciano Coelho85a99942011-05-12 16:28:29 +0300200 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300201
Beni Lev4ee3e062012-08-27 12:49:39 +0300202 trace_cfg80211_sched_scan_stopped(wiphy);
203
Luciano Coelhoc10841c2011-06-30 08:32:41 +0300204 mutex_lock(&rdev->sched_scan_mtx);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300205 __cfg80211_stop_sched_scan(rdev, true);
Luciano Coelhoc10841c2011-06-30 08:32:41 +0300206 mutex_unlock(&rdev->sched_scan_mtx);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300207}
Luciano Coelho807f8a82011-05-11 17:09:35 +0300208EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
209
210int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
211 bool driver_initiated)
212{
Luciano Coelho807f8a82011-05-11 17:09:35 +0300213 struct net_device *dev;
214
Luciano Coelhoc10841c2011-06-30 08:32:41 +0300215 lockdep_assert_held(&rdev->sched_scan_mtx);
Luciano Coelho807f8a82011-05-11 17:09:35 +0300216
217 if (!rdev->sched_scan_req)
Luciano Coelho1a84ff72011-07-08 11:16:16 +0300218 return -ENOENT;
Luciano Coelho807f8a82011-05-11 17:09:35 +0300219
220 dev = rdev->sched_scan_req->dev;
221
Luciano Coelho85a99942011-05-12 16:28:29 +0300222 if (!driver_initiated) {
Hila Gonene35e4d22012-06-27 17:19:42 +0300223 int err = rdev_sched_scan_stop(rdev, dev);
Luciano Coelho85a99942011-05-12 16:28:29 +0300224 if (err)
225 return err;
226 }
Luciano Coelho807f8a82011-05-11 17:09:35 +0300227
228 nl80211_send_sched_scan(rdev, dev, NL80211_CMD_SCHED_SCAN_STOPPED);
229
230 kfree(rdev->sched_scan_req);
231 rdev->sched_scan_req = NULL;
232
Jesper Juhl3b4670f2011-06-29 22:49:33 +0200233 return 0;
Luciano Coelho807f8a82011-05-11 17:09:35 +0300234}
235
Dan Williamscb3a8ee2009-02-11 17:14:43 -0500236void cfg80211_bss_age(struct cfg80211_registered_device *dev,
237 unsigned long age_secs)
238{
239 struct cfg80211_internal_bss *bss;
240 unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC);
241
Johannes Berg2ca813a2013-02-01 01:04:14 +0100242 spin_lock_bh(&dev->bss_lock);
Johannes Berg915de2f2012-11-28 22:39:37 +0100243 list_for_each_entry(bss, &dev->bss_list, list)
Dan Williamscb3a8ee2009-02-11 17:14:43 -0500244 bss->ts -= age_jiffies;
Johannes Berg2ca813a2013-02-01 01:04:14 +0100245 spin_unlock_bh(&dev->bss_lock);
Dan Williamscb3a8ee2009-02-11 17:14:43 -0500246}
247
Johannes Berg2a519312009-02-10 21:25:55 +0100248void cfg80211_bss_expire(struct cfg80211_registered_device *dev)
249{
Sam Leffler15d60302012-10-11 21:03:34 -0700250 __cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
Johannes Berg2a519312009-02-10 21:25:55 +0100251}
252
Johannes Bergc21dbf92010-01-26 14:15:46 +0100253const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
Johannes Berg2a519312009-02-10 21:25:55 +0100254{
Johannes Bergc21dbf92010-01-26 14:15:46 +0100255 while (len > 2 && ies[0] != eid) {
Johannes Berg2a519312009-02-10 21:25:55 +0100256 len -= ies[1] + 2;
257 ies += ies[1] + 2;
258 }
259 if (len < 2)
260 return NULL;
261 if (len < 2 + ies[1])
262 return NULL;
263 return ies;
264}
Johannes Bergc21dbf92010-01-26 14:15:46 +0100265EXPORT_SYMBOL(cfg80211_find_ie);
Johannes Berg2a519312009-02-10 21:25:55 +0100266
Eliad Peller0c28ec52011-09-15 11:53:01 +0300267const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type,
268 const u8 *ies, int len)
269{
270 struct ieee80211_vendor_ie *ie;
271 const u8 *pos = ies, *end = ies + len;
272 int ie_oui;
273
274 while (pos < end) {
275 pos = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, pos,
276 end - pos);
277 if (!pos)
278 return NULL;
279
280 if (end - pos < sizeof(*ie))
281 return NULL;
282
283 ie = (struct ieee80211_vendor_ie *)pos;
284 ie_oui = ie->oui[0] << 16 | ie->oui[1] << 8 | ie->oui[2];
285 if (ie_oui == oui && ie->oui_type == oui_type)
286 return pos;
287
288 pos += 2 + ie->len;
289 }
290 return NULL;
291}
292EXPORT_SYMBOL(cfg80211_find_vendor_ie);
293
Johannes Berg915de2f2012-11-28 22:39:37 +0100294static bool is_bss(struct cfg80211_bss *a, const u8 *bssid,
Johannes Berg2a519312009-02-10 21:25:55 +0100295 const u8 *ssid, size_t ssid_len)
296{
Johannes Berg9caf0362012-11-29 01:25:20 +0100297 const struct cfg80211_bss_ies *ies;
Johannes Berg2a519312009-02-10 21:25:55 +0100298 const u8 *ssidie;
299
Joe Perchesac422d32012-05-08 18:56:55 +0000300 if (bssid && !ether_addr_equal(a->bssid, bssid))
Johannes Berg2a519312009-02-10 21:25:55 +0100301 return false;
302
Johannes Berg79420f02009-02-10 21:25:59 +0100303 if (!ssid)
304 return true;
305
Johannes Berg9caf0362012-11-29 01:25:20 +0100306 ies = rcu_access_pointer(a->ies);
307 if (!ies)
308 return false;
309 ssidie = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len);
Johannes Berg2a519312009-02-10 21:25:55 +0100310 if (!ssidie)
311 return false;
312 if (ssidie[1] != ssid_len)
313 return false;
314 return memcmp(ssidie + 2, ssid, ssid_len) == 0;
315}
316
Johannes Berg4593c4c2013-02-01 19:20:03 +0100317/**
318 * enum bss_compare_mode - BSS compare mode
319 * @BSS_CMP_REGULAR: regular compare mode (for insertion and normal find)
320 * @BSS_CMP_HIDE_ZLEN: find hidden SSID with zero-length mode
321 * @BSS_CMP_HIDE_NUL: find hidden SSID with NUL-ed out mode
322 */
323enum bss_compare_mode {
324 BSS_CMP_REGULAR,
325 BSS_CMP_HIDE_ZLEN,
326 BSS_CMP_HIDE_NUL,
327};
328
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100329static int cmp_bss(struct cfg80211_bss *a,
Johannes Berg5622f5b2013-01-30 00:26:45 +0100330 struct cfg80211_bss *b,
Johannes Berg4593c4c2013-02-01 19:20:03 +0100331 enum bss_compare_mode mode)
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100332{
Johannes Berg9caf0362012-11-29 01:25:20 +0100333 const struct cfg80211_bss_ies *a_ies, *b_ies;
Johannes Berg3af63412013-01-30 00:40:20 +0100334 const u8 *ie1 = NULL;
335 const u8 *ie2 = NULL;
Johannes Berg5622f5b2013-01-30 00:26:45 +0100336 int i, r;
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100337
Johannes Berg3af63412013-01-30 00:40:20 +0100338 if (a->channel != b->channel)
339 return b->channel->center_freq - a->channel->center_freq;
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100340
Johannes Berg9caf0362012-11-29 01:25:20 +0100341 a_ies = rcu_access_pointer(a->ies);
342 if (!a_ies)
343 return -1;
344 b_ies = rcu_access_pointer(b->ies);
345 if (!b_ies)
346 return 1;
347
Johannes Berg3af63412013-01-30 00:40:20 +0100348 if (WLAN_CAPABILITY_IS_STA_BSS(a->capability))
349 ie1 = cfg80211_find_ie(WLAN_EID_MESH_ID,
350 a_ies->data, a_ies->len);
351 if (WLAN_CAPABILITY_IS_STA_BSS(b->capability))
352 ie2 = cfg80211_find_ie(WLAN_EID_MESH_ID,
353 b_ies->data, b_ies->len);
354 if (ie1 && ie2) {
355 int mesh_id_cmp;
356
357 if (ie1[1] == ie2[1])
358 mesh_id_cmp = memcmp(ie1 + 2, ie2 + 2, ie1[1]);
359 else
360 mesh_id_cmp = ie2[1] - ie1[1];
361
362 ie1 = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
363 a_ies->data, a_ies->len);
364 ie2 = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
365 b_ies->data, b_ies->len);
366 if (ie1 && ie2) {
367 if (mesh_id_cmp)
368 return mesh_id_cmp;
369 if (ie1[1] != ie2[1])
370 return ie2[1] - ie1[1];
371 return memcmp(ie1 + 2, ie2 + 2, ie1[1]);
372 }
373 }
374
375 /*
376 * we can't use compare_ether_addr here since we need a < > operator.
377 * The binary return value of compare_ether_addr isn't enough
378 */
379 r = memcmp(a->bssid, b->bssid, sizeof(a->bssid));
380 if (r)
381 return r;
382
Johannes Berg9caf0362012-11-29 01:25:20 +0100383 ie1 = cfg80211_find_ie(WLAN_EID_SSID, a_ies->data, a_ies->len);
384 ie2 = cfg80211_find_ie(WLAN_EID_SSID, b_ies->data, b_ies->len);
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100385
Johannes Berg5622f5b2013-01-30 00:26:45 +0100386 if (!ie1 && !ie2)
387 return 0;
388
Johannes Bergf94f8b12012-11-28 22:42:34 +0100389 /*
Johannes Berg5622f5b2013-01-30 00:26:45 +0100390 * Note that with "hide_ssid", the function returns a match if
391 * the already-present BSS ("b") is a hidden SSID beacon for
392 * the new BSS ("a").
Johannes Bergf94f8b12012-11-28 22:42:34 +0100393 */
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100394
395 /* sort missing IE before (left of) present IE */
396 if (!ie1)
397 return -1;
398 if (!ie2)
399 return 1;
400
Johannes Berg4593c4c2013-02-01 19:20:03 +0100401 switch (mode) {
402 case BSS_CMP_HIDE_ZLEN:
403 /*
404 * In ZLEN mode we assume the BSS entry we're
405 * looking for has a zero-length SSID. So if
406 * the one we're looking at right now has that,
407 * return 0. Otherwise, return the difference
408 * in length, but since we're looking for the
409 * 0-length it's really equivalent to returning
410 * the length of the one we're looking at.
411 *
412 * No content comparison is needed as we assume
413 * the content length is zero.
414 */
415 return ie2[1];
416 case BSS_CMP_REGULAR:
417 default:
418 /* sort by length first, then by contents */
419 if (ie1[1] != ie2[1])
420 return ie2[1] - ie1[1];
Johannes Berg5622f5b2013-01-30 00:26:45 +0100421 return memcmp(ie1 + 2, ie2 + 2, ie1[1]);
Johannes Berg4593c4c2013-02-01 19:20:03 +0100422 case BSS_CMP_HIDE_NUL:
423 if (ie1[1] != ie2[1])
424 return ie2[1] - ie1[1];
425 /* this is equivalent to memcmp(zeroes, ie2 + 2, len) */
426 for (i = 0; i < ie2[1]; i++)
427 if (ie2[i + 2])
428 return -1;
429 return 0;
430 }
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100431}
432
Johannes Berg2a519312009-02-10 21:25:55 +0100433struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
434 struct ieee80211_channel *channel,
435 const u8 *bssid,
Johannes Berg79420f02009-02-10 21:25:59 +0100436 const u8 *ssid, size_t ssid_len,
437 u16 capa_mask, u16 capa_val)
Johannes Berg2a519312009-02-10 21:25:55 +0100438{
439 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
440 struct cfg80211_internal_bss *bss, *res = NULL;
Johannes Bergccb6c132010-07-13 10:55:38 +0200441 unsigned long now = jiffies;
Johannes Berg2a519312009-02-10 21:25:55 +0100442
Beni Lev4ee3e062012-08-27 12:49:39 +0300443 trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask,
444 capa_val);
445
Johannes Berg2a519312009-02-10 21:25:55 +0100446 spin_lock_bh(&dev->bss_lock);
447
448 list_for_each_entry(bss, &dev->bss_list, list) {
Johannes Berg79420f02009-02-10 21:25:59 +0100449 if ((bss->pub.capability & capa_mask) != capa_val)
450 continue;
Johannes Berg2a519312009-02-10 21:25:55 +0100451 if (channel && bss->pub.channel != channel)
452 continue;
Johannes Bergccb6c132010-07-13 10:55:38 +0200453 /* Don't get expired BSS structs */
454 if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) &&
455 !atomic_read(&bss->hold))
456 continue;
Johannes Berg2a519312009-02-10 21:25:55 +0100457 if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {
458 res = bss;
459 kref_get(&res->ref);
460 break;
461 }
462 }
463
464 spin_unlock_bh(&dev->bss_lock);
465 if (!res)
466 return NULL;
Beni Lev4ee3e062012-08-27 12:49:39 +0300467 trace_cfg80211_return_bss(&res->pub);
Johannes Berg2a519312009-02-10 21:25:55 +0100468 return &res->pub;
469}
470EXPORT_SYMBOL(cfg80211_get_bss);
471
Johannes Berg2a519312009-02-10 21:25:55 +0100472static void rb_insert_bss(struct cfg80211_registered_device *dev,
473 struct cfg80211_internal_bss *bss)
474{
475 struct rb_node **p = &dev->bss_tree.rb_node;
476 struct rb_node *parent = NULL;
477 struct cfg80211_internal_bss *tbss;
478 int cmp;
479
480 while (*p) {
481 parent = *p;
482 tbss = rb_entry(parent, struct cfg80211_internal_bss, rbn);
483
Johannes Berg4593c4c2013-02-01 19:20:03 +0100484 cmp = cmp_bss(&bss->pub, &tbss->pub, BSS_CMP_REGULAR);
Johannes Berg2a519312009-02-10 21:25:55 +0100485
486 if (WARN_ON(!cmp)) {
487 /* will sort of leak this BSS */
488 return;
489 }
490
491 if (cmp < 0)
492 p = &(*p)->rb_left;
493 else
494 p = &(*p)->rb_right;
495 }
496
497 rb_link_node(&bss->rbn, parent, p);
498 rb_insert_color(&bss->rbn, &dev->bss_tree);
499}
500
501static struct cfg80211_internal_bss *
502rb_find_bss(struct cfg80211_registered_device *dev,
Johannes Berg5622f5b2013-01-30 00:26:45 +0100503 struct cfg80211_internal_bss *res,
Johannes Berg4593c4c2013-02-01 19:20:03 +0100504 enum bss_compare_mode mode)
Johannes Berg2a519312009-02-10 21:25:55 +0100505{
506 struct rb_node *n = dev->bss_tree.rb_node;
507 struct cfg80211_internal_bss *bss;
508 int r;
509
510 while (n) {
511 bss = rb_entry(n, struct cfg80211_internal_bss, rbn);
Johannes Berg4593c4c2013-02-01 19:20:03 +0100512 r = cmp_bss(&res->pub, &bss->pub, mode);
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100513
514 if (r == 0)
515 return bss;
516 else if (r < 0)
517 n = n->rb_left;
518 else
519 n = n->rb_right;
520 }
521
522 return NULL;
523}
524
525static void
526copy_hidden_ies(struct cfg80211_internal_bss *res,
Johannes Berg915de2f2012-11-28 22:39:37 +0100527 struct cfg80211_internal_bss *hidden)
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100528{
Johannes Berg9caf0362012-11-29 01:25:20 +0100529 const struct cfg80211_bss_ies *ies;
530
531 if (rcu_access_pointer(res->pub.beacon_ies))
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100532 return;
533
Johannes Berg9caf0362012-11-29 01:25:20 +0100534 ies = rcu_access_pointer(hidden->pub.beacon_ies);
535 if (WARN_ON(!ies))
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100536 return;
537
Johannes Berg9caf0362012-11-29 01:25:20 +0100538 ies = kmemdup(ies, sizeof(*ies) + ies->len, GFP_ATOMIC);
539 if (unlikely(!ies))
540 return;
541 rcu_assign_pointer(res->pub.beacon_ies, ies);
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100542}
543
544static struct cfg80211_internal_bss *
Johannes Berg2a519312009-02-10 21:25:55 +0100545cfg80211_bss_update(struct cfg80211_registered_device *dev,
Johannes Berg9caf0362012-11-29 01:25:20 +0100546 struct cfg80211_internal_bss *tmp)
Johannes Berg2a519312009-02-10 21:25:55 +0100547{
548 struct cfg80211_internal_bss *found = NULL;
Johannes Berg2a519312009-02-10 21:25:55 +0100549
Johannes Berg9caf0362012-11-29 01:25:20 +0100550 if (WARN_ON(!tmp->pub.channel))
Johannes Berg2a519312009-02-10 21:25:55 +0100551 return NULL;
Johannes Berg2a519312009-02-10 21:25:55 +0100552
Johannes Berg9caf0362012-11-29 01:25:20 +0100553 tmp->ts = jiffies;
Johannes Berg2a519312009-02-10 21:25:55 +0100554
Johannes Berg2a519312009-02-10 21:25:55 +0100555 spin_lock_bh(&dev->bss_lock);
556
Johannes Berg9caf0362012-11-29 01:25:20 +0100557 if (WARN_ON(!rcu_access_pointer(tmp->pub.ies))) {
558 spin_unlock_bh(&dev->bss_lock);
559 return NULL;
560 }
561
Johannes Berg4593c4c2013-02-01 19:20:03 +0100562 found = rb_find_bss(dev, tmp, BSS_CMP_REGULAR);
Johannes Berg2a519312009-02-10 21:25:55 +0100563
Johannes Bergcd1658f2009-04-16 15:00:58 +0200564 if (found) {
Johannes Berg9caf0362012-11-29 01:25:20 +0100565 found->pub.beacon_interval = tmp->pub.beacon_interval;
566 found->pub.tsf = tmp->pub.tsf;
567 found->pub.signal = tmp->pub.signal;
568 found->pub.capability = tmp->pub.capability;
569 found->ts = tmp->ts;
Johannes Bergcd1658f2009-04-16 15:00:58 +0200570
Jouni Malinen34a6edd2010-01-06 16:19:24 +0200571 /* Update IEs */
Johannes Berg9caf0362012-11-29 01:25:20 +0100572 if (rcu_access_pointer(tmp->pub.proberesp_ies)) {
573 const struct cfg80211_bss_ies *old;
Johannes Bergcd1658f2009-04-16 15:00:58 +0200574
Johannes Berg9caf0362012-11-29 01:25:20 +0100575 old = rcu_access_pointer(found->pub.proberesp_ies);
Johannes Bergcd1658f2009-04-16 15:00:58 +0200576
Johannes Berg9caf0362012-11-29 01:25:20 +0100577 rcu_assign_pointer(found->pub.proberesp_ies,
578 tmp->pub.proberesp_ies);
Jouni Malinen34a6edd2010-01-06 16:19:24 +0200579 /* Override possible earlier Beacon frame IEs */
Johannes Berg9caf0362012-11-29 01:25:20 +0100580 rcu_assign_pointer(found->pub.ies,
581 tmp->pub.proberesp_ies);
582 if (old)
583 kfree_rcu((struct cfg80211_bss_ies *)old,
584 rcu_head);
585 } else if (rcu_access_pointer(tmp->pub.beacon_ies)) {
586 const struct cfg80211_bss_ies *old, *ies;
Johannes Berg915de2f2012-11-28 22:39:37 +0100587
Johannes Berg9caf0362012-11-29 01:25:20 +0100588 old = rcu_access_pointer(found->pub.beacon_ies);
589 ies = rcu_access_pointer(found->pub.ies);
Jouni Malinen34a6edd2010-01-06 16:19:24 +0200590
Johannes Berg9caf0362012-11-29 01:25:20 +0100591 rcu_assign_pointer(found->pub.beacon_ies,
592 tmp->pub.beacon_ies);
Sven Neumann01123e22010-12-09 15:05:24 +0100593
594 /* Override IEs if they were from a beacon before */
Johannes Berg9caf0362012-11-29 01:25:20 +0100595 if (old == ies)
596 rcu_assign_pointer(found->pub.ies,
597 tmp->pub.beacon_ies);
Johannes Bergcd1658f2009-04-16 15:00:58 +0200598
Johannes Berg9caf0362012-11-29 01:25:20 +0100599 if (old)
600 kfree_rcu((struct cfg80211_bss_ies *)old,
601 rcu_head);
602 }
Johannes Berg2a519312009-02-10 21:25:55 +0100603 } else {
Johannes Berg9caf0362012-11-29 01:25:20 +0100604 struct cfg80211_internal_bss *new;
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100605 struct cfg80211_internal_bss *hidden;
Johannes Berg9caf0362012-11-29 01:25:20 +0100606 struct cfg80211_bss_ies *ies;
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100607
608 /* First check if the beacon is a probe response from
609 * a hidden bss. If so, copy beacon ies (with nullified
610 * ssid) into the probe response bss entry (with real ssid).
611 * It is required basically for PSM implementation
612 * (probe responses do not contain tim ie) */
613
614 /* TODO: The code is not trying to update existing probe
615 * response bss entries when beacon ies are
616 * getting changed. */
Johannes Berg4593c4c2013-02-01 19:20:03 +0100617 hidden = rb_find_bss(dev, tmp, BSS_CMP_HIDE_ZLEN);
618 if (hidden) {
Johannes Berg9caf0362012-11-29 01:25:20 +0100619 copy_hidden_ies(tmp, hidden);
Johannes Berg4593c4c2013-02-01 19:20:03 +0100620 } else {
621 hidden = rb_find_bss(dev, tmp, BSS_CMP_HIDE_NUL);
622 if (hidden)
623 copy_hidden_ies(tmp, hidden);
624 }
Dmitry Tarnyagindd9dfb92011-11-04 17:12:07 +0100625
Johannes Berg9caf0362012-11-29 01:25:20 +0100626 /*
627 * create a copy -- the "res" variable that is passed in
628 * is allocated on the stack since it's not needed in the
629 * more common case of an update
630 */
631 new = kzalloc(sizeof(*new) + dev->wiphy.bss_priv_size,
632 GFP_ATOMIC);
633 if (!new) {
634 ies = (void *)rcu_dereference(tmp->pub.beacon_ies);
635 if (ies)
636 kfree_rcu(ies, rcu_head);
637 ies = (void *)rcu_dereference(tmp->pub.proberesp_ies);
638 if (ies)
639 kfree_rcu(ies, rcu_head);
640 spin_unlock_bh(&dev->bss_lock);
641 return NULL;
642 }
643 memcpy(new, tmp, sizeof(*new));
644 kref_init(&new->ref);
645 list_add_tail(&new->list, &dev->bss_list);
646 rb_insert_bss(dev, new);
647 found = new;
Johannes Berg2a519312009-02-10 21:25:55 +0100648 }
649
650 dev->bss_generation++;
651 spin_unlock_bh(&dev->bss_lock);
652
653 kref_get(&found->ref);
654 return found;
655}
656
Johannes Berg0172bb72012-11-23 14:23:30 +0100657static struct ieee80211_channel *
658cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen,
659 struct ieee80211_channel *channel)
660{
661 const u8 *tmp;
662 u32 freq;
663 int channel_number = -1;
664
665 tmp = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ie, ielen);
666 if (tmp && tmp[1] == 1) {
667 channel_number = tmp[2];
668 } else {
669 tmp = cfg80211_find_ie(WLAN_EID_HT_OPERATION, ie, ielen);
670 if (tmp && tmp[1] >= sizeof(struct ieee80211_ht_operation)) {
671 struct ieee80211_ht_operation *htop = (void *)(tmp + 2);
672
673 channel_number = htop->primary_chan;
674 }
675 }
676
677 if (channel_number < 0)
678 return channel;
679
680 freq = ieee80211_channel_to_frequency(channel_number, channel->band);
681 channel = ieee80211_get_channel(wiphy, freq);
682 if (!channel)
683 return NULL;
684 if (channel->flags & IEEE80211_CHAN_DISABLED)
685 return NULL;
686 return channel;
687}
688
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200689struct cfg80211_bss*
690cfg80211_inform_bss(struct wiphy *wiphy,
691 struct ieee80211_channel *channel,
Johannes Berg7b8bcff2012-03-13 13:57:04 +0100692 const u8 *bssid, u64 tsf, u16 capability,
693 u16 beacon_interval, const u8 *ie, size_t ielen,
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200694 s32 signal, gfp_t gfp)
695{
Johannes Berg9caf0362012-11-29 01:25:20 +0100696 struct cfg80211_bss_ies *ies;
697 struct cfg80211_internal_bss tmp = {}, *res;
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200698
699 if (WARN_ON(!wiphy))
700 return NULL;
701
Sujith22fe88d2010-05-13 10:34:08 +0530702 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200703 (signal < 0 || signal > 100)))
704 return NULL;
705
Johannes Berg0172bb72012-11-23 14:23:30 +0100706 channel = cfg80211_get_bss_channel(wiphy, ie, ielen, channel);
707 if (!channel)
708 return NULL;
709
Johannes Berg9caf0362012-11-29 01:25:20 +0100710 memcpy(tmp.pub.bssid, bssid, ETH_ALEN);
711 tmp.pub.channel = channel;
712 tmp.pub.signal = signal;
713 tmp.pub.tsf = tsf;
714 tmp.pub.beacon_interval = beacon_interval;
715 tmp.pub.capability = capability;
Jouni Malinen34a6edd2010-01-06 16:19:24 +0200716 /*
717 * Since we do not know here whether the IEs are from a Beacon or Probe
718 * Response frame, we need to pick one of the options and only use it
719 * with the driver that does not provide the full Beacon/Probe Response
720 * frame. Use Beacon frame pointer to avoid indicating that this should
Johannes Berg50521aa2013-01-30 21:33:19 +0100721 * override the IEs pointer should we have received an earlier
Johannes Berg9caf0362012-11-29 01:25:20 +0100722 * indication of Probe Response data.
Jouni Malinen34a6edd2010-01-06 16:19:24 +0200723 */
Johannes Berg9caf0362012-11-29 01:25:20 +0100724 ies = kmalloc(sizeof(*ies) + ielen, gfp);
725 if (!ies)
726 return NULL;
727 ies->len = ielen;
728 memcpy(ies->data, ie, ielen);
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200729
Johannes Berg9caf0362012-11-29 01:25:20 +0100730 rcu_assign_pointer(tmp.pub.beacon_ies, ies);
731 rcu_assign_pointer(tmp.pub.ies, ies);
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200732
Johannes Berg9caf0362012-11-29 01:25:20 +0100733 res = cfg80211_bss_update(wiphy_to_dev(wiphy), &tmp);
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200734 if (!res)
735 return NULL;
736
737 if (res->pub.capability & WLAN_CAPABILITY_ESS)
738 regulatory_hint_found_beacon(wiphy, channel, gfp);
739
Beni Lev4ee3e062012-08-27 12:49:39 +0300740 trace_cfg80211_return_bss(&res->pub);
Jussi Kivilinna06aa7af2009-03-26 23:40:09 +0200741 /* cfg80211_bss_update gives us a referenced result */
742 return &res->pub;
743}
744EXPORT_SYMBOL(cfg80211_inform_bss);
745
Johannes Berg2a519312009-02-10 21:25:55 +0100746struct cfg80211_bss *
747cfg80211_inform_bss_frame(struct wiphy *wiphy,
748 struct ieee80211_channel *channel,
749 struct ieee80211_mgmt *mgmt, size_t len,
Johannes Berg77965c92009-02-18 18:45:06 +0100750 s32 signal, gfp_t gfp)
Johannes Berg2a519312009-02-10 21:25:55 +0100751{
Johannes Berg9caf0362012-11-29 01:25:20 +0100752 struct cfg80211_internal_bss tmp = {}, *res;
753 struct cfg80211_bss_ies *ies;
Johannes Berg2a519312009-02-10 21:25:55 +0100754 size_t ielen = len - offsetof(struct ieee80211_mgmt,
755 u.probe_resp.variable);
Mariusz Kozlowskibef9bac2011-03-26 19:26:55 +0100756
Johannes Berg0172bb72012-11-23 14:23:30 +0100757 BUILD_BUG_ON(offsetof(struct ieee80211_mgmt, u.probe_resp.variable) !=
758 offsetof(struct ieee80211_mgmt, u.beacon.variable));
759
Beni Lev4ee3e062012-08-27 12:49:39 +0300760 trace_cfg80211_inform_bss_frame(wiphy, channel, mgmt, len, signal);
761
Mariusz Kozlowskibef9bac2011-03-26 19:26:55 +0100762 if (WARN_ON(!mgmt))
763 return NULL;
764
765 if (WARN_ON(!wiphy))
766 return NULL;
Johannes Berg2a519312009-02-10 21:25:55 +0100767
Sujith22fe88d2010-05-13 10:34:08 +0530768 if (WARN_ON(wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC &&
Hila Gonen768be592012-08-26 11:00:28 +0300769 (signal < 0 || signal > 100)))
Johannes Berg2a519312009-02-10 21:25:55 +0100770 return NULL;
771
Mariusz Kozlowskibef9bac2011-03-26 19:26:55 +0100772 if (WARN_ON(len < offsetof(struct ieee80211_mgmt, u.probe_resp.variable)))
Johannes Berg2a519312009-02-10 21:25:55 +0100773 return NULL;
774
Johannes Berg0172bb72012-11-23 14:23:30 +0100775 channel = cfg80211_get_bss_channel(wiphy, mgmt->u.beacon.variable,
776 ielen, channel);
777 if (!channel)
778 return NULL;
779
Johannes Berg9caf0362012-11-29 01:25:20 +0100780 ies = kmalloc(sizeof(*ies) + ielen, gfp);
781 if (!ies)
Johannes Berg2a519312009-02-10 21:25:55 +0100782 return NULL;
Johannes Berg9caf0362012-11-29 01:25:20 +0100783 ies->len = ielen;
784 memcpy(ies->data, mgmt->u.probe_resp.variable, ielen);
Johannes Berg2a519312009-02-10 21:25:55 +0100785
Johannes Berg9caf0362012-11-29 01:25:20 +0100786 if (ieee80211_is_probe_resp(mgmt->frame_control))
787 rcu_assign_pointer(tmp.pub.proberesp_ies, ies);
788 else
789 rcu_assign_pointer(tmp.pub.beacon_ies, ies);
790 rcu_assign_pointer(tmp.pub.ies, ies);
791
792 memcpy(tmp.pub.bssid, mgmt->bssid, ETH_ALEN);
793 tmp.pub.channel = channel;
794 tmp.pub.signal = signal;
795 tmp.pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp);
796 tmp.pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int);
797 tmp.pub.capability = le16_to_cpu(mgmt->u.probe_resp.capab_info);
Johannes Berg2a519312009-02-10 21:25:55 +0100798
Johannes Berg9caf0362012-11-29 01:25:20 +0100799 res = cfg80211_bss_update(wiphy_to_dev(wiphy), &tmp);
Johannes Berg2a519312009-02-10 21:25:55 +0100800 if (!res)
801 return NULL;
802
Luis R. Rodrigueze38f8a72009-02-21 00:20:39 -0500803 if (res->pub.capability & WLAN_CAPABILITY_ESS)
804 regulatory_hint_found_beacon(wiphy, channel, gfp);
805
Beni Lev4ee3e062012-08-27 12:49:39 +0300806 trace_cfg80211_return_bss(&res->pub);
Johannes Berg2a519312009-02-10 21:25:55 +0100807 /* cfg80211_bss_update gives us a referenced result */
808 return &res->pub;
809}
810EXPORT_SYMBOL(cfg80211_inform_bss_frame);
811
Johannes Berg4c0c0b72012-01-20 13:55:26 +0100812void cfg80211_ref_bss(struct cfg80211_bss *pub)
813{
814 struct cfg80211_internal_bss *bss;
815
816 if (!pub)
817 return;
818
819 bss = container_of(pub, struct cfg80211_internal_bss, pub);
820 kref_get(&bss->ref);
821}
822EXPORT_SYMBOL(cfg80211_ref_bss);
823
Johannes Berg2a519312009-02-10 21:25:55 +0100824void cfg80211_put_bss(struct cfg80211_bss *pub)
825{
826 struct cfg80211_internal_bss *bss;
827
828 if (!pub)
829 return;
830
831 bss = container_of(pub, struct cfg80211_internal_bss, pub);
832 kref_put(&bss->ref, bss_release);
833}
834EXPORT_SYMBOL(cfg80211_put_bss);
835
Johannes Bergd491af12009-02-10 21:25:58 +0100836void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *pub)
837{
838 struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy);
839 struct cfg80211_internal_bss *bss;
840
841 if (WARN_ON(!pub))
842 return;
843
844 bss = container_of(pub, struct cfg80211_internal_bss, pub);
845
846 spin_lock_bh(&dev->bss_lock);
Johannes Berg32073902010-10-06 21:18:04 +0200847 if (!list_empty(&bss->list)) {
Juuso Oikarinen2b78ac92011-03-28 14:32:32 +0300848 __cfg80211_unlink_bss(dev, bss);
Johannes Berg32073902010-10-06 21:18:04 +0200849 dev->bss_generation++;
Johannes Berg32073902010-10-06 21:18:04 +0200850 }
Johannes Bergd491af12009-02-10 21:25:58 +0100851 spin_unlock_bh(&dev->bss_lock);
Johannes Bergd491af12009-02-10 21:25:58 +0100852}
853EXPORT_SYMBOL(cfg80211_unlink_bss);
854
Johannes Berg3d23e342009-09-29 23:27:28 +0200855#ifdef CONFIG_CFG80211_WEXT
Johannes Berg2a519312009-02-10 21:25:55 +0100856int cfg80211_wext_siwscan(struct net_device *dev,
857 struct iw_request_info *info,
858 union iwreq_data *wrqu, char *extra)
859{
860 struct cfg80211_registered_device *rdev;
861 struct wiphy *wiphy;
862 struct iw_scan_req *wreq = NULL;
Johannes Berg65486c82009-12-23 15:33:35 +0100863 struct cfg80211_scan_request *creq = NULL;
Johannes Berg2a519312009-02-10 21:25:55 +0100864 int i, err, n_channels = 0;
865 enum ieee80211_band band;
866
867 if (!netif_running(dev))
868 return -ENETDOWN;
869
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200870 if (wrqu->data.length == sizeof(struct iw_scan_req))
871 wreq = (struct iw_scan_req *)extra;
872
Johannes Berg463d0182009-07-14 00:33:35 +0200873 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex);
Johannes Berg2a519312009-02-10 21:25:55 +0100874
875 if (IS_ERR(rdev))
876 return PTR_ERR(rdev);
877
878 if (rdev->scan_req) {
879 err = -EBUSY;
880 goto out;
881 }
882
883 wiphy = &rdev->wiphy;
884
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200885 /* Determine number of channels, needed to allocate creq */
886 if (wreq && wreq->num_channels)
887 n_channels = wreq->num_channels;
888 else {
889 for (band = 0; band < IEEE80211_NUM_BANDS; band++)
890 if (wiphy->bands[band])
891 n_channels += wiphy->bands[band]->n_channels;
892 }
Johannes Berg2a519312009-02-10 21:25:55 +0100893
894 creq = kzalloc(sizeof(*creq) + sizeof(struct cfg80211_ssid) +
895 n_channels * sizeof(void *),
896 GFP_ATOMIC);
897 if (!creq) {
898 err = -ENOMEM;
899 goto out;
900 }
901
902 creq->wiphy = wiphy;
Johannes Bergfd014282012-06-18 19:17:03 +0200903 creq->wdev = dev->ieee80211_ptr;
Johannes Berg5ba63532009-08-07 17:54:07 +0200904 /* SSIDs come after channels */
905 creq->ssids = (void *)&creq->channels[n_channels];
Johannes Berg2a519312009-02-10 21:25:55 +0100906 creq->n_channels = n_channels;
907 creq->n_ssids = 1;
Sam Leffler15d60302012-10-11 21:03:34 -0700908 creq->scan_start = jiffies;
Johannes Berg2a519312009-02-10 21:25:55 +0100909
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200910 /* translate "Scan on frequencies" request */
Johannes Berg2a519312009-02-10 21:25:55 +0100911 i = 0;
912 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
913 int j;
Johannes Berg584991d2009-11-02 13:32:03 +0100914
Johannes Berg2a519312009-02-10 21:25:55 +0100915 if (!wiphy->bands[band])
916 continue;
Johannes Berg584991d2009-11-02 13:32:03 +0100917
Johannes Berg2a519312009-02-10 21:25:55 +0100918 for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
Johannes Berg584991d2009-11-02 13:32:03 +0100919 /* ignore disabled channels */
920 if (wiphy->bands[band]->channels[j].flags &
921 IEEE80211_CHAN_DISABLED)
922 continue;
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200923
924 /* If we have a wireless request structure and the
925 * wireless request specifies frequencies, then search
926 * for the matching hardware channel.
927 */
928 if (wreq && wreq->num_channels) {
929 int k;
930 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
931 for (k = 0; k < wreq->num_channels; k++) {
Holger Schuriga4e7b732009-09-11 10:13:53 +0200932 int wext_freq = cfg80211_wext_freq(wiphy, &wreq->channel_list[k]);
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200933 if (wext_freq == wiphy_freq)
934 goto wext_freq_found;
935 }
936 goto wext_freq_not_found;
937 }
938
939 wext_freq_found:
Johannes Berg2a519312009-02-10 21:25:55 +0100940 creq->channels[i] = &wiphy->bands[band]->channels[j];
941 i++;
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200942 wext_freq_not_found: ;
Johannes Berg2a519312009-02-10 21:25:55 +0100943 }
944 }
Holger Schurig8862dc52009-09-11 10:13:55 +0200945 /* No channels found? */
946 if (!i) {
947 err = -EINVAL;
948 goto out;
949 }
Johannes Berg2a519312009-02-10 21:25:55 +0100950
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200951 /* Set real number of channels specified in creq->channels[] */
952 creq->n_channels = i;
Johannes Berg2a519312009-02-10 21:25:55 +0100953
Holger Schurigb2e3abd2009-09-09 13:09:54 +0200954 /* translate "Scan for SSID" request */
955 if (wreq) {
Johannes Berg2a519312009-02-10 21:25:55 +0100956 if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
Johannes Berg65486c82009-12-23 15:33:35 +0100957 if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) {
958 err = -EINVAL;
959 goto out;
960 }
Johannes Berg2a519312009-02-10 21:25:55 +0100961 memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len);
962 creq->ssids[0].ssid_len = wreq->essid_len;
963 }
964 if (wreq->scan_type == IW_SCAN_TYPE_PASSIVE)
965 creq->n_ssids = 0;
966 }
967
Johannes Berg34850ab2011-07-18 18:08:35 +0200968 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Johannes Berga401d2b2011-07-20 00:52:16 +0200969 if (wiphy->bands[i])
970 creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1;
Johannes Berg34850ab2011-07-18 18:08:35 +0200971
Johannes Berg2a519312009-02-10 21:25:55 +0100972 rdev->scan_req = creq;
Hila Gonene35e4d22012-06-27 17:19:42 +0300973 err = rdev_scan(rdev, creq);
Johannes Berg2a519312009-02-10 21:25:55 +0100974 if (err) {
975 rdev->scan_req = NULL;
Johannes Berg65486c82009-12-23 15:33:35 +0100976 /* creq will be freed below */
Johannes Berg463d0182009-07-14 00:33:35 +0200977 } else {
Johannes Bergfd014282012-06-18 19:17:03 +0200978 nl80211_send_scan_start(rdev, dev->ieee80211_ptr);
Johannes Berg65486c82009-12-23 15:33:35 +0100979 /* creq now owned by driver */
980 creq = NULL;
Johannes Berg463d0182009-07-14 00:33:35 +0200981 dev_hold(dev);
982 }
Johannes Berg2a519312009-02-10 21:25:55 +0100983 out:
Johannes Berg65486c82009-12-23 15:33:35 +0100984 kfree(creq);
Johannes Berg4d0c8ae2009-07-07 03:56:09 +0200985 cfg80211_unlock_rdev(rdev);
Johannes Berg2a519312009-02-10 21:25:55 +0100986 return err;
987}
Johannes Bergba44cb72009-04-20 18:49:39 +0200988EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan);
Johannes Berg2a519312009-02-10 21:25:55 +0100989
990static void ieee80211_scan_add_ies(struct iw_request_info *info,
Johannes Berg9caf0362012-11-29 01:25:20 +0100991 const struct cfg80211_bss_ies *ies,
Johannes Berg2a519312009-02-10 21:25:55 +0100992 char **current_ev, char *end_buf)
993{
Johannes Berg9caf0362012-11-29 01:25:20 +0100994 const u8 *pos, *end, *next;
Johannes Berg2a519312009-02-10 21:25:55 +0100995 struct iw_event iwe;
996
Johannes Berg9caf0362012-11-29 01:25:20 +0100997 if (!ies)
Johannes Berg2a519312009-02-10 21:25:55 +0100998 return;
999
1000 /*
1001 * If needed, fragment the IEs buffer (at IE boundaries) into short
1002 * enough fragments to fit into IW_GENERIC_IE_MAX octet messages.
1003 */
Johannes Berg9caf0362012-11-29 01:25:20 +01001004 pos = ies->data;
1005 end = pos + ies->len;
Johannes Berg2a519312009-02-10 21:25:55 +01001006
1007 while (end - pos > IW_GENERIC_IE_MAX) {
1008 next = pos + 2 + pos[1];
1009 while (next + 2 + next[1] - pos < IW_GENERIC_IE_MAX)
1010 next = next + 2 + next[1];
1011
1012 memset(&iwe, 0, sizeof(iwe));
1013 iwe.cmd = IWEVGENIE;
1014 iwe.u.data.length = next - pos;
1015 *current_ev = iwe_stream_add_point(info, *current_ev,
Johannes Berg9caf0362012-11-29 01:25:20 +01001016 end_buf, &iwe,
1017 (void *)pos);
Johannes Berg2a519312009-02-10 21:25:55 +01001018
1019 pos = next;
1020 }
1021
1022 if (end > pos) {
1023 memset(&iwe, 0, sizeof(iwe));
1024 iwe.cmd = IWEVGENIE;
1025 iwe.u.data.length = end - pos;
1026 *current_ev = iwe_stream_add_point(info, *current_ev,
Johannes Berg9caf0362012-11-29 01:25:20 +01001027 end_buf, &iwe,
1028 (void *)pos);
Johannes Berg2a519312009-02-10 21:25:55 +01001029 }
1030}
1031
Dan Williamscb3a8ee2009-02-11 17:14:43 -05001032static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
1033{
1034 unsigned long end = jiffies;
1035
1036 if (end >= start)
1037 return jiffies_to_msecs(end - start);
1038
1039 return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1);
1040}
Johannes Berg2a519312009-02-10 21:25:55 +01001041
1042static char *
Johannes Berg77965c92009-02-18 18:45:06 +01001043ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info,
1044 struct cfg80211_internal_bss *bss, char *current_ev,
1045 char *end_buf)
Johannes Berg2a519312009-02-10 21:25:55 +01001046{
Johannes Berg9caf0362012-11-29 01:25:20 +01001047 const struct cfg80211_bss_ies *ies;
Johannes Berg2a519312009-02-10 21:25:55 +01001048 struct iw_event iwe;
Johannes Berg9caf0362012-11-29 01:25:20 +01001049 const u8 *ie;
Johannes Berg2a519312009-02-10 21:25:55 +01001050 u8 *buf, *cfg, *p;
Johannes Berg9caf0362012-11-29 01:25:20 +01001051 int rem, i, sig;
Johannes Berg2a519312009-02-10 21:25:55 +01001052 bool ismesh = false;
1053
1054 memset(&iwe, 0, sizeof(iwe));
1055 iwe.cmd = SIOCGIWAP;
1056 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1057 memcpy(iwe.u.ap_addr.sa_data, bss->pub.bssid, ETH_ALEN);
1058 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1059 IW_EV_ADDR_LEN);
1060
1061 memset(&iwe, 0, sizeof(iwe));
1062 iwe.cmd = SIOCGIWFREQ;
1063 iwe.u.freq.m = ieee80211_frequency_to_channel(bss->pub.channel->center_freq);
1064 iwe.u.freq.e = 0;
1065 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1066 IW_EV_FREQ_LEN);
1067
1068 memset(&iwe, 0, sizeof(iwe));
1069 iwe.cmd = SIOCGIWFREQ;
1070 iwe.u.freq.m = bss->pub.channel->center_freq;
1071 iwe.u.freq.e = 6;
1072 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1073 IW_EV_FREQ_LEN);
1074
Johannes Berg77965c92009-02-18 18:45:06 +01001075 if (wiphy->signal_type != CFG80211_SIGNAL_TYPE_NONE) {
Johannes Berg2a519312009-02-10 21:25:55 +01001076 memset(&iwe, 0, sizeof(iwe));
1077 iwe.cmd = IWEVQUAL;
1078 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED |
1079 IW_QUAL_NOISE_INVALID |
Johannes Berga77b8552009-02-18 18:27:22 +01001080 IW_QUAL_QUAL_UPDATED;
Johannes Berg77965c92009-02-18 18:45:06 +01001081 switch (wiphy->signal_type) {
Johannes Berg2a519312009-02-10 21:25:55 +01001082 case CFG80211_SIGNAL_TYPE_MBM:
Johannes Berga77b8552009-02-18 18:27:22 +01001083 sig = bss->pub.signal / 100;
1084 iwe.u.qual.level = sig;
Johannes Berg2a519312009-02-10 21:25:55 +01001085 iwe.u.qual.updated |= IW_QUAL_DBM;
Johannes Berga77b8552009-02-18 18:27:22 +01001086 if (sig < -110) /* rather bad */
1087 sig = -110;
1088 else if (sig > -40) /* perfect */
1089 sig = -40;
1090 /* will give a range of 0 .. 70 */
1091 iwe.u.qual.qual = sig + 110;
Johannes Berg2a519312009-02-10 21:25:55 +01001092 break;
1093 case CFG80211_SIGNAL_TYPE_UNSPEC:
1094 iwe.u.qual.level = bss->pub.signal;
Johannes Berga77b8552009-02-18 18:27:22 +01001095 /* will give range 0 .. 100 */
1096 iwe.u.qual.qual = bss->pub.signal;
Johannes Berg2a519312009-02-10 21:25:55 +01001097 break;
1098 default:
1099 /* not reached */
1100 break;
1101 }
1102 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1103 &iwe, IW_EV_QUAL_LEN);
1104 }
1105
1106 memset(&iwe, 0, sizeof(iwe));
1107 iwe.cmd = SIOCGIWENCODE;
1108 if (bss->pub.capability & WLAN_CAPABILITY_PRIVACY)
1109 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1110 else
1111 iwe.u.data.flags = IW_ENCODE_DISABLED;
1112 iwe.u.data.length = 0;
1113 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1114 &iwe, "");
1115
Johannes Berg9caf0362012-11-29 01:25:20 +01001116 rcu_read_lock();
1117 ies = rcu_dereference(bss->pub.ies);
1118 if (ies) {
1119 rem = ies->len;
1120 ie = ies->data;
1121 } else {
1122 rem = 0;
1123 ie = NULL;
1124 }
1125
1126 while (ies && rem >= 2) {
Johannes Berg2a519312009-02-10 21:25:55 +01001127 /* invalid data */
1128 if (ie[1] > rem - 2)
1129 break;
1130
1131 switch (ie[0]) {
1132 case WLAN_EID_SSID:
1133 memset(&iwe, 0, sizeof(iwe));
1134 iwe.cmd = SIOCGIWESSID;
1135 iwe.u.data.length = ie[1];
1136 iwe.u.data.flags = 1;
1137 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
Johannes Berg9caf0362012-11-29 01:25:20 +01001138 &iwe, (u8 *)ie + 2);
Johannes Berg2a519312009-02-10 21:25:55 +01001139 break;
1140 case WLAN_EID_MESH_ID:
1141 memset(&iwe, 0, sizeof(iwe));
1142 iwe.cmd = SIOCGIWESSID;
1143 iwe.u.data.length = ie[1];
1144 iwe.u.data.flags = 1;
1145 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
Johannes Berg9caf0362012-11-29 01:25:20 +01001146 &iwe, (u8 *)ie + 2);
Johannes Berg2a519312009-02-10 21:25:55 +01001147 break;
1148 case WLAN_EID_MESH_CONFIG:
1149 ismesh = true;
Rui Paulo136cfa22009-11-18 18:40:00 +00001150 if (ie[1] != sizeof(struct ieee80211_meshconf_ie))
Johannes Berg2a519312009-02-10 21:25:55 +01001151 break;
1152 buf = kmalloc(50, GFP_ATOMIC);
1153 if (!buf)
1154 break;
Johannes Berg9caf0362012-11-29 01:25:20 +01001155 cfg = (u8 *)ie + 2;
Johannes Berg2a519312009-02-10 21:25:55 +01001156 memset(&iwe, 0, sizeof(iwe));
1157 iwe.cmd = IWEVCUSTOM;
Rui Paulo76aa5e72009-11-18 18:22:59 +00001158 sprintf(buf, "Mesh Network Path Selection Protocol ID: "
1159 "0x%02X", cfg[0]);
Johannes Berg2a519312009-02-10 21:25:55 +01001160 iwe.u.data.length = strlen(buf);
1161 current_ev = iwe_stream_add_point(info, current_ev,
1162 end_buf,
1163 &iwe, buf);
Rui Paulo76aa5e72009-11-18 18:22:59 +00001164 sprintf(buf, "Path Selection Metric ID: 0x%02X",
1165 cfg[1]);
Johannes Berg2a519312009-02-10 21:25:55 +01001166 iwe.u.data.length = strlen(buf);
1167 current_ev = iwe_stream_add_point(info, current_ev,
1168 end_buf,
1169 &iwe, buf);
Rui Paulo76aa5e72009-11-18 18:22:59 +00001170 sprintf(buf, "Congestion Control Mode ID: 0x%02X",
1171 cfg[2]);
Johannes Berg2a519312009-02-10 21:25:55 +01001172 iwe.u.data.length = strlen(buf);
1173 current_ev = iwe_stream_add_point(info, current_ev,
1174 end_buf,
1175 &iwe, buf);
Rui Paulo76aa5e72009-11-18 18:22:59 +00001176 sprintf(buf, "Synchronization ID: 0x%02X", cfg[3]);
Johannes Berg2a519312009-02-10 21:25:55 +01001177 iwe.u.data.length = strlen(buf);
1178 current_ev = iwe_stream_add_point(info, current_ev,
1179 end_buf,
1180 &iwe, buf);
Rui Paulo76aa5e72009-11-18 18:22:59 +00001181 sprintf(buf, "Authentication ID: 0x%02X", cfg[4]);
1182 iwe.u.data.length = strlen(buf);
1183 current_ev = iwe_stream_add_point(info, current_ev,
1184 end_buf,
1185 &iwe, buf);
1186 sprintf(buf, "Formation Info: 0x%02X", cfg[5]);
1187 iwe.u.data.length = strlen(buf);
1188 current_ev = iwe_stream_add_point(info, current_ev,
1189 end_buf,
1190 &iwe, buf);
1191 sprintf(buf, "Capabilities: 0x%02X", cfg[6]);
Johannes Berg2a519312009-02-10 21:25:55 +01001192 iwe.u.data.length = strlen(buf);
1193 current_ev = iwe_stream_add_point(info, current_ev,
1194 end_buf,
1195 &iwe, buf);
1196 kfree(buf);
1197 break;
1198 case WLAN_EID_SUPP_RATES:
1199 case WLAN_EID_EXT_SUPP_RATES:
1200 /* display all supported rates in readable format */
1201 p = current_ev + iwe_stream_lcp_len(info);
1202
1203 memset(&iwe, 0, sizeof(iwe));
1204 iwe.cmd = SIOCGIWRATE;
1205 /* Those two flags are ignored... */
1206 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
1207
1208 for (i = 0; i < ie[1]; i++) {
1209 iwe.u.bitrate.value =
1210 ((ie[i + 2] & 0x7f) * 500000);
1211 p = iwe_stream_add_value(info, current_ev, p,
1212 end_buf, &iwe, IW_EV_PARAM_LEN);
1213 }
1214 current_ev = p;
1215 break;
1216 }
1217 rem -= ie[1] + 2;
1218 ie += ie[1] + 2;
1219 }
1220
Joe Perchesf64f9e72009-11-29 16:55:45 -08001221 if (bss->pub.capability & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS) ||
1222 ismesh) {
Johannes Berg2a519312009-02-10 21:25:55 +01001223 memset(&iwe, 0, sizeof(iwe));
1224 iwe.cmd = SIOCGIWMODE;
1225 if (ismesh)
1226 iwe.u.mode = IW_MODE_MESH;
1227 else if (bss->pub.capability & WLAN_CAPABILITY_ESS)
1228 iwe.u.mode = IW_MODE_MASTER;
1229 else
1230 iwe.u.mode = IW_MODE_ADHOC;
1231 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1232 &iwe, IW_EV_UINT_LEN);
1233 }
1234
1235 buf = kmalloc(30, GFP_ATOMIC);
1236 if (buf) {
1237 memset(&iwe, 0, sizeof(iwe));
1238 iwe.cmd = IWEVCUSTOM;
1239 sprintf(buf, "tsf=%016llx", (unsigned long long)(bss->pub.tsf));
1240 iwe.u.data.length = strlen(buf);
1241 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1242 &iwe, buf);
1243 memset(&iwe, 0, sizeof(iwe));
1244 iwe.cmd = IWEVCUSTOM;
Dan Williamscb3a8ee2009-02-11 17:14:43 -05001245 sprintf(buf, " Last beacon: %ums ago",
1246 elapsed_jiffies_msecs(bss->ts));
Johannes Berg2a519312009-02-10 21:25:55 +01001247 iwe.u.data.length = strlen(buf);
1248 current_ev = iwe_stream_add_point(info, current_ev,
1249 end_buf, &iwe, buf);
1250 kfree(buf);
1251 }
1252
Johannes Berg9caf0362012-11-29 01:25:20 +01001253 ieee80211_scan_add_ies(info, ies, &current_ev, end_buf);
1254 rcu_read_unlock();
Johannes Berg2a519312009-02-10 21:25:55 +01001255
1256 return current_ev;
1257}
1258
1259
1260static int ieee80211_scan_results(struct cfg80211_registered_device *dev,
1261 struct iw_request_info *info,
1262 char *buf, size_t len)
1263{
1264 char *current_ev = buf;
1265 char *end_buf = buf + len;
1266 struct cfg80211_internal_bss *bss;
1267
1268 spin_lock_bh(&dev->bss_lock);
1269 cfg80211_bss_expire(dev);
1270
1271 list_for_each_entry(bss, &dev->bss_list, list) {
1272 if (buf + len - current_ev <= IW_EV_ADDR_LEN) {
1273 spin_unlock_bh(&dev->bss_lock);
1274 return -E2BIG;
1275 }
Johannes Berg77965c92009-02-18 18:45:06 +01001276 current_ev = ieee80211_bss(&dev->wiphy, info, bss,
1277 current_ev, end_buf);
Johannes Berg2a519312009-02-10 21:25:55 +01001278 }
1279 spin_unlock_bh(&dev->bss_lock);
1280 return current_ev - buf;
1281}
1282
1283
1284int cfg80211_wext_giwscan(struct net_device *dev,
1285 struct iw_request_info *info,
1286 struct iw_point *data, char *extra)
1287{
1288 struct cfg80211_registered_device *rdev;
1289 int res;
1290
1291 if (!netif_running(dev))
1292 return -ENETDOWN;
1293
Johannes Berg463d0182009-07-14 00:33:35 +02001294 rdev = cfg80211_get_dev_from_ifindex(dev_net(dev), dev->ifindex);
Johannes Berg2a519312009-02-10 21:25:55 +01001295
1296 if (IS_ERR(rdev))
1297 return PTR_ERR(rdev);
1298
1299 if (rdev->scan_req) {
1300 res = -EAGAIN;
1301 goto out;
1302 }
1303
1304 res = ieee80211_scan_results(rdev, info, extra, data->length);
1305 data->length = 0;
1306 if (res >= 0) {
1307 data->length = res;
1308 res = 0;
1309 }
1310
1311 out:
Johannes Berg4d0c8ae2009-07-07 03:56:09 +02001312 cfg80211_unlock_rdev(rdev);
Johannes Berg2a519312009-02-10 21:25:55 +01001313 return res;
1314}
Johannes Bergba44cb72009-04-20 18:49:39 +02001315EXPORT_SYMBOL_GPL(cfg80211_wext_giwscan);
Johannes Berg2a519312009-02-10 21:25:55 +01001316#endif