Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * mac80211 configuration hooks for cfg80211 |
| 3 | * |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 4 | * Copyright 2006-2010 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 | |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 39 | static bool nl80211_params_check(enum nl80211_iftype type, |
| 40 | struct vif_params *params) |
| 41 | { |
| 42 | if (!nl80211_type_check(type)) |
| 43 | return false; |
| 44 | |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 45 | return true; |
| 46 | } |
| 47 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 48 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 49 | enum nl80211_iftype type, u32 *flags, |
| 50 | struct vif_params *params) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 51 | { |
| 52 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 53 | struct net_device *dev; |
| 54 | struct ieee80211_sub_if_data *sdata; |
| 55 | int err; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 56 | |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 57 | if (!nl80211_params_check(type, params)) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 58 | return -EINVAL; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 59 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 60 | err = ieee80211_if_add(local, name, &dev, type, params); |
| 61 | if (err || type != NL80211_IFTYPE_MONITOR || !flags) |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 62 | return err; |
| 63 | |
| 64 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 65 | sdata->u.mntr_flags = *flags; |
| 66 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Johannes Berg | 463d018 | 2009-07-14 00:33:35 +0200 | [diff] [blame] | 69 | static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev) |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 70 | { |
Johannes Berg | 463d018 | 2009-07-14 00:33:35 +0200 | [diff] [blame] | 71 | ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev)); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 72 | |
Johannes Berg | 7563652 | 2008-07-09 14:40:35 +0200 | [diff] [blame] | 73 | return 0; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Johannes Berg | e36d56b | 2009-06-09 21:04:43 +0200 | [diff] [blame] | 76 | static int ieee80211_change_iface(struct wiphy *wiphy, |
| 77 | struct net_device *dev, |
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 | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 81 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 82 | int ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 83 | |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 84 | if (ieee80211_sdata_running(sdata)) |
Johannes Berg | c1f9a76 | 2009-11-01 19:25:40 +0100 | [diff] [blame] | 85 | return -EBUSY; |
| 86 | |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 87 | if (!nl80211_params_check(type, params)) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 88 | return -EINVAL; |
| 89 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 90 | ret = ieee80211_if_change_type(sdata, type); |
Johannes Berg | f3947e2 | 2008-07-09 14:40:36 +0200 | [diff] [blame] | 91 | if (ret) |
| 92 | return ret; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 93 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 94 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len) |
Johannes Berg | 472dbc4 | 2008-09-11 00:01:49 +0200 | [diff] [blame] | 95 | ieee80211_sdata_set_mesh_id(sdata, |
| 96 | params->mesh_id_len, |
| 97 | params->mesh_id); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 98 | |
Johannes Berg | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 99 | if (type == NL80211_IFTYPE_AP_VLAN && |
| 100 | params && params->use_4addr == 0) |
| 101 | rcu_assign_pointer(sdata->u.vlan.sta, NULL); |
| 102 | else if (type == NL80211_IFTYPE_STATION && |
| 103 | params && params->use_4addr >= 0) |
| 104 | sdata->u.mgd.use_4addr = params->use_4addr; |
| 105 | |
Felix Fietkau | f7917af | 2010-04-27 00:26:34 +0200 | [diff] [blame] | 106 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) |
| 107 | sdata->u.mntr_flags = *flags; |
| 108 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 112 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 113 | u8 key_idx, const u8 *mac_addr, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 114 | struct key_params *params) |
| 115 | { |
| 116 | struct ieee80211_sub_if_data *sdata; |
| 117 | struct sta_info *sta = NULL; |
| 118 | enum ieee80211_key_alg alg; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 119 | struct ieee80211_key *key; |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 120 | int err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 121 | |
| 122 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 123 | |
| 124 | switch (params->cipher) { |
| 125 | case WLAN_CIPHER_SUITE_WEP40: |
| 126 | case WLAN_CIPHER_SUITE_WEP104: |
| 127 | alg = ALG_WEP; |
| 128 | break; |
| 129 | case WLAN_CIPHER_SUITE_TKIP: |
| 130 | alg = ALG_TKIP; |
| 131 | break; |
| 132 | case WLAN_CIPHER_SUITE_CCMP: |
| 133 | alg = ALG_CCMP; |
| 134 | break; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 135 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 136 | alg = ALG_AES_CMAC; |
| 137 | break; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 138 | default: |
| 139 | return -EINVAL; |
| 140 | } |
| 141 | |
Jouni Malinen | faa8fdc | 2009-05-11 21:57:58 +0300 | [diff] [blame] | 142 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key, |
| 143 | params->seq_len, params->seq); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 144 | if (!key) |
| 145 | return -ENOMEM; |
| 146 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 147 | rcu_read_lock(); |
| 148 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 149 | if (mac_addr) { |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 150 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 151 | if (!sta) { |
| 152 | ieee80211_key_free(key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 153 | err = -ENOENT; |
| 154 | goto out_unlock; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 155 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 156 | } |
| 157 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 158 | ieee80211_key_link(key, sdata, sta); |
| 159 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 160 | err = 0; |
| 161 | out_unlock: |
| 162 | rcu_read_unlock(); |
| 163 | |
| 164 | return err; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 168 | u8 key_idx, const u8 *mac_addr) |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 169 | { |
| 170 | struct ieee80211_sub_if_data *sdata; |
| 171 | struct sta_info *sta; |
| 172 | int ret; |
| 173 | |
| 174 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 175 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 176 | rcu_read_lock(); |
| 177 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 178 | if (mac_addr) { |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 179 | ret = -ENOENT; |
| 180 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 181 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 182 | if (!sta) |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 183 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 184 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 185 | if (sta->key) { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 186 | ieee80211_key_free(sta->key); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 187 | WARN_ON(sta->key); |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 188 | ret = 0; |
| 189 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 190 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 191 | goto out_unlock; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 192 | } |
| 193 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 194 | if (!sdata->keys[key_idx]) { |
| 195 | ret = -ENOENT; |
| 196 | goto out_unlock; |
| 197 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 198 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 199 | ieee80211_key_free(sdata->keys[key_idx]); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 200 | WARN_ON(sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 201 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 202 | ret = 0; |
| 203 | out_unlock: |
| 204 | rcu_read_unlock(); |
| 205 | |
| 206 | return ret; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 207 | } |
| 208 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 209 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 4e94390 | 2009-05-09 20:06:47 +0200 | [diff] [blame] | 210 | u8 key_idx, const u8 *mac_addr, void *cookie, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 211 | void (*callback)(void *cookie, |
| 212 | struct key_params *params)) |
| 213 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 214 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 215 | struct sta_info *sta = NULL; |
| 216 | u8 seq[6] = {0}; |
| 217 | struct key_params params; |
| 218 | struct ieee80211_key *key; |
| 219 | u32 iv32; |
| 220 | u16 iv16; |
| 221 | int err = -ENOENT; |
| 222 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 223 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 224 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 225 | rcu_read_lock(); |
| 226 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 227 | if (mac_addr) { |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 228 | sta = sta_info_get_bss(sdata, mac_addr); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 229 | if (!sta) |
| 230 | goto out; |
| 231 | |
| 232 | key = sta->key; |
| 233 | } else |
| 234 | key = sdata->keys[key_idx]; |
| 235 | |
| 236 | if (!key) |
| 237 | goto out; |
| 238 | |
| 239 | memset(¶ms, 0, sizeof(params)); |
| 240 | |
| 241 | switch (key->conf.alg) { |
| 242 | case ALG_TKIP: |
| 243 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 244 | |
Harvey Harrison | b0f76b3 | 2008-05-14 16:26:19 -0700 | [diff] [blame] | 245 | iv32 = key->u.tkip.tx.iv32; |
| 246 | iv16 = key->u.tkip.tx.iv16; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 247 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 248 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) |
| 249 | drv_get_tkip_seq(sdata->local, |
| 250 | key->conf.hw_key_idx, |
| 251 | &iv32, &iv16); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 252 | |
| 253 | seq[0] = iv16 & 0xff; |
| 254 | seq[1] = (iv16 >> 8) & 0xff; |
| 255 | seq[2] = iv32 & 0xff; |
| 256 | seq[3] = (iv32 >> 8) & 0xff; |
| 257 | seq[4] = (iv32 >> 16) & 0xff; |
| 258 | seq[5] = (iv32 >> 24) & 0xff; |
| 259 | params.seq = seq; |
| 260 | params.seq_len = 6; |
| 261 | break; |
| 262 | case ALG_CCMP: |
| 263 | params.cipher = WLAN_CIPHER_SUITE_CCMP; |
| 264 | seq[0] = key->u.ccmp.tx_pn[5]; |
| 265 | seq[1] = key->u.ccmp.tx_pn[4]; |
| 266 | seq[2] = key->u.ccmp.tx_pn[3]; |
| 267 | seq[3] = key->u.ccmp.tx_pn[2]; |
| 268 | seq[4] = key->u.ccmp.tx_pn[1]; |
| 269 | seq[5] = key->u.ccmp.tx_pn[0]; |
| 270 | params.seq = seq; |
| 271 | params.seq_len = 6; |
| 272 | break; |
| 273 | case ALG_WEP: |
| 274 | if (key->conf.keylen == 5) |
| 275 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 276 | else |
| 277 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 278 | break; |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 279 | case ALG_AES_CMAC: |
| 280 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 281 | seq[0] = key->u.aes_cmac.tx_pn[5]; |
| 282 | seq[1] = key->u.aes_cmac.tx_pn[4]; |
| 283 | seq[2] = key->u.aes_cmac.tx_pn[3]; |
| 284 | seq[3] = key->u.aes_cmac.tx_pn[2]; |
| 285 | seq[4] = key->u.aes_cmac.tx_pn[1]; |
| 286 | seq[5] = key->u.aes_cmac.tx_pn[0]; |
| 287 | params.seq = seq; |
| 288 | params.seq_len = 6; |
| 289 | break; |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | params.key = key->conf.key; |
| 293 | params.key_len = key->conf.keylen; |
| 294 | |
| 295 | callback(cookie, ¶ms); |
| 296 | err = 0; |
| 297 | |
| 298 | out: |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 299 | rcu_read_unlock(); |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 300 | return err; |
| 301 | } |
| 302 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 303 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 304 | struct net_device *dev, |
| 305 | u8 key_idx) |
| 306 | { |
| 307 | struct ieee80211_sub_if_data *sdata; |
| 308 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 309 | rcu_read_lock(); |
| 310 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 311 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 312 | ieee80211_set_default_key(sdata, key_idx); |
| 313 | |
Johannes Berg | 3b96766 | 2008-04-08 17:56:52 +0200 | [diff] [blame] | 314 | rcu_read_unlock(); |
| 315 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 316 | return 0; |
| 317 | } |
| 318 | |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 319 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
| 320 | struct net_device *dev, |
| 321 | u8 key_idx) |
| 322 | { |
| 323 | struct ieee80211_sub_if_data *sdata; |
| 324 | |
| 325 | rcu_read_lock(); |
| 326 | |
| 327 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 328 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
| 329 | |
| 330 | rcu_read_unlock(); |
| 331 | |
| 332 | return 0; |
| 333 | } |
| 334 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 335 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 336 | { |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 337 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 338 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 339 | sinfo->generation = sdata->local->sta_generation; |
| 340 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 341 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
| 342 | STATION_INFO_RX_BYTES | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 343 | STATION_INFO_TX_BYTES | |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 344 | STATION_INFO_RX_PACKETS | |
| 345 | STATION_INFO_TX_PACKETS | |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 346 | STATION_INFO_TX_BITRATE; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 347 | |
| 348 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
| 349 | sinfo->rx_bytes = sta->rx_bytes; |
| 350 | sinfo->tx_bytes = sta->tx_bytes; |
Jouni Malinen | 98c8a60a | 2009-02-17 13:24:57 +0200 | [diff] [blame] | 351 | sinfo->rx_packets = sta->rx_packets; |
| 352 | sinfo->tx_packets = sta->tx_packets; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 353 | |
John W. Linville | 19deffb | 2009-12-08 17:10:13 -0500 | [diff] [blame] | 354 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
| 355 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { |
Henning Rogge | 420e7fa | 2008-12-11 22:04:19 +0100 | [diff] [blame] | 356 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 357 | sinfo->signal = (s8)sta->last_signal; |
| 358 | } |
| 359 | |
| 360 | sinfo->txrate.flags = 0; |
| 361 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS) |
| 362 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 363 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
| 364 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 365 | if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) |
| 366 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 367 | |
| 368 | if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) { |
| 369 | struct ieee80211_supported_band *sband; |
| 370 | sband = sta->local->hw.wiphy->bands[ |
| 371 | sta->local->hw.conf.channel->band]; |
| 372 | sinfo->txrate.legacy = |
| 373 | sband->bitrates[sta->last_tx_rate.idx].bitrate; |
| 374 | } else |
| 375 | sinfo->txrate.mcs = sta->last_tx_rate.idx; |
| 376 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 377 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 378 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 379 | sinfo->filled |= STATION_INFO_LLID | |
| 380 | STATION_INFO_PLID | |
| 381 | STATION_INFO_PLINK_STATE; |
| 382 | |
| 383 | sinfo->llid = le16_to_cpu(sta->llid); |
| 384 | sinfo->plid = le16_to_cpu(sta->plid); |
| 385 | sinfo->plink_state = sta->plink_state; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 386 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 387 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | |
| 391 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 392 | int idx, u8 *mac, struct station_info *sinfo) |
| 393 | { |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 394 | 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] | 395 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 396 | int ret = -ENOENT; |
| 397 | |
| 398 | rcu_read_lock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 399 | |
Johannes Berg | 3b53fde8 | 2009-11-16 12:00:37 +0100 | [diff] [blame] | 400 | sta = sta_info_get_by_idx(sdata, idx); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 401 | if (sta) { |
| 402 | ret = 0; |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 403 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 404 | sta_set_sinfo(sta, sinfo); |
| 405 | } |
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 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 408 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 409 | return ret; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 410 | } |
| 411 | |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 412 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
| 413 | int idx, struct survey_info *survey) |
| 414 | { |
| 415 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 416 | |
| 417 | if (!local->ops->get_survey) |
| 418 | return -EOPNOTSUPP; |
| 419 | |
| 420 | return drv_get_survey(local, idx, survey); |
| 421 | } |
| 422 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 423 | 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] | 424 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 425 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 426 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 427 | struct sta_info *sta; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 428 | int ret = -ENOENT; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 429 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 430 | rcu_read_lock(); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 431 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 432 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 433 | if (sta) { |
| 434 | ret = 0; |
| 435 | sta_set_sinfo(sta, sinfo); |
| 436 | } |
| 437 | |
| 438 | rcu_read_unlock(); |
| 439 | |
| 440 | return ret; |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 441 | } |
| 442 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 443 | /* |
| 444 | * This handles both adding a beacon and setting new beacon info |
| 445 | */ |
| 446 | static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, |
| 447 | struct beacon_parameters *params) |
| 448 | { |
| 449 | struct beacon_data *new, *old; |
| 450 | int new_head_len, new_tail_len; |
| 451 | int size; |
| 452 | int err = -EINVAL; |
| 453 | |
| 454 | old = sdata->u.ap.beacon; |
| 455 | |
| 456 | /* head must not be zero-length */ |
| 457 | if (params->head && !params->head_len) |
| 458 | return -EINVAL; |
| 459 | |
| 460 | /* |
| 461 | * This is a kludge. beacon interval should really be part |
| 462 | * of the beacon information. |
| 463 | */ |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 464 | if (params->interval && |
| 465 | (sdata->vif.bss_conf.beacon_int != params->interval)) { |
| 466 | sdata->vif.bss_conf.beacon_int = params->interval; |
| 467 | ieee80211_bss_info_change_notify(sdata, |
| 468 | BSS_CHANGED_BEACON_INT); |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | /* Need to have a beacon head if we don't have one yet */ |
| 472 | if (!params->head && !old) |
| 473 | return err; |
| 474 | |
| 475 | /* sorry, no way to start beaconing without dtim period */ |
| 476 | if (!params->dtim_period && !old) |
| 477 | return err; |
| 478 | |
| 479 | /* new or old head? */ |
| 480 | if (params->head) |
| 481 | new_head_len = params->head_len; |
| 482 | else |
| 483 | new_head_len = old->head_len; |
| 484 | |
| 485 | /* new or old tail? */ |
| 486 | if (params->tail || !old) |
| 487 | /* params->tail_len will be zero for !params->tail */ |
| 488 | new_tail_len = params->tail_len; |
| 489 | else |
| 490 | new_tail_len = old->tail_len; |
| 491 | |
| 492 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 493 | |
| 494 | new = kzalloc(size, GFP_KERNEL); |
| 495 | if (!new) |
| 496 | return -ENOMEM; |
| 497 | |
| 498 | /* start filling the new info now */ |
| 499 | |
| 500 | /* new or old dtim period? */ |
| 501 | if (params->dtim_period) |
| 502 | new->dtim_period = params->dtim_period; |
| 503 | else |
| 504 | new->dtim_period = old->dtim_period; |
| 505 | |
| 506 | /* |
| 507 | * pointers go into the block we allocated, |
| 508 | * memory is | beacon_data | head | tail | |
| 509 | */ |
| 510 | new->head = ((u8 *) new) + sizeof(*new); |
| 511 | new->tail = new->head + new_head_len; |
| 512 | new->head_len = new_head_len; |
| 513 | new->tail_len = new_tail_len; |
| 514 | |
| 515 | /* copy in head */ |
| 516 | if (params->head) |
| 517 | memcpy(new->head, params->head, new_head_len); |
| 518 | else |
| 519 | memcpy(new->head, old->head, new_head_len); |
| 520 | |
| 521 | /* copy in optional tail */ |
| 522 | if (params->tail) |
| 523 | memcpy(new->tail, params->tail, new_tail_len); |
| 524 | else |
| 525 | if (old) |
| 526 | memcpy(new->tail, old->tail, new_tail_len); |
| 527 | |
Johannes Berg | 19885c4 | 2010-02-05 11:45:06 +0100 | [diff] [blame] | 528 | sdata->vif.bss_conf.dtim_period = new->dtim_period; |
| 529 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 530 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
| 531 | |
| 532 | synchronize_rcu(); |
| 533 | |
| 534 | kfree(old); |
| 535 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 536 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
| 537 | BSS_CHANGED_BEACON); |
| 538 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 542 | struct beacon_parameters *params) |
| 543 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 544 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 545 | struct beacon_data *old; |
| 546 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 547 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 548 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 549 | old = sdata->u.ap.beacon; |
| 550 | |
| 551 | if (old) |
| 552 | return -EALREADY; |
| 553 | |
| 554 | return ieee80211_config_beacon(sdata, params); |
| 555 | } |
| 556 | |
| 557 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 558 | struct beacon_parameters *params) |
| 559 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 560 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 561 | struct beacon_data *old; |
| 562 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 563 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 564 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 565 | old = sdata->u.ap.beacon; |
| 566 | |
| 567 | if (!old) |
| 568 | return -ENOENT; |
| 569 | |
| 570 | return ieee80211_config_beacon(sdata, params); |
| 571 | } |
| 572 | |
| 573 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) |
| 574 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 575 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 576 | struct beacon_data *old; |
| 577 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 578 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 579 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 580 | old = sdata->u.ap.beacon; |
| 581 | |
| 582 | if (!old) |
| 583 | return -ENOENT; |
| 584 | |
| 585 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); |
| 586 | synchronize_rcu(); |
| 587 | kfree(old); |
| 588 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 589 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
| 590 | return 0; |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 591 | } |
| 592 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 593 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 594 | struct iapp_layer2_update { |
| 595 | u8 da[ETH_ALEN]; /* broadcast */ |
| 596 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 597 | __be16 len; /* 6 */ |
| 598 | u8 dsap; /* 0 */ |
| 599 | u8 ssap; /* 0 */ |
| 600 | u8 control; |
| 601 | u8 xid_info[3]; |
| 602 | } __attribute__ ((packed)); |
| 603 | |
| 604 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 605 | { |
| 606 | struct iapp_layer2_update *msg; |
| 607 | struct sk_buff *skb; |
| 608 | |
| 609 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 610 | * bridge devices */ |
| 611 | |
| 612 | skb = dev_alloc_skb(sizeof(*msg)); |
| 613 | if (!skb) |
| 614 | return; |
| 615 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 616 | |
| 617 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 618 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 619 | |
| 620 | memset(msg->da, 0xff, ETH_ALEN); |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 621 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 622 | msg->len = htons(6); |
| 623 | msg->dsap = 0; |
| 624 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 625 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 626 | * F=0 (no poll command; unsolicited frame) */ |
| 627 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 628 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 629 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 630 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 631 | skb->dev = sta->sdata->dev; |
| 632 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 633 | memset(skb->cb, 0, sizeof(skb->cb)); |
| 634 | netif_rx(skb); |
| 635 | } |
| 636 | |
| 637 | static void sta_apply_parameters(struct ieee80211_local *local, |
| 638 | struct sta_info *sta, |
| 639 | struct station_parameters *params) |
| 640 | { |
| 641 | u32 rates; |
| 642 | int i, j; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 643 | struct ieee80211_supported_band *sband; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 644 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 645 | u32 mask, set; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 646 | |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 647 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 648 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 649 | spin_lock_bh(&sta->lock); |
| 650 | mask = params->sta_flags_mask; |
| 651 | set = params->sta_flags_set; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 652 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 653 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 654 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 655 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 656 | sta->flags |= WLAN_STA_AUTHORIZED; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 657 | } |
| 658 | |
Johannes Berg | eccb8e8 | 2009-05-11 21:57:56 +0300 | [diff] [blame] | 659 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
| 660 | sta->flags &= ~WLAN_STA_SHORT_PREAMBLE; |
| 661 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
| 662 | sta->flags |= WLAN_STA_SHORT_PREAMBLE; |
| 663 | } |
| 664 | |
| 665 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
| 666 | sta->flags &= ~WLAN_STA_WME; |
| 667 | if (set & BIT(NL80211_STA_FLAG_WME)) |
| 668 | sta->flags |= WLAN_STA_WME; |
| 669 | } |
| 670 | |
| 671 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
| 672 | sta->flags &= ~WLAN_STA_MFP; |
| 673 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
| 674 | sta->flags |= WLAN_STA_MFP; |
| 675 | } |
| 676 | spin_unlock_bh(&sta->lock); |
| 677 | |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 678 | /* |
Johannes Berg | 51b50fb | 2009-05-24 16:42:30 +0200 | [diff] [blame] | 679 | * cfg80211 validates this (1-2007) and allows setting the AID |
| 680 | * only when creating a new station entry |
| 681 | */ |
| 682 | if (params->aid) |
| 683 | sta->sta.aid = params->aid; |
| 684 | |
| 685 | /* |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 686 | * FIXME: updating the following information is racy when this |
| 687 | * function is called from ieee80211_change_station(). |
| 688 | * However, all this information should be static so |
| 689 | * maybe we should just reject attemps to change it. |
| 690 | */ |
| 691 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 692 | if (params->listen_interval >= 0) |
| 693 | sta->listen_interval = params->listen_interval; |
| 694 | |
| 695 | if (params->supported_rates) { |
| 696 | rates = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 697 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 698 | for (i = 0; i < params->supported_rates_len; i++) { |
| 699 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 700 | for (j = 0; j < sband->n_bitrates; j++) { |
| 701 | if (sband->bitrates[j].bitrate == rate) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 702 | rates |= BIT(j); |
| 703 | } |
| 704 | } |
Johannes Berg | 323ce79 | 2008-09-11 02:45:11 +0200 | [diff] [blame] | 705 | sta->sta.supp_rates[local->oper_channel->band] = rates; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 706 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 707 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 708 | if (params->ht_capa) |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 709 | ieee80211_ht_cap_ie_to_sta_ht_cap(sband, |
| 710 | params->ht_capa, |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 711 | &sta->sta.ht_cap); |
Jouni Malinen | 36aedc90 | 2008-08-25 11:58:58 +0300 | [diff] [blame] | 712 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 713 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 714 | switch (params->plink_action) { |
| 715 | case PLINK_ACTION_OPEN: |
| 716 | mesh_plink_open(sta); |
| 717 | break; |
| 718 | case PLINK_ACTION_BLOCK: |
| 719 | mesh_plink_block(sta); |
| 720 | break; |
| 721 | } |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame] | 722 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 726 | u8 *mac, struct station_parameters *params) |
| 727 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 728 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 729 | struct sta_info *sta; |
| 730 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 731 | int err; |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 732 | int layer2_update; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 733 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 734 | if (params->vlan) { |
| 735 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 736 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 737 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 738 | sdata->vif.type != NL80211_IFTYPE_AP) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 739 | return -EINVAL; |
| 740 | } else |
| 741 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 742 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 743 | if (compare_ether_addr(mac, sdata->vif.addr) == 0) |
Johannes Berg | 03e4497 | 2008-02-27 09:56:40 +0100 | [diff] [blame] | 744 | return -EINVAL; |
| 745 | |
| 746 | if (is_multicast_ether_addr(mac)) |
| 747 | return -EINVAL; |
| 748 | |
| 749 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 750 | if (!sta) |
| 751 | return -ENOMEM; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 752 | |
| 753 | sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 754 | |
| 755 | sta_apply_parameters(local, sta, params); |
| 756 | |
Johannes Berg | 4b7679a | 2008-09-18 18:14:18 +0200 | [diff] [blame] | 757 | rate_control_rate_init(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 758 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 759 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
| 760 | sdata->vif.type == NL80211_IFTYPE_AP; |
| 761 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 762 | err = sta_info_insert_rcu(sta); |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 763 | if (err) { |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 764 | rcu_read_unlock(); |
| 765 | return err; |
| 766 | } |
| 767 | |
Jouni Malinen | b8d476c | 2008-12-12 17:08:31 +0200 | [diff] [blame] | 768 | if (layer2_update) |
Johannes Berg | 73651ee | 2008-02-25 16:27:47 +0100 | [diff] [blame] | 769 | ieee80211_send_layer2_update(sta); |
| 770 | |
| 771 | rcu_read_unlock(); |
| 772 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 777 | u8 *mac) |
| 778 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 779 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 780 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 781 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 782 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 783 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 784 | if (mac) |
| 785 | return sta_info_destroy_addr_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 786 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 787 | sta_info_flush(local, sdata); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | static int ieee80211_change_station(struct wiphy *wiphy, |
| 792 | struct net_device *dev, |
| 793 | u8 *mac, |
| 794 | struct station_parameters *params) |
| 795 | { |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 796 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 797 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 798 | struct sta_info *sta; |
| 799 | struct ieee80211_sub_if_data *vlansdata; |
| 800 | |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 801 | rcu_read_lock(); |
| 802 | |
Felix Fietkau | 0e5ded5 | 2010-01-08 18:10:58 +0100 | [diff] [blame] | 803 | sta = sta_info_get_bss(sdata, mac); |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 804 | if (!sta) { |
| 805 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 806 | return -ENOENT; |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 807 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 808 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 809 | if (params->vlan && params->vlan != sta->sdata->dev) { |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 810 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 811 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 812 | if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
| 813 | vlansdata->vif.type != NL80211_IFTYPE_AP) { |
Johannes Berg | 98dd6a5 | 2008-04-10 15:36:09 +0200 | [diff] [blame] | 814 | rcu_read_unlock(); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 815 | return -EINVAL; |
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 | 9bc383d | 2009-11-19 11:55:19 +0100 | [diff] [blame] | 818 | if (params->vlan->ieee80211_ptr->use_4addr) { |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 819 | if (vlansdata->u.vlan.sta) { |
| 820 | rcu_read_unlock(); |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 821 | return -EBUSY; |
Johannes Berg | 3305443 | 2009-11-20 10:09:14 +0100 | [diff] [blame] | 822 | } |
Felix Fietkau | f14543ee | 2009-11-10 20:10:05 +0100 | [diff] [blame] | 823 | |
| 824 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
| 825 | } |
| 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_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 843 | struct mesh_path *mpath; |
| 844 | struct sta_info *sta; |
| 845 | int err; |
| 846 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 847 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 848 | |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 849 | rcu_read_lock(); |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 850 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 851 | if (!sta) { |
| 852 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 853 | return -ENOENT; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 854 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 855 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 856 | err = mesh_path_add(dst, sdata); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 857 | if (err) { |
| 858 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 859 | return err; |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 860 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 861 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 862 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 863 | if (!mpath) { |
| 864 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 865 | return -ENXIO; |
| 866 | } |
| 867 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 868 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 869 | rcu_read_unlock(); |
| 870 | return 0; |
| 871 | } |
| 872 | |
| 873 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 874 | u8 *dst) |
| 875 | { |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 876 | 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] | 877 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 878 | if (dst) |
| 879 | return mesh_path_del(dst, sdata); |
| 880 | |
| 881 | mesh_path_flush(sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 886 | struct net_device *dev, |
| 887 | u8 *dst, u8 *next_hop) |
| 888 | { |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 889 | struct ieee80211_sub_if_data *sdata; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 890 | struct mesh_path *mpath; |
| 891 | struct sta_info *sta; |
| 892 | |
Johannes Berg | 14db74b | 2008-07-29 13:22:52 +0200 | [diff] [blame] | 893 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 894 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 895 | rcu_read_lock(); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 896 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 897 | sta = sta_info_get(sdata, next_hop); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 898 | if (!sta) { |
| 899 | rcu_read_unlock(); |
| 900 | return -ENOENT; |
| 901 | } |
| 902 | |
Jasper Bryant-Greene | f698d85 | 2008-08-03 12:04:37 +1200 | [diff] [blame] | 903 | mpath = mesh_path_lookup(dst, sdata); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 904 | if (!mpath) { |
| 905 | rcu_read_unlock(); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 906 | return -ENOENT; |
| 907 | } |
| 908 | |
| 909 | mesh_path_fix_nexthop(mpath, sta); |
Johannes Berg | d0709a6 | 2008-02-25 16:27:46 +0100 | [diff] [blame] | 910 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 911 | rcu_read_unlock(); |
| 912 | return 0; |
| 913 | } |
| 914 | |
| 915 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 916 | struct mpath_info *pinfo) |
| 917 | { |
| 918 | if (mpath->next_hop) |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 919 | memcpy(next_hop, mpath->next_hop->sta.addr, ETH_ALEN); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 920 | else |
| 921 | memset(next_hop, 0, ETH_ALEN); |
| 922 | |
Johannes Berg | f5ea912 | 2009-08-07 16:17:38 +0200 | [diff] [blame] | 923 | pinfo->generation = mesh_paths_generation; |
| 924 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 925 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 926 | MPATH_INFO_SN | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 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; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 934 | pinfo->sn = mpath->sn; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 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; |
Rui Paulo | d19b3bf | 2009-11-09 23:46:55 +0000 | [diff] [blame] | 946 | if (mpath->flags & MESH_PATH_SN_VALID) |
| 947 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 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; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1020 | struct ieee80211_if_mesh *ifmsh; |
| 1021 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1022 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1023 | ifmsh = &sdata->u.mesh; |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1024 | |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1025 | /* Set the config options which we are interested in setting */ |
| 1026 | conf = &(sdata->u.mesh.mshcfg); |
| 1027 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) |
| 1028 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; |
| 1029 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) |
| 1030 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; |
| 1031 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) |
| 1032 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; |
| 1033 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) |
| 1034 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; |
| 1035 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) |
| 1036 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; |
| 1037 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) |
| 1038 | conf->dot11MeshTTL = nconf->dot11MeshTTL; |
| 1039 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) |
| 1040 | conf->auto_open_plinks = nconf->auto_open_plinks; |
| 1041 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
| 1042 | conf->dot11MeshHWMPmaxPREQretries = |
| 1043 | nconf->dot11MeshHWMPmaxPREQretries; |
| 1044 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) |
| 1045 | conf->path_refresh_time = nconf->path_refresh_time; |
| 1046 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) |
| 1047 | conf->min_discovery_timeout = nconf->min_discovery_timeout; |
| 1048 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) |
| 1049 | conf->dot11MeshHWMPactivePathTimeout = |
| 1050 | nconf->dot11MeshHWMPactivePathTimeout; |
| 1051 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) |
| 1052 | conf->dot11MeshHWMPpreqMinInterval = |
| 1053 | nconf->dot11MeshHWMPpreqMinInterval; |
| 1054 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
| 1055 | mask)) |
| 1056 | conf->dot11MeshHWMPnetDiameterTraversalTime = |
| 1057 | nconf->dot11MeshHWMPnetDiameterTraversalTime; |
Rui Paulo | 63c5723 | 2009-11-09 23:46:57 +0000 | [diff] [blame] | 1058 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
| 1059 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; |
| 1060 | ieee80211_mesh_root_setup(ifmsh); |
| 1061 | } |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1062 | return 0; |
| 1063 | } |
| 1064 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1065 | #endif |
| 1066 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1067 | static int ieee80211_change_bss(struct wiphy *wiphy, |
| 1068 | struct net_device *dev, |
| 1069 | struct bss_parameters *params) |
| 1070 | { |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1071 | struct ieee80211_sub_if_data *sdata; |
| 1072 | u32 changed = 0; |
| 1073 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1074 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1075 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1076 | if (params->use_cts_prot >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1077 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1078 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
| 1079 | } |
| 1080 | if (params->use_short_preamble >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1081 | sdata->vif.bss_conf.use_short_preamble = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1082 | params->use_short_preamble; |
| 1083 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
| 1084 | } |
Felix Fietkau | 43d3534 | 2010-01-15 03:00:48 +0100 | [diff] [blame] | 1085 | |
| 1086 | if (!sdata->vif.bss_conf.use_short_slot && |
| 1087 | sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) { |
| 1088 | sdata->vif.bss_conf.use_short_slot = true; |
| 1089 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1090 | } |
| 1091 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1092 | if (params->use_short_slot_time >= 0) { |
Johannes Berg | bda3933 | 2008-10-11 01:51:51 +0200 | [diff] [blame] | 1093 | sdata->vif.bss_conf.use_short_slot = |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1094 | params->use_short_slot_time; |
| 1095 | changed |= BSS_CHANGED_ERP_SLOT; |
| 1096 | } |
| 1097 | |
Jouni Malinen | 90c97a0 | 2008-10-30 16:59:22 +0200 | [diff] [blame] | 1098 | if (params->basic_rates) { |
| 1099 | int i, j; |
| 1100 | u32 rates = 0; |
| 1101 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1102 | struct ieee80211_supported_band *sband = |
| 1103 | wiphy->bands[local->oper_channel->band]; |
| 1104 | |
| 1105 | for (i = 0; i < params->basic_rates_len; i++) { |
| 1106 | int rate = (params->basic_rates[i] & 0x7f) * 5; |
| 1107 | for (j = 0; j < sband->n_bitrates; j++) { |
| 1108 | if (sband->bitrates[j].bitrate == rate) |
| 1109 | rates |= BIT(j); |
| 1110 | } |
| 1111 | } |
| 1112 | sdata->vif.bss_conf.basic_rates = rates; |
| 1113 | changed |= BSS_CHANGED_BASIC_RATES; |
| 1114 | } |
| 1115 | |
Felix Fietkau | 7b7b5e5 | 2010-04-27 01:23:36 +0200 | [diff] [blame] | 1116 | if (params->ap_isolate >= 0) { |
| 1117 | if (params->ap_isolate) |
| 1118 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1119 | else |
| 1120 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; |
| 1121 | } |
| 1122 | |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1123 | ieee80211_bss_info_change_notify(sdata, changed); |
| 1124 | |
| 1125 | return 0; |
| 1126 | } |
| 1127 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1128 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
| 1129 | struct ieee80211_txq_params *params) |
| 1130 | { |
| 1131 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1132 | struct ieee80211_tx_queue_params p; |
| 1133 | |
| 1134 | if (!local->ops->conf_tx) |
| 1135 | return -EOPNOTSUPP; |
| 1136 | |
| 1137 | memset(&p, 0, sizeof(p)); |
| 1138 | p.aifs = params->aifs; |
| 1139 | p.cw_max = params->cwmax; |
| 1140 | p.cw_min = params->cwmin; |
| 1141 | p.txop = params->txop; |
Kalle Valo | ab13315 | 2010-01-12 10:42:31 +0200 | [diff] [blame] | 1142 | |
| 1143 | /* |
| 1144 | * Setting tx queue params disables u-apsd because it's only |
| 1145 | * called in master mode. |
| 1146 | */ |
| 1147 | p.uapsd = false; |
| 1148 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1149 | if (drv_conf_tx(local, params->queue, &p)) { |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1150 | printk(KERN_DEBUG "%s: failed to set TX queue " |
Johannes Berg | 0bffe40 | 2009-06-09 16:18:32 +0200 | [diff] [blame] | 1151 | "parameters for queue %d\n", |
| 1152 | wiphy_name(local->hw.wiphy), params->queue); |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1153 | return -EINVAL; |
| 1154 | } |
| 1155 | |
Stanislaw Gruszka | 0af26b2 | 2010-03-29 12:18:36 +0200 | [diff] [blame] | 1156 | /* enable WMM or activate new settings */ |
| 1157 | local->hw.conf.flags |= IEEE80211_CONF_QOS; |
| 1158 | drv_config(local, IEEE80211_CONF_CHANGE_QOS); |
| 1159 | |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1160 | return 0; |
| 1161 | } |
| 1162 | |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1163 | static int ieee80211_set_channel(struct wiphy *wiphy, |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1164 | struct net_device *netdev, |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1165 | struct ieee80211_channel *chan, |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 1166 | enum nl80211_channel_type channel_type) |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1167 | { |
| 1168 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame^] | 1169 | struct ieee80211_sub_if_data *sdata = NULL; |
| 1170 | |
| 1171 | if (netdev) |
| 1172 | sdata = IEEE80211_DEV_TO_SUB_IF(netdev); |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1173 | |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1174 | switch (ieee80211_get_channel_mode(local, NULL)) { |
| 1175 | case CHAN_MODE_HOPPING: |
| 1176 | return -EBUSY; |
| 1177 | case CHAN_MODE_FIXED: |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame^] | 1178 | if (local->oper_channel != chan) |
| 1179 | return -EBUSY; |
| 1180 | if (!sdata && local->_oper_channel_type == channel_type) |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1181 | return 0; |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame^] | 1182 | break; |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1183 | case CHAN_MODE_UNDEFINED: |
| 1184 | break; |
| 1185 | } |
| 1186 | |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1187 | local->oper_channel = chan; |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1188 | |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame^] | 1189 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) |
| 1190 | return -EBUSY; |
| 1191 | |
| 1192 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
| 1193 | if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) |
| 1194 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); |
| 1195 | |
| 1196 | return 0; |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1197 | } |
| 1198 | |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1199 | #ifdef CONFIG_PM |
| 1200 | static int ieee80211_suspend(struct wiphy *wiphy) |
| 1201 | { |
| 1202 | return __ieee80211_suspend(wiphy_priv(wiphy)); |
| 1203 | } |
| 1204 | |
| 1205 | static int ieee80211_resume(struct wiphy *wiphy) |
| 1206 | { |
| 1207 | return __ieee80211_resume(wiphy_priv(wiphy)); |
| 1208 | } |
| 1209 | #else |
| 1210 | #define ieee80211_suspend NULL |
| 1211 | #define ieee80211_resume NULL |
| 1212 | #endif |
| 1213 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1214 | static int ieee80211_scan(struct wiphy *wiphy, |
| 1215 | struct net_device *dev, |
| 1216 | struct cfg80211_scan_request *req) |
| 1217 | { |
| 1218 | struct ieee80211_sub_if_data *sdata; |
| 1219 | |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1220 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1221 | |
| 1222 | if (sdata->vif.type != NL80211_IFTYPE_STATION && |
| 1223 | sdata->vif.type != NL80211_IFTYPE_ADHOC && |
Jouni Malinen | 357303e | 2009-04-16 18:44:53 +0300 | [diff] [blame] | 1224 | sdata->vif.type != NL80211_IFTYPE_MESH_POINT && |
| 1225 | (sdata->vif.type != NL80211_IFTYPE_AP || sdata->u.ap.beacon)) |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1226 | return -EOPNOTSUPP; |
| 1227 | |
| 1228 | return ieee80211_request_scan(sdata, req); |
| 1229 | } |
| 1230 | |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1231 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
| 1232 | struct cfg80211_auth_request *req) |
| 1233 | { |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1234 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
| 1238 | struct cfg80211_assoc_request *req) |
| 1239 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1240 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1241 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1242 | |
| 1243 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1244 | case CHAN_MODE_HOPPING: |
| 1245 | return -EBUSY; |
| 1246 | case CHAN_MODE_FIXED: |
| 1247 | if (local->oper_channel == req->bss->channel) |
| 1248 | break; |
| 1249 | return -EBUSY; |
| 1250 | case CHAN_MODE_UNDEFINED: |
| 1251 | break; |
| 1252 | } |
| 1253 | |
Johannes Berg | 77fdaa1 | 2009-07-07 03:45:17 +0200 | [diff] [blame] | 1254 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1255 | } |
| 1256 | |
| 1257 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1258 | struct cfg80211_deauth_request *req, |
| 1259 | void *cookie) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1260 | { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1261 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), |
| 1262 | req, cookie); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1266 | struct cfg80211_disassoc_request *req, |
| 1267 | void *cookie) |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1268 | { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1269 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), |
| 1270 | req, cookie); |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1271 | } |
| 1272 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1273 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 1274 | struct cfg80211_ibss_params *params) |
| 1275 | { |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1276 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1277 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1278 | |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 1279 | switch (ieee80211_get_channel_mode(local, sdata)) { |
| 1280 | case CHAN_MODE_HOPPING: |
| 1281 | return -EBUSY; |
| 1282 | case CHAN_MODE_FIXED: |
| 1283 | if (!params->channel_fixed) |
| 1284 | return -EBUSY; |
| 1285 | if (local->oper_channel == params->channel) |
| 1286 | break; |
| 1287 | return -EBUSY; |
| 1288 | case CHAN_MODE_UNDEFINED: |
| 1289 | break; |
| 1290 | } |
| 1291 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1292 | return ieee80211_ibss_join(sdata, params); |
| 1293 | } |
| 1294 | |
| 1295 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 1296 | { |
| 1297 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1298 | |
| 1299 | return ieee80211_ibss_leave(sdata); |
| 1300 | } |
| 1301 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1302 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 1303 | { |
| 1304 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1305 | int err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1306 | |
Lukáš Turek | 310bc67 | 2009-12-21 22:50:48 +0100 | [diff] [blame] | 1307 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { |
| 1308 | err = drv_set_coverage_class(local, wiphy->coverage_class); |
| 1309 | |
| 1310 | if (err) |
| 1311 | return err; |
| 1312 | } |
| 1313 | |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1314 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1315 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1316 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 1317 | if (err) |
| 1318 | return err; |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1319 | } |
| 1320 | |
| 1321 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 1322 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
| 1323 | if (changed & WIPHY_PARAM_RETRY_LONG) |
| 1324 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
| 1325 | if (changed & |
| 1326 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) |
| 1327 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); |
| 1328 | |
| 1329 | return 0; |
| 1330 | } |
| 1331 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1332 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
| 1333 | enum tx_power_setting type, int dbm) |
| 1334 | { |
| 1335 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1336 | struct ieee80211_channel *chan = local->hw.conf.channel; |
| 1337 | u32 changes = 0; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1338 | |
| 1339 | switch (type) { |
| 1340 | case TX_POWER_AUTOMATIC: |
| 1341 | local->user_power_level = -1; |
| 1342 | break; |
| 1343 | case TX_POWER_LIMITED: |
| 1344 | if (dbm < 0) |
| 1345 | return -EINVAL; |
| 1346 | local->user_power_level = dbm; |
| 1347 | break; |
| 1348 | case TX_POWER_FIXED: |
| 1349 | if (dbm < 0) |
| 1350 | return -EINVAL; |
| 1351 | /* TODO: move to cfg80211 when it knows the channel */ |
| 1352 | if (dbm > chan->max_power) |
| 1353 | return -EINVAL; |
| 1354 | local->user_power_level = dbm; |
| 1355 | break; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1356 | } |
| 1357 | |
| 1358 | ieee80211_hw_config(local, changes); |
| 1359 | |
| 1360 | return 0; |
| 1361 | } |
| 1362 | |
| 1363 | static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm) |
| 1364 | { |
| 1365 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1366 | |
| 1367 | *dbm = local->hw.conf.power_level; |
| 1368 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1369 | return 0; |
| 1370 | } |
| 1371 | |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1372 | static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, |
| 1373 | u8 *addr) |
| 1374 | { |
| 1375 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1376 | |
| 1377 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); |
| 1378 | |
| 1379 | return 0; |
| 1380 | } |
| 1381 | |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 1382 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
| 1383 | { |
| 1384 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1385 | |
| 1386 | drv_rfkill_poll(local); |
| 1387 | } |
| 1388 | |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1389 | #ifdef CONFIG_NL80211_TESTMODE |
Johannes Berg | 99783e2 | 2009-07-07 03:54:43 +0200 | [diff] [blame] | 1390 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len) |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1391 | { |
| 1392 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 1393 | |
| 1394 | if (!local->ops->testmode_cmd) |
| 1395 | return -EOPNOTSUPP; |
| 1396 | |
| 1397 | return local->ops->testmode_cmd(&local->hw, data, len); |
| 1398 | } |
| 1399 | #endif |
| 1400 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1401 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, |
| 1402 | enum ieee80211_smps_mode smps_mode) |
| 1403 | { |
| 1404 | const u8 *ap; |
| 1405 | enum ieee80211_smps_mode old_req; |
| 1406 | int err; |
| 1407 | |
| 1408 | old_req = sdata->u.mgd.req_smps; |
| 1409 | sdata->u.mgd.req_smps = smps_mode; |
| 1410 | |
| 1411 | if (old_req == smps_mode && |
| 1412 | smps_mode != IEEE80211_SMPS_AUTOMATIC) |
| 1413 | return 0; |
| 1414 | |
| 1415 | /* |
| 1416 | * If not associated, or current association is not an HT |
| 1417 | * association, there's no need to send an action frame. |
| 1418 | */ |
| 1419 | if (!sdata->u.mgd.associated || |
Johannes Berg | 0aaffa9 | 2010-05-05 15:28:27 +0200 | [diff] [blame^] | 1420 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) { |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1421 | mutex_lock(&sdata->local->iflist_mtx); |
| 1422 | ieee80211_recalc_smps(sdata->local, sdata); |
| 1423 | mutex_unlock(&sdata->local->iflist_mtx); |
| 1424 | return 0; |
| 1425 | } |
| 1426 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 1427 | ap = sdata->u.mgd.associated->bssid; |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1428 | |
| 1429 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { |
| 1430 | if (sdata->u.mgd.powersave) |
| 1431 | smps_mode = IEEE80211_SMPS_DYNAMIC; |
| 1432 | else |
| 1433 | smps_mode = IEEE80211_SMPS_OFF; |
| 1434 | } |
| 1435 | |
| 1436 | /* send SM PS frame to AP */ |
| 1437 | err = ieee80211_send_smps_action(sdata, smps_mode, |
| 1438 | ap, ap); |
| 1439 | if (err) |
| 1440 | sdata->u.mgd.req_smps = old_req; |
| 1441 | |
| 1442 | return err; |
| 1443 | } |
| 1444 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1445 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 1446 | bool enabled, int timeout) |
| 1447 | { |
| 1448 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1449 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1450 | struct ieee80211_conf *conf = &local->hw.conf; |
| 1451 | |
Benoit Papillault | e5de30c | 2010-01-15 12:21:37 +0100 | [diff] [blame] | 1452 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 1453 | return -EOPNOTSUPP; |
| 1454 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1455 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
| 1456 | return -EOPNOTSUPP; |
| 1457 | |
| 1458 | if (enabled == sdata->u.mgd.powersave && |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1459 | timeout == conf->dynamic_ps_forced_timeout) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1460 | return 0; |
| 1461 | |
| 1462 | sdata->u.mgd.powersave = enabled; |
Juuso Oikarinen | 195e294 | 2010-04-27 12:47:40 +0300 | [diff] [blame] | 1463 | conf->dynamic_ps_forced_timeout = timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1464 | |
Johannes Berg | 0f78231 | 2009-12-01 13:37:02 +0100 | [diff] [blame] | 1465 | /* no change, but if automatic follow powersave */ |
| 1466 | mutex_lock(&sdata->u.mgd.mtx); |
| 1467 | __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps); |
| 1468 | mutex_unlock(&sdata->u.mgd.mtx); |
| 1469 | |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1470 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
| 1471 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
| 1472 | |
| 1473 | ieee80211_recalc_ps(local, -1); |
| 1474 | |
| 1475 | return 0; |
| 1476 | } |
| 1477 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1478 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
| 1479 | struct net_device *dev, |
| 1480 | s32 rssi_thold, u32 rssi_hyst) |
| 1481 | { |
| 1482 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1483 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 1484 | struct ieee80211_vif *vif = &sdata->vif; |
| 1485 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 1486 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1487 | if (rssi_thold == bss_conf->cqm_rssi_thold && |
| 1488 | rssi_hyst == bss_conf->cqm_rssi_hyst) |
| 1489 | return 0; |
| 1490 | |
| 1491 | bss_conf->cqm_rssi_thold = rssi_thold; |
| 1492 | bss_conf->cqm_rssi_hyst = rssi_hyst; |
| 1493 | |
Jouni Malinen | 17e4ec1 | 2010-03-29 23:28:30 -0700 | [diff] [blame] | 1494 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) { |
| 1495 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
| 1496 | return -EOPNOTSUPP; |
| 1497 | return 0; |
| 1498 | } |
| 1499 | |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1500 | /* tell the driver upon association, unless already associated */ |
| 1501 | if (sdata->u.mgd.associated) |
| 1502 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); |
| 1503 | |
| 1504 | return 0; |
| 1505 | } |
| 1506 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1507 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
| 1508 | struct net_device *dev, |
| 1509 | const u8 *addr, |
| 1510 | const struct cfg80211_bitrate_mask *mask) |
| 1511 | { |
| 1512 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1513 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
Johannes Berg | 2c7e6bc | 2009-12-04 09:26:38 +0100 | [diff] [blame] | 1514 | int i; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1515 | |
Johannes Berg | 2c7e6bc | 2009-12-04 09:26:38 +0100 | [diff] [blame] | 1516 | /* |
| 1517 | * This _could_ be supported by providing a hook for |
| 1518 | * drivers for this function, but at this point it |
| 1519 | * doesn't seem worth bothering. |
| 1520 | */ |
| 1521 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) |
| 1522 | return -EOPNOTSUPP; |
| 1523 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1524 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1525 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 1526 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1527 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1528 | return 0; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1529 | } |
| 1530 | |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1531 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
| 1532 | struct net_device *dev, |
| 1533 | struct ieee80211_channel *chan, |
| 1534 | enum nl80211_channel_type channel_type, |
| 1535 | unsigned int duration, |
| 1536 | u64 *cookie) |
| 1537 | { |
| 1538 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1539 | |
| 1540 | return ieee80211_wk_remain_on_channel(sdata, chan, channel_type, |
| 1541 | duration, cookie); |
| 1542 | } |
| 1543 | |
| 1544 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, |
| 1545 | struct net_device *dev, |
| 1546 | u64 cookie) |
| 1547 | { |
| 1548 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 1549 | |
| 1550 | return ieee80211_wk_cancel_remain_on_channel(sdata, cookie); |
| 1551 | } |
| 1552 | |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 1553 | static int ieee80211_action(struct wiphy *wiphy, struct net_device *dev, |
| 1554 | struct ieee80211_channel *chan, |
| 1555 | enum nl80211_channel_type channel_type, |
| 1556 | const u8 *buf, size_t len, u64 *cookie) |
| 1557 | { |
| 1558 | return ieee80211_mgd_action(IEEE80211_DEV_TO_SUB_IF(dev), chan, |
| 1559 | channel_type, buf, len, cookie); |
| 1560 | } |
| 1561 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1562 | struct cfg80211_ops mac80211_config_ops = { |
| 1563 | .add_virtual_intf = ieee80211_add_iface, |
| 1564 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 1565 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 1566 | .add_key = ieee80211_add_key, |
| 1567 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 1568 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 1569 | .set_default_key = ieee80211_config_default_key, |
Jouni Malinen | 3cfcf6ac | 2009-01-08 13:32:02 +0200 | [diff] [blame] | 1570 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 1571 | .add_beacon = ieee80211_add_beacon, |
| 1572 | .set_beacon = ieee80211_set_beacon, |
| 1573 | .del_beacon = ieee80211_del_beacon, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 1574 | .add_station = ieee80211_add_station, |
| 1575 | .del_station = ieee80211_del_station, |
| 1576 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 1577 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1578 | .dump_station = ieee80211_dump_station, |
Holger Schurig | 1289723 | 2010-04-19 10:23:57 +0200 | [diff] [blame] | 1579 | .dump_survey = ieee80211_dump_survey, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1580 | #ifdef CONFIG_MAC80211_MESH |
| 1581 | .add_mpath = ieee80211_add_mpath, |
| 1582 | .del_mpath = ieee80211_del_mpath, |
| 1583 | .change_mpath = ieee80211_change_mpath, |
| 1584 | .get_mpath = ieee80211_get_mpath, |
| 1585 | .dump_mpath = ieee80211_dump_mpath, |
colin@cozybit.com | 93da9cc | 2008-10-21 12:03:48 -0700 | [diff] [blame] | 1586 | .set_mesh_params = ieee80211_set_mesh_params, |
| 1587 | .get_mesh_params = ieee80211_get_mesh_params, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 1588 | #endif |
Jouni Malinen | 9f1ba90 | 2008-08-07 20:07:01 +0300 | [diff] [blame] | 1589 | .change_bss = ieee80211_change_bss, |
Jouni Malinen | 3188848 | 2008-10-30 16:59:24 +0200 | [diff] [blame] | 1590 | .set_txq_params = ieee80211_set_txq_params, |
Jouni Malinen | 72bdcf3 | 2008-11-26 16:15:24 +0200 | [diff] [blame] | 1591 | .set_channel = ieee80211_set_channel, |
Bob Copeland | 665af4f | 2009-01-19 11:20:53 -0500 | [diff] [blame] | 1592 | .suspend = ieee80211_suspend, |
| 1593 | .resume = ieee80211_resume, |
Johannes Berg | 2a51931 | 2009-02-10 21:25:55 +0100 | [diff] [blame] | 1594 | .scan = ieee80211_scan, |
Jouni Malinen | 636a5d3 | 2009-03-19 13:39:22 +0200 | [diff] [blame] | 1595 | .auth = ieee80211_auth, |
| 1596 | .assoc = ieee80211_assoc, |
| 1597 | .deauth = ieee80211_deauth, |
| 1598 | .disassoc = ieee80211_disassoc, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 1599 | .join_ibss = ieee80211_join_ibss, |
| 1600 | .leave_ibss = ieee80211_leave_ibss, |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 1601 | .set_wiphy_params = ieee80211_set_wiphy_params, |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 1602 | .set_tx_power = ieee80211_set_tx_power, |
| 1603 | .get_tx_power = ieee80211_get_tx_power, |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1604 | .set_wds_peer = ieee80211_set_wds_peer, |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 1605 | .rfkill_poll = ieee80211_rfkill_poll, |
Johannes Berg | aff89a9 | 2009-07-01 21:26:51 +0200 | [diff] [blame] | 1606 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1607 | .set_power_mgmt = ieee80211_set_power_mgmt, |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1608 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
Johannes Berg | b8bc4b0 | 2009-12-23 13:15:42 +0100 | [diff] [blame] | 1609 | .remain_on_channel = ieee80211_remain_on_channel, |
| 1610 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, |
Jouni Malinen | 026331c | 2010-02-15 12:53:10 +0200 | [diff] [blame] | 1611 | .action = ieee80211_action, |
Juuso Oikarinen | a97c13c | 2010-03-23 09:02:34 +0200 | [diff] [blame] | 1612 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1613 | }; |