aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/cfg.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni.malinen@atheros.com>2009-03-20 15:21:19 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-27 20:13:05 -0400
commiteec60b037a875513d9715dcdb90b13ed81fc5f26 (patch)
treeb031d92f7613f2c043c151f102307ec3351843c1 /net/mac80211/cfg.c
parent35a8efe1a67ba5d7bb7492f67f52ed2aa4925892 (diff)
nl80211: Check iftype in cfg80211 code
We do not want to require all the drivers using cfg80211 to need to do this. In addition, make the error values consistent by using EOPNOTSUPP instead of semi-random assortment of errno values. Signed-off-by: Jouni Malinen <jouni.malinen@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r--net/mac80211/cfg.c40
1 files changed, 0 insertions, 40 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index b5810b4c79ac..e677b751d468 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -540,9 +540,6 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
540 540
541 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 541 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
542 542
543 if (sdata->vif.type != NL80211_IFTYPE_AP)
544 return -EINVAL;
545
546 old = sdata->u.ap.beacon; 543 old = sdata->u.ap.beacon;
547 544
548 if (old) 545 if (old)
@@ -559,9 +556,6 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
559 556
560 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 557 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
561 558
562 if (sdata->vif.type != NL80211_IFTYPE_AP)
563 return -EINVAL;
564
565 old = sdata->u.ap.beacon; 559 old = sdata->u.ap.beacon;
566 560
567 if (!old) 561 if (!old)
@@ -577,9 +571,6 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
577 571
578 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 572 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
579 573
580 if (sdata->vif.type != NL80211_IFTYPE_AP)
581 return -EINVAL;
582
583 old = sdata->u.ap.beacon; 574 old = sdata->u.ap.beacon;
584 575
585 if (!old) 576 if (!old)
@@ -858,9 +849,6 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
858 849
859 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 850 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
860 851
861 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
862 return -ENOTSUPP;
863
864 rcu_read_lock(); 852 rcu_read_lock();
865 sta = sta_info_get(local, next_hop); 853 sta = sta_info_get(local, next_hop);
866 if (!sta) { 854 if (!sta) {
@@ -908,9 +896,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
908 896
909 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 897 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
910 898
911 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
912 return -ENOTSUPP;
913
914 rcu_read_lock(); 899 rcu_read_lock();
915 900
916 sta = sta_info_get(local, next_hop); 901 sta = sta_info_get(local, next_hop);
@@ -979,9 +964,6 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
979 964
980 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 965 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
981 966
982 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
983 return -ENOTSUPP;
984
985 rcu_read_lock(); 967 rcu_read_lock();
986 mpath = mesh_path_lookup(dst, sdata); 968 mpath = mesh_path_lookup(dst, sdata);
987 if (!mpath) { 969 if (!mpath) {
@@ -1003,9 +985,6 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1003 985
1004 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 986 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1005 987
1006 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1007 return -ENOTSUPP;
1008
1009 rcu_read_lock(); 988 rcu_read_lock();
1010 mpath = mesh_path_lookup_by_idx(idx, sdata); 989 mpath = mesh_path_lookup_by_idx(idx, sdata);
1011 if (!mpath) { 990 if (!mpath) {
@@ -1025,8 +1004,6 @@ static int ieee80211_get_mesh_params(struct wiphy *wiphy,
1025 struct ieee80211_sub_if_data *sdata; 1004 struct ieee80211_sub_if_data *sdata;
1026 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1005 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1027 1006
1028 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1029 return -ENOTSUPP;
1030 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); 1007 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1031 return 0; 1008 return 0;
1032} 1009}
@@ -1044,9 +1021,6 @@ static int ieee80211_set_mesh_params(struct wiphy *wiphy,
1044 struct ieee80211_sub_if_data *sdata; 1021 struct ieee80211_sub_if_data *sdata;
1045 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1022 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1046 1023
1047 if (sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
1048 return -ENOTSUPP;
1049
1050 /* Set the config options which we are interested in setting */ 1024 /* Set the config options which we are interested in setting */
1051 conf = &(sdata->u.mesh.mshcfg); 1025 conf = &(sdata->u.mesh.mshcfg);
1052 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) 1026 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
@@ -1094,9 +1068,6 @@ static int ieee80211_change_bss(struct wiphy *wiphy,
1094 1068
1095 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1069 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1096 1070
1097 if (sdata->vif.type != NL80211_IFTYPE_AP)
1098 return -EINVAL;
1099
1100 if (params->use_cts_prot >= 0) { 1071 if (params->use_cts_prot >= 0) {
1101 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; 1072 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1102 changed |= BSS_CHANGED_ERP_CTS_PROT; 1073 changed |= BSS_CHANGED_ERP_CTS_PROT;
@@ -1209,9 +1180,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1209 1180
1210 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1181 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1211 1182
1212 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1213 return -EOPNOTSUPP;
1214
1215 switch (req->auth_type) { 1183 switch (req->auth_type) {
1216 case NL80211_AUTHTYPE_OPEN_SYSTEM: 1184 case NL80211_AUTHTYPE_OPEN_SYSTEM:
1217 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN; 1185 sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN;
@@ -1268,9 +1236,6 @@ static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1268 1236
1269 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1237 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1270 1238
1271 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1272 return -EOPNOTSUPP;
1273
1274 if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 || 1239 if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 ||
1275 !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED)) 1240 !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED))
1276 return -ENOLINK; /* not authenticated */ 1241 return -ENOLINK; /* not authenticated */
@@ -1305,8 +1270,6 @@ static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1305 struct ieee80211_sub_if_data *sdata; 1270 struct ieee80211_sub_if_data *sdata;
1306 1271
1307 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1272 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1308 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1309 return -EOPNOTSUPP;
1310 1273
1311 /* TODO: req->ie */ 1274 /* TODO: req->ie */
1312 return ieee80211_sta_deauthenticate(sdata, req->reason_code); 1275 return ieee80211_sta_deauthenticate(sdata, req->reason_code);
@@ -1319,9 +1282,6 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1319 1282
1320 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1283 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1321 1284
1322 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1323 return -EOPNOTSUPP;
1324
1325 /* TODO: req->ie */ 1285 /* TODO: req->ie */
1326 return ieee80211_sta_disassociate(sdata, req->reason_code); 1286 return ieee80211_sta_disassociate(sdata, req->reason_code);
1327} 1287}