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