2 * mac80211 configuration hooks for cfg80211
4 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
6 * This file is GPLv2 as found in COPYING.
9 #include <linux/ieee80211.h>
10 #include <linux/nl80211.h>
11 #include <linux/rtnetlink.h>
12 #include <net/net_namespace.h>
13 #include <linux/rcupdate.h>
14 #include <net/cfg80211.h>
15 #include "ieee80211_i.h"
20 struct ieee80211_hw
*wiphy_to_hw(struct wiphy
*wiphy
)
22 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
25 EXPORT_SYMBOL(wiphy_to_hw
);
27 static bool nl80211_type_check(enum nl80211_iftype type
)
30 case NL80211_IFTYPE_ADHOC
:
31 case NL80211_IFTYPE_STATION
:
32 case NL80211_IFTYPE_MONITOR
:
33 #ifdef CONFIG_MAC80211_MESH
34 case NL80211_IFTYPE_MESH_POINT
:
36 case NL80211_IFTYPE_WDS
:
43 static int ieee80211_add_iface(struct wiphy
*wiphy
, char *name
,
44 enum nl80211_iftype type
, u32
*flags
,
45 struct vif_params
*params
)
47 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
48 struct net_device
*dev
;
49 struct ieee80211_sub_if_data
*sdata
;
52 if (!nl80211_type_check(type
))
55 err
= ieee80211_if_add(local
, name
, &dev
, type
, params
);
56 if (err
|| type
!= NL80211_IFTYPE_MONITOR
|| !flags
)
59 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
60 sdata
->u
.mntr_flags
= *flags
;
64 static int ieee80211_del_iface(struct wiphy
*wiphy
, int ifindex
)
66 struct net_device
*dev
;
67 struct ieee80211_sub_if_data
*sdata
;
69 /* we're under RTNL */
70 dev
= __dev_get_by_index(&init_net
, ifindex
);
74 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
76 ieee80211_if_remove(sdata
);
81 static int ieee80211_change_iface(struct wiphy
*wiphy
, int ifindex
,
82 enum nl80211_iftype type
, u32
*flags
,
83 struct vif_params
*params
)
85 struct net_device
*dev
;
86 struct ieee80211_sub_if_data
*sdata
;
89 /* we're under RTNL */
90 dev
= __dev_get_by_index(&init_net
, ifindex
);
94 if (!nl80211_type_check(type
))
97 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
99 ret
= ieee80211_if_change_type(sdata
, type
);
103 if (netif_running(sdata
->dev
))
106 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
107 ieee80211_sdata_set_mesh_id(sdata
,
111 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
|| !flags
)
114 sdata
->u
.mntr_flags
= *flags
;
118 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
119 u8 key_idx
, u8
*mac_addr
,
120 struct key_params
*params
)
122 struct ieee80211_sub_if_data
*sdata
;
123 struct sta_info
*sta
= NULL
;
124 enum ieee80211_key_alg alg
;
125 struct ieee80211_key
*key
;
128 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
130 switch (params
->cipher
) {
131 case WLAN_CIPHER_SUITE_WEP40
:
132 case WLAN_CIPHER_SUITE_WEP104
:
135 case WLAN_CIPHER_SUITE_TKIP
:
138 case WLAN_CIPHER_SUITE_CCMP
:
145 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
152 sta
= sta_info_get(sdata
->local
, mac_addr
);
154 ieee80211_key_free(key
);
160 ieee80211_key_link(key
, sdata
, sta
);
169 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
170 u8 key_idx
, u8
*mac_addr
)
172 struct ieee80211_sub_if_data
*sdata
;
173 struct sta_info
*sta
;
176 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
183 sta
= sta_info_get(sdata
->local
, mac_addr
);
188 ieee80211_key_free(sta
->key
);
196 if (!sdata
->keys
[key_idx
]) {
201 ieee80211_key_free(sdata
->keys
[key_idx
]);
202 WARN_ON(sdata
->keys
[key_idx
]);
211 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
212 u8 key_idx
, u8
*mac_addr
, void *cookie
,
213 void (*callback
)(void *cookie
,
214 struct key_params
*params
))
216 struct ieee80211_sub_if_data
*sdata
;
217 struct sta_info
*sta
= NULL
;
219 struct key_params params
;
220 struct ieee80211_key
*key
;
225 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
230 sta
= sta_info_get(sdata
->local
, mac_addr
);
236 key
= sdata
->keys
[key_idx
];
241 memset(¶ms
, 0, sizeof(params
));
243 switch (key
->conf
.alg
) {
245 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
247 iv32
= key
->u
.tkip
.tx
.iv32
;
248 iv16
= key
->u
.tkip
.tx
.iv16
;
250 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
251 sdata
->local
->ops
->get_tkip_seq
)
252 sdata
->local
->ops
->get_tkip_seq(
253 local_to_hw(sdata
->local
),
254 key
->conf
.hw_key_idx
,
257 seq
[0] = iv16
& 0xff;
258 seq
[1] = (iv16
>> 8) & 0xff;
259 seq
[2] = iv32
& 0xff;
260 seq
[3] = (iv32
>> 8) & 0xff;
261 seq
[4] = (iv32
>> 16) & 0xff;
262 seq
[5] = (iv32
>> 24) & 0xff;
267 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
268 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
269 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
270 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
271 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
272 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
273 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
278 if (key
->conf
.keylen
== 5)
279 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
281 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
285 params
.key
= key
->conf
.key
;
286 params
.key_len
= key
->conf
.keylen
;
288 callback(cookie
, ¶ms
);
296 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
297 struct net_device
*dev
,
300 struct ieee80211_sub_if_data
*sdata
;
304 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
305 ieee80211_set_default_key(sdata
, key_idx
);
312 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
314 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
316 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
317 STATION_INFO_RX_BYTES
|
318 STATION_INFO_TX_BYTES
;
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
;
324 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
325 #ifdef CONFIG_MAC80211_MESH
326 sinfo
->filled
|= STATION_INFO_LLID
|
328 STATION_INFO_PLINK_STATE
;
330 sinfo
->llid
= le16_to_cpu(sta
->llid
);
331 sinfo
->plid
= le16_to_cpu(sta
->plid
);
332 sinfo
->plink_state
= sta
->plink_state
;
338 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
339 int idx
, u8
*mac
, struct station_info
*sinfo
)
341 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
342 struct sta_info
*sta
;
347 sta
= sta_info_get_by_idx(local
, idx
, dev
);
350 memcpy(mac
, sta
->sta
.addr
, ETH_ALEN
);
351 sta_set_sinfo(sta
, sinfo
);
359 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
360 u8
*mac
, struct station_info
*sinfo
)
362 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
363 struct sta_info
*sta
;
368 /* XXX: verify sta->dev == dev */
370 sta
= sta_info_get(local
, mac
);
373 sta_set_sinfo(sta
, sinfo
);
382 * This handles both adding a beacon and setting new beacon info
384 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
385 struct beacon_parameters
*params
)
387 struct beacon_data
*new, *old
;
388 int new_head_len
, new_tail_len
;
392 old
= sdata
->u
.ap
.beacon
;
394 /* head must not be zero-length */
395 if (params
->head
&& !params
->head_len
)
399 * This is a kludge. beacon interval should really be part
400 * of the beacon information.
402 if (params
->interval
) {
403 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
404 if (ieee80211_hw_config(sdata
->local
))
407 * We updated some parameter so if below bails out
413 /* Need to have a beacon head if we don't have one yet */
414 if (!params
->head
&& !old
)
417 /* sorry, no way to start beaconing without dtim period */
418 if (!params
->dtim_period
&& !old
)
421 /* new or old head? */
423 new_head_len
= params
->head_len
;
425 new_head_len
= old
->head_len
;
427 /* new or old tail? */
428 if (params
->tail
|| !old
)
429 /* params->tail_len will be zero for !params->tail */
430 new_tail_len
= params
->tail_len
;
432 new_tail_len
= old
->tail_len
;
434 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
436 new = kzalloc(size
, GFP_KERNEL
);
440 /* start filling the new info now */
442 /* new or old dtim period? */
443 if (params
->dtim_period
)
444 new->dtim_period
= params
->dtim_period
;
446 new->dtim_period
= old
->dtim_period
;
449 * pointers go into the block we allocated,
450 * memory is | beacon_data | head | tail |
452 new->head
= ((u8
*) new) + sizeof(*new);
453 new->tail
= new->head
+ new_head_len
;
454 new->head_len
= new_head_len
;
455 new->tail_len
= new_tail_len
;
459 memcpy(new->head
, params
->head
, new_head_len
);
461 memcpy(new->head
, old
->head
, new_head_len
);
463 /* copy in optional tail */
465 memcpy(new->tail
, params
->tail
, new_tail_len
);
468 memcpy(new->tail
, old
->tail
, new_tail_len
);
470 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
476 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
479 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
480 struct beacon_parameters
*params
)
482 struct ieee80211_sub_if_data
*sdata
;
483 struct beacon_data
*old
;
485 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
487 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
490 old
= sdata
->u
.ap
.beacon
;
495 return ieee80211_config_beacon(sdata
, params
);
498 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
499 struct beacon_parameters
*params
)
501 struct ieee80211_sub_if_data
*sdata
;
502 struct beacon_data
*old
;
504 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
506 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
509 old
= sdata
->u
.ap
.beacon
;
514 return ieee80211_config_beacon(sdata
, params
);
517 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
519 struct ieee80211_sub_if_data
*sdata
;
520 struct beacon_data
*old
;
522 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
524 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
527 old
= sdata
->u
.ap
.beacon
;
532 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
536 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
539 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
540 struct iapp_layer2_update
{
541 u8 da
[ETH_ALEN
]; /* broadcast */
542 u8 sa
[ETH_ALEN
]; /* STA addr */
548 } __attribute__ ((packed
));
550 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
552 struct iapp_layer2_update
*msg
;
555 /* Send Level 2 Update Frame to update forwarding tables in layer 2
558 skb
= dev_alloc_skb(sizeof(*msg
));
561 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
563 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
564 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
566 memset(msg
->da
, 0xff, ETH_ALEN
);
567 memcpy(msg
->sa
, sta
->sta
.addr
, ETH_ALEN
);
570 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
571 msg
->control
= 0xaf; /* XID response lsb.1111F101.
572 * F=0 (no poll command; unsolicited frame) */
573 msg
->xid_info
[0] = 0x81; /* XID format identifier */
574 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
575 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
577 skb
->dev
= sta
->sdata
->dev
;
578 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
579 memset(skb
->cb
, 0, sizeof(skb
->cb
));
583 static void sta_apply_parameters(struct ieee80211_local
*local
,
584 struct sta_info
*sta
,
585 struct station_parameters
*params
)
589 struct ieee80211_supported_band
*sband
;
590 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
593 * FIXME: updating the flags is racy when this function is
594 * called from ieee80211_change_station(), this will
595 * be resolved in a future patch.
598 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
599 spin_lock_bh(&sta
->lock
);
600 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
601 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
602 sta
->flags
|= WLAN_STA_AUTHORIZED
;
604 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
605 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
606 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
608 sta
->flags
&= ~WLAN_STA_WME
;
609 if (params
->station_flags
& STATION_FLAG_WME
)
610 sta
->flags
|= WLAN_STA_WME
;
611 spin_unlock_bh(&sta
->lock
);
615 * FIXME: updating the following information is racy when this
616 * function is called from ieee80211_change_station().
617 * However, all this information should be static so
618 * maybe we should just reject attemps to change it.
622 sta
->sta
.aid
= params
->aid
;
623 if (sta
->sta
.aid
> IEEE80211_MAX_AID
)
624 sta
->sta
.aid
= 0; /* XXX: should this be an error? */
627 if (params
->listen_interval
>= 0)
628 sta
->listen_interval
= params
->listen_interval
;
630 if (params
->supported_rates
) {
632 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
634 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
635 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
636 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
637 if (sband
->bitrates
[j
].bitrate
== rate
)
641 sta
->sta
.supp_rates
[local
->oper_channel
->band
] = rates
;
644 if (params
->ht_capa
) {
645 ieee80211_ht_cap_ie_to_ht_info(params
->ht_capa
,
649 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
650 switch (params
->plink_action
) {
651 case PLINK_ACTION_OPEN
:
652 mesh_plink_open(sta
);
654 case PLINK_ACTION_BLOCK
:
655 mesh_plink_block(sta
);
661 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
662 u8
*mac
, struct station_parameters
*params
)
664 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
665 struct sta_info
*sta
;
666 struct ieee80211_sub_if_data
*sdata
;
669 /* Prevent a race with changing the rate control algorithm */
670 if (!netif_running(dev
))
674 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
676 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
677 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
680 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
682 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
685 if (is_multicast_ether_addr(mac
))
688 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
692 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
694 sta_apply_parameters(local
, sta
, params
);
696 rate_control_rate_init(sta
);
700 err
= sta_info_insert(sta
);
702 /* STA has been freed */
707 if (sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
708 sdata
->vif
.type
== NL80211_IFTYPE_AP
)
709 ieee80211_send_layer2_update(sta
);
716 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
719 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
720 struct ieee80211_sub_if_data
*sdata
;
721 struct sta_info
*sta
;
723 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
728 /* XXX: get sta belonging to dev */
729 sta
= sta_info_get(local
, mac
);
735 sta_info_unlink(&sta
);
738 sta_info_destroy(sta
);
740 sta_info_flush(local
, sdata
);
745 static int ieee80211_change_station(struct wiphy
*wiphy
,
746 struct net_device
*dev
,
748 struct station_parameters
*params
)
750 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
751 struct sta_info
*sta
;
752 struct ieee80211_sub_if_data
*vlansdata
;
756 /* XXX: get sta belonging to dev */
757 sta
= sta_info_get(local
, mac
);
763 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
764 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
766 if (vlansdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
767 vlansdata
->vif
.type
!= NL80211_IFTYPE_AP
) {
772 sta
->sdata
= vlansdata
;
773 ieee80211_send_layer2_update(sta
);
776 sta_apply_parameters(local
, sta
, params
);
783 #ifdef CONFIG_MAC80211_MESH
784 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
785 u8
*dst
, u8
*next_hop
)
787 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
788 struct ieee80211_sub_if_data
*sdata
;
789 struct mesh_path
*mpath
;
790 struct sta_info
*sta
;
793 if (!netif_running(dev
))
796 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
798 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
802 sta
= sta_info_get(local
, next_hop
);
808 err
= mesh_path_add(dst
, sdata
);
814 mpath
= mesh_path_lookup(dst
, sdata
);
819 mesh_path_fix_nexthop(mpath
, sta
);
825 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
828 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
831 return mesh_path_del(dst
, sdata
);
833 mesh_path_flush(sdata
);
837 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
838 struct net_device
*dev
,
839 u8
*dst
, u8
*next_hop
)
841 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
842 struct ieee80211_sub_if_data
*sdata
;
843 struct mesh_path
*mpath
;
844 struct sta_info
*sta
;
846 if (!netif_running(dev
))
849 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
851 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
856 sta
= sta_info_get(local
, next_hop
);
862 mpath
= mesh_path_lookup(dst
, sdata
);
868 mesh_path_fix_nexthop(mpath
, sta
);
874 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
875 struct mpath_info
*pinfo
)
878 memcpy(next_hop
, mpath
->next_hop
->sta
.addr
, ETH_ALEN
);
880 memset(next_hop
, 0, ETH_ALEN
);
882 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
886 MPATH_INFO_DISCOVERY_TIMEOUT
|
887 MPATH_INFO_DISCOVERY_RETRIES
|
890 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
891 pinfo
->dsn
= mpath
->dsn
;
892 pinfo
->metric
= mpath
->metric
;
893 if (time_before(jiffies
, mpath
->exp_time
))
894 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
895 pinfo
->discovery_timeout
=
896 jiffies_to_msecs(mpath
->discovery_timeout
);
897 pinfo
->discovery_retries
= mpath
->discovery_retries
;
899 if (mpath
->flags
& MESH_PATH_ACTIVE
)
900 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
901 if (mpath
->flags
& MESH_PATH_RESOLVING
)
902 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
903 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
904 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
905 if (mpath
->flags
& MESH_PATH_FIXED
)
906 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
907 if (mpath
->flags
& MESH_PATH_RESOLVING
)
908 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
910 pinfo
->flags
= mpath
->flags
;
913 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
914 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
917 struct ieee80211_sub_if_data
*sdata
;
918 struct mesh_path
*mpath
;
920 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
922 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
926 mpath
= mesh_path_lookup(dst
, sdata
);
931 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
932 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
937 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
938 int idx
, u8
*dst
, u8
*next_hop
,
939 struct mpath_info
*pinfo
)
941 struct ieee80211_sub_if_data
*sdata
;
942 struct mesh_path
*mpath
;
944 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
946 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
950 mpath
= mesh_path_lookup_by_idx(idx
, sdata
);
955 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
956 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
962 static int ieee80211_change_bss(struct wiphy
*wiphy
,
963 struct net_device
*dev
,
964 struct bss_parameters
*params
)
966 struct ieee80211_sub_if_data
*sdata
;
969 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
971 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
974 if (params
->use_cts_prot
>= 0) {
975 sdata
->bss_conf
.use_cts_prot
= params
->use_cts_prot
;
976 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
978 if (params
->use_short_preamble
>= 0) {
979 sdata
->bss_conf
.use_short_preamble
=
980 params
->use_short_preamble
;
981 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
983 if (params
->use_short_slot_time
>= 0) {
984 sdata
->bss_conf
.use_short_slot
=
985 params
->use_short_slot_time
;
986 changed
|= BSS_CHANGED_ERP_SLOT
;
989 ieee80211_bss_info_change_notify(sdata
, changed
);
994 struct cfg80211_ops mac80211_config_ops
= {
995 .add_virtual_intf
= ieee80211_add_iface
,
996 .del_virtual_intf
= ieee80211_del_iface
,
997 .change_virtual_intf
= ieee80211_change_iface
,
998 .add_key
= ieee80211_add_key
,
999 .del_key
= ieee80211_del_key
,
1000 .get_key
= ieee80211_get_key
,
1001 .set_default_key
= ieee80211_config_default_key
,
1002 .add_beacon
= ieee80211_add_beacon
,
1003 .set_beacon
= ieee80211_set_beacon
,
1004 .del_beacon
= ieee80211_del_beacon
,
1005 .add_station
= ieee80211_add_station
,
1006 .del_station
= ieee80211_del_station
,
1007 .change_station
= ieee80211_change_station
,
1008 .get_station
= ieee80211_get_station
,
1009 .dump_station
= ieee80211_dump_station
,
1010 #ifdef CONFIG_MAC80211_MESH
1011 .add_mpath
= ieee80211_add_mpath
,
1012 .del_mpath
= ieee80211_del_mpath
,
1013 .change_mpath
= ieee80211_change_mpath
,
1014 .get_mpath
= ieee80211_get_mpath
,
1015 .dump_mpath
= ieee80211_dump_mpath
,
1017 .change_bss
= ieee80211_change_bss
,