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 #define DEFAULT_RATES 0
22 static enum ieee80211_if_types
23 nl80211_type_to_mac80211_type(enum nl80211_iftype type
)
26 case NL80211_IFTYPE_UNSPECIFIED
:
27 return IEEE80211_IF_TYPE_STA
;
28 case NL80211_IFTYPE_ADHOC
:
29 return IEEE80211_IF_TYPE_IBSS
;
30 case NL80211_IFTYPE_STATION
:
31 return IEEE80211_IF_TYPE_STA
;
32 case NL80211_IFTYPE_MONITOR
:
33 return IEEE80211_IF_TYPE_MNTR
;
34 #ifdef CONFIG_MAC80211_MESH
35 case NL80211_IFTYPE_MESH_POINT
:
36 return IEEE80211_IF_TYPE_MESH_POINT
;
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
;
140 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
);
164 sta
= sta_info_get(sdata
->local
, mac_addr
);
166 ieee80211_key_free(key
);
171 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
;
187 struct ieee80211_key
*key
;
189 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
192 sta
= sta_info_get(sdata
->local
, mac_addr
);
199 ieee80211_key_free(key
);
208 if (!sdata
->keys
[key_idx
])
211 key
= sdata
->keys
[key_idx
];
212 ieee80211_key_free(key
);
213 WARN_ON(sdata
->keys
[key_idx
]);
218 static int ieee80211_get_key(struct wiphy
*wiphy
, struct net_device
*dev
,
219 u8 key_idx
, u8
*mac_addr
, void *cookie
,
220 void (*callback
)(void *cookie
,
221 struct key_params
*params
))
223 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
224 struct sta_info
*sta
= NULL
;
226 struct key_params params
;
227 struct ieee80211_key
*key
;
233 sta
= sta_info_get(sdata
->local
, mac_addr
);
239 key
= sdata
->keys
[key_idx
];
244 memset(¶ms
, 0, sizeof(params
));
246 switch (key
->conf
.alg
) {
248 params
.cipher
= WLAN_CIPHER_SUITE_TKIP
;
250 iv32
= key
->u
.tkip
.iv32
;
251 iv16
= key
->u
.tkip
.iv16
;
253 if (key
->flags
& KEY_FLAG_UPLOADED_TO_HARDWARE
&&
254 sdata
->local
->ops
->get_tkip_seq
)
255 sdata
->local
->ops
->get_tkip_seq(
256 local_to_hw(sdata
->local
),
257 key
->conf
.hw_key_idx
,
260 seq
[0] = iv16
& 0xff;
261 seq
[1] = (iv16
>> 8) & 0xff;
262 seq
[2] = iv32
& 0xff;
263 seq
[3] = (iv32
>> 8) & 0xff;
264 seq
[4] = (iv32
>> 16) & 0xff;
265 seq
[5] = (iv32
>> 24) & 0xff;
270 params
.cipher
= WLAN_CIPHER_SUITE_CCMP
;
271 seq
[0] = key
->u
.ccmp
.tx_pn
[5];
272 seq
[1] = key
->u
.ccmp
.tx_pn
[4];
273 seq
[2] = key
->u
.ccmp
.tx_pn
[3];
274 seq
[3] = key
->u
.ccmp
.tx_pn
[2];
275 seq
[4] = key
->u
.ccmp
.tx_pn
[1];
276 seq
[5] = key
->u
.ccmp
.tx_pn
[0];
281 if (key
->conf
.keylen
== 5)
282 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
284 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
288 params
.key
= key
->conf
.key
;
289 params
.key_len
= key
->conf
.keylen
;
291 callback(cookie
, ¶ms
);
300 static int ieee80211_config_default_key(struct wiphy
*wiphy
,
301 struct net_device
*dev
,
304 struct ieee80211_sub_if_data
*sdata
;
306 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
307 ieee80211_set_default_key(sdata
, key_idx
);
312 static void sta_set_sinfo(struct sta_info
*sta
, struct station_info
*sinfo
)
314 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(sta
->dev
);
316 sinfo
->filled
= STATION_INFO_INACTIVE_TIME
|
317 STATION_INFO_RX_BYTES
|
318 STATION_INFO_TX_BYTES
;
320 sinfo
->inactive_time
= jiffies_to_msecs(jiffies
- sta
->last_rx
);
321 sinfo
->rx_bytes
= sta
->rx_bytes
;
322 sinfo
->tx_bytes
= sta
->tx_bytes
;
324 if (ieee80211_vif_is_mesh(&sdata
->vif
)) {
325 #ifdef CONFIG_MAC80211_MESH
326 sinfo
->filled
|= STATION_INFO_LLID
|
328 STATION_INFO_PLINK_STATE
;
330 sinfo
->llid
= le16_to_cpu(sta
->llid
);
331 sinfo
->plid
= le16_to_cpu(sta
->plid
);
332 sinfo
->plink_state
= sta
->plink_state
;
338 static int ieee80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
339 int idx
, u8
*mac
, struct station_info
*sinfo
)
341 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
342 struct sta_info
*sta
;
344 sta
= sta_info_get_by_idx(local
, idx
, dev
);
348 memcpy(mac
, sta
->addr
, ETH_ALEN
);
349 sta_set_sinfo(sta
, sinfo
);
355 static int ieee80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
356 u8
*mac
, struct station_info
*sinfo
)
358 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
359 struct sta_info
*sta
;
361 sta
= sta_info_get(local
, mac
);
365 /* XXX: verify sta->dev == dev */
366 sta_set_sinfo(sta
, sinfo
);
373 * This handles both adding a beacon and setting new beacon info
375 static int ieee80211_config_beacon(struct ieee80211_sub_if_data
*sdata
,
376 struct beacon_parameters
*params
)
378 struct beacon_data
*new, *old
;
379 int new_head_len
, new_tail_len
;
383 old
= sdata
->u
.ap
.beacon
;
385 /* head must not be zero-length */
386 if (params
->head
&& !params
->head_len
)
390 * This is a kludge. beacon interval should really be part
391 * of the beacon information.
393 if (params
->interval
) {
394 sdata
->local
->hw
.conf
.beacon_int
= params
->interval
;
395 if (ieee80211_hw_config(sdata
->local
))
398 * We updated some parameter so if below bails out
404 /* Need to have a beacon head if we don't have one yet */
405 if (!params
->head
&& !old
)
408 /* sorry, no way to start beaconing without dtim period */
409 if (!params
->dtim_period
&& !old
)
412 /* new or old head? */
414 new_head_len
= params
->head_len
;
416 new_head_len
= old
->head_len
;
418 /* new or old tail? */
419 if (params
->tail
|| !old
)
420 /* params->tail_len will be zero for !params->tail */
421 new_tail_len
= params
->tail_len
;
423 new_tail_len
= old
->tail_len
;
425 size
= sizeof(*new) + new_head_len
+ new_tail_len
;
427 new = kzalloc(size
, GFP_KERNEL
);
431 /* start filling the new info now */
433 /* new or old dtim period? */
434 if (params
->dtim_period
)
435 new->dtim_period
= params
->dtim_period
;
437 new->dtim_period
= old
->dtim_period
;
440 * pointers go into the block we allocated,
441 * memory is | beacon_data | head | tail |
443 new->head
= ((u8
*) new) + sizeof(*new);
444 new->tail
= new->head
+ new_head_len
;
445 new->head_len
= new_head_len
;
446 new->tail_len
= new_tail_len
;
450 memcpy(new->head
, params
->head
, new_head_len
);
452 memcpy(new->head
, old
->head
, new_head_len
);
454 /* copy in optional tail */
456 memcpy(new->tail
, params
->tail
, new_tail_len
);
459 memcpy(new->tail
, old
->tail
, new_tail_len
);
461 rcu_assign_pointer(sdata
->u
.ap
.beacon
, new);
467 return ieee80211_if_config_beacon(sdata
->dev
);
470 static int ieee80211_add_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
471 struct beacon_parameters
*params
)
473 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
474 struct beacon_data
*old
;
476 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
479 old
= sdata
->u
.ap
.beacon
;
484 return ieee80211_config_beacon(sdata
, params
);
487 static int ieee80211_set_beacon(struct wiphy
*wiphy
, struct net_device
*dev
,
488 struct beacon_parameters
*params
)
490 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
491 struct beacon_data
*old
;
493 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
496 old
= sdata
->u
.ap
.beacon
;
501 return ieee80211_config_beacon(sdata
, params
);
504 static int ieee80211_del_beacon(struct wiphy
*wiphy
, struct net_device
*dev
)
506 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
507 struct beacon_data
*old
;
509 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
512 old
= sdata
->u
.ap
.beacon
;
517 rcu_assign_pointer(sdata
->u
.ap
.beacon
, NULL
);
521 return ieee80211_if_config_beacon(dev
);
524 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
525 struct iapp_layer2_update
{
526 u8 da
[ETH_ALEN
]; /* broadcast */
527 u8 sa
[ETH_ALEN
]; /* STA addr */
533 } __attribute__ ((packed
));
535 static void ieee80211_send_layer2_update(struct sta_info
*sta
)
537 struct iapp_layer2_update
*msg
;
540 /* Send Level 2 Update Frame to update forwarding tables in layer 2
543 skb
= dev_alloc_skb(sizeof(*msg
));
546 msg
= (struct iapp_layer2_update
*)skb_put(skb
, sizeof(*msg
));
548 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
549 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
551 memset(msg
->da
, 0xff, ETH_ALEN
);
552 memcpy(msg
->sa
, sta
->addr
, ETH_ALEN
);
555 msg
->ssap
= 0x01; /* NULL LSAP, CR Bit: Response */
556 msg
->control
= 0xaf; /* XID response lsb.1111F101.
557 * F=0 (no poll command; unsolicited frame) */
558 msg
->xid_info
[0] = 0x81; /* XID format identifier */
559 msg
->xid_info
[1] = 1; /* LLC types/classes: Type 1 LLC */
560 msg
->xid_info
[2] = 0; /* XID sender's receive window size (RW) */
563 skb
->protocol
= eth_type_trans(skb
, sta
->dev
);
564 memset(skb
->cb
, 0, sizeof(skb
->cb
));
568 static void sta_apply_parameters(struct ieee80211_local
*local
,
569 struct sta_info
*sta
,
570 struct station_parameters
*params
)
574 struct ieee80211_supported_band
*sband
;
575 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(sta
->dev
);
577 if (params
->station_flags
& STATION_FLAG_CHANGED
) {
578 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
579 if (params
->station_flags
& STATION_FLAG_AUTHORIZED
)
580 sta
->flags
|= WLAN_STA_AUTHORIZED
;
582 sta
->flags
&= ~WLAN_STA_SHORT_PREAMBLE
;
583 if (params
->station_flags
& STATION_FLAG_SHORT_PREAMBLE
)
584 sta
->flags
|= WLAN_STA_SHORT_PREAMBLE
;
586 sta
->flags
&= ~WLAN_STA_WME
;
587 if (params
->station_flags
& STATION_FLAG_WME
)
588 sta
->flags
|= WLAN_STA_WME
;
592 sta
->aid
= params
->aid
;
593 if (sta
->aid
> IEEE80211_MAX_AID
)
594 sta
->aid
= 0; /* XXX: should this be an error? */
597 if (params
->listen_interval
>= 0)
598 sta
->listen_interval
= params
->listen_interval
;
600 if (params
->supported_rates
) {
602 sband
= local
->hw
.wiphy
->bands
[local
->oper_channel
->band
];
604 for (i
= 0; i
< params
->supported_rates_len
; i
++) {
605 int rate
= (params
->supported_rates
[i
] & 0x7f) * 5;
606 for (j
= 0; j
< sband
->n_bitrates
; j
++) {
607 if (sband
->bitrates
[j
].bitrate
== rate
)
611 sta
->supp_rates
[local
->oper_channel
->band
] = rates
;
614 if (ieee80211_vif_is_mesh(&sdata
->vif
) && params
->plink_action
) {
615 switch (params
->plink_action
) {
616 case PLINK_ACTION_OPEN
:
617 mesh_plink_open(sta
);
619 case PLINK_ACTION_BLOCK
:
620 mesh_plink_block(sta
);
626 static int ieee80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
627 u8
*mac
, struct station_parameters
*params
)
629 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
630 struct sta_info
*sta
;
631 struct ieee80211_sub_if_data
*sdata
;
633 /* Prevent a race with changing the rate control algorithm */
634 if (!netif_running(dev
))
638 sdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
640 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
641 sdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
644 sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
646 if (ieee80211_vif_is_mesh(&sdata
->vif
))
647 sta
= mesh_plink_add(mac
, DEFAULT_RATES
, dev
);
649 sta
= sta_info_add(local
, dev
, mac
, GFP_KERNEL
);
654 sta
->dev
= sdata
->dev
;
655 if (sdata
->vif
.type
== IEEE80211_IF_TYPE_VLAN
||
656 sdata
->vif
.type
== IEEE80211_IF_TYPE_AP
)
657 ieee80211_send_layer2_update(sta
);
659 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
661 sta_apply_parameters(local
, sta
, params
);
663 rate_control_rate_init(sta
, local
);
670 static int ieee80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
673 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
674 struct sta_info
*sta
;
677 /* XXX: get sta belonging to dev */
678 sta
= sta_info_get(local
, mac
);
685 sta_info_flush(local
, dev
);
690 static int ieee80211_change_station(struct wiphy
*wiphy
,
691 struct net_device
*dev
,
693 struct station_parameters
*params
)
695 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
696 struct sta_info
*sta
;
697 struct ieee80211_sub_if_data
*vlansdata
;
699 /* XXX: get sta belonging to dev */
700 sta
= sta_info_get(local
, mac
);
704 if (params
->vlan
&& params
->vlan
!= sta
->dev
) {
705 vlansdata
= IEEE80211_DEV_TO_SUB_IF(params
->vlan
);
707 if (vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_VLAN
||
708 vlansdata
->vif
.type
!= IEEE80211_IF_TYPE_AP
)
711 sta
->dev
= params
->vlan
;
712 ieee80211_send_layer2_update(sta
);
715 sta_apply_parameters(local
, sta
, params
);
722 #ifdef CONFIG_MAC80211_MESH
723 static int ieee80211_add_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
724 u8
*dst
, u8
*next_hop
)
726 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
727 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
728 struct mesh_path
*mpath
;
729 struct sta_info
*sta
;
732 if (!netif_running(dev
))
735 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
738 sta
= sta_info_get(local
, next_hop
);
742 err
= mesh_path_add(dst
, dev
);
747 mpath
= mesh_path_lookup(dst
, dev
);
753 mesh_path_fix_nexthop(mpath
, sta
);
759 static int ieee80211_del_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
763 return mesh_path_del(dst
, dev
);
765 mesh_path_flush(dev
);
769 static int ieee80211_change_mpath(struct wiphy
*wiphy
,
770 struct net_device
*dev
,
771 u8
*dst
, u8
*next_hop
)
773 struct ieee80211_local
*local
= wdev_priv(dev
->ieee80211_ptr
);
774 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
775 struct mesh_path
*mpath
;
776 struct sta_info
*sta
;
778 if (!netif_running(dev
))
781 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
784 sta
= sta_info_get(local
, next_hop
);
789 mpath
= mesh_path_lookup(dst
, dev
);
796 mesh_path_fix_nexthop(mpath
, sta
);
802 static void mpath_set_pinfo(struct mesh_path
*mpath
, u8
*next_hop
,
803 struct mpath_info
*pinfo
)
806 memcpy(next_hop
, mpath
->next_hop
->addr
, ETH_ALEN
);
808 memset(next_hop
, 0, ETH_ALEN
);
810 pinfo
->filled
= MPATH_INFO_FRAME_QLEN
|
814 MPATH_INFO_DISCOVERY_TIMEOUT
|
815 MPATH_INFO_DISCOVERY_RETRIES
|
818 pinfo
->frame_qlen
= mpath
->frame_queue
.qlen
;
819 pinfo
->dsn
= mpath
->dsn
;
820 pinfo
->metric
= mpath
->metric
;
821 if (time_before(jiffies
, mpath
->exp_time
))
822 pinfo
->exptime
= jiffies_to_msecs(mpath
->exp_time
- jiffies
);
823 pinfo
->discovery_timeout
=
824 jiffies_to_msecs(mpath
->discovery_timeout
);
825 pinfo
->discovery_retries
= mpath
->discovery_retries
;
827 if (mpath
->flags
& MESH_PATH_ACTIVE
)
828 pinfo
->flags
|= NL80211_MPATH_FLAG_ACTIVE
;
829 if (mpath
->flags
& MESH_PATH_RESOLVING
)
830 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
831 if (mpath
->flags
& MESH_PATH_DSN_VALID
)
832 pinfo
->flags
|= NL80211_MPATH_FLAG_DSN_VALID
;
833 if (mpath
->flags
& MESH_PATH_FIXED
)
834 pinfo
->flags
|= NL80211_MPATH_FLAG_FIXED
;
835 if (mpath
->flags
& MESH_PATH_RESOLVING
)
836 pinfo
->flags
|= NL80211_MPATH_FLAG_RESOLVING
;
838 pinfo
->flags
= mpath
->flags
;
841 static int ieee80211_get_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
842 u8
*dst
, u8
*next_hop
, struct mpath_info
*pinfo
)
845 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
846 struct mesh_path
*mpath
;
848 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
852 mpath
= mesh_path_lookup(dst
, dev
);
857 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
858 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
863 static int ieee80211_dump_mpath(struct wiphy
*wiphy
, struct net_device
*dev
,
864 int idx
, u8
*dst
, u8
*next_hop
,
865 struct mpath_info
*pinfo
)
867 struct ieee80211_sub_if_data
*sdata
= IEEE80211_DEV_TO_SUB_IF(dev
);
868 struct mesh_path
*mpath
;
870 if (sdata
->vif
.type
!= IEEE80211_IF_TYPE_MESH_POINT
)
874 mpath
= mesh_path_lookup_by_idx(idx
, dev
);
879 memcpy(dst
, mpath
->dst
, ETH_ALEN
);
880 mpath_set_pinfo(mpath
, next_hop
, pinfo
);
886 struct cfg80211_ops mac80211_config_ops
= {
887 .add_virtual_intf
= ieee80211_add_iface
,
888 .del_virtual_intf
= ieee80211_del_iface
,
889 .change_virtual_intf
= ieee80211_change_iface
,
890 .add_key
= ieee80211_add_key
,
891 .del_key
= ieee80211_del_key
,
892 .get_key
= ieee80211_get_key
,
893 .set_default_key
= ieee80211_config_default_key
,
894 .add_beacon
= ieee80211_add_beacon
,
895 .set_beacon
= ieee80211_set_beacon
,
896 .del_beacon
= ieee80211_del_beacon
,
897 .add_station
= ieee80211_add_station
,
898 .del_station
= ieee80211_del_station
,
899 .change_station
= ieee80211_change_station
,
900 .get_station
= ieee80211_get_station
,
901 .dump_station
= ieee80211_dump_station
,
902 #ifdef CONFIG_MAC80211_MESH
903 .add_mpath
= ieee80211_add_mpath
,
904 .del_mpath
= ieee80211_del_mpath
,
905 .change_mpath
= ieee80211_change_mpath
,
906 .get_mpath
= ieee80211_get_mpath
,
907 .dump_mpath
= ieee80211_dump_mpath
,