]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - net/wireless/mlme.c
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git...
[mirror_ubuntu-zesty-kernel.git] / net / wireless / mlme.c
CommitLineData
6039f6d2
JM
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>
c6fb08aa 9#include <linux/etherdevice.h>
6039f6d2
JM
10#include <linux/netdevice.h>
11#include <linux/nl80211.h>
5a0e3ad6 12#include <linux/slab.h>
a9a11622 13#include <linux/wireless.h>
6039f6d2 14#include <net/cfg80211.h>
a9a11622 15#include <net/iw_handler.h>
6039f6d2
JM
16#include "core.h"
17#include "nl80211.h"
e35e4d28
HG
18#include "rdev-ops.h"
19
6039f6d2 20
cb0b4beb 21void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len)
6039f6d2 22{
19957bb3
JB
23 struct wireless_dev *wdev = dev->ieee80211_ptr;
24 struct wiphy *wiphy = wdev->wiphy;
6039f6d2 25 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
19957bb3 26
4ee3e063 27 trace_cfg80211_send_rx_auth(dev);
667503dd 28 wdev_lock(wdev);
cb0b4beb 29
95de817b
JB
30 nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL);
31 cfg80211_sme_rx_auth(dev, buf, len);
667503dd
JB
32
33 wdev_unlock(wdev);
6039f6d2
JM
34}
35EXPORT_SYMBOL(cfg80211_send_rx_auth);
36
95de817b
JB
37void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss,
38 const u8 *buf, size_t len)
6039f6d2 39{
6829c878
JB
40 u16 status_code;
41 struct wireless_dev *wdev = dev->ieee80211_ptr;
42 struct wiphy *wiphy = wdev->wiphy;
6039f6d2 43 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
6829c878
JB
44 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
45 u8 *ie = mgmt->u.assoc_resp.variable;
95de817b 46 int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
6829c878 47
4ee3e063 48 trace_cfg80211_send_rx_assoc(dev, bss);
667503dd 49 wdev_lock(wdev);
cb0b4beb 50
6829c878
JB
51 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
52
f401a6f7
JB
53 /*
54 * This is a bit of a hack, we don't notify userspace of
55 * a (re-)association reply if we tried to send a reassoc
56 * and got a reject -- we only try again with an assoc
57 * frame instead of reassoc.
58 */
59 if (status_code != WLAN_STATUS_SUCCESS && wdev->conn &&
95de817b
JB
60 cfg80211_sme_failed_reassoc(wdev)) {
61 cfg80211_put_bss(bss);
f401a6f7 62 goto out;
95de817b 63 }
f401a6f7 64
cb0b4beb 65 nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL);
6829c878 66
95de817b 67 if (status_code != WLAN_STATUS_SUCCESS && wdev->conn) {
7d930bc3 68 cfg80211_sme_failed_assoc(wdev);
7d930bc3
JB
69 /*
70 * do not call connect_result() now because the
71 * sme will schedule work that does it later.
72 */
95de817b 73 cfg80211_put_bss(bss);
7d930bc3 74 goto out;
df7fc0f9
JB
75 }
76
ea416a79
JB
77 if (!wdev->conn && wdev->sme_state == CFG80211_SME_IDLE) {
78 /*
79 * This is for the userspace SME, the CONNECTING
80 * state will be changed to CONNECTED by
81 * __cfg80211_connect_result() below.
82 */
83 wdev->sme_state = CFG80211_SME_CONNECTING;
84 }
85
95de817b 86 /* this consumes the bss reference */
df7fc0f9
JB
87 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs,
88 status_code,
95de817b 89 status_code == WLAN_STATUS_SUCCESS, bss);
f401a6f7 90 out:
667503dd 91 wdev_unlock(wdev);
6039f6d2
JM
92}
93EXPORT_SYMBOL(cfg80211_send_rx_assoc);
94
ce470613 95void __cfg80211_send_deauth(struct net_device *dev,
667503dd 96 const u8 *buf, size_t len)
6039f6d2 97{
6829c878
JB
98 struct wireless_dev *wdev = dev->ieee80211_ptr;
99 struct wiphy *wiphy = wdev->wiphy;
6039f6d2 100 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
6829c878 101 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
19957bb3 102 const u8 *bssid = mgmt->bssid;
95de817b 103 bool was_current = false;
6829c878 104
4ee3e063 105 trace___cfg80211_send_deauth(dev);
667503dd 106 ASSERT_WDEV_LOCK(wdev);
cb0b4beb 107
19957bb3 108 if (wdev->current_bss &&
ac422d3c 109 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
19957bb3
JB
110 cfg80211_unhold_bss(wdev->current_bss);
111 cfg80211_put_bss(&wdev->current_bss->pub);
112 wdev->current_bss = NULL;
3f3b6a8d 113 was_current = true;
19957bb3 114 }
19957bb3 115
5fba4af3
JB
116 nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL);
117
3f3b6a8d 118 if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) {
6829c878
JB
119 u16 reason_code;
120 bool from_ap;
121
122 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
123
ac422d3c 124 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr);
667503dd 125 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
6829c878 126 } else if (wdev->sme_state == CFG80211_SME_CONNECTING) {
667503dd
JB
127 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, NULL, 0,
128 WLAN_STATUS_UNSPECIFIED_FAILURE,
df7fc0f9 129 false, NULL);
667503dd
JB
130 }
131}
ce470613 132EXPORT_SYMBOL(__cfg80211_send_deauth);
667503dd 133
ce470613 134void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len)
667503dd
JB
135{
136 struct wireless_dev *wdev = dev->ieee80211_ptr;
137
ce470613
HS
138 wdev_lock(wdev);
139 __cfg80211_send_deauth(dev, buf, len);
140 wdev_unlock(wdev);
6039f6d2 141}
53b46b84 142EXPORT_SYMBOL(cfg80211_send_deauth);
6039f6d2 143
ce470613 144void __cfg80211_send_disassoc(struct net_device *dev,
667503dd 145 const u8 *buf, size_t len)
6039f6d2 146{
6829c878
JB
147 struct wireless_dev *wdev = dev->ieee80211_ptr;
148 struct wiphy *wiphy = wdev->wiphy;
6039f6d2 149 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
6829c878 150 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
19957bb3 151 const u8 *bssid = mgmt->bssid;
19957bb3
JB
152 u16 reason_code;
153 bool from_ap;
6829c878 154
4ee3e063 155 trace___cfg80211_send_disassoc(dev);
596a07c1 156 ASSERT_WDEV_LOCK(wdev);
cb0b4beb
JB
157
158 nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL);
a3b8b056 159
596a07c1
JB
160 if (wdev->sme_state != CFG80211_SME_CONNECTED)
161 return;
6829c878 162
19957bb3 163 if (wdev->current_bss &&
ac422d3c 164 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
95de817b
JB
165 cfg80211_sme_disassoc(dev, wdev->current_bss);
166 cfg80211_unhold_bss(wdev->current_bss);
167 cfg80211_put_bss(&wdev->current_bss->pub);
168 wdev->current_bss = NULL;
19957bb3
JB
169 } else
170 WARN_ON(1);
6829c878 171
6829c878 172
19957bb3
JB
173 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
174
ac422d3c 175 from_ap = !ether_addr_equal(mgmt->sa, dev->dev_addr);
667503dd 176 __cfg80211_disconnected(dev, NULL, 0, reason_code, from_ap);
667503dd 177}
ce470613 178EXPORT_SYMBOL(__cfg80211_send_disassoc);
667503dd 179
ce470613 180void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len)
667503dd
JB
181{
182 struct wireless_dev *wdev = dev->ieee80211_ptr;
183
ce470613
HS
184 wdev_lock(wdev);
185 __cfg80211_send_disassoc(dev, buf, len);
186 wdev_unlock(wdev);
1965c853 187}
6829c878 188EXPORT_SYMBOL(cfg80211_send_disassoc);
1965c853 189
cf4e594e
JM
190void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
191 size_t len)
192{
193 struct wireless_dev *wdev = dev->ieee80211_ptr;
194 struct wiphy *wiphy = wdev->wiphy;
195 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
196
4ee3e063 197 trace_cfg80211_send_unprot_deauth(dev);
cf4e594e
JM
198 nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC);
199}
200EXPORT_SYMBOL(cfg80211_send_unprot_deauth);
201
202void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf,
203 size_t len)
204{
205 struct wireless_dev *wdev = dev->ieee80211_ptr;
206 struct wiphy *wiphy = wdev->wiphy;
207 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
208
4ee3e063 209 trace_cfg80211_send_unprot_disassoc(dev);
cf4e594e
JM
210 nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC);
211}
212EXPORT_SYMBOL(cfg80211_send_unprot_disassoc);
213
a58ce43f
JB
214void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr)
215{
216 struct wireless_dev *wdev = dev->ieee80211_ptr;
217 struct wiphy *wiphy = wdev->wiphy;
218 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
219
4ee3e063 220 trace_cfg80211_send_auth_timeout(dev, addr);
a58ce43f
JB
221 wdev_lock(wdev);
222
223 nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
224 if (wdev->sme_state == CFG80211_SME_CONNECTING)
225 __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
226 WLAN_STATUS_UNSPECIFIED_FAILURE,
227 false, NULL);
228
667503dd 229 wdev_unlock(wdev);
1965c853
JM
230}
231EXPORT_SYMBOL(cfg80211_send_auth_timeout);
232
cb0b4beb 233void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr)
1965c853 234{
6829c878
JB
235 struct wireless_dev *wdev = dev->ieee80211_ptr;
236 struct wiphy *wiphy = wdev->wiphy;
1965c853 237 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
19957bb3 238
4ee3e063 239 trace_cfg80211_send_assoc_timeout(dev, addr);
667503dd 240 wdev_lock(wdev);
cb0b4beb
JB
241
242 nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL);
6829c878 243 if (wdev->sme_state == CFG80211_SME_CONNECTING)
667503dd
JB
244 __cfg80211_connect_result(dev, addr, NULL, 0, NULL, 0,
245 WLAN_STATUS_UNSPECIFIED_FAILURE,
df7fc0f9 246 false, NULL);
19957bb3 247
667503dd 248 wdev_unlock(wdev);
1965c853
JM
249}
250EXPORT_SYMBOL(cfg80211_send_assoc_timeout);
251
a3b8b056
JM
252void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
253 enum nl80211_key_type key_type, int key_id,
e6d6e342 254 const u8 *tsc, gfp_t gfp)
a3b8b056
JM
255{
256 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
257 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
3d23e349 258#ifdef CONFIG_CFG80211_WEXT
f58d4ed9 259 union iwreq_data wrqu;
e6d6e342 260 char *buf = kmalloc(128, gfp);
f58d4ed9
JB
261
262 if (buf) {
263 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
264 "keyid=%d %scast addr=%pM)", key_id,
265 key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
266 addr);
267 memset(&wrqu, 0, sizeof(wrqu));
268 wrqu.data.length = strlen(buf);
269 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
270 kfree(buf);
271 }
272#endif
273
4ee3e063 274 trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc);
e6d6e342 275 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
a3b8b056
JM
276}
277EXPORT_SYMBOL(cfg80211_michael_mic_failure);
19957bb3
JB
278
279/* some MLME handling for userspace SME */
667503dd
JB
280int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
281 struct net_device *dev,
282 struct ieee80211_channel *chan,
283 enum nl80211_auth_type auth_type,
284 const u8 *bssid,
285 const u8 *ssid, int ssid_len,
fffd0934 286 const u8 *ie, int ie_len,
e39e5b5e
JM
287 const u8 *key, int key_len, int key_idx,
288 const u8 *sae_data, int sae_data_len)
19957bb3
JB
289{
290 struct wireless_dev *wdev = dev->ieee80211_ptr;
291 struct cfg80211_auth_request req;
95de817b 292 int err;
19957bb3 293
667503dd
JB
294 ASSERT_WDEV_LOCK(wdev);
295
fffd0934
JB
296 if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
297 if (!key || !key_len || key_idx < 0 || key_idx > 4)
298 return -EINVAL;
299
0a9b5e17 300 if (wdev->current_bss &&
ac422d3c 301 ether_addr_equal(bssid, wdev->current_bss->pub.bssid))
0a9b5e17
JB
302 return -EALREADY;
303
19957bb3
JB
304 memset(&req, 0, sizeof(req));
305
306 req.ie = ie;
307 req.ie_len = ie_len;
e39e5b5e
JM
308 req.sae_data = sae_data;
309 req.sae_data_len = sae_data_len;
19957bb3
JB
310 req.auth_type = auth_type;
311 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
312 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
fffd0934
JB
313 req.key = key;
314 req.key_len = key_len;
315 req.key_idx = key_idx;
19957bb3
JB
316 if (!req.bss)
317 return -ENOENT;
318
e4e32459
MK
319 err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
320 CHAN_MODE_SHARED);
321 if (err)
322 goto out;
323
e35e4d28 324 err = rdev_auth(rdev, dev, &req);
19957bb3 325
e4e32459 326out:
95de817b 327 cfg80211_put_bss(req.bss);
19957bb3
JB
328 return err;
329}
330
667503dd
JB
331int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
332 struct net_device *dev, struct ieee80211_channel *chan,
333 enum nl80211_auth_type auth_type, const u8 *bssid,
334 const u8 *ssid, int ssid_len,
fffd0934 335 const u8 *ie, int ie_len,
e39e5b5e
JM
336 const u8 *key, int key_len, int key_idx,
337 const u8 *sae_data, int sae_data_len)
667503dd
JB
338{
339 int err;
340
e4e32459 341 mutex_lock(&rdev->devlist_mtx);
667503dd
JB
342 wdev_lock(dev->ieee80211_ptr);
343 err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
fffd0934 344 ssid, ssid_len, ie, ie_len,
e39e5b5e
JM
345 key, key_len, key_idx,
346 sae_data, sae_data_len);
667503dd 347 wdev_unlock(dev->ieee80211_ptr);
e4e32459 348 mutex_unlock(&rdev->devlist_mtx);
667503dd
JB
349
350 return err;
351}
352
7e7c8926
BG
353/* Do a logical ht_capa &= ht_capa_mask. */
354void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
355 const struct ieee80211_ht_cap *ht_capa_mask)
356{
357 int i;
358 u8 *p1, *p2;
359 if (!ht_capa_mask) {
360 memset(ht_capa, 0, sizeof(*ht_capa));
361 return;
362 }
363
364 p1 = (u8*)(ht_capa);
365 p2 = (u8*)(ht_capa_mask);
366 for (i = 0; i<sizeof(*ht_capa); i++)
367 p1[i] &= p2[i];
368}
369
667503dd
JB
370int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
371 struct net_device *dev,
372 struct ieee80211_channel *chan,
373 const u8 *bssid, const u8 *prev_bssid,
374 const u8 *ssid, int ssid_len,
375 const u8 *ie, int ie_len, bool use_mfp,
7e7c8926
BG
376 struct cfg80211_crypto_settings *crypt,
377 u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
378 struct ieee80211_ht_cap *ht_capa_mask)
19957bb3
JB
379{
380 struct wireless_dev *wdev = dev->ieee80211_ptr;
381 struct cfg80211_assoc_request req;
95de817b 382 int err;
24b6b15f 383 bool was_connected = false;
19957bb3 384
667503dd
JB
385 ASSERT_WDEV_LOCK(wdev);
386
19957bb3
JB
387 memset(&req, 0, sizeof(req));
388
24b6b15f 389 if (wdev->current_bss && prev_bssid &&
ac422d3c 390 ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) {
24b6b15f
JM
391 /*
392 * Trying to reassociate: Allow this to proceed and let the old
393 * association to be dropped when the new one is completed.
394 */
395 if (wdev->sme_state == CFG80211_SME_CONNECTED) {
396 was_connected = true;
397 wdev->sme_state = CFG80211_SME_CONNECTING;
398 }
399 } else if (wdev->current_bss)
19957bb3
JB
400 return -EALREADY;
401
402 req.ie = ie;
403 req.ie_len = ie_len;
404 memcpy(&req.crypto, crypt, sizeof(req.crypto));
405 req.use_mfp = use_mfp;
3e5d7649 406 req.prev_bssid = prev_bssid;
7e7c8926
BG
407 req.flags = assoc_flags;
408 if (ht_capa)
409 memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa));
410 if (ht_capa_mask)
411 memcpy(&req.ht_capa_mask, ht_capa_mask,
412 sizeof(req.ht_capa_mask));
413 cfg80211_oper_and_ht_capa(&req.ht_capa_mask,
414 rdev->wiphy.ht_capa_mod_mask);
415
19957bb3
JB
416 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
417 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
24b6b15f
JM
418 if (!req.bss) {
419 if (was_connected)
420 wdev->sme_state = CFG80211_SME_CONNECTED;
19957bb3 421 return -ENOENT;
24b6b15f 422 }
19957bb3 423
e4e32459
MK
424 err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
425 CHAN_MODE_SHARED);
426 if (err)
427 goto out;
428
e35e4d28 429 err = rdev_assoc(rdev, dev, &req);
19957bb3 430
e4e32459 431out:
95de817b
JB
432 if (err) {
433 if (was_connected)
434 wdev->sme_state = CFG80211_SME_CONNECTED;
435 cfg80211_put_bss(req.bss);
19957bb3
JB
436 }
437
19957bb3
JB
438 return err;
439}
440
667503dd
JB
441int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
442 struct net_device *dev,
443 struct ieee80211_channel *chan,
444 const u8 *bssid, const u8 *prev_bssid,
445 const u8 *ssid, int ssid_len,
446 const u8 *ie, int ie_len, bool use_mfp,
7e7c8926
BG
447 struct cfg80211_crypto_settings *crypt,
448 u32 assoc_flags, struct ieee80211_ht_cap *ht_capa,
449 struct ieee80211_ht_cap *ht_capa_mask)
667503dd
JB
450{
451 struct wireless_dev *wdev = dev->ieee80211_ptr;
452 int err;
453
e4e32459 454 mutex_lock(&rdev->devlist_mtx);
667503dd
JB
455 wdev_lock(wdev);
456 err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
7e7c8926
BG
457 ssid, ssid_len, ie, ie_len, use_mfp, crypt,
458 assoc_flags, ht_capa, ht_capa_mask);
667503dd 459 wdev_unlock(wdev);
e4e32459 460 mutex_unlock(&rdev->devlist_mtx);
667503dd
JB
461
462 return err;
463}
464
465int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
466 struct net_device *dev, const u8 *bssid,
d5cdfacb
JM
467 const u8 *ie, int ie_len, u16 reason,
468 bool local_state_change)
19957bb3
JB
469{
470 struct wireless_dev *wdev = dev->ieee80211_ptr;
95de817b
JB
471 struct cfg80211_deauth_request req = {
472 .bssid = bssid,
473 .reason_code = reason,
474 .ie = ie,
475 .ie_len = ie_len,
6863255b 476 .local_state_change = local_state_change,
95de817b 477 };
19957bb3 478
667503dd
JB
479 ASSERT_WDEV_LOCK(wdev);
480
6863255b
SG
481 if (local_state_change && (!wdev->current_bss ||
482 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
95de817b 483 return 0;
19957bb3 484
e35e4d28 485 return rdev_deauth(rdev, dev, &req);
19957bb3
JB
486}
487
667503dd
JB
488int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
489 struct net_device *dev, const u8 *bssid,
d5cdfacb
JM
490 const u8 *ie, int ie_len, u16 reason,
491 bool local_state_change)
667503dd
JB
492{
493 struct wireless_dev *wdev = dev->ieee80211_ptr;
494 int err;
495
496 wdev_lock(wdev);
d5cdfacb
JM
497 err = __cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason,
498 local_state_change);
667503dd
JB
499 wdev_unlock(wdev);
500
501 return err;
502}
503
504static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
505 struct net_device *dev, const u8 *bssid,
d5cdfacb
JM
506 const u8 *ie, int ie_len, u16 reason,
507 bool local_state_change)
19957bb3
JB
508{
509 struct wireless_dev *wdev = dev->ieee80211_ptr;
510 struct cfg80211_disassoc_request req;
511
667503dd
JB
512 ASSERT_WDEV_LOCK(wdev);
513
f9d6b402
JB
514 if (wdev->sme_state != CFG80211_SME_CONNECTED)
515 return -ENOTCONN;
516
517 if (WARN_ON(!wdev->current_bss))
518 return -ENOTCONN;
519
19957bb3
JB
520 memset(&req, 0, sizeof(req));
521 req.reason_code = reason;
d5cdfacb 522 req.local_state_change = local_state_change;
19957bb3
JB
523 req.ie = ie;
524 req.ie_len = ie_len;
ac422d3c 525 if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid))
19957bb3
JB
526 req.bss = &wdev->current_bss->pub;
527 else
528 return -ENOTCONN;
529
e35e4d28 530 return rdev_disassoc(rdev, dev, &req);
667503dd
JB
531}
532
533int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
534 struct net_device *dev, const u8 *bssid,
d5cdfacb
JM
535 const u8 *ie, int ie_len, u16 reason,
536 bool local_state_change)
667503dd
JB
537{
538 struct wireless_dev *wdev = dev->ieee80211_ptr;
539 int err;
540
541 wdev_lock(wdev);
d5cdfacb
JM
542 err = __cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason,
543 local_state_change);
667503dd
JB
544 wdev_unlock(wdev);
545
546 return err;
19957bb3
JB
547}
548
549void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
550 struct net_device *dev)
551{
552 struct wireless_dev *wdev = dev->ieee80211_ptr;
553 struct cfg80211_deauth_request req;
95de817b 554 u8 bssid[ETH_ALEN];
19957bb3 555
667503dd
JB
556 ASSERT_WDEV_LOCK(wdev);
557
19957bb3
JB
558 if (!rdev->ops->deauth)
559 return;
560
561 memset(&req, 0, sizeof(req));
562 req.reason_code = WLAN_REASON_DEAUTH_LEAVING;
563 req.ie = NULL;
564 req.ie_len = 0;
565
95de817b
JB
566 if (!wdev->current_bss)
567 return;
19957bb3 568
95de817b
JB
569 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
570 req.bssid = bssid;
e35e4d28 571 rdev_deauth(rdev, dev, &req);
95de817b
JB
572
573 if (wdev->current_bss) {
574 cfg80211_unhold_bss(wdev->current_bss);
575 cfg80211_put_bss(&wdev->current_bss->pub);
576 wdev->current_bss = NULL;
19957bb3
JB
577 }
578}
9588bbd5 579
71bbc994 580void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie,
9588bbd5 581 struct ieee80211_channel *chan,
9588bbd5
JM
582 unsigned int duration, gfp_t gfp)
583{
71bbc994 584 struct wiphy *wiphy = wdev->wiphy;
9588bbd5
JM
585 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
586
42d97a59
JB
587 trace_cfg80211_ready_on_channel(wdev, cookie, chan, duration);
588 nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, duration, gfp);
9588bbd5
JM
589}
590EXPORT_SYMBOL(cfg80211_ready_on_channel);
591
71bbc994 592void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie,
9588bbd5 593 struct ieee80211_channel *chan,
9588bbd5
JM
594 gfp_t gfp)
595{
71bbc994 596 struct wiphy *wiphy = wdev->wiphy;
9588bbd5
JM
597 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
598
42d97a59
JB
599 trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan);
600 nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, gfp);
9588bbd5
JM
601}
602EXPORT_SYMBOL(cfg80211_remain_on_channel_expired);
98b62183
JB
603
604void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
605 struct station_info *sinfo, gfp_t gfp)
606{
607 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
608 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
609
4ee3e063 610 trace_cfg80211_new_sta(dev, mac_addr, sinfo);
98b62183
JB
611 nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp);
612}
613EXPORT_SYMBOL(cfg80211_new_sta);
026331c4 614
ec15e68b
JM
615void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
616{
617 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
618 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
619
4ee3e063 620 trace_cfg80211_del_sta(dev, mac_addr);
ec15e68b
JM
621 nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp);
622}
623EXPORT_SYMBOL(cfg80211_del_sta);
624
ed44a951
PP
625void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
626 enum nl80211_connect_failed_reason reason,
627 gfp_t gfp)
628{
629 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
630 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
631
632 nl80211_send_conn_failed_event(rdev, dev, mac_addr, reason, gfp);
633}
634EXPORT_SYMBOL(cfg80211_conn_failed);
635
2e161f78 636struct cfg80211_mgmt_registration {
026331c4
JM
637 struct list_head list;
638
15e47304 639 u32 nlportid;
026331c4
JM
640
641 int match_len;
642
2e161f78
JB
643 __le16 frame_type;
644
026331c4
JM
645 u8 match[];
646};
647
15e47304 648int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
2e161f78
JB
649 u16 frame_type, const u8 *match_data,
650 int match_len)
026331c4 651{
271733cf
JB
652 struct wiphy *wiphy = wdev->wiphy;
653 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
2e161f78 654 struct cfg80211_mgmt_registration *reg, *nreg;
026331c4 655 int err = 0;
2e161f78
JB
656 u16 mgmt_type;
657
658 if (!wdev->wiphy->mgmt_stypes)
659 return -EOPNOTSUPP;
660
661 if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
662 return -EINVAL;
663
664 if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE))
665 return -EINVAL;
666
667 mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
668 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type)))
669 return -EINVAL;
026331c4
JM
670
671 nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL);
672 if (!nreg)
673 return -ENOMEM;
674
2e161f78 675 spin_lock_bh(&wdev->mgmt_registrations_lock);
026331c4 676
2e161f78 677 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
026331c4
JM
678 int mlen = min(match_len, reg->match_len);
679
2e161f78
JB
680 if (frame_type != le16_to_cpu(reg->frame_type))
681 continue;
682
026331c4
JM
683 if (memcmp(reg->match, match_data, mlen) == 0) {
684 err = -EALREADY;
685 break;
686 }
687 }
688
689 if (err) {
690 kfree(nreg);
691 goto out;
692 }
693
694 memcpy(nreg->match, match_data, match_len);
695 nreg->match_len = match_len;
15e47304 696 nreg->nlportid = snd_portid;
2e161f78
JB
697 nreg->frame_type = cpu_to_le16(frame_type);
698 list_add(&nreg->list, &wdev->mgmt_registrations);
026331c4 699
271733cf 700 if (rdev->ops->mgmt_frame_register)
e35e4d28 701 rdev_mgmt_frame_register(rdev, wdev, frame_type, true);
271733cf 702
026331c4 703 out:
2e161f78 704 spin_unlock_bh(&wdev->mgmt_registrations_lock);
271733cf 705
026331c4
JM
706 return err;
707}
708
15e47304 709void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
026331c4 710{
271733cf
JB
711 struct wiphy *wiphy = wdev->wiphy;
712 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
2e161f78 713 struct cfg80211_mgmt_registration *reg, *tmp;
026331c4 714
2e161f78 715 spin_lock_bh(&wdev->mgmt_registrations_lock);
026331c4 716
2e161f78 717 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
15e47304 718 if (reg->nlportid != nlportid)
271733cf
JB
719 continue;
720
721 if (rdev->ops->mgmt_frame_register) {
722 u16 frame_type = le16_to_cpu(reg->frame_type);
723
e35e4d28
HG
724 rdev_mgmt_frame_register(rdev, wdev,
725 frame_type, false);
026331c4 726 }
271733cf
JB
727
728 list_del(&reg->list);
729 kfree(reg);
026331c4
JM
730 }
731
2e161f78 732 spin_unlock_bh(&wdev->mgmt_registrations_lock);
28946da7 733
15e47304
EB
734 if (nlportid == wdev->ap_unexpected_nlportid)
735 wdev->ap_unexpected_nlportid = 0;
026331c4
JM
736}
737
2e161f78 738void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
026331c4 739{
2e161f78 740 struct cfg80211_mgmt_registration *reg, *tmp;
026331c4 741
2e161f78 742 spin_lock_bh(&wdev->mgmt_registrations_lock);
026331c4 743
2e161f78 744 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
026331c4
JM
745 list_del(&reg->list);
746 kfree(reg);
747 }
748
2e161f78 749 spin_unlock_bh(&wdev->mgmt_registrations_lock);
026331c4
JM
750}
751
2e161f78 752int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
71bbc994 753 struct wireless_dev *wdev,
f7ca38df 754 struct ieee80211_channel *chan, bool offchan,
42d97a59
JB
755 unsigned int wait, const u8 *buf, size_t len,
756 bool no_cck, bool dont_wait_for_ack, u64 *cookie)
026331c4 757{
026331c4 758 const struct ieee80211_mgmt *mgmt;
2e161f78
JB
759 u16 stype;
760
761 if (!wdev->wiphy->mgmt_stypes)
762 return -EOPNOTSUPP;
026331c4 763
2e161f78 764 if (!rdev->ops->mgmt_tx)
026331c4 765 return -EOPNOTSUPP;
2e161f78 766
026331c4
JM
767 if (len < 24 + 1)
768 return -EINVAL;
769
770 mgmt = (const struct ieee80211_mgmt *) buf;
2e161f78
JB
771
772 if (!ieee80211_is_mgmt(mgmt->frame_control))
026331c4 773 return -EINVAL;
2e161f78
JB
774
775 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
776 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4)))
777 return -EINVAL;
778
779 if (ieee80211_is_action(mgmt->frame_control) &&
780 mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) {
663fcafd
JB
781 int err = 0;
782
fe100acd
JB
783 wdev_lock(wdev);
784
663fcafd
JB
785 switch (wdev->iftype) {
786 case NL80211_IFTYPE_ADHOC:
787 case NL80211_IFTYPE_STATION:
788 case NL80211_IFTYPE_P2P_CLIENT:
789 if (!wdev->current_bss) {
790 err = -ENOTCONN;
791 break;
792 }
793
ac422d3c
JP
794 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
795 mgmt->bssid)) {
663fcafd
JB
796 err = -ENOTCONN;
797 break;
798 }
799
800 /*
801 * check for IBSS DA must be done by driver as
802 * cfg80211 doesn't track the stations
803 */
804 if (wdev->iftype == NL80211_IFTYPE_ADHOC)
805 break;
fe100acd 806
663fcafd 807 /* for station, check that DA is the AP */
ac422d3c
JP
808 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
809 mgmt->da)) {
663fcafd
JB
810 err = -ENOTCONN;
811 break;
812 }
813 break;
814 case NL80211_IFTYPE_AP:
815 case NL80211_IFTYPE_P2P_GO:
816 case NL80211_IFTYPE_AP_VLAN:
98104fde 817 if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev)))
663fcafd
JB
818 err = -EINVAL;
819 break;
0778a6a3 820 case NL80211_IFTYPE_MESH_POINT:
ac422d3c 821 if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) {
0778a6a3
JC
822 err = -EINVAL;
823 break;
824 }
825 /*
826 * check for mesh DA must be done by driver as
827 * cfg80211 doesn't track the stations
828 */
829 break;
98104fde
JB
830 case NL80211_IFTYPE_P2P_DEVICE:
831 /*
832 * fall through, P2P device only supports
833 * public action frames
834 */
663fcafd
JB
835 default:
836 err = -EOPNOTSUPP;
837 break;
838 }
fe100acd 839 wdev_unlock(wdev);
663fcafd
JB
840
841 if (err)
842 return err;
026331c4
JM
843 }
844
98104fde 845 if (!ether_addr_equal(mgmt->sa, wdev_address(wdev)))
026331c4
JM
846 return -EINVAL;
847
848 /* Transmit the Action frame as requested by user space */
e35e4d28 849 return rdev_mgmt_tx(rdev, wdev, chan, offchan,
e35e4d28
HG
850 wait, buf, len, no_cck, dont_wait_for_ack,
851 cookie);
026331c4
JM
852}
853
71bbc994 854bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
804483e9 855 const u8 *buf, size_t len, gfp_t gfp)
026331c4 856{
026331c4
JM
857 struct wiphy *wiphy = wdev->wiphy;
858 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
2e161f78
JB
859 struct cfg80211_mgmt_registration *reg;
860 const struct ieee80211_txrx_stypes *stypes =
861 &wiphy->mgmt_stypes[wdev->iftype];
862 struct ieee80211_mgmt *mgmt = (void *)buf;
863 const u8 *data;
864 int data_len;
026331c4 865 bool result = false;
2e161f78
JB
866 __le16 ftype = mgmt->frame_control &
867 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
868 u16 stype;
026331c4 869
4ee3e063 870 trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm);
2e161f78 871 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
026331c4 872
4ee3e063
BL
873 if (!(stypes->rx & BIT(stype))) {
874 trace_cfg80211_return_bool(false);
2e161f78 875 return false;
4ee3e063 876 }
026331c4 877
2e161f78
JB
878 data = buf + ieee80211_hdrlen(mgmt->frame_control);
879 data_len = len - ieee80211_hdrlen(mgmt->frame_control);
880
881 spin_lock_bh(&wdev->mgmt_registrations_lock);
882
883 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
884 if (reg->frame_type != ftype)
885 continue;
026331c4 886
2e161f78 887 if (reg->match_len > data_len)
026331c4
JM
888 continue;
889
2e161f78 890 if (memcmp(reg->match, data, reg->match_len))
026331c4
JM
891 continue;
892
893 /* found match! */
894
895 /* Indicate the received Action frame to user space */
15e47304 896 if (nl80211_send_mgmt(rdev, wdev, reg->nlportid,
804483e9 897 freq, sig_mbm,
2e161f78 898 buf, len, gfp))
026331c4
JM
899 continue;
900
901 result = true;
902 break;
903 }
904
2e161f78 905 spin_unlock_bh(&wdev->mgmt_registrations_lock);
026331c4 906
4ee3e063 907 trace_cfg80211_return_bool(result);
026331c4
JM
908 return result;
909}
2e161f78 910EXPORT_SYMBOL(cfg80211_rx_mgmt);
026331c4 911
71bbc994 912void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
2e161f78 913 const u8 *buf, size_t len, bool ack, gfp_t gfp)
026331c4 914{
026331c4
JM
915 struct wiphy *wiphy = wdev->wiphy;
916 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
917
4ee3e063
BL
918 trace_cfg80211_mgmt_tx_status(wdev, cookie, ack);
919
026331c4 920 /* Indicate TX status of the Action frame to user space */
71bbc994 921 nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp);
026331c4 922}
2e161f78 923EXPORT_SYMBOL(cfg80211_mgmt_tx_status);
d6dc1a38
JO
924
925void cfg80211_cqm_rssi_notify(struct net_device *dev,
926 enum nl80211_cqm_rssi_threshold_event rssi_event,
927 gfp_t gfp)
928{
929 struct wireless_dev *wdev = dev->ieee80211_ptr;
930 struct wiphy *wiphy = wdev->wiphy;
931 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
932
4ee3e063
BL
933 trace_cfg80211_cqm_rssi_notify(dev, rssi_event);
934
d6dc1a38
JO
935 /* Indicate roaming trigger event to user space */
936 nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp);
937}
938EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
c063dbf5
JB
939
940void cfg80211_cqm_pktloss_notify(struct net_device *dev,
941 const u8 *peer, u32 num_packets, gfp_t gfp)
942{
943 struct wireless_dev *wdev = dev->ieee80211_ptr;
944 struct wiphy *wiphy = wdev->wiphy;
945 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
946
4ee3e063
BL
947 trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets);
948
c063dbf5
JB
949 /* Indicate roaming trigger event to user space */
950 nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp);
951}
952EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify);
e5497d76 953
84f10708
TP
954void cfg80211_cqm_txe_notify(struct net_device *dev,
955 const u8 *peer, u32 num_packets,
956 u32 rate, u32 intvl, gfp_t gfp)
957{
958 struct wireless_dev *wdev = dev->ieee80211_ptr;
959 struct wiphy *wiphy = wdev->wiphy;
960 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
961
962 nl80211_send_cqm_txe_notify(rdev, dev, peer, num_packets,
963 rate, intvl, gfp);
964}
965EXPORT_SYMBOL(cfg80211_cqm_txe_notify);
966
e5497d76
JB
967void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid,
968 const u8 *replay_ctr, gfp_t gfp)
969{
970 struct wireless_dev *wdev = dev->ieee80211_ptr;
971 struct wiphy *wiphy = wdev->wiphy;
972 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
973
4ee3e063 974 trace_cfg80211_gtk_rekey_notify(dev, bssid);
e5497d76
JB
975 nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp);
976}
977EXPORT_SYMBOL(cfg80211_gtk_rekey_notify);
c9df56b4
JM
978
979void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
980 const u8 *bssid, bool preauth, gfp_t gfp)
981{
982 struct wireless_dev *wdev = dev->ieee80211_ptr;
983 struct wiphy *wiphy = wdev->wiphy;
984 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
985
4ee3e063 986 trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth);
c9df56b4
JM
987 nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp);
988}
989EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
28946da7 990
683b6d3b
JB
991void cfg80211_ch_switch_notify(struct net_device *dev,
992 struct cfg80211_chan_def *chandef)
5314526b
TP
993{
994 struct wireless_dev *wdev = dev->ieee80211_ptr;
995 struct wiphy *wiphy = wdev->wiphy;
996 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
5314526b 997
683b6d3b 998 trace_cfg80211_ch_switch_notify(dev, chandef);
4ee3e063 999
5314526b
TP
1000 wdev_lock(wdev);
1001
1002 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
1003 wdev->iftype != NL80211_IFTYPE_P2P_GO))
1004 goto out;
1005
683b6d3b
JB
1006 wdev->channel = chandef->chan;
1007 nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
5314526b
TP
1008out:
1009 wdev_unlock(wdev);
1010 return;
1011}
1012EXPORT_SYMBOL(cfg80211_ch_switch_notify);
1013
28946da7
JB
1014bool cfg80211_rx_spurious_frame(struct net_device *dev,
1015 const u8 *addr, gfp_t gfp)
1016{
1017 struct wireless_dev *wdev = dev->ieee80211_ptr;
4ee3e063
BL
1018 bool ret;
1019
1020 trace_cfg80211_rx_spurious_frame(dev, addr);
28946da7
JB
1021
1022 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
4ee3e063
BL
1023 wdev->iftype != NL80211_IFTYPE_P2P_GO)) {
1024 trace_cfg80211_return_bool(false);
28946da7 1025 return false;
4ee3e063
BL
1026 }
1027 ret = nl80211_unexpected_frame(dev, addr, gfp);
1028 trace_cfg80211_return_bool(ret);
1029 return ret;
28946da7
JB
1030}
1031EXPORT_SYMBOL(cfg80211_rx_spurious_frame);
b92ab5d8
JB
1032
1033bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
1034 const u8 *addr, gfp_t gfp)
1035{
1036 struct wireless_dev *wdev = dev->ieee80211_ptr;
4ee3e063
BL
1037 bool ret;
1038
1039 trace_cfg80211_rx_unexpected_4addr_frame(dev, addr);
b92ab5d8
JB
1040
1041 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
1042 wdev->iftype != NL80211_IFTYPE_P2P_GO &&
4ee3e063
BL
1043 wdev->iftype != NL80211_IFTYPE_AP_VLAN)) {
1044 trace_cfg80211_return_bool(false);
b92ab5d8 1045 return false;
4ee3e063
BL
1046 }
1047 ret = nl80211_unexpected_4addr_frame(dev, addr, gfp);
1048 trace_cfg80211_return_bool(ret);
1049 return ret;
b92ab5d8
JB
1050}
1051EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);