Lines Matching +full:assoc +full:- +full:select
1 // SPDX-License-Identifier: GPL-2.0
23 #include "rdev-ops.h"
26 * Software SME in cfg80211, using auth/assoc/deauth calls to the
33 /* these are sub-states of the _CONNECTING sme_state */
56 if (!wdev->conn) in cfg80211_sme_free()
59 kfree(wdev->conn->ie); in cfg80211_sme_free()
60 kfree(wdev->conn); in cfg80211_sme_free()
61 wdev->conn = NULL; in cfg80211_sme_free()
66 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_conn_scan()
73 if (rdev->scan_req || rdev->scan_msg) in cfg80211_conn_scan()
74 return -EBUSY; in cfg80211_conn_scan()
76 if (wdev->conn->params.channel) in cfg80211_conn_scan()
79 n_channels = ieee80211_get_num_supported_channels(wdev->wiphy); in cfg80211_conn_scan()
81 request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + in cfg80211_conn_scan()
82 sizeof(request->channels[0]) * n_channels, in cfg80211_conn_scan()
85 return -ENOMEM; in cfg80211_conn_scan()
87 if (wdev->conn->params.channel) { in cfg80211_conn_scan()
88 enum nl80211_band band = wdev->conn->params.channel->band; in cfg80211_conn_scan()
90 wdev->wiphy->bands[band]; in cfg80211_conn_scan()
94 return -EINVAL; in cfg80211_conn_scan()
96 request->channels[0] = wdev->conn->params.channel; in cfg80211_conn_scan()
97 request->rates[band] = (1 << sband->n_bitrates) - 1; in cfg80211_conn_scan()
105 bands = wdev->wiphy->bands[band]; in cfg80211_conn_scan()
108 for (j = 0; j < bands->n_channels; j++) { in cfg80211_conn_scan()
109 channel = &bands->channels[j]; in cfg80211_conn_scan()
110 if (channel->flags & IEEE80211_CHAN_DISABLED) in cfg80211_conn_scan()
112 request->channels[i++] = channel; in cfg80211_conn_scan()
114 request->rates[band] = (1 << bands->n_bitrates) - 1; in cfg80211_conn_scan()
118 request->n_channels = n_channels; in cfg80211_conn_scan()
119 request->ssids = (void *)&request->channels[n_channels]; in cfg80211_conn_scan()
120 request->n_ssids = 1; in cfg80211_conn_scan()
122 memcpy(request->ssids[0].ssid, wdev->conn->params.ssid, in cfg80211_conn_scan()
123 wdev->conn->params.ssid_len); in cfg80211_conn_scan()
124 request->ssids[0].ssid_len = wdev->conn->params.ssid_len; in cfg80211_conn_scan()
126 eth_broadcast_addr(request->bssid); in cfg80211_conn_scan()
128 request->wdev = wdev; in cfg80211_conn_scan()
129 request->wiphy = &rdev->wiphy; in cfg80211_conn_scan()
130 request->scan_start = jiffies; in cfg80211_conn_scan()
132 rdev->scan_req = request; in cfg80211_conn_scan()
136 wdev->conn->state = CFG80211_CONN_SCANNING; in cfg80211_conn_scan()
138 dev_hold(wdev->netdev); in cfg80211_conn_scan()
140 rdev->scan_req = NULL; in cfg80211_conn_scan()
149 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_conn_do_work()
156 if (!wdev->conn) in cfg80211_conn_do_work()
159 params = &wdev->conn->params; in cfg80211_conn_do_work()
161 switch (wdev->conn->state) { in cfg80211_conn_do_work()
164 return -ENOENT; in cfg80211_conn_do_work()
168 if (WARN_ON(!rdev->ops->auth)) in cfg80211_conn_do_work()
169 return -EOPNOTSUPP; in cfg80211_conn_do_work()
170 wdev->conn->state = CFG80211_CONN_AUTHENTICATING; in cfg80211_conn_do_work()
171 return cfg80211_mlme_auth(rdev, wdev->netdev, in cfg80211_conn_do_work()
172 params->channel, params->auth_type, in cfg80211_conn_do_work()
173 params->bssid, in cfg80211_conn_do_work()
174 params->ssid, params->ssid_len, in cfg80211_conn_do_work()
176 params->key, params->key_len, in cfg80211_conn_do_work()
177 params->key_idx, NULL, 0); in cfg80211_conn_do_work()
180 return -ENOTCONN; in cfg80211_conn_do_work()
182 if (WARN_ON(!rdev->ops->assoc)) in cfg80211_conn_do_work()
183 return -EOPNOTSUPP; in cfg80211_conn_do_work()
184 wdev->conn->state = CFG80211_CONN_ASSOCIATING; in cfg80211_conn_do_work()
185 if (wdev->conn->prev_bssid_valid) in cfg80211_conn_do_work()
186 req.prev_bssid = wdev->conn->prev_bssid; in cfg80211_conn_do_work()
187 req.ie = params->ie; in cfg80211_conn_do_work()
188 req.ie_len = params->ie_len; in cfg80211_conn_do_work()
189 req.use_mfp = params->mfp != NL80211_MFP_NO; in cfg80211_conn_do_work()
190 req.crypto = params->crypto; in cfg80211_conn_do_work()
191 req.flags = params->flags; in cfg80211_conn_do_work()
192 req.ht_capa = params->ht_capa; in cfg80211_conn_do_work()
193 req.ht_capa_mask = params->ht_capa_mask; in cfg80211_conn_do_work()
194 req.vht_capa = params->vht_capa; in cfg80211_conn_do_work()
195 req.vht_capa_mask = params->vht_capa_mask; in cfg80211_conn_do_work()
197 err = cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel, in cfg80211_conn_do_work()
198 params->bssid, params->ssid, in cfg80211_conn_do_work()
199 params->ssid_len, &req); in cfg80211_conn_do_work()
201 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, in cfg80211_conn_do_work()
210 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, in cfg80211_conn_do_work()
213 return -ENOTCONN; in cfg80211_conn_do_work()
215 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, in cfg80211_conn_do_work()
238 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_conn_work()
239 if (!wdev->netdev) in cfg80211_conn_work()
243 if (!netif_running(wdev->netdev)) { in cfg80211_conn_work()
247 if (!wdev->conn || in cfg80211_conn_work()
248 wdev->conn->state == CFG80211_CONN_CONNECTED) { in cfg80211_conn_work()
252 if (wdev->conn->params.bssid) { in cfg80211_conn_work()
253 memcpy(bssid_buf, wdev->conn->params.bssid, ETH_ALEN); in cfg80211_conn_work()
261 cr.status = -1; in cfg80211_conn_work()
264 __cfg80211_connect_result(wdev->netdev, &cr, false); in cfg80211_conn_work()
275 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_get_conn_bss()
280 bss = cfg80211_get_bss(wdev->wiphy, wdev->conn->params.channel, in cfg80211_get_conn_bss()
281 wdev->conn->params.bssid, in cfg80211_get_conn_bss()
282 wdev->conn->params.ssid, in cfg80211_get_conn_bss()
283 wdev->conn->params.ssid_len, in cfg80211_get_conn_bss()
284 wdev->conn_bss_type, in cfg80211_get_conn_bss()
285 IEEE80211_PRIVACY(wdev->conn->params.privacy)); in cfg80211_get_conn_bss()
289 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN); in cfg80211_get_conn_bss()
290 wdev->conn->params.bssid = wdev->conn->bssid; in cfg80211_get_conn_bss()
291 wdev->conn->params.channel = bss->channel; in cfg80211_get_conn_bss()
292 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; in cfg80211_get_conn_bss()
293 schedule_work(&rdev->conn_work); in cfg80211_get_conn_bss()
300 struct wireless_dev *wdev = dev->ieee80211_ptr; in __cfg80211_sme_scan_done()
301 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in __cfg80211_sme_scan_done()
306 if (!wdev->conn) in __cfg80211_sme_scan_done()
309 if (wdev->conn->state != CFG80211_CONN_SCANNING && in __cfg80211_sme_scan_done()
310 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN) in __cfg80211_sme_scan_done()
315 cfg80211_put_bss(&rdev->wiphy, bss); in __cfg80211_sme_scan_done()
317 schedule_work(&rdev->conn_work); in __cfg80211_sme_scan_done()
322 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_sme_scan_done()
331 struct wiphy *wiphy = wdev->wiphy; in cfg80211_sme_rx_auth()
334 u16 status_code = le16_to_cpu(mgmt->u.auth.status_code); in cfg80211_sme_rx_auth()
338 if (!wdev->conn || wdev->conn->state == CFG80211_CONN_CONNECTED) in cfg80211_sme_rx_auth()
342 wdev->conn->auto_auth && in cfg80211_sme_rx_auth()
343 wdev->conn->params.auth_type != NL80211_AUTHTYPE_NETWORK_EAP) { in cfg80211_sme_rx_auth()
344 /* select automatically between only open, shared, leap */ in cfg80211_sme_rx_auth()
345 switch (wdev->conn->params.auth_type) { in cfg80211_sme_rx_auth()
347 if (wdev->connect_keys) in cfg80211_sme_rx_auth()
348 wdev->conn->params.auth_type = in cfg80211_sme_rx_auth()
351 wdev->conn->params.auth_type = in cfg80211_sme_rx_auth()
355 wdev->conn->params.auth_type = in cfg80211_sme_rx_auth()
360 wdev->conn->params.auth_type = in cfg80211_sme_rx_auth()
364 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; in cfg80211_sme_rx_auth()
365 schedule_work(&rdev->conn_work); in cfg80211_sme_rx_auth()
371 cr.bssid = mgmt->bssid; in cfg80211_sme_rx_auth()
373 __cfg80211_connect_result(wdev->netdev, &cr, false); in cfg80211_sme_rx_auth()
374 } else if (wdev->conn->state == CFG80211_CONN_AUTHENTICATING) { in cfg80211_sme_rx_auth()
375 wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT; in cfg80211_sme_rx_auth()
376 schedule_work(&rdev->conn_work); in cfg80211_sme_rx_auth()
382 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_rx_assoc_resp()
384 if (!wdev->conn) in cfg80211_sme_rx_assoc_resp()
388 wdev->conn->state = CFG80211_CONN_CONNECTED; in cfg80211_sme_rx_assoc_resp()
392 if (wdev->conn->prev_bssid_valid) { in cfg80211_sme_rx_assoc_resp()
395 * need to fall back to trying regular assoc; in cfg80211_sme_rx_assoc_resp()
398 wdev->conn->prev_bssid_valid = false; in cfg80211_sme_rx_assoc_resp()
399 wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT; in cfg80211_sme_rx_assoc_resp()
400 schedule_work(&rdev->conn_work); in cfg80211_sme_rx_assoc_resp()
404 wdev->conn->state = CFG80211_CONN_ASSOC_FAILED; in cfg80211_sme_rx_assoc_resp()
405 schedule_work(&rdev->conn_work); in cfg80211_sme_rx_assoc_resp()
416 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_auth_timeout()
418 if (!wdev->conn) in cfg80211_sme_auth_timeout()
421 wdev->conn->state = CFG80211_CONN_AUTH_FAILED_TIMEOUT; in cfg80211_sme_auth_timeout()
422 schedule_work(&rdev->conn_work); in cfg80211_sme_auth_timeout()
427 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_disassoc()
429 if (!wdev->conn) in cfg80211_sme_disassoc()
432 wdev->conn->state = CFG80211_CONN_DEAUTH; in cfg80211_sme_disassoc()
433 schedule_work(&rdev->conn_work); in cfg80211_sme_disassoc()
438 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_assoc_timeout()
440 if (!wdev->conn) in cfg80211_sme_assoc_timeout()
443 wdev->conn->state = CFG80211_CONN_ASSOC_FAILED_TIMEOUT; in cfg80211_sme_assoc_timeout()
444 schedule_work(&rdev->conn_work); in cfg80211_sme_assoc_timeout()
449 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_abandon_assoc()
451 if (!wdev->conn) in cfg80211_sme_abandon_assoc()
454 wdev->conn->state = CFG80211_CONN_ABANDON; in cfg80211_sme_abandon_assoc()
455 schedule_work(&rdev->conn_work); in cfg80211_sme_abandon_assoc()
462 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_get_conn_ies()
466 if (!rdev->wiphy.extended_capabilities_len || in cfg80211_sme_get_conn_ies()
470 return -ENOMEM; in cfg80211_sme_get_conn_ies()
475 buf = kmalloc(ies_len + rdev->wiphy.extended_capabilities_len + 2, in cfg80211_sme_get_conn_ies()
478 return -ENOMEM; in cfg80211_sme_get_conn_ies()
495 memcpy(buf + offs + rdev->wiphy.extended_capabilities_len + 2, in cfg80211_sme_get_conn_ies()
496 ies + offs, ies_len - offs); in cfg80211_sme_get_conn_ies()
503 buf[offs + 1] = rdev->wiphy.extended_capabilities_len; in cfg80211_sme_get_conn_ies()
505 rdev->wiphy.extended_capabilities, in cfg80211_sme_get_conn_ies()
506 rdev->wiphy.extended_capabilities_len); in cfg80211_sme_get_conn_ies()
509 *out_ies_len = ies_len + rdev->wiphy.extended_capabilities_len + 2; in cfg80211_sme_get_conn_ies()
518 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_connect()
522 if (!rdev->ops->auth || !rdev->ops->assoc) in cfg80211_sme_connect()
523 return -EOPNOTSUPP; in cfg80211_sme_connect()
525 if (wdev->current_bss) { in cfg80211_sme_connect()
526 cfg80211_unhold_bss(wdev->current_bss); in cfg80211_sme_connect()
527 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); in cfg80211_sme_connect()
528 wdev->current_bss = NULL; in cfg80211_sme_connect()
533 if (WARN_ON(wdev->conn)) in cfg80211_sme_connect()
534 return -EINPROGRESS; in cfg80211_sme_connect()
536 wdev->conn = kzalloc(sizeof(*wdev->conn), GFP_KERNEL); in cfg80211_sme_connect()
537 if (!wdev->conn) in cfg80211_sme_connect()
538 return -ENOMEM; in cfg80211_sme_connect()
543 memcpy(&wdev->conn->params, connect, sizeof(*connect)); in cfg80211_sme_connect()
544 if (connect->bssid) { in cfg80211_sme_connect()
545 wdev->conn->params.bssid = wdev->conn->bssid; in cfg80211_sme_connect()
546 memcpy(wdev->conn->bssid, connect->bssid, ETH_ALEN); in cfg80211_sme_connect()
549 if (cfg80211_sme_get_conn_ies(wdev, connect->ie, connect->ie_len, in cfg80211_sme_connect()
550 &wdev->conn->ie, in cfg80211_sme_connect()
551 &wdev->conn->params.ie_len)) { in cfg80211_sme_connect()
552 kfree(wdev->conn); in cfg80211_sme_connect()
553 wdev->conn = NULL; in cfg80211_sme_connect()
554 return -ENOMEM; in cfg80211_sme_connect()
556 wdev->conn->params.ie = wdev->conn->ie; in cfg80211_sme_connect()
558 if (connect->auth_type == NL80211_AUTHTYPE_AUTOMATIC) { in cfg80211_sme_connect()
559 wdev->conn->auto_auth = true; in cfg80211_sme_connect()
561 wdev->conn->params.auth_type = in cfg80211_sme_connect()
564 wdev->conn->auto_auth = false; in cfg80211_sme_connect()
567 wdev->conn->params.ssid = wdev->ssid; in cfg80211_sme_connect()
568 wdev->conn->params.ssid_len = wdev->ssid_len; in cfg80211_sme_connect()
574 memcpy(wdev->conn->prev_bssid, prev_bssid, ETH_ALEN); in cfg80211_sme_connect()
575 wdev->conn->prev_bssid_valid = true; in cfg80211_sme_connect()
583 cfg80211_put_bss(wdev->wiphy, bss); in cfg80211_sme_connect()
593 if (err == -EBUSY) { in cfg80211_sme_connect()
595 wdev->conn->state = CFG80211_CONN_SCAN_AGAIN; in cfg80211_sme_connect()
607 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_sme_disconnect()
610 if (!wdev->conn) in cfg80211_sme_disconnect()
613 if (!rdev->ops->deauth) in cfg80211_sme_disconnect()
614 return -EOPNOTSUPP; in cfg80211_sme_disconnect()
616 if (wdev->conn->state == CFG80211_CONN_SCANNING || in cfg80211_sme_disconnect()
617 wdev->conn->state == CFG80211_CONN_SCAN_AGAIN) { in cfg80211_sme_disconnect()
622 /* wdev->conn->params.bssid must be set if > SCANNING */ in cfg80211_sme_disconnect()
623 err = cfg80211_mlme_deauth(rdev, wdev->netdev, in cfg80211_sme_disconnect()
624 wdev->conn->params.bssid, in cfg80211_sme_disconnect()
632 * code shared for in-device and software SME
650 list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { in cfg80211_is_all_idle()
652 if (wdev->conn || wdev->current_bss || in cfg80211_is_all_idle()
683 struct wireless_dev *wdev = dev->ieee80211_ptr; in __cfg80211_connect_result()
691 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && in __cfg80211_connect_result()
692 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) { in __cfg80211_connect_result()
693 cfg80211_put_bss(wdev->wiphy, cr->bss); in __cfg80211_connect_result()
697 wdev->unprot_beacon_reported = 0; in __cfg80211_connect_result()
698 nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev, cr, in __cfg80211_connect_result()
703 if (cr->req_ie && cr->status == WLAN_STATUS_SUCCESS) { in __cfg80211_connect_result()
705 wrqu.data.length = cr->req_ie_len; in __cfg80211_connect_result()
707 cr->req_ie); in __cfg80211_connect_result()
710 if (cr->resp_ie && cr->status == WLAN_STATUS_SUCCESS) { in __cfg80211_connect_result()
712 wrqu.data.length = cr->resp_ie_len; in __cfg80211_connect_result()
714 cr->resp_ie); in __cfg80211_connect_result()
719 if (cr->bssid && cr->status == WLAN_STATUS_SUCCESS) { in __cfg80211_connect_result()
720 memcpy(wrqu.ap_addr.sa_data, cr->bssid, ETH_ALEN); in __cfg80211_connect_result()
721 memcpy(wdev->wext.prev_bssid, cr->bssid, ETH_ALEN); in __cfg80211_connect_result()
722 wdev->wext.prev_bssid_valid = true; in __cfg80211_connect_result()
728 if (!cr->bss && (cr->status == WLAN_STATUS_SUCCESS)) { in __cfg80211_connect_result()
729 WARN_ON_ONCE(!wiphy_to_rdev(wdev->wiphy)->ops->connect); in __cfg80211_connect_result()
730 cr->bss = cfg80211_get_bss(wdev->wiphy, NULL, cr->bssid, in __cfg80211_connect_result()
731 wdev->ssid, wdev->ssid_len, in __cfg80211_connect_result()
732 wdev->conn_bss_type, in __cfg80211_connect_result()
734 if (cr->bss) in __cfg80211_connect_result()
735 cfg80211_hold_bss(bss_from_pub(cr->bss)); in __cfg80211_connect_result()
738 if (wdev->current_bss) { in __cfg80211_connect_result()
739 cfg80211_unhold_bss(wdev->current_bss); in __cfg80211_connect_result()
740 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); in __cfg80211_connect_result()
741 wdev->current_bss = NULL; in __cfg80211_connect_result()
744 if (cr->status != WLAN_STATUS_SUCCESS) { in __cfg80211_connect_result()
745 kfree_sensitive(wdev->connect_keys); in __cfg80211_connect_result()
746 wdev->connect_keys = NULL; in __cfg80211_connect_result()
747 wdev->ssid_len = 0; in __cfg80211_connect_result()
748 wdev->conn_owner_nlportid = 0; in __cfg80211_connect_result()
749 if (cr->bss) { in __cfg80211_connect_result()
750 cfg80211_unhold_bss(bss_from_pub(cr->bss)); in __cfg80211_connect_result()
751 cfg80211_put_bss(wdev->wiphy, cr->bss); in __cfg80211_connect_result()
757 if (WARN_ON(!cr->bss)) in __cfg80211_connect_result()
760 wdev->current_bss = bss_from_pub(cr->bss); in __cfg80211_connect_result()
762 if (!(wdev->wiphy->flags & WIPHY_FLAG_HAS_STATIC_WEP)) in __cfg80211_connect_result()
766 country_ie = ieee80211_bss_get_ie(cr->bss, WLAN_EID_COUNTRY); in __cfg80211_connect_result()
780 * - country_ie + 2, the start of the country ie data, and in __cfg80211_connect_result()
781 * - and country_ie[1] which is the IE length in __cfg80211_connect_result()
783 regulatory_hint_country_ie(wdev->wiphy, cr->bss->channel->band, in __cfg80211_connect_result()
793 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_connect_done()
794 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_connect_done()
799 if (params->bss) { in cfg80211_connect_done()
800 struct cfg80211_internal_bss *ibss = bss_from_pub(params->bss); in cfg80211_connect_done()
802 if (list_empty(&ibss->list)) { in cfg80211_connect_done()
803 struct cfg80211_bss *found = NULL, *tmp = params->bss; in cfg80211_connect_done()
805 found = cfg80211_get_bss(wdev->wiphy, NULL, in cfg80211_connect_done()
806 params->bss->bssid, in cfg80211_connect_done()
807 wdev->ssid, wdev->ssid_len, in cfg80211_connect_done()
808 wdev->conn_bss_type, in cfg80211_connect_done()
814 params->bss = found; in cfg80211_connect_done()
826 ibss->ts); in cfg80211_connect_done()
829 cfg80211_put_bss(wdev->wiphy, tmp); in cfg80211_connect_done()
833 ev = kzalloc(sizeof(*ev) + (params->bssid ? ETH_ALEN : 0) + in cfg80211_connect_done()
834 params->req_ie_len + params->resp_ie_len + in cfg80211_connect_done()
835 params->fils.kek_len + params->fils.pmk_len + in cfg80211_connect_done()
836 (params->fils.pmkid ? WLAN_PMKID_LEN : 0), gfp); in cfg80211_connect_done()
838 cfg80211_put_bss(wdev->wiphy, params->bss); in cfg80211_connect_done()
842 ev->type = EVENT_CONNECT_RESULT; in cfg80211_connect_done()
844 if (params->bssid) { in cfg80211_connect_done()
845 ev->cr.bssid = next; in cfg80211_connect_done()
846 memcpy((void *)ev->cr.bssid, params->bssid, ETH_ALEN); in cfg80211_connect_done()
849 if (params->req_ie_len) { in cfg80211_connect_done()
850 ev->cr.req_ie = next; in cfg80211_connect_done()
851 ev->cr.req_ie_len = params->req_ie_len; in cfg80211_connect_done()
852 memcpy((void *)ev->cr.req_ie, params->req_ie, in cfg80211_connect_done()
853 params->req_ie_len); in cfg80211_connect_done()
854 next += params->req_ie_len; in cfg80211_connect_done()
856 if (params->resp_ie_len) { in cfg80211_connect_done()
857 ev->cr.resp_ie = next; in cfg80211_connect_done()
858 ev->cr.resp_ie_len = params->resp_ie_len; in cfg80211_connect_done()
859 memcpy((void *)ev->cr.resp_ie, params->resp_ie, in cfg80211_connect_done()
860 params->resp_ie_len); in cfg80211_connect_done()
861 next += params->resp_ie_len; in cfg80211_connect_done()
863 if (params->fils.kek_len) { in cfg80211_connect_done()
864 ev->cr.fils.kek = next; in cfg80211_connect_done()
865 ev->cr.fils.kek_len = params->fils.kek_len; in cfg80211_connect_done()
866 memcpy((void *)ev->cr.fils.kek, params->fils.kek, in cfg80211_connect_done()
867 params->fils.kek_len); in cfg80211_connect_done()
868 next += params->fils.kek_len; in cfg80211_connect_done()
870 if (params->fils.pmk_len) { in cfg80211_connect_done()
871 ev->cr.fils.pmk = next; in cfg80211_connect_done()
872 ev->cr.fils.pmk_len = params->fils.pmk_len; in cfg80211_connect_done()
873 memcpy((void *)ev->cr.fils.pmk, params->fils.pmk, in cfg80211_connect_done()
874 params->fils.pmk_len); in cfg80211_connect_done()
875 next += params->fils.pmk_len; in cfg80211_connect_done()
877 if (params->fils.pmkid) { in cfg80211_connect_done()
878 ev->cr.fils.pmkid = next; in cfg80211_connect_done()
879 memcpy((void *)ev->cr.fils.pmkid, params->fils.pmkid, in cfg80211_connect_done()
883 ev->cr.fils.update_erp_next_seq_num = params->fils.update_erp_next_seq_num; in cfg80211_connect_done()
884 if (params->fils.update_erp_next_seq_num) in cfg80211_connect_done()
885 ev->cr.fils.erp_next_seq_num = params->fils.erp_next_seq_num; in cfg80211_connect_done()
886 if (params->bss) in cfg80211_connect_done()
887 cfg80211_hold_bss(bss_from_pub(params->bss)); in cfg80211_connect_done()
888 ev->cr.bss = params->bss; in cfg80211_connect_done()
889 ev->cr.status = params->status; in cfg80211_connect_done()
890 ev->cr.timeout_reason = params->timeout_reason; in cfg80211_connect_done()
892 spin_lock_irqsave(&wdev->event_lock, flags); in cfg80211_connect_done()
893 list_add_tail(&ev->list, &wdev->event_list); in cfg80211_connect_done()
894 spin_unlock_irqrestore(&wdev->event_lock, flags); in cfg80211_connect_done()
895 queue_work(cfg80211_wq, &rdev->event_work); in cfg80211_connect_done()
908 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && in __cfg80211_roamed()
909 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) in __cfg80211_roamed()
912 if (WARN_ON(!wdev->current_bss)) in __cfg80211_roamed()
915 cfg80211_unhold_bss(wdev->current_bss); in __cfg80211_roamed()
916 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); in __cfg80211_roamed()
917 wdev->current_bss = NULL; in __cfg80211_roamed()
919 if (WARN_ON(!info->bss)) in __cfg80211_roamed()
922 cfg80211_hold_bss(bss_from_pub(info->bss)); in __cfg80211_roamed()
923 wdev->current_bss = bss_from_pub(info->bss); in __cfg80211_roamed()
925 wdev->unprot_beacon_reported = 0; in __cfg80211_roamed()
926 nl80211_send_roamed(wiphy_to_rdev(wdev->wiphy), in __cfg80211_roamed()
927 wdev->netdev, info, GFP_KERNEL); in __cfg80211_roamed()
930 if (info->req_ie) { in __cfg80211_roamed()
932 wrqu.data.length = info->req_ie_len; in __cfg80211_roamed()
933 wireless_send_event(wdev->netdev, IWEVASSOCREQIE, in __cfg80211_roamed()
934 &wrqu, info->req_ie); in __cfg80211_roamed()
937 if (info->resp_ie) { in __cfg80211_roamed()
939 wrqu.data.length = info->resp_ie_len; in __cfg80211_roamed()
940 wireless_send_event(wdev->netdev, IWEVASSOCRESPIE, in __cfg80211_roamed()
941 &wrqu, info->resp_ie); in __cfg80211_roamed()
946 memcpy(wrqu.ap_addr.sa_data, info->bss->bssid, ETH_ALEN); in __cfg80211_roamed()
947 memcpy(wdev->wext.prev_bssid, info->bss->bssid, ETH_ALEN); in __cfg80211_roamed()
948 wdev->wext.prev_bssid_valid = true; in __cfg80211_roamed()
949 wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL); in __cfg80211_roamed()
954 cfg80211_put_bss(wdev->wiphy, info->bss); in __cfg80211_roamed()
957 /* Consumes info->bss object one way or another */
961 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_roamed()
962 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_roamed()
967 if (!info->bss) { in cfg80211_roamed()
968 info->bss = cfg80211_get_bss(wdev->wiphy, info->channel, in cfg80211_roamed()
969 info->bssid, wdev->ssid, in cfg80211_roamed()
970 wdev->ssid_len, in cfg80211_roamed()
971 wdev->conn_bss_type, in cfg80211_roamed()
975 if (WARN_ON(!info->bss)) in cfg80211_roamed()
978 ev = kzalloc(sizeof(*ev) + info->req_ie_len + info->resp_ie_len + in cfg80211_roamed()
979 info->fils.kek_len + info->fils.pmk_len + in cfg80211_roamed()
980 (info->fils.pmkid ? WLAN_PMKID_LEN : 0), gfp); in cfg80211_roamed()
982 cfg80211_put_bss(wdev->wiphy, info->bss); in cfg80211_roamed()
986 ev->type = EVENT_ROAMED; in cfg80211_roamed()
988 if (info->req_ie_len) { in cfg80211_roamed()
989 ev->rm.req_ie = next; in cfg80211_roamed()
990 ev->rm.req_ie_len = info->req_ie_len; in cfg80211_roamed()
991 memcpy((void *)ev->rm.req_ie, info->req_ie, info->req_ie_len); in cfg80211_roamed()
992 next += info->req_ie_len; in cfg80211_roamed()
994 if (info->resp_ie_len) { in cfg80211_roamed()
995 ev->rm.resp_ie = next; in cfg80211_roamed()
996 ev->rm.resp_ie_len = info->resp_ie_len; in cfg80211_roamed()
997 memcpy((void *)ev->rm.resp_ie, info->resp_ie, in cfg80211_roamed()
998 info->resp_ie_len); in cfg80211_roamed()
999 next += info->resp_ie_len; in cfg80211_roamed()
1001 if (info->fils.kek_len) { in cfg80211_roamed()
1002 ev->rm.fils.kek = next; in cfg80211_roamed()
1003 ev->rm.fils.kek_len = info->fils.kek_len; in cfg80211_roamed()
1004 memcpy((void *)ev->rm.fils.kek, info->fils.kek, in cfg80211_roamed()
1005 info->fils.kek_len); in cfg80211_roamed()
1006 next += info->fils.kek_len; in cfg80211_roamed()
1008 if (info->fils.pmk_len) { in cfg80211_roamed()
1009 ev->rm.fils.pmk = next; in cfg80211_roamed()
1010 ev->rm.fils.pmk_len = info->fils.pmk_len; in cfg80211_roamed()
1011 memcpy((void *)ev->rm.fils.pmk, info->fils.pmk, in cfg80211_roamed()
1012 info->fils.pmk_len); in cfg80211_roamed()
1013 next += info->fils.pmk_len; in cfg80211_roamed()
1015 if (info->fils.pmkid) { in cfg80211_roamed()
1016 ev->rm.fils.pmkid = next; in cfg80211_roamed()
1017 memcpy((void *)ev->rm.fils.pmkid, info->fils.pmkid, in cfg80211_roamed()
1021 ev->rm.fils.update_erp_next_seq_num = info->fils.update_erp_next_seq_num; in cfg80211_roamed()
1022 if (info->fils.update_erp_next_seq_num) in cfg80211_roamed()
1023 ev->rm.fils.erp_next_seq_num = info->fils.erp_next_seq_num; in cfg80211_roamed()
1024 ev->rm.bss = info->bss; in cfg80211_roamed()
1026 spin_lock_irqsave(&wdev->event_lock, flags); in cfg80211_roamed()
1027 list_add_tail(&ev->list, &wdev->event_list); in cfg80211_roamed()
1028 spin_unlock_irqrestore(&wdev->event_lock, flags); in cfg80211_roamed()
1029 queue_work(cfg80211_wq, &rdev->event_work); in cfg80211_roamed()
1037 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) in __cfg80211_port_authorized()
1040 if (WARN_ON(!wdev->current_bss) || in __cfg80211_port_authorized()
1041 WARN_ON(!ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) in __cfg80211_port_authorized()
1044 nl80211_send_port_authorized(wiphy_to_rdev(wdev->wiphy), wdev->netdev, in __cfg80211_port_authorized()
1051 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_port_authorized()
1052 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_port_authorized()
1063 ev->type = EVENT_PORT_AUTHORIZED; in cfg80211_port_authorized()
1064 memcpy(ev->pa.bssid, bssid, ETH_ALEN); in cfg80211_port_authorized()
1070 spin_lock_irqsave(&wdev->event_lock, flags); in cfg80211_port_authorized()
1071 list_add_tail(&ev->list, &wdev->event_list); in cfg80211_port_authorized()
1072 spin_unlock_irqrestore(&wdev->event_lock, flags); in cfg80211_port_authorized()
1073 queue_work(cfg80211_wq, &rdev->event_work); in cfg80211_port_authorized()
1080 struct wireless_dev *wdev = dev->ieee80211_ptr; in __cfg80211_disconnected()
1081 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in __cfg80211_disconnected()
1089 if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && in __cfg80211_disconnected()
1090 wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) in __cfg80211_disconnected()
1093 if (wdev->current_bss) { in __cfg80211_disconnected()
1094 cfg80211_unhold_bss(wdev->current_bss); in __cfg80211_disconnected()
1095 cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); in __cfg80211_disconnected()
1098 wdev->current_bss = NULL; in __cfg80211_disconnected()
1099 wdev->ssid_len = 0; in __cfg80211_disconnected()
1100 wdev->conn_owner_nlportid = 0; in __cfg80211_disconnected()
1101 kfree_sensitive(wdev->connect_keys); in __cfg80211_disconnected()
1102 wdev->connect_keys = NULL; in __cfg80211_disconnected()
1107 if (rdev->ops->crit_proto_stop && rdev->crit_proto_nlportid) { in __cfg80211_disconnected()
1108 rdev->crit_proto_nlportid = 0; in __cfg80211_disconnected()
1116 if (rdev->ops->del_key) { in __cfg80211_disconnected()
1120 wdev->wiphy, in __cfg80211_disconnected()
1123 wdev->wiphy, in __cfg80211_disconnected()
1136 wdev->wext.connect.ssid_len = 0; in __cfg80211_disconnected()
1146 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_disconnected()
1147 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_disconnected()
1155 ev->type = EVENT_DISCONNECTED; in cfg80211_disconnected()
1156 ev->dc.ie = ((u8 *)ev) + sizeof(*ev); in cfg80211_disconnected()
1157 ev->dc.ie_len = ie_len; in cfg80211_disconnected()
1158 memcpy((void *)ev->dc.ie, ie, ie_len); in cfg80211_disconnected()
1159 ev->dc.reason = reason; in cfg80211_disconnected()
1160 ev->dc.locally_generated = locally_generated; in cfg80211_disconnected()
1162 spin_lock_irqsave(&wdev->event_lock, flags); in cfg80211_disconnected()
1163 list_add_tail(&ev->list, &wdev->event_list); in cfg80211_disconnected()
1164 spin_unlock_irqrestore(&wdev->event_lock, flags); in cfg80211_disconnected()
1165 queue_work(cfg80211_wq, &rdev->event_work); in cfg80211_disconnected()
1178 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_connect()
1186 * same (which is the case for re-association.) in cfg80211_connect()
1188 if (wdev->ssid_len && in cfg80211_connect()
1189 (wdev->ssid_len != connect->ssid_len || in cfg80211_connect()
1190 memcmp(wdev->ssid, connect->ssid, wdev->ssid_len))) in cfg80211_connect()
1191 return -EALREADY; in cfg80211_connect()
1194 * If connected, reject (re-)association unless prev_bssid in cfg80211_connect()
1197 if (wdev->current_bss) { in cfg80211_connect()
1199 return -EALREADY; in cfg80211_connect()
1200 if (!ether_addr_equal(prev_bssid, wdev->current_bss->pub.bssid)) in cfg80211_connect()
1201 return -ENOTCONN; in cfg80211_connect()
1209 if (wdev->connect_keys) in cfg80211_connect()
1210 return -EINPROGRESS; in cfg80211_connect()
1212 cfg80211_oper_and_ht_capa(&connect->ht_capa_mask, in cfg80211_connect()
1213 rdev->wiphy.ht_capa_mod_mask); in cfg80211_connect()
1214 cfg80211_oper_and_vht_capa(&connect->vht_capa_mask, in cfg80211_connect()
1215 rdev->wiphy.vht_capa_mod_mask); in cfg80211_connect()
1217 if (connkeys && connkeys->def >= 0) { in cfg80211_connect()
1221 idx = connkeys->def; in cfg80211_connect()
1222 cipher = connkeys->params[idx].cipher; in cfg80211_connect()
1226 connect->key_idx = idx; in cfg80211_connect()
1227 connect->key = connkeys->params[idx].key; in cfg80211_connect()
1228 connect->key_len = connkeys->params[idx].key_len; in cfg80211_connect()
1234 if (connect->crypto.cipher_group == 0) in cfg80211_connect()
1235 connect->crypto.cipher_group = cipher; in cfg80211_connect()
1237 if (connect->crypto.n_ciphers_pairwise == 0) { in cfg80211_connect()
1238 connect->crypto.n_ciphers_pairwise = 1; in cfg80211_connect()
1239 connect->crypto.ciphers_pairwise[0] = cipher; in cfg80211_connect()
1243 connect->crypto.wep_keys = connkeys->params; in cfg80211_connect()
1244 connect->crypto.wep_tx_key = connkeys->def; in cfg80211_connect()
1247 return -EINVAL; in cfg80211_connect()
1250 wdev->connect_keys = connkeys; in cfg80211_connect()
1251 memcpy(wdev->ssid, connect->ssid, connect->ssid_len); in cfg80211_connect()
1252 wdev->ssid_len = connect->ssid_len; in cfg80211_connect()
1254 wdev->conn_bss_type = connect->pbss ? IEEE80211_BSS_TYPE_PBSS : in cfg80211_connect()
1257 if (!rdev->ops->connect) in cfg80211_connect()
1263 wdev->connect_keys = NULL; in cfg80211_connect()
1268 if (!wdev->current_bss) in cfg80211_connect()
1269 wdev->ssid_len = 0; in cfg80211_connect()
1279 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_disconnect()
1284 kfree_sensitive(wdev->connect_keys); in cfg80211_disconnect()
1285 wdev->connect_keys = NULL; in cfg80211_disconnect()
1287 wdev->conn_owner_nlportid = 0; in cfg80211_disconnect()
1289 if (wdev->conn) in cfg80211_disconnect()
1291 else if (!rdev->ops->disconnect) in cfg80211_disconnect()
1293 else if (wdev->ssid_len) in cfg80211_disconnect()
1301 if (!wdev->current_bss) in cfg80211_disconnect()
1302 wdev->ssid_len = 0; in cfg80211_disconnect()
1315 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_autodisconnect_wk()
1319 if (wdev->conn_owner_nlportid) { in cfg80211_autodisconnect_wk()
1320 switch (wdev->iftype) { in cfg80211_autodisconnect_wk()
1322 __cfg80211_leave_ibss(rdev, wdev->netdev, false); in cfg80211_autodisconnect_wk()
1326 __cfg80211_stop_ap(rdev, wdev->netdev, false); in cfg80211_autodisconnect_wk()
1329 __cfg80211_leave_mesh(rdev, wdev->netdev); in cfg80211_autodisconnect_wk()
1335 * ops->disconnect not implemented. Otherwise we can in cfg80211_autodisconnect_wk()
1338 if (rdev->ops->disconnect || wdev->current_bss) in cfg80211_autodisconnect_wk()
1339 cfg80211_disconnect(rdev, wdev->netdev, in cfg80211_autodisconnect_wk()
1343 cfg80211_mlme_deauth(rdev, wdev->netdev, in cfg80211_autodisconnect_wk()
1344 wdev->disconnect_bssid, in cfg80211_autodisconnect_wk()