Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * cfg80211 wext compat for managed mode. |
| 3 | * |
| 4 | * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> |
| 5 | * Copyright (C) 2009 Intel Corporation. All rights reserved. |
| 6 | */ |
| 7 | |
| 8 | #include <linux/etherdevice.h> |
| 9 | #include <linux/if_arp.h> |
| 10 | #include <net/cfg80211.h> |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame^] | 11 | #include "wext-compat.h" |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 12 | #include "nl80211.h" |
| 13 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 14 | int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, |
| 15 | struct wireless_dev *wdev) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 16 | { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 17 | struct cfg80211_cached_keys *ck = NULL; |
| 18 | int err, i; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 19 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 20 | ASSERT_RDEV_LOCK(rdev); |
| 21 | ASSERT_WDEV_LOCK(wdev); |
| 22 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 23 | if (!netif_running(wdev->netdev)) |
| 24 | return 0; |
| 25 | |
| 26 | wdev->wext.connect.ie = wdev->wext.ie; |
| 27 | wdev->wext.connect.ie_len = wdev->wext.ie_len; |
| 28 | wdev->wext.connect.privacy = wdev->wext.default_key != -1; |
| 29 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 30 | if (wdev->wext.keys) { |
| 31 | wdev->wext.keys->def = wdev->wext.default_key; |
| 32 | wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key; |
| 33 | } |
| 34 | |
| 35 | if (!wdev->wext.connect.ssid_len) |
| 36 | return 0; |
| 37 | |
| 38 | if (wdev->wext.keys) { |
| 39 | ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL); |
| 40 | if (!ck) |
| 41 | return -ENOMEM; |
| 42 | for (i = 0; i < 6; i++) |
| 43 | ck->params[i].key = ck->data[i]; |
| 44 | } |
| 45 | err = __cfg80211_connect(rdev, wdev->netdev, |
| 46 | &wdev->wext.connect, ck); |
| 47 | if (err) |
| 48 | kfree(ck); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 49 | |
| 50 | return err; |
| 51 | } |
| 52 | |
| 53 | int cfg80211_mgd_wext_siwfreq(struct net_device *dev, |
| 54 | struct iw_request_info *info, |
| 55 | struct iw_freq *freq, char *extra) |
| 56 | { |
| 57 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 58 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 59 | struct ieee80211_channel *chan; |
| 60 | int err; |
| 61 | |
| 62 | /* call only for station! */ |
| 63 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 64 | return -EINVAL; |
| 65 | |
| 66 | chan = cfg80211_wext_freq(wdev->wiphy, freq); |
| 67 | if (chan && IS_ERR(chan)) |
| 68 | return PTR_ERR(chan); |
| 69 | |
| 70 | if (chan && (chan->flags & IEEE80211_CHAN_DISABLED)) |
| 71 | return -EINVAL; |
| 72 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 73 | cfg80211_lock_rdev(rdev); |
| 74 | wdev_lock(wdev); |
| 75 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 76 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
| 77 | bool event = true; |
Johannes Berg | 25e83c4 | 2009-07-16 11:39:04 +0200 | [diff] [blame] | 78 | |
| 79 | if (wdev->wext.connect.channel == chan) { |
| 80 | err = 0; |
| 81 | goto out; |
| 82 | } |
| 83 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 84 | /* if SSID set, we'll try right again, avoid event */ |
| 85 | if (wdev->wext.connect.ssid_len) |
| 86 | event = false; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 87 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 88 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 89 | event); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 90 | if (err) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 91 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 92 | } |
| 93 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 94 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 95 | wdev->wext.connect.channel = chan; |
| 96 | |
| 97 | /* SSID is not set, we just want to switch channel */ |
| 98 | if (wdev->wext.connect.ssid_len && chan) { |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 99 | err = -EOPNOTSUPP; |
| 100 | if (rdev->ops->set_channel) |
| 101 | err = rdev->ops->set_channel(wdev->wiphy, chan, |
| 102 | NL80211_CHAN_NO_HT); |
| 103 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 104 | } |
| 105 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 106 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 107 | out: |
| 108 | wdev_unlock(wdev); |
| 109 | cfg80211_unlock_rdev(rdev); |
| 110 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 111 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 112 | |
| 113 | int cfg80211_mgd_wext_giwfreq(struct net_device *dev, |
| 114 | struct iw_request_info *info, |
| 115 | struct iw_freq *freq, char *extra) |
| 116 | { |
| 117 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 118 | struct ieee80211_channel *chan = NULL; |
| 119 | |
| 120 | /* call only for station! */ |
| 121 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 122 | return -EINVAL; |
| 123 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 124 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 125 | if (wdev->current_bss) |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 126 | chan = wdev->current_bss->pub.channel; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 127 | else if (wdev->wext.connect.channel) |
| 128 | chan = wdev->wext.connect.channel; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 129 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 130 | |
| 131 | if (chan) { |
| 132 | freq->m = chan->center_freq; |
| 133 | freq->e = 6; |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | /* no channel if not joining */ |
| 138 | return -EINVAL; |
| 139 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 140 | |
| 141 | int cfg80211_mgd_wext_siwessid(struct net_device *dev, |
| 142 | struct iw_request_info *info, |
| 143 | struct iw_point *data, char *ssid) |
| 144 | { |
| 145 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 146 | size_t len = data->length; |
| 147 | int err; |
| 148 | |
| 149 | /* call only for station! */ |
| 150 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 151 | return -EINVAL; |
| 152 | |
| 153 | if (!data->flags) |
| 154 | len = 0; |
| 155 | |
| 156 | /* iwconfig uses nul termination in SSID.. */ |
| 157 | if (len > 0 && ssid[len - 1] == '\0') |
| 158 | len--; |
| 159 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 160 | cfg80211_lock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 161 | wdev_lock(wdev); |
| 162 | |
| 163 | err = 0; |
| 164 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 165 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
| 166 | bool event = true; |
Johannes Berg | 25e83c4 | 2009-07-16 11:39:04 +0200 | [diff] [blame] | 167 | |
| 168 | if (wdev->wext.connect.ssid && len && |
| 169 | len == wdev->wext.connect.ssid_len && |
| 170 | memcmp(wdev->wext.connect.ssid, ssid, len) == 0) |
| 171 | goto out; |
| 172 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 173 | /* if SSID set now, we'll try to connect, avoid event */ |
| 174 | if (len) |
| 175 | event = false; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 176 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 177 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 178 | event); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 179 | if (err) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 180 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | wdev->wext.connect.ssid = wdev->wext.ssid; |
| 184 | memcpy(wdev->wext.ssid, ssid, len); |
| 185 | wdev->wext.connect.ssid_len = len; |
| 186 | |
| 187 | wdev->wext.connect.crypto.control_port = false; |
| 188 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 189 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 190 | out: |
| 191 | wdev_unlock(wdev); |
| 192 | cfg80211_unlock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 193 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 194 | } |
| 195 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 196 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwessid); |
| 197 | |
| 198 | int cfg80211_mgd_wext_giwessid(struct net_device *dev, |
| 199 | struct iw_request_info *info, |
| 200 | struct iw_point *data, char *ssid) |
| 201 | { |
| 202 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 203 | |
| 204 | /* call only for station! */ |
| 205 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 206 | return -EINVAL; |
| 207 | |
| 208 | data->flags = 0; |
| 209 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 210 | wdev_lock(wdev); |
Johannes Berg | 908d436 | 2009-07-10 17:53:34 +0200 | [diff] [blame] | 211 | if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 212 | data->flags = 1; |
| 213 | data->length = wdev->wext.connect.ssid_len; |
| 214 | memcpy(ssid, wdev->wext.connect.ssid, data->length); |
| 215 | } else |
| 216 | data->flags = 0; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 217 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 222 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwessid); |
| 223 | |
| 224 | int cfg80211_mgd_wext_siwap(struct net_device *dev, |
| 225 | struct iw_request_info *info, |
| 226 | struct sockaddr *ap_addr, char *extra) |
| 227 | { |
| 228 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 229 | u8 *bssid = ap_addr->sa_data; |
| 230 | int err; |
| 231 | |
| 232 | /* call only for station! */ |
| 233 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 234 | return -EINVAL; |
| 235 | |
| 236 | if (ap_addr->sa_family != ARPHRD_ETHER) |
| 237 | return -EINVAL; |
| 238 | |
| 239 | /* automatic mode */ |
| 240 | if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) |
| 241 | bssid = NULL; |
| 242 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 243 | cfg80211_lock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 244 | wdev_lock(wdev); |
| 245 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 246 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
Johannes Berg | 25e83c4 | 2009-07-16 11:39:04 +0200 | [diff] [blame] | 247 | err = 0; |
| 248 | /* both automatic */ |
| 249 | if (!bssid && !wdev->wext.connect.bssid) |
| 250 | goto out; |
| 251 | |
| 252 | /* fixed already - and no change */ |
| 253 | if (wdev->wext.connect.bssid && bssid && |
| 254 | compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) |
| 255 | goto out; |
| 256 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 257 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 258 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 259 | false); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 260 | if (err) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 261 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | if (bssid) { |
| 265 | memcpy(wdev->wext.bssid, bssid, ETH_ALEN); |
| 266 | wdev->wext.connect.bssid = wdev->wext.bssid; |
| 267 | } else |
| 268 | wdev->wext.connect.bssid = NULL; |
| 269 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 270 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 271 | out: |
| 272 | wdev_unlock(wdev); |
| 273 | cfg80211_unlock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 274 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 275 | } |
| 276 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 277 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwap); |
| 278 | |
| 279 | int cfg80211_mgd_wext_giwap(struct net_device *dev, |
| 280 | struct iw_request_info *info, |
| 281 | struct sockaddr *ap_addr, char *extra) |
| 282 | { |
| 283 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 284 | |
| 285 | /* call only for station! */ |
| 286 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 287 | return -EINVAL; |
| 288 | |
| 289 | ap_addr->sa_family = ARPHRD_ETHER; |
| 290 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 291 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 292 | if (wdev->current_bss) |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 293 | memcpy(ap_addr->sa_data, wdev->current_bss->pub.bssid, ETH_ALEN); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 294 | else if (wdev->wext.connect.bssid) |
| 295 | memcpy(ap_addr->sa_data, wdev->wext.connect.bssid, ETH_ALEN); |
| 296 | else |
| 297 | memset(ap_addr->sa_data, 0, ETH_ALEN); |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 298 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 303 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwap); |
| 304 | |
| 305 | int cfg80211_wext_siwgenie(struct net_device *dev, |
| 306 | struct iw_request_info *info, |
| 307 | struct iw_point *data, char *extra) |
| 308 | { |
| 309 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 310 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 311 | u8 *ie = extra; |
| 312 | int ie_len = data->length, err; |
| 313 | |
| 314 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 315 | return -EOPNOTSUPP; |
| 316 | |
| 317 | if (!ie_len) |
| 318 | ie = NULL; |
| 319 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 320 | wdev_lock(wdev); |
| 321 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 322 | /* no change */ |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 323 | err = 0; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 324 | if (wdev->wext.ie_len == ie_len && |
| 325 | memcmp(wdev->wext.ie, ie, ie_len) == 0) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 326 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 327 | |
| 328 | if (ie_len) { |
| 329 | ie = kmemdup(extra, ie_len, GFP_KERNEL); |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 330 | if (!ie) { |
| 331 | err = -ENOMEM; |
| 332 | goto out; |
| 333 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 334 | } else |
| 335 | ie = NULL; |
| 336 | |
| 337 | kfree(wdev->wext.ie); |
| 338 | wdev->wext.ie = ie; |
| 339 | wdev->wext.ie_len = ie_len; |
| 340 | |
| 341 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 342 | err = __cfg80211_disconnect(rdev, dev, |
| 343 | WLAN_REASON_DEAUTH_LEAVING, false); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 344 | if (err) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 345 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | /* userspace better not think we'll reconnect */ |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 349 | err = 0; |
| 350 | out: |
| 351 | wdev_unlock(wdev); |
| 352 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 353 | } |
| 354 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwgenie); |
| 355 | |
| 356 | int cfg80211_wext_siwmlme(struct net_device *dev, |
| 357 | struct iw_request_info *info, |
| 358 | struct iw_point *data, char *extra) |
| 359 | { |
| 360 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 361 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 362 | struct cfg80211_registered_device *rdev; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 363 | int err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 364 | |
| 365 | if (!wdev) |
| 366 | return -EOPNOTSUPP; |
| 367 | |
| 368 | rdev = wiphy_to_dev(wdev->wiphy); |
| 369 | |
| 370 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 371 | return -EINVAL; |
| 372 | |
| 373 | if (mlme->addr.sa_family != ARPHRD_ETHER) |
| 374 | return -EINVAL; |
| 375 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 376 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 377 | switch (mlme->cmd) { |
| 378 | case IW_MLME_DEAUTH: |
| 379 | case IW_MLME_DISASSOC: |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 380 | err = __cfg80211_disconnect(rdev, dev, mlme->reason_code, |
| 381 | true); |
| 382 | break; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 383 | default: |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 384 | err = -EOPNOTSUPP; |
| 385 | break; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 386 | } |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 387 | wdev_unlock(wdev); |
| 388 | |
| 389 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 390 | } |
| 391 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme); |