blob: dd6f79d7bd2e13075dde8cbbcedbeed64edb6a67 [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 Berg959867f2013-06-19 13:05:42 +0200134void cfg80211_assoc_timeout(struct net_device *dev, struct cfg80211_bss *bss)
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
Johannes Berg959867f2013-06-19 13:05:42 +0200140 trace_cfg80211_send_assoc_timeout(dev, bss->bssid);
Johannes Bergcb0b4be2009-07-07 03:56:07 +0200141
Johannes Berg959867f2013-06-19 13:05:42 +0200142 nl80211_send_assoc_timeout(rdev, dev, bss->bssid, GFP_KERNEL);
Johannes Bergceca7b72013-05-16 00:55:45 +0200143 cfg80211_sme_assoc_timeout(wdev);
Johannes Berg959867f2013-06-19 13:05:42 +0200144
145 cfg80211_put_bss(wiphy, bss);
Jouni Malinen1965c852009-04-22 21:38:25 +0300146}
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200147EXPORT_SYMBOL(cfg80211_assoc_timeout);
148
149void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len)
150{
151 struct wireless_dev *wdev = dev->ieee80211_ptr;
152 struct ieee80211_mgmt *mgmt = (void *)buf;
153
154 ASSERT_WDEV_LOCK(wdev);
155
156 trace_cfg80211_tx_mlme_mgmt(dev, buf, len);
157
158 if (WARN_ON(len < 2))
159 return;
160
161 if (ieee80211_is_deauth(mgmt->frame_control))
Johannes Bergceca7b72013-05-16 00:55:45 +0200162 cfg80211_process_deauth(wdev, buf, len);
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200163 else
Johannes Bergceca7b72013-05-16 00:55:45 +0200164 cfg80211_process_disassoc(wdev, buf, len);
Johannes Berg6ff57cf2013-05-16 00:55:00 +0200165}
166EXPORT_SYMBOL(cfg80211_tx_mlme_mgmt);
Jouni Malinen1965c852009-04-22 21:38:25 +0300167
Jouni Malinena3b8b052009-03-27 21:59:49 +0200168void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
169 enum nl80211_key_type key_type, int key_id,
Johannes Berge6d6e342009-07-01 21:26:47 +0200170 const u8 *tsc, gfp_t gfp)
Jouni Malinena3b8b052009-03-27 21:59:49 +0200171{
172 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
173 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg3d23e342009-09-29 23:27:28 +0200174#ifdef CONFIG_CFG80211_WEXT
Johannes Bergf58d4ed2009-06-19 02:45:21 +0200175 union iwreq_data wrqu;
Johannes Berge6d6e342009-07-01 21:26:47 +0200176 char *buf = kmalloc(128, gfp);
Johannes Bergf58d4ed2009-06-19 02:45:21 +0200177
178 if (buf) {
179 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
180 "keyid=%d %scast addr=%pM)", key_id,
181 key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
182 addr);
183 memset(&wrqu, 0, sizeof(wrqu));
184 wrqu.data.length = strlen(buf);
185 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
186 kfree(buf);
187 }
188#endif
189
Beni Lev4ee3e062012-08-27 12:49:39 +0300190 trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc);
Johannes Berge6d6e342009-07-01 21:26:47 +0200191 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
Jouni Malinena3b8b052009-03-27 21:59:49 +0200192}
193EXPORT_SYMBOL(cfg80211_michael_mic_failure);
Johannes Berg19957bb2009-07-02 17:20:43 +0200194
195/* some MLME handling for userspace SME */
Johannes Berg91bf9b22013-05-15 17:44:01 +0200196int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
197 struct net_device *dev,
198 struct ieee80211_channel *chan,
199 enum nl80211_auth_type auth_type,
200 const u8 *bssid,
201 const u8 *ssid, int ssid_len,
202 const u8 *ie, int ie_len,
203 const u8 *key, int key_len, int key_idx,
204 const u8 *sae_data, int sae_data_len)
Johannes Berg19957bb2009-07-02 17:20:43 +0200205{
206 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg7ade7032013-05-13 11:37:30 +0200207 struct cfg80211_auth_request req = {
208 .ie = ie,
209 .ie_len = ie_len,
210 .sae_data = sae_data,
211 .sae_data_len = sae_data_len,
212 .auth_type = auth_type,
213 .key = key,
214 .key_len = key_len,
215 .key_idx = key_idx,
216 };
Johannes Berg95de8172012-01-20 13:55:25 +0100217 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200218
Johannes Berg667503dd2009-07-07 03:56:11 +0200219 ASSERT_WDEV_LOCK(wdev);
220
Johannes Bergfffd0932009-07-08 14:22:54 +0200221 if (auth_type == NL80211_AUTHTYPE_SHARED_KEY)
222 if (!key || !key_len || key_idx < 0 || key_idx > 4)
223 return -EINVAL;
224
Johannes Berg0a9b5e12009-07-02 18:26:18 +0200225 if (wdev->current_bss &&
Joe Perchesac422d32012-05-08 18:56:55 +0000226 ether_addr_equal(bssid, wdev->current_bss->pub.bssid))
Johannes Berg0a9b5e12009-07-02 18:26:18 +0200227 return -EALREADY;
228
Johannes Berg19957bb2009-07-02 17:20:43 +0200229 req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
230 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
231 if (!req.bss)
232 return -ENOENT;
233
Michal Kaziore4e32452012-06-29 12:47:08 +0200234 err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
235 CHAN_MODE_SHARED);
236 if (err)
237 goto out;
238
Hila Gonene35e4d22012-06-27 17:19:42 +0300239 err = rdev_auth(rdev, dev, &req);
Johannes Berg19957bb2009-07-02 17:20:43 +0200240
Michal Kaziore4e32452012-06-29 12:47:08 +0200241out:
Johannes Berg5b112d32013-02-01 01:49:58 +0100242 cfg80211_put_bss(&rdev->wiphy, req.bss);
Johannes Berg19957bb2009-07-02 17:20:43 +0200243 return err;
244}
245
Ben Greear7e7c8922011-11-18 11:31:59 -0800246/* Do a logical ht_capa &= ht_capa_mask. */
247void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
248 const struct ieee80211_ht_cap *ht_capa_mask)
249{
250 int i;
251 u8 *p1, *p2;
252 if (!ht_capa_mask) {
253 memset(ht_capa, 0, sizeof(*ht_capa));
254 return;
255 }
256
257 p1 = (u8*)(ht_capa);
258 p2 = (u8*)(ht_capa_mask);
259 for (i = 0; i<sizeof(*ht_capa); i++)
260 p1[i] &= p2[i];
261}
262
Johannes Bergee2aca32013-02-21 17:36:01 +0100263/* Do a logical ht_capa &= ht_capa_mask. */
264void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
265 const struct ieee80211_vht_cap *vht_capa_mask)
266{
267 int i;
268 u8 *p1, *p2;
269 if (!vht_capa_mask) {
270 memset(vht_capa, 0, sizeof(*vht_capa));
271 return;
272 }
273
274 p1 = (u8*)(vht_capa);
275 p2 = (u8*)(vht_capa_mask);
276 for (i = 0; i < sizeof(*vht_capa); i++)
277 p1[i] &= p2[i];
278}
279
Johannes Berg91bf9b22013-05-15 17:44:01 +0200280int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
281 struct net_device *dev,
282 struct ieee80211_channel *chan,
283 const u8 *bssid,
284 const u8 *ssid, int ssid_len,
285 struct cfg80211_assoc_request *req)
Johannes Berg19957bb2009-07-02 17:20:43 +0200286{
287 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100288 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200289
Johannes Berg667503dd2009-07-07 03:56:11 +0200290 ASSERT_WDEV_LOCK(wdev);
291
Johannes Bergceca7b72013-05-16 00:55:45 +0200292 if (wdev->current_bss &&
293 (!req->prev_bssid || !ether_addr_equal(wdev->current_bss->pub.bssid,
294 req->prev_bssid)))
Johannes Berg19957bb2009-07-02 17:20:43 +0200295 return -EALREADY;
296
Johannes Bergf62fab72013-02-21 20:09:09 +0100297 cfg80211_oper_and_ht_capa(&req->ht_capa_mask,
Ben Greear7e7c8922011-11-18 11:31:59 -0800298 rdev->wiphy.ht_capa_mod_mask);
Johannes Bergf62fab72013-02-21 20:09:09 +0100299 cfg80211_oper_and_vht_capa(&req->vht_capa_mask,
Johannes Bergee2aca32013-02-21 17:36:01 +0100300 rdev->wiphy.vht_capa_mod_mask);
Ben Greear7e7c8922011-11-18 11:31:59 -0800301
Johannes Bergf62fab72013-02-21 20:09:09 +0100302 req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len,
303 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Johannes Bergceca7b72013-05-16 00:55:45 +0200304 if (!req->bss)
Johannes Berg19957bb2009-07-02 17:20:43 +0200305 return -ENOENT;
306
Johannes Bergf62fab72013-02-21 20:09:09 +0100307 err = cfg80211_can_use_chan(rdev, wdev, chan, CHAN_MODE_SHARED);
Michal Kaziore4e32452012-06-29 12:47:08 +0200308 if (err)
309 goto out;
310
Johannes Bergf62fab72013-02-21 20:09:09 +0100311 err = rdev_assoc(rdev, dev, req);
Johannes Berg95de8172012-01-20 13:55:25 +0100312
Michal Kaziore4e32452012-06-29 12:47:08 +0200313out:
Johannes Bergceca7b72013-05-16 00:55:45 +0200314 if (err)
Johannes Bergf62fab72013-02-21 20:09:09 +0100315 cfg80211_put_bss(&rdev->wiphy, req->bss);
Johannes Berg95de8172012-01-20 13:55:25 +0100316
Johannes Berg19957bb2009-07-02 17:20:43 +0200317 return err;
318}
319
Johannes Berg91bf9b22013-05-15 17:44:01 +0200320int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
321 struct net_device *dev, const u8 *bssid,
322 const u8 *ie, int ie_len, u16 reason,
323 bool local_state_change)
Johannes Berg19957bb2009-07-02 17:20:43 +0200324{
325 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100326 struct cfg80211_deauth_request req = {
327 .bssid = bssid,
328 .reason_code = reason,
329 .ie = ie,
330 .ie_len = ie_len,
Stanislaw Gruszka68632552012-10-15 14:52:41 +0200331 .local_state_change = local_state_change,
Johannes Berg95de8172012-01-20 13:55:25 +0100332 };
Johannes Berg19957bb2009-07-02 17:20:43 +0200333
Johannes Berg667503dd2009-07-07 03:56:11 +0200334 ASSERT_WDEV_LOCK(wdev);
335
Johannes Bergceca7b72013-05-16 00:55:45 +0200336 if (local_state_change &&
337 (!wdev->current_bss ||
338 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
Johannes Berg95de8172012-01-20 13:55:25 +0100339 return 0;
Johannes Berg19957bb2009-07-02 17:20:43 +0200340
Hila Gonene35e4d22012-06-27 17:19:42 +0300341 return rdev_deauth(rdev, dev, &req);
Johannes Berg19957bb2009-07-02 17:20:43 +0200342}
343
Johannes Berg91bf9b22013-05-15 17:44:01 +0200344int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
345 struct net_device *dev, const u8 *bssid,
346 const u8 *ie, int ie_len, u16 reason,
347 bool local_state_change)
Johannes Berg19957bb2009-07-02 17:20:43 +0200348{
349 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg7ade7032013-05-13 11:37:30 +0200350 struct cfg80211_disassoc_request req = {
351 .reason_code = reason,
352 .local_state_change = local_state_change,
353 .ie = ie,
354 .ie_len = ie_len,
355 };
Johannes Bergceca7b72013-05-16 00:55:45 +0200356 int err;
Johannes Berg19957bb2009-07-02 17:20:43 +0200357
Johannes Berg667503dd2009-07-07 03:56:11 +0200358 ASSERT_WDEV_LOCK(wdev);
359
Johannes Bergceca7b72013-05-16 00:55:45 +0200360 if (!wdev->current_bss)
Johannes Bergf9d6b402009-07-27 10:22:28 +0200361 return -ENOTCONN;
362
Joe Perchesac422d32012-05-08 18:56:55 +0000363 if (ether_addr_equal(wdev->current_bss->pub.bssid, bssid))
Johannes Berg19957bb2009-07-02 17:20:43 +0200364 req.bss = &wdev->current_bss->pub;
365 else
366 return -ENOTCONN;
367
Johannes Bergceca7b72013-05-16 00:55:45 +0200368 err = rdev_disassoc(rdev, dev, &req);
369 if (err)
370 return err;
371
372 /* driver should have reported the disassoc */
373 WARN_ON(wdev->current_bss);
374 return 0;
Johannes Berg667503dd2009-07-07 03:56:11 +0200375}
376
Johannes Berg19957bb2009-07-02 17:20:43 +0200377void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
378 struct net_device *dev)
379{
380 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berg95de8172012-01-20 13:55:25 +0100381 u8 bssid[ETH_ALEN];
Johannes Berg19957bb2009-07-02 17:20:43 +0200382
Johannes Berg667503dd2009-07-07 03:56:11 +0200383 ASSERT_WDEV_LOCK(wdev);
384
Johannes Berg19957bb2009-07-02 17:20:43 +0200385 if (!rdev->ops->deauth)
386 return;
387
Johannes Berg95de8172012-01-20 13:55:25 +0100388 if (!wdev->current_bss)
389 return;
Johannes Berg19957bb2009-07-02 17:20:43 +0200390
Johannes Berg95de8172012-01-20 13:55:25 +0100391 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
Johannes Bergceca7b72013-05-16 00:55:45 +0200392 cfg80211_mlme_deauth(rdev, dev, bssid, NULL, 0,
393 WLAN_REASON_DEAUTH_LEAVING, false);
Johannes Berg19957bb2009-07-02 17:20:43 +0200394}
Jouni Malinen9588bbd2009-12-23 13:15:41 +0100395
Johannes Berg2e161f72010-08-12 15:38:38 +0200396struct cfg80211_mgmt_registration {
Jouni Malinen026331c2010-02-15 12:53:10 +0200397 struct list_head list;
398
Eric W. Biederman15e47302012-09-07 20:12:54 +0000399 u32 nlportid;
Jouni Malinen026331c2010-02-15 12:53:10 +0200400
401 int match_len;
402
Johannes Berg2e161f72010-08-12 15:38:38 +0200403 __le16 frame_type;
404
Jouni Malinen026331c2010-02-15 12:53:10 +0200405 u8 match[];
406};
407
Eric W. Biederman15e47302012-09-07 20:12:54 +0000408int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
Johannes Berg2e161f72010-08-12 15:38:38 +0200409 u16 frame_type, const u8 *match_data,
410 int match_len)
Jouni Malinen026331c2010-02-15 12:53:10 +0200411{
Johannes Berg271733c2010-10-13 12:06:23 +0200412 struct wiphy *wiphy = wdev->wiphy;
413 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200414 struct cfg80211_mgmt_registration *reg, *nreg;
Jouni Malinen026331c2010-02-15 12:53:10 +0200415 int err = 0;
Johannes Berg2e161f72010-08-12 15:38:38 +0200416 u16 mgmt_type;
417
418 if (!wdev->wiphy->mgmt_stypes)
419 return -EOPNOTSUPP;
420
421 if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
422 return -EINVAL;
423
424 if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE))
425 return -EINVAL;
426
427 mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
428 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type)))
429 return -EINVAL;
Jouni Malinen026331c2010-02-15 12:53:10 +0200430
431 nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL);
432 if (!nreg)
433 return -ENOMEM;
434
Johannes Berg2e161f72010-08-12 15:38:38 +0200435 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200436
Johannes Berg2e161f72010-08-12 15:38:38 +0200437 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
Jouni Malinen026331c2010-02-15 12:53:10 +0200438 int mlen = min(match_len, reg->match_len);
439
Johannes Berg2e161f72010-08-12 15:38:38 +0200440 if (frame_type != le16_to_cpu(reg->frame_type))
441 continue;
442
Jouni Malinen026331c2010-02-15 12:53:10 +0200443 if (memcmp(reg->match, match_data, mlen) == 0) {
444 err = -EALREADY;
445 break;
446 }
447 }
448
449 if (err) {
450 kfree(nreg);
451 goto out;
452 }
453
454 memcpy(nreg->match, match_data, match_len);
455 nreg->match_len = match_len;
Eric W. Biederman15e47302012-09-07 20:12:54 +0000456 nreg->nlportid = snd_portid;
Johannes Berg2e161f72010-08-12 15:38:38 +0200457 nreg->frame_type = cpu_to_le16(frame_type);
458 list_add(&nreg->list, &wdev->mgmt_registrations);
Jouni Malinen026331c2010-02-15 12:53:10 +0200459
Johannes Berg271733c2010-10-13 12:06:23 +0200460 if (rdev->ops->mgmt_frame_register)
Hila Gonene35e4d22012-06-27 17:19:42 +0300461 rdev_mgmt_frame_register(rdev, wdev, frame_type, true);
Johannes Berg271733c2010-10-13 12:06:23 +0200462
Jouni Malinen026331c2010-02-15 12:53:10 +0200463 out:
Johannes Berg2e161f72010-08-12 15:38:38 +0200464 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Johannes Berg271733c2010-10-13 12:06:23 +0200465
Jouni Malinen026331c2010-02-15 12:53:10 +0200466 return err;
467}
468
Eric W. Biederman15e47302012-09-07 20:12:54 +0000469void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid)
Jouni Malinen026331c2010-02-15 12:53:10 +0200470{
Johannes Berg271733c2010-10-13 12:06:23 +0200471 struct wiphy *wiphy = wdev->wiphy;
472 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200473 struct cfg80211_mgmt_registration *reg, *tmp;
Jouni Malinen026331c2010-02-15 12:53:10 +0200474
Johannes Berg2e161f72010-08-12 15:38:38 +0200475 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200476
Johannes Berg2e161f72010-08-12 15:38:38 +0200477 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
Eric W. Biederman15e47302012-09-07 20:12:54 +0000478 if (reg->nlportid != nlportid)
Johannes Berg271733c2010-10-13 12:06:23 +0200479 continue;
480
481 if (rdev->ops->mgmt_frame_register) {
482 u16 frame_type = le16_to_cpu(reg->frame_type);
483
Hila Gonene35e4d22012-06-27 17:19:42 +0300484 rdev_mgmt_frame_register(rdev, wdev,
485 frame_type, false);
Jouni Malinen026331c2010-02-15 12:53:10 +0200486 }
Johannes Berg271733c2010-10-13 12:06:23 +0200487
488 list_del(&reg->list);
489 kfree(reg);
Jouni Malinen026331c2010-02-15 12:53:10 +0200490 }
491
Johannes Berg2e161f72010-08-12 15:38:38 +0200492 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Johannes Berg28946da2011-11-04 11:18:12 +0100493
Arend van Spriel5de17982013-04-18 15:49:00 +0200494 if (nlportid && rdev->crit_proto_nlportid == nlportid) {
495 rdev->crit_proto_nlportid = 0;
496 rdev_crit_proto_stop(rdev, wdev);
497 }
498
Eric W. Biederman15e47302012-09-07 20:12:54 +0000499 if (nlportid == wdev->ap_unexpected_nlportid)
500 wdev->ap_unexpected_nlportid = 0;
Jouni Malinen026331c2010-02-15 12:53:10 +0200501}
502
Johannes Berg2e161f72010-08-12 15:38:38 +0200503void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
Jouni Malinen026331c2010-02-15 12:53:10 +0200504{
Johannes Berg2e161f72010-08-12 15:38:38 +0200505 struct cfg80211_mgmt_registration *reg, *tmp;
Jouni Malinen026331c2010-02-15 12:53:10 +0200506
Johannes Berg2e161f72010-08-12 15:38:38 +0200507 spin_lock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200508
Johannes Berg2e161f72010-08-12 15:38:38 +0200509 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
Jouni Malinen026331c2010-02-15 12:53:10 +0200510 list_del(&reg->list);
511 kfree(reg);
512 }
513
Johannes Berg2e161f72010-08-12 15:38:38 +0200514 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200515}
516
Johannes Berg2e161f72010-08-12 15:38:38 +0200517int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
Johannes Berg71bbc992012-06-15 15:30:18 +0200518 struct wireless_dev *wdev,
Johannes Bergf7ca38d2010-11-25 10:02:29 +0100519 struct ieee80211_channel *chan, bool offchan,
Johannes Berg42d97a52012-11-08 18:31:02 +0100520 unsigned int wait, const u8 *buf, size_t len,
521 bool no_cck, bool dont_wait_for_ack, u64 *cookie)
Jouni Malinen026331c2010-02-15 12:53:10 +0200522{
Jouni Malinen026331c2010-02-15 12:53:10 +0200523 const struct ieee80211_mgmt *mgmt;
Johannes Berg2e161f72010-08-12 15:38:38 +0200524 u16 stype;
Jouni Malinen026331c2010-02-15 12:53:10 +0200525
Johannes Berg2e161f72010-08-12 15:38:38 +0200526 if (!wdev->wiphy->mgmt_stypes)
Jouni Malinen026331c2010-02-15 12:53:10 +0200527 return -EOPNOTSUPP;
Johannes Berg2e161f72010-08-12 15:38:38 +0200528
529 if (!rdev->ops->mgmt_tx)
530 return -EOPNOTSUPP;
531
Jouni Malinen026331c2010-02-15 12:53:10 +0200532 if (len < 24 + 1)
533 return -EINVAL;
534
535 mgmt = (const struct ieee80211_mgmt *) buf;
Johannes Berg2e161f72010-08-12 15:38:38 +0200536
537 if (!ieee80211_is_mgmt(mgmt->frame_control))
Jouni Malinen026331c2010-02-15 12:53:10 +0200538 return -EINVAL;
Johannes Berg2e161f72010-08-12 15:38:38 +0200539
540 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
541 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4)))
542 return -EINVAL;
543
544 if (ieee80211_is_action(mgmt->frame_control) &&
545 mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200546 int err = 0;
547
Johannes Bergfe100ac2010-08-09 15:52:03 +0200548 wdev_lock(wdev);
549
Johannes Berg663fcaf2010-09-30 21:06:09 +0200550 switch (wdev->iftype) {
551 case NL80211_IFTYPE_ADHOC:
552 case NL80211_IFTYPE_STATION:
553 case NL80211_IFTYPE_P2P_CLIENT:
554 if (!wdev->current_bss) {
555 err = -ENOTCONN;
556 break;
557 }
Johannes Bergfe100ac2010-08-09 15:52:03 +0200558
Joe Perchesac422d32012-05-08 18:56:55 +0000559 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
560 mgmt->bssid)) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200561 err = -ENOTCONN;
562 break;
563 }
564
565 /*
566 * check for IBSS DA must be done by driver as
567 * cfg80211 doesn't track the stations
568 */
569 if (wdev->iftype == NL80211_IFTYPE_ADHOC)
570 break;
571
572 /* for station, check that DA is the AP */
Joe Perchesac422d32012-05-08 18:56:55 +0000573 if (!ether_addr_equal(wdev->current_bss->pub.bssid,
574 mgmt->da)) {
Johannes Berg663fcaf2010-09-30 21:06:09 +0200575 err = -ENOTCONN;
576 break;
577 }
578 break;
579 case NL80211_IFTYPE_AP:
580 case NL80211_IFTYPE_P2P_GO:
581 case NL80211_IFTYPE_AP_VLAN:
Johannes Berg98104fde2012-06-16 00:19:54 +0200582 if (!ether_addr_equal(mgmt->bssid, wdev_address(wdev)))
Johannes Berg663fcaf2010-09-30 21:06:09 +0200583 err = -EINVAL;
584 break;
Javier Cardona0778a6a2011-05-03 16:57:08 -0700585 case NL80211_IFTYPE_MESH_POINT:
Joe Perchesac422d32012-05-08 18:56:55 +0000586 if (!ether_addr_equal(mgmt->sa, mgmt->bssid)) {
Javier Cardona0778a6a2011-05-03 16:57:08 -0700587 err = -EINVAL;
588 break;
589 }
590 /*
591 * check for mesh DA must be done by driver as
592 * cfg80211 doesn't track the stations
593 */
594 break;
Johannes Berg98104fde2012-06-16 00:19:54 +0200595 case NL80211_IFTYPE_P2P_DEVICE:
596 /*
597 * fall through, P2P device only supports
598 * public action frames
599 */
Johannes Berg663fcaf2010-09-30 21:06:09 +0200600 default:
601 err = -EOPNOTSUPP;
602 break;
603 }
Johannes Bergfe100ac2010-08-09 15:52:03 +0200604 wdev_unlock(wdev);
Johannes Berg663fcaf2010-09-30 21:06:09 +0200605
606 if (err)
607 return err;
Jouni Malinen026331c2010-02-15 12:53:10 +0200608 }
609
Johannes Berg98104fde2012-06-16 00:19:54 +0200610 if (!ether_addr_equal(mgmt->sa, wdev_address(wdev)))
Jouni Malinen026331c2010-02-15 12:53:10 +0200611 return -EINVAL;
612
613 /* Transmit the Action frame as requested by user space */
Hila Gonene35e4d22012-06-27 17:19:42 +0300614 return rdev_mgmt_tx(rdev, wdev, chan, offchan,
Hila Gonene35e4d22012-06-27 17:19:42 +0300615 wait, buf, len, no_cck, dont_wait_for_ack,
616 cookie);
Jouni Malinen026331c2010-02-15 12:53:10 +0200617}
618
Johannes Berg71bbc992012-06-15 15:30:18 +0200619bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm,
Johannes Berg804483e2012-03-05 22:18:41 +0100620 const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen026331c2010-02-15 12:53:10 +0200621{
Jouni Malinen026331c2010-02-15 12:53:10 +0200622 struct wiphy *wiphy = wdev->wiphy;
623 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berg2e161f72010-08-12 15:38:38 +0200624 struct cfg80211_mgmt_registration *reg;
625 const struct ieee80211_txrx_stypes *stypes =
626 &wiphy->mgmt_stypes[wdev->iftype];
627 struct ieee80211_mgmt *mgmt = (void *)buf;
628 const u8 *data;
629 int data_len;
Jouni Malinen026331c2010-02-15 12:53:10 +0200630 bool result = false;
Johannes Berg2e161f72010-08-12 15:38:38 +0200631 __le16 ftype = mgmt->frame_control &
632 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
633 u16 stype;
Jouni Malinen026331c2010-02-15 12:53:10 +0200634
Beni Lev4ee3e062012-08-27 12:49:39 +0300635 trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm);
Johannes Berg2e161f72010-08-12 15:38:38 +0200636 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
Jouni Malinen026331c2010-02-15 12:53:10 +0200637
Beni Lev4ee3e062012-08-27 12:49:39 +0300638 if (!(stypes->rx & BIT(stype))) {
639 trace_cfg80211_return_bool(false);
Johannes Berg2e161f72010-08-12 15:38:38 +0200640 return false;
Beni Lev4ee3e062012-08-27 12:49:39 +0300641 }
Jouni Malinen026331c2010-02-15 12:53:10 +0200642
Johannes Berg2e161f72010-08-12 15:38:38 +0200643 data = buf + ieee80211_hdrlen(mgmt->frame_control);
644 data_len = len - ieee80211_hdrlen(mgmt->frame_control);
Jouni Malinen026331c2010-02-15 12:53:10 +0200645
Johannes Berg2e161f72010-08-12 15:38:38 +0200646 spin_lock_bh(&wdev->mgmt_registrations_lock);
647
648 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
649 if (reg->frame_type != ftype)
Jouni Malinen026331c2010-02-15 12:53:10 +0200650 continue;
651
Johannes Berg2e161f72010-08-12 15:38:38 +0200652 if (reg->match_len > data_len)
653 continue;
654
655 if (memcmp(reg->match, data, reg->match_len))
Jouni Malinen026331c2010-02-15 12:53:10 +0200656 continue;
657
658 /* found match! */
659
660 /* Indicate the received Action frame to user space */
Eric W. Biederman15e47302012-09-07 20:12:54 +0000661 if (nl80211_send_mgmt(rdev, wdev, reg->nlportid,
Johannes Berg804483e2012-03-05 22:18:41 +0100662 freq, sig_mbm,
Johannes Berg2e161f72010-08-12 15:38:38 +0200663 buf, len, gfp))
Jouni Malinen026331c2010-02-15 12:53:10 +0200664 continue;
665
666 result = true;
667 break;
668 }
669
Johannes Berg2e161f72010-08-12 15:38:38 +0200670 spin_unlock_bh(&wdev->mgmt_registrations_lock);
Jouni Malinen026331c2010-02-15 12:53:10 +0200671
Beni Lev4ee3e062012-08-27 12:49:39 +0300672 trace_cfg80211_return_bool(result);
Jouni Malinen026331c2010-02-15 12:53:10 +0200673 return result;
674}
Johannes Berg2e161f72010-08-12 15:38:38 +0200675EXPORT_SYMBOL(cfg80211_rx_mgmt);
Jouni Malinen026331c2010-02-15 12:53:10 +0200676
Simon Wunderlich04f39042013-02-08 18:16:19 +0100677void cfg80211_dfs_channels_update_work(struct work_struct *work)
678{
679 struct delayed_work *delayed_work;
680 struct cfg80211_registered_device *rdev;
681 struct cfg80211_chan_def chandef;
682 struct ieee80211_supported_band *sband;
683 struct ieee80211_channel *c;
684 struct wiphy *wiphy;
685 bool check_again = false;
686 unsigned long timeout, next_time = 0;
687 int bandid, i;
688
689 delayed_work = container_of(work, struct delayed_work, work);
690 rdev = container_of(delayed_work, struct cfg80211_registered_device,
691 dfs_update_channels_wk);
692 wiphy = &rdev->wiphy;
693
Johannes Berg5fe231e2013-05-08 21:45:15 +0200694 rtnl_lock();
Simon Wunderlich04f39042013-02-08 18:16:19 +0100695 for (bandid = 0; bandid < IEEE80211_NUM_BANDS; bandid++) {
696 sband = wiphy->bands[bandid];
697 if (!sband)
698 continue;
699
700 for (i = 0; i < sband->n_channels; i++) {
701 c = &sband->channels[i];
702
703 if (c->dfs_state != NL80211_DFS_UNAVAILABLE)
704 continue;
705
706 timeout = c->dfs_state_entered +
707 IEEE80211_DFS_MIN_NOP_TIME_MS;
708
709 if (time_after_eq(jiffies, timeout)) {
710 c->dfs_state = NL80211_DFS_USABLE;
711 cfg80211_chandef_create(&chandef, c,
712 NL80211_CHAN_NO_HT);
713
714 nl80211_radar_notify(rdev, &chandef,
715 NL80211_RADAR_NOP_FINISHED,
716 NULL, GFP_ATOMIC);
717 continue;
718 }
719
720 if (!check_again)
721 next_time = timeout - jiffies;
722 else
723 next_time = min(next_time, timeout - jiffies);
724 check_again = true;
725 }
726 }
Johannes Berg5fe231e2013-05-08 21:45:15 +0200727 rtnl_unlock();
Simon Wunderlich04f39042013-02-08 18:16:19 +0100728
729 /* reschedule if there are other channels waiting to be cleared again */
730 if (check_again)
731 queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk,
732 next_time);
733}
734
735
736void cfg80211_radar_event(struct wiphy *wiphy,
737 struct cfg80211_chan_def *chandef,
738 gfp_t gfp)
739{
740 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
741 unsigned long timeout;
742
743 trace_cfg80211_radar_event(wiphy, chandef);
744
745 /* only set the chandef supplied channel to unavailable, in
746 * case the radar is detected on only one of multiple channels
747 * spanned by the chandef.
748 */
749 cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_UNAVAILABLE);
750
751 timeout = msecs_to_jiffies(IEEE80211_DFS_MIN_NOP_TIME_MS);
752 queue_delayed_work(cfg80211_wq, &rdev->dfs_update_channels_wk,
753 timeout);
754
755 nl80211_radar_notify(rdev, chandef, NL80211_RADAR_DETECTED, NULL, gfp);
756}
757EXPORT_SYMBOL(cfg80211_radar_event);
758
759void cfg80211_cac_event(struct net_device *netdev,
760 enum nl80211_radar_event event, gfp_t gfp)
761{
762 struct wireless_dev *wdev = netdev->ieee80211_ptr;
763 struct wiphy *wiphy = wdev->wiphy;
764 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
765 struct cfg80211_chan_def chandef;
766 unsigned long timeout;
767
768 trace_cfg80211_cac_event(netdev, event);
769
770 if (WARN_ON(!wdev->cac_started))
771 return;
772
773 if (WARN_ON(!wdev->channel))
774 return;
775
776 cfg80211_chandef_create(&chandef, wdev->channel, NL80211_CHAN_NO_HT);
777
778 switch (event) {
779 case NL80211_RADAR_CAC_FINISHED:
780 timeout = wdev->cac_start_time +
781 msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
782 WARN_ON(!time_after_eq(jiffies, timeout));
783 cfg80211_set_dfs_state(wiphy, &chandef, NL80211_DFS_AVAILABLE);
784 break;
785 case NL80211_RADAR_CAC_ABORTED:
786 break;
787 default:
788 WARN_ON(1);
789 return;
790 }
791 wdev->cac_started = false;
792
793 nl80211_radar_notify(rdev, &chandef, event, netdev, gfp);
794}
795EXPORT_SYMBOL(cfg80211_cac_event);