blob: a61a44bc6cf024cbd32e6da15e4df93d0067cabe [file] [log] [blame]
Jouni Malinen6039f6d2009-03-19 13:39:21 +02001/*
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>
Felix Fietkauc6fb08a2012-03-18 22:58:04 +01009#include <linux/etherdevice.h>
Jouni Malinen6039f6d2009-03-19 13:39:21 +020010#include <linux/netdevice.h>
11#include <linux/nl80211.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090012#include <linux/slab.h>
Johannes Berga9a11622009-07-27 12:01:53 +020013#include <linux/wireless.h>
Jouni Malinen6039f6d2009-03-19 13:39:21 +020014#include <net/cfg80211.h>
Johannes Berga9a11622009-07-27 12:01:53 +020015#include <net/iw_handler.h>
Jouni Malinen6039f6d2009-03-19 13:39:21 +020016#include "core.h"
17#include "nl80211.h"
Hila Gonene35e4d22012-06-27 17:19:42 +030018#include "rdev-ops.h"
19
Jouni Malinen6039f6d2009-03-19 13:39:21 +020020
Johannes Berg6ff57cf2013-05-16 00:55:00 +020021void cfg80211_rx_assoc_resp(struct net_device *dev, struct cfg80211_bss *bss,
Johannes Berg95de8172012-01-20 13:55:25 +010022 const u8 *buf, size_t len)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020023{
Johannes Berg6829c872009-07-02 09:13:27 +020024 struct wireless_dev *wdev = dev->ieee80211_ptr;
25 struct wiphy *wiphy = wdev->wiphy;
Jouni Malinen6039f6d2009-03-19 13:39:21 +020026 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg6829c872009-07-02 09:13:27 +020027 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
28 u8 *ie = mgmt->u.assoc_resp.variable;
Johannes Berg95de8172012-01-20 13:55:25 +010029 int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable);
Johannes Bergceca7b72013-05-16 00:55:45 +020030 u16 status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
Johannes Berg6829c872009-07-02 09:13:27 +020031
Beni Lev4ee3e062012-08-27 12:49:39 +030032 trace_cfg80211_send_rx_assoc(dev, bss);
Johannes Bergcb0b4be2009-07-07 03:56:07 +020033
Johannes Bergf401a6f2009-08-07 14:51:05 +020034 /*
35 * This is a bit of a hack, we don't notify userspace of
36 * a (re-)association reply if we tried to send a reassoc
37 * and got a reject -- we only try again with an assoc
38 * frame instead of reassoc.
39 */
Johannes Bergceca7b72013-05-16 00:55:45 +020040 if (cfg80211_sme_rx_assoc_resp(wdev, status_code)) {
Johannes Berg5b112d32013-02-01 01:49:58 +010041 cfg80211_put_bss(wiphy, bss);
Johannes Berg8d61ffa2013-05-10 12:32:47 +020042 return;
Johannes Berg95de8172012-01-20 13:55:25 +010043 }
Johannes Bergf401a6f2009-08-07 14:51:05 +020044
Johannes Bergcb0b4be2009-07-07 03:56:07 +020045 nl80211_send_rx_assoc(rdev, dev, buf, len, GFP_KERNEL);
Johannes Bergceca7b72013-05-16 00:55:45 +020046 /* update current_bss etc., consumes the bss reference */
Johannes Bergdf7fc0f2009-07-29 11:23:49 +020047 __cfg80211_connect_result(dev, mgmt->bssid, NULL, 0, ie, len - ieoffs,
48 status_code,
Johannes Berg95de8172012-01-20 13:55:25 +010049 status_code == WLAN_STATUS_SUCCESS, bss);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020050}
Johannes Berg6ff57cf2013-05-16 00:55:00 +020051EXPORT_SYMBOL(cfg80211_rx_assoc_resp);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020052
Johannes Bergceca7b72013-05-16 00:55:45 +020053static void cfg80211_process_auth(struct wireless_dev *wdev,
54 const u8 *buf, size_t len)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020055{
Johannes Bergceca7b72013-05-16 00:55:45 +020056 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
Johannes Berg6829c872009-07-02 09:13:27 +020057
Johannes Bergceca7b72013-05-16 00:55:45 +020058 nl80211_send_rx_auth(rdev, wdev->netdev, buf, len, GFP_KERNEL);
59 cfg80211_sme_rx_auth(wdev, buf, len);
Johannes Berg667503dd2009-07-07 03:56:11 +020060}
Jouni Malinen6039f6d2009-03-19 13:39:21 +020061
Johannes Bergceca7b72013-05-16 00:55:45 +020062static void cfg80211_process_deauth(struct wireless_dev *wdev,
63 const u8 *buf, size_t len)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020064{
Johannes Bergceca7b72013-05-16 00:55:45 +020065 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
Johannes Berg6829c872009-07-02 09:13:27 +020066 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
Johannes Berg19957bb2009-07-02 17:20:43 +020067 const u8 *bssid = mgmt->bssid;
Johannes Bergceca7b72013-05-16 00:55:45 +020068 u16 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
69 bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr);
Johannes Berg6829c872009-07-02 09:13:27 +020070
Johannes Bergceca7b72013-05-16 00:55:45 +020071 nl80211_send_deauth(rdev, wdev->netdev, buf, len, GFP_KERNEL);
Johannes Berg6829c872009-07-02 09:13:27 +020072
Johannes Bergceca7b72013-05-16 00:55:45 +020073 if (!wdev->current_bss ||
74 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))
Johannes Berg596a07c2009-07-11 00:17:32 +020075 return;
Johannes Berg6829c872009-07-02 09:13:27 +020076
Johannes Bergceca7b72013-05-16 00:55:45 +020077 __cfg80211_disconnected(wdev->netdev, NULL, 0, reason_code, from_ap);
78 cfg80211_sme_deauth(wdev);
79}
Johannes Berg6829c872009-07-02 09:13:27 +020080
Johannes Bergceca7b72013-05-16 00:55:45 +020081static void cfg80211_process_disassoc(struct wireless_dev *wdev,
82 const u8 *buf, size_t len)
83{
84 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
85 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
86 const u8 *bssid = mgmt->bssid;
87 u16 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
88 bool from_ap = !ether_addr_equal(mgmt->sa, wdev->netdev->dev_addr);
Johannes Berg19957bb2009-07-02 17:20:43 +020089
Johannes Bergceca7b72013-05-16 00:55:45 +020090 nl80211_send_disassoc(rdev, wdev->netdev, buf, len, GFP_KERNEL);
91
92 if (WARN_ON(!wdev->current_bss ||
93 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
94 return;
95
96 __cfg80211_disconnected(wdev->netdev, NULL, 0, reason_code, from_ap);
97 cfg80211_sme_disassoc(wdev);
Johannes Berg667503dd2009-07-07 03:56:11 +020098}
Jouni Malinena3b8b052009-03-27 21:59:49 +020099
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200100void cfg80211_rx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len)
101{
102 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200103 struct ieee80211_mgmt *mgmt = (void *)buf;
104
105 ASSERT_WDEV_LOCK(wdev);
106
107 trace_cfg80211_rx_mlme_mgmt(dev, buf, len);
108
109 if (WARN_ON(len < 2))
110 return;
111
Johannes Bergceca7b72013-05-16 00:55:45 +0200112 if (ieee80211_is_auth(mgmt->frame_control))
113 cfg80211_process_auth(wdev, buf, len);
114 else if (ieee80211_is_deauth(mgmt->frame_control))
115 cfg80211_process_deauth(wdev, buf, len);
116 else if (ieee80211_is_disassoc(mgmt->frame_control))
117 cfg80211_process_disassoc(wdev, buf, len);
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200118}
119EXPORT_SYMBOL(cfg80211_rx_mlme_mgmt);
120
121void cfg80211_auth_timeout(struct net_device *dev, const u8 *addr)
Johannes Berga58ce432009-11-19 12:45:42 +0100122{
123 struct wireless_dev *wdev = dev->ieee80211_ptr;
124 struct wiphy *wiphy = wdev->wiphy;
125 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
126
Beni Lev4ee3e062012-08-27 12:49:39 +0300127 trace_cfg80211_send_auth_timeout(dev, addr);
Johannes Berga58ce432009-11-19 12:45:42 +0100128
129 nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL);
Johannes Bergceca7b72013-05-16 00:55:45 +0200130 cfg80211_sme_auth_timeout(wdev);
Jouni Malinen1965c852009-04-22 21:38:25 +0300131}
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200132EXPORT_SYMBOL(cfg80211_auth_timeout);
Jouni Malinen1965c852009-04-22 21:38:25 +0300133
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200134void cfg80211_assoc_timeout(struct net_device *dev, const u8 *addr)
Jouni Malinen1965c852009-04-22 21:38:25 +0300135{
Johannes Berg6829c872009-07-02 09:13:27 +0200136 struct wireless_dev *wdev = dev->ieee80211_ptr;
137 struct wiphy *wiphy = wdev->wiphy;
Jouni Malinen1965c852009-04-22 21:38:25 +0300138 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg19957bb2009-07-02 17:20:43 +0200139
Beni Lev4ee3e062012-08-27 12:49:39 +0300140 trace_cfg80211_send_assoc_timeout(dev, addr);
Johannes Bergcb0b4be2009-07-07 03:56:07 +0200141
142 nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL);
Johannes Bergceca7b72013-05-16 00:55:45 +0200143 cfg80211_sme_assoc_timeout(wdev);
Jouni Malinen1965c852009-04-22 21:38:25 +0300144}
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200145EXPORT_SYMBOL(cfg80211_assoc_timeout);
146
147void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len)
148{
149 struct wireless_dev *wdev = dev->ieee80211_ptr;
150 struct ieee80211_mgmt *mgmt = (void *)buf;
151
152 ASSERT_WDEV_LOCK(wdev);
153
154 trace_cfg80211_tx_mlme_mgmt(dev, buf, len);
155
156 if (WARN_ON(len < 2))
157 return;
158
159 if (ieee80211_is_deauth(mgmt->frame_control))
Johannes Bergceca7b72013-05-16 00:55:45 +0200160 cfg80211_process_deauth(wdev, buf, len);
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200161 else
Johannes Bergceca7b72013-05-16 00:55:45 +0200162 cfg80211_process_disassoc(wdev, buf, len);
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200163}
164EXPORT_SYMBOL(cfg80211_tx_mlme_mgmt);
Jouni Malinen1965c852009-04-22 21:38:25 +0300165
Jouni Malinena3b8b052009-03-27 21:59:49 +0200166void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
167 enum nl80211_key_type key_type, int key_id,
Johannes Berge6d6e342009-07-01 21:26:47 +0200168 const u8 *tsc, gfp_t gfp)
Jouni Malinena3b8b052009-03-27 21:59:49 +0200169{
170 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
171 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg3d23e342009-09-29 23:27:28 +0200172#ifdef CONFIG_CFG80211_WEXT
Johannes Bergf58d4ed2009-06-19 02:45:21 +0200173 union iwreq_data wrqu;
Johannes Berge6d6e342009-07-01 21:26:47 +0200174 char *buf = kmalloc(128, gfp);
Johannes Bergf58d4ed2009-06-19 02:45:21 +0200175
176 if (buf) {
177 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
178 "keyid=%d %scast addr=%pM)", key_id,
179 key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
180 addr);
181 memset(&wrqu, 0, sizeof(wrqu));
182 wrqu.data.length = strlen(buf);
183 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
184 kfree(buf);
185 }
186#endif
187
Beni Lev4ee3e062012-08-27 12:49:39 +0300188 trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc);
Johannes Berge6d6e342009-07-01 21:26:47 +0200189 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
Jouni Malinena3b8b052009-03-27 21:59:49 +0200190}
191EXPORT_SYMBOL(cfg80211_michael_mic_failure);
Johannes Berg19957bb2009-07-02 17:20:43 +0200192
193/* some MLME handling for userspace SME */
Johannes Berg91bf9b22013-05-15 17:44:01 +0200194int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
195 struct net_device *dev,
196 struct ieee80211_channel *chan,
197 enum nl80211_auth_type auth_type,
198 const u8 *bssid,
199 const u8 *ssid, int ssid_len,
200 const u8 *ie, int ie_len,
201 const u8 *key, int key_len, int key_idx,
202 const u8 *sae_data, int sae_data_len)
Johannes Berg19957bb2009-07-02 17:20:43 +0200203{
204 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg7ade7032013-05-13 11:37:30 +0200205 struct cfg80211_auth_request req = {
206 .ie = ie,
207 .ie_len = ie_len,
208 .sae_data = sae_data,
209 .sae_data_len = sae_data_len,
210 .auth_type = auth_type,
211 .key = key,
212 .key_len = key_len,
213 .key_idx = key_idx,
214 };
Johannes Berg95de8172012-01-20 13:55:25 +0100215 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200216
Johannes Berg667503dd2009-07-07 03:56:11 +0200217 ASSERT_WDEV_LOCK(wdev);
218
Johannes Bergfffd0932009-07-08 14:22:54 +0200219 if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
220 if (!key || !key_len || key_idx < 0 || key_idx > 4)
221 return -EINVAL;
222
Johannes Berg0a9b5e12009-07-02 18:26:18 +0200223 if (wdev->current_bss &&
Joe Perchesac422d32012-05-08 18:56:55 +0000224 ether_addr_equal(bssid, wdev->current_bss->pub.bssid))
Johannes Berg0a9b5e12009-07-02 18:26:18 +0200225 return -EALREADY;
226
Johannes Berg19957bb2009-07-02 17:20:43 +0200227 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
228 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
229 if (!req.bss)
230 return -ENOENT;
231
Michal Kaziore4e32452012-06-29 12:47:08 +0200232 err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
233 CHAN_MODE_SHARED);
234 if (err)
235 goto out;
236
Hila Gonene35e4d22012-06-27 17:19:42 +0300237 err = rdev_auth(rdev, dev, &req);
Johannes Berg19957bb2009-07-02 17:20:43 +0200238
Michal Kaziore4e32452012-06-29 12:47:08 +0200239out:
Johannes Berg5b112d32013-02-01 01:49:58 +0100240 cfg80211_put_bss(&rdev->wiphy, req.bss);
Johannes Berg19957bb2009-07-02 17:20:43 +0200241 return err;
242}
243
Ben Greear7e7c8922011-11-18 11:31:59 -0800244/* Do a logical ht_capa &= ht_capa_mask. */
245void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
246 const struct ieee80211_ht_cap *ht_capa_mask)
247{
248 int i;
249 u8 *p1, *p2;
250 if (!ht_capa_mask) {
251 memset(ht_capa, 0, sizeof(*ht_capa));
252 return;
253 }
254
255 p1 = (u8*)(ht_capa);
256 p2 = (u8*)(ht_capa_mask);
257 for (i = 0; i<sizeof(*ht_capa); i++)
258 p1[i] &= p2[i];
259}
260
Johannes Bergee2aca32013-02-21 17:36:01 +0100261/* Do a logical ht_capa &= ht_capa_mask. */
262void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
263 const struct ieee80211_vht_cap *vht_capa_mask)
264{
265 int i;
266 u8 *p1, *p2;
267 if (!vht_capa_mask) {
268 memset(vht_capa, 0, sizeof(*vht_capa));
269 return;
270 }
271
272 p1 = (u8*)(vht_capa);
273 p2 = (u8*)(vht_capa_mask);
274 for (i = 0; i < sizeof(*vht_capa); i++)
275 p1[i] &= p2[i];
276}
277
Johannes Berg91bf9b22013-05-15 17:44:01 +0200278int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
279 struct net_device *dev,
280 struct ieee80211_channel *chan,
281 const u8 *bssid,
282 const u8 *ssid, int ssid_len,
283 struct cfg80211_assoc_request *req)
Johannes Berg19957bb2009-07-02 17:20:43 +0200284{
285 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100286 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200287
Johannes Berg667503dd2009-07-07 03:56:11 +0200288 ASSERT_WDEV_LOCK(wdev);
289
Johannes Bergceca7b72013-05-16 00:55:45 +0200290 if (wdev->current_bss &&
291 (!req->prev_bssid || !ether_addr_equal(wdev->current_bss->pub.bssid,
292 req->prev_bssid)))
Johannes Berg19957bb2009-07-02 17:20:43 +0200293 return -EALREADY;
294
Johannes Bergf62fab72013-02-21 20:09:09 +0100295 cfg80211_oper_and_ht_capa(&req->ht_capa_mask,
Ben Greear7e7c8922011-11-18 11:31:59 -0800296 rdev->wiphy.ht_capa_mod_mask);
Johannes Bergf62fab72013-02-21 20:09:09 +0100297 cfg80211_oper_and_vht_capa(&req->vht_capa_mask,
Johannes Bergee2aca32013-02-21 17:36:01 +0100298 rdev->wiphy.vht_capa_mod_mask);
Ben Greear7e7c8922011-11-18 11:31:59 -0800299
Johannes Bergf62fab72013-02-21 20:09:09 +0100300 req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
301 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Johannes Bergceca7b72013-05-16 00:55:45 +0200302 if (!req->bss)
Johannes Berg19957bb2009-07-02 17:20:43 +0200303 return -ENOENT;
304
Johannes Bergf62fab72013-02-21 20:09:09 +0100305 err = cfg80211_can_use_chan(rdev, wdev, chan, CHAN_MODE_SHARED);
Michal Kaziore4e32452012-06-29 12:47:08 +0200306 if (err)
307 goto out;
308
Johannes Bergf62fab72013-02-21 20:09:09 +0100309 err = rdev_assoc(rdev, dev, req);
Johannes Berg95de8172012-01-20 13:55:25 +0100310
Michal Kaziore4e32452012-06-29 12:47:08 +0200311out:
Johannes Bergceca7b72013-05-16 00:55:45 +0200312 if (err)
Johannes Bergf62fab72013-02-21 20:09:09 +0100313 cfg80211_put_bss(&rdev->wiphy, req->bss);
Johannes Berg95de8172012-01-20 13:55:25 +0100314
Johannes Berg19957bb2009-07-02 17:20:43 +0200315 return err;
316}
317
Johannes Berg91bf9b22013-05-15 17:44:01 +0200318int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
319 struct net_device *dev, const u8 *bssid,
320 const u8 *ie, int ie_len, u16 reason,
321 bool local_state_change)
Johannes Berg19957bb2009-07-02 17:20:43 +0200322{
323 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100324 struct cfg80211_deauth_request req = {
325 .bssid = bssid,
326 .reason_code = reason,
327 .ie = ie,
328 .ie_len = ie_len,
Stanislaw Gruszka68632552012-10-15 14:52:41 +0200329 .local_state_change = local_state_change,
Johannes Berg95de8172012-01-20 13:55:25 +0100330 };
Johannes Berg19957bb2009-07-02 17:20:43 +0200331
Johannes Berg667503dd2009-07-07 03:56:11 +0200332 ASSERT_WDEV_LOCK(wdev);
333
Johannes Bergceca7b72013-05-16 00:55:45 +0200334 if (local_state_change &&
335 (!wdev->current_bss ||
336 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
Johannes Berg95de8172012-01-20 13:55:25 +0100337 return 0;
Johannes Berg19957bb2009-07-02 17:20:43 +0200338
Hila Gonene35e4d22012-06-27 17:19:42 +0300339 return rdev_deauth(rdev, dev, &req);
Johannes Berg19957bb2009-07-02 17:20:43 +0200340}
341
Johannes Berg91bf9b22013-05-15 17:44:01 +0200342int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
343 struct net_device *dev, const u8 *bssid,
344 const u8 *ie, int ie_len, u16 reason,
345 bool local_state_change)
Johannes Berg19957bb2009-07-02 17:20:43 +0200346{
347 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg7ade7032013-05-13 11:37:30 +0200348 struct cfg80211_disassoc_request req = {
349 .reason_code = reason,
350 .local_state_change = local_state_change,
351 .ie = ie,
352 .ie_len = ie_len,
353 };
Johannes Bergceca7b72013-05-16 00:55:45 +0200354 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200355
Johannes Berg667503dd2009-07-07 03:56:11 +0200356 ASSERT_WDEV_LOCK(wdev);
357
Johannes Bergceca7b72013-05-16 00:55:45 +0200358 if (!wdev->current_bss)
Johannes Bergf9d6b402009-07-27 10:22:28 +0200359 return -ENOTCONN;
360
Joe Perchesac422d32012-05-08 18:56:55 +0000361 if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid))
Johannes Berg19957bb2009-07-02 17:20:43 +0200362 req.bss = &wdev->current_bss->pub;
363 else
364 return -ENOTCONN;
365
Johannes Bergceca7b72013-05-16 00:55:45 +0200366 err = rdev_disassoc(rdev, dev, &req);
367 if (err)
368 return err;
369
370 /* driver should have reported the disassoc */
371 WARN_ON(wdev->current_bss);
372 return 0;
Johannes Berg667503dd2009-07-07 03:56:11 +0200373}
374
Johannes Berg19957bb2009-07-02 17:20:43 +0200375void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
376 struct net_device *dev)
377{
378 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100379 u8 bssid[ETH_ALEN];
Johannes Berg19957bb2009-07-02 17:20:43 +0200380
Johannes Berg667503dd2009-07-07 03:56:11 +0200381 ASSERT_WDEV_LOCK(wdev);
382
Johannes Berg19957bb2009-07-02 17:20:43 +0200383 if (!rdev->ops->deauth)
384 return;
385
Johannes Berg95de8172012-01-20 13:55:25 +0100386 if (!wdev->current_bss)
387 return;
Johannes Berg19957bb2009-07-02 17:20:43 +0200388
Johannes Berg95de8172012-01-20 13:55:25 +0100389 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
Johannes Bergceca7b72013-05-16 00:55:45 +0200390 cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0,
391 WLAN_REASON_DEAUTH_LEAVING, false);
Johannes Berg19957bb2009-07-02 17:20:43 +0200392}
Jouni Malinen9588bbd2009-12-23 13:15:41 +0100393
Johannes Berg2e161f72010-08-12 15:38:38 +0200394struct cfg80211_mgmt_registration {
Jouni Malinen026331c2010-02-15 12:53:10 +0200395 struct list_head list;
396
Eric W. Biederman15e47302012-09-07 20:12:54 +0000397 u32 nlportid;
Jouni Malinen026331c2010-02-15 12:53:10 +0200398
399 int match_len;
400
Johannes Berg2e161f72010-08-12 15:38:38 +0200401 __le16 frame_type;
402
Jouni Malinen026331c2010-02-15 12:53:10 +0200403 u8 match[];
404};
405
Eric W. Biederman15e47302012-09-07 20:12:54 +0000406int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
Johannes Berg2e161f72010-08-12 15:38:38 +0200407 u16 frame_type, const u8 *match_data,
408 int match_len)
Jouni Malinen026331c2010-02-15 12:53:10 +0200409{
Johannes Berg271733c2010-10-13 12:06:23 +0200410 struct wiphy *wiphy = wdev->wiphy;
411 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200412 struct cfg80211_mgmt_registration *reg, *nreg;
Jouni Malinen026331c2010-02-15 12:53:10 +0200413 int err = 0;
Johannes Berg2e161f72010-08-12 15:38:38 +0200414 u16 mgmt_type;
415
416 if (!wdev->wiphy->mgmt_stypes)
417 return -EOPNOTSUPP;
418
419 if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
420 return -EINVAL;
421
422 if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE))
423 return -EINVAL;
424
425 mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
426 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type)))
427 return -EINVAL;
Jouni Malinen026331c2010-02-15 12:53:10 +0200428
429 nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL);
430 if (!nreg)
431 return -ENOMEM;
432
Johannes Berg2e161f72010-08-12 15:38:38 +0200433 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200434
Johannes Berg2e161f72010-08-12 15:38:38 +0200435 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
Jouni Malinen026331c2010-02-15 12:53:10 +0200436 int mlen = min(match_len, reg->match_len);
437
Johannes Berg2e161f72010-08-12 15:38:38 +0200438 if (frame_type != le16_to_cpu(reg->frame_type))
439 continue;
440
Jouni Malinen026331c2010-02-15 12:53:10 +0200441 if (memcmp(reg->match, match_data, mlen) == 0) {
442 err = -EALREADY;
443 break;
444 }
445 }
446
447 if (err) {
448 kfree(nreg);
449 goto out;
450 }
451
452 memcpy(nreg->match, match_data, match_len);
453 nreg->match_len = match_len;
Eric W. Biederman15e47302012-09-07 20:12:54 +0000454 nreg->nlportid = snd_portid;
Johannes Berg2e161f72010-08-12 15:38:38 +0200455 nreg->frame_type = cpu_to_le16(frame_type);
456 list_add(&nreg->list, &wdev->mgmt_registrations);
Jouni Malinen026331c2010-02-15 12:53:10 +0200457
Johannes Berg271733c2010-10-13 12:06:23 +0200458 if (rdev->ops->mgmt_frame_register)
Hila Gonene35e4d22012-06-27 17:19:42 +0300459 rdev_mgmt_frame_register(rdev, wdev, frame_type, true);
Johannes Berg271733c2010-10-13 12:06:23 +0200460
Jouni Malinen026331c2010-02-15 12:53:10 +0200461 out:
Johannes Berg2e161f72010-08-12 15:38:38 +0200462 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Johannes Berg271733c2010-10-13 12:06:23 +0200463
Jouni Malinen026331c2010-02-15 12:53:10 +0200464 return err;
465}
466
Eric W. Biederman15e47302012-09-07 20:12:54 +0000467void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
Jouni Malinen026331c2010-02-15 12:53:10 +0200468{
Johannes Berg271733c2010-10-13 12:06:23 +0200469 struct wiphy *wiphy = wdev->wiphy;
470 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200471 struct cfg80211_mgmt_registration *reg, *tmp;
Jouni Malinen026331c2010-02-15 12:53:10 +0200472
Johannes Berg2e161f72010-08-12 15:38:38 +0200473 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200474
Johannes Berg2e161f72010-08-12 15:38:38 +0200475 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
Eric W. Biederman15e47302012-09-07 20:12:54 +0000476 if (reg->nlportid != nlportid)
Johannes Berg271733c2010-10-13 12:06:23 +0200477 continue;
478
479 if (rdev->ops->mgmt_frame_register) {
480 u16 frame_type = le16_to_cpu(reg->frame_type);
481
Hila Gonene35e4d22012-06-27 17:19:42 +0300482 rdev_mgmt_frame_register(rdev, wdev,
483 frame_type, false);
Jouni Malinen026331c2010-02-15 12:53:10 +0200484 }
Johannes Berg271733c2010-10-13 12:06:23 +0200485
486 list_del(&reg->list);
487 kfree(reg);
Jouni Malinen026331c2010-02-15 12:53:10 +0200488 }
489
Johannes Berg2e161f72010-08-12 15:38:38 +0200490 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Johannes Berg28946da2011-11-04 11:18:12 +0100491
Arend van Spriel5de17982013-04-18 15:49:00 +0200492 if (nlportid && rdev->crit_proto_nlportid == nlportid) {
493 rdev->crit_proto_nlportid = 0;
494 rdev_crit_proto_stop(rdev, wdev);
495 }
496
Eric W. Biederman15e47302012-09-07 20:12:54 +0000497 if (nlportid == wdev->ap_unexpected_nlportid)
498 wdev->ap_unexpected_nlportid = 0;
Jouni Malinen026331c2010-02-15 12:53:10 +0200499}
500
Johannes Berg2e161f72010-08-12 15:38:38 +0200501void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
Jouni Malinen026331c2010-02-15 12:53:10 +0200502{
Johannes Berg2e161f72010-08-12 15:38:38 +0200503 struct cfg80211_mgmt_registration *reg, *tmp;
Jouni Malinen026331c2010-02-15 12:53:10 +0200504
Johannes Berg2e161f72010-08-12 15:38:38 +0200505 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200506
Johannes Berg2e161f72010-08-12 15:38:38 +0200507 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
Jouni Malinen026331c2010-02-15 12:53:10 +0200508 list_del(&reg->list);
509 kfree(reg);
510 }
511
Johannes Berg2e161f72010-08-12 15:38:38 +0200512 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200513}
514
Johannes Berg2e161f72010-08-12 15:38:38 +0200515int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
Johannes Berg71bbc992012-06-15 15:30:18 +0200516 struct wireless_dev *wdev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +0100517 struct ieee80211_channel *chan, bool offchan,
Johannes Berg42d97a52012-11-08 18:31:02 +0100518 unsigned int wait, const u8 *buf, size_t len,
519 bool no_cck, bool dont_wait_for_ack, u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +0200520{
Jouni Malinen026331c2010-02-15 12:53:10 +0200521 const struct ieee80211_mgmt *mgmt;
Johannes Berg2e161f72010-08-12 15:38:38 +0200522 u16 stype;
Jouni Malinen026331c2010-02-15 12:53:10 +0200523
Johannes Berg2e161f72010-08-12 15:38:38 +0200524 if (!wdev->wiphy->mgmt_stypes)
Jouni Malinen026331c2010-02-15 12:53:10 +0200525 return -EOPNOTSUPP;
Johannes Berg2e161f72010-08-12 15:38:38 +0200526
527 if (!rdev->ops->mgmt_tx)
528 return -EOPNOTSUPP;
529
Jouni Malinen026331c2010-02-15 12:53:10 +0200530 if (len < 24 + 1)
531 return -EINVAL;
532
533 mgmt = (const struct ieee80211_mgmt *) buf;
Johannes Berg2e161f72010-08-12 15:38:38 +0200534
535 if (!ieee80211_is_mgmt(mgmt->frame_control))
Jouni Malinen026331c2010-02-15 12:53:10 +0200536 return -EINVAL;
Johannes Berg2e161f72010-08-12 15:38:38 +0200537
538 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
539 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4)))
540 return -EINVAL;
541
542 if (ieee80211_is_action(mgmt->frame_control) &&
543 mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200544 int err = 0;
545
Johannes Bergfe100ac2010-08-09 15:52:03 +0200546 wdev_lock(wdev);
547
Johannes Berg663fcaf2010-09-30 21:06:09 +0200548 switch (wdev->iftype) {
549 case NL80211_IFTYPE_ADHOC:
550 case NL80211_IFTYPE_STATION:
551 case NL80211_IFTYPE_P2P_CLIENT:
552 if (!wdev->current_bss) {
553 err = -ENOTCONN;
554 break;
555 }
Johannes Bergfe100ac2010-08-09 15:52:03 +0200556
Joe Perchesac422d32012-05-08 18:56:55 +0000557 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
558 mgmt->bssid)) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200559 err = -ENOTCONN;
560 break;
561 }
562
563 /*
564 * check for IBSS DA must be done by driver as
565 * cfg80211 doesn't track the stations
566 */
567 if (wdev->iftype == NL80211_IFTYPE_ADHOC)
568 break;
569
570 /* for station, check that DA is the AP */
Joe Perchesac422d32012-05-08 18:56:55 +0000571 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
572 mgmt->da)) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200573 err = -ENOTCONN;
574 break;
575 }
576 break;
577 case NL80211_IFTYPE_AP:
578 case NL80211_IFTYPE_P2P_GO:
579 case NL80211_IFTYPE_AP_VLAN:
Johannes Berg98104fde2012-06-16 00:19:54 +0200580 if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev)))
Johannes Berg663fcaf2010-09-30 21:06:09 +0200581 err = -EINVAL;
582 break;
Javier Cardona0778a6a2011-05-03 16:57:08 -0700583 case NL80211_IFTYPE_MESH_POINT:
Joe Perchesac422d32012-05-08 18:56:55 +0000584 if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) {
Javier Cardona0778a6a2011-05-03 16:57:08 -0700585 err = -EINVAL;
586 break;
587 }
588 /*
589 * check for mesh DA must be done by driver as
590 * cfg80211 doesn't track the stations
591 */
592 break;
Johannes Berg98104fde2012-06-16 00:19:54 +0200593 case NL80211_IFTYPE_P2P_DEVICE:
594 /*
595 * fall through, P2P device only supports
596 * public action frames
597 */
Johannes Berg663fcaf2010-09-30 21:06:09 +0200598 default:
599 err = -EOPNOTSUPP;
600 break;
601 }
Johannes Bergfe100ac2010-08-09 15:52:03 +0200602 wdev_unlock(wdev);
Johannes Berg663fcaf2010-09-30 21:06:09 +0200603
604 if (err)
605 return err;
Jouni Malinen026331c2010-02-15 12:53:10 +0200606 }
607
Johannes Berg98104fde2012-06-16 00:19:54 +0200608 if (!ether_addr_equal(mgmt->sa, wdev_address(wdev)))
Jouni Malinen026331c2010-02-15 12:53:10 +0200609 return -EINVAL;
610
611 /* Transmit the Action frame as requested by user space */
Hila Gonene35e4d22012-06-27 17:19:42 +0300612 return rdev_mgmt_tx(rdev, wdev, chan, offchan,
Hila Gonene35e4d22012-06-27 17:19:42 +0300613 wait, buf, len, no_cck, dont_wait_for_ack,
614 cookie);
Jouni Malinen026331c2010-02-15 12:53:10 +0200615}
616
Johannes Berg71bbc992012-06-15 15:30:18 +0200617bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
Johannes Berg804483e2012-03-05 22:18:41 +0100618 const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen026331c2010-02-15 12:53:10 +0200619{
Jouni Malinen026331c2010-02-15 12:53:10 +0200620 struct wiphy *wiphy = wdev->wiphy;
621 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200622 struct cfg80211_mgmt_registration *reg;
623 const struct ieee80211_txrx_stypes *stypes =
624 &wiphy->mgmt_stypes[wdev->iftype];
625 struct ieee80211_mgmt *mgmt = (void *)buf;
626 const u8 *data;
627 int data_len;
Jouni Malinen026331c2010-02-15 12:53:10 +0200628 bool result = false;
Johannes Berg2e161f72010-08-12 15:38:38 +0200629 __le16 ftype = mgmt->frame_control &
630 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
631 u16 stype;
Jouni Malinen026331c2010-02-15 12:53:10 +0200632
Beni Lev4ee3e062012-08-27 12:49:39 +0300633 trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm);
Johannes Berg2e161f72010-08-12 15:38:38 +0200634 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
Jouni Malinen026331c2010-02-15 12:53:10 +0200635
Beni Lev4ee3e062012-08-27 12:49:39 +0300636 if (!(stypes->rx & BIT(stype))) {
637 trace_cfg80211_return_bool(false);
Johannes Berg2e161f72010-08-12 15:38:38 +0200638 return false;
Beni Lev4ee3e062012-08-27 12:49:39 +0300639 }
Jouni Malinen026331c2010-02-15 12:53:10 +0200640
Johannes Berg2e161f72010-08-12 15:38:38 +0200641 data = buf + ieee80211_hdrlen(mgmt->frame_control);
642 data_len = len - ieee80211_hdrlen(mgmt->frame_control);
Jouni Malinen026331c2010-02-15 12:53:10 +0200643
Johannes Berg2e161f72010-08-12 15:38:38 +0200644 spin_lock_bh(&wdev->mgmt_registrations_lock);
645
646 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
647 if (reg->frame_type != ftype)
Jouni Malinen026331c2010-02-15 12:53:10 +0200648 continue;
649
Johannes Berg2e161f72010-08-12 15:38:38 +0200650 if (reg->match_len > data_len)
651 continue;
652
653 if (memcmp(reg->match, data, reg->match_len))
Jouni Malinen026331c2010-02-15 12:53:10 +0200654 continue;
655
656 /* found match! */
657
658 /* Indicate the received Action frame to user space */
Eric W. Biederman15e47302012-09-07 20:12:54 +0000659 if (nl80211_send_mgmt(rdev, wdev, reg->nlportid,
Johannes Berg804483e2012-03-05 22:18:41 +0100660 freq, sig_mbm,
Johannes Berg2e161f72010-08-12 15:38:38 +0200661 buf, len, gfp))
Jouni Malinen026331c2010-02-15 12:53:10 +0200662 continue;
663
664 result = true;
665 break;
666 }
667
Johannes Berg2e161f72010-08-12 15:38:38 +0200668 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200669
Beni Lev4ee3e062012-08-27 12:49:39 +0300670 trace_cfg80211_return_bool(result);
Jouni Malinen026331c2010-02-15 12:53:10 +0200671 return result;
672}
Johannes Berg2e161f72010-08-12 15:38:38 +0200673EXPORT_SYMBOL(cfg80211_rx_mgmt);
Jouni Malinen026331c2010-02-15 12:53:10 +0200674
Simon Wunderlich04f39042013-02-08 18:16:19 +0100675void cfg80211_dfs_channels_update_work(struct work_struct *work)
676{
677 struct delayed_work *delayed_work;
678 struct cfg80211_registered_device *rdev;
679 struct cfg80211_chan_def chandef;
680 struct ieee80211_supported_band *sband;
681 struct ieee80211_channel *c;
682 struct wiphy *wiphy;
683 bool check_again = false;
684 unsigned long timeout, next_time = 0;
685 int bandid, i;
686
687 delayed_work = container_of(work, struct delayed_work, work);
688 rdev = container_of(delayed_work, struct cfg80211_registered_device,
689 dfs_update_channels_wk);
690 wiphy = &rdev->wiphy;
691
Johannes Berg5fe231e2013-05-08 21:45:15 +0200692 rtnl_lock();
Simon Wunderlich04f39042013-02-08 18:16:19 +0100693 for (bandid = 0; bandid < IEEE80211_NUM_BANDS; bandid++) {
694 sband = wiphy->bands[bandid];
695 if (!sband)
696 continue;
697
698 for (i = 0; i < sband->n_channels; i++) {
699 c = &sband->channels[i];
700
701 if (c->dfs_state != NL80211_DFS_UNAVAILABLE)
702 continue;
703
704 timeout = c->dfs_state_entered +
705 IEEE80211_DFS_MIN_NOP_TIME_MS;
706
707 if (time_after_eq(jiffies, timeout)) {
708 c->dfs_state = NL80211_DFS_USABLE;
709 cfg80211_chandef_create(&chandef, c,
710 NL80211_CHAN_NO_HT);
711
712 nl80211_radar_notify(rdev, &chandef,
713 NL80211_RADAR_NOP_FINISHED,
714 NULL, GFP_ATOMIC);
715 continue;
716 }
717
718 if (!check_again)
719 next_time = timeout - jiffies;
720 else
721 next_time = min(next_time, timeout - jiffies);
722 check_again = true;
723 }
724 }
Johannes Berg5fe231e2013-05-08 21:45:15 +0200725 rtnl_unlock();
Simon Wunderlich04f39042013-02-08 18:16:19 +0100726
727 /* reschedule if there are other channels waiting to be cleared again */
728 if (check_again)
729 queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk,
730 next_time);
731}
732
733
734void cfg80211_radar_event(struct wiphy *wiphy,
735 struct cfg80211_chan_def *chandef,
736 gfp_t gfp)
737{
738 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
739 unsigned long timeout;
740
741 trace_cfg80211_radar_event(wiphy, chandef);
742
743 /* only set the chandef supplied channel to unavailable, in
744 * case the radar is detected on only one of multiple channels
745 * spanned by the chandef.
746 */
747 cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_UNAVAILABLE);
748
749 timeout = msecs_to_jiffies(IEEE80211_DFS_MIN_NOP_TIME_MS);
750 queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk,
751 timeout);
752
753 nl80211_radar_notify(rdev, chandef, NL80211_RADAR_DETECTED, NULL, gfp);
754}
755EXPORT_SYMBOL(cfg80211_radar_event);
756
757void cfg80211_cac_event(struct net_device *netdev,
758 enum nl80211_radar_event event, gfp_t gfp)
759{
760 struct wireless_dev *wdev = netdev->ieee80211_ptr;
761 struct wiphy *wiphy = wdev->wiphy;
762 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
763 struct cfg80211_chan_def chandef;
764 unsigned long timeout;
765
766 trace_cfg80211_cac_event(netdev, event);
767
768 if (WARN_ON(!wdev->cac_started))
769 return;
770
771 if (WARN_ON(!wdev->channel))
772 return;
773
774 cfg80211_chandef_create(&chandef, wdev->channel, NL80211_CHAN_NO_HT);
775
776 switch (event) {
777 case NL80211_RADAR_CAC_FINISHED:
778 timeout = wdev->cac_start_time +
779 msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
780 WARN_ON(!time_after_eq(jiffies, timeout));
781 cfg80211_set_dfs_state(wiphy, &chandef, NL80211_DFS_AVAILABLE);
782 break;
783 case NL80211_RADAR_CAC_ABORTED:
784 break;
785 default:
786 WARN_ON(1);
787 return;
788 }
789 wdev->cac_started = false;
790
791 nl80211_radar_notify(rdev, &chandef, event, netdev, gfp);
792}
793EXPORT_SYMBOL(cfg80211_cac_event);