diff options
Diffstat (limited to 'net/wireless/wext-compat.c')
-rw-r--r-- | net/wireless/wext-compat.c | 229 |
1 files changed, 185 insertions, 44 deletions
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); | ||