diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-07-01 15:26:56 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-10 15:01:51 -0400 |
commit | f21293549f60f88c74fcb9944737f11048896dc4 (patch) | |
tree | d4a00663f87816c0c742e74d7b2c9bad31a18816 /net/wireless | |
parent | 6829c878ecd24ff0ae41b4668c7e9d0f11b66942 (diff) |
cfg80211: managed mode wext compatibility
This adds code to make it possible to use the cfg80211
connect() API with wireless extensions, and because the
previous patch added emulation of that API with auth()
and assoc(), by extension also supports wext on that.
At the same time, removes code from mac80211 for wext,
but doesn't yet clean up mac80211's mlme code more.
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/Makefile | 2 | ||||
-rw-r--r-- | net/wireless/core.c | 23 | ||||
-rw-r--r-- | net/wireless/core.h | 3 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 2 | ||||
-rw-r--r-- | net/wireless/sme.c | 55 | ||||
-rw-r--r-- | net/wireless/wext-compat.c | 229 | ||||
-rw-r--r-- | net/wireless/wext-sme.c | 329 |
7 files changed, 570 insertions, 73 deletions
diff --git a/net/wireless/Makefile b/net/wireless/Makefile index 750c08e31b10..d74cc77fa57a 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile | |||
@@ -7,6 +7,6 @@ obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o | |||
7 | 7 | ||
8 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o mlme.o ibss.o sme.o | 8 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o mlme.o ibss.o sme.o |
9 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o | 9 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o |
10 | cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o | 10 | cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o wext-sme.o |
11 | 11 | ||
12 | ccflags-y += -D__CHECK_ENDIAN__ | 12 | ccflags-y += -D__CHECK_ENDIAN__ |
diff --git a/net/wireless/core.c b/net/wireless/core.c index a0a679704612..e2f80dd0e4a6 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -553,6 +553,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
553 | #ifdef CONFIG_WIRELESS_EXT | 553 | #ifdef CONFIG_WIRELESS_EXT |
554 | wdev->wext.default_key = -1; | 554 | wdev->wext.default_key = -1; |
555 | wdev->wext.default_mgmt_key = -1; | 555 | wdev->wext.default_mgmt_key = -1; |
556 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | ||
556 | #endif | 557 | #endif |
557 | mutex_unlock(&rdev->devlist_mtx); | 558 | mutex_unlock(&rdev->devlist_mtx); |
558 | break; | 559 | break; |
@@ -565,8 +566,13 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
565 | cfg80211_leave_ibss(rdev, dev, true); | 566 | cfg80211_leave_ibss(rdev, dev, true); |
566 | break; | 567 | break; |
567 | case NL80211_IFTYPE_STATION: | 568 | case NL80211_IFTYPE_STATION: |
569 | #ifdef CONFIG_WIRELESS_EXT | ||
570 | kfree(wdev->wext.ie); | ||
571 | wdev->wext.ie = NULL; | ||
572 | wdev->wext.ie_len = 0; | ||
573 | #endif | ||
568 | cfg80211_disconnect(rdev, dev, | 574 | cfg80211_disconnect(rdev, dev, |
569 | WLAN_REASON_DEAUTH_LEAVING); | 575 | WLAN_REASON_DEAUTH_LEAVING, true); |
570 | break; | 576 | break; |
571 | default: | 577 | default: |
572 | break; | 578 | break; |
@@ -578,11 +584,20 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
578 | break; | 584 | break; |
579 | case NETDEV_UP: | 585 | case NETDEV_UP: |
580 | #ifdef CONFIG_WIRELESS_EXT | 586 | #ifdef CONFIG_WIRELESS_EXT |
581 | if (wdev->iftype != NL80211_IFTYPE_ADHOC) | 587 | switch (wdev->iftype) { |
588 | case NL80211_IFTYPE_ADHOC: | ||
589 | if (wdev->wext.ibss.ssid_len) | ||
590 | cfg80211_join_ibss(rdev, dev, | ||
591 | &wdev->wext.ibss); | ||
582 | break; | 592 | break; |
583 | if (!wdev->wext.ibss.ssid_len) | 593 | case NL80211_IFTYPE_STATION: |
594 | if (wdev->wext.connect.ssid_len) | ||
595 | cfg80211_connect(rdev, dev, | ||
596 | &wdev->wext.connect); | ||
597 | break; | ||
598 | default: | ||
584 | break; | 599 | break; |
585 | cfg80211_join_ibss(rdev, dev, &wdev->wext.ibss); | 600 | } |
586 | #endif | 601 | #endif |
587 | break; | 602 | break; |
588 | case NETDEV_UNREGISTER: | 603 | case NETDEV_UNREGISTER: |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 2c0f64252f3d..5209acb0ff7e 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -181,7 +181,8 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, | |||
181 | struct net_device *dev, | 181 | struct net_device *dev, |
182 | struct cfg80211_connect_params *connect); | 182 | struct cfg80211_connect_params *connect); |
183 | int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | 183 | int cfg80211_disconnect(struct cfg80211_registered_device *rdev, |
184 | struct net_device *dev, u16 reason); | 184 | struct net_device *dev, u16 reason, |
185 | bool wextev); | ||
185 | 186 | ||
186 | void cfg80211_conn_work(struct work_struct *work); | 187 | void cfg80211_conn_work(struct work_struct *work); |
187 | 188 | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 89aa9e781d10..0008144b354b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -3747,7 +3747,7 @@ static int nl80211_disconnect(struct sk_buff *skb, struct genl_info *info) | |||
3747 | goto out; | 3747 | goto out; |
3748 | } | 3748 | } |
3749 | 3749 | ||
3750 | err = cfg80211_disconnect(drv, dev, reason); | 3750 | err = cfg80211_disconnect(drv, dev, reason, true); |
3751 | 3751 | ||
3752 | out: | 3752 | out: |
3753 | cfg80211_put_dev(drv); | 3753 | cfg80211_put_dev(drv); |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 3abb04729873..f272ebf94303 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -273,10 +273,10 @@ void cfg80211_sme_rx_auth(struct net_device *dev, const u8 *buf, size_t len) | |||
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | 276 | static void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, |
277 | const u8 *req_ie, size_t req_ie_len, | 277 | const u8 *req_ie, size_t req_ie_len, |
278 | const u8 *resp_ie, size_t resp_ie_len, | 278 | const u8 *resp_ie, size_t resp_ie_len, |
279 | u16 status, gfp_t gfp) | 279 | u16 status, bool wextev, gfp_t gfp) |
280 | { | 280 | { |
281 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 281 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
282 | struct cfg80211_bss *bss; | 282 | struct cfg80211_bss *bss; |
@@ -321,25 +321,36 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
321 | status, gfp); | 321 | status, gfp); |
322 | 322 | ||
323 | #ifdef CONFIG_WIRELESS_EXT | 323 | #ifdef CONFIG_WIRELESS_EXT |
324 | if (req_ie && status == WLAN_STATUS_SUCCESS) { | 324 | if (wextev) { |
325 | memset(&wrqu, 0, sizeof(wrqu)); | 325 | if (req_ie && status == WLAN_STATUS_SUCCESS) { |
326 | wrqu.data.length = req_ie_len; | 326 | memset(&wrqu, 0, sizeof(wrqu)); |
327 | wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, req_ie); | 327 | wrqu.data.length = req_ie_len; |
328 | } | 328 | wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, req_ie); |
329 | } | ||
330 | |||
331 | if (resp_ie && status == WLAN_STATUS_SUCCESS) { | ||
332 | memset(&wrqu, 0, sizeof(wrqu)); | ||
333 | wrqu.data.length = resp_ie_len; | ||
334 | wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, resp_ie); | ||
335 | } | ||
329 | 336 | ||
330 | if (resp_ie && status == WLAN_STATUS_SUCCESS) { | ||
331 | memset(&wrqu, 0, sizeof(wrqu)); | 337 | memset(&wrqu, 0, sizeof(wrqu)); |
332 | wrqu.data.length = resp_ie_len; | 338 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
333 | wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, resp_ie); | 339 | if (bssid && status == WLAN_STATUS_SUCCESS) |
340 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); | ||
341 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | ||
334 | } | 342 | } |
335 | |||
336 | memset(&wrqu, 0, sizeof(wrqu)); | ||
337 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | ||
338 | if (bssid && status == WLAN_STATUS_SUCCESS) | ||
339 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); | ||
340 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); | ||
341 | #endif | 343 | #endif |
342 | } | 344 | } |
345 | |||
346 | void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | ||
347 | const u8 *req_ie, size_t req_ie_len, | ||
348 | const u8 *resp_ie, size_t resp_ie_len, | ||
349 | u16 status, gfp_t gfp) | ||
350 | { | ||
351 | bool wextev = status == WLAN_STATUS_SUCCESS; | ||
352 | __cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, resp_ie, resp_ie_len, status, wextev, gfp); | ||
353 | } | ||
343 | EXPORT_SYMBOL(cfg80211_connect_result); | 354 | EXPORT_SYMBOL(cfg80211_connect_result); |
344 | 355 | ||
345 | void cfg80211_roamed(struct net_device *dev, const u8 *bssid, | 356 | void cfg80211_roamed(struct net_device *dev, const u8 *bssid, |
@@ -540,7 +551,7 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev, | |||
540 | } | 551 | } |
541 | 552 | ||
542 | int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | 553 | int cfg80211_disconnect(struct cfg80211_registered_device *rdev, |
543 | struct net_device *dev, u16 reason) | 554 | struct net_device *dev, u16 reason, bool wextev) |
544 | { | 555 | { |
545 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 556 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
546 | int err; | 557 | int err; |
@@ -585,9 +596,9 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
585 | if (wdev->sme_state == CFG80211_SME_CONNECTED) | 596 | if (wdev->sme_state == CFG80211_SME_CONNECTED) |
586 | __cfg80211_disconnected(dev, GFP_KERNEL, NULL, 0, 0, false); | 597 | __cfg80211_disconnected(dev, GFP_KERNEL, NULL, 0, 0, false); |
587 | else if (wdev->sme_state == CFG80211_SME_CONNECTING) | 598 | else if (wdev->sme_state == CFG80211_SME_CONNECTING) |
588 | cfg80211_connect_result(dev, NULL, NULL, 0, NULL, 0, | 599 | __cfg80211_connect_result(dev, NULL, NULL, 0, NULL, 0, |
589 | WLAN_STATUS_UNSPECIFIED_FAILURE, | 600 | WLAN_STATUS_UNSPECIFIED_FAILURE, |
590 | GFP_KERNEL); | 601 | wextev, GFP_KERNEL); |
591 | 602 | ||
592 | return 0; | 603 | return 0; |
593 | } | 604 | } |
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index cae3b52fba7f..02f052fc1808 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -261,50 +261,6 @@ int cfg80211_wext_giwrange(struct net_device *dev, | |||
261 | } | 261 | } |
262 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrange); | 262 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrange); |
263 | 263 | ||
264 | int cfg80211_wext_siwmlme(struct net_device *dev, | ||
265 | struct iw_request_info *info, | ||
266 | struct iw_point *data, char *extra) | ||
267 | { | ||
268 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
269 | struct iw_mlme *mlme = (struct iw_mlme *)extra; | ||
270 | struct cfg80211_registered_device *rdev; | ||
271 | union { | ||
272 | struct cfg80211_disassoc_request disassoc; | ||
273 | struct cfg80211_deauth_request deauth; | ||
274 | } cmd; | ||
275 | |||
276 | if (!wdev) | ||
277 | return -EOPNOTSUPP; | ||
278 | |||
279 | rdev = wiphy_to_dev(wdev->wiphy); | ||
280 | |||
281 | if (wdev->iftype != NL80211_IFTYPE_STATION) | ||
282 | return -EINVAL; | ||
283 | |||
284 | if (mlme->addr.sa_family != ARPHRD_ETHER) | ||
285 | return -EINVAL; | ||
286 | |||
287 | memset(&cmd, 0, sizeof(cmd)); | ||
288 | |||
289 | switch (mlme->cmd) { | ||
290 | case IW_MLME_DEAUTH: | ||
291 | if (!rdev->ops->deauth) | ||
292 | return -EOPNOTSUPP; | ||
293 | cmd.deauth.peer_addr = mlme->addr.sa_data; | ||
294 | cmd.deauth.reason_code = mlme->reason_code; | ||
295 | return rdev->ops->deauth(wdev->wiphy, dev, &cmd.deauth); | ||
296 | case IW_MLME_DISASSOC: | ||
297 | if (!rdev->ops->disassoc) | ||
298 | return -EOPNOTSUPP; | ||
299 | cmd.disassoc.peer_addr = mlme->addr.sa_data; | ||
300 | cmd.disassoc.reason_code = mlme->reason_code; | ||
301 | return rdev->ops->disassoc(wdev->wiphy, dev, &cmd.disassoc); | ||
302 | default: | ||
303 | return -EOPNOTSUPP; | ||
304 | } | ||
305 | } | ||
306 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme); | ||
307 | |||
308 | 264 | ||
309 | /** | 265 | /** |
310 | * cfg80211_wext_freq - get wext frequency for non-"auto" | 266 | * cfg80211_wext_freq - get wext frequency for non-"auto" |
@@ -846,3 +802,188 @@ int cfg80211_wext_giwtxpower(struct net_device *dev, | |||
846 | return 0; | 802 | return 0; |
847 | } | 803 | } |
848 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower); | 804 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower); |
805 | |||
806 | static int cfg80211_set_auth_alg(struct wireless_dev *wdev, | ||
807 | s32 auth_alg) | ||
808 | { | ||
809 | int nr_alg = 0; | ||
810 | |||
811 | if (!auth_alg) | ||
812 | return -EINVAL; | ||
813 | |||
814 | if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM | | ||
815 | IW_AUTH_ALG_SHARED_KEY | | ||
816 | IW_AUTH_ALG_LEAP)) | ||
817 | return -EINVAL; | ||
818 | |||
819 | if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) { | ||
820 | nr_alg++; | ||
821 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; | ||
822 | } | ||
823 | |||
824 | if (auth_alg & IW_AUTH_ALG_SHARED_KEY) { | ||
825 | nr_alg++; | ||
826 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; | ||
827 | } | ||
828 | |||
829 | if (auth_alg & IW_AUTH_ALG_LEAP) { | ||
830 | nr_alg++; | ||
831 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; | ||
832 | } | ||
833 | |||
834 | if (nr_alg > 1) | ||
835 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | ||
836 | |||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions) | ||
841 | { | ||
842 | wdev->wext.connect.crypto.wpa_versions = 0; | ||
843 | |||
844 | if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA | | ||
845 | IW_AUTH_WPA_VERSION_WPA2)) | ||
846 | return -EINVAL; | ||
847 | |||
848 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA) | ||
849 | wdev->wext.connect.crypto.wpa_versions |= | ||
850 | NL80211_WPA_VERSION_1; | ||
851 | |||
852 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2) | ||
853 | wdev->wext.connect.crypto.wpa_versions |= | ||
854 | NL80211_WPA_VERSION_2; | ||
855 | |||
856 | return 0; | ||
857 | } | ||
858 | |||
859 | int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher) | ||
860 | { | ||
861 | wdev->wext.connect.crypto.cipher_group = 0; | ||
862 | |||
863 | if (cipher & IW_AUTH_CIPHER_WEP40) | ||
864 | wdev->wext.connect.crypto.cipher_group = | ||
865 | WLAN_CIPHER_SUITE_WEP40; | ||
866 | else if (cipher & IW_AUTH_CIPHER_WEP104) | ||
867 | wdev->wext.connect.crypto.cipher_group = | ||
868 | WLAN_CIPHER_SUITE_WEP104; | ||
869 | else if (cipher & IW_AUTH_CIPHER_TKIP) | ||
870 | wdev->wext.connect.crypto.cipher_group = | ||
871 | WLAN_CIPHER_SUITE_TKIP; | ||
872 | else if (cipher & IW_AUTH_CIPHER_CCMP) | ||
873 | wdev->wext.connect.crypto.cipher_group = | ||
874 | WLAN_CIPHER_SUITE_CCMP; | ||
875 | else if (cipher & IW_AUTH_CIPHER_AES_CMAC) | ||
876 | wdev->wext.connect.crypto.cipher_group = | ||
877 | WLAN_CIPHER_SUITE_AES_CMAC; | ||
878 | else | ||
879 | return -EINVAL; | ||
880 | |||
881 | return 0; | ||
882 | } | ||
883 | |||
884 | int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher) | ||
885 | { | ||
886 | int nr_ciphers = 0; | ||
887 | u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; | ||
888 | |||
889 | if (cipher & IW_AUTH_CIPHER_WEP40) { | ||
890 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40; | ||
891 | nr_ciphers++; | ||
892 | } | ||
893 | |||
894 | if (cipher & IW_AUTH_CIPHER_WEP104) { | ||
895 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104; | ||
896 | nr_ciphers++; | ||
897 | } | ||
898 | |||
899 | if (cipher & IW_AUTH_CIPHER_TKIP) { | ||
900 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP; | ||
901 | nr_ciphers++; | ||
902 | } | ||
903 | |||
904 | if (cipher & IW_AUTH_CIPHER_CCMP) { | ||
905 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP; | ||
906 | nr_ciphers++; | ||
907 | } | ||
908 | |||
909 | if (cipher & IW_AUTH_CIPHER_AES_CMAC) { | ||
910 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC; | ||
911 | nr_ciphers++; | ||
912 | } | ||
913 | |||
914 | BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5); | ||
915 | |||
916 | wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; | ||
917 | |||
918 | return 0; | ||
919 | } | ||
920 | |||
921 | |||
922 | int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt) | ||
923 | { | ||
924 | int nr_akm_suites = 0; | ||
925 | |||
926 | if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X | | ||
927 | IW_AUTH_KEY_MGMT_PSK)) | ||
928 | return -EINVAL; | ||
929 | |||
930 | if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) { | ||
931 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = | ||
932 | WLAN_AKM_SUITE_8021X; | ||
933 | nr_akm_suites++; | ||
934 | } | ||
935 | |||
936 | if (key_mgt & IW_AUTH_KEY_MGMT_PSK) { | ||
937 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = | ||
938 | WLAN_AKM_SUITE_PSK; | ||
939 | nr_akm_suites++; | ||
940 | } | ||
941 | |||
942 | wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; | ||
943 | |||
944 | return 0; | ||
945 | } | ||
946 | |||
947 | int cfg80211_wext_siwauth(struct net_device *dev, | ||
948 | struct iw_request_info *info, | ||
949 | struct iw_param *data, char *extra) | ||
950 | { | ||
951 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
952 | |||
953 | if (wdev->iftype != NL80211_IFTYPE_STATION) | ||
954 | return -EOPNOTSUPP; | ||
955 | |||
956 | switch (data->flags & IW_AUTH_INDEX) { | ||
957 | case IW_AUTH_PRIVACY_INVOKED: | ||
958 | wdev->wext.connect.privacy = data->value; | ||
959 | return 0; | ||
960 | case IW_AUTH_WPA_VERSION: | ||
961 | return cfg80211_set_wpa_version(wdev, data->value); | ||
962 | case IW_AUTH_CIPHER_GROUP: | ||
963 | return cfg80211_set_cipher_group(wdev, data->value); | ||
964 | case IW_AUTH_KEY_MGMT: | ||
965 | return cfg80211_set_key_mgt(wdev, data->value); | ||
966 | case IW_AUTH_CIPHER_PAIRWISE: | ||
967 | return cfg80211_set_cipher_pairwise(wdev, data->value); | ||
968 | case IW_AUTH_80211_AUTH_ALG: | ||
969 | return cfg80211_set_auth_alg(wdev, data->value); | ||
970 | case IW_AUTH_WPA_ENABLED: | ||
971 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: | ||
972 | case IW_AUTH_DROP_UNENCRYPTED: | ||
973 | case IW_AUTH_MFP: | ||
974 | return 0; | ||
975 | default: | ||
976 | return -EOPNOTSUPP; | ||
977 | } | ||
978 | } | ||
979 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwauth); | ||
980 | |||
981 | int cfg80211_wext_giwauth(struct net_device *dev, | ||
982 | struct iw_request_info *info, | ||
983 | struct iw_param *data, char *extra) | ||
984 | { | ||
985 | /* XXX: what do we need? */ | ||
986 | |||
987 | return -EOPNOTSUPP; | ||
988 | } | ||
989 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth); | ||
diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c new file mode 100644 index 000000000000..3b531d572b69 --- /dev/null +++ b/net/wireless/wext-sme.c | |||
@@ -0,0 +1,329 @@ | |||
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 | |||
13 | static int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, | ||
14 | struct wireless_dev *wdev) | ||
15 | { | ||
16 | int err; | ||
17 | |||
18 | if (!netif_running(wdev->netdev)) | ||
19 | return 0; | ||
20 | |||
21 | wdev->wext.connect.ie = wdev->wext.ie; | ||
22 | wdev->wext.connect.ie_len = wdev->wext.ie_len; | ||
23 | wdev->wext.connect.privacy = wdev->wext.default_key != -1; | ||
24 | |||
25 | err = 0; | ||
26 | if (wdev->wext.connect.ssid_len != 0) | ||
27 | err = cfg80211_connect(rdev, wdev->netdev, | ||
28 | &wdev->wext.connect); | ||
29 | |||
30 | return err; | ||
31 | } | ||
32 | |||
33 | int cfg80211_mgd_wext_siwfreq(struct net_device *dev, | ||
34 | struct iw_request_info *info, | ||
35 | struct iw_freq *freq, char *extra) | ||
36 | { | ||
37 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
38 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
39 | struct ieee80211_channel *chan; | ||
40 | int err; | ||
41 | |||
42 | /* call only for station! */ | ||
43 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
44 | return -EINVAL; | ||
45 | |||
46 | chan = cfg80211_wext_freq(wdev->wiphy, freq); | ||
47 | if (chan && IS_ERR(chan)) | ||
48 | return PTR_ERR(chan); | ||
49 | |||
50 | if (chan && (chan->flags & IEEE80211_CHAN_DISABLED)) | ||
51 | return -EINVAL; | ||
52 | |||
53 | if (wdev->wext.connect.channel == chan) | ||
54 | return 0; | ||
55 | |||
56 | if (wdev->sme_state != CFG80211_SME_IDLE) { | ||
57 | bool event = true; | ||
58 | /* if SSID set, we'll try right again, avoid event */ | ||
59 | if (wdev->wext.connect.ssid_len) | ||
60 | event = false; | ||
61 | err = cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), | ||
62 | dev, WLAN_REASON_DEAUTH_LEAVING, | ||
63 | event); | ||
64 | if (err) | ||
65 | return err; | ||
66 | } | ||
67 | |||
68 | wdev->wext.connect.channel = chan; | ||
69 | |||
70 | /* SSID is not set, we just want to switch channel */ | ||
71 | if (wdev->wext.connect.ssid_len && chan) { | ||
72 | if (!rdev->ops->set_channel) | ||
73 | return -EOPNOTSUPP; | ||
74 | |||
75 | return rdev->ops->set_channel(wdev->wiphy, chan, | ||
76 | NL80211_CHAN_NO_HT); | ||
77 | } | ||
78 | |||
79 | return cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); | ||
80 | } | ||
81 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
82 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwfreq); | ||
83 | |||
84 | int cfg80211_mgd_wext_giwfreq(struct net_device *dev, | ||
85 | struct iw_request_info *info, | ||
86 | struct iw_freq *freq, char *extra) | ||
87 | { | ||
88 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
89 | struct ieee80211_channel *chan = NULL; | ||
90 | |||
91 | /* call only for station! */ | ||
92 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
93 | return -EINVAL; | ||
94 | |||
95 | if (wdev->current_bss) | ||
96 | chan = wdev->current_bss->channel; | ||
97 | else if (wdev->wext.connect.channel) | ||
98 | chan = wdev->wext.connect.channel; | ||
99 | |||
100 | if (chan) { | ||
101 | freq->m = chan->center_freq; | ||
102 | freq->e = 6; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | /* no channel if not joining */ | ||
107 | return -EINVAL; | ||
108 | } | ||
109 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
110 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwfreq); | ||
111 | |||
112 | int cfg80211_mgd_wext_siwessid(struct net_device *dev, | ||
113 | struct iw_request_info *info, | ||
114 | struct iw_point *data, char *ssid) | ||
115 | { | ||
116 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
117 | size_t len = data->length; | ||
118 | int err; | ||
119 | |||
120 | /* call only for station! */ | ||
121 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
122 | return -EINVAL; | ||
123 | |||
124 | if (!data->flags) | ||
125 | len = 0; | ||
126 | |||
127 | /* iwconfig uses nul termination in SSID.. */ | ||
128 | if (len > 0 && ssid[len - 1] == '\0') | ||
129 | len--; | ||
130 | |||
131 | if (wdev->wext.connect.ssid && len && | ||
132 | len == wdev->wext.connect.ssid_len && | ||
133 | memcmp(wdev->wext.connect.ssid, ssid, len)) | ||
134 | return 0; | ||
135 | |||
136 | if (wdev->sme_state != CFG80211_SME_IDLE) { | ||
137 | bool event = true; | ||
138 | /* if SSID set now, we'll try to connect, avoid event */ | ||
139 | if (len) | ||
140 | event = false; | ||
141 | err = cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), | ||
142 | dev, WLAN_REASON_DEAUTH_LEAVING, | ||
143 | event); | ||
144 | if (err) | ||
145 | return err; | ||
146 | } | ||
147 | |||
148 | wdev->wext.connect.ssid = wdev->wext.ssid; | ||
149 | memcpy(wdev->wext.ssid, ssid, len); | ||
150 | wdev->wext.connect.ssid_len = len; | ||
151 | |||
152 | wdev->wext.connect.crypto.control_port = false; | ||
153 | |||
154 | return cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); | ||
155 | } | ||
156 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
157 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwessid); | ||
158 | |||
159 | int cfg80211_mgd_wext_giwessid(struct net_device *dev, | ||
160 | struct iw_request_info *info, | ||
161 | struct iw_point *data, char *ssid) | ||
162 | { | ||
163 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
164 | |||
165 | /* call only for station! */ | ||
166 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
167 | return -EINVAL; | ||
168 | |||
169 | data->flags = 0; | ||
170 | |||
171 | if (wdev->ssid_len) { | ||
172 | data->flags = 1; | ||
173 | data->length = wdev->ssid_len; | ||
174 | memcpy(ssid, wdev->ssid, data->length); | ||
175 | } else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) { | ||
176 | data->flags = 1; | ||
177 | data->length = wdev->wext.connect.ssid_len; | ||
178 | memcpy(ssid, wdev->wext.connect.ssid, data->length); | ||
179 | } else | ||
180 | data->flags = 0; | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
185 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwessid); | ||
186 | |||
187 | int cfg80211_mgd_wext_siwap(struct net_device *dev, | ||
188 | struct iw_request_info *info, | ||
189 | struct sockaddr *ap_addr, char *extra) | ||
190 | { | ||
191 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
192 | u8 *bssid = ap_addr->sa_data; | ||
193 | int err; | ||
194 | |||
195 | /* call only for station! */ | ||
196 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
197 | return -EINVAL; | ||
198 | |||
199 | if (ap_addr->sa_family != ARPHRD_ETHER) | ||
200 | return -EINVAL; | ||
201 | |||
202 | /* automatic mode */ | ||
203 | if (is_zero_ether_addr(bssid) || is_broadcast_ether_addr(bssid)) | ||
204 | bssid = NULL; | ||
205 | |||
206 | /* both automatic */ | ||
207 | if (!bssid && !wdev->wext.connect.bssid) | ||
208 | return 0; | ||
209 | |||
210 | /* fixed already - and no change */ | ||
211 | if (wdev->wext.connect.bssid && bssid && | ||
212 | compare_ether_addr(bssid, wdev->wext.connect.bssid) == 0) | ||
213 | return 0; | ||
214 | |||
215 | if (wdev->sme_state != CFG80211_SME_IDLE) { | ||
216 | err = cfg80211_disconnect(wiphy_to_dev(wdev->wiphy), | ||
217 | dev, WLAN_REASON_DEAUTH_LEAVING, | ||
218 | false); | ||
219 | if (err) | ||
220 | return err; | ||
221 | } | ||
222 | |||
223 | if (bssid) { | ||
224 | memcpy(wdev->wext.bssid, bssid, ETH_ALEN); | ||
225 | wdev->wext.connect.bssid = wdev->wext.bssid; | ||
226 | } else | ||
227 | wdev->wext.connect.bssid = NULL; | ||
228 | |||
229 | return cfg80211_mgd_wext_connect(wiphy_to_dev(wdev->wiphy), wdev); | ||
230 | } | ||
231 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
232 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_siwap); | ||
233 | |||
234 | int cfg80211_mgd_wext_giwap(struct net_device *dev, | ||
235 | struct iw_request_info *info, | ||
236 | struct sockaddr *ap_addr, char *extra) | ||
237 | { | ||
238 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
239 | |||
240 | /* call only for station! */ | ||
241 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION)) | ||
242 | return -EINVAL; | ||
243 | |||
244 | ap_addr->sa_family = ARPHRD_ETHER; | ||
245 | |||
246 | if (wdev->current_bss) | ||
247 | memcpy(ap_addr->sa_data, wdev->current_bss->bssid, ETH_ALEN); | ||
248 | else if (wdev->wext.connect.bssid) | ||
249 | memcpy(ap_addr->sa_data, wdev->wext.connect.bssid, ETH_ALEN); | ||
250 | else | ||
251 | memset(ap_addr->sa_data, 0, ETH_ALEN); | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | /* temporary symbol - mark GPL - in the future the handler won't be */ | ||
256 | EXPORT_SYMBOL_GPL(cfg80211_mgd_wext_giwap); | ||
257 | |||
258 | int cfg80211_wext_siwgenie(struct net_device *dev, | ||
259 | struct iw_request_info *info, | ||
260 | struct iw_point *data, char *extra) | ||
261 | { | ||
262 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
263 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
264 | u8 *ie = extra; | ||
265 | int ie_len = data->length, err; | ||
266 | |||
267 | if (wdev->iftype != NL80211_IFTYPE_STATION) | ||
268 | return -EOPNOTSUPP; | ||
269 | |||
270 | if (!ie_len) | ||
271 | ie = NULL; | ||
272 | |||
273 | /* no change */ | ||
274 | if (wdev->wext.ie_len == ie_len && | ||
275 | memcmp(wdev->wext.ie, ie, ie_len) == 0) | ||
276 | return 0; | ||
277 | |||
278 | if (ie_len) { | ||
279 | ie = kmemdup(extra, ie_len, GFP_KERNEL); | ||
280 | if (!ie) | ||
281 | return -ENOMEM; | ||
282 | } else | ||
283 | ie = NULL; | ||
284 | |||
285 | kfree(wdev->wext.ie); | ||
286 | wdev->wext.ie = ie; | ||
287 | wdev->wext.ie_len = ie_len; | ||
288 | |||
289 | if (wdev->sme_state != CFG80211_SME_IDLE) { | ||
290 | err = cfg80211_disconnect(rdev, dev, | ||
291 | WLAN_REASON_DEAUTH_LEAVING, false); | ||
292 | if (err) | ||
293 | return err; | ||
294 | } | ||
295 | |||
296 | /* userspace better not think we'll reconnect */ | ||
297 | return 0; | ||
298 | } | ||
299 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwgenie); | ||
300 | |||
301 | int cfg80211_wext_siwmlme(struct net_device *dev, | ||
302 | struct iw_request_info *info, | ||
303 | struct iw_point *data, char *extra) | ||
304 | { | ||
305 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
306 | struct iw_mlme *mlme = (struct iw_mlme *)extra; | ||
307 | struct cfg80211_registered_device *rdev; | ||
308 | |||
309 | if (!wdev) | ||
310 | return -EOPNOTSUPP; | ||
311 | |||
312 | rdev = wiphy_to_dev(wdev->wiphy); | ||
313 | |||
314 | if (wdev->iftype != NL80211_IFTYPE_STATION) | ||
315 | return -EINVAL; | ||
316 | |||
317 | if (mlme->addr.sa_family != ARPHRD_ETHER) | ||
318 | return -EINVAL; | ||
319 | |||
320 | switch (mlme->cmd) { | ||
321 | case IW_MLME_DEAUTH: | ||
322 | case IW_MLME_DISASSOC: | ||
323 | return cfg80211_disconnect(rdev, dev, mlme->reason_code, | ||
324 | true); | ||
325 | default: | ||
326 | return -EOPNOTSUPP; | ||
327 | } | ||
328 | } | ||
329 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmlme); | ||