Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * mac80211 configuration hooks for cfg80211 |
| 3 | * |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 4 | * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 5 | * |
| 6 | * This file is GPLv2 as found in COPYING. |
| 7 | */ |
| 8 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 9 | #include <linux/ieee80211.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 10 | #include <linux/nl80211.h> |
| 11 | #include <linux/rtnetlink.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 12 | #include <net/net_namespace.h> |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 13 | #include <linux/rcupdate.h> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 14 | #include <net/cfg80211.h> |
| 15 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 16 | #include "driver-ops.h" |
Michael Wu | e0eb685 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 17 | #include "cfg.h" |
Johannes Berg | 2c8dccc | 2008-04-08 15:14:40 -0400 | [diff] [blame] | 18 | #include "rate.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 19 | #include "mesh.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 20 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 21 | static bool nl80211_type_check(enum nl80211_iftype type) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 22 | { |
| 23 | switch (type) { |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 24 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 25 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 26 | case NL80211_IFTYPE_MONITOR: |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 27 | #ifdef CONFIG_MAC80211_MESH |
| 28 | case NL80211_IFTYPE_MESH_POINT: |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 29 | #endif |
Jouni Malinen | fbf1892 | 2008-10-30 19:50:30 +0200 | [diff] [blame] | 30 | case NL80211_IFTYPE_AP: |
| 31 | case NL80211_IFTYPE_AP_VLAN: |
Johannes Berg | b454048 | 2008-04-14 15:37:03 +0200 | [diff] [blame] | 32 | case NL80211_IFTYPE_WDS: |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 33 | return true; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 34 | default: |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 35 | return false; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 36 | } |
| 37 | } |
| 38 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 39 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 40 | enum nl80211_iftype type, u32 *flags, |
| 41 | struct vif_params *params) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 42 | { |
| 43 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 44 | struct net_device *dev; |
| 45 | struct ieee80211_sub_if_data *sdata; |
| 46 | int err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 47 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 48 | if (!nl80211_type_check(type)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 49 | return -EINVAL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 50 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 51 | err = ieee80211_if_add(local, name, &dev, type, params); |
| 52 | if (err || type != NL80211_IFTYPE_MONITOR || !flags) |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 53 | return err; |
| 54 | |
| 55 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 56 | sdata->u.mntr_flags = *flags; |
| 57 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) |
| 61 | { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 62 | struct net_device *dev; |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 63 | struct ieee80211_sub_if_data *sdata; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 64 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 65 | /* we're under RTNL */ |
| 66 | dev = __dev_get_by_index(&init_net, ifindex); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 67 | if (!dev) |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 68 | return -ENODEV; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 69 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 70 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 71 | |
| 72 | ieee80211_if_remove(sdata); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 73 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 74 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 77 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 78 | enum nl80211_iftype type, u32 *flags, |
| 79 | struct vif_params *params) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 80 | { |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 81 | struct net_device *dev; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 82 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 83 | int ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 84 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 85 | /* we're under RTNL */ |
| 86 | dev = __dev_get_by_index(&init_net, ifindex); |
| 87 | if (!dev) |
| 88 | return -ENODEV; |
| 89 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 90 | if (!nl80211_type_check(type)) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 91 | return -EINVAL; |
| 92 | |
| 93 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 94 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 95 | ret = ieee80211_if_change_type(sdata, type); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 96 | if (ret) |
| 97 | return ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 98 | |
Johannes Berg | f8b25cd | 2008-09-16 20:22:21 +0200 | [diff] [blame] | 99 | if (netif_running(sdata->dev)) |
| 100 | return -EBUSY; |
| 101 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 102 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 103 | ieee80211_sdata_set_mesh_id(sdata, |
| 104 | params->mesh_id_len, |
| 105 | params->mesh_id); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 106 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 107 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR || !flags) |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 108 | return 0; |
| 109 | |
| 110 | sdata->u.mntr_flags = *flags; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 111 | return 0; |
| 112 | } |
| 113 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 114 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 115 | u8 key_idx, const u8 *mac_addr, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 116 | struct key_params *params) |
| 117 | { |
| 118 | struct ieee80211_sub_if_data *sdata; |
| 119 | struct sta_info *sta = NULL; |
| 120 | enum ieee80211_key_alg alg; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 121 | struct ieee80211_key *key; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 122 | int err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 123 | |
| 124 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 125 | |
| 126 | switch (params->cipher) { |
| 127 | case WLAN_CIPHER_SUITE_WEP40: |
| 128 | case WLAN_CIPHER_SUITE_WEP104: |
| 129 | alg = ALG_WEP; |
| 130 | break; |
| 131 | case WLAN_CIPHER_SUITE_TKIP: |
| 132 | alg = ALG_TKIP; |
| 133 | break; |
| 134 | case WLAN_CIPHER_SUITE_CCMP: |
| 135 | alg = ALG_CCMP; |
| 136 | break; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 137 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 138 | alg = ALG_AES_CMAC; |
| 139 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 140 | default: |
| 141 | return -EINVAL; |
| 142 | } |
| 143 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 144 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key); |
| 145 | if (!key) |
| 146 | return -ENOMEM; |
| 147 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 148 | rcu_read_lock(); |
| 149 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 150 | if (mac_addr) { |
| 151 | sta = sta_info_get(sdata->local, mac_addr); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 152 | if (!sta) { |
| 153 | ieee80211_key_free(key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 154 | err = -ENOENT; |
| 155 | goto out_unlock; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 156 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 157 | } |
| 158 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 159 | ieee80211_key_link(key, sdata, sta); |
| 160 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 161 | err = 0; |
| 162 | out_unlock: |
| 163 | rcu_read_unlock(); |
| 164 | |
| 165 | return err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 169 | u8 key_idx, const u8 *mac_addr) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 170 | { |
| 171 | struct ieee80211_sub_if_data *sdata; |
| 172 | struct sta_info *sta; |
| 173 | int ret; |
| 174 | |
| 175 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 176 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 177 | rcu_read_lock(); |
| 178 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 179 | if (mac_addr) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 180 | ret = -ENOENT; |
| 181 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 182 | sta = sta_info_get(sdata->local, mac_addr); |
| 183 | if (!sta) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 184 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 185 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 186 | if (sta->key) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 187 | ieee80211_key_free(sta->key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 188 | WARN_ON(sta->key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 189 | ret = 0; |
| 190 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 191 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 192 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 193 | } |
| 194 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 195 | if (!sdata->keys[key_idx]) { |
| 196 | ret = -ENOENT; |
| 197 | goto out_unlock; |
| 198 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 199 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 200 | ieee80211_key_free(sdata->keys[key_idx]); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 201 | WARN_ON(sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 202 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 203 | ret = 0; |
| 204 | out_unlock: |
| 205 | rcu_read_unlock(); |
| 206 | |
| 207 | return ret; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 208 | } |
| 209 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 210 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 211 | u8 key_idx, const u8 *mac_addr, void *cookie, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 212 | void (*callback)(void *cookie, |
| 213 | struct key_params *params)) |
| 214 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 215 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 216 | struct sta_info *sta = NULL; |
| 217 | u8 seq[6] = {0}; |
| 218 | struct key_params params; |
| 219 | struct ieee80211_key *key; |
| 220 | u32 iv32; |
| 221 | u16 iv16; |
| 222 | int err = -ENOENT; |
| 223 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 224 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 225 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 226 | rcu_read_lock(); |
| 227 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 228 | if (mac_addr) { |
| 229 | sta = sta_info_get(sdata->local, mac_addr); |
| 230 | if (!sta) |
| 231 | goto out; |
| 232 | |
| 233 | key = sta->key; |
| 234 | } else |
| 235 | key = sdata->keys[key_idx]; |
| 236 | |
| 237 | if (!key) |
| 238 | goto out; |
| 239 | |
| 240 | memset(¶ms, 0, sizeof(params)); |
| 241 | |
| 242 | switch (key->conf.alg) { |
| 243 | case ALG_TKIP: |
| 244 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 245 | |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 246 | iv32 = key->u.tkip.tx.iv32; |
| 247 | iv16 = key->u.tkip.tx.iv16; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 248 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 249 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) |
| 250 | drv_get_tkip_seq(sdata->local, |
| 251 | key->conf.hw_key_idx, |
| 252 | &iv32, &iv16); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 253 | |
| 254 | seq[0] = iv16 & 0xff; |
| 255 | seq[1] = (iv16 >> 8) & 0xff; |
| 256 | seq[2] = iv32 & 0xff; |
| 257 | seq[3] = (iv32 >> 8) & 0xff; |
| 258 | seq[4] = (iv32 >> 16) & 0xff; |
| 259 | seq[5] = (iv32 >> 24) & 0xff; |
| 260 | params.seq = seq; |
| 261 | params.seq_len = 6; |
| 262 | break; |
| 263 | case ALG_CCMP: |
| 264 | params.cipher = WLAN_CIPHER_SUITE_CCMP; |
| 265 | seq[0] = key->u.ccmp.tx_pn[5]; |
| 266 | seq[1] = key->u.ccmp.tx_pn[4]; |
| 267 | seq[2] = key->u.ccmp.tx_pn[3]; |
| 268 | seq[3] = key->u.ccmp.tx_pn[2]; |
| 269 | seq[4] = key->u.ccmp.tx_pn[1]; |
| 270 | seq[5] = key->u.ccmp.tx_pn[0]; |
| 271 | params.seq = seq; |
| 272 | params.seq_len = 6; |
| 273 | break; |
| 274 | case ALG_WEP: |
| 275 | if (key->conf.keylen == 5) |
| 276 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 277 | else |
| 278 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 279 | break; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 280 | case ALG_AES_CMAC: |
| 281 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 282 | seq[0] = key->u.aes_cmac.tx_pn[5]; |
| 283 | seq[1] = key->u.aes_cmac.tx_pn[4]; |
| 284 | seq[2] = key->u.aes_cmac.tx_pn[3]; |
| 285 | seq[3] = key->u.aes_cmac.tx_pn[2]; |
| 286 | seq[4] = key->u.aes_cmac.tx_pn[1]; |
| 287 | seq[5] = key->u.aes_cmac.tx_pn[0]; |
| 288 | params.seq = seq; |
| 289 | params.seq_len = 6; |
| 290 | break; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | params.key = key->conf.key; |
| 294 | params.key_len = key->conf.keylen; |
| 295 | |
| 296 | callback(cookie, ¶ms); |
| 297 | err = 0; |
| 298 | |
| 299 | out: |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 300 | rcu_read_unlock(); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 301 | return err; |
| 302 | } |
| 303 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 304 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 305 | struct net_device *dev, |
| 306 | u8 key_idx) |
| 307 | { |
| 308 | struct ieee80211_sub_if_data *sdata; |
| 309 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 310 | rcu_read_lock(); |
| 311 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 312 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 313 | ieee80211_set_default_key(sdata, key_idx); |
| 314 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 315 | rcu_read_unlock(); |
| 316 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 317 | return 0; |
| 318 | } |
| 319 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 320 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 321 | struct net_device *dev, |
| 322 | u8 key_idx) |
| 323 | { |
| 324 | struct ieee80211_sub_if_data *sdata; |
| 325 | |
| 326 | rcu_read_lock(); |
| 327 | |
| 328 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 329 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
| 330 | |
| 331 | rcu_read_unlock(); |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 336 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 337 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 338 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 339 | |
| 340 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
| 341 | STATION_INFO_RX_BYTES | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 342 | STATION_INFO_TX_BYTES | |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 343 | STATION_INFO_RX_PACKETS | |
| 344 | STATION_INFO_TX_PACKETS | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 345 | STATION_INFO_TX_BITRATE; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 346 | |
| 347 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
| 348 | sinfo->rx_bytes = sta->rx_bytes; |
| 349 | sinfo->tx_bytes = sta->tx_bytes; |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 350 | sinfo->rx_packets = sta->rx_packets; |
| 351 | sinfo->tx_packets = sta->tx_packets; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 352 | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 353 | if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { |
| 354 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 355 | sinfo->signal = (s8)sta->last_signal; |
| 356 | } |
| 357 | |
| 358 | sinfo->txrate.flags = 0; |
| 359 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) |
| 360 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 361 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 362 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 363 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) |
| 364 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 365 | |
| 366 | if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) { |
| 367 | struct ieee80211_supported_band *sband; |
| 368 | sband = sta->local->hw.wiphy->bands[ |
| 369 | sta->local->hw.conf.channel->band]; |
| 370 | sinfo->txrate.legacy = |
| 371 | sband->bitrates[sta->last_tx_rate.idx].bitrate; |
| 372 | } else |
| 373 | sinfo->txrate.mcs = sta->last_tx_rate.idx; |
| 374 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 375 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 376 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 377 | sinfo->filled |= STATION_INFO_LLID | |
| 378 | STATION_INFO_PLID | |
| 379 | STATION_INFO_PLINK_STATE; |
| 380 | |
| 381 | sinfo->llid = le16_to_cpu(sta->llid); |
| 382 | sinfo->plid = le16_to_cpu(sta->plid); |
| 383 | sinfo->plink_state = sta->plink_state; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 384 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 385 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | |
| 389 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 390 | int idx, u8 *mac, struct station_info *sinfo) |
| 391 | { |
| 392 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 393 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 394 | int ret = -ENOENT; |
| 395 | |
| 396 | rcu_read_lock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 397 | |
| 398 | sta = sta_info_get_by_idx(local, idx, dev); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 399 | if (sta) { |
| 400 | ret = 0; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 401 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 402 | sta_set_sinfo(sta, sinfo); |
| 403 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 404 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 405 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 406 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 407 | return ret; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 408 | } |
| 409 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 410 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 411 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 412 | { |
| 413 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 414 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 415 | int ret = -ENOENT; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 416 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 417 | rcu_read_lock(); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 418 | |
| 419 | /* XXX: verify sta->dev == dev */ |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 420 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 421 | sta = sta_info_get(local, mac); |
| 422 | if (sta) { |
| 423 | ret = 0; |
| 424 | sta_set_sinfo(sta, sinfo); |
| 425 | } |
| 426 | |
| 427 | rcu_read_unlock(); |
| 428 | |
| 429 | return ret; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 430 | } |
| 431 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 432 | /* |
| 433 | * This handles both adding a beacon and setting new beacon info |
| 434 | */ |
| 435 | static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, |
| 436 | struct beacon_parameters *params) |
| 437 | { |
| 438 | struct beacon_data *new, *old; |
| 439 | int new_head_len, new_tail_len; |
| 440 | int size; |
| 441 | int err = -EINVAL; |
| 442 | |
| 443 | old = sdata->u.ap.beacon; |
| 444 | |
| 445 | /* head must not be zero-length */ |
| 446 | if (params->head && !params->head_len) |
| 447 | return -EINVAL; |
| 448 | |
| 449 | /* |
| 450 | * This is a kludge. beacon interval should really be part |
| 451 | * of the beacon information. |
| 452 | */ |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 453 | if (params->interval && |
| 454 | (sdata->vif.bss_conf.beacon_int != params->interval)) { |
| 455 | sdata->vif.bss_conf.beacon_int = params->interval; |
| 456 | ieee80211_bss_info_change_notify(sdata, |
| 457 | BSS_CHANGED_BEACON_INT); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | /* Need to have a beacon head if we don't have one yet */ |
| 461 | if (!params->head && !old) |
| 462 | return err; |
| 463 | |
| 464 | /* sorry, no way to start beaconing without dtim period */ |
| 465 | if (!params->dtim_period && !old) |
| 466 | return err; |
| 467 | |
| 468 | /* new or old head? */ |
| 469 | if (params->head) |
| 470 | new_head_len = params->head_len; |
| 471 | else |
| 472 | new_head_len = old->head_len; |
| 473 | |
| 474 | /* new or old tail? */ |
| 475 | if (params->tail || !old) |
| 476 | /* params->tail_len will be zero for !params->tail */ |
| 477 | new_tail_len = params->tail_len; |
| 478 | else |
| 479 | new_tail_len = old->tail_len; |
| 480 | |
| 481 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 482 | |
| 483 | new = kzalloc(size, GFP_KERNEL); |
| 484 | if (!new) |
| 485 | return -ENOMEM; |
| 486 | |
| 487 | /* start filling the new info now */ |
| 488 | |
| 489 | /* new or old dtim period? */ |
| 490 | if (params->dtim_period) |
| 491 | new->dtim_period = params->dtim_period; |
| 492 | else |
| 493 | new->dtim_period = old->dtim_period; |
| 494 | |
| 495 | /* |
| 496 | * pointers go into the block we allocated, |
| 497 | * memory is | beacon_data | head | tail | |
| 498 | */ |
| 499 | new->head = ((u8 *) new) + sizeof(*new); |
| 500 | new->tail = new->head + new_head_len; |
| 501 | new->head_len = new_head_len; |
| 502 | new->tail_len = new_tail_len; |
| 503 | |
| 504 | /* copy in head */ |
| 505 | if (params->head) |
| 506 | memcpy(new->head, params->head, new_head_len); |
| 507 | else |
| 508 | memcpy(new->head, old->head, new_head_len); |
| 509 | |
| 510 | /* copy in optional tail */ |
| 511 | if (params->tail) |
| 512 | memcpy(new->tail, params->tail, new_tail_len); |
| 513 | else |
| 514 | if (old) |
| 515 | memcpy(new->tail, old->tail, new_tail_len); |
| 516 | |
| 517 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
| 518 | |
| 519 | synchronize_rcu(); |
| 520 | |
| 521 | kfree(old); |
| 522 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 523 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
| 524 | BSS_CHANGED_BEACON); |
| 525 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 529 | struct beacon_parameters *params) |
| 530 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 531 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 532 | struct beacon_data *old; |
| 533 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 534 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 535 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 536 | old = sdata->u.ap.beacon; |
| 537 | |
| 538 | if (old) |
| 539 | return -EALREADY; |
| 540 | |
| 541 | return ieee80211_config_beacon(sdata, params); |
| 542 | } |
| 543 | |
| 544 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 545 | struct beacon_parameters *params) |
| 546 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 547 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 548 | struct beacon_data *old; |
| 549 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 550 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 551 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 552 | old = sdata->u.ap.beacon; |
| 553 | |
| 554 | if (!old) |
| 555 | return -ENOENT; |
| 556 | |
| 557 | return ieee80211_config_beacon(sdata, params); |
| 558 | } |
| 559 | |
| 560 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) |
| 561 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 562 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 563 | struct beacon_data *old; |
| 564 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 565 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 566 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 567 | old = sdata->u.ap.beacon; |
| 568 | |
| 569 | if (!old) |
| 570 | return -ENOENT; |
| 571 | |
| 572 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); |
| 573 | synchronize_rcu(); |
| 574 | kfree(old); |
| 575 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 576 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
| 577 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 578 | } |
| 579 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 580 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 581 | struct iapp_layer2_update { |
| 582 | u8 da[ETH_ALEN]; /* broadcast */ |
| 583 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 584 | __be16 len; /* 6 */ |
| 585 | u8 dsap; /* 0 */ |
| 586 | u8 ssap; /* 0 */ |
| 587 | u8 control; |
| 588 | u8 xid_info[3]; |
| 589 | } __attribute__ ((packed)); |
| 590 | |
| 591 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 592 | { |
| 593 | struct iapp_layer2_update *msg; |
| 594 | struct sk_buff *skb; |
| 595 | |
| 596 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 597 | * bridge devices */ |
| 598 | |
| 599 | skb = dev_alloc_skb(sizeof(*msg)); |
| 600 | if (!skb) |
| 601 | return; |
| 602 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 603 | |
| 604 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 605 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 606 | |
| 607 | memset(msg->da, 0xff, ETH_ALEN); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 608 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 609 | msg->len = htons(6); |
| 610 | msg->dsap = 0; |
| 611 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 612 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 613 | * F=0 (no poll command; unsolicited frame) */ |
| 614 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 615 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 616 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 617 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 618 | skb->dev = sta->sdata->dev; |
| 619 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 620 | memset(skb->cb, 0, sizeof(skb->cb)); |
| 621 | netif_rx(skb); |
| 622 | } |
| 623 | |
| 624 | static void sta_apply_parameters(struct ieee80211_local *local, |
| 625 | struct sta_info *sta, |
| 626 | struct station_parameters *params) |
| 627 | { |
| 628 | u32 rates; |
| 629 | int i, j; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 630 | struct ieee80211_supported_band *sband; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 631 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame^] | 632 | u32 mask, set; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 633 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 634 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 635 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame^] | 636 | spin_lock_bh(&sta->lock); |
| 637 | mask = params->sta_flags_mask; |
| 638 | set = params->sta_flags_set; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 639 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame^] | 640 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 641 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame^] | 642 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 643 | sta->flags |= WLAN_STA_AUTHORIZED; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 644 | } |
| 645 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame^] | 646 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
| 647 | sta->flags &= ~WLAN_STA_SHORT_PREAMBLE; |
| 648 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
| 649 | sta->flags |= WLAN_STA_SHORT_PREAMBLE; |
| 650 | } |
| 651 | |
| 652 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
| 653 | sta->flags &= ~WLAN_STA_WME; |
| 654 | if (set & BIT(NL80211_STA_FLAG_WME)) |
| 655 | sta->flags |= WLAN_STA_WME; |
| 656 | } |
| 657 | |
| 658 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
| 659 | sta->flags &= ~WLAN_STA_MFP; |
| 660 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
| 661 | sta->flags |= WLAN_STA_MFP; |
| 662 | } |
| 663 | spin_unlock_bh(&sta->lock); |
| 664 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 665 | /* |
| 666 | * FIXME: updating the following information is racy when this |
| 667 | * function is called from ieee80211_change_station(). |
| 668 | * However, all this information should be static so |
| 669 | * maybe we should just reject attemps to change it. |
| 670 | */ |
| 671 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 672 | if (params->aid) { |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 673 | sta->sta.aid = params->aid; |
| 674 | if (sta->sta.aid > IEEE80211_MAX_AID) |
| 675 | sta->sta.aid = 0; /* XXX: should this be an error? */ |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | if (params->listen_interval >= 0) |
| 679 | sta->listen_interval = params->listen_interval; |
| 680 | |
| 681 | if (params->supported_rates) { |
| 682 | rates = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 683 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 684 | for (i = 0; i < params->supported_rates_len; i++) { |
| 685 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 686 | for (j = 0; j < sband->n_bitrates; j++) { |
| 687 | if (sband->bitrates[j].bitrate == rate) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 688 | rates |= BIT(j); |
| 689 | } |
| 690 | } |
Johannes Berg | 323ce79 | 2008-09-11 02:45:11 +0200 | [diff] [blame] | 691 | sta->sta.supp_rates[local->oper_channel->band] = rates; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 692 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 693 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 694 | if (params->ht_capa) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 695 | ieee80211_ht_cap_ie_to_sta_ht_cap(sband, |
| 696 | params->ht_capa, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 697 | &sta->sta.ht_cap); |
Jouni Malinen | 36aedc9 | 2008-08-25 11:58:58 +0300 | [diff] [blame] | 698 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 699 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 700 | switch (params->plink_action) { |
| 701 | case PLINK_ACTION_OPEN: |
| 702 | mesh_plink_open(sta); |
| 703 | break; |
| 704 | case PLINK_ACTION_BLOCK: |
| 705 | mesh_plink_block(sta); |
| 706 | break; |
| 707 | } |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 708 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 712 | u8 *mac, struct station_parameters *params) |
| 713 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 714 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 715 | struct sta_info *sta; |
| 716 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 717 | int err; |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 718 | int layer2_update; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 719 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 720 | if (params->vlan) { |
| 721 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 722 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 723 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 724 | sdata->vif.type != NL80211_IFTYPE_AP) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 725 | return -EINVAL; |
| 726 | } else |
| 727 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 728 | |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 729 | if (compare_ether_addr(mac, dev->dev_addr) == 0) |
| 730 | return -EINVAL; |
| 731 | |
| 732 | if (is_multicast_ether_addr(mac)) |
| 733 | return -EINVAL; |
| 734 | |
| 735 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 736 | if (!sta) |
| 737 | return -ENOMEM; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 738 | |
| 739 | sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 740 | |
| 741 | sta_apply_parameters(local, sta, params); |
| 742 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 743 | rate_control_rate_init(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 744 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 745 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
| 746 | sdata->vif.type == NL80211_IFTYPE_AP; |
| 747 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 748 | rcu_read_lock(); |
| 749 | |
| 750 | err = sta_info_insert(sta); |
| 751 | if (err) { |
Johannes Berg | 93e5deb | 2008-04-01 15:21:00 +0200 | [diff] [blame] | 752 | /* STA has been freed */ |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 753 | if (err == -EEXIST && layer2_update) { |
| 754 | /* Need to update layer 2 devices on reassociation */ |
| 755 | sta = sta_info_get(local, mac); |
| 756 | if (sta) |
| 757 | ieee80211_send_layer2_update(sta); |
| 758 | } |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 759 | rcu_read_unlock(); |
| 760 | return err; |
| 761 | } |
| 762 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 763 | if (layer2_update) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 764 | ieee80211_send_layer2_update(sta); |
| 765 | |
| 766 | rcu_read_unlock(); |
| 767 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 768 | return 0; |
| 769 | } |
| 770 | |
| 771 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 772 | u8 *mac) |
| 773 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 774 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 775 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 776 | struct sta_info *sta; |
| 777 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 778 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 779 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 780 | if (mac) { |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 781 | rcu_read_lock(); |
| 782 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 783 | /* XXX: get sta belonging to dev */ |
| 784 | sta = sta_info_get(local, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 785 | if (!sta) { |
| 786 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 787 | return -ENOENT; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 788 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 789 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 790 | sta_info_unlink(&sta); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 791 | rcu_read_unlock(); |
| 792 | |
Johannes Berg | 4f6fab4 | 2008-03-31 19:23:02 +0200 | [diff] [blame] | 793 | sta_info_destroy(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 794 | } else |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 795 | sta_info_flush(local, sdata); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 796 | |
| 797 | return 0; |
| 798 | } |
| 799 | |
| 800 | static int ieee80211_change_station(struct wiphy *wiphy, |
| 801 | struct net_device *dev, |
| 802 | u8 *mac, |
| 803 | struct station_parameters *params) |
| 804 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 805 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 806 | struct sta_info *sta; |
| 807 | struct ieee80211_sub_if_data *vlansdata; |
| 808 | |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 809 | rcu_read_lock(); |
| 810 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 811 | /* XXX: get sta belonging to dev */ |
| 812 | sta = sta_info_get(local, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 813 | if (!sta) { |
| 814 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 815 | return -ENOENT; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 816 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 817 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 818 | if (params->vlan && params->vlan != sta->sdata->dev) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 819 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 820 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 821 | if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 822 | vlansdata->vif.type != NL80211_IFTYPE_AP) { |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 823 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 824 | return -EINVAL; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 825 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 826 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 827 | sta->sdata = vlansdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 828 | ieee80211_send_layer2_update(sta); |
| 829 | } |
| 830 | |
| 831 | sta_apply_parameters(local, sta, params); |
| 832 | |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 833 | rcu_read_unlock(); |
| 834 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 835 | return 0; |
| 836 | } |
| 837 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 838 | #ifdef CONFIG_MAC80211_MESH |
| 839 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 840 | u8 *dst, u8 *next_hop) |
| 841 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 842 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 843 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 844 | struct mesh_path *mpath; |
| 845 | struct sta_info *sta; |
| 846 | int err; |
| 847 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 848 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 849 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 850 | rcu_read_lock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 851 | sta = sta_info_get(local, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 852 | if (!sta) { |
| 853 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 854 | return -ENOENT; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 855 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 856 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 857 | err = mesh_path_add(dst, sdata); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 858 | if (err) { |
| 859 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 860 | return err; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 861 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 862 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 863 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 864 | if (!mpath) { |
| 865 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 866 | return -ENXIO; |
| 867 | } |
| 868 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 869 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 870 | rcu_read_unlock(); |
| 871 | return 0; |
| 872 | } |
| 873 | |
| 874 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 875 | u8 *dst) |
| 876 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 877 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 878 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 879 | if (dst) |
| 880 | return mesh_path_del(dst, sdata); |
| 881 | |
| 882 | mesh_path_flush(sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 883 | return 0; |
| 884 | } |
| 885 | |
| 886 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 887 | struct net_device *dev, |
| 888 | u8 *dst, u8 *next_hop) |
| 889 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 890 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 891 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 892 | struct mesh_path *mpath; |
| 893 | struct sta_info *sta; |
| 894 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 895 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 896 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 897 | rcu_read_lock(); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 898 | |
| 899 | sta = sta_info_get(local, next_hop); |
| 900 | if (!sta) { |
| 901 | rcu_read_unlock(); |
| 902 | return -ENOENT; |
| 903 | } |
| 904 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 905 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 906 | if (!mpath) { |
| 907 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 908 | return -ENOENT; |
| 909 | } |
| 910 | |
| 911 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 912 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 913 | rcu_read_unlock(); |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 918 | struct mpath_info *pinfo) |
| 919 | { |
| 920 | if (mpath->next_hop) |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 921 | memcpy(next_hop, mpath->next_hop->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 922 | else |
| 923 | memset(next_hop, 0, ETH_ALEN); |
| 924 | |
| 925 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
| 926 | MPATH_INFO_DSN | |
| 927 | MPATH_INFO_METRIC | |
| 928 | MPATH_INFO_EXPTIME | |
| 929 | MPATH_INFO_DISCOVERY_TIMEOUT | |
| 930 | MPATH_INFO_DISCOVERY_RETRIES | |
| 931 | MPATH_INFO_FLAGS; |
| 932 | |
| 933 | pinfo->frame_qlen = mpath->frame_queue.qlen; |
| 934 | pinfo->dsn = mpath->dsn; |
| 935 | pinfo->metric = mpath->metric; |
| 936 | if (time_before(jiffies, mpath->exp_time)) |
| 937 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); |
| 938 | pinfo->discovery_timeout = |
| 939 | jiffies_to_msecs(mpath->discovery_timeout); |
| 940 | pinfo->discovery_retries = mpath->discovery_retries; |
| 941 | pinfo->flags = 0; |
| 942 | if (mpath->flags & MESH_PATH_ACTIVE) |
| 943 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; |
| 944 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 945 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 946 | if (mpath->flags & MESH_PATH_DSN_VALID) |
| 947 | pinfo->flags |= NL80211_MPATH_FLAG_DSN_VALID; |
| 948 | if (mpath->flags & MESH_PATH_FIXED) |
| 949 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; |
| 950 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 951 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 952 | |
| 953 | pinfo->flags = mpath->flags; |
| 954 | } |
| 955 | |
| 956 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 957 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
| 958 | |
| 959 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 960 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 961 | struct mesh_path *mpath; |
| 962 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 963 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 964 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 965 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 966 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 967 | if (!mpath) { |
| 968 | rcu_read_unlock(); |
| 969 | return -ENOENT; |
| 970 | } |
| 971 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 972 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 973 | rcu_read_unlock(); |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 978 | int idx, u8 *dst, u8 *next_hop, |
| 979 | struct mpath_info *pinfo) |
| 980 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 981 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 982 | struct mesh_path *mpath; |
| 983 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 984 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 985 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 986 | rcu_read_lock(); |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 987 | mpath = mesh_path_lookup_by_idx(idx, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 988 | if (!mpath) { |
| 989 | rcu_read_unlock(); |
| 990 | return -ENOENT; |
| 991 | } |
| 992 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 993 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 994 | rcu_read_unlock(); |
| 995 | return 0; |
| 996 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 997 | |
| 998 | static int ieee80211_get_mesh_params(struct wiphy *wiphy, |
| 999 | struct net_device *dev, |
| 1000 | struct mesh_config *conf) |
| 1001 | { |
| 1002 | struct ieee80211_sub_if_data *sdata; |
| 1003 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1004 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1005 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
| 1006 | return 0; |
| 1007 | } |
| 1008 | |
| 1009 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) |
| 1010 | { |
| 1011 | return (mask >> (parm-1)) & 0x1; |
| 1012 | } |
| 1013 | |
| 1014 | static int ieee80211_set_mesh_params(struct wiphy *wiphy, |
| 1015 | struct net_device *dev, |
| 1016 | const struct mesh_config *nconf, u32 mask) |
| 1017 | { |
| 1018 | struct mesh_config *conf; |
| 1019 | struct ieee80211_sub_if_data *sdata; |
| 1020 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1021 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1022 | /* Set the config options which we are interested in setting */ |
| 1023 | conf = &(sdata->u.mesh.mshcfg); |
| 1024 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) |
| 1025 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; |
| 1026 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) |
| 1027 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; |
| 1028 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) |
| 1029 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; |
| 1030 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) |
| 1031 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; |
| 1032 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) |
| 1033 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; |
| 1034 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) |
| 1035 | conf->dot11MeshTTL = nconf->dot11MeshTTL; |
| 1036 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) |
| 1037 | conf->auto_open_plinks = nconf->auto_open_plinks; |
| 1038 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
| 1039 | conf->dot11MeshHWMPmaxPREQretries = |
| 1040 | nconf->dot11MeshHWMPmaxPREQretries; |
| 1041 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) |
| 1042 | conf->path_refresh_time = nconf->path_refresh_time; |
| 1043 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) |
| 1044 | conf->min_discovery_timeout = nconf->min_discovery_timeout; |
| 1045 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) |
| 1046 | conf->dot11MeshHWMPactivePathTimeout = |
| 1047 | nconf->dot11MeshHWMPactivePathTimeout; |
| 1048 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) |
| 1049 | conf->dot11MeshHWMPpreqMinInterval = |
| 1050 | nconf->dot11MeshHWMPpreqMinInterval; |
| 1051 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
| 1052 | mask)) |
| 1053 | conf->dot11MeshHWMPnetDiameterTraversalTime = |
| 1054 | nconf->dot11MeshHWMPnetDiameterTraversalTime; |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1058 | #endif |
| 1059 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1060 | static int ieee80211_change_bss(struct wiphy *wiphy, |
| 1061 | struct net_device *dev, |
| 1062 | struct bss_parameters *params) |
| 1063 | { |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1064 | struct ieee80211_sub_if_data *sdata; |
| 1065 | u32 changed = 0; |
| 1066 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1067 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1068 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1069 | if (params->use_cts_prot >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1070 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1071 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
| 1072 | } |
| 1073 | if (params->use_short_preamble >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1074 | sdata->vif.bss_conf.use_short_preamble = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1075 | params->use_short_preamble; |
| 1076 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
| 1077 | } |
| 1078 | if (params->use_short_slot_time >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1079 | sdata->vif.bss_conf.use_short_slot = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1080 | params->use_short_slot_time; |
| 1081 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1082 | } |
| 1083 | |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 1084 | if (params->basic_rates) { |
| 1085 | int i, j; |
| 1086 | u32 rates = 0; |
| 1087 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1088 | struct ieee80211_supported_band *sband = |
| 1089 | wiphy->bands[local->oper_channel->band]; |
| 1090 | |
| 1091 | for (i = 0; i < params->basic_rates_len; i++) { |
| 1092 | int rate = (params->basic_rates[i] & 0x7f) * 5; |
| 1093 | for (j = 0; j < sband->n_bitrates; j++) { |
| 1094 | if (sband->bitrates[j].bitrate == rate) |
| 1095 | rates |= BIT(j); |
| 1096 | } |
| 1097 | } |
| 1098 | sdata->vif.bss_conf.basic_rates = rates; |
| 1099 | changed |= BSS_CHANGED_BASIC_RATES; |
| 1100 | } |
| 1101 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1102 | ieee80211_bss_info_change_notify(sdata, changed); |
| 1103 | |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1107 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
| 1108 | struct ieee80211_txq_params *params) |
| 1109 | { |
| 1110 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1111 | struct ieee80211_tx_queue_params p; |
| 1112 | |
| 1113 | if (!local->ops->conf_tx) |
| 1114 | return -EOPNOTSUPP; |
| 1115 | |
| 1116 | memset(&p, 0, sizeof(p)); |
| 1117 | p.aifs = params->aifs; |
| 1118 | p.cw_max = params->cwmax; |
| 1119 | p.cw_min = params->cwmin; |
| 1120 | p.txop = params->txop; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1121 | if (drv_conf_tx(local, params->queue, &p)) { |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1122 | printk(KERN_DEBUG "%s: failed to set TX queue " |
| 1123 | "parameters for queue %d\n", local->mdev->name, |
| 1124 | params->queue); |
| 1125 | return -EINVAL; |
| 1126 | } |
| 1127 | |
| 1128 | return 0; |
| 1129 | } |
| 1130 | |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1131 | static int ieee80211_set_channel(struct wiphy *wiphy, |
| 1132 | struct ieee80211_channel *chan, |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 1133 | enum nl80211_channel_type channel_type) |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1134 | { |
| 1135 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1136 | |
| 1137 | local->oper_channel = chan; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 1138 | local->oper_channel_type = channel_type; |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1139 | |
| 1140 | return ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
| 1141 | } |
| 1142 | |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1143 | #ifdef CONFIG_PM |
| 1144 | static int ieee80211_suspend(struct wiphy *wiphy) |
| 1145 | { |
| 1146 | return __ieee80211_suspend(wiphy_priv(wiphy)); |
| 1147 | } |
| 1148 | |
| 1149 | static int ieee80211_resume(struct wiphy *wiphy) |
| 1150 | { |
| 1151 | return __ieee80211_resume(wiphy_priv(wiphy)); |
| 1152 | } |
| 1153 | #else |
| 1154 | #define ieee80211_suspend NULL |
| 1155 | #define ieee80211_resume NULL |
| 1156 | #endif |
| 1157 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1158 | static int ieee80211_scan(struct wiphy *wiphy, |
| 1159 | struct net_device *dev, |
| 1160 | struct cfg80211_scan_request *req) |
| 1161 | { |
| 1162 | struct ieee80211_sub_if_data *sdata; |
| 1163 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1164 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1165 | |
| 1166 | if (sdata->vif.type != NL80211_IFTYPE_STATION && |
| 1167 | sdata->vif.type != NL80211_IFTYPE_ADHOC && |
Jouni Malinen | 357303e | 2009-04-16 18:44:53 +0300 | [diff] [blame] | 1168 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
| 1169 | (sdata->vif.type != NL80211_IFTYPE_AP || sdata->u.ap.beacon)) |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1170 | return -EOPNOTSUPP; |
| 1171 | |
| 1172 | return ieee80211_request_scan(sdata, req); |
| 1173 | } |
| 1174 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1175 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
| 1176 | struct cfg80211_auth_request *req) |
| 1177 | { |
| 1178 | struct ieee80211_sub_if_data *sdata; |
| 1179 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1180 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1181 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1182 | switch (req->auth_type) { |
| 1183 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 1184 | sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN; |
| 1185 | break; |
| 1186 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 1187 | sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_SHARED_KEY; |
| 1188 | break; |
| 1189 | case NL80211_AUTHTYPE_FT: |
| 1190 | sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_FT; |
| 1191 | break; |
| 1192 | case NL80211_AUTHTYPE_NETWORK_EAP: |
| 1193 | sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_LEAP; |
| 1194 | break; |
| 1195 | default: |
| 1196 | return -EOPNOTSUPP; |
| 1197 | } |
| 1198 | |
| 1199 | memcpy(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN); |
| 1200 | sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
| 1201 | sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET; |
| 1202 | |
| 1203 | /* TODO: req->chan */ |
| 1204 | sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL; |
| 1205 | |
| 1206 | if (req->ssid) { |
| 1207 | sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET; |
| 1208 | memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len); |
| 1209 | sdata->u.mgd.ssid_len = req->ssid_len; |
| 1210 | sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; |
| 1211 | } |
| 1212 | |
| 1213 | kfree(sdata->u.mgd.sme_auth_ie); |
| 1214 | sdata->u.mgd.sme_auth_ie = NULL; |
| 1215 | sdata->u.mgd.sme_auth_ie_len = 0; |
| 1216 | if (req->ie) { |
| 1217 | sdata->u.mgd.sme_auth_ie = kmalloc(req->ie_len, GFP_KERNEL); |
| 1218 | if (sdata->u.mgd.sme_auth_ie == NULL) |
| 1219 | return -ENOMEM; |
| 1220 | memcpy(sdata->u.mgd.sme_auth_ie, req->ie, req->ie_len); |
| 1221 | sdata->u.mgd.sme_auth_ie_len = req->ie_len; |
| 1222 | } |
| 1223 | |
| 1224 | sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME; |
| 1225 | sdata->u.mgd.state = IEEE80211_STA_MLME_DIRECT_PROBE; |
| 1226 | ieee80211_sta_req_auth(sdata); |
| 1227 | return 0; |
| 1228 | } |
| 1229 | |
| 1230 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 1231 | struct cfg80211_assoc_request *req) |
| 1232 | { |
| 1233 | struct ieee80211_sub_if_data *sdata; |
| 1234 | int ret; |
| 1235 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1236 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1237 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1238 | if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 || |
| 1239 | !(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED)) |
| 1240 | return -ENOLINK; /* not authenticated */ |
| 1241 | |
| 1242 | sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
| 1243 | sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET; |
| 1244 | |
| 1245 | /* TODO: req->chan */ |
| 1246 | sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL; |
| 1247 | |
| 1248 | if (req->ssid) { |
| 1249 | sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET; |
| 1250 | memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len); |
| 1251 | sdata->u.mgd.ssid_len = req->ssid_len; |
| 1252 | sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; |
| 1253 | } else |
| 1254 | sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL; |
| 1255 | |
| 1256 | ret = ieee80211_sta_set_extra_ie(sdata, req->ie, req->ie_len); |
| 1257 | if (ret) |
| 1258 | return ret; |
| 1259 | |
Jouni Malinen | dc6382ce | 2009-05-06 22:09:37 +0300 | [diff] [blame] | 1260 | if (req->use_mfp) { |
| 1261 | sdata->u.mgd.mfp = IEEE80211_MFP_REQUIRED; |
| 1262 | sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED; |
| 1263 | } else { |
| 1264 | sdata->u.mgd.mfp = IEEE80211_MFP_DISABLED; |
| 1265 | sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED; |
| 1266 | } |
| 1267 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1268 | sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME; |
| 1269 | sdata->u.mgd.state = IEEE80211_STA_MLME_ASSOCIATE; |
| 1270 | ieee80211_sta_req_auth(sdata); |
| 1271 | return 0; |
| 1272 | } |
| 1273 | |
| 1274 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
| 1275 | struct cfg80211_deauth_request *req) |
| 1276 | { |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 1277 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1278 | |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 1279 | /* TODO: req->ie, req->peer_addr */ |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1280 | return ieee80211_sta_deauthenticate(sdata, req->reason_code); |
| 1281 | } |
| 1282 | |
| 1283 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
| 1284 | struct cfg80211_disassoc_request *req) |
| 1285 | { |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 1286 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1287 | |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 1288 | /* TODO: req->ie, req->peer_addr */ |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1289 | return ieee80211_sta_disassociate(sdata, req->reason_code); |
| 1290 | } |
| 1291 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1292 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 1293 | struct cfg80211_ibss_params *params) |
| 1294 | { |
| 1295 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1296 | |
| 1297 | return ieee80211_ibss_join(sdata, params); |
| 1298 | } |
| 1299 | |
| 1300 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 1301 | { |
| 1302 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1303 | |
| 1304 | return ieee80211_ibss_leave(sdata); |
| 1305 | } |
| 1306 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1307 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 1308 | { |
| 1309 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1310 | int err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1311 | |
| 1312 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1313 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1314 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1315 | if (err) |
| 1316 | return err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 1320 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
| 1321 | if (changed & WIPHY_PARAM_RETRY_LONG) |
| 1322 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
| 1323 | if (changed & |
| 1324 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) |
| 1325 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); |
| 1326 | |
| 1327 | return 0; |
| 1328 | } |
| 1329 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1330 | struct cfg80211_ops mac80211_config_ops = { |
| 1331 | .add_virtual_intf = ieee80211_add_iface, |
| 1332 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 1333 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 1334 | .add_key = ieee80211_add_key, |
| 1335 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 1336 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 1337 | .set_default_key = ieee80211_config_default_key, |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 1338 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1339 | .add_beacon = ieee80211_add_beacon, |
| 1340 | .set_beacon = ieee80211_set_beacon, |
| 1341 | .del_beacon = ieee80211_del_beacon, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1342 | .add_station = ieee80211_add_station, |
| 1343 | .del_station = ieee80211_del_station, |
| 1344 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 1345 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1346 | .dump_station = ieee80211_dump_station, |
| 1347 | #ifdef CONFIG_MAC80211_MESH |
| 1348 | .add_mpath = ieee80211_add_mpath, |
| 1349 | .del_mpath = ieee80211_del_mpath, |
| 1350 | .change_mpath = ieee80211_change_mpath, |
| 1351 | .get_mpath = ieee80211_get_mpath, |
| 1352 | .dump_mpath = ieee80211_dump_mpath, |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1353 | .set_mesh_params = ieee80211_set_mesh_params, |
| 1354 | .get_mesh_params = ieee80211_get_mesh_params, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1355 | #endif |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1356 | .change_bss = ieee80211_change_bss, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1357 | .set_txq_params = ieee80211_set_txq_params, |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1358 | .set_channel = ieee80211_set_channel, |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1359 | .suspend = ieee80211_suspend, |
| 1360 | .resume = ieee80211_resume, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1361 | .scan = ieee80211_scan, |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1362 | .auth = ieee80211_auth, |
| 1363 | .assoc = ieee80211_assoc, |
| 1364 | .deauth = ieee80211_deauth, |
| 1365 | .disassoc = ieee80211_disassoc, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1366 | .join_ibss = ieee80211_join_ibss, |
| 1367 | .leave_ibss = ieee80211_leave_ibss, |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1368 | .set_wiphy_params = ieee80211_set_wiphy_params, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1369 | }; |