2 * This is the new netlink-based wireless configuration interface.
4 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
8 #include <linux/module.h>
10 #include <linux/mutex.h>
11 #include <linux/list.h>
12 #include <linux/if_ether.h>
13 #include <linux/ieee80211.h>
14 #include <linux/nl80211.h>
15 #include <linux/rtnetlink.h>
16 #include <linux/netlink.h>
17 #include <net/genetlink.h>
18 #include <net/cfg80211.h>
22 /* the netlink family */
23 static struct genl_family nl80211_fam
= {
24 .id
= GENL_ID_GENERATE
, /* don't bother with a hardcoded ID */
25 .name
= "nl80211", /* have users key off the name instead */
26 .hdrsize
= 0, /* no private header */
27 .version
= 1, /* no particular meaning now */
28 .maxattr
= NL80211_ATTR_MAX
,
31 /* internal helper: get drv and dev */
32 static int get_drv_dev_by_info_ifindex(struct genl_info
*info
,
33 struct cfg80211_registered_device
**drv
,
34 struct net_device
**dev
)
38 if (!info
->attrs
[NL80211_ATTR_IFINDEX
])
41 ifindex
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFINDEX
]);
42 *dev
= dev_get_by_index(&init_net
, ifindex
);
46 *drv
= cfg80211_get_dev_from_ifindex(ifindex
);
55 /* policy for the attributes */
56 static struct nla_policy nl80211_policy
[NL80211_ATTR_MAX
+1] __read_mostly
= {
57 [NL80211_ATTR_WIPHY
] = { .type
= NLA_U32
},
58 [NL80211_ATTR_WIPHY_NAME
] = { .type
= NLA_NUL_STRING
,
59 .len
= BUS_ID_SIZE
-1 },
61 [NL80211_ATTR_IFTYPE
] = { .type
= NLA_U32
},
62 [NL80211_ATTR_IFINDEX
] = { .type
= NLA_U32
},
63 [NL80211_ATTR_IFNAME
] = { .type
= NLA_NUL_STRING
, .len
= IFNAMSIZ
-1 },
65 [NL80211_ATTR_MAC
] = { .type
= NLA_BINARY
, .len
= ETH_ALEN
},
67 [NL80211_ATTR_KEY_DATA
] = { .type
= NLA_BINARY
,
68 .len
= WLAN_MAX_KEY_LEN
},
69 [NL80211_ATTR_KEY_IDX
] = { .type
= NLA_U8
},
70 [NL80211_ATTR_KEY_CIPHER
] = { .type
= NLA_U32
},
71 [NL80211_ATTR_KEY_DEFAULT
] = { .type
= NLA_FLAG
},
73 [NL80211_ATTR_BEACON_INTERVAL
] = { .type
= NLA_U32
},
74 [NL80211_ATTR_DTIM_PERIOD
] = { .type
= NLA_U32
},
75 [NL80211_ATTR_BEACON_HEAD
] = { .type
= NLA_BINARY
,
76 .len
= IEEE80211_MAX_DATA_LEN
},
77 [NL80211_ATTR_BEACON_TAIL
] = { .type
= NLA_BINARY
,
78 .len
= IEEE80211_MAX_DATA_LEN
},
79 [NL80211_ATTR_STA_AID
] = { .type
= NLA_U16
},
80 [NL80211_ATTR_STA_FLAGS
] = { .type
= NLA_NESTED
},
81 [NL80211_ATTR_STA_LISTEN_INTERVAL
] = { .type
= NLA_U16
},
82 [NL80211_ATTR_STA_SUPPORTED_RATES
] = { .type
= NLA_BINARY
,
83 .len
= NL80211_MAX_SUPP_RATES
},
84 [NL80211_ATTR_STA_PLINK_ACTION
] = { .type
= NLA_U8
},
85 [NL80211_ATTR_STA_VLAN
] = { .type
= NLA_U32
},
86 [NL80211_ATTR_MNTR_FLAGS
] = { .type
= NLA_NESTED
},
87 [NL80211_ATTR_MESH_ID
] = { .type
= NLA_BINARY
,
88 .len
= IEEE80211_MAX_MESH_ID_LEN
},
89 [NL80211_ATTR_MPATH_NEXT_HOP
] = { .type
= NLA_U32
},
92 /* message building helper */
93 static inline void *nl80211hdr_put(struct sk_buff
*skb
, u32 pid
, u32 seq
,
96 /* since there is no private header just add the generic one */
97 return genlmsg_put(skb
, pid
, seq
, &nl80211_fam
, flags
, cmd
);
100 /* netlink command implementations */
102 static int nl80211_send_wiphy(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
103 struct cfg80211_registered_device
*dev
)
106 struct nlattr
*nl_bands
, *nl_band
;
107 struct nlattr
*nl_freqs
, *nl_freq
;
108 struct nlattr
*nl_rates
, *nl_rate
;
109 enum ieee80211_band band
;
110 struct ieee80211_channel
*chan
;
111 struct ieee80211_rate
*rate
;
114 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_WIPHY
);
118 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY
, dev
->idx
);
119 NLA_PUT_STRING(msg
, NL80211_ATTR_WIPHY_NAME
, wiphy_name(&dev
->wiphy
));
121 nl_bands
= nla_nest_start(msg
, NL80211_ATTR_WIPHY_BANDS
);
123 goto nla_put_failure
;
125 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
126 if (!dev
->wiphy
.bands
[band
])
129 nl_band
= nla_nest_start(msg
, band
);
131 goto nla_put_failure
;
133 /* add frequencies */
134 nl_freqs
= nla_nest_start(msg
, NL80211_BAND_ATTR_FREQS
);
136 goto nla_put_failure
;
138 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_channels
; i
++) {
139 nl_freq
= nla_nest_start(msg
, i
);
141 goto nla_put_failure
;
143 chan
= &dev
->wiphy
.bands
[band
]->channels
[i
];
144 NLA_PUT_U32(msg
, NL80211_FREQUENCY_ATTR_FREQ
,
147 if (chan
->flags
& IEEE80211_CHAN_DISABLED
)
148 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_DISABLED
);
149 if (chan
->flags
& IEEE80211_CHAN_PASSIVE_SCAN
)
150 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
);
151 if (chan
->flags
& IEEE80211_CHAN_NO_IBSS
)
152 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_NO_IBSS
);
153 if (chan
->flags
& IEEE80211_CHAN_RADAR
)
154 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_RADAR
);
156 nla_nest_end(msg
, nl_freq
);
159 nla_nest_end(msg
, nl_freqs
);
162 nl_rates
= nla_nest_start(msg
, NL80211_BAND_ATTR_RATES
);
164 goto nla_put_failure
;
166 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_bitrates
; i
++) {
167 nl_rate
= nla_nest_start(msg
, i
);
169 goto nla_put_failure
;
171 rate
= &dev
->wiphy
.bands
[band
]->bitrates
[i
];
172 NLA_PUT_U32(msg
, NL80211_BITRATE_ATTR_RATE
,
174 if (rate
->flags
& IEEE80211_RATE_SHORT_PREAMBLE
)
176 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
);
178 nla_nest_end(msg
, nl_rate
);
181 nla_nest_end(msg
, nl_rates
);
183 nla_nest_end(msg
, nl_band
);
185 nla_nest_end(msg
, nl_bands
);
187 return genlmsg_end(msg
, hdr
);
190 genlmsg_cancel(msg
, hdr
);
194 static int nl80211_dump_wiphy(struct sk_buff
*skb
, struct netlink_callback
*cb
)
197 int start
= cb
->args
[0];
198 struct cfg80211_registered_device
*dev
;
200 mutex_lock(&cfg80211_drv_mutex
);
201 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
204 if (nl80211_send_wiphy(skb
, NETLINK_CB(cb
->skb
).pid
,
205 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
211 mutex_unlock(&cfg80211_drv_mutex
);
218 static int nl80211_get_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
221 struct cfg80211_registered_device
*dev
;
223 dev
= cfg80211_get_dev_from_info(info
);
227 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
231 if (nl80211_send_wiphy(msg
, info
->snd_pid
, info
->snd_seq
, 0, dev
) < 0)
234 cfg80211_put_dev(dev
);
236 return genlmsg_unicast(msg
, info
->snd_pid
);
241 cfg80211_put_dev(dev
);
245 static int nl80211_set_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
247 struct cfg80211_registered_device
*rdev
;
250 if (!info
->attrs
[NL80211_ATTR_WIPHY_NAME
])
253 rdev
= cfg80211_get_dev_from_info(info
);
255 return PTR_ERR(rdev
);
257 result
= cfg80211_dev_rename(rdev
, nla_data(info
->attrs
[NL80211_ATTR_WIPHY_NAME
]));
259 cfg80211_put_dev(rdev
);
264 static int nl80211_send_iface(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
265 struct net_device
*dev
)
269 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_INTERFACE
);
273 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
274 NLA_PUT_STRING(msg
, NL80211_ATTR_IFNAME
, dev
->name
);
275 /* TODO: interface type */
276 return genlmsg_end(msg
, hdr
);
279 genlmsg_cancel(msg
, hdr
);
283 static int nl80211_dump_interface(struct sk_buff
*skb
, struct netlink_callback
*cb
)
287 int wp_start
= cb
->args
[0];
288 int if_start
= cb
->args
[1];
289 struct cfg80211_registered_device
*dev
;
290 struct wireless_dev
*wdev
;
292 mutex_lock(&cfg80211_drv_mutex
);
293 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
294 if (++wp_idx
< wp_start
)
298 mutex_lock(&dev
->devlist_mtx
);
299 list_for_each_entry(wdev
, &dev
->netdev_list
, list
) {
300 if (++if_idx
< if_start
)
302 if (nl80211_send_iface(skb
, NETLINK_CB(cb
->skb
).pid
,
303 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
307 mutex_unlock(&dev
->devlist_mtx
);
309 mutex_unlock(&cfg80211_drv_mutex
);
311 cb
->args
[0] = wp_idx
;
312 cb
->args
[1] = if_idx
;
317 static int nl80211_get_interface(struct sk_buff
*skb
, struct genl_info
*info
)
320 struct cfg80211_registered_device
*dev
;
321 struct net_device
*netdev
;
324 err
= get_drv_dev_by_info_ifindex(info
, &dev
, &netdev
);
328 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
332 if (nl80211_send_iface(msg
, info
->snd_pid
, info
->snd_seq
, 0, netdev
) < 0)
336 cfg80211_put_dev(dev
);
338 return genlmsg_unicast(msg
, info
->snd_pid
);
344 cfg80211_put_dev(dev
);
348 static const struct nla_policy mntr_flags_policy
[NL80211_MNTR_FLAG_MAX
+ 1] = {
349 [NL80211_MNTR_FLAG_FCSFAIL
] = { .type
= NLA_FLAG
},
350 [NL80211_MNTR_FLAG_PLCPFAIL
] = { .type
= NLA_FLAG
},
351 [NL80211_MNTR_FLAG_CONTROL
] = { .type
= NLA_FLAG
},
352 [NL80211_MNTR_FLAG_OTHER_BSS
] = { .type
= NLA_FLAG
},
353 [NL80211_MNTR_FLAG_COOK_FRAMES
] = { .type
= NLA_FLAG
},
356 static int parse_monitor_flags(struct nlattr
*nla
, u32
*mntrflags
)
358 struct nlattr
*flags
[NL80211_MNTR_FLAG_MAX
+ 1];
366 if (nla_parse_nested(flags
, NL80211_MNTR_FLAG_MAX
,
367 nla
, mntr_flags_policy
))
370 for (flag
= 1; flag
<= NL80211_MNTR_FLAG_MAX
; flag
++)
372 *mntrflags
|= (1<<flag
);
377 static int nl80211_set_interface(struct sk_buff
*skb
, struct genl_info
*info
)
379 struct cfg80211_registered_device
*drv
;
380 struct vif_params params
;
382 enum nl80211_iftype type
;
383 struct net_device
*dev
;
386 memset(¶ms
, 0, sizeof(params
));
388 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
389 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
390 if (type
> NL80211_IFTYPE_MAX
)
395 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
398 ifindex
= dev
->ifindex
;
401 if (!drv
->ops
->change_virtual_intf
) {
406 if (type
== NL80211_IFTYPE_MESH_POINT
&&
407 info
->attrs
[NL80211_ATTR_MESH_ID
]) {
408 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
409 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
413 err
= parse_monitor_flags(type
== NL80211_IFTYPE_MONITOR
?
414 info
->attrs
[NL80211_ATTR_MNTR_FLAGS
] : NULL
,
416 err
= drv
->ops
->change_virtual_intf(&drv
->wiphy
, ifindex
,
417 type
, err
? NULL
: &flags
, ¶ms
);
421 cfg80211_put_dev(drv
);
425 static int nl80211_new_interface(struct sk_buff
*skb
, struct genl_info
*info
)
427 struct cfg80211_registered_device
*drv
;
428 struct vif_params params
;
430 enum nl80211_iftype type
= NL80211_IFTYPE_UNSPECIFIED
;
433 memset(¶ms
, 0, sizeof(params
));
435 if (!info
->attrs
[NL80211_ATTR_IFNAME
])
438 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
439 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
440 if (type
> NL80211_IFTYPE_MAX
)
444 drv
= cfg80211_get_dev_from_info(info
);
448 if (!drv
->ops
->add_virtual_intf
) {
453 if (type
== NL80211_IFTYPE_MESH_POINT
&&
454 info
->attrs
[NL80211_ATTR_MESH_ID
]) {
455 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
456 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
460 err
= parse_monitor_flags(type
== NL80211_IFTYPE_MONITOR
?
461 info
->attrs
[NL80211_ATTR_MNTR_FLAGS
] : NULL
,
463 err
= drv
->ops
->add_virtual_intf(&drv
->wiphy
,
464 nla_data(info
->attrs
[NL80211_ATTR_IFNAME
]),
465 type
, err
? NULL
: &flags
, ¶ms
);
470 cfg80211_put_dev(drv
);
474 static int nl80211_del_interface(struct sk_buff
*skb
, struct genl_info
*info
)
476 struct cfg80211_registered_device
*drv
;
478 struct net_device
*dev
;
480 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
483 ifindex
= dev
->ifindex
;
486 if (!drv
->ops
->del_virtual_intf
) {
492 err
= drv
->ops
->del_virtual_intf(&drv
->wiphy
, ifindex
);
496 cfg80211_put_dev(drv
);
500 struct get_key_cookie
{
505 static void get_key_callback(void *c
, struct key_params
*params
)
507 struct get_key_cookie
*cookie
= c
;
510 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_DATA
,
511 params
->key_len
, params
->key
);
514 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_SEQ
,
515 params
->seq_len
, params
->seq
);
518 NLA_PUT_U32(cookie
->msg
, NL80211_ATTR_KEY_CIPHER
,
526 static int nl80211_get_key(struct sk_buff
*skb
, struct genl_info
*info
)
528 struct cfg80211_registered_device
*drv
;
530 struct net_device
*dev
;
533 struct get_key_cookie cookie
= {
539 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
540 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
545 if (info
->attrs
[NL80211_ATTR_MAC
])
546 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
548 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
552 if (!drv
->ops
->get_key
) {
557 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
563 hdr
= nl80211hdr_put(msg
, info
->snd_pid
, info
->snd_seq
, 0,
564 NL80211_CMD_NEW_KEY
);
573 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
574 NLA_PUT_U8(msg
, NL80211_ATTR_KEY_IDX
, key_idx
);
576 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
579 err
= drv
->ops
->get_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
,
580 &cookie
, get_key_callback
);
587 goto nla_put_failure
;
589 genlmsg_end(msg
, hdr
);
590 err
= genlmsg_unicast(msg
, info
->snd_pid
);
597 cfg80211_put_dev(drv
);
602 static int nl80211_set_key(struct sk_buff
*skb
, struct genl_info
*info
)
604 struct cfg80211_registered_device
*drv
;
606 struct net_device
*dev
;
609 if (!info
->attrs
[NL80211_ATTR_KEY_IDX
])
612 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
617 /* currently only support setting default key */
618 if (!info
->attrs
[NL80211_ATTR_KEY_DEFAULT
])
621 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
625 if (!drv
->ops
->set_default_key
) {
631 err
= drv
->ops
->set_default_key(&drv
->wiphy
, dev
, key_idx
);
635 cfg80211_put_dev(drv
);
640 static int nl80211_new_key(struct sk_buff
*skb
, struct genl_info
*info
)
642 struct cfg80211_registered_device
*drv
;
644 struct net_device
*dev
;
645 struct key_params params
;
649 memset(¶ms
, 0, sizeof(params
));
651 if (!info
->attrs
[NL80211_ATTR_KEY_CIPHER
])
654 if (info
->attrs
[NL80211_ATTR_KEY_DATA
]) {
655 params
.key
= nla_data(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
656 params
.key_len
= nla_len(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
659 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
660 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
662 params
.cipher
= nla_get_u32(info
->attrs
[NL80211_ATTR_KEY_CIPHER
]);
664 if (info
->attrs
[NL80211_ATTR_MAC
])
665 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
671 * Disallow pairwise keys with non-zero index unless it's WEP
672 * (because current deployments use pairwise WEP keys with
673 * non-zero indizes but 802.11i clearly specifies to use zero)
675 if (mac_addr
&& key_idx
&&
676 params
.cipher
!= WLAN_CIPHER_SUITE_WEP40
&&
677 params
.cipher
!= WLAN_CIPHER_SUITE_WEP104
)
680 /* TODO: add definitions for the lengths to linux/ieee80211.h */
681 switch (params
.cipher
) {
682 case WLAN_CIPHER_SUITE_WEP40
:
683 if (params
.key_len
!= 5)
686 case WLAN_CIPHER_SUITE_TKIP
:
687 if (params
.key_len
!= 32)
690 case WLAN_CIPHER_SUITE_CCMP
:
691 if (params
.key_len
!= 16)
694 case WLAN_CIPHER_SUITE_WEP104
:
695 if (params
.key_len
!= 13)
702 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
706 if (!drv
->ops
->add_key
) {
712 err
= drv
->ops
->add_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
, ¶ms
);
716 cfg80211_put_dev(drv
);
721 static int nl80211_del_key(struct sk_buff
*skb
, struct genl_info
*info
)
723 struct cfg80211_registered_device
*drv
;
725 struct net_device
*dev
;
729 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
730 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
735 if (info
->attrs
[NL80211_ATTR_MAC
])
736 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
738 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
742 if (!drv
->ops
->del_key
) {
748 err
= drv
->ops
->del_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
);
752 cfg80211_put_dev(drv
);
757 static int nl80211_addset_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
759 int (*call
)(struct wiphy
*wiphy
, struct net_device
*dev
,
760 struct beacon_parameters
*info
);
761 struct cfg80211_registered_device
*drv
;
763 struct net_device
*dev
;
764 struct beacon_parameters params
;
767 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
771 switch (info
->genlhdr
->cmd
) {
772 case NL80211_CMD_NEW_BEACON
:
773 /* these are required for NEW_BEACON */
774 if (!info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
] ||
775 !info
->attrs
[NL80211_ATTR_DTIM_PERIOD
] ||
776 !info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
781 call
= drv
->ops
->add_beacon
;
783 case NL80211_CMD_SET_BEACON
:
784 call
= drv
->ops
->set_beacon
;
797 memset(¶ms
, 0, sizeof(params
));
799 if (info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]) {
801 nla_get_u32(info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]);
805 if (info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]) {
807 nla_get_u32(info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]);
811 if (info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
812 params
.head
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
814 nla_len(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
818 if (info
->attrs
[NL80211_ATTR_BEACON_TAIL
]) {
819 params
.tail
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
821 nla_len(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
831 err
= call(&drv
->wiphy
, dev
, ¶ms
);
835 cfg80211_put_dev(drv
);
840 static int nl80211_del_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
842 struct cfg80211_registered_device
*drv
;
844 struct net_device
*dev
;
846 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
850 if (!drv
->ops
->del_beacon
) {
856 err
= drv
->ops
->del_beacon(&drv
->wiphy
, dev
);
860 cfg80211_put_dev(drv
);
865 static const struct nla_policy sta_flags_policy
[NL80211_STA_FLAG_MAX
+ 1] = {
866 [NL80211_STA_FLAG_AUTHORIZED
] = { .type
= NLA_FLAG
},
867 [NL80211_STA_FLAG_SHORT_PREAMBLE
] = { .type
= NLA_FLAG
},
868 [NL80211_STA_FLAG_WME
] = { .type
= NLA_FLAG
},
871 static int parse_station_flags(struct nlattr
*nla
, u32
*staflags
)
873 struct nlattr
*flags
[NL80211_STA_FLAG_MAX
+ 1];
881 if (nla_parse_nested(flags
, NL80211_STA_FLAG_MAX
,
882 nla
, sta_flags_policy
))
885 *staflags
= STATION_FLAG_CHANGED
;
887 for (flag
= 1; flag
<= NL80211_STA_FLAG_MAX
; flag
++)
889 *staflags
|= (1<<flag
);
894 static int nl80211_send_station(struct sk_buff
*msg
, u32 pid
, u32 seq
,
895 int flags
, struct net_device
*dev
,
896 u8
*mac_addr
, struct station_info
*sinfo
)
899 struct nlattr
*sinfoattr
;
901 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
905 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
906 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
908 sinfoattr
= nla_nest_start(msg
, NL80211_ATTR_STA_INFO
);
910 goto nla_put_failure
;
911 if (sinfo
->filled
& STATION_INFO_INACTIVE_TIME
)
912 NLA_PUT_U32(msg
, NL80211_STA_INFO_INACTIVE_TIME
,
913 sinfo
->inactive_time
);
914 if (sinfo
->filled
& STATION_INFO_RX_BYTES
)
915 NLA_PUT_U32(msg
, NL80211_STA_INFO_RX_BYTES
,
917 if (sinfo
->filled
& STATION_INFO_TX_BYTES
)
918 NLA_PUT_U32(msg
, NL80211_STA_INFO_TX_BYTES
,
920 if (sinfo
->filled
& STATION_INFO_LLID
)
921 NLA_PUT_U16(msg
, NL80211_STA_INFO_LLID
,
923 if (sinfo
->filled
& STATION_INFO_PLID
)
924 NLA_PUT_U16(msg
, NL80211_STA_INFO_PLID
,
926 if (sinfo
->filled
& STATION_INFO_PLINK_STATE
)
927 NLA_PUT_U8(msg
, NL80211_STA_INFO_PLINK_STATE
,
930 nla_nest_end(msg
, sinfoattr
);
932 return genlmsg_end(msg
, hdr
);
935 genlmsg_cancel(msg
, hdr
);
939 static int nl80211_dump_station(struct sk_buff
*skb
,
940 struct netlink_callback
*cb
)
944 int sta_idx
= cb
->args
[2];
945 int wp_start
= cb
->args
[0];
946 int if_start
= cb
->args
[1];
947 struct station_info sinfo
;
948 struct cfg80211_registered_device
*dev
;
949 struct wireless_dev
*wdev
;
950 u8 mac_addr
[ETH_ALEN
];
954 /* TODO: filter by device */
955 mutex_lock(&cfg80211_drv_mutex
);
956 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
959 if (++wp_idx
< wp_start
)
963 mutex_lock(&dev
->devlist_mtx
);
964 list_for_each_entry(wdev
, &dev
->netdev_list
, list
) {
967 if (++if_idx
< if_start
)
969 if (!dev
->ops
->dump_station
)
974 err
= dev
->ops
->dump_station(&dev
->wiphy
,
975 wdev
->netdev
, sta_idx
, mac_addr
,
982 if (nl80211_send_station(skb
,
983 NETLINK_CB(cb
->skb
).pid
,
984 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
985 wdev
->netdev
, mac_addr
,
992 mutex_unlock(&dev
->devlist_mtx
);
994 mutex_unlock(&cfg80211_drv_mutex
);
996 cb
->args
[0] = wp_idx
;
997 cb
->args
[1] = if_idx
;
998 cb
->args
[2] = sta_idx
;
1003 static int nl80211_get_station(struct sk_buff
*skb
, struct genl_info
*info
)
1005 struct cfg80211_registered_device
*drv
;
1007 struct net_device
*dev
;
1008 struct station_info sinfo
;
1009 struct sk_buff
*msg
;
1010 u8
*mac_addr
= NULL
;
1012 memset(&sinfo
, 0, sizeof(sinfo
));
1014 if (!info
->attrs
[NL80211_ATTR_MAC
])
1017 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1019 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1023 if (!drv
->ops
->get_station
) {
1029 err
= drv
->ops
->get_station(&drv
->wiphy
, dev
, mac_addr
, &sinfo
);
1035 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1039 if (nl80211_send_station(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1040 dev
, mac_addr
, &sinfo
) < 0)
1043 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1050 cfg80211_put_dev(drv
);
1056 * Get vlan interface making sure it is on the right wiphy.
1058 static int get_vlan(struct nlattr
*vlanattr
,
1059 struct cfg80211_registered_device
*rdev
,
1060 struct net_device
**vlan
)
1065 *vlan
= dev_get_by_index(&init_net
, nla_get_u32(vlanattr
));
1068 if (!(*vlan
)->ieee80211_ptr
)
1070 if ((*vlan
)->ieee80211_ptr
->wiphy
!= &rdev
->wiphy
)
1076 static int nl80211_set_station(struct sk_buff
*skb
, struct genl_info
*info
)
1078 struct cfg80211_registered_device
*drv
;
1080 struct net_device
*dev
;
1081 struct station_parameters params
;
1082 u8
*mac_addr
= NULL
;
1084 memset(¶ms
, 0, sizeof(params
));
1086 params
.listen_interval
= -1;
1088 if (info
->attrs
[NL80211_ATTR_STA_AID
])
1091 if (!info
->attrs
[NL80211_ATTR_MAC
])
1094 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1096 if (info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]) {
1097 params
.supported_rates
=
1098 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1099 params
.supported_rates_len
=
1100 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1103 if (info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1104 params
.listen_interval
=
1105 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1107 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1108 ¶ms
.station_flags
))
1111 if (info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
])
1112 params
.plink_action
=
1113 nla_get_u8(info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
]);
1115 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1119 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1123 if (!drv
->ops
->change_station
) {
1129 err
= drv
->ops
->change_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1134 dev_put(params
.vlan
);
1135 cfg80211_put_dev(drv
);
1140 static int nl80211_new_station(struct sk_buff
*skb
, struct genl_info
*info
)
1142 struct cfg80211_registered_device
*drv
;
1144 struct net_device
*dev
;
1145 struct station_parameters params
;
1146 u8
*mac_addr
= NULL
;
1148 memset(¶ms
, 0, sizeof(params
));
1150 if (!info
->attrs
[NL80211_ATTR_MAC
])
1153 if (!info
->attrs
[NL80211_ATTR_STA_AID
])
1156 if (!info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1159 if (!info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
])
1162 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1163 params
.supported_rates
=
1164 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1165 params
.supported_rates_len
=
1166 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1167 params
.listen_interval
=
1168 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1169 params
.aid
= nla_get_u16(info
->attrs
[NL80211_ATTR_STA_AID
]);
1171 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1172 ¶ms
.station_flags
))
1175 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1179 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1183 if (!drv
->ops
->add_station
) {
1189 err
= drv
->ops
->add_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1194 dev_put(params
.vlan
);
1195 cfg80211_put_dev(drv
);
1200 static int nl80211_del_station(struct sk_buff
*skb
, struct genl_info
*info
)
1202 struct cfg80211_registered_device
*drv
;
1204 struct net_device
*dev
;
1205 u8
*mac_addr
= NULL
;
1207 if (info
->attrs
[NL80211_ATTR_MAC
])
1208 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1210 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1214 if (!drv
->ops
->del_station
) {
1220 err
= drv
->ops
->del_station(&drv
->wiphy
, dev
, mac_addr
);
1224 cfg80211_put_dev(drv
);
1229 static int nl80211_send_mpath(struct sk_buff
*msg
, u32 pid
, u32 seq
,
1230 int flags
, struct net_device
*dev
,
1231 u8
*dst
, u8
*next_hop
,
1232 struct mpath_info
*pinfo
)
1235 struct nlattr
*pinfoattr
;
1237 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
1241 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
1242 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, dst
);
1243 NLA_PUT(msg
, NL80211_ATTR_MPATH_NEXT_HOP
, ETH_ALEN
, next_hop
);
1245 pinfoattr
= nla_nest_start(msg
, NL80211_ATTR_MPATH_INFO
);
1247 goto nla_put_failure
;
1248 if (pinfo
->filled
& MPATH_INFO_FRAME_QLEN
)
1249 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_FRAME_QLEN
,
1251 if (pinfo
->filled
& MPATH_INFO_DSN
)
1252 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DSN
,
1254 if (pinfo
->filled
& MPATH_INFO_METRIC
)
1255 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_METRIC
,
1257 if (pinfo
->filled
& MPATH_INFO_EXPTIME
)
1258 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_EXPTIME
,
1260 if (pinfo
->filled
& MPATH_INFO_FLAGS
)
1261 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_FLAGS
,
1263 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_TIMEOUT
)
1264 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT
,
1265 pinfo
->discovery_timeout
);
1266 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_RETRIES
)
1267 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_DISCOVERY_RETRIES
,
1268 pinfo
->discovery_retries
);
1270 nla_nest_end(msg
, pinfoattr
);
1272 return genlmsg_end(msg
, hdr
);
1275 genlmsg_cancel(msg
, hdr
);
1279 static int nl80211_dump_mpath(struct sk_buff
*skb
,
1280 struct netlink_callback
*cb
)
1284 int sta_idx
= cb
->args
[2];
1285 int wp_start
= cb
->args
[0];
1286 int if_start
= cb
->args
[1];
1287 struct mpath_info pinfo
;
1288 struct cfg80211_registered_device
*dev
;
1289 struct wireless_dev
*wdev
;
1291 u8 next_hop
[ETH_ALEN
];
1295 /* TODO: filter by device */
1296 mutex_lock(&cfg80211_drv_mutex
);
1297 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
1300 if (++wp_idx
< wp_start
)
1304 mutex_lock(&dev
->devlist_mtx
);
1305 list_for_each_entry(wdev
, &dev
->netdev_list
, list
) {
1308 if (++if_idx
< if_start
)
1310 if (!dev
->ops
->dump_mpath
)
1313 for (;; ++sta_idx
) {
1315 err
= dev
->ops
->dump_mpath(&dev
->wiphy
,
1316 wdev
->netdev
, sta_idx
, dst
,
1323 if (nl80211_send_mpath(skb
,
1324 NETLINK_CB(cb
->skb
).pid
,
1325 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
1326 wdev
->netdev
, dst
, next_hop
,
1333 mutex_unlock(&dev
->devlist_mtx
);
1335 mutex_unlock(&cfg80211_drv_mutex
);
1337 cb
->args
[0] = wp_idx
;
1338 cb
->args
[1] = if_idx
;
1339 cb
->args
[2] = sta_idx
;
1344 static int nl80211_get_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1346 struct cfg80211_registered_device
*drv
;
1348 struct net_device
*dev
;
1349 struct mpath_info pinfo
;
1350 struct sk_buff
*msg
;
1352 u8 next_hop
[ETH_ALEN
];
1354 memset(&pinfo
, 0, sizeof(pinfo
));
1356 if (!info
->attrs
[NL80211_ATTR_MAC
])
1359 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1361 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1365 if (!drv
->ops
->get_mpath
) {
1371 err
= drv
->ops
->get_mpath(&drv
->wiphy
, dev
, dst
, next_hop
, &pinfo
);
1377 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1381 if (nl80211_send_mpath(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1382 dev
, dst
, next_hop
, &pinfo
) < 0)
1385 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1392 cfg80211_put_dev(drv
);
1397 static int nl80211_set_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1399 struct cfg80211_registered_device
*drv
;
1401 struct net_device
*dev
;
1403 u8
*next_hop
= NULL
;
1405 if (!info
->attrs
[NL80211_ATTR_MAC
])
1408 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1411 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1412 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1414 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1418 if (!drv
->ops
->change_mpath
) {
1424 err
= drv
->ops
->change_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1428 cfg80211_put_dev(drv
);
1432 static int nl80211_new_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1434 struct cfg80211_registered_device
*drv
;
1436 struct net_device
*dev
;
1438 u8
*next_hop
= NULL
;
1440 if (!info
->attrs
[NL80211_ATTR_MAC
])
1443 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1446 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1447 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1449 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1453 if (!drv
->ops
->add_mpath
) {
1459 err
= drv
->ops
->add_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1463 cfg80211_put_dev(drv
);
1468 static int nl80211_del_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1470 struct cfg80211_registered_device
*drv
;
1472 struct net_device
*dev
;
1475 if (info
->attrs
[NL80211_ATTR_MAC
])
1476 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1478 err
= get_drv_dev_by_info_ifindex(info
, &drv
, &dev
);
1482 if (!drv
->ops
->del_mpath
) {
1488 err
= drv
->ops
->del_mpath(&drv
->wiphy
, dev
, dst
);
1492 cfg80211_put_dev(drv
);
1497 static struct genl_ops nl80211_ops
[] = {
1499 .cmd
= NL80211_CMD_GET_WIPHY
,
1500 .doit
= nl80211_get_wiphy
,
1501 .dumpit
= nl80211_dump_wiphy
,
1502 .policy
= nl80211_policy
,
1503 /* can be retrieved by unprivileged users */
1506 .cmd
= NL80211_CMD_SET_WIPHY
,
1507 .doit
= nl80211_set_wiphy
,
1508 .policy
= nl80211_policy
,
1509 .flags
= GENL_ADMIN_PERM
,
1512 .cmd
= NL80211_CMD_GET_INTERFACE
,
1513 .doit
= nl80211_get_interface
,
1514 .dumpit
= nl80211_dump_interface
,
1515 .policy
= nl80211_policy
,
1516 /* can be retrieved by unprivileged users */
1519 .cmd
= NL80211_CMD_SET_INTERFACE
,
1520 .doit
= nl80211_set_interface
,
1521 .policy
= nl80211_policy
,
1522 .flags
= GENL_ADMIN_PERM
,
1525 .cmd
= NL80211_CMD_NEW_INTERFACE
,
1526 .doit
= nl80211_new_interface
,
1527 .policy
= nl80211_policy
,
1528 .flags
= GENL_ADMIN_PERM
,
1531 .cmd
= NL80211_CMD_DEL_INTERFACE
,
1532 .doit
= nl80211_del_interface
,
1533 .policy
= nl80211_policy
,
1534 .flags
= GENL_ADMIN_PERM
,
1537 .cmd
= NL80211_CMD_GET_KEY
,
1538 .doit
= nl80211_get_key
,
1539 .policy
= nl80211_policy
,
1540 .flags
= GENL_ADMIN_PERM
,
1543 .cmd
= NL80211_CMD_SET_KEY
,
1544 .doit
= nl80211_set_key
,
1545 .policy
= nl80211_policy
,
1546 .flags
= GENL_ADMIN_PERM
,
1549 .cmd
= NL80211_CMD_NEW_KEY
,
1550 .doit
= nl80211_new_key
,
1551 .policy
= nl80211_policy
,
1552 .flags
= GENL_ADMIN_PERM
,
1555 .cmd
= NL80211_CMD_DEL_KEY
,
1556 .doit
= nl80211_del_key
,
1557 .policy
= nl80211_policy
,
1558 .flags
= GENL_ADMIN_PERM
,
1561 .cmd
= NL80211_CMD_SET_BEACON
,
1562 .policy
= nl80211_policy
,
1563 .flags
= GENL_ADMIN_PERM
,
1564 .doit
= nl80211_addset_beacon
,
1567 .cmd
= NL80211_CMD_NEW_BEACON
,
1568 .policy
= nl80211_policy
,
1569 .flags
= GENL_ADMIN_PERM
,
1570 .doit
= nl80211_addset_beacon
,
1573 .cmd
= NL80211_CMD_DEL_BEACON
,
1574 .policy
= nl80211_policy
,
1575 .flags
= GENL_ADMIN_PERM
,
1576 .doit
= nl80211_del_beacon
,
1579 .cmd
= NL80211_CMD_GET_STATION
,
1580 .doit
= nl80211_get_station
,
1581 .dumpit
= nl80211_dump_station
,
1582 .policy
= nl80211_policy
,
1583 .flags
= GENL_ADMIN_PERM
,
1586 .cmd
= NL80211_CMD_SET_STATION
,
1587 .doit
= nl80211_set_station
,
1588 .policy
= nl80211_policy
,
1589 .flags
= GENL_ADMIN_PERM
,
1592 .cmd
= NL80211_CMD_NEW_STATION
,
1593 .doit
= nl80211_new_station
,
1594 .policy
= nl80211_policy
,
1595 .flags
= GENL_ADMIN_PERM
,
1598 .cmd
= NL80211_CMD_DEL_STATION
,
1599 .doit
= nl80211_del_station
,
1600 .policy
= nl80211_policy
,
1601 .flags
= GENL_ADMIN_PERM
,
1604 .cmd
= NL80211_CMD_GET_MPATH
,
1605 .doit
= nl80211_get_mpath
,
1606 .dumpit
= nl80211_dump_mpath
,
1607 .policy
= nl80211_policy
,
1608 .flags
= GENL_ADMIN_PERM
,
1611 .cmd
= NL80211_CMD_SET_MPATH
,
1612 .doit
= nl80211_set_mpath
,
1613 .policy
= nl80211_policy
,
1614 .flags
= GENL_ADMIN_PERM
,
1617 .cmd
= NL80211_CMD_NEW_MPATH
,
1618 .doit
= nl80211_new_mpath
,
1619 .policy
= nl80211_policy
,
1620 .flags
= GENL_ADMIN_PERM
,
1623 .cmd
= NL80211_CMD_DEL_MPATH
,
1624 .doit
= nl80211_del_mpath
,
1625 .policy
= nl80211_policy
,
1626 .flags
= GENL_ADMIN_PERM
,
1630 /* multicast groups */
1631 static struct genl_multicast_group nl80211_config_mcgrp
= {
1635 /* notification functions */
1637 void nl80211_notify_dev_rename(struct cfg80211_registered_device
*rdev
)
1639 struct sk_buff
*msg
;
1641 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1645 if (nl80211_send_wiphy(msg
, 0, 0, 0, rdev
) < 0) {
1650 genlmsg_multicast(msg
, 0, nl80211_config_mcgrp
.id
, GFP_KERNEL
);
1653 /* initialisation/exit functions */
1655 int nl80211_init(void)
1659 err
= genl_register_family(&nl80211_fam
);
1663 for (i
= 0; i
< ARRAY_SIZE(nl80211_ops
); i
++) {
1664 err
= genl_register_ops(&nl80211_fam
, &nl80211_ops
[i
]);
1669 err
= genl_register_mc_group(&nl80211_fam
, &nl80211_config_mcgrp
);
1675 genl_unregister_family(&nl80211_fam
);
1679 void nl80211_exit(void)
1681 genl_unregister_family(&nl80211_fam
);