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
;
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
;
140 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
142 switch (params
->cipher
) {
143 case WLAN_CIPHER_SUITE_WEP40
:
144 case WLAN_CIPHER_SUITE_WEP104
:
147 case WLAN_CIPHER_SUITE_TKIP
:
150 case WLAN_CIPHER_SUITE_CCMP
:
157 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
164 sta
= sta_info_get(sdata
->local
, mac_addr
);
166 ieee80211_key_free(key
);
172 ieee80211_key_link(key
, sdata
, sta
);
181 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
182 u8 key_idx
, u8
*mac_addr
)
184 struct ieee80211_sub_if_data
*sdata
;
185 struct sta_info
*sta
;
188 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
195 sta
= sta_info_get(sdata
->local
, mac_addr
);
200 ieee80211_key_free(sta
->key
);
208 if (!sdata
->keys
[key_idx
]) {
213 ieee80211_key_free(sdata
->keys
[key_idx
]);
214 WARN_ON(sdata
->keys
[key_idx
]);
223 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
224 u8 key_idx
, u8
*mac_addr
, void *cookie
,
225 void (*callback
)(void *cookie
,
226 struct key_params
*params
))
228 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
229 struct sta_info
*sta
= NULL
;
231 struct key_params params
;
232 struct ieee80211_key
*key
;
240 sta
= sta_info_get(sdata
->local
, mac_addr
);
246 key
= sdata
->keys
[key_idx
];
251 memset(¶ms
, 0, sizeof(params
));
253 switch (key
->conf
.alg
) {
255 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
257 iv32
= key
->u
.tkip
.iv32
;
258 iv16
= key
->u
.tkip
.iv16
;
260 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
261 sdata
->local
->ops
->get_tkip_seq
)
262 sdata
->local
->ops
->get_tkip_seq(
263 local_to_hw(sdata
->local
),
264 key
->conf
.hw_key_idx
,
267 seq
[0] = iv16
& 0xff;
268 seq
[1] = (iv16
>> 8) & 0xff;
269 seq
[2] = iv32
& 0xff;
270 seq
[3] = (iv32
>> 8) & 0xff;
271 seq
[4] = (iv32
>> 16) & 0xff;
272 seq
[5] = (iv32
>> 24) & 0xff;
277 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
278 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
279 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
280 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
281 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
282 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
283 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
288 if (key
->conf
.keylen
== 5)
289 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
291 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
295 params
.key
= key
->conf
.key
;
296 params
.key_len
= key
->conf
.keylen
;
298 callback(cookie
, ¶ms
);
306 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
307 struct net_device
*dev
,
310 struct ieee80211_sub_if_data
*sdata
;
314 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
315 ieee80211_set_default_key(sdata
, key_idx
);
322 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
324 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
326 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
327 STATION_INFO_RX_BYTES
|
328 STATION_INFO_TX_BYTES
;
330 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
331 sinfo
->rx_bytes
= sta
->rx_bytes
;
332 sinfo
->tx_bytes
= sta
->tx_bytes
;
334 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
335 #ifdef CONFIG_MAC80211_MESH
336 sinfo
->filled
|= STATION_INFO_LLID
|
338 STATION_INFO_PLINK_STATE
;
340 sinfo
->llid
= le16_to_cpu(sta
->llid
);
341 sinfo
->plid
= le16_to_cpu(sta
->plid
);
342 sinfo
->plink_state
= sta
->plink_state
;
348 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
349 int idx
, u8
*mac
, struct station_info
*sinfo
)
351 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
352 struct sta_info
*sta
;
357 sta
= sta_info_get_by_idx(local
, idx
, dev
);
360 memcpy(mac
, sta
->addr
, ETH_ALEN
);
361 sta_set_sinfo(sta
, sinfo
);
369 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
370 u8
*mac
, struct station_info
*sinfo
)
372 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
373 struct sta_info
*sta
;
378 /* XXX: verify sta->dev == dev */
380 sta
= sta_info_get(local
, mac
);
383 sta_set_sinfo(sta
, sinfo
);
392 * This handles both adding a beacon and setting new beacon info
394 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
395 struct beacon_parameters
*params
)
397 struct beacon_data
*new, *old
;
398 int new_head_len
, new_tail_len
;
402 old
= sdata
->u
.ap
.beacon
;
404 /* head must not be zero-length */
405 if (params
->head
&& !params
->head_len
)
409 * This is a kludge. beacon interval should really be part
410 * of the beacon information.
412 if (params
->interval
) {
413 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
414 if (ieee80211_hw_config(sdata
->local
))
417 * We updated some parameter so if below bails out
423 /* Need to have a beacon head if we don't have one yet */
424 if (!params
->head
&& !old
)
427 /* sorry, no way to start beaconing without dtim period */
428 if (!params
->dtim_period
&& !old
)
431 /* new or old head? */
433 new_head_len
= params
->head_len
;
435 new_head_len
= old
->head_len
;
437 /* new or old tail? */
438 if (params
->tail
|| !old
)
439 /* params->tail_len will be zero for !params->tail */
440 new_tail_len
= params
->tail_len
;
442 new_tail_len
= old
->tail_len
;
444 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
446 new = kzalloc(size
, GFP_KERNEL
);
450 /* start filling the new info now */
452 /* new or old dtim period? */
453 if (params
->dtim_period
)
454 new->dtim_period
= params
->dtim_period
;
456 new->dtim_period
= old
->dtim_period
;
459 * pointers go into the block we allocated,
460 * memory is | beacon_data | head | tail |
462 new->head
= ((u8
*) new) + sizeof(*new);
463 new->tail
= new->head
+ new_head_len
;
464 new->head_len
= new_head_len
;
465 new->tail_len
= new_tail_len
;
469 memcpy(new->head
, params
->head
, new_head_len
);
471 memcpy(new->head
, old
->head
, new_head_len
);
473 /* copy in optional tail */
475 memcpy(new->tail
, params
->tail
, new_tail_len
);
478 memcpy(new->tail
, old
->tail
, new_tail_len
);
480 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
486 return ieee80211_if_config_beacon(sdata
->dev
);
489 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
490 struct beacon_parameters
*params
)
492 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
493 struct beacon_data
*old
;
495 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
498 old
= sdata
->u
.ap
.beacon
;
503 return ieee80211_config_beacon(sdata
, params
);
506 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
507 struct beacon_parameters
*params
)
509 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
510 struct beacon_data
*old
;
512 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
515 old
= sdata
->u
.ap
.beacon
;
520 return ieee80211_config_beacon(sdata
, params
);
523 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
525 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
526 struct beacon_data
*old
;
528 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
531 old
= sdata
->u
.ap
.beacon
;
536 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
540 return ieee80211_if_config_beacon(dev
);
543 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
544 struct iapp_layer2_update
{
545 u8 da
[ETH_ALEN
]; /* broadcast */
546 u8 sa
[ETH_ALEN
]; /* STA addr */
552 } __attribute__ ((packed
));
554 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
556 struct iapp_layer2_update
*msg
;
559 /* Send Level 2 Update Frame to update forwarding tables in layer 2
562 skb
= dev_alloc_skb(sizeof(*msg
));
565 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
567 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
568 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
570 memset(msg
->da
, 0xff, ETH_ALEN
);
571 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
574 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
575 msg
->control
= 0xaf; /* XID response lsb.1111F101.
576 * F=0 (no poll command; unsolicited frame) */
577 msg
->xid_info
[0] = 0x81; /* XID format identifier */
578 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
579 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
581 skb
->dev
= sta
->sdata
->dev
;
582 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
583 memset(skb
->cb
, 0, sizeof(skb
->cb
));
587 static void sta_apply_parameters(struct ieee80211_local
*local
,
588 struct sta_info
*sta
,
589 struct station_parameters
*params
)
593 struct ieee80211_supported_band
*sband
;
594 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
597 * FIXME: updating the flags is racy when this function is
598 * called from ieee80211_change_station(), this will
599 * be resolved in a future patch.
602 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
603 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
604 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
605 sta
->flags
|= WLAN_STA_AUTHORIZED
;
607 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
608 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
609 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
611 sta
->flags
&= ~WLAN_STA_WME
;
612 if (params
->station_flags
& STATION_FLAG_WME
)
613 sta
->flags
|= WLAN_STA_WME
;
617 * FIXME: updating the following information is racy when this
618 * function is called from ieee80211_change_station().
619 * However, all this information should be static so
620 * maybe we should just reject attemps to change it.
624 sta
->aid
= params
->aid
;
625 if (sta
->aid
> IEEE80211_MAX_AID
)
626 sta
->aid
= 0; /* XXX: should this be an error? */
629 if (params
->listen_interval
>= 0)
630 sta
->listen_interval
= params
->listen_interval
;
632 if (params
->supported_rates
) {
634 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
636 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
637 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
638 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
639 if (sband
->bitrates
[j
].bitrate
== rate
)
643 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
646 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
647 switch (params
->plink_action
) {
648 case PLINK_ACTION_OPEN
:
649 mesh_plink_open(sta
);
651 case PLINK_ACTION_BLOCK
:
652 mesh_plink_block(sta
);
658 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
659 u8
*mac
, struct station_parameters
*params
)
661 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
662 struct sta_info
*sta
;
663 struct ieee80211_sub_if_data
*sdata
;
666 /* Prevent a race with changing the rate control algorithm */
667 if (!netif_running(dev
))
671 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
673 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
674 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
677 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
679 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
682 if (is_multicast_ether_addr(mac
))
685 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
689 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
691 sta_apply_parameters(local
, sta
, params
);
693 rate_control_rate_init(sta
, local
);
697 err
= sta_info_insert(sta
);
699 /* STA has been freed */
704 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
705 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
706 ieee80211_send_layer2_update(sta
);
713 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
716 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
717 struct ieee80211_local
*local
= sdata
->local
;
718 struct sta_info
*sta
;
723 /* XXX: get sta belonging to dev */
724 sta
= sta_info_get(local
, mac
);
730 sta_info_unlink(&sta
);
733 sta_info_destroy(sta
);
735 sta_info_flush(local
, sdata
);
740 static int ieee80211_change_station(struct wiphy
*wiphy
,
741 struct net_device
*dev
,
743 struct station_parameters
*params
)
745 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
746 struct sta_info
*sta
;
747 struct ieee80211_sub_if_data
*vlansdata
;
751 /* XXX: get sta belonging to dev */
752 sta
= sta_info_get(local
, mac
);
758 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
759 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
761 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
762 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
) {
767 sta
->sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
768 ieee80211_send_layer2_update(sta
);
771 sta_apply_parameters(local
, sta
, params
);
778 #ifdef CONFIG_MAC80211_MESH
779 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
780 u8
*dst
, u8
*next_hop
)
782 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
783 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
784 struct mesh_path
*mpath
;
785 struct sta_info
*sta
;
788 if (!netif_running(dev
))
791 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
795 sta
= sta_info_get(local
, next_hop
);
801 err
= mesh_path_add(dst
, dev
);
807 mpath
= mesh_path_lookup(dst
, dev
);
812 mesh_path_fix_nexthop(mpath
, sta
);
818 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
822 return mesh_path_del(dst
, dev
);
824 mesh_path_flush(dev
);
828 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
829 struct net_device
*dev
,
830 u8
*dst
, u8
*next_hop
)
832 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
833 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
834 struct mesh_path
*mpath
;
835 struct sta_info
*sta
;
837 if (!netif_running(dev
))
840 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
845 sta
= sta_info_get(local
, next_hop
);
851 mpath
= mesh_path_lookup(dst
, dev
);
857 mesh_path_fix_nexthop(mpath
, sta
);
863 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
864 struct mpath_info
*pinfo
)
867 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
869 memset(next_hop
, 0, ETH_ALEN
);
871 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
875 MPATH_INFO_DISCOVERY_TIMEOUT
|
876 MPATH_INFO_DISCOVERY_RETRIES
|
879 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
880 pinfo
->dsn
= mpath
->dsn
;
881 pinfo
->metric
= mpath
->metric
;
882 if (time_before(jiffies
, mpath
->exp_time
))
883 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
884 pinfo
->discovery_timeout
=
885 jiffies_to_msecs(mpath
->discovery_timeout
);
886 pinfo
->discovery_retries
= mpath
->discovery_retries
;
888 if (mpath
->flags
& MESH_PATH_ACTIVE
)
889 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
890 if (mpath
->flags
& MESH_PATH_RESOLVING
)
891 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
892 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
893 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
894 if (mpath
->flags
& MESH_PATH_FIXED
)
895 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
896 if (mpath
->flags
& MESH_PATH_RESOLVING
)
897 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
899 pinfo
->flags
= mpath
->flags
;
902 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
903 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
906 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
907 struct mesh_path
*mpath
;
909 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
913 mpath
= mesh_path_lookup(dst
, dev
);
918 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
919 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
924 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
925 int idx
, u8
*dst
, u8
*next_hop
,
926 struct mpath_info
*pinfo
)
928 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
929 struct mesh_path
*mpath
;
931 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
935 mpath
= mesh_path_lookup_by_idx(idx
, dev
);
940 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
941 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
947 struct cfg80211_ops mac80211_config_ops
= {
948 .add_virtual_intf
= ieee80211_add_iface
,
949 .del_virtual_intf
= ieee80211_del_iface
,
950 .change_virtual_intf
= ieee80211_change_iface
,
951 .add_key
= ieee80211_add_key
,
952 .del_key
= ieee80211_del_key
,
953 .get_key
= ieee80211_get_key
,
954 .set_default_key
= ieee80211_config_default_key
,
955 .add_beacon
= ieee80211_add_beacon
,
956 .set_beacon
= ieee80211_set_beacon
,
957 .del_beacon
= ieee80211_del_beacon
,
958 .add_station
= ieee80211_add_station
,
959 .del_station
= ieee80211_del_station
,
960 .change_station
= ieee80211_change_station
,
961 .get_station
= ieee80211_get_station
,
962 .dump_station
= ieee80211_dump_station
,
963 #ifdef CONFIG_MAC80211_MESH
964 .add_mpath
= ieee80211_add_mpath
,
965 .del_mpath
= ieee80211_del_mpath
,
966 .change_mpath
= ieee80211_change_mpath
,
967 .get_mpath
= ieee80211_get_mpath
,
968 .dump_mpath
= ieee80211_dump_mpath
,