da64071ceb84fa9a4dc83747804aea6b0bc02175
[pandora-kernel.git] / net / wireless / mlme.c
1 /*
2  * cfg80211 MLME SAP interface
3  *
4  * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
5  */
6
7 #include <linux/kernel.h>
8 #include <linux/module.h>
9 #include <linux/netdevice.h>
10 #include <linux/nl80211.h>
11 #include <linux/wireless.h>
12 #include <net/cfg80211.h>
13 #include <net/iw_handler.h>
14 #include "core.h"
15 #include "nl80211.h"
16
17 void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
18 {
19         struct wireless_dev *wdev = dev->ieee80211_ptr;
20         struct wiphy *wiphy = wdev->wiphy;
21         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
22         struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
23         u8 *bssid = mgmt->bssid;
24         int i;
25         u16 status = le16_to_cpu(mgmt->u.auth.status_code);
26         bool done = false;
27
28         wdev_lock(wdev);
29
30         for (i = 0; i < MAX_AUTH_BSSES; i++) {
31                 if (wdev->authtry_bsses[i] &&
32                     memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid,
33                                                         ETH_ALEN) == 0) {
34                         if (status == WLAN_STATUS_SUCCESS) {
35                                 wdev->auth_bsses[i] = wdev->authtry_bsses[i];
36                         } else {
37                                 cfg80211_unhold_bss(wdev->authtry_bsses[i]);
38                                 cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
39                         }
40                         wdev->authtry_bsses[i] = NULL;
41                         done = true;
42                         break;
43                 }
44         }
45
46         WARN_ON(!done);
47
48         nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
49         cfg80211_sme_rx_auth(dev, buf, len);
50
51         wdev_unlock(wdev);
52 }
53 EXPORT_SYMBOL(cfg80211_send_rx_auth);
54
55 void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
56 {
57         u16 status_code;
58         struct wireless_dev *wdev = dev->ieee80211_ptr;
59         struct wiphy *wiphy = wdev->wiphy;
60         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
61         struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
62         u8 *ie = mgmt->u.assoc_resp.variable;
63         int i, ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
64         struct cfg80211_internal_bss *bss = NULL;
65
66         wdev_lock(wdev);
67
68         status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
69
70         /*
71          * This is a bit of a hack, we don't notify userspace of
72          * a (re-)association reply if we tried to send a reassoc
73          * and got a reject -- we only try again with an assoc
74          * frame instead of reassoc.
75          */
76         if (status_code != WLAN_STATUS_SUCCESS && wdev->conn &&
77             cfg80211_sme_failed_reassoc(wdev))
78                 goto out;
79
80         nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL);
81
82         if (status_code == WLAN_STATUS_SUCCESS) {
83                 for (i = 0; i < MAX_AUTH_BSSES; i++) {
84                         if (!wdev->auth_bsses[i])
85                                 continue;
86                         if (memcmp(wdev->auth_bsses[i]->pub.bssid, mgmt->bssid,
87                                    ETH_ALEN) == 0) {
88                                 bss = wdev->auth_bsses[i];
89                                 wdev->auth_bsses[i] = NULL;
90                                 /* additional reference to drop hold */
91                                 cfg80211_ref_bss(bss);
92                                 break;
93                         }
94                 }
95
96                 WARN_ON(!bss);
97         }
98
99         /* this consumes one bss reference (unless bss is NULL) */
100         __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs,
101                                   status_code,
102                                   status_code == WLAN_STATUS_SUCCESS,
103                                   bss ? &bss->pub : NULL);
104         /* drop hold now, and also reference acquired above */
105         if (bss) {
106                 cfg80211_unhold_bss(bss);
107                 cfg80211_put_bss(&bss->pub);
108         }
109
110  out:
111         wdev_unlock(wdev);
112 }
113 EXPORT_SYMBOL(cfg80211_send_rx_assoc);
114
115 static void __cfg80211_send_deauth(struct net_device *dev,
116                                    const u8 *buf, size_t len)
117 {
118         struct wireless_dev *wdev = dev->ieee80211_ptr;
119         struct wiphy *wiphy = wdev->wiphy;
120         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
121         struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
122         const u8 *bssid = mgmt->bssid;
123         int i;
124         bool done = false;
125
126         ASSERT_WDEV_LOCK(wdev);
127
128         nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL);
129
130         if (wdev->current_bss &&
131             memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
132                 done = true;
133                 cfg80211_unhold_bss(wdev->current_bss);
134                 cfg80211_put_bss(&wdev->current_bss->pub);
135                 wdev->current_bss = NULL;
136         } else for (i = 0; i < MAX_AUTH_BSSES; i++) {
137                 if (wdev->auth_bsses[i] &&
138                     memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) {
139                         cfg80211_unhold_bss(wdev->auth_bsses[i]);
140                         cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
141                         wdev->auth_bsses[i] = NULL;
142                         done = true;
143                         break;
144                 }
145                 if (wdev->authtry_bsses[i] &&
146                     memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) {
147                         cfg80211_unhold_bss(wdev->authtry_bsses[i]);
148                         cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
149                         wdev->authtry_bsses[i] = NULL;
150                         done = true;
151                         break;
152                 }
153         }
154
155         WARN_ON(!done);
156
157         if (wdev->sme_state == CFG80211_SME_CONNECTED) {
158                 u16 reason_code;
159                 bool from_ap;
160
161                 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
162
163                 from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
164                 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
165         } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
166                 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
167                                           WLAN_STATUS_UNSPECIFIED_FAILURE,
168                                           false, NULL);
169         }
170 }
171
172
173 void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len,
174                           void *cookie)
175 {
176         struct wireless_dev *wdev = dev->ieee80211_ptr;
177
178         BUG_ON(cookie && wdev != cookie);
179
180         if (cookie) {
181                 /* called within callback */
182                 __cfg80211_send_deauth(dev, buf, len);
183         } else {
184                 wdev_lock(wdev);
185                 __cfg80211_send_deauth(dev, buf, len);
186                 wdev_unlock(wdev);
187         }
188 }
189 EXPORT_SYMBOL(cfg80211_send_deauth);
190
191 static void __cfg80211_send_disassoc(struct net_device *dev,
192                                      const u8 *buf, size_t len)
193 {
194         struct wireless_dev *wdev = dev->ieee80211_ptr;
195         struct wiphy *wiphy = wdev->wiphy;
196         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
197         struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
198         const u8 *bssid = mgmt->bssid;
199         int i;
200         u16 reason_code;
201         bool from_ap;
202         bool done = false;
203
204         ASSERT_WDEV_LOCK(wdev);
205
206         nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL);
207
208         if (wdev->sme_state != CFG80211_SME_CONNECTED)
209                 return;
210
211         if (wdev->current_bss &&
212             memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
213                 for (i = 0; i < MAX_AUTH_BSSES; i++) {
214                         if (wdev->authtry_bsses[i] || wdev->auth_bsses[i])
215                                 continue;
216                         wdev->auth_bsses[i] = wdev->current_bss;
217                         wdev->current_bss = NULL;
218                         done = true;
219                         cfg80211_sme_disassoc(dev, i);
220                         break;
221                 }
222                 WARN_ON(!done);
223         } else
224                 WARN_ON(1);
225
226
227         reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
228
229         from_ap = memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0;
230         __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
231 }
232
233 void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len,
234                             void *cookie)
235 {
236         struct wireless_dev *wdev = dev->ieee80211_ptr;
237
238         BUG_ON(cookie && wdev != cookie);
239
240         if (cookie) {
241                 /* called within callback */
242                 __cfg80211_send_disassoc(dev, buf, len);
243         } else {
244                 wdev_lock(wdev);
245                 __cfg80211_send_disassoc(dev, buf, len);
246                 wdev_unlock(wdev);
247         }
248 }
249 EXPORT_SYMBOL(cfg80211_send_disassoc);
250
251 void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
252 {
253         struct wireless_dev *wdev = dev->ieee80211_ptr;
254         struct wiphy *wiphy = wdev->wiphy;
255         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
256         int i;
257         bool done = false;
258
259         wdev_lock(wdev);
260
261         nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
262         if (wdev->sme_state == CFG80211_SME_CONNECTING)
263                 __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
264                                           WLAN_STATUS_UNSPECIFIED_FAILURE,
265                                           false, NULL);
266
267         for (i = 0; addr && i < MAX_AUTH_BSSES; i++) {
268                 if (wdev->authtry_bsses[i] &&
269                     memcmp(wdev->authtry_bsses[i]->pub.bssid,
270                            addr, ETH_ALEN) == 0) {
271                         cfg80211_unhold_bss(wdev->authtry_bsses[i]);
272                         cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
273                         wdev->authtry_bsses[i] = NULL;
274                         done = true;
275                         break;
276                 }
277         }
278
279         WARN_ON(!done);
280
281         wdev_unlock(wdev);
282 }
283 EXPORT_SYMBOL(cfg80211_send_auth_timeout);
284
285 void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
286 {
287         struct wireless_dev *wdev = dev->ieee80211_ptr;
288         struct wiphy *wiphy = wdev->wiphy;
289         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
290         int i;
291         bool done = false;
292
293         wdev_lock(wdev);
294
295         nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL);
296         if (wdev->sme_state == CFG80211_SME_CONNECTING)
297                 __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
298                                           WLAN_STATUS_UNSPECIFIED_FAILURE,
299                                           false, NULL);
300
301         for (i = 0; addr && i < MAX_AUTH_BSSES; i++) {
302                 if (wdev->auth_bsses[i] &&
303                     memcmp(wdev->auth_bsses[i]->pub.bssid,
304                            addr, ETH_ALEN) == 0) {
305                         cfg80211_unhold_bss(wdev->auth_bsses[i]);
306                         cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
307                         wdev->auth_bsses[i] = NULL;
308                         done = true;
309                         break;
310                 }
311         }
312
313         WARN_ON(!done);
314
315         wdev_unlock(wdev);
316 }
317 EXPORT_SYMBOL(cfg80211_send_assoc_timeout);
318
319 void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
320                                   enum nl80211_key_type key_type, int key_id,
321                                   const u8 *tsc, gfp_t gfp)
322 {
323         struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
324         struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
325 #ifdef CONFIG_WIRELESS_EXT
326         union iwreq_data wrqu;
327         char *buf = kmalloc(128, gfp);
328
329         if (buf) {
330                 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
331                         "keyid=%d %scast addr=%pM)", key_id,
332                         key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
333                         addr);
334                 memset(&wrqu, 0, sizeof(wrqu));
335                 wrqu.data.length = strlen(buf);
336                 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
337                 kfree(buf);
338         }
339 #endif
340
341         nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
342 }
343 EXPORT_SYMBOL(cfg80211_michael_mic_failure);
344
345 /* some MLME handling for userspace SME */
346 int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
347                          struct net_device *dev,
348                          struct ieee80211_channel *chan,
349                          enum nl80211_auth_type auth_type,
350                          const u8 *bssid,
351                          const u8 *ssid, int ssid_len,
352                          const u8 *ie, int ie_len,
353                          const u8 *key, int key_len, int key_idx)
354 {
355         struct wireless_dev *wdev = dev->ieee80211_ptr;
356         struct cfg80211_auth_request req;
357         struct cfg80211_internal_bss *bss;
358         int i, err, slot = -1, nfree = 0;
359
360         ASSERT_WDEV_LOCK(wdev);
361
362         if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
363                 if (!key || !key_len || key_idx < 0 || key_idx > 4)
364                         return -EINVAL;
365
366         if (wdev->current_bss &&
367             memcmp(bssid, wdev->current_bss->pub.bssid, ETH_ALEN) == 0)
368                 return -EALREADY;
369
370         for (i = 0; i < MAX_AUTH_BSSES; i++) {
371                 if (wdev->authtry_bsses[i] &&
372                     memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid,
373                                                 ETH_ALEN) == 0)
374                         return -EALREADY;
375                 if (wdev->auth_bsses[i] &&
376                     memcmp(bssid, wdev->auth_bsses[i]->pub.bssid,
377                                                 ETH_ALEN) == 0)
378                         return -EALREADY;
379         }
380
381         memset(&req, 0, sizeof(req));
382
383         req.ie = ie;
384         req.ie_len = ie_len;
385         req.auth_type = auth_type;
386         req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
387                                    WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
388         req.key = key;
389         req.key_len = key_len;
390         req.key_idx = key_idx;
391         if (!req.bss)
392                 return -ENOENT;
393
394         bss = bss_from_pub(req.bss);
395
396         for (i = 0; i < MAX_AUTH_BSSES; i++) {
397                 if (!wdev->auth_bsses[i] && !wdev->authtry_bsses[i]) {
398                         slot = i;
399                         nfree++;
400                 }
401         }
402
403         /* we need one free slot for disassoc and one for this auth */
404         if (nfree < 2) {
405                 err = -ENOSPC;
406                 goto out;
407         }
408
409         wdev->authtry_bsses[slot] = bss;
410         cfg80211_hold_bss(bss);
411
412         err = rdev->ops->auth(&rdev->wiphy, dev, &req);
413         if (err) {
414                 wdev->authtry_bsses[slot] = NULL;
415                 cfg80211_unhold_bss(bss);
416         }
417
418  out:
419         if (err)
420                 cfg80211_put_bss(req.bss);
421         return err;
422 }
423
424 int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
425                        struct net_device *dev, struct ieee80211_channel *chan,
426                        enum nl80211_auth_type auth_type, const u8 *bssid,
427                        const u8 *ssid, int ssid_len,
428                        const u8 *ie, int ie_len,
429                        const u8 *key, int key_len, int key_idx)
430 {
431         int err;
432
433         wdev_lock(dev->ieee80211_ptr);
434         err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
435                                    ssid, ssid_len, ie, ie_len,
436                                    key, key_len, key_idx);
437         wdev_unlock(dev->ieee80211_ptr);
438
439         return err;
440 }
441
442 int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
443                           struct net_device *dev,
444                           struct ieee80211_channel *chan,
445                           const u8 *bssid, const u8 *prev_bssid,
446                           const u8 *ssid, int ssid_len,
447                           const u8 *ie, int ie_len, bool use_mfp,
448                           struct cfg80211_crypto_settings *crypt)
449 {
450         struct wireless_dev *wdev = dev->ieee80211_ptr;
451         struct cfg80211_assoc_request req;
452         struct cfg80211_internal_bss *bss;
453         int i, err, slot = -1;
454
455         ASSERT_WDEV_LOCK(wdev);
456
457         memset(&req, 0, sizeof(req));
458
459         if (wdev->current_bss)
460                 return -EALREADY;
461
462         req.ie = ie;
463         req.ie_len = ie_len;
464         memcpy(&req.crypto, crypt, sizeof(req.crypto));
465         req.use_mfp = use_mfp;
466         req.prev_bssid = prev_bssid;
467         req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
468                                    WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
469         if (!req.bss)
470                 return -ENOENT;
471
472         bss = bss_from_pub(req.bss);
473
474         for (i = 0; i < MAX_AUTH_BSSES; i++) {
475                 if (bss == wdev->auth_bsses[i]) {
476                         slot = i;
477                         break;
478                 }
479         }
480
481         if (slot < 0) {
482                 err = -ENOTCONN;
483                 goto out;
484         }
485
486         err = rdev->ops->assoc(&rdev->wiphy, dev, &req);
487  out:
488         /* still a reference in wdev->auth_bsses[slot] */
489         cfg80211_put_bss(req.bss);
490         return err;
491 }
492
493 int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
494                         struct net_device *dev,
495                         struct ieee80211_channel *chan,
496                         const u8 *bssid, const u8 *prev_bssid,
497                         const u8 *ssid, int ssid_len,
498                         const u8 *ie, int ie_len, bool use_mfp,
499                         struct cfg80211_crypto_settings *crypt)
500 {
501         struct wireless_dev *wdev = dev->ieee80211_ptr;
502         int err;
503
504         wdev_lock(wdev);
505         err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
506                                     ssid, ssid_len, ie, ie_len, use_mfp, crypt);
507         wdev_unlock(wdev);
508
509         return err;
510 }
511
512 int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
513                            struct net_device *dev, const u8 *bssid,
514                            const u8 *ie, int ie_len, u16 reason)
515 {
516         struct wireless_dev *wdev = dev->ieee80211_ptr;
517         struct cfg80211_deauth_request req;
518         int i;
519
520         ASSERT_WDEV_LOCK(wdev);
521
522         memset(&req, 0, sizeof(req));
523         req.reason_code = reason;
524         req.ie = ie;
525         req.ie_len = ie_len;
526         if (wdev->current_bss &&
527             memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0) {
528                 req.bss = &wdev->current_bss->pub;
529         } else for (i = 0; i < MAX_AUTH_BSSES; i++) {
530                 if (wdev->auth_bsses[i] &&
531                     memcmp(bssid, wdev->auth_bsses[i]->pub.bssid, ETH_ALEN) == 0) {
532                         req.bss = &wdev->auth_bsses[i]->pub;
533                         break;
534                 }
535                 if (wdev->authtry_bsses[i] &&
536                     memcmp(bssid, wdev->authtry_bsses[i]->pub.bssid, ETH_ALEN) == 0) {
537                         req.bss = &wdev->authtry_bsses[i]->pub;
538                         break;
539                 }
540         }
541
542         if (!req.bss)
543                 return -ENOTCONN;
544
545         return rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
546 }
547
548 int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
549                          struct net_device *dev, const u8 *bssid,
550                          const u8 *ie, int ie_len, u16 reason)
551 {
552         struct wireless_dev *wdev = dev->ieee80211_ptr;
553         int err;
554
555         wdev_lock(wdev);
556         err = __cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason);
557         wdev_unlock(wdev);
558
559         return err;
560 }
561
562 static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
563                                     struct net_device *dev, const u8 *bssid,
564                                     const u8 *ie, int ie_len, u16 reason)
565 {
566         struct wireless_dev *wdev = dev->ieee80211_ptr;
567         struct cfg80211_disassoc_request req;
568
569         ASSERT_WDEV_LOCK(wdev);
570
571         if (wdev->sme_state != CFG80211_SME_CONNECTED)
572                 return -ENOTCONN;
573
574         if (WARN_ON(!wdev->current_bss))
575                 return -ENOTCONN;
576
577         memset(&req, 0, sizeof(req));
578         req.reason_code = reason;
579         req.ie = ie;
580         req.ie_len = ie_len;
581         if (memcmp(wdev->current_bss->pub.bssid, bssid, ETH_ALEN) == 0)
582                 req.bss = &wdev->current_bss->pub;
583         else
584                 return -ENOTCONN;
585
586         return rdev->ops->disassoc(&rdev->wiphy, dev, &req, wdev);
587 }
588
589 int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
590                            struct net_device *dev, const u8 *bssid,
591                            const u8 *ie, int ie_len, u16 reason)
592 {
593         struct wireless_dev *wdev = dev->ieee80211_ptr;
594         int err;
595
596         wdev_lock(wdev);
597         err = __cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason);
598         wdev_unlock(wdev);
599
600         return err;
601 }
602
603 void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
604                         struct net_device *dev)
605 {
606         struct wireless_dev *wdev = dev->ieee80211_ptr;
607         struct cfg80211_deauth_request req;
608         int i;
609
610         ASSERT_WDEV_LOCK(wdev);
611
612         if (!rdev->ops->deauth)
613                 return;
614
615         memset(&req, 0, sizeof(req));
616         req.reason_code = WLAN_REASON_DEAUTH_LEAVING;
617         req.ie = NULL;
618         req.ie_len = 0;
619
620         if (wdev->current_bss) {
621                 req.bss = &wdev->current_bss->pub;
622                 rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
623                 if (wdev->current_bss) {
624                         cfg80211_unhold_bss(wdev->current_bss);
625                         cfg80211_put_bss(&wdev->current_bss->pub);
626                         wdev->current_bss = NULL;
627                 }
628         }
629
630         for (i = 0; i < MAX_AUTH_BSSES; i++) {
631                 if (wdev->auth_bsses[i]) {
632                         req.bss = &wdev->auth_bsses[i]->pub;
633                         rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
634                         if (wdev->auth_bsses[i]) {
635                                 cfg80211_unhold_bss(wdev->auth_bsses[i]);
636                                 cfg80211_put_bss(&wdev->auth_bsses[i]->pub);
637                                 wdev->auth_bsses[i] = NULL;
638                         }
639                 }
640                 if (wdev->authtry_bsses[i]) {
641                         req.bss = &wdev->authtry_bsses[i]->pub;
642                         rdev->ops->deauth(&rdev->wiphy, dev, &req, wdev);
643                         if (wdev->authtry_bsses[i]) {
644                                 cfg80211_unhold_bss(wdev->authtry_bsses[i]);
645                                 cfg80211_put_bss(&wdev->authtry_bsses[i]->pub);
646                                 wdev->authtry_bsses[i] = NULL;
647                         }
648                 }
649         }
650 }