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 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
56 itype
= nl80211_type_to_mac80211_type(type
);
57 if (itype
== IEEE80211_IF_TYPE_INVALID
)
60 err
= ieee80211_if_add(local
->mdev
, name
, &dev
, itype
, params
);
61 if (err
|| itype
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
64 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
65 sdata
->u
.mntr_flags
= *flags
;
69 static int ieee80211_del_iface(struct wiphy
*wiphy
, int ifindex
)
71 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
72 struct net_device
*dev
;
75 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
78 /* we're under RTNL */
79 dev
= __dev_get_by_index(&init_net
, ifindex
);
85 return ieee80211_if_remove(local
->mdev
, name
, -1);
88 static int ieee80211_change_iface(struct wiphy
*wiphy
, int ifindex
,
89 enum nl80211_iftype type
, u32
*flags
,
90 struct vif_params
*params
)
92 struct ieee80211_local
*local
= wiphy_priv(wiphy
);
93 struct net_device
*dev
;
94 enum ieee80211_if_types itype
;
95 struct ieee80211_sub_if_data
*sdata
;
97 if (unlikely(local
->reg_state
!= IEEE80211_DEV_REGISTERED
))
100 /* we're under RTNL */
101 dev
= __dev_get_by_index(&init_net
, ifindex
);
105 if (netif_running(dev
))
108 itype
= nl80211_type_to_mac80211_type(type
);
109 if (itype
== IEEE80211_IF_TYPE_INVALID
)
112 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
114 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
)
117 ieee80211_if_reinit(dev
);
118 ieee80211_if_set_type(dev
, itype
);
120 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->mesh_id_len
)
121 ieee80211_if_sta_set_mesh_id(&sdata
->u
.sta
,
125 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MNTR
|| !flags
)
128 sdata
->u
.mntr_flags
= *flags
;
132 static int ieee80211_add_key(struct wiphy
*wiphy
, struct net_device
*dev
,
133 u8 key_idx
, u8
*mac_addr
,
134 struct key_params
*params
)
136 struct ieee80211_sub_if_data
*sdata
;
137 struct sta_info
*sta
= NULL
;
138 enum ieee80211_key_alg alg
;
139 struct ieee80211_key
*key
;
142 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
144 switch (params
->cipher
) {
145 case WLAN_CIPHER_SUITE_WEP40
:
146 case WLAN_CIPHER_SUITE_WEP104
:
149 case WLAN_CIPHER_SUITE_TKIP
:
152 case WLAN_CIPHER_SUITE_CCMP
:
159 key
= ieee80211_key_alloc(alg
, key_idx
, params
->key_len
, params
->key
);
166 sta
= sta_info_get(sdata
->local
, mac_addr
);
168 ieee80211_key_free(key
);
174 ieee80211_key_link(key
, sdata
, sta
);
183 static int ieee80211_del_key(struct wiphy
*wiphy
, struct net_device
*dev
,
184 u8 key_idx
, u8
*mac_addr
)
186 struct ieee80211_sub_if_data
*sdata
;
187 struct sta_info
*sta
;
190 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
197 sta
= sta_info_get(sdata
->local
, mac_addr
);
202 ieee80211_key_free(sta
->key
);
210 if (!sdata
->keys
[key_idx
]) {
215 ieee80211_key_free(sdata
->keys
[key_idx
]);
216 WARN_ON(sdata
->keys
[key_idx
]);
225 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
226 u8 key_idx
, u8
*mac_addr
, void *cookie
,
227 void (*callback
)(void *cookie
,
228 struct key_params
*params
))
230 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
231 struct sta_info
*sta
= NULL
;
233 struct key_params params
;
234 struct ieee80211_key
*key
;
242 sta
= sta_info_get(sdata
->local
, mac_addr
);
248 key
= sdata
->keys
[key_idx
];
253 memset(¶ms
, 0, sizeof(params
));
255 switch (key
->conf
.alg
) {
257 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
259 iv32
= key
->u
.tkip
.iv32
;
260 iv16
= key
->u
.tkip
.iv16
;
262 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
263 sdata
->local
->ops
->get_tkip_seq
)
264 sdata
->local
->ops
->get_tkip_seq(
265 local_to_hw(sdata
->local
),
266 key
->conf
.hw_key_idx
,
269 seq
[0] = iv16
& 0xff;
270 seq
[1] = (iv16
>> 8) & 0xff;
271 seq
[2] = iv32
& 0xff;
272 seq
[3] = (iv32
>> 8) & 0xff;
273 seq
[4] = (iv32
>> 16) & 0xff;
274 seq
[5] = (iv32
>> 24) & 0xff;
279 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
280 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
281 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
282 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
283 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
284 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
285 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
290 if (key
->conf
.keylen
== 5)
291 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
293 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
297 params
.key
= key
->conf
.key
;
298 params
.key_len
= key
->conf
.keylen
;
300 callback(cookie
, ¶ms
);
308 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
309 struct net_device
*dev
,
312 struct ieee80211_sub_if_data
*sdata
;
316 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
317 ieee80211_set_default_key(sdata
, key_idx
);
324 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
326 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
328 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
329 STATION_INFO_RX_BYTES
|
330 STATION_INFO_TX_BYTES
;
332 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
333 sinfo
->rx_bytes
= sta
->rx_bytes
;
334 sinfo
->tx_bytes
= sta
->tx_bytes
;
336 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
337 #ifdef CONFIG_MAC80211_MESH
338 sinfo
->filled
|= STATION_INFO_LLID
|
340 STATION_INFO_PLINK_STATE
;
342 sinfo
->llid
= le16_to_cpu(sta
->llid
);
343 sinfo
->plid
= le16_to_cpu(sta
->plid
);
344 sinfo
->plink_state
= sta
->plink_state
;
350 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
351 int idx
, u8
*mac
, struct station_info
*sinfo
)
353 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
354 struct sta_info
*sta
;
359 sta
= sta_info_get_by_idx(local
, idx
, dev
);
362 memcpy(mac
, sta
->addr
, ETH_ALEN
);
363 sta_set_sinfo(sta
, sinfo
);
371 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
372 u8
*mac
, struct station_info
*sinfo
)
374 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
375 struct sta_info
*sta
;
380 /* XXX: verify sta->dev == dev */
382 sta
= sta_info_get(local
, mac
);
385 sta_set_sinfo(sta
, sinfo
);
394 * This handles both adding a beacon and setting new beacon info
396 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
397 struct beacon_parameters
*params
)
399 struct beacon_data
*new, *old
;
400 int new_head_len
, new_tail_len
;
404 old
= sdata
->u
.ap
.beacon
;
406 /* head must not be zero-length */
407 if (params
->head
&& !params
->head_len
)
411 * This is a kludge. beacon interval should really be part
412 * of the beacon information.
414 if (params
->interval
) {
415 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
416 if (ieee80211_hw_config(sdata
->local
))
419 * We updated some parameter so if below bails out
425 /* Need to have a beacon head if we don't have one yet */
426 if (!params
->head
&& !old
)
429 /* sorry, no way to start beaconing without dtim period */
430 if (!params
->dtim_period
&& !old
)
433 /* new or old head? */
435 new_head_len
= params
->head_len
;
437 new_head_len
= old
->head_len
;
439 /* new or old tail? */
440 if (params
->tail
|| !old
)
441 /* params->tail_len will be zero for !params->tail */
442 new_tail_len
= params
->tail_len
;
444 new_tail_len
= old
->tail_len
;
446 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
448 new = kzalloc(size
, GFP_KERNEL
);
452 /* start filling the new info now */
454 /* new or old dtim period? */
455 if (params
->dtim_period
)
456 new->dtim_period
= params
->dtim_period
;
458 new->dtim_period
= old
->dtim_period
;
461 * pointers go into the block we allocated,
462 * memory is | beacon_data | head | tail |
464 new->head
= ((u8
*) new) + sizeof(*new);
465 new->tail
= new->head
+ new_head_len
;
466 new->head_len
= new_head_len
;
467 new->tail_len
= new_tail_len
;
471 memcpy(new->head
, params
->head
, new_head_len
);
473 memcpy(new->head
, old
->head
, new_head_len
);
475 /* copy in optional tail */
477 memcpy(new->tail
, params
->tail
, new_tail_len
);
480 memcpy(new->tail
, old
->tail
, new_tail_len
);
482 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
488 return ieee80211_if_config_beacon(sdata
->dev
);
491 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
492 struct beacon_parameters
*params
)
494 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
495 struct beacon_data
*old
;
497 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
500 old
= sdata
->u
.ap
.beacon
;
505 return ieee80211_config_beacon(sdata
, params
);
508 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
509 struct beacon_parameters
*params
)
511 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
512 struct beacon_data
*old
;
514 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
517 old
= sdata
->u
.ap
.beacon
;
522 return ieee80211_config_beacon(sdata
, params
);
525 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
527 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
528 struct beacon_data
*old
;
530 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
533 old
= sdata
->u
.ap
.beacon
;
538 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
542 return ieee80211_if_config_beacon(dev
);
545 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
546 struct iapp_layer2_update
{
547 u8 da
[ETH_ALEN
]; /* broadcast */
548 u8 sa
[ETH_ALEN
]; /* STA addr */
554 } __attribute__ ((packed
));
556 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
558 struct iapp_layer2_update
*msg
;
561 /* Send Level 2 Update Frame to update forwarding tables in layer 2
564 skb
= dev_alloc_skb(sizeof(*msg
));
567 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
569 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
570 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
572 memset(msg
->da
, 0xff, ETH_ALEN
);
573 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
576 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
577 msg
->control
= 0xaf; /* XID response lsb.1111F101.
578 * F=0 (no poll command; unsolicited frame) */
579 msg
->xid_info
[0] = 0x81; /* XID format identifier */
580 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
581 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
583 skb
->dev
= sta
->sdata
->dev
;
584 skb
->protocol
= eth_type_trans(skb
, sta
->sdata
->dev
);
585 memset(skb
->cb
, 0, sizeof(skb
->cb
));
589 static void sta_apply_parameters(struct ieee80211_local
*local
,
590 struct sta_info
*sta
,
591 struct station_parameters
*params
)
595 struct ieee80211_supported_band
*sband
;
596 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
599 * FIXME: updating the flags is racy when this function is
600 * called from ieee80211_change_station(), this will
601 * be resolved in a future patch.
604 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
605 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
606 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
607 sta
->flags
|= WLAN_STA_AUTHORIZED
;
609 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
610 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
611 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
613 sta
->flags
&= ~WLAN_STA_WME
;
614 if (params
->station_flags
& STATION_FLAG_WME
)
615 sta
->flags
|= WLAN_STA_WME
;
619 * FIXME: updating the following information is racy when this
620 * function is called from ieee80211_change_station().
621 * However, all this information should be static so
622 * maybe we should just reject attemps to change it.
626 sta
->aid
= params
->aid
;
627 if (sta
->aid
> IEEE80211_MAX_AID
)
628 sta
->aid
= 0; /* XXX: should this be an error? */
631 if (params
->listen_interval
>= 0)
632 sta
->listen_interval
= params
->listen_interval
;
634 if (params
->supported_rates
) {
636 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
638 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
639 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
640 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
641 if (sband
->bitrates
[j
].bitrate
== rate
)
645 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
648 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
649 switch (params
->plink_action
) {
650 case PLINK_ACTION_OPEN
:
651 mesh_plink_open(sta
);
653 case PLINK_ACTION_BLOCK
:
654 mesh_plink_block(sta
);
660 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
661 u8
*mac
, struct station_parameters
*params
)
663 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
664 struct sta_info
*sta
;
665 struct ieee80211_sub_if_data
*sdata
;
668 /* Prevent a race with changing the rate control algorithm */
669 if (!netif_running(dev
))
673 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
675 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
676 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
679 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
681 if (compare_ether_addr(mac
, dev
->dev_addr
) == 0)
684 if (is_multicast_ether_addr(mac
))
687 sta
= sta_info_alloc(sdata
, mac
, GFP_KERNEL
);
691 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
693 sta_apply_parameters(local
, sta
, params
);
695 rate_control_rate_init(sta
, local
);
699 err
= sta_info_insert(sta
);
701 /* STA has been freed */
706 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
707 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
708 ieee80211_send_layer2_update(sta
);
715 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
718 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
719 struct ieee80211_local
*local
= sdata
->local
;
720 struct sta_info
*sta
;
725 /* XXX: get sta belonging to dev */
726 sta
= sta_info_get(local
, mac
);
732 sta_info_unlink(&sta
);
735 sta_info_destroy(sta
);
737 sta_info_flush(local
, sdata
);
742 static int ieee80211_change_station(struct wiphy
*wiphy
,
743 struct net_device
*dev
,
745 struct station_parameters
*params
)
747 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
748 struct sta_info
*sta
;
749 struct ieee80211_sub_if_data
*vlansdata
;
753 /* XXX: get sta belonging to dev */
754 sta
= sta_info_get(local
, mac
);
760 if (params
->vlan
&& params
->vlan
!= sta
->sdata
->dev
) {
761 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
763 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
764 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
) {
769 sta
->sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
770 ieee80211_send_layer2_update(sta
);
773 sta_apply_parameters(local
, sta
, params
);
780 #ifdef CONFIG_MAC80211_MESH
781 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
782 u8
*dst
, u8
*next_hop
)
784 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
785 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
786 struct mesh_path
*mpath
;
787 struct sta_info
*sta
;
790 if (!netif_running(dev
))
793 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
797 sta
= sta_info_get(local
, next_hop
);
803 err
= mesh_path_add(dst
, dev
);
809 mpath
= mesh_path_lookup(dst
, dev
);
814 mesh_path_fix_nexthop(mpath
, sta
);
820 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
824 return mesh_path_del(dst
, dev
);
826 mesh_path_flush(dev
);
830 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
831 struct net_device
*dev
,
832 u8
*dst
, u8
*next_hop
)
834 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
835 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
836 struct mesh_path
*mpath
;
837 struct sta_info
*sta
;
839 if (!netif_running(dev
))
842 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
847 sta
= sta_info_get(local
, next_hop
);
853 mpath
= mesh_path_lookup(dst
, dev
);
859 mesh_path_fix_nexthop(mpath
, sta
);
865 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
866 struct mpath_info
*pinfo
)
869 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
871 memset(next_hop
, 0, ETH_ALEN
);
873 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
877 MPATH_INFO_DISCOVERY_TIMEOUT
|
878 MPATH_INFO_DISCOVERY_RETRIES
|
881 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
882 pinfo
->dsn
= mpath
->dsn
;
883 pinfo
->metric
= mpath
->metric
;
884 if (time_before(jiffies
, mpath
->exp_time
))
885 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
886 pinfo
->discovery_timeout
=
887 jiffies_to_msecs(mpath
->discovery_timeout
);
888 pinfo
->discovery_retries
= mpath
->discovery_retries
;
890 if (mpath
->flags
& MESH_PATH_ACTIVE
)
891 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
892 if (mpath
->flags
& MESH_PATH_RESOLVING
)
893 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
894 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
895 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
896 if (mpath
->flags
& MESH_PATH_FIXED
)
897 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
898 if (mpath
->flags
& MESH_PATH_RESOLVING
)
899 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
901 pinfo
->flags
= mpath
->flags
;
904 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
905 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
908 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
909 struct mesh_path
*mpath
;
911 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
915 mpath
= mesh_path_lookup(dst
, dev
);
920 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
921 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
926 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
927 int idx
, u8
*dst
, u8
*next_hop
,
928 struct mpath_info
*pinfo
)
930 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
931 struct mesh_path
*mpath
;
933 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
937 mpath
= mesh_path_lookup_by_idx(idx
, dev
);
942 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
943 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
949 struct cfg80211_ops mac80211_config_ops
= {
950 .add_virtual_intf
= ieee80211_add_iface
,
951 .del_virtual_intf
= ieee80211_del_iface
,
952 .change_virtual_intf
= ieee80211_change_iface
,
953 .add_key
= ieee80211_add_key
,
954 .del_key
= ieee80211_del_key
,
955 .get_key
= ieee80211_get_key
,
956 .set_default_key
= ieee80211_config_default_key
,
957 .add_beacon
= ieee80211_add_beacon
,
958 .set_beacon
= ieee80211_set_beacon
,
959 .del_beacon
= ieee80211_del_beacon
,
960 .add_station
= ieee80211_add_station
,
961 .del_station
= ieee80211_del_station
,
962 .change_station
= ieee80211_change_station
,
963 .get_station
= ieee80211_get_station
,
964 .dump_station
= ieee80211_dump_station
,
965 #ifdef CONFIG_MAC80211_MESH
966 .add_mpath
= ieee80211_add_mpath
,
967 .del_mpath
= ieee80211_del_mpath
,
968 .change_mpath
= ieee80211_change_mpath
,
969 .get_mpath
= ieee80211_get_mpath
,
970 .dump_mpath
= ieee80211_dump_mpath
,