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