Jiri Benc | f0706e82 | 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 | f0706e82 | 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 | f0706e82 | 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 | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 14 | #include <net/cfg80211.h> |
| 15 | #include "ieee80211_i.h" |
Michael Wu | e0eb685 | 2007-09-18 17:29:21 -0400 | [diff] [blame] | 16 | #include "cfg.h" |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 17 | #include "ieee80211_rate.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 18 | #include "mesh.h" |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 19 | |
| 20 | #define DEFAULT_RATES 0 |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 21 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 22 | static enum ieee80211_if_types |
| 23 | nl80211_type_to_mac80211_type(enum nl80211_iftype type) |
| 24 | { |
| 25 | switch (type) { |
| 26 | case NL80211_IFTYPE_UNSPECIFIED: |
| 27 | return IEEE80211_IF_TYPE_STA; |
| 28 | case NL80211_IFTYPE_ADHOC: |
| 29 | return IEEE80211_IF_TYPE_IBSS; |
| 30 | case NL80211_IFTYPE_STATION: |
| 31 | return IEEE80211_IF_TYPE_STA; |
| 32 | case NL80211_IFTYPE_MONITOR: |
| 33 | return IEEE80211_IF_TYPE_MNTR; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 34 | #ifdef CONFIG_MAC80211_MESH |
| 35 | case NL80211_IFTYPE_MESH_POINT: |
| 36 | return IEEE80211_IF_TYPE_MESH_POINT; |
| 37 | #endif |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 38 | default: |
| 39 | return IEEE80211_IF_TYPE_INVALID; |
| 40 | } |
| 41 | } |
| 42 | |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 43 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 44 | enum nl80211_iftype type, u32 *flags, |
| 45 | struct vif_params *params) |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 46 | { |
| 47 | struct ieee80211_local *local = wiphy_priv(wiphy); |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 48 | enum ieee80211_if_types itype; |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 49 | struct net_device *dev; |
| 50 | struct ieee80211_sub_if_data *sdata; |
| 51 | int err; |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 52 | |
| 53 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) |
| 54 | return -ENODEV; |
| 55 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 56 | itype = nl80211_type_to_mac80211_type(type); |
| 57 | if (itype == IEEE80211_IF_TYPE_INVALID) |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 58 | return -EINVAL; |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 59 | |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 60 | err = ieee80211_if_add(local->mdev, name, &dev, itype, params); |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 61 | if (err || itype != IEEE80211_IF_TYPE_MNTR || !flags) |
| 62 | return err; |
| 63 | |
| 64 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 65 | sdata->u.mntr_flags = *flags; |
| 66 | return 0; |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) |
| 70 | { |
| 71 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 72 | struct net_device *dev; |
| 73 | char *name; |
| 74 | |
| 75 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) |
| 76 | return -ENODEV; |
| 77 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 78 | /* we're under RTNL */ |
| 79 | dev = __dev_get_by_index(&init_net, ifindex); |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 80 | if (!dev) |
| 81 | return 0; |
| 82 | |
| 83 | name = dev->name; |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 84 | |
| 85 | return ieee80211_if_remove(local->mdev, name, -1); |
| 86 | } |
| 87 | |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 88 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, |
Luis Carlos Cobo | 2ec600d | 2008-02-23 15:17:06 +0100 | [diff] [blame] | 89 | enum nl80211_iftype type, u32 *flags, |
| 90 | struct vif_params *params) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 91 | { |
| 92 | struct ieee80211_local *local = wiphy_priv(wiphy); |
| 93 | struct net_device *dev; |
| 94 | enum ieee80211_if_types itype; |
| 95 | struct ieee80211_sub_if_data *sdata; |
| 96 | |
| 97 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) |
| 98 | return -ENODEV; |
| 99 | |
| 100 | /* we're under RTNL */ |
| 101 | dev = __dev_get_by_index(&init_net, ifindex); |
| 102 | if (!dev) |
| 103 | return -ENODEV; |
| 104 | |
| 105 | if (netif_running(dev)) |
| 106 | return -EBUSY; |
| 107 | |
| 108 | itype = nl80211_type_to_mac80211_type(type); |
| 109 | if (itype == IEEE80211_IF_TYPE_INVALID) |
| 110 | return -EINVAL; |
| 111 | |
| 112 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 113 | |
Johannes Berg | 51fb61e | 2007-12-19 01:31:27 +0100 | [diff] [blame] | 114 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN) |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 115 | return -EOPNOTSUPP; |
| 116 | |
| 117 | ieee80211_if_reinit(dev); |
| 118 | ieee80211_if_set_type(dev, itype); |
| 119 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 120 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len) |
| 121 | ieee80211_if_sta_set_mesh_id(&sdata->u.sta, |
| 122 | params->mesh_id_len, |
| 123 | params->mesh_id); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 124 | |
Michael Wu | 8cc9a73 | 2008-01-31 19:48:23 +0100 | [diff] [blame] | 125 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags) |
| 126 | return 0; |
| 127 | |
| 128 | sdata->u.mntr_flags = *flags; |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 132 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
| 133 | u8 key_idx, u8 *mac_addr, |
| 134 | struct key_params *params) |
| 135 | { |
| 136 | struct ieee80211_sub_if_data *sdata; |
| 137 | struct sta_info *sta = NULL; |
| 138 | enum ieee80211_key_alg alg; |
| 139 | int ret; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 140 | struct ieee80211_key *key; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 141 | |
| 142 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 143 | |
| 144 | switch (params->cipher) { |
| 145 | case WLAN_CIPHER_SUITE_WEP40: |
| 146 | case WLAN_CIPHER_SUITE_WEP104: |
| 147 | alg = ALG_WEP; |
| 148 | break; |
| 149 | case WLAN_CIPHER_SUITE_TKIP: |
| 150 | alg = ALG_TKIP; |
| 151 | break; |
| 152 | case WLAN_CIPHER_SUITE_CCMP: |
| 153 | alg = ALG_CCMP; |
| 154 | break; |
| 155 | default: |
| 156 | return -EINVAL; |
| 157 | } |
| 158 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 159 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key); |
| 160 | if (!key) |
| 161 | return -ENOMEM; |
| 162 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 163 | if (mac_addr) { |
| 164 | sta = sta_info_get(sdata->local, mac_addr); |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 165 | if (!sta) { |
| 166 | ieee80211_key_free(key); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 167 | return -ENOENT; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 168 | } |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 169 | } |
| 170 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 171 | ieee80211_key_link(key, sdata, sta); |
| 172 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 173 | ret = 0; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 174 | |
| 175 | if (sta) |
| 176 | sta_info_put(sta); |
| 177 | |
| 178 | return ret; |
| 179 | } |
| 180 | |
| 181 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
| 182 | u8 key_idx, u8 *mac_addr) |
| 183 | { |
| 184 | struct ieee80211_sub_if_data *sdata; |
| 185 | struct sta_info *sta; |
| 186 | int ret; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 187 | struct ieee80211_key *key; |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 188 | |
| 189 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 190 | |
| 191 | if (mac_addr) { |
| 192 | sta = sta_info_get(sdata->local, mac_addr); |
| 193 | if (!sta) |
| 194 | return -ENOENT; |
| 195 | |
| 196 | ret = 0; |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 197 | if (sta->key) { |
| 198 | key = sta->key; |
| 199 | ieee80211_key_free(key); |
| 200 | WARN_ON(sta->key); |
| 201 | } else |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 202 | ret = -ENOENT; |
| 203 | |
| 204 | sta_info_put(sta); |
| 205 | return ret; |
| 206 | } |
| 207 | |
| 208 | if (!sdata->keys[key_idx]) |
| 209 | return -ENOENT; |
| 210 | |
Johannes Berg | db4d116 | 2008-02-25 16:27:45 +0100 | [diff] [blame] | 211 | key = sdata->keys[key_idx]; |
| 212 | ieee80211_key_free(key); |
| 213 | WARN_ON(sdata->keys[key_idx]); |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 218 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
| 219 | u8 key_idx, u8 *mac_addr, void *cookie, |
| 220 | void (*callback)(void *cookie, |
| 221 | struct key_params *params)) |
| 222 | { |
| 223 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 224 | struct sta_info *sta = NULL; |
| 225 | u8 seq[6] = {0}; |
| 226 | struct key_params params; |
| 227 | struct ieee80211_key *key; |
| 228 | u32 iv32; |
| 229 | u16 iv16; |
| 230 | int err = -ENOENT; |
| 231 | |
| 232 | if (mac_addr) { |
| 233 | sta = sta_info_get(sdata->local, mac_addr); |
| 234 | if (!sta) |
| 235 | goto out; |
| 236 | |
| 237 | key = sta->key; |
| 238 | } else |
| 239 | key = sdata->keys[key_idx]; |
| 240 | |
| 241 | if (!key) |
| 242 | goto out; |
| 243 | |
| 244 | memset(¶ms, 0, sizeof(params)); |
| 245 | |
| 246 | switch (key->conf.alg) { |
| 247 | case ALG_TKIP: |
| 248 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 249 | |
| 250 | iv32 = key->u.tkip.iv32; |
| 251 | iv16 = key->u.tkip.iv16; |
| 252 | |
| 253 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && |
| 254 | sdata->local->ops->get_tkip_seq) |
| 255 | sdata->local->ops->get_tkip_seq( |
| 256 | local_to_hw(sdata->local), |
| 257 | key->conf.hw_key_idx, |
| 258 | &iv32, &iv16); |
| 259 | |
| 260 | seq[0] = iv16 & 0xff; |
| 261 | seq[1] = (iv16 >> 8) & 0xff; |
| 262 | seq[2] = iv32 & 0xff; |
| 263 | seq[3] = (iv32 >> 8) & 0xff; |
| 264 | seq[4] = (iv32 >> 16) & 0xff; |
| 265 | seq[5] = (iv32 >> 24) & 0xff; |
| 266 | params.seq = seq; |
| 267 | params.seq_len = 6; |
| 268 | break; |
| 269 | case ALG_CCMP: |
| 270 | params.cipher = WLAN_CIPHER_SUITE_CCMP; |
| 271 | seq[0] = key->u.ccmp.tx_pn[5]; |
| 272 | seq[1] = key->u.ccmp.tx_pn[4]; |
| 273 | seq[2] = key->u.ccmp.tx_pn[3]; |
| 274 | seq[3] = key->u.ccmp.tx_pn[2]; |
| 275 | seq[4] = key->u.ccmp.tx_pn[1]; |
| 276 | seq[5] = key->u.ccmp.tx_pn[0]; |
| 277 | params.seq = seq; |
| 278 | params.seq_len = 6; |
| 279 | break; |
| 280 | case ALG_WEP: |
| 281 | if (key->conf.keylen == 5) |
| 282 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 283 | else |
| 284 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 285 | break; |
| 286 | } |
| 287 | |
| 288 | params.key = key->conf.key; |
| 289 | params.key_len = key->conf.keylen; |
| 290 | |
| 291 | callback(cookie, ¶ms); |
| 292 | err = 0; |
| 293 | |
| 294 | out: |
| 295 | if (sta) |
| 296 | sta_info_put(sta); |
| 297 | return err; |
| 298 | } |
| 299 | |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 300 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
| 301 | struct net_device *dev, |
| 302 | u8 key_idx) |
| 303 | { |
| 304 | struct ieee80211_sub_if_data *sdata; |
| 305 | |
| 306 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 307 | ieee80211_set_default_key(sdata, key_idx); |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 312 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
| 313 | { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 314 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 315 | |
| 316 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
| 317 | STATION_INFO_RX_BYTES | |
| 318 | STATION_INFO_TX_BYTES; |
| 319 | |
| 320 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); |
| 321 | sinfo->rx_bytes = sta->rx_bytes; |
| 322 | sinfo->tx_bytes = sta->tx_bytes; |
| 323 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 324 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 325 | #ifdef CONFIG_MAC80211_MESH |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 326 | sinfo->filled |= STATION_INFO_LLID | |
| 327 | STATION_INFO_PLID | |
| 328 | STATION_INFO_PLINK_STATE; |
| 329 | |
| 330 | sinfo->llid = le16_to_cpu(sta->llid); |
| 331 | sinfo->plid = le16_to_cpu(sta->plid); |
| 332 | sinfo->plink_state = sta->plink_state; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 333 | #endif |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 334 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | |
| 338 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 339 | int idx, u8 *mac, struct station_info *sinfo) |
| 340 | { |
| 341 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 342 | struct sta_info *sta; |
| 343 | |
| 344 | sta = sta_info_get_by_idx(local, idx, dev); |
| 345 | if (!sta) |
| 346 | return -ENOENT; |
| 347 | |
| 348 | memcpy(mac, sta->addr, ETH_ALEN); |
| 349 | sta_set_sinfo(sta, sinfo); |
| 350 | sta_info_put(sta); |
| 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 355 | 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] | 356 | u8 *mac, struct station_info *sinfo) |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 357 | { |
| 358 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 359 | struct sta_info *sta; |
| 360 | |
| 361 | sta = sta_info_get(local, mac); |
| 362 | if (!sta) |
| 363 | return -ENOENT; |
| 364 | |
| 365 | /* XXX: verify sta->dev == dev */ |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 366 | sta_set_sinfo(sta, sinfo); |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 367 | sta_info_put(sta); |
| 368 | |
| 369 | return 0; |
| 370 | } |
| 371 | |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 372 | /* |
| 373 | * This handles both adding a beacon and setting new beacon info |
| 374 | */ |
| 375 | static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, |
| 376 | struct beacon_parameters *params) |
| 377 | { |
| 378 | struct beacon_data *new, *old; |
| 379 | int new_head_len, new_tail_len; |
| 380 | int size; |
| 381 | int err = -EINVAL; |
| 382 | |
| 383 | old = sdata->u.ap.beacon; |
| 384 | |
| 385 | /* head must not be zero-length */ |
| 386 | if (params->head && !params->head_len) |
| 387 | return -EINVAL; |
| 388 | |
| 389 | /* |
| 390 | * This is a kludge. beacon interval should really be part |
| 391 | * of the beacon information. |
| 392 | */ |
| 393 | if (params->interval) { |
| 394 | sdata->local->hw.conf.beacon_int = params->interval; |
| 395 | if (ieee80211_hw_config(sdata->local)) |
| 396 | return -EINVAL; |
| 397 | /* |
| 398 | * We updated some parameter so if below bails out |
| 399 | * it's not an error. |
| 400 | */ |
| 401 | err = 0; |
| 402 | } |
| 403 | |
| 404 | /* Need to have a beacon head if we don't have one yet */ |
| 405 | if (!params->head && !old) |
| 406 | return err; |
| 407 | |
| 408 | /* sorry, no way to start beaconing without dtim period */ |
| 409 | if (!params->dtim_period && !old) |
| 410 | return err; |
| 411 | |
| 412 | /* new or old head? */ |
| 413 | if (params->head) |
| 414 | new_head_len = params->head_len; |
| 415 | else |
| 416 | new_head_len = old->head_len; |
| 417 | |
| 418 | /* new or old tail? */ |
| 419 | if (params->tail || !old) |
| 420 | /* params->tail_len will be zero for !params->tail */ |
| 421 | new_tail_len = params->tail_len; |
| 422 | else |
| 423 | new_tail_len = old->tail_len; |
| 424 | |
| 425 | size = sizeof(*new) + new_head_len + new_tail_len; |
| 426 | |
| 427 | new = kzalloc(size, GFP_KERNEL); |
| 428 | if (!new) |
| 429 | return -ENOMEM; |
| 430 | |
| 431 | /* start filling the new info now */ |
| 432 | |
| 433 | /* new or old dtim period? */ |
| 434 | if (params->dtim_period) |
| 435 | new->dtim_period = params->dtim_period; |
| 436 | else |
| 437 | new->dtim_period = old->dtim_period; |
| 438 | |
| 439 | /* |
| 440 | * pointers go into the block we allocated, |
| 441 | * memory is | beacon_data | head | tail | |
| 442 | */ |
| 443 | new->head = ((u8 *) new) + sizeof(*new); |
| 444 | new->tail = new->head + new_head_len; |
| 445 | new->head_len = new_head_len; |
| 446 | new->tail_len = new_tail_len; |
| 447 | |
| 448 | /* copy in head */ |
| 449 | if (params->head) |
| 450 | memcpy(new->head, params->head, new_head_len); |
| 451 | else |
| 452 | memcpy(new->head, old->head, new_head_len); |
| 453 | |
| 454 | /* copy in optional tail */ |
| 455 | if (params->tail) |
| 456 | memcpy(new->tail, params->tail, new_tail_len); |
| 457 | else |
| 458 | if (old) |
| 459 | memcpy(new->tail, old->tail, new_tail_len); |
| 460 | |
| 461 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
| 462 | |
| 463 | synchronize_rcu(); |
| 464 | |
| 465 | kfree(old); |
| 466 | |
| 467 | return ieee80211_if_config_beacon(sdata->dev); |
| 468 | } |
| 469 | |
| 470 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 471 | struct beacon_parameters *params) |
| 472 | { |
| 473 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 474 | struct beacon_data *old; |
| 475 | |
| 476 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
| 477 | return -EINVAL; |
| 478 | |
| 479 | old = sdata->u.ap.beacon; |
| 480 | |
| 481 | if (old) |
| 482 | return -EALREADY; |
| 483 | |
| 484 | return ieee80211_config_beacon(sdata, params); |
| 485 | } |
| 486 | |
| 487 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 488 | struct beacon_parameters *params) |
| 489 | { |
| 490 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 491 | struct beacon_data *old; |
| 492 | |
| 493 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
| 494 | return -EINVAL; |
| 495 | |
| 496 | old = sdata->u.ap.beacon; |
| 497 | |
| 498 | if (!old) |
| 499 | return -ENOENT; |
| 500 | |
| 501 | return ieee80211_config_beacon(sdata, params); |
| 502 | } |
| 503 | |
| 504 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) |
| 505 | { |
| 506 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 507 | struct beacon_data *old; |
| 508 | |
| 509 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
| 510 | return -EINVAL; |
| 511 | |
| 512 | old = sdata->u.ap.beacon; |
| 513 | |
| 514 | if (!old) |
| 515 | return -ENOENT; |
| 516 | |
| 517 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); |
| 518 | synchronize_rcu(); |
| 519 | kfree(old); |
| 520 | |
| 521 | return ieee80211_if_config_beacon(dev); |
| 522 | } |
| 523 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 524 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
| 525 | struct iapp_layer2_update { |
| 526 | u8 da[ETH_ALEN]; /* broadcast */ |
| 527 | u8 sa[ETH_ALEN]; /* STA addr */ |
| 528 | __be16 len; /* 6 */ |
| 529 | u8 dsap; /* 0 */ |
| 530 | u8 ssap; /* 0 */ |
| 531 | u8 control; |
| 532 | u8 xid_info[3]; |
| 533 | } __attribute__ ((packed)); |
| 534 | |
| 535 | static void ieee80211_send_layer2_update(struct sta_info *sta) |
| 536 | { |
| 537 | struct iapp_layer2_update *msg; |
| 538 | struct sk_buff *skb; |
| 539 | |
| 540 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 |
| 541 | * bridge devices */ |
| 542 | |
| 543 | skb = dev_alloc_skb(sizeof(*msg)); |
| 544 | if (!skb) |
| 545 | return; |
| 546 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); |
| 547 | |
| 548 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) |
| 549 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ |
| 550 | |
| 551 | memset(msg->da, 0xff, ETH_ALEN); |
| 552 | memcpy(msg->sa, sta->addr, ETH_ALEN); |
| 553 | msg->len = htons(6); |
| 554 | msg->dsap = 0; |
| 555 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ |
| 556 | msg->control = 0xaf; /* XID response lsb.1111F101. |
| 557 | * F=0 (no poll command; unsolicited frame) */ |
| 558 | msg->xid_info[0] = 0x81; /* XID format identifier */ |
| 559 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ |
| 560 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ |
| 561 | |
| 562 | skb->dev = sta->dev; |
| 563 | skb->protocol = eth_type_trans(skb, sta->dev); |
| 564 | memset(skb->cb, 0, sizeof(skb->cb)); |
| 565 | netif_rx(skb); |
| 566 | } |
| 567 | |
| 568 | static void sta_apply_parameters(struct ieee80211_local *local, |
| 569 | struct sta_info *sta, |
| 570 | struct station_parameters *params) |
| 571 | { |
| 572 | u32 rates; |
| 573 | int i, j; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 574 | struct ieee80211_supported_band *sband; |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 575 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 576 | |
| 577 | if (params->station_flags & STATION_FLAG_CHANGED) { |
| 578 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
| 579 | if (params->station_flags & STATION_FLAG_AUTHORIZED) |
| 580 | sta->flags |= WLAN_STA_AUTHORIZED; |
| 581 | |
| 582 | sta->flags &= ~WLAN_STA_SHORT_PREAMBLE; |
| 583 | if (params->station_flags & STATION_FLAG_SHORT_PREAMBLE) |
| 584 | sta->flags |= WLAN_STA_SHORT_PREAMBLE; |
| 585 | |
| 586 | sta->flags &= ~WLAN_STA_WME; |
| 587 | if (params->station_flags & STATION_FLAG_WME) |
| 588 | sta->flags |= WLAN_STA_WME; |
| 589 | } |
| 590 | |
| 591 | if (params->aid) { |
| 592 | sta->aid = params->aid; |
| 593 | if (sta->aid > IEEE80211_MAX_AID) |
| 594 | sta->aid = 0; /* XXX: should this be an error? */ |
| 595 | } |
| 596 | |
| 597 | if (params->listen_interval >= 0) |
| 598 | sta->listen_interval = params->listen_interval; |
| 599 | |
| 600 | if (params->supported_rates) { |
| 601 | rates = 0; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 602 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
| 603 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 604 | for (i = 0; i < params->supported_rates_len; i++) { |
| 605 | int rate = (params->supported_rates[i] & 0x7f) * 5; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 606 | for (j = 0; j < sband->n_bitrates; j++) { |
| 607 | if (sband->bitrates[j].bitrate == rate) |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 608 | rates |= BIT(j); |
| 609 | } |
| 610 | } |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 611 | sta->supp_rates[local->oper_channel->band] = rates; |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 612 | } |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 613 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 614 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) { |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 615 | switch (params->plink_action) { |
| 616 | case PLINK_ACTION_OPEN: |
| 617 | mesh_plink_open(sta); |
| 618 | break; |
| 619 | case PLINK_ACTION_BLOCK: |
| 620 | mesh_plink_block(sta); |
| 621 | break; |
| 622 | } |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 623 | } |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 624 | } |
| 625 | |
| 626 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
| 627 | u8 *mac, struct station_parameters *params) |
| 628 | { |
| 629 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 630 | struct sta_info *sta; |
| 631 | struct ieee80211_sub_if_data *sdata; |
| 632 | |
| 633 | /* Prevent a race with changing the rate control algorithm */ |
| 634 | if (!netif_running(dev)) |
| 635 | return -ENETDOWN; |
| 636 | |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 637 | if (params->vlan) { |
| 638 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 639 | |
| 640 | if (sdata->vif.type != IEEE80211_IF_TYPE_VLAN || |
| 641 | sdata->vif.type != IEEE80211_IF_TYPE_AP) |
| 642 | return -EINVAL; |
| 643 | } else |
| 644 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 645 | |
Johannes Berg | 902acc7 | 2008-02-23 15:17:19 +0100 | [diff] [blame^] | 646 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 647 | sta = mesh_plink_add(mac, DEFAULT_RATES, dev); |
| 648 | else |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 649 | sta = sta_info_add(local, dev, mac, GFP_KERNEL); |
| 650 | |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 651 | if (IS_ERR(sta)) |
| 652 | return PTR_ERR(sta); |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 653 | |
| 654 | sta->dev = sdata->dev; |
| 655 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN || |
| 656 | sdata->vif.type == IEEE80211_IF_TYPE_AP) |
| 657 | ieee80211_send_layer2_update(sta); |
| 658 | |
| 659 | sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 660 | |
| 661 | sta_apply_parameters(local, sta, params); |
| 662 | |
| 663 | rate_control_rate_init(sta, local); |
| 664 | |
| 665 | sta_info_put(sta); |
| 666 | |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
| 671 | u8 *mac) |
| 672 | { |
| 673 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 674 | struct sta_info *sta; |
| 675 | |
| 676 | if (mac) { |
| 677 | /* XXX: get sta belonging to dev */ |
| 678 | sta = sta_info_get(local, mac); |
| 679 | if (!sta) |
| 680 | return -ENOENT; |
| 681 | |
| 682 | sta_info_free(sta); |
| 683 | sta_info_put(sta); |
| 684 | } else |
| 685 | sta_info_flush(local, dev); |
| 686 | |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static int ieee80211_change_station(struct wiphy *wiphy, |
| 691 | struct net_device *dev, |
| 692 | u8 *mac, |
| 693 | struct station_parameters *params) |
| 694 | { |
| 695 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 696 | struct sta_info *sta; |
| 697 | struct ieee80211_sub_if_data *vlansdata; |
| 698 | |
| 699 | /* XXX: get sta belonging to dev */ |
| 700 | sta = sta_info_get(local, mac); |
| 701 | if (!sta) |
| 702 | return -ENOENT; |
| 703 | |
| 704 | if (params->vlan && params->vlan != sta->dev) { |
| 705 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
| 706 | |
| 707 | if (vlansdata->vif.type != IEEE80211_IF_TYPE_VLAN || |
| 708 | vlansdata->vif.type != IEEE80211_IF_TYPE_AP) |
| 709 | return -EINVAL; |
| 710 | |
| 711 | sta->dev = params->vlan; |
| 712 | ieee80211_send_layer2_update(sta); |
| 713 | } |
| 714 | |
| 715 | sta_apply_parameters(local, sta, params); |
| 716 | |
| 717 | sta_info_put(sta); |
| 718 | |
| 719 | return 0; |
| 720 | } |
| 721 | |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 722 | #ifdef CONFIG_MAC80211_MESH |
| 723 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 724 | u8 *dst, u8 *next_hop) |
| 725 | { |
| 726 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 727 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 728 | struct mesh_path *mpath; |
| 729 | struct sta_info *sta; |
| 730 | int err; |
| 731 | |
| 732 | if (!netif_running(dev)) |
| 733 | return -ENETDOWN; |
| 734 | |
| 735 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
| 736 | return -ENOTSUPP; |
| 737 | |
| 738 | sta = sta_info_get(local, next_hop); |
| 739 | if (!sta) |
| 740 | return -ENOENT; |
| 741 | |
| 742 | err = mesh_path_add(dst, dev); |
| 743 | if (err) |
| 744 | return err; |
| 745 | |
| 746 | rcu_read_lock(); |
| 747 | mpath = mesh_path_lookup(dst, dev); |
| 748 | if (!mpath) { |
| 749 | rcu_read_unlock(); |
| 750 | sta_info_put(sta); |
| 751 | return -ENXIO; |
| 752 | } |
| 753 | mesh_path_fix_nexthop(mpath, sta); |
| 754 | sta_info_put(sta); |
| 755 | rcu_read_unlock(); |
| 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 760 | u8 *dst) |
| 761 | { |
| 762 | if (dst) |
| 763 | return mesh_path_del(dst, dev); |
| 764 | |
| 765 | mesh_path_flush(dev); |
| 766 | return 0; |
| 767 | } |
| 768 | |
| 769 | static int ieee80211_change_mpath(struct wiphy *wiphy, |
| 770 | struct net_device *dev, |
| 771 | u8 *dst, u8 *next_hop) |
| 772 | { |
| 773 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
| 774 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 775 | struct mesh_path *mpath; |
| 776 | struct sta_info *sta; |
| 777 | |
| 778 | if (!netif_running(dev)) |
| 779 | return -ENETDOWN; |
| 780 | |
| 781 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
| 782 | return -ENOTSUPP; |
| 783 | |
| 784 | sta = sta_info_get(local, next_hop); |
| 785 | if (!sta) |
| 786 | return -ENOENT; |
| 787 | |
| 788 | rcu_read_lock(); |
| 789 | mpath = mesh_path_lookup(dst, dev); |
| 790 | if (!mpath) { |
| 791 | rcu_read_unlock(); |
| 792 | sta_info_put(sta); |
| 793 | return -ENOENT; |
| 794 | } |
| 795 | |
| 796 | mesh_path_fix_nexthop(mpath, sta); |
| 797 | sta_info_put(sta); |
| 798 | rcu_read_unlock(); |
| 799 | return 0; |
| 800 | } |
| 801 | |
| 802 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, |
| 803 | struct mpath_info *pinfo) |
| 804 | { |
| 805 | if (mpath->next_hop) |
| 806 | memcpy(next_hop, mpath->next_hop->addr, ETH_ALEN); |
| 807 | else |
| 808 | memset(next_hop, 0, ETH_ALEN); |
| 809 | |
| 810 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
| 811 | MPATH_INFO_DSN | |
| 812 | MPATH_INFO_METRIC | |
| 813 | MPATH_INFO_EXPTIME | |
| 814 | MPATH_INFO_DISCOVERY_TIMEOUT | |
| 815 | MPATH_INFO_DISCOVERY_RETRIES | |
| 816 | MPATH_INFO_FLAGS; |
| 817 | |
| 818 | pinfo->frame_qlen = mpath->frame_queue.qlen; |
| 819 | pinfo->dsn = mpath->dsn; |
| 820 | pinfo->metric = mpath->metric; |
| 821 | if (time_before(jiffies, mpath->exp_time)) |
| 822 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); |
| 823 | pinfo->discovery_timeout = |
| 824 | jiffies_to_msecs(mpath->discovery_timeout); |
| 825 | pinfo->discovery_retries = mpath->discovery_retries; |
| 826 | pinfo->flags = 0; |
| 827 | if (mpath->flags & MESH_PATH_ACTIVE) |
| 828 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; |
| 829 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 830 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 831 | if (mpath->flags & MESH_PATH_DSN_VALID) |
| 832 | pinfo->flags |= NL80211_MPATH_FLAG_DSN_VALID; |
| 833 | if (mpath->flags & MESH_PATH_FIXED) |
| 834 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; |
| 835 | if (mpath->flags & MESH_PATH_RESOLVING) |
| 836 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; |
| 837 | |
| 838 | pinfo->flags = mpath->flags; |
| 839 | } |
| 840 | |
| 841 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 842 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
| 843 | |
| 844 | { |
| 845 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 846 | struct mesh_path *mpath; |
| 847 | |
| 848 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
| 849 | return -ENOTSUPP; |
| 850 | |
| 851 | rcu_read_lock(); |
| 852 | mpath = mesh_path_lookup(dst, dev); |
| 853 | if (!mpath) { |
| 854 | rcu_read_unlock(); |
| 855 | return -ENOENT; |
| 856 | } |
| 857 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 858 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 859 | rcu_read_unlock(); |
| 860 | return 0; |
| 861 | } |
| 862 | |
| 863 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, |
| 864 | int idx, u8 *dst, u8 *next_hop, |
| 865 | struct mpath_info *pinfo) |
| 866 | { |
| 867 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
| 868 | struct mesh_path *mpath; |
| 869 | |
| 870 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
| 871 | return -ENOTSUPP; |
| 872 | |
| 873 | rcu_read_lock(); |
| 874 | mpath = mesh_path_lookup_by_idx(idx, dev); |
| 875 | if (!mpath) { |
| 876 | rcu_read_unlock(); |
| 877 | return -ENOENT; |
| 878 | } |
| 879 | memcpy(dst, mpath->dst, ETH_ALEN); |
| 880 | mpath_set_pinfo(mpath, next_hop, pinfo); |
| 881 | rcu_read_unlock(); |
| 882 | return 0; |
| 883 | } |
| 884 | #endif |
| 885 | |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 886 | struct cfg80211_ops mac80211_config_ops = { |
| 887 | .add_virtual_intf = ieee80211_add_iface, |
| 888 | .del_virtual_intf = ieee80211_del_iface, |
Johannes Berg | 42613db | 2007-09-28 21:52:27 +0200 | [diff] [blame] | 889 | .change_virtual_intf = ieee80211_change_iface, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 890 | .add_key = ieee80211_add_key, |
| 891 | .del_key = ieee80211_del_key, |
Johannes Berg | 62da92f | 2007-12-19 02:03:31 +0100 | [diff] [blame] | 892 | .get_key = ieee80211_get_key, |
Johannes Berg | e8cbb4c | 2007-12-19 02:03:30 +0100 | [diff] [blame] | 893 | .set_default_key = ieee80211_config_default_key, |
Johannes Berg | 5dfdaf5 | 2007-12-19 02:03:33 +0100 | [diff] [blame] | 894 | .add_beacon = ieee80211_add_beacon, |
| 895 | .set_beacon = ieee80211_set_beacon, |
| 896 | .del_beacon = ieee80211_del_beacon, |
Johannes Berg | 4fd6931 | 2007-12-19 02:03:35 +0100 | [diff] [blame] | 897 | .add_station = ieee80211_add_station, |
| 898 | .del_station = ieee80211_del_station, |
| 899 | .change_station = ieee80211_change_station, |
Johannes Berg | 7bbdd2d | 2007-12-19 02:03:37 +0100 | [diff] [blame] | 900 | .get_station = ieee80211_get_station, |
Luis Carlos Cobo | c5dd9c2 | 2008-02-23 15:17:17 +0100 | [diff] [blame] | 901 | .dump_station = ieee80211_dump_station, |
| 902 | #ifdef CONFIG_MAC80211_MESH |
| 903 | .add_mpath = ieee80211_add_mpath, |
| 904 | .del_mpath = ieee80211_del_mpath, |
| 905 | .change_mpath = ieee80211_change_mpath, |
| 906 | .get_mpath = ieee80211_get_mpath, |
| 907 | .dump_mpath = ieee80211_dump_mpath, |
| 908 | #endif |
Jiri Benc | f0706e82 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 909 | }; |