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 ieee80211_local
*local
= wiphy_priv(wiphy
);
86 struct net_device
*dev
;
87 struct ieee80211_sub_if_data
*sdata
;
90 /* we're under RTNL */
91 dev
= __dev_get_by_index(&init_net
, ifindex
);
95 if (!nl80211_type_check(type
))
98 if (dev
== local
->mdev
)
101 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
103 ret
= ieee80211_if_change_type(sdata
, type
);
107 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
108 ieee80211_sdata_set_mesh_id(sdata
,
112 if (sdata
->vif
.type
!= NL80211_IFTYPE_MONITOR
|| !flags
)
115 sdata
->u
.mntr_flags
= *flags
;
119 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
120 u8 key_idx
, u8
*mac_addr
,
121 struct key_params
*params
)
123 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
124 struct ieee80211_sub_if_data
*sdata
;
125 struct sta_info
*sta
= NULL
;
126 enum ieee80211_key_alg alg
;
127 struct ieee80211_key
*key
;
130 if (dev
== local
->mdev
)
133 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
135 switch (params
->cipher
) {
136 case WLAN_CIPHER_SUITE_WEP40
:
137 case WLAN_CIPHER_SUITE_WEP104
:
140 case WLAN_CIPHER_SUITE_TKIP
:
143 case WLAN_CIPHER_SUITE_CCMP
:
150 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
157 sta
= sta_info_get(sdata
->local
, mac_addr
);
159 ieee80211_key_free(key
);
165 ieee80211_key_link(key
, sdata
, sta
);
174 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
175 u8 key_idx
, u8
*mac_addr
)
177 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
178 struct ieee80211_sub_if_data
*sdata
;
179 struct sta_info
*sta
;
182 if (dev
== local
->mdev
)
185 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
192 sta
= sta_info_get(sdata
->local
, mac_addr
);
197 ieee80211_key_free(sta
->key
);
205 if (!sdata
->keys
[key_idx
]) {
210 ieee80211_key_free(sdata
->keys
[key_idx
]);
211 WARN_ON(sdata
->keys
[key_idx
]);
220 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
221 u8 key_idx
, u8
*mac_addr
, void *cookie
,
222 void (*callback
)(void *cookie
,
223 struct key_params
*params
))
225 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
226 struct ieee80211_sub_if_data
*sdata
;
227 struct sta_info
*sta
= NULL
;
229 struct key_params params
;
230 struct ieee80211_key
*key
;
235 if (dev
== local
->mdev
)
238 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
243 sta
= sta_info_get(sdata
->local
, mac_addr
);
249 key
= sdata
->keys
[key_idx
];
254 memset(¶ms
, 0, sizeof(params
));
256 switch (key
->conf
.alg
) {
258 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
260 iv32
= key
->u
.tkip
.tx
.iv32
;
261 iv16
= key
->u
.tkip
.tx
.iv16
;
263 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
264 sdata
->local
->ops
->get_tkip_seq
)
265 sdata
->local
->ops
->get_tkip_seq(
266 local_to_hw(sdata
->local
),
267 key
->conf
.hw_key_idx
,
270 seq
[0] = iv16
& 0xff;
271 seq
[1] = (iv16
>> 8) & 0xff;
272 seq
[2] = iv32
& 0xff;
273 seq
[3] = (iv32
>> 8) & 0xff;
274 seq
[4] = (iv32
>> 16) & 0xff;
275 seq
[5] = (iv32
>> 24) & 0xff;
280 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
281 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
282 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
283 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
284 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
285 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
286 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
291 if (key
->conf
.keylen
== 5)
292 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
294 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
298 params
.key
= key
->conf
.key
;
299 params
.key_len
= key
->conf
.keylen
;
301 callback(cookie
, ¶ms
);
309 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
310 struct net_device
*dev
,
313 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
314 struct ieee80211_sub_if_data
*sdata
;
316 if (dev
== local
->mdev
)
321 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
322 ieee80211_set_default_key(sdata
, key_idx
);
329 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
331 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
333 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
334 STATION_INFO_RX_BYTES
|
335 STATION_INFO_TX_BYTES
;
337 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
338 sinfo
->rx_bytes
= sta
->rx_bytes
;
339 sinfo
->tx_bytes
= sta
->tx_bytes
;
341 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
342 #ifdef CONFIG_MAC80211_MESH
343 sinfo
->filled
|= STATION_INFO_LLID
|
345 STATION_INFO_PLINK_STATE
;
347 sinfo
->llid
= le16_to_cpu(sta
->llid
);
348 sinfo
->plid
= le16_to_cpu(sta
->plid
);
349 sinfo
->plink_state
= sta
->plink_state
;
355 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
356 int idx
, u8
*mac
, struct station_info
*sinfo
)
358 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
359 struct sta_info
*sta
;
364 sta
= sta_info_get_by_idx(local
, idx
, dev
);
367 memcpy(mac
, sta
->addr
, ETH_ALEN
);
368 sta_set_sinfo(sta
, sinfo
);
376 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
377 u8
*mac
, struct station_info
*sinfo
)
379 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
380 struct sta_info
*sta
;
385 /* XXX: verify sta->dev == dev */
387 sta
= sta_info_get(local
, mac
);
390 sta_set_sinfo(sta
, sinfo
);
399 * This handles both adding a beacon and setting new beacon info
401 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
402 struct beacon_parameters
*params
)
404 struct beacon_data
*new, *old
;
405 int new_head_len
, new_tail_len
;
409 old
= sdata
->u
.ap
.beacon
;
411 /* head must not be zero-length */
412 if (params
->head
&& !params
->head_len
)
416 * This is a kludge. beacon interval should really be part
417 * of the beacon information.
419 if (params
->interval
) {
420 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
421 if (ieee80211_hw_config(sdata
->local
))
424 * We updated some parameter so if below bails out
430 /* Need to have a beacon head if we don't have one yet */
431 if (!params
->head
&& !old
)
434 /* sorry, no way to start beaconing without dtim period */
435 if (!params
->dtim_period
&& !old
)
438 /* new or old head? */
440 new_head_len
= params
->head_len
;
442 new_head_len
= old
->head_len
;
444 /* new or old tail? */
445 if (params
->tail
|| !old
)
446 /* params->tail_len will be zero for !params->tail */
447 new_tail_len
= params
->tail_len
;
449 new_tail_len
= old
->tail_len
;
451 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
453 new = kzalloc(size
, GFP_KERNEL
);
457 /* start filling the new info now */
459 /* new or old dtim period? */
460 if (params
->dtim_period
)
461 new->dtim_period
= params
->dtim_period
;
463 new->dtim_period
= old
->dtim_period
;
466 * pointers go into the block we allocated,
467 * memory is | beacon_data | head | tail |
469 new->head
= ((u8
*) new) + sizeof(*new);
470 new->tail
= new->head
+ new_head_len
;
471 new->head_len
= new_head_len
;
472 new->tail_len
= new_tail_len
;
476 memcpy(new->head
, params
->head
, new_head_len
);
478 memcpy(new->head
, old
->head
, new_head_len
);
480 /* copy in optional tail */
482 memcpy(new->tail
, params
->tail
, new_tail_len
);
485 memcpy(new->tail
, old
->tail
, new_tail_len
);
487 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
493 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
496 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
497 struct beacon_parameters
*params
)
499 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
500 struct ieee80211_sub_if_data
*sdata
;
501 struct beacon_data
*old
;
503 if (dev
== local
->mdev
)
506 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
508 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
511 old
= sdata
->u
.ap
.beacon
;
516 return ieee80211_config_beacon(sdata
, params
);
519 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
520 struct beacon_parameters
*params
)
522 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
523 struct ieee80211_sub_if_data
*sdata
;
524 struct beacon_data
*old
;
526 if (dev
== local
->mdev
)
529 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
531 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
534 old
= sdata
->u
.ap
.beacon
;
539 return ieee80211_config_beacon(sdata
, params
);
542 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
544 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
545 struct ieee80211_sub_if_data
*sdata
;
546 struct beacon_data
*old
;
548 if (dev
== local
->mdev
)
551 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
553 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
556 old
= sdata
->u
.ap
.beacon
;
561 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
565 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
568 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
569 struct iapp_layer2_update
{
570 u8 da
[ETH_ALEN
]; /* broadcast */
571 u8 sa
[ETH_ALEN
]; /* STA addr */
577 } __attribute__ ((packed
));
579 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
581 struct iapp_layer2_update
*msg
;
584 /* Send Level 2 Update Frame to update forwarding tables in layer 2
587 skb
= dev_alloc_skb(sizeof(*msg
));
590 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
592 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
593 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
595 memset(msg
->da
, 0xff, ETH_ALEN
);
596 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
599 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
600 msg
->control
= 0xaf; /* XID response lsb.1111F101.
601 * F=0 (no poll command; unsolicited frame) */
602 msg
->xid_info
[0] = 0x81; /* XID format identifier */
603 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
604 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
606 skb
->dev
= sta
->sdata
->dev
;
607 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
608 memset(skb
->cb
, 0, sizeof(skb
->cb
));
612 static void sta_apply_parameters(struct ieee80211_local
*local
,
613 struct sta_info
*sta
,
614 struct station_parameters
*params
)
618 struct ieee80211_supported_band
*sband
;
619 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
622 * FIXME: updating the flags is racy when this function is
623 * called from ieee80211_change_station(), this will
624 * be resolved in a future patch.
627 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
628 spin_lock_bh(&sta
->lock
);
629 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
630 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
631 sta
->flags
|= WLAN_STA_AUTHORIZED
;
633 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
634 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
635 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
637 sta
->flags
&= ~WLAN_STA_WME
;
638 if (params
->station_flags
& STATION_FLAG_WME
)
639 sta
->flags
|= WLAN_STA_WME
;
640 spin_unlock_bh(&sta
->lock
);
644 * FIXME: updating the following information is racy when this
645 * function is called from ieee80211_change_station().
646 * However, all this information should be static so
647 * maybe we should just reject attemps to change it.
651 sta
->aid
= params
->aid
;
652 if (sta
->aid
> IEEE80211_MAX_AID
)
653 sta
->aid
= 0; /* XXX: should this be an error? */
656 if (params
->listen_interval
>= 0)
657 sta
->listen_interval
= params
->listen_interval
;
659 if (params
->supported_rates
) {
661 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
663 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
664 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
665 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
666 if (sband
->bitrates
[j
].bitrate
== rate
)
670 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
673 if (params
->ht_capa
) {
674 ieee80211_ht_cap_ie_to_ht_info(params
->ht_capa
,
678 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
679 switch (params
->plink_action
) {
680 case PLINK_ACTION_OPEN
:
681 mesh_plink_open(sta
);
683 case PLINK_ACTION_BLOCK
:
684 mesh_plink_block(sta
);
690 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
691 u8
*mac
, struct station_parameters
*params
)
693 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
694 struct sta_info
*sta
;
695 struct ieee80211_sub_if_data
*sdata
;
698 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
701 /* Prevent a race with changing the rate control algorithm */
702 if (!netif_running(dev
))
706 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
708 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
709 sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
712 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
714 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
717 if (is_multicast_ether_addr(mac
))
720 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
724 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
726 sta_apply_parameters(local
, sta
, params
);
728 rate_control_rate_init(sta
, local
);
732 err
= sta_info_insert(sta
);
734 /* STA has been freed */
739 if (sdata
->vif
.type
== NL80211_IFTYPE_AP_VLAN
||
740 sdata
->vif
.type
== NL80211_IFTYPE_AP
)
741 ieee80211_send_layer2_update(sta
);
748 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
751 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
752 struct ieee80211_sub_if_data
*sdata
;
753 struct sta_info
*sta
;
755 if (dev
== local
->mdev
)
758 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
763 /* XXX: get sta belonging to dev */
764 sta
= sta_info_get(local
, mac
);
770 sta_info_unlink(&sta
);
773 sta_info_destroy(sta
);
775 sta_info_flush(local
, sdata
);
780 static int ieee80211_change_station(struct wiphy
*wiphy
,
781 struct net_device
*dev
,
783 struct station_parameters
*params
)
785 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
786 struct sta_info
*sta
;
787 struct ieee80211_sub_if_data
*vlansdata
;
789 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
794 /* XXX: get sta belonging to dev */
795 sta
= sta_info_get(local
, mac
);
801 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
802 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
804 if (vlansdata
->vif
.type
!= NL80211_IFTYPE_AP_VLAN
&&
805 vlansdata
->vif
.type
!= NL80211_IFTYPE_AP
) {
810 sta
->sdata
= vlansdata
;
811 ieee80211_send_layer2_update(sta
);
814 sta_apply_parameters(local
, sta
, params
);
821 #ifdef CONFIG_MAC80211_MESH
822 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
823 u8
*dst
, u8
*next_hop
)
825 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
826 struct ieee80211_sub_if_data
*sdata
;
827 struct mesh_path
*mpath
;
828 struct sta_info
*sta
;
831 if (dev
== local
->mdev
)
834 if (!netif_running(dev
))
837 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
839 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
843 sta
= sta_info_get(local
, next_hop
);
849 err
= mesh_path_add(dst
, sdata
);
855 mpath
= mesh_path_lookup(dst
, sdata
);
860 mesh_path_fix_nexthop(mpath
, sta
);
866 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
869 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
872 return mesh_path_del(dst
, sdata
);
874 mesh_path_flush(sdata
);
878 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
879 struct net_device
*dev
,
880 u8
*dst
, u8
*next_hop
)
882 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
883 struct ieee80211_sub_if_data
*sdata
;
884 struct mesh_path
*mpath
;
885 struct sta_info
*sta
;
887 if (dev
== local
->mdev
)
890 if (!netif_running(dev
))
893 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
895 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
900 sta
= sta_info_get(local
, next_hop
);
906 mpath
= mesh_path_lookup(dst
, sdata
);
912 mesh_path_fix_nexthop(mpath
, sta
);
918 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
919 struct mpath_info
*pinfo
)
922 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
924 memset(next_hop
, 0, ETH_ALEN
);
926 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
930 MPATH_INFO_DISCOVERY_TIMEOUT
|
931 MPATH_INFO_DISCOVERY_RETRIES
|
934 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
935 pinfo
->dsn
= mpath
->dsn
;
936 pinfo
->metric
= mpath
->metric
;
937 if (time_before(jiffies
, mpath
->exp_time
))
938 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
939 pinfo
->discovery_timeout
=
940 jiffies_to_msecs(mpath
->discovery_timeout
);
941 pinfo
->discovery_retries
= mpath
->discovery_retries
;
943 if (mpath
->flags
& MESH_PATH_ACTIVE
)
944 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
945 if (mpath
->flags
& MESH_PATH_RESOLVING
)
946 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
947 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
948 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
949 if (mpath
->flags
& MESH_PATH_FIXED
)
950 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
951 if (mpath
->flags
& MESH_PATH_RESOLVING
)
952 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
954 pinfo
->flags
= mpath
->flags
;
957 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
958 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
961 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
962 struct ieee80211_sub_if_data
*sdata
;
963 struct mesh_path
*mpath
;
965 if (dev
== local
->mdev
)
968 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
970 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
974 mpath
= mesh_path_lookup(dst
, sdata
);
979 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
980 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
985 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
986 int idx
, u8
*dst
, u8
*next_hop
,
987 struct mpath_info
*pinfo
)
989 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
990 struct ieee80211_sub_if_data
*sdata
;
991 struct mesh_path
*mpath
;
993 if (dev
== local
->mdev
)
996 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
998 if (sdata
->vif
.type
!= NL80211_IFTYPE_MESH_POINT
)
1002 mpath
= mesh_path_lookup_by_idx(idx
, sdata
);
1007 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1008 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1014 static int ieee80211_change_bss(struct wiphy
*wiphy
,
1015 struct net_device
*dev
,
1016 struct bss_parameters
*params
)
1018 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
1019 struct ieee80211_sub_if_data
*sdata
;
1022 if (dev
== local
->mdev
)
1025 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
1027 if (sdata
->vif
.type
!= NL80211_IFTYPE_AP
)
1030 if (params
->use_cts_prot
>= 0) {
1031 sdata
->bss_conf
.use_cts_prot
= params
->use_cts_prot
;
1032 changed
|= BSS_CHANGED_ERP_CTS_PROT
;
1034 if (params
->use_short_preamble
>= 0) {
1035 sdata
->bss_conf
.use_short_preamble
=
1036 params
->use_short_preamble
;
1037 changed
|= BSS_CHANGED_ERP_PREAMBLE
;
1039 if (params
->use_short_slot_time
>= 0) {
1040 sdata
->bss_conf
.use_short_slot
=
1041 params
->use_short_slot_time
;
1042 changed
|= BSS_CHANGED_ERP_SLOT
;
1045 ieee80211_bss_info_change_notify(sdata
, changed
);
1050 struct cfg80211_ops mac80211_config_ops
= {
1051 .add_virtual_intf
= ieee80211_add_iface
,
1052 .del_virtual_intf
= ieee80211_del_iface
,
1053 .change_virtual_intf
= ieee80211_change_iface
,
1054 .add_key
= ieee80211_add_key
,
1055 .del_key
= ieee80211_del_key
,
1056 .get_key
= ieee80211_get_key
,
1057 .set_default_key
= ieee80211_config_default_key
,
1058 .add_beacon
= ieee80211_add_beacon
,
1059 .set_beacon
= ieee80211_set_beacon
,
1060 .del_beacon
= ieee80211_del_beacon
,
1061 .add_station
= ieee80211_add_station
,
1062 .del_station
= ieee80211_del_station
,
1063 .change_station
= ieee80211_change_station
,
1064 .get_station
= ieee80211_get_station
,
1065 .dump_station
= ieee80211_dump_station
,
1066 #ifdef CONFIG_MAC80211_MESH
1067 .add_mpath
= ieee80211_add_mpath
,
1068 .del_mpath
= ieee80211_del_mpath
,
1069 .change_mpath
= ieee80211_change_mpath
,
1070 .get_mpath
= ieee80211_get_mpath
,
1071 .dump_mpath
= ieee80211_dump_mpath
,
1073 .change_bss
= ieee80211_change_bss
,