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"
17 #include "ieee80211_rate.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
;
37 return IEEE80211_IF_TYPE_INVALID
;
41 static int ieee80211_add_iface(struct wiphy
*wiphy
, char *name
,
42 enum nl80211_iftype type
, u32
*flags
,
43 struct vif_params
*params
)
45 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
46 enum ieee80211_if_types itype
;
47 struct net_device
*dev
;
48 struct ieee80211_sub_if_data
*sdata
;
51 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
54 itype
= nl80211_type_to_mac80211_type(type
);
55 if (itype
== IEEE80211_IF_TYPE_INVALID
)
58 err
= ieee80211_if_add(local
->mdev
, name
, &dev
, itype
, params
);
59 if (err
|| itype
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
62 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
63 sdata
->u
.mntr_flags
= *flags
;
67 static int ieee80211_del_iface(struct wiphy
*wiphy
, int ifindex
)
69 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
70 struct net_device
*dev
;
73 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
76 /* we're under RTNL */
77 dev
= __dev_get_by_index(&init_net
, ifindex
);
83 return ieee80211_if_remove(local
->mdev
, name
, -1);
86 static int ieee80211_change_iface(struct wiphy
*wiphy
, int ifindex
,
87 enum nl80211_iftype type
, u32
*flags
,
88 struct vif_params
*params
)
90 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
91 struct net_device
*dev
;
92 enum ieee80211_if_types itype
;
93 struct ieee80211_sub_if_data
*sdata
;
95 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
98 /* we're under RTNL */
99 dev
= __dev_get_by_index(&init_net
, ifindex
);
103 if (netif_running(dev
))
106 itype
= nl80211_type_to_mac80211_type(type
);
107 if (itype
== IEEE80211_IF_TYPE_INVALID
)
110 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
112 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
)
115 ieee80211_if_reinit(dev
);
116 ieee80211_if_set_type(dev
, itype
);
118 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
119 ieee80211_if_sta_set_mesh_id(&sdata
->u
.sta
,
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_sub_if_data
*sdata
;
135 struct sta_info
*sta
= NULL
;
136 enum ieee80211_key_alg alg
;
137 struct ieee80211_key
*key
;
139 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
141 switch (params
->cipher
) {
142 case WLAN_CIPHER_SUITE_WEP40
:
143 case WLAN_CIPHER_SUITE_WEP104
:
146 case WLAN_CIPHER_SUITE_TKIP
:
149 case WLAN_CIPHER_SUITE_CCMP
:
156 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
161 sta
= sta_info_get(sdata
->local
, mac_addr
);
163 ieee80211_key_free(key
);
168 ieee80211_key_link(key
, sdata
, sta
);
173 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
174 u8 key_idx
, u8
*mac_addr
)
176 struct ieee80211_sub_if_data
*sdata
;
177 struct sta_info
*sta
;
180 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
183 sta
= sta_info_get(sdata
->local
, mac_addr
);
189 ieee80211_key_free(sta
->key
);
197 if (!sdata
->keys
[key_idx
])
200 ieee80211_key_free(sdata
->keys
[key_idx
]);
201 WARN_ON(sdata
->keys
[key_idx
]);
206 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
207 u8 key_idx
, u8
*mac_addr
, void *cookie
,
208 void (*callback
)(void *cookie
,
209 struct key_params
*params
))
211 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
212 struct sta_info
*sta
= NULL
;
214 struct key_params params
;
215 struct ieee80211_key
*key
;
221 sta
= sta_info_get(sdata
->local
, mac_addr
);
227 key
= sdata
->keys
[key_idx
];
232 memset(¶ms
, 0, sizeof(params
));
234 switch (key
->conf
.alg
) {
236 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
238 iv32
= key
->u
.tkip
.iv32
;
239 iv16
= key
->u
.tkip
.iv16
;
241 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
242 sdata
->local
->ops
->get_tkip_seq
)
243 sdata
->local
->ops
->get_tkip_seq(
244 local_to_hw(sdata
->local
),
245 key
->conf
.hw_key_idx
,
248 seq
[0] = iv16
& 0xff;
249 seq
[1] = (iv16
>> 8) & 0xff;
250 seq
[2] = iv32
& 0xff;
251 seq
[3] = (iv32
>> 8) & 0xff;
252 seq
[4] = (iv32
>> 16) & 0xff;
253 seq
[5] = (iv32
>> 24) & 0xff;
258 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
259 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
260 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
261 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
262 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
263 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
264 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
269 if (key
->conf
.keylen
== 5)
270 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
272 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
276 params
.key
= key
->conf
.key
;
277 params
.key_len
= key
->conf
.keylen
;
279 callback(cookie
, ¶ms
);
286 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
287 struct net_device
*dev
,
290 struct ieee80211_sub_if_data
*sdata
;
292 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
293 ieee80211_set_default_key(sdata
, key_idx
);
298 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
300 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
302 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
303 STATION_INFO_RX_BYTES
|
304 STATION_INFO_TX_BYTES
;
306 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
307 sinfo
->rx_bytes
= sta
->rx_bytes
;
308 sinfo
->tx_bytes
= sta
->tx_bytes
;
310 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
311 #ifdef CONFIG_MAC80211_MESH
312 sinfo
->filled
|= STATION_INFO_LLID
|
314 STATION_INFO_PLINK_STATE
;
316 sinfo
->llid
= le16_to_cpu(sta
->llid
);
317 sinfo
->plid
= le16_to_cpu(sta
->plid
);
318 sinfo
->plink_state
= sta
->plink_state
;
324 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
325 int idx
, u8
*mac
, struct station_info
*sinfo
)
327 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
328 struct sta_info
*sta
;
333 sta
= sta_info_get_by_idx(local
, idx
, dev
);
336 memcpy(mac
, sta
->addr
, ETH_ALEN
);
337 sta_set_sinfo(sta
, sinfo
);
345 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
346 u8
*mac
, struct station_info
*sinfo
)
348 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
349 struct sta_info
*sta
;
354 /* XXX: verify sta->dev == dev */
356 sta
= sta_info_get(local
, mac
);
359 sta_set_sinfo(sta
, sinfo
);
368 * This handles both adding a beacon and setting new beacon info
370 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
371 struct beacon_parameters
*params
)
373 struct beacon_data
*new, *old
;
374 int new_head_len
, new_tail_len
;
378 old
= sdata
->u
.ap
.beacon
;
380 /* head must not be zero-length */
381 if (params
->head
&& !params
->head_len
)
385 * This is a kludge. beacon interval should really be part
386 * of the beacon information.
388 if (params
->interval
) {
389 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
390 if (ieee80211_hw_config(sdata
->local
))
393 * We updated some parameter so if below bails out
399 /* Need to have a beacon head if we don't have one yet */
400 if (!params
->head
&& !old
)
403 /* sorry, no way to start beaconing without dtim period */
404 if (!params
->dtim_period
&& !old
)
407 /* new or old head? */
409 new_head_len
= params
->head_len
;
411 new_head_len
= old
->head_len
;
413 /* new or old tail? */
414 if (params
->tail
|| !old
)
415 /* params->tail_len will be zero for !params->tail */
416 new_tail_len
= params
->tail_len
;
418 new_tail_len
= old
->tail_len
;
420 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
422 new = kzalloc(size
, GFP_KERNEL
);
426 /* start filling the new info now */
428 /* new or old dtim period? */
429 if (params
->dtim_period
)
430 new->dtim_period
= params
->dtim_period
;
432 new->dtim_period
= old
->dtim_period
;
435 * pointers go into the block we allocated,
436 * memory is | beacon_data | head | tail |
438 new->head
= ((u8
*) new) + sizeof(*new);
439 new->tail
= new->head
+ new_head_len
;
440 new->head_len
= new_head_len
;
441 new->tail_len
= new_tail_len
;
445 memcpy(new->head
, params
->head
, new_head_len
);
447 memcpy(new->head
, old
->head
, new_head_len
);
449 /* copy in optional tail */
451 memcpy(new->tail
, params
->tail
, new_tail_len
);
454 memcpy(new->tail
, old
->tail
, new_tail_len
);
456 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
462 return ieee80211_if_config_beacon(sdata
->dev
);
465 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
466 struct beacon_parameters
*params
)
468 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
469 struct beacon_data
*old
;
471 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
474 old
= sdata
->u
.ap
.beacon
;
479 return ieee80211_config_beacon(sdata
, params
);
482 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
483 struct beacon_parameters
*params
)
485 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
486 struct beacon_data
*old
;
488 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
491 old
= sdata
->u
.ap
.beacon
;
496 return ieee80211_config_beacon(sdata
, params
);
499 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
501 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
502 struct beacon_data
*old
;
504 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
507 old
= sdata
->u
.ap
.beacon
;
512 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
516 return ieee80211_if_config_beacon(dev
);
519 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
520 struct iapp_layer2_update
{
521 u8 da
[ETH_ALEN
]; /* broadcast */
522 u8 sa
[ETH_ALEN
]; /* STA addr */
528 } __attribute__ ((packed
));
530 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
532 struct iapp_layer2_update
*msg
;
535 /* Send Level 2 Update Frame to update forwarding tables in layer 2
538 skb
= dev_alloc_skb(sizeof(*msg
));
541 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
543 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
544 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
546 memset(msg
->da
, 0xff, ETH_ALEN
);
547 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
550 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
551 msg
->control
= 0xaf; /* XID response lsb.1111F101.
552 * F=0 (no poll command; unsolicited frame) */
553 msg
->xid_info
[0] = 0x81; /* XID format identifier */
554 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
555 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
557 skb
->dev
= sta
->sdata
->dev
;
558 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
559 memset(skb
->cb
, 0, sizeof(skb
->cb
));
563 static void sta_apply_parameters(struct ieee80211_local
*local
,
564 struct sta_info
*sta
,
565 struct station_parameters
*params
)
569 struct ieee80211_supported_band
*sband
;
570 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
573 * FIXME: updating the flags is racy when this function is
574 * called from ieee80211_change_station(), this will
575 * be resolved in a future patch.
578 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
579 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
580 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
581 sta
->flags
|= WLAN_STA_AUTHORIZED
;
583 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
584 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
585 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
587 sta
->flags
&= ~WLAN_STA_WME
;
588 if (params
->station_flags
& STATION_FLAG_WME
)
589 sta
->flags
|= WLAN_STA_WME
;
593 * FIXME: updating the following information is racy when this
594 * function is called from ieee80211_change_station().
595 * However, all this information should be static so
596 * maybe we should just reject attemps to change it.
600 sta
->aid
= params
->aid
;
601 if (sta
->aid
> IEEE80211_MAX_AID
)
602 sta
->aid
= 0; /* XXX: should this be an error? */
605 if (params
->listen_interval
>= 0)
606 sta
->listen_interval
= params
->listen_interval
;
608 if (params
->supported_rates
) {
610 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
612 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
613 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
614 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
615 if (sband
->bitrates
[j
].bitrate
== rate
)
619 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
622 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
623 switch (params
->plink_action
) {
624 case PLINK_ACTION_OPEN
:
625 mesh_plink_open(sta
);
627 case PLINK_ACTION_BLOCK
:
628 mesh_plink_block(sta
);
634 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
635 u8
*mac
, struct station_parameters
*params
)
637 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
638 struct sta_info
*sta
;
639 struct ieee80211_sub_if_data
*sdata
;
642 /* Prevent a race with changing the rate control algorithm */
643 if (!netif_running(dev
))
647 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
649 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
650 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
653 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
655 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
658 if (is_multicast_ether_addr(mac
))
661 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
665 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
667 sta_apply_parameters(local
, sta
, params
);
669 rate_control_rate_init(sta
, local
);
673 err
= sta_info_insert(sta
);
675 /* STA has been freed */
680 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
681 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
682 ieee80211_send_layer2_update(sta
);
689 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
692 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
693 struct ieee80211_local
*local
= sdata
->local
;
694 struct sta_info
*sta
;
697 /* XXX: get sta belonging to dev */
698 sta
= sta_info_get(local
, mac
);
702 sta_info_unlink(&sta
);
703 sta_info_destroy(sta
);
705 sta_info_flush(local
, sdata
);
710 static int ieee80211_change_station(struct wiphy
*wiphy
,
711 struct net_device
*dev
,
713 struct station_parameters
*params
)
715 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
716 struct sta_info
*sta
;
717 struct ieee80211_sub_if_data
*vlansdata
;
719 /* XXX: get sta belonging to dev */
720 sta
= sta_info_get(local
, mac
);
724 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
725 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
727 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
728 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
731 sta
->sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
732 ieee80211_send_layer2_update(sta
);
735 sta_apply_parameters(local
, sta
, params
);
740 #ifdef CONFIG_MAC80211_MESH
741 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
742 u8
*dst
, u8
*next_hop
)
744 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
745 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
746 struct mesh_path
*mpath
;
747 struct sta_info
*sta
;
750 if (!netif_running(dev
))
753 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
757 sta
= sta_info_get(local
, next_hop
);
763 err
= mesh_path_add(dst
, dev
);
769 mpath
= mesh_path_lookup(dst
, dev
);
774 mesh_path_fix_nexthop(mpath
, sta
);
780 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
784 return mesh_path_del(dst
, dev
);
786 mesh_path_flush(dev
);
790 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
791 struct net_device
*dev
,
792 u8
*dst
, u8
*next_hop
)
794 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
795 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
796 struct mesh_path
*mpath
;
797 struct sta_info
*sta
;
799 if (!netif_running(dev
))
802 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
807 sta
= sta_info_get(local
, next_hop
);
813 mpath
= mesh_path_lookup(dst
, dev
);
819 mesh_path_fix_nexthop(mpath
, sta
);
825 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
826 struct mpath_info
*pinfo
)
829 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
831 memset(next_hop
, 0, ETH_ALEN
);
833 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
837 MPATH_INFO_DISCOVERY_TIMEOUT
|
838 MPATH_INFO_DISCOVERY_RETRIES
|
841 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
842 pinfo
->dsn
= mpath
->dsn
;
843 pinfo
->metric
= mpath
->metric
;
844 if (time_before(jiffies
, mpath
->exp_time
))
845 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
846 pinfo
->discovery_timeout
=
847 jiffies_to_msecs(mpath
->discovery_timeout
);
848 pinfo
->discovery_retries
= mpath
->discovery_retries
;
850 if (mpath
->flags
& MESH_PATH_ACTIVE
)
851 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
852 if (mpath
->flags
& MESH_PATH_RESOLVING
)
853 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
854 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
855 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
856 if (mpath
->flags
& MESH_PATH_FIXED
)
857 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
858 if (mpath
->flags
& MESH_PATH_RESOLVING
)
859 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
861 pinfo
->flags
= mpath
->flags
;
864 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
865 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
868 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
869 struct mesh_path
*mpath
;
871 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
875 mpath
= mesh_path_lookup(dst
, dev
);
880 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
881 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
886 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
887 int idx
, u8
*dst
, u8
*next_hop
,
888 struct mpath_info
*pinfo
)
890 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
891 struct mesh_path
*mpath
;
893 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
897 mpath
= mesh_path_lookup_by_idx(idx
, dev
);
902 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
903 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
909 struct cfg80211_ops mac80211_config_ops
= {
910 .add_virtual_intf
= ieee80211_add_iface
,
911 .del_virtual_intf
= ieee80211_del_iface
,
912 .change_virtual_intf
= ieee80211_change_iface
,
913 .add_key
= ieee80211_add_key
,
914 .del_key
= ieee80211_del_key
,
915 .get_key
= ieee80211_get_key
,
916 .set_default_key
= ieee80211_config_default_key
,
917 .add_beacon
= ieee80211_add_beacon
,
918 .set_beacon
= ieee80211_set_beacon
,
919 .del_beacon
= ieee80211_del_beacon
,
920 .add_station
= ieee80211_add_station
,
921 .del_station
= ieee80211_del_station
,
922 .change_station
= ieee80211_change_station
,
923 .get_station
= ieee80211_get_station
,
924 .dump_station
= ieee80211_dump_station
,
925 #ifdef CONFIG_MAC80211_MESH
926 .add_mpath
= ieee80211_add_mpath
,
927 .del_mpath
= ieee80211_del_mpath
,
928 .change_mpath
= ieee80211_change_mpath
,
929 .get_mpath
= ieee80211_get_mpath
,
930 .dump_mpath
= ieee80211_dump_mpath
,