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 | |
| 75 | if (wdev->wext.connect.channel == chan) { |
| 76 | err = 0; |
| 77 | goto out; |
| 78 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 79 | |
| 80 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
| 81 | bool event = true; |
| 82 | /* if SSID set, we'll try right again, avoid event */ |
| 83 | if (wdev->wext.connect.ssid_len) |
| 84 | event = false; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 85 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 86 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 87 | event); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 88 | if (err) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 89 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 92 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 93 | wdev->wext.connect.channel = chan; |
| 94 | |
| 95 | /* SSID is not set, we just want to switch channel */ |
| 96 | if (wdev->wext.connect.ssid_len && chan) { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 97 | err = -EOPNOTSUPP; |
| 98 | if (rdev->ops->set_channel) |
| 99 | err = rdev->ops->set_channel(wdev->wiphy, chan, |
| 100 | NL80211_CHAN_NO_HT); |
| 101 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 102 | } |
| 103 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 104 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 105 | out: |
| 106 | wdev_unlock(wdev); |
| 107 | cfg80211_unlock_rdev(rdev); |
| 108 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 109 | } |
| 110 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 111 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwfreq); |
| 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 | 667503dd | 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 | 667503dd | 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 | } |
| 140 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 141 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwfreq); |
| 142 | |
| 143 | int cfg80211_mgd_wext_siwessid(struct net_device *dev, |
| 144 | struct iw_request_info *info, |
| 145 | struct iw_point *data, char *ssid) |
| 146 | { |
| 147 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 148 | size_t len = data->length; |
| 149 | int err; |
| 150 | |
| 151 | /* call only for station! */ |
| 152 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 153 | return -EINVAL; |
| 154 | |
| 155 | if (!data->flags) |
| 156 | len = 0; |
| 157 | |
| 158 | /* iwconfig uses nul termination in SSID.. */ |
| 159 | if (len > 0 && ssid[len - 1] == '\0') |
| 160 | len--; |
| 161 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 162 | cfg80211_lock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 163 | wdev_lock(wdev); |
| 164 | |
| 165 | err = 0; |
| 166 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 167 | if (wdev->wext.connect.ssid && len && |
| 168 | len == wdev->wext.connect.ssid_len && |
| 169 | memcmp(wdev->wext.connect.ssid, ssid, len)) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 170 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 171 | |
| 172 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
| 173 | bool event = true; |
| 174 | /* if SSID set now, we'll try to connect, avoid event */ |
| 175 | if (len) |
| 176 | event = false; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 177 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 178 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 179 | event); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 180 | if (err) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 181 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | wdev->wext.connect.ssid = wdev->wext.ssid; |
| 185 | memcpy(wdev->wext.ssid, ssid, len); |
| 186 | wdev->wext.connect.ssid_len = len; |
| 187 | |
| 188 | wdev->wext.connect.crypto.control_port = false; |
| 189 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 190 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 191 | out: |
| 192 | wdev_unlock(wdev); |
| 193 | cfg80211_unlock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 194 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 195 | } |
| 196 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 197 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwessid); |
| 198 | |
| 199 | int cfg80211_mgd_wext_giwessid(struct net_device *dev, |
| 200 | struct iw_request_info *info, |
| 201 | struct iw_point *data, char *ssid) |
| 202 | { |
| 203 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 204 | |
| 205 | /* call only for station! */ |
| 206 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 207 | return -EINVAL; |
| 208 | |
| 209 | data->flags = 0; |
| 210 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 211 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 212 | if (wdev->ssid_len) { |
| 213 | data->flags = 1; |
| 214 | data->length = wdev->ssid_len; |
| 215 | memcpy(ssid, wdev->ssid, data->length); |
| 216 | } else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { |
| 217 | data->flags = 1; |
| 218 | data->length = wdev->wext.connect.ssid_len; |
| 219 | memcpy(ssid, wdev->wext.connect.ssid, data->length); |
| 220 | } else |
| 221 | data->flags = 0; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 222 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 223 | |
| 224 | return 0; |
| 225 | } |
| 226 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 227 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwessid); |
| 228 | |
| 229 | int cfg80211_mgd_wext_siwap(struct net_device *dev, |
| 230 | struct iw_request_info *info, |
| 231 | struct sockaddr *ap_addr, char *extra) |
| 232 | { |
| 233 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 234 | u8 *bssid = ap_addr->sa_data; |
| 235 | int err; |
| 236 | |
| 237 | /* call only for station! */ |
| 238 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 239 | return -EINVAL; |
| 240 | |
| 241 | if (ap_addr->sa_family != ARPHRD_ETHER) |
| 242 | return -EINVAL; |
| 243 | |
| 244 | /* automatic mode */ |
| 245 | if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) |
| 246 | bssid = NULL; |
| 247 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 248 | cfg80211_lock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 249 | wdev_lock(wdev); |
| 250 | |
| 251 | err = 0; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 252 | /* both automatic */ |
| 253 | if (!bssid && !wdev->wext.connect.bssid) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 254 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 255 | |
| 256 | /* fixed already - and no change */ |
| 257 | if (wdev->wext.connect.bssid && bssid && |
| 258 | compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 259 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 260 | |
| 261 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 262 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 263 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 264 | false); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 265 | if (err) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 266 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | if (bssid) { |
| 270 | memcpy(wdev->wext.bssid, bssid, ETH_ALEN); |
| 271 | wdev->wext.connect.bssid = wdev->wext.bssid; |
| 272 | } else |
| 273 | wdev->wext.connect.bssid = NULL; |
| 274 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 275 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 276 | out: |
| 277 | wdev_unlock(wdev); |
| 278 | cfg80211_unlock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 279 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 280 | } |
| 281 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 282 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwap); |
| 283 | |
| 284 | int cfg80211_mgd_wext_giwap(struct net_device *dev, |
| 285 | struct iw_request_info *info, |
| 286 | struct sockaddr *ap_addr, char *extra) |
| 287 | { |
| 288 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 289 | |
| 290 | /* call only for station! */ |
| 291 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 292 | return -EINVAL; |
| 293 | |
| 294 | ap_addr->sa_family = ARPHRD_ETHER; |
| 295 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 296 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 297 | if (wdev->current_bss) |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 298 | memcpy(ap_addr->sa_data, wdev->current_bss->pub.bssid, ETH_ALEN); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 299 | else if (wdev->wext.connect.bssid) |
| 300 | memcpy(ap_addr->sa_data, wdev->wext.connect.bssid, ETH_ALEN); |
| 301 | else |
| 302 | memset(ap_addr->sa_data, 0, ETH_ALEN); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 303 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | /* temporary symbol - mark GPL - in the future the handler won't be */ |
| 308 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwap); |
| 309 | |
| 310 | int cfg80211_wext_siwgenie(struct net_device *dev, |
| 311 | struct iw_request_info *info, |
| 312 | struct iw_point *data, char *extra) |
| 313 | { |
| 314 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 315 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 316 | u8 *ie = extra; |
| 317 | int ie_len = data->length, err; |
| 318 | |
| 319 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 320 | return -EOPNOTSUPP; |
| 321 | |
| 322 | if (!ie_len) |
| 323 | ie = NULL; |
| 324 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 325 | wdev_lock(wdev); |
| 326 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 327 | /* no change */ |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 328 | err = 0; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 329 | if (wdev->wext.ie_len == ie_len && |
| 330 | memcmp(wdev->wext.ie, ie, ie_len) == 0) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 331 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 332 | |
| 333 | if (ie_len) { |
| 334 | ie = kmemdup(extra, ie_len, GFP_KERNEL); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 335 | if (!ie) { |
| 336 | err = -ENOMEM; |
| 337 | goto out; |
| 338 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 339 | } else |
| 340 | ie = NULL; |
| 341 | |
| 342 | kfree(wdev->wext.ie); |
| 343 | wdev->wext.ie = ie; |
| 344 | wdev->wext.ie_len = ie_len; |
| 345 | |
| 346 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 347 | err = __cfg80211_disconnect(rdev, dev, |
| 348 | WLAN_REASON_DEAUTH_LEAVING, false); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 349 | if (err) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 350 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /* userspace better not think we'll reconnect */ |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 354 | err = 0; |
| 355 | out: |
| 356 | wdev_unlock(wdev); |
| 357 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 358 | } |
| 359 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwgenie); |
| 360 | |
| 361 | int cfg80211_wext_siwmlme(struct net_device *dev, |
| 362 | struct iw_request_info *info, |
| 363 | struct iw_point *data, char *extra) |
| 364 | { |
| 365 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 366 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
| 367 | struct cfg80211_registered_device *rdev; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 368 | int err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 369 | |
| 370 | if (!wdev) |
| 371 | return -EOPNOTSUPP; |
| 372 | |
| 373 | rdev = wiphy_to_dev(wdev->wiphy); |
| 374 | |
| 375 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 376 | return -EINVAL; |
| 377 | |
| 378 | if (mlme->addr.sa_family != ARPHRD_ETHER) |
| 379 | return -EINVAL; |
| 380 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 381 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 382 | switch (mlme->cmd) { |
| 383 | case IW_MLME_DEAUTH: |
| 384 | case IW_MLME_DISASSOC: |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 385 | err = __cfg80211_disconnect(rdev, dev, mlme->reason_code, |
| 386 | true); |
| 387 | break; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 388 | default: |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 389 | err = -EOPNOTSUPP; |
| 390 | break; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 391 | } |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 392 | wdev_unlock(wdev); |
| 393 | |
| 394 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 395 | } |
| 396 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme); |