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 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 195 | |
| 196 | int cfg80211_mgd_wext_giwessid(struct net_device *dev, |
| 197 | struct iw_request_info *info, |
| 198 | struct iw_point *data, char *ssid) |
| 199 | { |
| 200 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 201 | |
| 202 | /* call only for station! */ |
| 203 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 204 | return -EINVAL; |
| 205 | |
| 206 | data->flags = 0; |
| 207 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 208 | wdev_lock(wdev); |
Zhu Yi | a42dd7ef | 2009-08-05 15:07:13 +0800 | [diff] [blame^] | 209 | if (wdev->current_bss) { |
| 210 | const u8 *ie = ieee80211_bss_get_ie(&wdev->current_bss->pub, |
| 211 | WLAN_EID_SSID); |
| 212 | if (ie) { |
| 213 | data->flags = 1; |
| 214 | data->length = ie[1]; |
| 215 | memcpy(ssid, ie + 2, data->length); |
| 216 | } |
| 217 | } else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 218 | data->flags = 1; |
| 219 | data->length = wdev->wext.connect.ssid_len; |
| 220 | memcpy(ssid, wdev->wext.connect.ssid, data->length); |
| 221 | } else |
| 222 | data->flags = 0; |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 223 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 224 | |
| 225 | return 0; |
| 226 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 227 | |
| 228 | int cfg80211_mgd_wext_siwap(struct net_device *dev, |
| 229 | struct iw_request_info *info, |
| 230 | struct sockaddr *ap_addr, char *extra) |
| 231 | { |
| 232 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 233 | u8 *bssid = ap_addr->sa_data; |
| 234 | int err; |
| 235 | |
| 236 | /* call only for station! */ |
| 237 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 238 | return -EINVAL; |
| 239 | |
| 240 | if (ap_addr->sa_family != ARPHRD_ETHER) |
| 241 | return -EINVAL; |
| 242 | |
| 243 | /* automatic mode */ |
| 244 | if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) |
| 245 | bssid = NULL; |
| 246 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 247 | cfg80211_lock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 248 | wdev_lock(wdev); |
| 249 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 250 | if (wdev->sme_state != CFG80211_SME_IDLE) { |
Johannes Berg | 25e83c4 | 2009-07-16 11:39:04 +0200 | [diff] [blame] | 251 | err = 0; |
| 252 | /* both automatic */ |
| 253 | if (!bssid && !wdev->wext.connect.bssid) |
| 254 | goto out; |
| 255 | |
| 256 | /* fixed already - and no change */ |
| 257 | if (wdev->wext.connect.bssid && bssid && |
| 258 | compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) |
| 259 | goto out; |
| 260 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 261 | err = __cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), |
| 262 | dev, WLAN_REASON_DEAUTH_LEAVING, |
| 263 | false); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 264 | if (err) |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 265 | goto out; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | if (bssid) { |
| 269 | memcpy(wdev->wext.bssid, bssid, ETH_ALEN); |
| 270 | wdev->wext.connect.bssid = wdev->wext.bssid; |
| 271 | } else |
| 272 | wdev->wext.connect.bssid = NULL; |
| 273 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 274 | err = cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); |
| 275 | out: |
| 276 | wdev_unlock(wdev); |
| 277 | cfg80211_unlock_rdev(wiphy_to_dev(wdev->wiphy)); |
| 278 | return err; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 279 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 280 | |
| 281 | int cfg80211_mgd_wext_giwap(struct net_device *dev, |
| 282 | struct iw_request_info *info, |
| 283 | struct sockaddr *ap_addr, char *extra) |
| 284 | { |
| 285 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 286 | |
| 287 | /* call only for station! */ |
| 288 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) |
| 289 | return -EINVAL; |
| 290 | |
| 291 | ap_addr->sa_family = ARPHRD_ETHER; |
| 292 | |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 293 | wdev_lock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 294 | if (wdev->current_bss) |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 295 | memcpy(ap_addr->sa_data, wdev->current_bss->pub.bssid, ETH_ALEN); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 296 | else if (wdev->wext.connect.bssid) |
| 297 | memcpy(ap_addr->sa_data, wdev->wext.connect.bssid, ETH_ALEN); |
| 298 | else |
| 299 | memset(ap_addr->sa_data, 0, ETH_ALEN); |
Johannes Berg | 667503d | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 300 | wdev_unlock(wdev); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 301 | |
| 302 | return 0; |
| 303 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 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); |