aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/mlme.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/wireless/mlme.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'net/wireless/mlme.c')
-rw-r--r--net/wireless/mlme.c279
1 files changed, 214 insertions, 65 deletions
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index d1a3fb99fdf2..493b939970cd 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -149,7 +149,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
149 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; 149 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf;
150 const u8 *bssid = mgmt->bssid; 150 const u8 *bssid = mgmt->bssid;
151 int i; 151 int i;
152 bool found = false; 152 bool found = false, was_current = false;
153 153
154 ASSERT_WDEV_LOCK(wdev); 154 ASSERT_WDEV_LOCK(wdev);
155 155
@@ -159,6 +159,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
159 cfg80211_put_bss(&wdev->current_bss->pub); 159 cfg80211_put_bss(&wdev->current_bss->pub);
160 wdev->current_bss = NULL; 160 wdev->current_bss = NULL;
161 found = true; 161 found = true;
162 was_current = true;
162 } else for (i = 0; i < MAX_AUTH_BSSES; i++) { 163 } else for (i = 0; i < MAX_AUTH_BSSES; i++) {
163 if (wdev->auth_bsses[i] && 164 if (wdev->auth_bsses[i] &&
164 memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { 165 memcmp(wdev->auth_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) {
@@ -183,7 +184,7 @@ void __cfg80211_send_deauth(struct net_device *dev,
183 184
184 nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL); 185 nl80211_send_deauth(rdev, dev, buf, len, GFP_KERNEL);
185 186
186 if (wdev->sme_state == CFG80211_SME_CONNECTED) { 187 if (wdev->sme_state == CFG80211_SME_CONNECTED && was_current) {
187 u16 reason_code; 188 u16 reason_code;
188 bool from_ap; 189 bool from_ap;
189 190
@@ -262,6 +263,28 @@ void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len)
262} 263}
263EXPORT_SYMBOL(cfg80211_send_disassoc); 264EXPORT_SYMBOL(cfg80211_send_disassoc);
264 265
266void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf,
267 size_t len)
268{
269 struct wireless_dev *wdev = dev->ieee80211_ptr;
270 struct wiphy *wiphy = wdev->wiphy;
271 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
272
273 nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC);
274}
275EXPORT_SYMBOL(cfg80211_send_unprot_deauth);
276
277void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf,
278 size_t len)
279{
280 struct wireless_dev *wdev = dev->ieee80211_ptr;
281 struct wiphy *wiphy = wdev->wiphy;
282 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
283
284 nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC);
285}
286EXPORT_SYMBOL(cfg80211_send_unprot_disassoc);
287
265static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr) 288static void __cfg80211_auth_remove(struct wireless_dev *wdev, const u8 *addr)
266{ 289{
267 int i; 290 int i;
@@ -747,31 +770,62 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
747} 770}
748EXPORT_SYMBOL(cfg80211_new_sta); 771EXPORT_SYMBOL(cfg80211_new_sta);
749 772
750struct cfg80211_action_registration { 773void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp)
774{
775 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
776 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
777
778 nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp);
779}
780EXPORT_SYMBOL(cfg80211_del_sta);
781
782struct cfg80211_mgmt_registration {
751 struct list_head list; 783 struct list_head list;
752 784
753 u32 nlpid; 785 u32 nlpid;
754 786
755 int match_len; 787 int match_len;
756 788
789 __le16 frame_type;
790
757 u8 match[]; 791 u8 match[];
758}; 792};
759 793
760int cfg80211_mlme_register_action(struct wireless_dev *wdev, u32 snd_pid, 794int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid,
761 const u8 *match_data, int match_len) 795 u16 frame_type, const u8 *match_data,
796 int match_len)
762{ 797{
763 struct cfg80211_action_registration *reg, *nreg; 798 struct wiphy *wiphy = wdev->wiphy;
799 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
800 struct cfg80211_mgmt_registration *reg, *nreg;
764 int err = 0; 801 int err = 0;
802 u16 mgmt_type;
803
804 if (!wdev->wiphy->mgmt_stypes)
805 return -EOPNOTSUPP;
806
807 if ((frame_type & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT)
808 return -EINVAL;
809
810 if (frame_type & ~(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE))
811 return -EINVAL;
812
813 mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
814 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].rx & BIT(mgmt_type)))
815 return -EINVAL;
765 816
766 nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL); 817 nreg = kzalloc(sizeof(*reg) + match_len, GFP_KERNEL);
767 if (!nreg) 818 if (!nreg)
768 return -ENOMEM; 819 return -ENOMEM;
769 820
770 spin_lock_bh(&wdev->action_registrations_lock); 821 spin_lock_bh(&wdev->mgmt_registrations_lock);
771 822
772 list_for_each_entry(reg, &wdev->action_registrations, list) { 823 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
773 int mlen = min(match_len, reg->match_len); 824 int mlen = min(match_len, reg->match_len);
774 825
826 if (frame_type != le16_to_cpu(reg->frame_type))
827 continue;
828
775 if (memcmp(reg->match, match_data, mlen) == 0) { 829 if (memcmp(reg->match, match_data, mlen) == 0) {
776 err = -EALREADY; 830 err = -EALREADY;
777 break; 831 break;
@@ -786,140 +840,223 @@ int cfg80211_mlme_register_action(struct wireless_dev *wdev, u32 snd_pid,
786 memcpy(nreg->match, match_data, match_len); 840 memcpy(nreg->match, match_data, match_len);
787 nreg->match_len = match_len; 841 nreg->match_len = match_len;
788 nreg->nlpid = snd_pid; 842 nreg->nlpid = snd_pid;
789 list_add(&nreg->list, &wdev->action_registrations); 843 nreg->frame_type = cpu_to_le16(frame_type);
844 list_add(&nreg->list, &wdev->mgmt_registrations);
845
846 if (rdev->ops->mgmt_frame_register)
847 rdev->ops->mgmt_frame_register(wiphy, wdev->netdev,
848 frame_type, true);
790 849
791 out: 850 out:
792 spin_unlock_bh(&wdev->action_registrations_lock); 851 spin_unlock_bh(&wdev->mgmt_registrations_lock);
852
793 return err; 853 return err;
794} 854}
795 855
796void cfg80211_mlme_unregister_actions(struct wireless_dev *wdev, u32 nlpid) 856void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid)
797{ 857{
798 struct cfg80211_action_registration *reg, *tmp; 858 struct wiphy *wiphy = wdev->wiphy;
859 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
860 struct cfg80211_mgmt_registration *reg, *tmp;
799 861
800 spin_lock_bh(&wdev->action_registrations_lock); 862 spin_lock_bh(&wdev->mgmt_registrations_lock);
801 863
802 list_for_each_entry_safe(reg, tmp, &wdev->action_registrations, list) { 864 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
803 if (reg->nlpid == nlpid) { 865 if (reg->nlpid != nlpid)
804 list_del(&reg->list); 866 continue;
805 kfree(reg); 867
868 if (rdev->ops->mgmt_frame_register) {
869 u16 frame_type = le16_to_cpu(reg->frame_type);
870
871 rdev->ops->mgmt_frame_register(wiphy, wdev->netdev,
872 frame_type, false);
806 } 873 }
874
875 list_del(&reg->list);
876 kfree(reg);
807 } 877 }
808 878
809 spin_unlock_bh(&wdev->action_registrations_lock); 879 spin_unlock_bh(&wdev->mgmt_registrations_lock);
810} 880}
811 881
812void cfg80211_mlme_purge_actions(struct wireless_dev *wdev) 882void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev)
813{ 883{
814 struct cfg80211_action_registration *reg, *tmp; 884 struct cfg80211_mgmt_registration *reg, *tmp;
815 885
816 spin_lock_bh(&wdev->action_registrations_lock); 886 spin_lock_bh(&wdev->mgmt_registrations_lock);
817 887
818 list_for_each_entry_safe(reg, tmp, &wdev->action_registrations, list) { 888 list_for_each_entry_safe(reg, tmp, &wdev->mgmt_registrations, list) {
819 list_del(&reg->list); 889 list_del(&reg->list);
820 kfree(reg); 890 kfree(reg);
821 } 891 }
822 892
823 spin_unlock_bh(&wdev->action_registrations_lock); 893 spin_unlock_bh(&wdev->mgmt_registrations_lock);
824} 894}
825 895
826int cfg80211_mlme_action(struct cfg80211_registered_device *rdev, 896int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
827 struct net_device *dev, 897 struct net_device *dev,
828 struct ieee80211_channel *chan, 898 struct ieee80211_channel *chan, bool offchan,
829 enum nl80211_channel_type channel_type, 899 enum nl80211_channel_type channel_type,
830 bool channel_type_valid, 900 bool channel_type_valid, unsigned int wait,
831 const u8 *buf, size_t len, u64 *cookie) 901 const u8 *buf, size_t len, u64 *cookie)
832{ 902{
833 struct wireless_dev *wdev = dev->ieee80211_ptr; 903 struct wireless_dev *wdev = dev->ieee80211_ptr;
834 const struct ieee80211_mgmt *mgmt; 904 const struct ieee80211_mgmt *mgmt;
905 u16 stype;
906
907 if (!wdev->wiphy->mgmt_stypes)
908 return -EOPNOTSUPP;
835 909
836 if (rdev->ops->action == NULL) 910 if (!rdev->ops->mgmt_tx)
837 return -EOPNOTSUPP; 911 return -EOPNOTSUPP;
912
838 if (len < 24 + 1) 913 if (len < 24 + 1)
839 return -EINVAL; 914 return -EINVAL;
840 915
841 mgmt = (const struct ieee80211_mgmt *) buf; 916 mgmt = (const struct ieee80211_mgmt *) buf;
842 if (!ieee80211_is_action(mgmt->frame_control)) 917
918 if (!ieee80211_is_mgmt(mgmt->frame_control))
843 return -EINVAL; 919 return -EINVAL;
844 if (mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) { 920
845 /* Verify that we are associated with the destination AP */ 921 stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
922 if (!(wdev->wiphy->mgmt_stypes[wdev->iftype].tx & BIT(stype >> 4)))
923 return -EINVAL;
924
925 if (ieee80211_is_action(mgmt->frame_control) &&
926 mgmt->u.action.category != WLAN_CATEGORY_PUBLIC) {
927 int err = 0;
928
846 wdev_lock(wdev); 929 wdev_lock(wdev);
847 930
848 if (!wdev->current_bss || 931 switch (wdev->iftype) {
849 memcmp(wdev->current_bss->pub.bssid, mgmt->bssid, 932 case NL80211_IFTYPE_ADHOC:
850 ETH_ALEN) != 0 || 933 case NL80211_IFTYPE_STATION:
851 (wdev->iftype == NL80211_IFTYPE_STATION && 934 case NL80211_IFTYPE_P2P_CLIENT:
852 memcmp(wdev->current_bss->pub.bssid, mgmt->da, 935 if (!wdev->current_bss) {
853 ETH_ALEN) != 0)) { 936 err = -ENOTCONN;
854 wdev_unlock(wdev); 937 break;
855 return -ENOTCONN; 938 }
856 } 939
940 if (memcmp(wdev->current_bss->pub.bssid,
941 mgmt->bssid, ETH_ALEN)) {
942 err = -ENOTCONN;
943 break;
944 }
857 945
946 /*
947 * check for IBSS DA must be done by driver as
948 * cfg80211 doesn't track the stations
949 */
950 if (wdev->iftype == NL80211_IFTYPE_ADHOC)
951 break;
952
953 /* for station, check that DA is the AP */
954 if (memcmp(wdev->current_bss->pub.bssid,
955 mgmt->da, ETH_ALEN)) {
956 err = -ENOTCONN;
957 break;
958 }
959 break;
960 case NL80211_IFTYPE_AP:
961 case NL80211_IFTYPE_P2P_GO:
962 case NL80211_IFTYPE_AP_VLAN:
963 if (memcmp(mgmt->bssid, dev->dev_addr, ETH_ALEN))
964 err = -EINVAL;
965 break;
966 case NL80211_IFTYPE_MESH_POINT:
967 if (memcmp(mgmt->sa, mgmt->bssid, ETH_ALEN)) {
968 err = -EINVAL;
969 break;
970 }
971 /*
972 * check for mesh DA must be done by driver as
973 * cfg80211 doesn't track the stations
974 */
975 break;
976 default:
977 err = -EOPNOTSUPP;
978 break;
979 }
858 wdev_unlock(wdev); 980 wdev_unlock(wdev);
981
982 if (err)
983 return err;
859 } 984 }
860 985
861 if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0) 986 if (memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) != 0)
862 return -EINVAL; 987 return -EINVAL;
863 988
864 /* Transmit the Action frame as requested by user space */ 989 /* Transmit the Action frame as requested by user space */
865 return rdev->ops->action(&rdev->wiphy, dev, chan, channel_type, 990 return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan,
866 channel_type_valid, buf, len, cookie); 991 channel_type, channel_type_valid,
992 wait, buf, len, cookie);
867} 993}
868 994
869bool cfg80211_rx_action(struct net_device *dev, int freq, const u8 *buf, 995bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf,
870 size_t len, gfp_t gfp) 996 size_t len, gfp_t gfp)
871{ 997{
872 struct wireless_dev *wdev = dev->ieee80211_ptr; 998 struct wireless_dev *wdev = dev->ieee80211_ptr;
873 struct wiphy *wiphy = wdev->wiphy; 999 struct wiphy *wiphy = wdev->wiphy;
874 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 1000 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
875 struct cfg80211_action_registration *reg; 1001 struct cfg80211_mgmt_registration *reg;
876 const u8 *action_data; 1002 const struct ieee80211_txrx_stypes *stypes =
877 int action_data_len; 1003 &wiphy->mgmt_stypes[wdev->iftype];
1004 struct ieee80211_mgmt *mgmt = (void *)buf;
1005 const u8 *data;
1006 int data_len;
878 bool result = false; 1007 bool result = false;
1008 __le16 ftype = mgmt->frame_control &
1009 cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE);
1010 u16 stype;
1011
1012 stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4;
879 1013
880 /* frame length - min size excluding category */ 1014 if (!(stypes->rx & BIT(stype)))
881 action_data_len = len - (IEEE80211_MIN_ACTION_SIZE - 1); 1015 return false;
882 1016
883 /* action data starts with category */ 1017 data = buf + ieee80211_hdrlen(mgmt->frame_control);
884 action_data = buf + IEEE80211_MIN_ACTION_SIZE - 1; 1018 data_len = len - ieee80211_hdrlen(mgmt->frame_control);
885 1019
886 spin_lock_bh(&wdev->action_registrations_lock); 1020 spin_lock_bh(&wdev->mgmt_registrations_lock);
887 1021
888 list_for_each_entry(reg, &wdev->action_registrations, list) { 1022 list_for_each_entry(reg, &wdev->mgmt_registrations, list) {
889 if (reg->match_len > action_data_len) 1023 if (reg->frame_type != ftype)
890 continue; 1024 continue;
891 1025
892 if (memcmp(reg->match, action_data, reg->match_len)) 1026 if (reg->match_len > data_len)
1027 continue;
1028
1029 if (memcmp(reg->match, data, reg->match_len))
893 continue; 1030 continue;
894 1031
895 /* found match! */ 1032 /* found match! */
896 1033
897 /* Indicate the received Action frame to user space */ 1034 /* Indicate the received Action frame to user space */
898 if (nl80211_send_action(rdev, dev, reg->nlpid, freq, 1035 if (nl80211_send_mgmt(rdev, dev, reg->nlpid, freq,
899 buf, len, gfp)) 1036 buf, len, gfp))
900 continue; 1037 continue;
901 1038
902 result = true; 1039 result = true;
903 break; 1040 break;
904 } 1041 }
905 1042
906 spin_unlock_bh(&wdev->action_registrations_lock); 1043 spin_unlock_bh(&wdev->mgmt_registrations_lock);
907 1044
908 return result; 1045 return result;
909} 1046}
910EXPORT_SYMBOL(cfg80211_rx_action); 1047EXPORT_SYMBOL(cfg80211_rx_mgmt);
911 1048
912void cfg80211_action_tx_status(struct net_device *dev, u64 cookie, 1049void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie,
913 const u8 *buf, size_t len, bool ack, gfp_t gfp) 1050 const u8 *buf, size_t len, bool ack, gfp_t gfp)
914{ 1051{
915 struct wireless_dev *wdev = dev->ieee80211_ptr; 1052 struct wireless_dev *wdev = dev->ieee80211_ptr;
916 struct wiphy *wiphy = wdev->wiphy; 1053 struct wiphy *wiphy = wdev->wiphy;
917 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 1054 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
918 1055
919 /* Indicate TX status of the Action frame to user space */ 1056 /* Indicate TX status of the Action frame to user space */
920 nl80211_send_action_tx_status(rdev, dev, cookie, buf, len, ack, gfp); 1057 nl80211_send_mgmt_tx_status(rdev, dev, cookie, buf, len, ack, gfp);
921} 1058}
922EXPORT_SYMBOL(cfg80211_action_tx_status); 1059EXPORT_SYMBOL(cfg80211_mgmt_tx_status);
923 1060
924void cfg80211_cqm_rssi_notify(struct net_device *dev, 1061void cfg80211_cqm_rssi_notify(struct net_device *dev,
925 enum nl80211_cqm_rssi_threshold_event rssi_event, 1062 enum nl80211_cqm_rssi_threshold_event rssi_event,
@@ -933,3 +1070,15 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
933 nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); 1070 nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp);
934} 1071}
935EXPORT_SYMBOL(cfg80211_cqm_rssi_notify); 1072EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
1073
1074void cfg80211_cqm_pktloss_notify(struct net_device *dev,
1075 const u8 *peer, u32 num_packets, gfp_t gfp)
1076{
1077 struct wireless_dev *wdev = dev->ieee80211_ptr;
1078 struct wiphy *wiphy = wdev->wiphy;
1079 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1080
1081 /* Indicate roaming trigger event to user space */
1082 nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp);
1083}
1084EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify);