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 enum ieee80211_if_types
28 nl80211_type_to_mac80211_type(enum nl80211_iftype 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
;
39 #ifdef CONFIG_MAC80211_MESH
40 case NL80211_IFTYPE_MESH_POINT
:
41 return IEEE80211_IF_TYPE_MESH_POINT
;
43 case NL80211_IFTYPE_WDS
:
44 return IEEE80211_IF_TYPE_WDS
;
46 return IEEE80211_IF_TYPE_INVALID
;
50 static int ieee80211_add_iface(struct wiphy
*wiphy
, char *name
,
51 enum nl80211_iftype type
, u32
*flags
,
52 struct vif_params
*params
)
54 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
55 enum ieee80211_if_types itype
;
56 struct net_device
*dev
;
57 struct ieee80211_sub_if_data
*sdata
;
60 itype
= nl80211_type_to_mac80211_type(type
);
61 if (itype
== IEEE80211_IF_TYPE_INVALID
)
64 err
= ieee80211_if_add(local
, name
, &dev
, itype
, params
);
65 if (err
|| itype
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
68 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
69 sdata
->u
.mntr_flags
= *flags
;
73 static int ieee80211_del_iface(struct wiphy
*wiphy
, int ifindex
)
75 struct net_device
*dev
;
76 struct ieee80211_sub_if_data
*sdata
;
78 /* we're under RTNL */
79 dev
= __dev_get_by_index(&init_net
, ifindex
);
83 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
85 ieee80211_if_remove(sdata
);
90 static int ieee80211_change_iface(struct wiphy
*wiphy
, int ifindex
,
91 enum nl80211_iftype type
, u32
*flags
,
92 struct vif_params
*params
)
94 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
95 struct net_device
*dev
;
96 enum ieee80211_if_types itype
;
97 struct ieee80211_sub_if_data
*sdata
;
100 /* we're under RTNL */
101 dev
= __dev_get_by_index(&init_net
, ifindex
);
105 itype
= nl80211_type_to_mac80211_type(type
);
106 if (itype
== IEEE80211_IF_TYPE_INVALID
)
109 if (dev
== local
->mdev
)
112 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
114 ret
= ieee80211_if_change_type(sdata
, itype
);
118 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
119 ieee80211_sdata_set_mesh_id(sdata
,
123 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
126 sdata
->u
.mntr_flags
= *flags
;
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
)
134 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
135 struct ieee80211_sub_if_data
*sdata
;
136 struct sta_info
*sta
= NULL
;
137 enum ieee80211_key_alg alg
;
138 struct ieee80211_key
*key
;
141 if (dev
== local
->mdev
)
144 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
146 switch (params
->cipher
) {
147 case WLAN_CIPHER_SUITE_WEP40
:
148 case WLAN_CIPHER_SUITE_WEP104
:
151 case WLAN_CIPHER_SUITE_TKIP
:
154 case WLAN_CIPHER_SUITE_CCMP
:
161 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
168 sta
= sta_info_get(sdata
->local
, mac_addr
);
170 ieee80211_key_free(key
);
176 ieee80211_key_link(key
, sdata
, sta
);
185 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
186 u8 key_idx
, u8
*mac_addr
)
188 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
189 struct ieee80211_sub_if_data
*sdata
;
190 struct sta_info
*sta
;
193 if (dev
== local
->mdev
)
196 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
203 sta
= sta_info_get(sdata
->local
, mac_addr
);
208 ieee80211_key_free(sta
->key
);
216 if (!sdata
->keys
[key_idx
]) {
221 ieee80211_key_free(sdata
->keys
[key_idx
]);
222 WARN_ON(sdata
->keys
[key_idx
]);
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
))
236 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
237 struct ieee80211_sub_if_data
*sdata
;
238 struct sta_info
*sta
= NULL
;
240 struct key_params params
;
241 struct ieee80211_key
*key
;
246 if (dev
== local
->mdev
)
249 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
254 sta
= sta_info_get(sdata
->local
, mac_addr
);
260 key
= sdata
->keys
[key_idx
];
265 memset(¶ms
, 0, sizeof(params
));
267 switch (key
->conf
.alg
) {
269 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
271 iv32
= key
->u
.tkip
.tx
.iv32
;
272 iv16
= key
->u
.tkip
.tx
.iv16
;
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
,
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;
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];
302 if (key
->conf
.keylen
== 5)
303 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
305 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
309 params
.key
= key
->conf
.key
;
310 params
.key_len
= key
->conf
.keylen
;
312 callback(cookie
, ¶ms
);
320 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
321 struct net_device
*dev
,
324 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
325 struct ieee80211_sub_if_data
*sdata
;
327 if (dev
== local
->mdev
)
332 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
333 ieee80211_set_default_key(sdata
, key_idx
);
340 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
342 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
344 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
345 STATION_INFO_RX_BYTES
|
346 STATION_INFO_TX_BYTES
;
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
;
352 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
353 #ifdef CONFIG_MAC80211_MESH
354 sinfo
->filled
|= STATION_INFO_LLID
|
356 STATION_INFO_PLINK_STATE
;
358 sinfo
->llid
= le16_to_cpu(sta
->llid
);
359 sinfo
->plid
= le16_to_cpu(sta
->plid
);
360 sinfo
->plink_state
= sta
->plink_state
;
366 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
367 int idx
, u8
*mac
, struct station_info
*sinfo
)
369 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
370 struct sta_info
*sta
;
375 sta
= sta_info_get_by_idx(local
, idx
, dev
);
378 memcpy(mac
, sta
->addr
, ETH_ALEN
);
379 sta_set_sinfo(sta
, sinfo
);
387 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
388 u8
*mac
, struct station_info
*sinfo
)
390 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
391 struct sta_info
*sta
;
396 /* XXX: verify sta->dev == dev */
398 sta
= sta_info_get(local
, mac
);
401 sta_set_sinfo(sta
, sinfo
);
410 * This handles both adding a beacon and setting new beacon info
412 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
413 struct beacon_parameters
*params
)
415 struct beacon_data
*new, *old
;
416 int new_head_len
, new_tail_len
;
420 old
= sdata
->u
.ap
.beacon
;
422 /* head must not be zero-length */
423 if (params
->head
&& !params
->head_len
)
427 * This is a kludge. beacon interval should really be part
428 * of the beacon information.
430 if (params
->interval
) {
431 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
432 if (ieee80211_hw_config(sdata
->local
))
435 * We updated some parameter so if below bails out
441 /* Need to have a beacon head if we don't have one yet */
442 if (!params
->head
&& !old
)
445 /* sorry, no way to start beaconing without dtim period */
446 if (!params
->dtim_period
&& !old
)
449 /* new or old head? */
451 new_head_len
= params
->head_len
;
453 new_head_len
= old
->head_len
;
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
;
460 new_tail_len
= old
->tail_len
;
462 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
464 new = kzalloc(size
, GFP_KERNEL
);
468 /* start filling the new info now */
470 /* new or old dtim period? */
471 if (params
->dtim_period
)
472 new->dtim_period
= params
->dtim_period
;
474 new->dtim_period
= old
->dtim_period
;
477 * pointers go into the block we allocated,
478 * memory is | beacon_data | head | tail |
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
;
487 memcpy(new->head
, params
->head
, new_head_len
);
489 memcpy(new->head
, old
->head
, new_head_len
);
491 /* copy in optional tail */
493 memcpy(new->tail
, params
->tail
, new_tail_len
);
496 memcpy(new->tail
, old
->tail
, new_tail_len
);
498 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
504 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
507 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
508 struct beacon_parameters
*params
)
510 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
511 struct ieee80211_sub_if_data
*sdata
;
512 struct beacon_data
*old
;
514 if (dev
== local
->mdev
)
517 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
519 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
522 old
= sdata
->u
.ap
.beacon
;
527 return ieee80211_config_beacon(sdata
, params
);
530 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
531 struct beacon_parameters
*params
)
533 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
534 struct ieee80211_sub_if_data
*sdata
;
535 struct beacon_data
*old
;
537 if (dev
== local
->mdev
)
540 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
542 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
545 old
= sdata
->u
.ap
.beacon
;
550 return ieee80211_config_beacon(sdata
, params
);
553 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
555 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
556 struct ieee80211_sub_if_data
*sdata
;
557 struct beacon_data
*old
;
559 if (dev
== local
->mdev
)
562 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
564 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
567 old
= sdata
->u
.ap
.beacon
;
572 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
576 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
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 */
588 } __attribute__ ((packed
));
590 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
592 struct iapp_layer2_update
*msg
;
595 /* Send Level 2 Update Frame to update forwarding tables in layer 2
598 skb
= dev_alloc_skb(sizeof(*msg
));
601 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
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 */
606 memset(msg
->da
, 0xff, ETH_ALEN
);
607 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
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) */
617 skb
->dev
= sta
->sdata
->dev
;
618 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
619 memset(skb
->cb
, 0, sizeof(skb
->cb
));
623 static void sta_apply_parameters(struct ieee80211_local
*local
,
624 struct sta_info
*sta
,
625 struct station_parameters
*params
)
629 struct ieee80211_supported_band
*sband
;
630 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
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.
638 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
639 spin_lock_bh(&sta
->lock
);
640 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
641 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
642 sta
->flags
|= WLAN_STA_AUTHORIZED
;
644 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
645 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
646 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
648 sta
->flags
&= ~WLAN_STA_WME
;
649 if (params
->station_flags
& STATION_FLAG_WME
)
650 sta
->flags
|= WLAN_STA_WME
;
651 spin_unlock_bh(&sta
->lock
);
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.
662 sta
->aid
= params
->aid
;
663 if (sta
->aid
> IEEE80211_MAX_AID
)
664 sta
->aid
= 0; /* XXX: should this be an error? */
667 if (params
->listen_interval
>= 0)
668 sta
->listen_interval
= params
->listen_interval
;
670 if (params
->supported_rates
) {
672 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
674 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
675 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
676 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
677 if (sband
->bitrates
[j
].bitrate
== rate
)
681 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
684 if (params
->ht_capa
) {
685 ieee80211_ht_cap_ie_to_ht_info(params
->ht_capa
,
689 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
690 switch (params
->plink_action
) {
691 case PLINK_ACTION_OPEN
:
692 mesh_plink_open(sta
);
694 case PLINK_ACTION_BLOCK
:
695 mesh_plink_block(sta
);
701 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
702 u8
*mac
, struct station_parameters
*params
)
704 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
705 struct sta_info
*sta
;
706 struct ieee80211_sub_if_data
*sdata
;
709 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
712 /* Prevent a race with changing the rate control algorithm */
713 if (!netif_running(dev
))
717 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
719 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
&&
720 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
723 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
725 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
728 if (is_multicast_ether_addr(mac
))
731 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
735 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
737 sta_apply_parameters(local
, sta
, params
);
739 rate_control_rate_init(sta
, local
);
743 err
= sta_info_insert(sta
);
745 /* STA has been freed */
750 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
751 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
752 ieee80211_send_layer2_update(sta
);
759 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
762 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
763 struct ieee80211_sub_if_data
*sdata
;
764 struct sta_info
*sta
;
766 if (dev
== local
->mdev
)
769 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
774 /* XXX: get sta belonging to dev */
775 sta
= sta_info_get(local
, mac
);
781 sta_info_unlink(&sta
);
784 sta_info_destroy(sta
);
786 sta_info_flush(local
, sdata
);
791 static int ieee80211_change_station(struct wiphy
*wiphy
,
792 struct net_device
*dev
,
794 struct station_parameters
*params
)
796 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
797 struct sta_info
*sta
;
798 struct ieee80211_sub_if_data
*vlansdata
;
800 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
805 /* XXX: get sta belonging to dev */
806 sta
= sta_info_get(local
, mac
);
812 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
813 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
815 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
&&
816 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
) {
821 sta
->sdata
= vlansdata
;
822 ieee80211_send_layer2_update(sta
);
825 sta_apply_parameters(local
, sta
, params
);
832 #ifdef CONFIG_MAC80211_MESH
833 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
834 u8
*dst
, u8
*next_hop
)
836 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
837 struct ieee80211_sub_if_data
*sdata
;
838 struct mesh_path
*mpath
;
839 struct sta_info
*sta
;
842 if (dev
== local
->mdev
)
845 if (!netif_running(dev
))
848 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
850 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
854 sta
= sta_info_get(local
, next_hop
);
860 err
= mesh_path_add(dst
, sdata
);
866 mpath
= mesh_path_lookup(dst
, sdata
);
871 mesh_path_fix_nexthop(mpath
, sta
);
877 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
880 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
883 return mesh_path_del(dst
, sdata
);
885 mesh_path_flush(sdata
);
889 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
890 struct net_device
*dev
,
891 u8
*dst
, u8
*next_hop
)
893 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
894 struct ieee80211_sub_if_data
*sdata
;
895 struct mesh_path
*mpath
;
896 struct sta_info
*sta
;
898 if (dev
== local
->mdev
)
901 if (!netif_running(dev
))
904 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
906 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
911 sta
= sta_info_get(local
, next_hop
);
917 mpath
= mesh_path_lookup(dst
, sdata
);
923 mesh_path_fix_nexthop(mpath
, sta
);
929 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
930 struct mpath_info
*pinfo
)
933 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
935 memset(next_hop
, 0, ETH_ALEN
);
937 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
941 MPATH_INFO_DISCOVERY_TIMEOUT
|
942 MPATH_INFO_DISCOVERY_RETRIES
|
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
;
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
;
965 pinfo
->flags
= mpath
->flags
;
968 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
969 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
972 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
973 struct ieee80211_sub_if_data
*sdata
;
974 struct mesh_path
*mpath
;
976 if (dev
== local
->mdev
)
979 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
981 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
985 mpath
= mesh_path_lookup(dst
, sdata
);
990 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
991 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
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
)
1000 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1001 struct ieee80211_sub_if_data
*sdata
;
1002 struct mesh_path
*mpath
;
1004 if (dev
== local
->mdev
)
1007 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1009 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
1013 mpath
= mesh_path_lookup_by_idx(idx
, sdata
);
1018 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1019 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1025 static int ieee80211_change_bss(struct wiphy
*wiphy
,
1026 struct net_device
*dev
,
1027 struct bss_parameters
*params
)
1029 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1030 struct ieee80211_sub_if_data
*sdata
;
1033 if (dev
== local
->mdev
)
1036 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1038 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
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
;
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
;
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
;
1056 ieee80211_bss_info_change_notify(sdata
, changed
);
1061 struct cfg80211_ops mac80211_config_ops
= {
1062 .add_virtual_intf
= ieee80211_add_iface
,
1063 .del_virtual_intf
= ieee80211_del_iface
,
1064 .change_virtual_intf
= ieee80211_change_iface
,
1065 .add_key
= ieee80211_add_key
,
1066 .del_key
= ieee80211_del_key
,
1067 .get_key
= ieee80211_get_key
,
1068 .set_default_key
= ieee80211_config_default_key
,
1069 .add_beacon
= ieee80211_add_beacon
,
1070 .set_beacon
= ieee80211_set_beacon
,
1071 .del_beacon
= ieee80211_del_beacon
,
1072 .add_station
= ieee80211_add_station
,
1073 .del_station
= ieee80211_del_station
,
1074 .change_station
= ieee80211_change_station
,
1075 .get_station
= ieee80211_get_station
,
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
,
1084 .change_bss
= ieee80211_change_bss
,