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 static enum ieee80211_if_types
21 nl80211_type_to_mac80211_type(enum nl80211_iftype type
)
24 case NL80211_IFTYPE_UNSPECIFIED
:
25 return IEEE80211_IF_TYPE_STA
;
26 case NL80211_IFTYPE_ADHOC
:
27 return IEEE80211_IF_TYPE_IBSS
;
28 case NL80211_IFTYPE_STATION
:
29 return IEEE80211_IF_TYPE_STA
;
30 case NL80211_IFTYPE_MONITOR
:
31 return IEEE80211_IF_TYPE_MNTR
;
32 #ifdef CONFIG_MAC80211_MESH
33 case NL80211_IFTYPE_MESH_POINT
:
34 return IEEE80211_IF_TYPE_MESH_POINT
;
36 case NL80211_IFTYPE_WDS
:
37 return IEEE80211_IF_TYPE_WDS
;
39 return IEEE80211_IF_TYPE_INVALID
;
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 enum ieee80211_if_types itype
;
49 struct net_device
*dev
;
50 struct ieee80211_sub_if_data
*sdata
;
53 itype
= nl80211_type_to_mac80211_type(type
);
54 if (itype
== IEEE80211_IF_TYPE_INVALID
)
57 err
= ieee80211_if_add(local
, name
, &dev
, itype
, params
);
58 if (err
|| itype
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
61 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
62 sdata
->u
.mntr_flags
= *flags
;
66 static int ieee80211_del_iface(struct wiphy
*wiphy
, int ifindex
)
68 struct net_device
*dev
;
70 /* we're under RTNL */
71 dev
= __dev_get_by_index(&init_net
, ifindex
);
75 ieee80211_if_remove(dev
);
80 static int ieee80211_change_iface(struct wiphy
*wiphy
, int ifindex
,
81 enum nl80211_iftype type
, u32
*flags
,
82 struct vif_params
*params
)
84 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
85 struct net_device
*dev
;
86 enum ieee80211_if_types itype
;
87 struct ieee80211_sub_if_data
*sdata
;
90 /* we're under RTNL */
91 dev
= __dev_get_by_index(&init_net
, ifindex
);
95 itype
= nl80211_type_to_mac80211_type(type
);
96 if (itype
== IEEE80211_IF_TYPE_INVALID
)
99 if (dev
== local
->mdev
)
102 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
104 ret
= ieee80211_if_change_type(sdata
, itype
);
108 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
109 ieee80211_if_sta_set_mesh_id(&sdata
->u
.sta
,
113 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
116 sdata
->u
.mntr_flags
= *flags
;
120 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
121 u8 key_idx
, u8
*mac_addr
,
122 struct key_params
*params
)
124 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
125 struct ieee80211_sub_if_data
*sdata
;
126 struct sta_info
*sta
= NULL
;
127 enum ieee80211_key_alg alg
;
128 struct ieee80211_key
*key
;
131 if (dev
== local
->mdev
)
134 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
136 switch (params
->cipher
) {
137 case WLAN_CIPHER_SUITE_WEP40
:
138 case WLAN_CIPHER_SUITE_WEP104
:
141 case WLAN_CIPHER_SUITE_TKIP
:
144 case WLAN_CIPHER_SUITE_CCMP
:
151 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
158 sta
= sta_info_get(sdata
->local
, mac_addr
);
160 ieee80211_key_free(key
);
166 ieee80211_key_link(key
, sdata
, sta
);
175 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
176 u8 key_idx
, u8
*mac_addr
)
178 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
179 struct ieee80211_sub_if_data
*sdata
;
180 struct sta_info
*sta
;
183 if (dev
== local
->mdev
)
186 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
193 sta
= sta_info_get(sdata
->local
, mac_addr
);
198 ieee80211_key_free(sta
->key
);
206 if (!sdata
->keys
[key_idx
]) {
211 ieee80211_key_free(sdata
->keys
[key_idx
]);
212 WARN_ON(sdata
->keys
[key_idx
]);
221 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
222 u8 key_idx
, u8
*mac_addr
, void *cookie
,
223 void (*callback
)(void *cookie
,
224 struct key_params
*params
))
226 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
227 struct ieee80211_sub_if_data
*sdata
;
228 struct sta_info
*sta
= NULL
;
230 struct key_params params
;
231 struct ieee80211_key
*key
;
236 if (dev
== local
->mdev
)
239 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
244 sta
= sta_info_get(sdata
->local
, mac_addr
);
250 key
= sdata
->keys
[key_idx
];
255 memset(¶ms
, 0, sizeof(params
));
257 switch (key
->conf
.alg
) {
259 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
261 iv32
= key
->u
.tkip
.tx
.iv32
;
262 iv16
= key
->u
.tkip
.tx
.iv16
;
264 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
265 sdata
->local
->ops
->get_tkip_seq
)
266 sdata
->local
->ops
->get_tkip_seq(
267 local_to_hw(sdata
->local
),
268 key
->conf
.hw_key_idx
,
271 seq
[0] = iv16
& 0xff;
272 seq
[1] = (iv16
>> 8) & 0xff;
273 seq
[2] = iv32
& 0xff;
274 seq
[3] = (iv32
>> 8) & 0xff;
275 seq
[4] = (iv32
>> 16) & 0xff;
276 seq
[5] = (iv32
>> 24) & 0xff;
281 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
282 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
283 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
284 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
285 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
286 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
287 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
292 if (key
->conf
.keylen
== 5)
293 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
295 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
299 params
.key
= key
->conf
.key
;
300 params
.key_len
= key
->conf
.keylen
;
302 callback(cookie
, ¶ms
);
310 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
311 struct net_device
*dev
,
314 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
315 struct ieee80211_sub_if_data
*sdata
;
317 if (dev
== local
->mdev
)
322 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
323 ieee80211_set_default_key(sdata
, key_idx
);
330 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
332 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
334 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
335 STATION_INFO_RX_BYTES
|
336 STATION_INFO_TX_BYTES
;
338 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
339 sinfo
->rx_bytes
= sta
->rx_bytes
;
340 sinfo
->tx_bytes
= sta
->tx_bytes
;
342 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
343 #ifdef CONFIG_MAC80211_MESH
344 sinfo
->filled
|= STATION_INFO_LLID
|
346 STATION_INFO_PLINK_STATE
;
348 sinfo
->llid
= le16_to_cpu(sta
->llid
);
349 sinfo
->plid
= le16_to_cpu(sta
->plid
);
350 sinfo
->plink_state
= sta
->plink_state
;
356 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
357 int idx
, u8
*mac
, struct station_info
*sinfo
)
359 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
360 struct sta_info
*sta
;
365 sta
= sta_info_get_by_idx(local
, idx
, dev
);
368 memcpy(mac
, sta
->addr
, ETH_ALEN
);
369 sta_set_sinfo(sta
, sinfo
);
377 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
378 u8
*mac
, struct station_info
*sinfo
)
380 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
381 struct sta_info
*sta
;
386 /* XXX: verify sta->dev == dev */
388 sta
= sta_info_get(local
, mac
);
391 sta_set_sinfo(sta
, sinfo
);
400 * This handles both adding a beacon and setting new beacon info
402 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
403 struct beacon_parameters
*params
)
405 struct beacon_data
*new, *old
;
406 int new_head_len
, new_tail_len
;
410 old
= sdata
->u
.ap
.beacon
;
412 /* head must not be zero-length */
413 if (params
->head
&& !params
->head_len
)
417 * This is a kludge. beacon interval should really be part
418 * of the beacon information.
420 if (params
->interval
) {
421 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
422 if (ieee80211_hw_config(sdata
->local
))
425 * We updated some parameter so if below bails out
431 /* Need to have a beacon head if we don't have one yet */
432 if (!params
->head
&& !old
)
435 /* sorry, no way to start beaconing without dtim period */
436 if (!params
->dtim_period
&& !old
)
439 /* new or old head? */
441 new_head_len
= params
->head_len
;
443 new_head_len
= old
->head_len
;
445 /* new or old tail? */
446 if (params
->tail
|| !old
)
447 /* params->tail_len will be zero for !params->tail */
448 new_tail_len
= params
->tail_len
;
450 new_tail_len
= old
->tail_len
;
452 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
454 new = kzalloc(size
, GFP_KERNEL
);
458 /* start filling the new info now */
460 /* new or old dtim period? */
461 if (params
->dtim_period
)
462 new->dtim_period
= params
->dtim_period
;
464 new->dtim_period
= old
->dtim_period
;
467 * pointers go into the block we allocated,
468 * memory is | beacon_data | head | tail |
470 new->head
= ((u8
*) new) + sizeof(*new);
471 new->tail
= new->head
+ new_head_len
;
472 new->head_len
= new_head_len
;
473 new->tail_len
= new_tail_len
;
477 memcpy(new->head
, params
->head
, new_head_len
);
479 memcpy(new->head
, old
->head
, new_head_len
);
481 /* copy in optional tail */
483 memcpy(new->tail
, params
->tail
, new_tail_len
);
486 memcpy(new->tail
, old
->tail
, new_tail_len
);
488 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
494 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
497 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
498 struct beacon_parameters
*params
)
500 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
501 struct ieee80211_sub_if_data
*sdata
;
502 struct beacon_data
*old
;
504 if (dev
== local
->mdev
)
507 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
509 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
512 old
= sdata
->u
.ap
.beacon
;
517 return ieee80211_config_beacon(sdata
, params
);
520 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
521 struct beacon_parameters
*params
)
523 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
524 struct ieee80211_sub_if_data
*sdata
;
525 struct beacon_data
*old
;
527 if (dev
== local
->mdev
)
530 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
532 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
535 old
= sdata
->u
.ap
.beacon
;
540 return ieee80211_config_beacon(sdata
, params
);
543 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
545 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
546 struct ieee80211_sub_if_data
*sdata
;
547 struct beacon_data
*old
;
549 if (dev
== local
->mdev
)
552 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
554 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
557 old
= sdata
->u
.ap
.beacon
;
562 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
566 return ieee80211_if_config(sdata
, IEEE80211_IFCC_BEACON
);
569 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
570 struct iapp_layer2_update
{
571 u8 da
[ETH_ALEN
]; /* broadcast */
572 u8 sa
[ETH_ALEN
]; /* STA addr */
578 } __attribute__ ((packed
));
580 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
582 struct iapp_layer2_update
*msg
;
585 /* Send Level 2 Update Frame to update forwarding tables in layer 2
588 skb
= dev_alloc_skb(sizeof(*msg
));
591 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
593 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
594 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
596 memset(msg
->da
, 0xff, ETH_ALEN
);
597 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
600 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
601 msg
->control
= 0xaf; /* XID response lsb.1111F101.
602 * F=0 (no poll command; unsolicited frame) */
603 msg
->xid_info
[0] = 0x81; /* XID format identifier */
604 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
605 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
607 skb
->dev
= sta
->sdata
->dev
;
608 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
609 memset(skb
->cb
, 0, sizeof(skb
->cb
));
613 static void sta_apply_parameters(struct ieee80211_local
*local
,
614 struct sta_info
*sta
,
615 struct station_parameters
*params
)
619 struct ieee80211_supported_band
*sband
;
620 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
623 * FIXME: updating the flags is racy when this function is
624 * called from ieee80211_change_station(), this will
625 * be resolved in a future patch.
628 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
629 spin_lock_bh(&sta
->lock
);
630 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
631 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
632 sta
->flags
|= WLAN_STA_AUTHORIZED
;
634 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
635 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
636 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
638 sta
->flags
&= ~WLAN_STA_WME
;
639 if (params
->station_flags
& STATION_FLAG_WME
)
640 sta
->flags
|= WLAN_STA_WME
;
641 spin_unlock_bh(&sta
->lock
);
645 * FIXME: updating the following information is racy when this
646 * function is called from ieee80211_change_station().
647 * However, all this information should be static so
648 * maybe we should just reject attemps to change it.
652 sta
->aid
= params
->aid
;
653 if (sta
->aid
> IEEE80211_MAX_AID
)
654 sta
->aid
= 0; /* XXX: should this be an error? */
657 if (params
->listen_interval
>= 0)
658 sta
->listen_interval
= params
->listen_interval
;
660 if (params
->supported_rates
) {
662 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
664 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
665 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
666 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
667 if (sband
->bitrates
[j
].bitrate
== rate
)
671 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
674 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
675 switch (params
->plink_action
) {
676 case PLINK_ACTION_OPEN
:
677 mesh_plink_open(sta
);
679 case PLINK_ACTION_BLOCK
:
680 mesh_plink_block(sta
);
686 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
687 u8
*mac
, struct station_parameters
*params
)
689 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
690 struct sta_info
*sta
;
691 struct ieee80211_sub_if_data
*sdata
;
694 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
697 /* Prevent a race with changing the rate control algorithm */
698 if (!netif_running(dev
))
702 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
704 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
&&
705 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
708 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
710 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
713 if (is_multicast_ether_addr(mac
))
716 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
720 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
722 sta_apply_parameters(local
, sta
, params
);
724 rate_control_rate_init(sta
, local
);
728 err
= sta_info_insert(sta
);
730 /* STA has been freed */
735 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
736 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
737 ieee80211_send_layer2_update(sta
);
744 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
747 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
748 struct ieee80211_sub_if_data
*sdata
;
749 struct sta_info
*sta
;
751 if (dev
== local
->mdev
)
754 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
759 /* XXX: get sta belonging to dev */
760 sta
= sta_info_get(local
, mac
);
766 sta_info_unlink(&sta
);
769 sta_info_destroy(sta
);
771 sta_info_flush(local
, sdata
);
776 static int ieee80211_change_station(struct wiphy
*wiphy
,
777 struct net_device
*dev
,
779 struct station_parameters
*params
)
781 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
782 struct sta_info
*sta
;
783 struct ieee80211_sub_if_data
*vlansdata
;
785 if (dev
== local
->mdev
|| params
->vlan
== local
->mdev
)
790 /* XXX: get sta belonging to dev */
791 sta
= sta_info_get(local
, mac
);
797 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
798 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
800 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
&&
801 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
) {
806 sta
->sdata
= vlansdata
;
807 ieee80211_send_layer2_update(sta
);
810 sta_apply_parameters(local
, sta
, params
);
817 #ifdef CONFIG_MAC80211_MESH
818 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
819 u8
*dst
, u8
*next_hop
)
821 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
822 struct ieee80211_sub_if_data
*sdata
;
823 struct mesh_path
*mpath
;
824 struct sta_info
*sta
;
827 if (dev
== local
->mdev
)
830 if (!netif_running(dev
))
833 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
835 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
839 sta
= sta_info_get(local
, next_hop
);
845 err
= mesh_path_add(dst
, dev
);
851 mpath
= mesh_path_lookup(dst
, dev
);
856 mesh_path_fix_nexthop(mpath
, sta
);
862 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
866 return mesh_path_del(dst
, dev
);
868 mesh_path_flush(dev
);
872 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
873 struct net_device
*dev
,
874 u8
*dst
, u8
*next_hop
)
876 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
877 struct ieee80211_sub_if_data
*sdata
;
878 struct mesh_path
*mpath
;
879 struct sta_info
*sta
;
881 if (dev
== local
->mdev
)
884 if (!netif_running(dev
))
887 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
889 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
894 sta
= sta_info_get(local
, next_hop
);
900 mpath
= mesh_path_lookup(dst
, dev
);
906 mesh_path_fix_nexthop(mpath
, sta
);
912 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
913 struct mpath_info
*pinfo
)
916 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
918 memset(next_hop
, 0, ETH_ALEN
);
920 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
924 MPATH_INFO_DISCOVERY_TIMEOUT
|
925 MPATH_INFO_DISCOVERY_RETRIES
|
928 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
929 pinfo
->dsn
= mpath
->dsn
;
930 pinfo
->metric
= mpath
->metric
;
931 if (time_before(jiffies
, mpath
->exp_time
))
932 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
933 pinfo
->discovery_timeout
=
934 jiffies_to_msecs(mpath
->discovery_timeout
);
935 pinfo
->discovery_retries
= mpath
->discovery_retries
;
937 if (mpath
->flags
& MESH_PATH_ACTIVE
)
938 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
939 if (mpath
->flags
& MESH_PATH_RESOLVING
)
940 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
941 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
942 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
943 if (mpath
->flags
& MESH_PATH_FIXED
)
944 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
945 if (mpath
->flags
& MESH_PATH_RESOLVING
)
946 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
948 pinfo
->flags
= mpath
->flags
;
951 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
952 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
955 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
956 struct ieee80211_sub_if_data
*sdata
;
957 struct mesh_path
*mpath
;
959 if (dev
== local
->mdev
)
962 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
964 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
968 mpath
= mesh_path_lookup(dst
, dev
);
973 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
974 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
979 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
980 int idx
, u8
*dst
, u8
*next_hop
,
981 struct mpath_info
*pinfo
)
983 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
984 struct ieee80211_sub_if_data
*sdata
;
985 struct mesh_path
*mpath
;
987 if (dev
== local
->mdev
)
990 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
992 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
996 mpath
= mesh_path_lookup_by_idx(idx
, dev
);
1001 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
1002 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
1008 struct cfg80211_ops mac80211_config_ops
= {
1009 .add_virtual_intf
= ieee80211_add_iface
,
1010 .del_virtual_intf
= ieee80211_del_iface
,
1011 .change_virtual_intf
= ieee80211_change_iface
,
1012 .add_key
= ieee80211_add_key
,
1013 .del_key
= ieee80211_del_key
,
1014 .get_key
= ieee80211_get_key
,
1015 .set_default_key
= ieee80211_config_default_key
,
1016 .add_beacon
= ieee80211_add_beacon
,
1017 .set_beacon
= ieee80211_set_beacon
,
1018 .del_beacon
= ieee80211_del_beacon
,
1019 .add_station
= ieee80211_add_station
,
1020 .del_station
= ieee80211_del_station
,
1021 .change_station
= ieee80211_change_station
,
1022 .get_station
= ieee80211_get_station
,
1023 .dump_station
= ieee80211_dump_station
,
1024 #ifdef CONFIG_MAC80211_MESH
1025 .add_mpath
= ieee80211_add_mpath
,
1026 .del_mpath
= ieee80211_del_mpath
,
1027 .change_mpath
= ieee80211_change_mpath
,
1028 .get_mpath
= ieee80211_get_mpath
,
1029 .dump_mpath
= ieee80211_dump_mpath
,