Commit | Line | Data |
---|---|---|
f0706e82 JB |
1 | /* |
2 | * mac80211 configuration hooks for cfg80211 | |
3 | * | |
62da92fb | 4 | * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net> |
f0706e82 JB |
5 | * |
6 | * This file is GPLv2 as found in COPYING. | |
7 | */ | |
8 | ||
e8cbb4cb | 9 | #include <linux/ieee80211.h> |
f0706e82 JB |
10 | #include <linux/nl80211.h> |
11 | #include <linux/rtnetlink.h> | |
881d966b | 12 | #include <net/net_namespace.h> |
5dfdaf58 | 13 | #include <linux/rcupdate.h> |
f0706e82 JB |
14 | #include <net/cfg80211.h> |
15 | #include "ieee80211_i.h" | |
e0eb6859 | 16 | #include "cfg.h" |
2c8dccc7 | 17 | #include "rate.h" |
c5dd9c2b | 18 | #include "mesh.h" |
c5dd9c2b | 19 | |
b2e1b302 LR |
20 | struct ieee80211_hw *wiphy_to_hw(struct wiphy *wiphy) |
21 | { | |
22 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
23 | return &local->hw; | |
24 | } | |
25 | EXPORT_SYMBOL(wiphy_to_hw); | |
26 | ||
42613db7 JB |
27 | static enum ieee80211_if_types |
28 | nl80211_type_to_mac80211_type(enum nl80211_iftype type) | |
29 | { | |
30 | switch (type) { | |
31 | case NL80211_IFTYPE_UNSPECIFIED: | |
32 | return IEEE80211_IF_TYPE_STA; | |
33 | case NL80211_IFTYPE_ADHOC: | |
34 | return IEEE80211_IF_TYPE_IBSS; | |
35 | case NL80211_IFTYPE_STATION: | |
36 | return IEEE80211_IF_TYPE_STA; | |
37 | case NL80211_IFTYPE_MONITOR: | |
38 | return IEEE80211_IF_TYPE_MNTR; | |
c5dd9c2b LCC |
39 | #ifdef CONFIG_MAC80211_MESH |
40 | case NL80211_IFTYPE_MESH_POINT: | |
41 | return IEEE80211_IF_TYPE_MESH_POINT; | |
42 | #endif | |
b454048c JB |
43 | case NL80211_IFTYPE_WDS: |
44 | return IEEE80211_IF_TYPE_WDS; | |
42613db7 JB |
45 | default: |
46 | return IEEE80211_IF_TYPE_INVALID; | |
47 | } | |
48 | } | |
49 | ||
f0706e82 | 50 | static int ieee80211_add_iface(struct wiphy *wiphy, char *name, |
2ec600d6 LCC |
51 | enum nl80211_iftype type, u32 *flags, |
52 | struct vif_params *params) | |
f0706e82 JB |
53 | { |
54 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
42613db7 | 55 | enum ieee80211_if_types itype; |
8cc9a739 MW |
56 | struct net_device *dev; |
57 | struct ieee80211_sub_if_data *sdata; | |
58 | int err; | |
f0706e82 | 59 | |
42613db7 JB |
60 | itype = nl80211_type_to_mac80211_type(type); |
61 | if (itype == IEEE80211_IF_TYPE_INVALID) | |
f0706e82 | 62 | return -EINVAL; |
f0706e82 | 63 | |
3e122be0 | 64 | err = ieee80211_if_add(local, name, &dev, itype, params); |
8cc9a739 MW |
65 | if (err || itype != IEEE80211_IF_TYPE_MNTR || !flags) |
66 | return err; | |
67 | ||
68 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
69 | sdata->u.mntr_flags = *flags; | |
70 | return 0; | |
f0706e82 JB |
71 | } |
72 | ||
73 | static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) | |
74 | { | |
f0706e82 | 75 | struct net_device *dev; |
f698d856 | 76 | struct ieee80211_sub_if_data *sdata; |
f0706e82 | 77 | |
42613db7 JB |
78 | /* we're under RTNL */ |
79 | dev = __dev_get_by_index(&init_net, ifindex); | |
f0706e82 | 80 | if (!dev) |
75636525 | 81 | return -ENODEV; |
f0706e82 | 82 | |
f698d856 JBG |
83 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
84 | ||
85 | ieee80211_if_remove(sdata); | |
f0706e82 | 86 | |
75636525 | 87 | return 0; |
f0706e82 JB |
88 | } |
89 | ||
42613db7 | 90 | static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, |
2ec600d6 LCC |
91 | enum nl80211_iftype type, u32 *flags, |
92 | struct vif_params *params) | |
42613db7 | 93 | { |
14db74bc | 94 | struct ieee80211_local *local = wiphy_priv(wiphy); |
42613db7 JB |
95 | struct net_device *dev; |
96 | enum ieee80211_if_types itype; | |
97 | struct ieee80211_sub_if_data *sdata; | |
f3947e2d | 98 | int ret; |
42613db7 | 99 | |
42613db7 JB |
100 | /* we're under RTNL */ |
101 | dev = __dev_get_by_index(&init_net, ifindex); | |
102 | if (!dev) | |
103 | return -ENODEV; | |
104 | ||
42613db7 JB |
105 | itype = nl80211_type_to_mac80211_type(type); |
106 | if (itype == IEEE80211_IF_TYPE_INVALID) | |
107 | return -EINVAL; | |
108 | ||
14db74bc JB |
109 | if (dev == local->mdev) |
110 | return -EOPNOTSUPP; | |
111 | ||
42613db7 JB |
112 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
113 | ||
f3947e2d JB |
114 | ret = ieee80211_if_change_type(sdata, itype); |
115 | if (ret) | |
116 | return ret; | |
42613db7 | 117 | |
902acc78 | 118 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len) |
472dbc45 JB |
119 | ieee80211_sdata_set_mesh_id(sdata, |
120 | params->mesh_id_len, | |
121 | params->mesh_id); | |
c5dd9c2b | 122 | |
8cc9a739 MW |
123 | if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR || !flags) |
124 | return 0; | |
125 | ||
126 | sdata->u.mntr_flags = *flags; | |
42613db7 JB |
127 | return 0; |
128 | } | |
129 | ||
e8cbb4cb JB |
130 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
131 | u8 key_idx, u8 *mac_addr, | |
132 | struct key_params *params) | |
133 | { | |
14db74bc | 134 | struct ieee80211_local *local = wiphy_priv(wiphy); |
e8cbb4cb JB |
135 | struct ieee80211_sub_if_data *sdata; |
136 | struct sta_info *sta = NULL; | |
137 | enum ieee80211_key_alg alg; | |
db4d1169 | 138 | struct ieee80211_key *key; |
3b96766f | 139 | int err; |
e8cbb4cb | 140 | |
14db74bc JB |
141 | if (dev == local->mdev) |
142 | return -EOPNOTSUPP; | |
143 | ||
e8cbb4cb JB |
144 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
145 | ||
146 | switch (params->cipher) { | |
147 | case WLAN_CIPHER_SUITE_WEP40: | |
148 | case WLAN_CIPHER_SUITE_WEP104: | |
149 | alg = ALG_WEP; | |
150 | break; | |
151 | case WLAN_CIPHER_SUITE_TKIP: | |
152 | alg = ALG_TKIP; | |
153 | break; | |
154 | case WLAN_CIPHER_SUITE_CCMP: | |
155 | alg = ALG_CCMP; | |
156 | break; | |
157 | default: | |
158 | return -EINVAL; | |
159 | } | |
160 | ||
db4d1169 JB |
161 | key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key); |
162 | if (!key) | |
163 | return -ENOMEM; | |
164 | ||
3b96766f JB |
165 | rcu_read_lock(); |
166 | ||
e8cbb4cb JB |
167 | if (mac_addr) { |
168 | sta = sta_info_get(sdata->local, mac_addr); | |
db4d1169 JB |
169 | if (!sta) { |
170 | ieee80211_key_free(key); | |
3b96766f JB |
171 | err = -ENOENT; |
172 | goto out_unlock; | |
db4d1169 | 173 | } |
e8cbb4cb JB |
174 | } |
175 | ||
db4d1169 JB |
176 | ieee80211_key_link(key, sdata, sta); |
177 | ||
3b96766f JB |
178 | err = 0; |
179 | out_unlock: | |
180 | rcu_read_unlock(); | |
181 | ||
182 | return err; | |
e8cbb4cb JB |
183 | } |
184 | ||
185 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |
186 | u8 key_idx, u8 *mac_addr) | |
187 | { | |
14db74bc | 188 | struct ieee80211_local *local = wiphy_priv(wiphy); |
e8cbb4cb JB |
189 | struct ieee80211_sub_if_data *sdata; |
190 | struct sta_info *sta; | |
191 | int ret; | |
192 | ||
14db74bc JB |
193 | if (dev == local->mdev) |
194 | return -EOPNOTSUPP; | |
195 | ||
e8cbb4cb JB |
196 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
197 | ||
3b96766f JB |
198 | rcu_read_lock(); |
199 | ||
e8cbb4cb | 200 | if (mac_addr) { |
3b96766f JB |
201 | ret = -ENOENT; |
202 | ||
e8cbb4cb JB |
203 | sta = sta_info_get(sdata->local, mac_addr); |
204 | if (!sta) | |
3b96766f | 205 | goto out_unlock; |
e8cbb4cb | 206 | |
db4d1169 | 207 | if (sta->key) { |
d0709a65 | 208 | ieee80211_key_free(sta->key); |
db4d1169 | 209 | WARN_ON(sta->key); |
3b96766f JB |
210 | ret = 0; |
211 | } | |
e8cbb4cb | 212 | |
3b96766f | 213 | goto out_unlock; |
e8cbb4cb JB |
214 | } |
215 | ||
3b96766f JB |
216 | if (!sdata->keys[key_idx]) { |
217 | ret = -ENOENT; | |
218 | goto out_unlock; | |
219 | } | |
e8cbb4cb | 220 | |
d0709a65 | 221 | ieee80211_key_free(sdata->keys[key_idx]); |
db4d1169 | 222 | WARN_ON(sdata->keys[key_idx]); |
e8cbb4cb | 223 | |
3b96766f JB |
224 | ret = 0; |
225 | out_unlock: | |
226 | rcu_read_unlock(); | |
227 | ||
228 | return ret; | |
e8cbb4cb JB |
229 | } |
230 | ||
62da92fb JB |
231 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
232 | u8 key_idx, u8 *mac_addr, void *cookie, | |
233 | void (*callback)(void *cookie, | |
234 | struct key_params *params)) | |
235 | { | |
14db74bc JB |
236 | struct ieee80211_local *local = wiphy_priv(wiphy); |
237 | struct ieee80211_sub_if_data *sdata; | |
62da92fb JB |
238 | struct sta_info *sta = NULL; |
239 | u8 seq[6] = {0}; | |
240 | struct key_params params; | |
241 | struct ieee80211_key *key; | |
242 | u32 iv32; | |
243 | u16 iv16; | |
244 | int err = -ENOENT; | |
245 | ||
14db74bc JB |
246 | if (dev == local->mdev) |
247 | return -EOPNOTSUPP; | |
248 | ||
249 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
250 | ||
3b96766f JB |
251 | rcu_read_lock(); |
252 | ||
62da92fb JB |
253 | if (mac_addr) { |
254 | sta = sta_info_get(sdata->local, mac_addr); | |
255 | if (!sta) | |
256 | goto out; | |
257 | ||
258 | key = sta->key; | |
259 | } else | |
260 | key = sdata->keys[key_idx]; | |
261 | ||
262 | if (!key) | |
263 | goto out; | |
264 | ||
265 | memset(¶ms, 0, sizeof(params)); | |
266 | ||
267 | switch (key->conf.alg) { | |
268 | case ALG_TKIP: | |
269 | params.cipher = WLAN_CIPHER_SUITE_TKIP; | |
270 | ||
b0f76b33 HH |
271 | iv32 = key->u.tkip.tx.iv32; |
272 | iv16 = key->u.tkip.tx.iv16; | |
62da92fb JB |
273 | |
274 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && | |
275 | sdata->local->ops->get_tkip_seq) | |
276 | sdata->local->ops->get_tkip_seq( | |
277 | local_to_hw(sdata->local), | |
278 | key->conf.hw_key_idx, | |
279 | &iv32, &iv16); | |
280 | ||
281 | seq[0] = iv16 & 0xff; | |
282 | seq[1] = (iv16 >> 8) & 0xff; | |
283 | seq[2] = iv32 & 0xff; | |
284 | seq[3] = (iv32 >> 8) & 0xff; | |
285 | seq[4] = (iv32 >> 16) & 0xff; | |
286 | seq[5] = (iv32 >> 24) & 0xff; | |
287 | params.seq = seq; | |
288 | params.seq_len = 6; | |
289 | break; | |
290 | case ALG_CCMP: | |
291 | params.cipher = WLAN_CIPHER_SUITE_CCMP; | |
292 | seq[0] = key->u.ccmp.tx_pn[5]; | |
293 | seq[1] = key->u.ccmp.tx_pn[4]; | |
294 | seq[2] = key->u.ccmp.tx_pn[3]; | |
295 | seq[3] = key->u.ccmp.tx_pn[2]; | |
296 | seq[4] = key->u.ccmp.tx_pn[1]; | |
297 | seq[5] = key->u.ccmp.tx_pn[0]; | |
298 | params.seq = seq; | |
299 | params.seq_len = 6; | |
300 | break; | |
301 | case ALG_WEP: | |
302 | if (key->conf.keylen == 5) | |
303 | params.cipher = WLAN_CIPHER_SUITE_WEP40; | |
304 | else | |
305 | params.cipher = WLAN_CIPHER_SUITE_WEP104; | |
306 | break; | |
307 | } | |
308 | ||
309 | params.key = key->conf.key; | |
310 | params.key_len = key->conf.keylen; | |
311 | ||
312 | callback(cookie, ¶ms); | |
313 | err = 0; | |
314 | ||
315 | out: | |
3b96766f | 316 | rcu_read_unlock(); |
62da92fb JB |
317 | return err; |
318 | } | |
319 | ||
e8cbb4cb JB |
320 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
321 | struct net_device *dev, | |
322 | u8 key_idx) | |
323 | { | |
14db74bc | 324 | struct ieee80211_local *local = wiphy_priv(wiphy); |
e8cbb4cb JB |
325 | struct ieee80211_sub_if_data *sdata; |
326 | ||
14db74bc JB |
327 | if (dev == local->mdev) |
328 | return -EOPNOTSUPP; | |
329 | ||
3b96766f JB |
330 | rcu_read_lock(); |
331 | ||
e8cbb4cb JB |
332 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
333 | ieee80211_set_default_key(sdata, key_idx); | |
334 | ||
3b96766f JB |
335 | rcu_read_unlock(); |
336 | ||
e8cbb4cb JB |
337 | return 0; |
338 | } | |
339 | ||
c5dd9c2b LCC |
340 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
341 | { | |
d0709a65 | 342 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
c5dd9c2b LCC |
343 | |
344 | sinfo->filled = STATION_INFO_INACTIVE_TIME | | |
345 | STATION_INFO_RX_BYTES | | |
346 | STATION_INFO_TX_BYTES; | |
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; | |
351 | ||
902acc78 | 352 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
c5dd9c2b | 353 | #ifdef CONFIG_MAC80211_MESH |
c5dd9c2b LCC |
354 | sinfo->filled |= STATION_INFO_LLID | |
355 | STATION_INFO_PLID | | |
356 | STATION_INFO_PLINK_STATE; | |
357 | ||
358 | sinfo->llid = le16_to_cpu(sta->llid); | |
359 | sinfo->plid = le16_to_cpu(sta->plid); | |
360 | sinfo->plink_state = sta->plink_state; | |
c5dd9c2b | 361 | #endif |
902acc78 | 362 | } |
c5dd9c2b LCC |
363 | } |
364 | ||
365 | ||
366 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, | |
367 | int idx, u8 *mac, struct station_info *sinfo) | |
368 | { | |
369 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
370 | struct sta_info *sta; | |
d0709a65 JB |
371 | int ret = -ENOENT; |
372 | ||
373 | rcu_read_lock(); | |
c5dd9c2b LCC |
374 | |
375 | sta = sta_info_get_by_idx(local, idx, dev); | |
d0709a65 JB |
376 | if (sta) { |
377 | ret = 0; | |
378 | memcpy(mac, sta->addr, ETH_ALEN); | |
379 | sta_set_sinfo(sta, sinfo); | |
380 | } | |
c5dd9c2b | 381 | |
d0709a65 | 382 | rcu_read_unlock(); |
c5dd9c2b | 383 | |
d0709a65 | 384 | return ret; |
c5dd9c2b LCC |
385 | } |
386 | ||
7bbdd2d9 | 387 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
2ec600d6 | 388 | u8 *mac, struct station_info *sinfo) |
7bbdd2d9 JB |
389 | { |
390 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
391 | struct sta_info *sta; | |
d0709a65 | 392 | int ret = -ENOENT; |
7bbdd2d9 | 393 | |
d0709a65 | 394 | rcu_read_lock(); |
7bbdd2d9 JB |
395 | |
396 | /* XXX: verify sta->dev == dev */ | |
7bbdd2d9 | 397 | |
d0709a65 JB |
398 | sta = sta_info_get(local, mac); |
399 | if (sta) { | |
400 | ret = 0; | |
401 | sta_set_sinfo(sta, sinfo); | |
402 | } | |
403 | ||
404 | rcu_read_unlock(); | |
405 | ||
406 | return ret; | |
7bbdd2d9 JB |
407 | } |
408 | ||
5dfdaf58 JB |
409 | /* |
410 | * This handles both adding a beacon and setting new beacon info | |
411 | */ | |
412 | static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, | |
413 | struct beacon_parameters *params) | |
414 | { | |
415 | struct beacon_data *new, *old; | |
416 | int new_head_len, new_tail_len; | |
417 | int size; | |
418 | int err = -EINVAL; | |
419 | ||
420 | old = sdata->u.ap.beacon; | |
421 | ||
422 | /* head must not be zero-length */ | |
423 | if (params->head && !params->head_len) | |
424 | return -EINVAL; | |
425 | ||
426 | /* | |
427 | * This is a kludge. beacon interval should really be part | |
428 | * of the beacon information. | |
429 | */ | |
430 | if (params->interval) { | |
431 | sdata->local->hw.conf.beacon_int = params->interval; | |
432 | if (ieee80211_hw_config(sdata->local)) | |
433 | return -EINVAL; | |
434 | /* | |
435 | * We updated some parameter so if below bails out | |
436 | * it's not an error. | |
437 | */ | |
438 | err = 0; | |
439 | } | |
440 | ||
441 | /* Need to have a beacon head if we don't have one yet */ | |
442 | if (!params->head && !old) | |
443 | return err; | |
444 | ||
445 | /* sorry, no way to start beaconing without dtim period */ | |
446 | if (!params->dtim_period && !old) | |
447 | return err; | |
448 | ||
449 | /* new or old head? */ | |
450 | if (params->head) | |
451 | new_head_len = params->head_len; | |
452 | else | |
453 | new_head_len = old->head_len; | |
454 | ||
455 | /* new or old tail? */ | |
456 | if (params->tail || !old) | |
457 | /* params->tail_len will be zero for !params->tail */ | |
458 | new_tail_len = params->tail_len; | |
459 | else | |
460 | new_tail_len = old->tail_len; | |
461 | ||
462 | size = sizeof(*new) + new_head_len + new_tail_len; | |
463 | ||
464 | new = kzalloc(size, GFP_KERNEL); | |
465 | if (!new) | |
466 | return -ENOMEM; | |
467 | ||
468 | /* start filling the new info now */ | |
469 | ||
470 | /* new or old dtim period? */ | |
471 | if (params->dtim_period) | |
472 | new->dtim_period = params->dtim_period; | |
473 | else | |
474 | new->dtim_period = old->dtim_period; | |
475 | ||
476 | /* | |
477 | * pointers go into the block we allocated, | |
478 | * memory is | beacon_data | head | tail | | |
479 | */ | |
480 | new->head = ((u8 *) new) + sizeof(*new); | |
481 | new->tail = new->head + new_head_len; | |
482 | new->head_len = new_head_len; | |
483 | new->tail_len = new_tail_len; | |
484 | ||
485 | /* copy in head */ | |
486 | if (params->head) | |
487 | memcpy(new->head, params->head, new_head_len); | |
488 | else | |
489 | memcpy(new->head, old->head, new_head_len); | |
490 | ||
491 | /* copy in optional tail */ | |
492 | if (params->tail) | |
493 | memcpy(new->tail, params->tail, new_tail_len); | |
494 | else | |
495 | if (old) | |
496 | memcpy(new->tail, old->tail, new_tail_len); | |
497 | ||
498 | rcu_assign_pointer(sdata->u.ap.beacon, new); | |
499 | ||
500 | synchronize_rcu(); | |
501 | ||
502 | kfree(old); | |
503 | ||
9d139c81 | 504 | return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
5dfdaf58 JB |
505 | } |
506 | ||
507 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, | |
508 | struct beacon_parameters *params) | |
509 | { | |
14db74bc JB |
510 | struct ieee80211_local *local = wiphy_priv(wiphy); |
511 | struct ieee80211_sub_if_data *sdata; | |
5dfdaf58 JB |
512 | struct beacon_data *old; |
513 | ||
14db74bc JB |
514 | if (dev == local->mdev) |
515 | return -EOPNOTSUPP; | |
516 | ||
517 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
518 | ||
5dfdaf58 JB |
519 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
520 | return -EINVAL; | |
521 | ||
522 | old = sdata->u.ap.beacon; | |
523 | ||
524 | if (old) | |
525 | return -EALREADY; | |
526 | ||
527 | return ieee80211_config_beacon(sdata, params); | |
528 | } | |
529 | ||
530 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, | |
531 | struct beacon_parameters *params) | |
532 | { | |
14db74bc JB |
533 | struct ieee80211_local *local = wiphy_priv(wiphy); |
534 | struct ieee80211_sub_if_data *sdata; | |
5dfdaf58 JB |
535 | struct beacon_data *old; |
536 | ||
14db74bc JB |
537 | if (dev == local->mdev) |
538 | return -EOPNOTSUPP; | |
539 | ||
540 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
541 | ||
5dfdaf58 JB |
542 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
543 | return -EINVAL; | |
544 | ||
545 | old = sdata->u.ap.beacon; | |
546 | ||
547 | if (!old) | |
548 | return -ENOENT; | |
549 | ||
550 | return ieee80211_config_beacon(sdata, params); | |
551 | } | |
552 | ||
553 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) | |
554 | { | |
14db74bc JB |
555 | struct ieee80211_local *local = wiphy_priv(wiphy); |
556 | struct ieee80211_sub_if_data *sdata; | |
5dfdaf58 JB |
557 | struct beacon_data *old; |
558 | ||
14db74bc JB |
559 | if (dev == local->mdev) |
560 | return -EOPNOTSUPP; | |
561 | ||
562 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
563 | ||
5dfdaf58 JB |
564 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
565 | return -EINVAL; | |
566 | ||
567 | old = sdata->u.ap.beacon; | |
568 | ||
569 | if (!old) | |
570 | return -ENOENT; | |
571 | ||
572 | rcu_assign_pointer(sdata->u.ap.beacon, NULL); | |
573 | synchronize_rcu(); | |
574 | kfree(old); | |
575 | ||
9d139c81 | 576 | return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); |
5dfdaf58 JB |
577 | } |
578 | ||
4fd6931e JB |
579 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
580 | struct iapp_layer2_update { | |
581 | u8 da[ETH_ALEN]; /* broadcast */ | |
582 | u8 sa[ETH_ALEN]; /* STA addr */ | |
583 | __be16 len; /* 6 */ | |
584 | u8 dsap; /* 0 */ | |
585 | u8 ssap; /* 0 */ | |
586 | u8 control; | |
587 | u8 xid_info[3]; | |
588 | } __attribute__ ((packed)); | |
589 | ||
590 | static void ieee80211_send_layer2_update(struct sta_info *sta) | |
591 | { | |
592 | struct iapp_layer2_update *msg; | |
593 | struct sk_buff *skb; | |
594 | ||
595 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 | |
596 | * bridge devices */ | |
597 | ||
598 | skb = dev_alloc_skb(sizeof(*msg)); | |
599 | if (!skb) | |
600 | return; | |
601 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); | |
602 | ||
603 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) | |
604 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ | |
605 | ||
606 | memset(msg->da, 0xff, ETH_ALEN); | |
607 | memcpy(msg->sa, sta->addr, ETH_ALEN); | |
608 | msg->len = htons(6); | |
609 | msg->dsap = 0; | |
610 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ | |
611 | msg->control = 0xaf; /* XID response lsb.1111F101. | |
612 | * F=0 (no poll command; unsolicited frame) */ | |
613 | msg->xid_info[0] = 0x81; /* XID format identifier */ | |
614 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ | |
615 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ | |
616 | ||
d0709a65 JB |
617 | skb->dev = sta->sdata->dev; |
618 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); | |
4fd6931e JB |
619 | memset(skb->cb, 0, sizeof(skb->cb)); |
620 | netif_rx(skb); | |
621 | } | |
622 | ||
623 | static void sta_apply_parameters(struct ieee80211_local *local, | |
624 | struct sta_info *sta, | |
625 | struct station_parameters *params) | |
626 | { | |
627 | u32 rates; | |
628 | int i, j; | |
8318d78a | 629 | struct ieee80211_supported_band *sband; |
d0709a65 | 630 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
4fd6931e | 631 | |
73651ee6 JB |
632 | /* |
633 | * FIXME: updating the flags is racy when this function is | |
634 | * called from ieee80211_change_station(), this will | |
635 | * be resolved in a future patch. | |
636 | */ | |
637 | ||
4fd6931e | 638 | if (params->station_flags & STATION_FLAG_CHANGED) { |
07346f81 | 639 | spin_lock_bh(&sta->lock); |
4fd6931e JB |
640 | sta->flags &= ~WLAN_STA_AUTHORIZED; |
641 | if (params->station_flags & STATION_FLAG_AUTHORIZED) | |
642 | sta->flags |= WLAN_STA_AUTHORIZED; | |
643 | ||
644 | sta->flags &= ~WLAN_STA_SHORT_PREAMBLE; | |
645 | if (params->station_flags & STATION_FLAG_SHORT_PREAMBLE) | |
646 | sta->flags |= WLAN_STA_SHORT_PREAMBLE; | |
647 | ||
648 | sta->flags &= ~WLAN_STA_WME; | |
649 | if (params->station_flags & STATION_FLAG_WME) | |
650 | sta->flags |= WLAN_STA_WME; | |
07346f81 | 651 | spin_unlock_bh(&sta->lock); |
4fd6931e JB |
652 | } |
653 | ||
73651ee6 JB |
654 | /* |
655 | * FIXME: updating the following information is racy when this | |
656 | * function is called from ieee80211_change_station(). | |
657 | * However, all this information should be static so | |
658 | * maybe we should just reject attemps to change it. | |
659 | */ | |
660 | ||
4fd6931e JB |
661 | if (params->aid) { |
662 | sta->aid = params->aid; | |
663 | if (sta->aid > IEEE80211_MAX_AID) | |
664 | sta->aid = 0; /* XXX: should this be an error? */ | |
665 | } | |
666 | ||
667 | if (params->listen_interval >= 0) | |
668 | sta->listen_interval = params->listen_interval; | |
669 | ||
670 | if (params->supported_rates) { | |
671 | rates = 0; | |
8318d78a JB |
672 | sband = local->hw.wiphy->bands[local->oper_channel->band]; |
673 | ||
4fd6931e JB |
674 | for (i = 0; i < params->supported_rates_len; i++) { |
675 | int rate = (params->supported_rates[i] & 0x7f) * 5; | |
8318d78a JB |
676 | for (j = 0; j < sband->n_bitrates; j++) { |
677 | if (sband->bitrates[j].bitrate == rate) | |
4fd6931e JB |
678 | rates |= BIT(j); |
679 | } | |
680 | } | |
8318d78a | 681 | sta->supp_rates[local->oper_channel->band] = rates; |
4fd6931e | 682 | } |
c5dd9c2b | 683 | |
36aedc90 JM |
684 | if (params->ht_capa) { |
685 | ieee80211_ht_cap_ie_to_ht_info(params->ht_capa, | |
686 | &sta->ht_info); | |
687 | } | |
688 | ||
902acc78 | 689 | if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) { |
c5dd9c2b LCC |
690 | switch (params->plink_action) { |
691 | case PLINK_ACTION_OPEN: | |
692 | mesh_plink_open(sta); | |
693 | break; | |
694 | case PLINK_ACTION_BLOCK: | |
695 | mesh_plink_block(sta); | |
696 | break; | |
697 | } | |
902acc78 | 698 | } |
4fd6931e JB |
699 | } |
700 | ||
701 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |
702 | u8 *mac, struct station_parameters *params) | |
703 | { | |
14db74bc | 704 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
705 | struct sta_info *sta; |
706 | struct ieee80211_sub_if_data *sdata; | |
73651ee6 | 707 | int err; |
4fd6931e | 708 | |
14db74bc JB |
709 | if (dev == local->mdev || params->vlan == local->mdev) |
710 | return -EOPNOTSUPP; | |
711 | ||
4fd6931e JB |
712 | /* Prevent a race with changing the rate control algorithm */ |
713 | if (!netif_running(dev)) | |
714 | return -ENETDOWN; | |
715 | ||
4fd6931e JB |
716 | if (params->vlan) { |
717 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); | |
718 | ||
679fda1a | 719 | if (sdata->vif.type != IEEE80211_IF_TYPE_VLAN && |
4fd6931e JB |
720 | sdata->vif.type != IEEE80211_IF_TYPE_AP) |
721 | return -EINVAL; | |
722 | } else | |
723 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
724 | ||
03e4497e JB |
725 | if (compare_ether_addr(mac, dev->dev_addr) == 0) |
726 | return -EINVAL; | |
727 | ||
728 | if (is_multicast_ether_addr(mac)) | |
729 | return -EINVAL; | |
730 | ||
731 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); | |
73651ee6 JB |
732 | if (!sta) |
733 | return -ENOMEM; | |
4fd6931e JB |
734 | |
735 | sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC; | |
736 | ||
737 | sta_apply_parameters(local, sta, params); | |
738 | ||
739 | rate_control_rate_init(sta, local); | |
740 | ||
73651ee6 JB |
741 | rcu_read_lock(); |
742 | ||
743 | err = sta_info_insert(sta); | |
744 | if (err) { | |
93e5deb1 | 745 | /* STA has been freed */ |
73651ee6 JB |
746 | rcu_read_unlock(); |
747 | return err; | |
748 | } | |
749 | ||
750 | if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN || | |
751 | sdata->vif.type == IEEE80211_IF_TYPE_AP) | |
752 | ieee80211_send_layer2_update(sta); | |
753 | ||
754 | rcu_read_unlock(); | |
755 | ||
4fd6931e JB |
756 | return 0; |
757 | } | |
758 | ||
759 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | |
760 | u8 *mac) | |
761 | { | |
14db74bc JB |
762 | struct ieee80211_local *local = wiphy_priv(wiphy); |
763 | struct ieee80211_sub_if_data *sdata; | |
4fd6931e JB |
764 | struct sta_info *sta; |
765 | ||
14db74bc JB |
766 | if (dev == local->mdev) |
767 | return -EOPNOTSUPP; | |
768 | ||
769 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
770 | ||
4fd6931e | 771 | if (mac) { |
98dd6a57 JB |
772 | rcu_read_lock(); |
773 | ||
4fd6931e JB |
774 | /* XXX: get sta belonging to dev */ |
775 | sta = sta_info_get(local, mac); | |
98dd6a57 JB |
776 | if (!sta) { |
777 | rcu_read_unlock(); | |
4fd6931e | 778 | return -ENOENT; |
98dd6a57 | 779 | } |
4fd6931e | 780 | |
d0709a65 | 781 | sta_info_unlink(&sta); |
98dd6a57 JB |
782 | rcu_read_unlock(); |
783 | ||
4f6fab47 | 784 | sta_info_destroy(sta); |
4fd6931e | 785 | } else |
d0709a65 | 786 | sta_info_flush(local, sdata); |
4fd6931e JB |
787 | |
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 | { | |
14db74bc | 796 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
797 | struct sta_info *sta; |
798 | struct ieee80211_sub_if_data *vlansdata; | |
799 | ||
14db74bc JB |
800 | if (dev == local->mdev || params->vlan == local->mdev) |
801 | return -EOPNOTSUPP; | |
802 | ||
98dd6a57 JB |
803 | rcu_read_lock(); |
804 | ||
4fd6931e JB |
805 | /* XXX: get sta belonging to dev */ |
806 | sta = sta_info_get(local, mac); | |
98dd6a57 JB |
807 | if (!sta) { |
808 | rcu_read_unlock(); | |
4fd6931e | 809 | return -ENOENT; |
98dd6a57 | 810 | } |
4fd6931e | 811 | |
d0709a65 | 812 | if (params->vlan && params->vlan != sta->sdata->dev) { |
4fd6931e JB |
813 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
814 | ||
679fda1a | 815 | if (vlansdata->vif.type != IEEE80211_IF_TYPE_VLAN && |
98dd6a57 JB |
816 | vlansdata->vif.type != IEEE80211_IF_TYPE_AP) { |
817 | rcu_read_unlock(); | |
4fd6931e | 818 | return -EINVAL; |
98dd6a57 | 819 | } |
4fd6931e | 820 | |
14db74bc | 821 | sta->sdata = vlansdata; |
4fd6931e JB |
822 | ieee80211_send_layer2_update(sta); |
823 | } | |
824 | ||
825 | sta_apply_parameters(local, sta, params); | |
826 | ||
98dd6a57 JB |
827 | rcu_read_unlock(); |
828 | ||
4fd6931e JB |
829 | return 0; |
830 | } | |
831 | ||
c5dd9c2b LCC |
832 | #ifdef CONFIG_MAC80211_MESH |
833 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |
834 | u8 *dst, u8 *next_hop) | |
835 | { | |
14db74bc JB |
836 | struct ieee80211_local *local = wiphy_priv(wiphy); |
837 | struct ieee80211_sub_if_data *sdata; | |
c5dd9c2b LCC |
838 | struct mesh_path *mpath; |
839 | struct sta_info *sta; | |
840 | int err; | |
841 | ||
14db74bc JB |
842 | if (dev == local->mdev) |
843 | return -EOPNOTSUPP; | |
844 | ||
c5dd9c2b LCC |
845 | if (!netif_running(dev)) |
846 | return -ENETDOWN; | |
847 | ||
14db74bc JB |
848 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
849 | ||
c5dd9c2b LCC |
850 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
851 | return -ENOTSUPP; | |
852 | ||
d0709a65 | 853 | rcu_read_lock(); |
c5dd9c2b | 854 | sta = sta_info_get(local, next_hop); |
d0709a65 JB |
855 | if (!sta) { |
856 | rcu_read_unlock(); | |
c5dd9c2b | 857 | return -ENOENT; |
d0709a65 | 858 | } |
c5dd9c2b | 859 | |
f698d856 | 860 | err = mesh_path_add(dst, sdata); |
d0709a65 JB |
861 | if (err) { |
862 | rcu_read_unlock(); | |
c5dd9c2b | 863 | return err; |
d0709a65 | 864 | } |
c5dd9c2b | 865 | |
f698d856 | 866 | mpath = mesh_path_lookup(dst, sdata); |
c5dd9c2b LCC |
867 | if (!mpath) { |
868 | rcu_read_unlock(); | |
c5dd9c2b LCC |
869 | return -ENXIO; |
870 | } | |
871 | mesh_path_fix_nexthop(mpath, sta); | |
d0709a65 | 872 | |
c5dd9c2b LCC |
873 | rcu_read_unlock(); |
874 | return 0; | |
875 | } | |
876 | ||
877 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, | |
878 | u8 *dst) | |
879 | { | |
f698d856 JBG |
880 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
881 | ||
c5dd9c2b | 882 | if (dst) |
f698d856 | 883 | return mesh_path_del(dst, sdata); |
c5dd9c2b | 884 | |
f698d856 | 885 | mesh_path_flush(sdata); |
c5dd9c2b LCC |
886 | return 0; |
887 | } | |
888 | ||
889 | static int ieee80211_change_mpath(struct wiphy *wiphy, | |
890 | struct net_device *dev, | |
891 | u8 *dst, u8 *next_hop) | |
892 | { | |
14db74bc JB |
893 | struct ieee80211_local *local = wiphy_priv(wiphy); |
894 | struct ieee80211_sub_if_data *sdata; | |
c5dd9c2b LCC |
895 | struct mesh_path *mpath; |
896 | struct sta_info *sta; | |
897 | ||
14db74bc JB |
898 | if (dev == local->mdev) |
899 | return -EOPNOTSUPP; | |
900 | ||
c5dd9c2b LCC |
901 | if (!netif_running(dev)) |
902 | return -ENETDOWN; | |
903 | ||
14db74bc JB |
904 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
905 | ||
c5dd9c2b LCC |
906 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
907 | return -ENOTSUPP; | |
908 | ||
d0709a65 JB |
909 | rcu_read_lock(); |
910 | ||
c5dd9c2b | 911 | sta = sta_info_get(local, next_hop); |
d0709a65 JB |
912 | if (!sta) { |
913 | rcu_read_unlock(); | |
c5dd9c2b | 914 | return -ENOENT; |
d0709a65 | 915 | } |
c5dd9c2b | 916 | |
f698d856 | 917 | mpath = mesh_path_lookup(dst, sdata); |
c5dd9c2b LCC |
918 | if (!mpath) { |
919 | rcu_read_unlock(); | |
c5dd9c2b LCC |
920 | return -ENOENT; |
921 | } | |
922 | ||
923 | mesh_path_fix_nexthop(mpath, sta); | |
d0709a65 | 924 | |
c5dd9c2b LCC |
925 | rcu_read_unlock(); |
926 | return 0; | |
927 | } | |
928 | ||
929 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, | |
930 | struct mpath_info *pinfo) | |
931 | { | |
932 | if (mpath->next_hop) | |
933 | memcpy(next_hop, mpath->next_hop->addr, ETH_ALEN); | |
934 | else | |
935 | memset(next_hop, 0, ETH_ALEN); | |
936 | ||
937 | pinfo->filled = MPATH_INFO_FRAME_QLEN | | |
938 | MPATH_INFO_DSN | | |
939 | MPATH_INFO_METRIC | | |
940 | MPATH_INFO_EXPTIME | | |
941 | MPATH_INFO_DISCOVERY_TIMEOUT | | |
942 | MPATH_INFO_DISCOVERY_RETRIES | | |
943 | MPATH_INFO_FLAGS; | |
944 | ||
945 | pinfo->frame_qlen = mpath->frame_queue.qlen; | |
946 | pinfo->dsn = mpath->dsn; | |
947 | pinfo->metric = mpath->metric; | |
948 | if (time_before(jiffies, mpath->exp_time)) | |
949 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); | |
950 | pinfo->discovery_timeout = | |
951 | jiffies_to_msecs(mpath->discovery_timeout); | |
952 | pinfo->discovery_retries = mpath->discovery_retries; | |
953 | pinfo->flags = 0; | |
954 | if (mpath->flags & MESH_PATH_ACTIVE) | |
955 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; | |
956 | if (mpath->flags & MESH_PATH_RESOLVING) | |
957 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; | |
958 | if (mpath->flags & MESH_PATH_DSN_VALID) | |
959 | pinfo->flags |= NL80211_MPATH_FLAG_DSN_VALID; | |
960 | if (mpath->flags & MESH_PATH_FIXED) | |
961 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; | |
962 | if (mpath->flags & MESH_PATH_RESOLVING) | |
963 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; | |
964 | ||
965 | pinfo->flags = mpath->flags; | |
966 | } | |
967 | ||
968 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, | |
969 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) | |
970 | ||
971 | { | |
14db74bc JB |
972 | struct ieee80211_local *local = wiphy_priv(wiphy); |
973 | struct ieee80211_sub_if_data *sdata; | |
c5dd9c2b LCC |
974 | struct mesh_path *mpath; |
975 | ||
14db74bc JB |
976 | if (dev == local->mdev) |
977 | return -EOPNOTSUPP; | |
978 | ||
979 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
980 | ||
c5dd9c2b LCC |
981 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
982 | return -ENOTSUPP; | |
983 | ||
984 | rcu_read_lock(); | |
f698d856 | 985 | mpath = mesh_path_lookup(dst, sdata); |
c5dd9c2b LCC |
986 | if (!mpath) { |
987 | rcu_read_unlock(); | |
988 | return -ENOENT; | |
989 | } | |
990 | memcpy(dst, mpath->dst, ETH_ALEN); | |
991 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
992 | rcu_read_unlock(); | |
993 | return 0; | |
994 | } | |
995 | ||
996 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, | |
997 | int idx, u8 *dst, u8 *next_hop, | |
998 | struct mpath_info *pinfo) | |
999 | { | |
14db74bc JB |
1000 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1001 | struct ieee80211_sub_if_data *sdata; | |
c5dd9c2b LCC |
1002 | struct mesh_path *mpath; |
1003 | ||
14db74bc JB |
1004 | if (dev == local->mdev) |
1005 | return -EOPNOTSUPP; | |
1006 | ||
1007 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1008 | ||
c5dd9c2b LCC |
1009 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
1010 | return -ENOTSUPP; | |
1011 | ||
1012 | rcu_read_lock(); | |
f698d856 | 1013 | mpath = mesh_path_lookup_by_idx(idx, sdata); |
c5dd9c2b LCC |
1014 | if (!mpath) { |
1015 | rcu_read_unlock(); | |
1016 | return -ENOENT; | |
1017 | } | |
1018 | memcpy(dst, mpath->dst, ETH_ALEN); | |
1019 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
1020 | rcu_read_unlock(); | |
1021 | return 0; | |
1022 | } | |
1023 | #endif | |
1024 | ||
9f1ba906 JM |
1025 | static int ieee80211_change_bss(struct wiphy *wiphy, |
1026 | struct net_device *dev, | |
1027 | struct bss_parameters *params) | |
1028 | { | |
1029 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1030 | struct ieee80211_sub_if_data *sdata; | |
1031 | u32 changed = 0; | |
1032 | ||
1033 | if (dev == local->mdev) | |
1034 | return -EOPNOTSUPP; | |
1035 | ||
1036 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1037 | ||
1038 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) | |
1039 | return -EINVAL; | |
1040 | ||
1041 | if (params->use_cts_prot >= 0) { | |
1042 | sdata->bss_conf.use_cts_prot = params->use_cts_prot; | |
1043 | changed |= BSS_CHANGED_ERP_CTS_PROT; | |
1044 | } | |
1045 | if (params->use_short_preamble >= 0) { | |
1046 | sdata->bss_conf.use_short_preamble = | |
1047 | params->use_short_preamble; | |
1048 | changed |= BSS_CHANGED_ERP_PREAMBLE; | |
1049 | } | |
1050 | if (params->use_short_slot_time >= 0) { | |
1051 | sdata->bss_conf.use_short_slot = | |
1052 | params->use_short_slot_time; | |
1053 | changed |= BSS_CHANGED_ERP_SLOT; | |
1054 | } | |
1055 | ||
1056 | ieee80211_bss_info_change_notify(sdata, changed); | |
1057 | ||
1058 | return 0; | |
1059 | } | |
1060 | ||
f0706e82 JB |
1061 | struct cfg80211_ops mac80211_config_ops = { |
1062 | .add_virtual_intf = ieee80211_add_iface, | |
1063 | .del_virtual_intf = ieee80211_del_iface, | |
42613db7 | 1064 | .change_virtual_intf = ieee80211_change_iface, |
e8cbb4cb JB |
1065 | .add_key = ieee80211_add_key, |
1066 | .del_key = ieee80211_del_key, | |
62da92fb | 1067 | .get_key = ieee80211_get_key, |
e8cbb4cb | 1068 | .set_default_key = ieee80211_config_default_key, |
5dfdaf58 JB |
1069 | .add_beacon = ieee80211_add_beacon, |
1070 | .set_beacon = ieee80211_set_beacon, | |
1071 | .del_beacon = ieee80211_del_beacon, | |
4fd6931e JB |
1072 | .add_station = ieee80211_add_station, |
1073 | .del_station = ieee80211_del_station, | |
1074 | .change_station = ieee80211_change_station, | |
7bbdd2d9 | 1075 | .get_station = ieee80211_get_station, |
c5dd9c2b LCC |
1076 | .dump_station = ieee80211_dump_station, |
1077 | #ifdef CONFIG_MAC80211_MESH | |
1078 | .add_mpath = ieee80211_add_mpath, | |
1079 | .del_mpath = ieee80211_del_mpath, | |
1080 | .change_mpath = ieee80211_change_mpath, | |
1081 | .get_mpath = ieee80211_get_mpath, | |
1082 | .dump_mpath = ieee80211_dump_mpath, | |
1083 | #endif | |
9f1ba906 | 1084 | .change_bss = ieee80211_change_bss, |
f0706e82 | 1085 | }; |