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>
23 /* the netlink family */
24 static struct genl_family nl80211_fam = {
25 .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
26 .name = "nl80211", /* have users key off the name instead */
27 .hdrsize = 0, /* no private header */
28 .version = 1, /* no particular meaning now */
29 .maxattr = NL80211_ATTR_MAX,
32 /* internal helper: get drv and dev */
33 static int get_drv_dev_by_info_ifindex(struct nlattr **attrs,
34 struct cfg80211_registered_device **drv,
35 struct net_device **dev)
39 if (!attrs[NL80211_ATTR_IFINDEX])
42 ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
43 *dev = dev_get_by_index(&init_net, ifindex);
47 *drv = cfg80211_get_dev_from_ifindex(ifindex);
56 /* policy for the attributes */
57 static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
58 [NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
59 [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
60 .len = BUS_ID_SIZE-1 },
62 [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
63 [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
64 [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
66 [NL80211_ATTR_MAC] = { .type = NLA_BINARY, .len = ETH_ALEN },
68 [NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
69 .len = WLAN_MAX_KEY_LEN },
70 [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
71 [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
72 [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG },
74 [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 },
75 [NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
76 [NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY,
77 .len = IEEE80211_MAX_DATA_LEN },
78 [NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
79 .len = IEEE80211_MAX_DATA_LEN },
80 [NL80211_ATTR_STA_AID] = { .type = NLA_U16 },
81 [NL80211_ATTR_STA_FLAGS] = { .type = NLA_NESTED },
82 [NL80211_ATTR_STA_LISTEN_INTERVAL] = { .type = NLA_U16 },
83 [NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY,
84 .len = NL80211_MAX_SUPP_RATES },
85 [NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 },
86 [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 },
87 [NL80211_ATTR_MNTR_FLAGS] = { .type = NLA_NESTED },
88 [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
89 .len = IEEE80211_MAX_MESH_ID_LEN },
90 [NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 },
92 [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 },
93 [NL80211_ATTR_REG_RULES] = { .type = NLA_NESTED },
95 [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 },
96 [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 },
97 [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 },
99 [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY,
100 .len = NL80211_HT_CAPABILITY_LEN },
103 /* message building helper */
104 static inline void *nl80211hdr_put(struct sk_buff *skb, u32 pid, u32 seq,
107 /* since there is no private header just add the generic one */
108 return genlmsg_put(skb, pid, seq, &nl80211_fam, flags, cmd);
111 /* netlink command implementations */
113 static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
114 struct cfg80211_registered_device *dev)
117 struct nlattr *nl_bands, *nl_band;
118 struct nlattr *nl_freqs, *nl_freq;
119 struct nlattr *nl_rates, *nl_rate;
120 struct nlattr *nl_modes;
121 enum ieee80211_band band;
122 struct ieee80211_channel *chan;
123 struct ieee80211_rate *rate;
125 u16 ifmodes = dev->wiphy.interface_modes;
127 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY);
131 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx);
132 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy));
134 nl_modes = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_IFTYPES);
136 goto nla_put_failure;
141 NLA_PUT_FLAG(msg, i);
146 nla_nest_end(msg, nl_modes);
148 nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS);
150 goto nla_put_failure;
152 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
153 if (!dev->wiphy.bands[band])
156 nl_band = nla_nest_start(msg, band);
158 goto nla_put_failure;
160 /* add frequencies */
161 nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS);
163 goto nla_put_failure;
165 for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) {
166 nl_freq = nla_nest_start(msg, i);
168 goto nla_put_failure;
170 chan = &dev->wiphy.bands[band]->channels[i];
171 NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_FREQ,
174 if (chan->flags & IEEE80211_CHAN_DISABLED)
175 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_DISABLED);
176 if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
177 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN);
178 if (chan->flags & IEEE80211_CHAN_NO_IBSS)
179 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_NO_IBSS);
180 if (chan->flags & IEEE80211_CHAN_RADAR)
181 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_RADAR);
183 nla_nest_end(msg, nl_freq);
186 nla_nest_end(msg, nl_freqs);
189 nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES);
191 goto nla_put_failure;
193 for (i = 0; i < dev->wiphy.bands[band]->n_bitrates; i++) {
194 nl_rate = nla_nest_start(msg, i);
196 goto nla_put_failure;
198 rate = &dev->wiphy.bands[band]->bitrates[i];
199 NLA_PUT_U32(msg, NL80211_BITRATE_ATTR_RATE,
201 if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
203 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE);
205 nla_nest_end(msg, nl_rate);
208 nla_nest_end(msg, nl_rates);
210 nla_nest_end(msg, nl_band);
212 nla_nest_end(msg, nl_bands);
214 return genlmsg_end(msg, hdr);
217 genlmsg_cancel(msg, hdr);
221 static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
224 int start = cb->args[0];
225 struct cfg80211_registered_device *dev;
227 mutex_lock(&cfg80211_drv_mutex);
228 list_for_each_entry(dev, &cfg80211_drv_list, list) {
231 if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid,
232 cb->nlh->nlmsg_seq, NLM_F_MULTI,
238 mutex_unlock(&cfg80211_drv_mutex);
245 static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
248 struct cfg80211_registered_device *dev;
250 dev = cfg80211_get_dev_from_info(info);
254 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
258 if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0)
261 cfg80211_put_dev(dev);
263 return genlmsg_unicast(msg, info->snd_pid);
268 cfg80211_put_dev(dev);
272 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
274 struct cfg80211_registered_device *rdev;
277 if (!info->attrs[NL80211_ATTR_WIPHY_NAME])
280 rdev = cfg80211_get_dev_from_info(info);
282 return PTR_ERR(rdev);
284 result = cfg80211_dev_rename(rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
286 cfg80211_put_dev(rdev);
291 static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags,
292 struct net_device *dev)
296 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE);
300 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
301 NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name);
302 NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype);
303 return genlmsg_end(msg, hdr);
306 genlmsg_cancel(msg, hdr);
310 static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *cb)
314 int wp_start = cb->args[0];
315 int if_start = cb->args[1];
316 struct cfg80211_registered_device *dev;
317 struct wireless_dev *wdev;
319 mutex_lock(&cfg80211_drv_mutex);
320 list_for_each_entry(dev, &cfg80211_drv_list, list) {
321 if (wp_idx < wp_start) {
327 mutex_lock(&dev->devlist_mtx);
328 list_for_each_entry(wdev, &dev->netdev_list, list) {
329 if (if_idx < if_start) {
333 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid,
334 cb->nlh->nlmsg_seq, NLM_F_MULTI,
336 mutex_unlock(&dev->devlist_mtx);
341 mutex_unlock(&dev->devlist_mtx);
346 mutex_unlock(&cfg80211_drv_mutex);
348 cb->args[0] = wp_idx;
349 cb->args[1] = if_idx;
354 static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
357 struct cfg80211_registered_device *dev;
358 struct net_device *netdev;
361 err = get_drv_dev_by_info_ifindex(info->attrs, &dev, &netdev);
365 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
369 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, netdev) < 0)
373 cfg80211_put_dev(dev);
375 return genlmsg_unicast(msg, info->snd_pid);
381 cfg80211_put_dev(dev);
385 static const struct nla_policy mntr_flags_policy[NL80211_MNTR_FLAG_MAX + 1] = {
386 [NL80211_MNTR_FLAG_FCSFAIL] = { .type = NLA_FLAG },
387 [NL80211_MNTR_FLAG_PLCPFAIL] = { .type = NLA_FLAG },
388 [NL80211_MNTR_FLAG_CONTROL] = { .type = NLA_FLAG },
389 [NL80211_MNTR_FLAG_OTHER_BSS] = { .type = NLA_FLAG },
390 [NL80211_MNTR_FLAG_COOK_FRAMES] = { .type = NLA_FLAG },
393 static int parse_monitor_flags(struct nlattr *nla, u32 *mntrflags)
395 struct nlattr *flags[NL80211_MNTR_FLAG_MAX + 1];
403 if (nla_parse_nested(flags, NL80211_MNTR_FLAG_MAX,
404 nla, mntr_flags_policy))
407 for (flag = 1; flag <= NL80211_MNTR_FLAG_MAX; flag++)
409 *mntrflags |= (1<<flag);
414 static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
416 struct cfg80211_registered_device *drv;
417 struct vif_params params;
419 enum nl80211_iftype type;
420 struct net_device *dev;
423 memset(¶ms, 0, sizeof(params));
425 if (info->attrs[NL80211_ATTR_IFTYPE]) {
426 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
427 if (type > NL80211_IFTYPE_MAX)
432 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
435 ifindex = dev->ifindex;
438 if (!drv->ops->change_virtual_intf ||
439 !(drv->wiphy.interface_modes & (1 << type))) {
444 if (type == NL80211_IFTYPE_MESH_POINT &&
445 info->attrs[NL80211_ATTR_MESH_ID]) {
446 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
447 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
451 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
452 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
454 err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
455 type, err ? NULL : &flags, ¶ms);
457 dev = __dev_get_by_index(&init_net, ifindex);
458 WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != type));
463 cfg80211_put_dev(drv);
467 static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
469 struct cfg80211_registered_device *drv;
470 struct vif_params params;
472 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
475 memset(¶ms, 0, sizeof(params));
477 if (!info->attrs[NL80211_ATTR_IFNAME])
480 if (info->attrs[NL80211_ATTR_IFTYPE]) {
481 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
482 if (type > NL80211_IFTYPE_MAX)
486 drv = cfg80211_get_dev_from_info(info);
490 if (!drv->ops->add_virtual_intf ||
491 !(drv->wiphy.interface_modes & (1 << type))) {
496 if (type == NL80211_IFTYPE_MESH_POINT &&
497 info->attrs[NL80211_ATTR_MESH_ID]) {
498 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
499 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
503 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
504 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
506 err = drv->ops->add_virtual_intf(&drv->wiphy,
507 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
508 type, err ? NULL : &flags, ¶ms);
513 cfg80211_put_dev(drv);
517 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
519 struct cfg80211_registered_device *drv;
521 struct net_device *dev;
523 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
526 ifindex = dev->ifindex;
529 if (!drv->ops->del_virtual_intf) {
535 err = drv->ops->del_virtual_intf(&drv->wiphy, ifindex);
539 cfg80211_put_dev(drv);
543 struct get_key_cookie {
548 static void get_key_callback(void *c, struct key_params *params)
550 struct get_key_cookie *cookie = c;
553 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA,
554 params->key_len, params->key);
557 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ,
558 params->seq_len, params->seq);
561 NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER,
569 static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
571 struct cfg80211_registered_device *drv;
573 struct net_device *dev;
576 struct get_key_cookie cookie = {
582 if (info->attrs[NL80211_ATTR_KEY_IDX])
583 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
588 if (info->attrs[NL80211_ATTR_MAC])
589 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
591 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
595 if (!drv->ops->get_key) {
600 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
606 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
607 NL80211_CMD_NEW_KEY);
616 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
617 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx);
619 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
622 err = drv->ops->get_key(&drv->wiphy, dev, key_idx, mac_addr,
623 &cookie, get_key_callback);
630 goto nla_put_failure;
632 genlmsg_end(msg, hdr);
633 err = genlmsg_unicast(msg, info->snd_pid);
640 cfg80211_put_dev(drv);
645 static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
647 struct cfg80211_registered_device *drv;
649 struct net_device *dev;
652 if (!info->attrs[NL80211_ATTR_KEY_IDX])
655 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
660 /* currently only support setting default key */
661 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT])
664 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
668 if (!drv->ops->set_default_key) {
674 err = drv->ops->set_default_key(&drv->wiphy, dev, key_idx);
678 cfg80211_put_dev(drv);
683 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
685 struct cfg80211_registered_device *drv;
687 struct net_device *dev;
688 struct key_params params;
692 memset(¶ms, 0, sizeof(params));
694 if (!info->attrs[NL80211_ATTR_KEY_CIPHER])
697 if (info->attrs[NL80211_ATTR_KEY_DATA]) {
698 params.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
699 params.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
702 if (info->attrs[NL80211_ATTR_KEY_IDX])
703 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
705 params.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
707 if (info->attrs[NL80211_ATTR_MAC])
708 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
714 * Disallow pairwise keys with non-zero index unless it's WEP
715 * (because current deployments use pairwise WEP keys with
716 * non-zero indizes but 802.11i clearly specifies to use zero)
718 if (mac_addr && key_idx &&
719 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
720 params.cipher != WLAN_CIPHER_SUITE_WEP104)
723 /* TODO: add definitions for the lengths to linux/ieee80211.h */
724 switch (params.cipher) {
725 case WLAN_CIPHER_SUITE_WEP40:
726 if (params.key_len != 5)
729 case WLAN_CIPHER_SUITE_TKIP:
730 if (params.key_len != 32)
733 case WLAN_CIPHER_SUITE_CCMP:
734 if (params.key_len != 16)
737 case WLAN_CIPHER_SUITE_WEP104:
738 if (params.key_len != 13)
745 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
749 if (!drv->ops->add_key) {
755 err = drv->ops->add_key(&drv->wiphy, dev, key_idx, mac_addr, ¶ms);
759 cfg80211_put_dev(drv);
764 static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
766 struct cfg80211_registered_device *drv;
768 struct net_device *dev;
772 if (info->attrs[NL80211_ATTR_KEY_IDX])
773 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
778 if (info->attrs[NL80211_ATTR_MAC])
779 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
781 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
785 if (!drv->ops->del_key) {
791 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
795 cfg80211_put_dev(drv);
800 static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
802 int (*call)(struct wiphy *wiphy, struct net_device *dev,
803 struct beacon_parameters *info);
804 struct cfg80211_registered_device *drv;
806 struct net_device *dev;
807 struct beacon_parameters params;
810 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
814 switch (info->genlhdr->cmd) {
815 case NL80211_CMD_NEW_BEACON:
816 /* these are required for NEW_BEACON */
817 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
818 !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
819 !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
824 call = drv->ops->add_beacon;
826 case NL80211_CMD_SET_BEACON:
827 call = drv->ops->set_beacon;
840 memset(¶ms, 0, sizeof(params));
842 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
844 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
848 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
850 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
854 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
855 params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
857 nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
861 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
862 params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
864 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
874 err = call(&drv->wiphy, dev, ¶ms);
878 cfg80211_put_dev(drv);
883 static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
885 struct cfg80211_registered_device *drv;
887 struct net_device *dev;
889 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
893 if (!drv->ops->del_beacon) {
899 err = drv->ops->del_beacon(&drv->wiphy, dev);
903 cfg80211_put_dev(drv);
908 static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
909 [NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
910 [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
911 [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
914 static int parse_station_flags(struct nlattr *nla, u32 *staflags)
916 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
924 if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
925 nla, sta_flags_policy))
928 *staflags = STATION_FLAG_CHANGED;
930 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
932 *staflags |= (1<<flag);
937 static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
938 int flags, struct net_device *dev,
939 u8 *mac_addr, struct station_info *sinfo)
942 struct nlattr *sinfoattr;
944 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
948 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
949 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
951 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
953 goto nla_put_failure;
954 if (sinfo->filled & STATION_INFO_INACTIVE_TIME)
955 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME,
956 sinfo->inactive_time);
957 if (sinfo->filled & STATION_INFO_RX_BYTES)
958 NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES,
960 if (sinfo->filled & STATION_INFO_TX_BYTES)
961 NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES,
963 if (sinfo->filled & STATION_INFO_LLID)
964 NLA_PUT_U16(msg, NL80211_STA_INFO_LLID,
966 if (sinfo->filled & STATION_INFO_PLID)
967 NLA_PUT_U16(msg, NL80211_STA_INFO_PLID,
969 if (sinfo->filled & STATION_INFO_PLINK_STATE)
970 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE,
973 nla_nest_end(msg, sinfoattr);
975 return genlmsg_end(msg, hdr);
978 genlmsg_cancel(msg, hdr);
982 static int nl80211_dump_station(struct sk_buff *skb,
983 struct netlink_callback *cb)
985 struct station_info sinfo;
986 struct cfg80211_registered_device *dev;
987 struct net_device *netdev;
988 u8 mac_addr[ETH_ALEN];
989 int ifidx = cb->args[0];
990 int sta_idx = cb->args[1];
994 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
995 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1000 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1003 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1008 netdev = dev_get_by_index(&init_net, ifidx);
1012 dev = cfg80211_get_dev_from_ifindex(ifidx);
1015 goto out_put_netdev;
1018 if (!dev->ops->dump_station) {
1026 err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx,
1033 if (nl80211_send_station(skb,
1034 NETLINK_CB(cb->skb).pid,
1035 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1045 cb->args[1] = sta_idx;
1050 cfg80211_put_dev(dev);
1057 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
1059 struct cfg80211_registered_device *drv;
1061 struct net_device *dev;
1062 struct station_info sinfo;
1063 struct sk_buff *msg;
1064 u8 *mac_addr = NULL;
1066 memset(&sinfo, 0, sizeof(sinfo));
1068 if (!info->attrs[NL80211_ATTR_MAC])
1071 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1073 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1077 if (!drv->ops->get_station) {
1083 err = drv->ops->get_station(&drv->wiphy, dev, mac_addr, &sinfo);
1089 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1093 if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0,
1094 dev, mac_addr, &sinfo) < 0)
1097 err = genlmsg_unicast(msg, info->snd_pid);
1104 cfg80211_put_dev(drv);
1110 * Get vlan interface making sure it is on the right wiphy.
1112 static int get_vlan(struct nlattr *vlanattr,
1113 struct cfg80211_registered_device *rdev,
1114 struct net_device **vlan)
1119 *vlan = dev_get_by_index(&init_net, nla_get_u32(vlanattr));
1122 if (!(*vlan)->ieee80211_ptr)
1124 if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy)
1130 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
1132 struct cfg80211_registered_device *drv;
1134 struct net_device *dev;
1135 struct station_parameters params;
1136 u8 *mac_addr = NULL;
1138 memset(¶ms, 0, sizeof(params));
1140 params.listen_interval = -1;
1142 if (info->attrs[NL80211_ATTR_STA_AID])
1145 if (!info->attrs[NL80211_ATTR_MAC])
1148 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1150 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
1151 params.supported_rates =
1152 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1153 params.supported_rates_len =
1154 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1157 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1158 params.listen_interval =
1159 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1161 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1163 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1165 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1166 ¶ms.station_flags))
1169 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
1170 params.plink_action =
1171 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
1173 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1177 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1181 if (!drv->ops->change_station) {
1187 err = drv->ops->change_station(&drv->wiphy, dev, mac_addr, ¶ms);
1192 dev_put(params.vlan);
1193 cfg80211_put_dev(drv);
1198 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1200 struct cfg80211_registered_device *drv;
1202 struct net_device *dev;
1203 struct station_parameters params;
1204 u8 *mac_addr = NULL;
1206 memset(¶ms, 0, sizeof(params));
1208 if (!info->attrs[NL80211_ATTR_MAC])
1211 if (!info->attrs[NL80211_ATTR_STA_AID])
1214 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1217 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
1220 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1221 params.supported_rates =
1222 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1223 params.supported_rates_len =
1224 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1225 params.listen_interval =
1226 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1227 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
1228 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1230 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1232 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1233 ¶ms.station_flags))
1236 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1240 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1244 if (!drv->ops->add_station) {
1250 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, ¶ms);
1255 dev_put(params.vlan);
1256 cfg80211_put_dev(drv);
1261 static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
1263 struct cfg80211_registered_device *drv;
1265 struct net_device *dev;
1266 u8 *mac_addr = NULL;
1268 if (info->attrs[NL80211_ATTR_MAC])
1269 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1271 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1275 if (!drv->ops->del_station) {
1281 err = drv->ops->del_station(&drv->wiphy, dev, mac_addr);
1285 cfg80211_put_dev(drv);
1290 static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq,
1291 int flags, struct net_device *dev,
1292 u8 *dst, u8 *next_hop,
1293 struct mpath_info *pinfo)
1296 struct nlattr *pinfoattr;
1298 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
1302 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1303 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
1304 NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
1306 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO);
1308 goto nla_put_failure;
1309 if (pinfo->filled & MPATH_INFO_FRAME_QLEN)
1310 NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN,
1312 if (pinfo->filled & MPATH_INFO_DSN)
1313 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DSN,
1315 if (pinfo->filled & MPATH_INFO_METRIC)
1316 NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC,
1318 if (pinfo->filled & MPATH_INFO_EXPTIME)
1319 NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME,
1321 if (pinfo->filled & MPATH_INFO_FLAGS)
1322 NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS,
1324 if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT)
1325 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
1326 pinfo->discovery_timeout);
1327 if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES)
1328 NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES,
1329 pinfo->discovery_retries);
1331 nla_nest_end(msg, pinfoattr);
1333 return genlmsg_end(msg, hdr);
1336 genlmsg_cancel(msg, hdr);
1340 static int nl80211_dump_mpath(struct sk_buff *skb,
1341 struct netlink_callback *cb)
1343 struct mpath_info pinfo;
1344 struct cfg80211_registered_device *dev;
1345 struct net_device *netdev;
1347 u8 next_hop[ETH_ALEN];
1348 int ifidx = cb->args[0];
1349 int path_idx = cb->args[1];
1353 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1354 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1359 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1362 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1367 netdev = dev_get_by_index(&init_net, ifidx);
1371 dev = cfg80211_get_dev_from_ifindex(ifidx);
1374 goto out_put_netdev;
1377 if (!dev->ops->dump_mpath) {
1385 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
1386 dst, next_hop, &pinfo);
1392 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid,
1393 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1394 netdev, dst, next_hop,
1403 cb->args[1] = path_idx;
1408 cfg80211_put_dev(dev);
1415 static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1417 struct cfg80211_registered_device *drv;
1419 struct net_device *dev;
1420 struct mpath_info pinfo;
1421 struct sk_buff *msg;
1423 u8 next_hop[ETH_ALEN];
1425 memset(&pinfo, 0, sizeof(pinfo));
1427 if (!info->attrs[NL80211_ATTR_MAC])
1430 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1432 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1436 if (!drv->ops->get_mpath) {
1442 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo);
1448 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1452 if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0,
1453 dev, dst, next_hop, &pinfo) < 0)
1456 err = genlmsg_unicast(msg, info->snd_pid);
1463 cfg80211_put_dev(drv);
1468 static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1470 struct cfg80211_registered_device *drv;
1472 struct net_device *dev;
1474 u8 *next_hop = NULL;
1476 if (!info->attrs[NL80211_ATTR_MAC])
1479 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1482 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1483 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1485 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1489 if (!drv->ops->change_mpath) {
1495 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
1499 cfg80211_put_dev(drv);
1503 static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1505 struct cfg80211_registered_device *drv;
1507 struct net_device *dev;
1509 u8 *next_hop = NULL;
1511 if (!info->attrs[NL80211_ATTR_MAC])
1514 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1517 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1518 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1520 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1524 if (!drv->ops->add_mpath) {
1530 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
1534 cfg80211_put_dev(drv);
1539 static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
1541 struct cfg80211_registered_device *drv;
1543 struct net_device *dev;
1546 if (info->attrs[NL80211_ATTR_MAC])
1547 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1549 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1553 if (!drv->ops->del_mpath) {
1559 err = drv->ops->del_mpath(&drv->wiphy, dev, dst);
1563 cfg80211_put_dev(drv);
1568 static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1570 struct cfg80211_registered_device *drv;
1572 struct net_device *dev;
1573 struct bss_parameters params;
1575 memset(¶ms, 0, sizeof(params));
1576 /* default to not changing parameters */
1577 params.use_cts_prot = -1;
1578 params.use_short_preamble = -1;
1579 params.use_short_slot_time = -1;
1581 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
1582 params.use_cts_prot =
1583 nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);
1584 if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])
1585 params.use_short_preamble =
1586 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
1587 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
1588 params.use_short_slot_time =
1589 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
1591 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1595 if (!drv->ops->change_bss) {
1601 err = drv->ops->change_bss(&drv->wiphy, dev, ¶ms);
1605 cfg80211_put_dev(drv);
1610 static const struct nla_policy
1611 reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
1612 [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
1613 [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
1614 [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
1615 [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
1616 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
1617 [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
1620 static int parse_reg_rule(struct nlattr *tb[],
1621 struct ieee80211_reg_rule *reg_rule)
1623 struct ieee80211_freq_range *freq_range = ®_rule->freq_range;
1624 struct ieee80211_power_rule *power_rule = ®_rule->power_rule;
1626 if (!tb[NL80211_ATTR_REG_RULE_FLAGS])
1628 if (!tb[NL80211_ATTR_FREQ_RANGE_START])
1630 if (!tb[NL80211_ATTR_FREQ_RANGE_END])
1632 if (!tb[NL80211_ATTR_FREQ_RANGE_MAX_BW])
1634 if (!tb[NL80211_ATTR_POWER_RULE_MAX_EIRP])
1637 reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]);
1639 freq_range->start_freq_khz =
1640 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]);
1641 freq_range->end_freq_khz =
1642 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]);
1643 freq_range->max_bandwidth_khz =
1644 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]);
1646 power_rule->max_eirp =
1647 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]);
1649 if (tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN])
1650 power_rule->max_antenna_gain =
1651 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN]);
1656 static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1661 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1664 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1666 #ifdef CONFIG_WIRELESS_OLD_REGULATORY
1667 /* We ignore world regdom requests with the old regdom setup */
1668 if (is_world_regdom(data))
1671 mutex_lock(&cfg80211_drv_mutex);
1672 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, NULL);
1673 mutex_unlock(&cfg80211_drv_mutex);
1677 static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1679 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
1680 struct nlattr *nl_reg_rule;
1681 char *alpha2 = NULL;
1682 int rem_reg_rules = 0, r = 0;
1683 u32 num_rules = 0, rule_idx = 0, size_of_regd;
1684 struct ieee80211_regdomain *rd = NULL;
1686 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1689 if (!info->attrs[NL80211_ATTR_REG_RULES])
1692 alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1694 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1697 if (num_rules > NL80211_MAX_SUPP_REG_RULES)
1701 if (!reg_is_valid_request(alpha2))
1704 size_of_regd = sizeof(struct ieee80211_regdomain) +
1705 (num_rules * sizeof(struct ieee80211_reg_rule));
1707 rd = kzalloc(size_of_regd, GFP_KERNEL);
1711 rd->n_reg_rules = num_rules;
1712 rd->alpha2[0] = alpha2[0];
1713 rd->alpha2[1] = alpha2[1];
1715 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1717 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1718 nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1720 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
1726 if (rule_idx > NL80211_MAX_SUPP_REG_RULES)
1730 BUG_ON(rule_idx != num_rules);
1732 mutex_lock(&cfg80211_drv_mutex);
1734 mutex_unlock(&cfg80211_drv_mutex);
1745 static struct genl_ops nl80211_ops[] = {
1747 .cmd = NL80211_CMD_GET_WIPHY,
1748 .doit = nl80211_get_wiphy,
1749 .dumpit = nl80211_dump_wiphy,
1750 .policy = nl80211_policy,
1751 /* can be retrieved by unprivileged users */
1754 .cmd = NL80211_CMD_SET_WIPHY,
1755 .doit = nl80211_set_wiphy,
1756 .policy = nl80211_policy,
1757 .flags = GENL_ADMIN_PERM,
1760 .cmd = NL80211_CMD_GET_INTERFACE,
1761 .doit = nl80211_get_interface,
1762 .dumpit = nl80211_dump_interface,
1763 .policy = nl80211_policy,
1764 /* can be retrieved by unprivileged users */
1767 .cmd = NL80211_CMD_SET_INTERFACE,
1768 .doit = nl80211_set_interface,
1769 .policy = nl80211_policy,
1770 .flags = GENL_ADMIN_PERM,
1773 .cmd = NL80211_CMD_NEW_INTERFACE,
1774 .doit = nl80211_new_interface,
1775 .policy = nl80211_policy,
1776 .flags = GENL_ADMIN_PERM,
1779 .cmd = NL80211_CMD_DEL_INTERFACE,
1780 .doit = nl80211_del_interface,
1781 .policy = nl80211_policy,
1782 .flags = GENL_ADMIN_PERM,
1785 .cmd = NL80211_CMD_GET_KEY,
1786 .doit = nl80211_get_key,
1787 .policy = nl80211_policy,
1788 .flags = GENL_ADMIN_PERM,
1791 .cmd = NL80211_CMD_SET_KEY,
1792 .doit = nl80211_set_key,
1793 .policy = nl80211_policy,
1794 .flags = GENL_ADMIN_PERM,
1797 .cmd = NL80211_CMD_NEW_KEY,
1798 .doit = nl80211_new_key,
1799 .policy = nl80211_policy,
1800 .flags = GENL_ADMIN_PERM,
1803 .cmd = NL80211_CMD_DEL_KEY,
1804 .doit = nl80211_del_key,
1805 .policy = nl80211_policy,
1806 .flags = GENL_ADMIN_PERM,
1809 .cmd = NL80211_CMD_SET_BEACON,
1810 .policy = nl80211_policy,
1811 .flags = GENL_ADMIN_PERM,
1812 .doit = nl80211_addset_beacon,
1815 .cmd = NL80211_CMD_NEW_BEACON,
1816 .policy = nl80211_policy,
1817 .flags = GENL_ADMIN_PERM,
1818 .doit = nl80211_addset_beacon,
1821 .cmd = NL80211_CMD_DEL_BEACON,
1822 .policy = nl80211_policy,
1823 .flags = GENL_ADMIN_PERM,
1824 .doit = nl80211_del_beacon,
1827 .cmd = NL80211_CMD_GET_STATION,
1828 .doit = nl80211_get_station,
1829 .dumpit = nl80211_dump_station,
1830 .policy = nl80211_policy,
1831 .flags = GENL_ADMIN_PERM,
1834 .cmd = NL80211_CMD_SET_STATION,
1835 .doit = nl80211_set_station,
1836 .policy = nl80211_policy,
1837 .flags = GENL_ADMIN_PERM,
1840 .cmd = NL80211_CMD_NEW_STATION,
1841 .doit = nl80211_new_station,
1842 .policy = nl80211_policy,
1843 .flags = GENL_ADMIN_PERM,
1846 .cmd = NL80211_CMD_DEL_STATION,
1847 .doit = nl80211_del_station,
1848 .policy = nl80211_policy,
1849 .flags = GENL_ADMIN_PERM,
1852 .cmd = NL80211_CMD_GET_MPATH,
1853 .doit = nl80211_get_mpath,
1854 .dumpit = nl80211_dump_mpath,
1855 .policy = nl80211_policy,
1856 .flags = GENL_ADMIN_PERM,
1859 .cmd = NL80211_CMD_SET_MPATH,
1860 .doit = nl80211_set_mpath,
1861 .policy = nl80211_policy,
1862 .flags = GENL_ADMIN_PERM,
1865 .cmd = NL80211_CMD_NEW_MPATH,
1866 .doit = nl80211_new_mpath,
1867 .policy = nl80211_policy,
1868 .flags = GENL_ADMIN_PERM,
1871 .cmd = NL80211_CMD_DEL_MPATH,
1872 .doit = nl80211_del_mpath,
1873 .policy = nl80211_policy,
1874 .flags = GENL_ADMIN_PERM,
1877 .cmd = NL80211_CMD_SET_BSS,
1878 .doit = nl80211_set_bss,
1879 .policy = nl80211_policy,
1880 .flags = GENL_ADMIN_PERM,
1883 .cmd = NL80211_CMD_SET_REG,
1884 .doit = nl80211_set_reg,
1885 .policy = nl80211_policy,
1886 .flags = GENL_ADMIN_PERM,
1889 .cmd = NL80211_CMD_REQ_SET_REG,
1890 .doit = nl80211_req_set_reg,
1891 .policy = nl80211_policy,
1892 .flags = GENL_ADMIN_PERM,
1896 /* multicast groups */
1897 static struct genl_multicast_group nl80211_config_mcgrp = {
1901 /* notification functions */
1903 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
1905 struct sk_buff *msg;
1907 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1911 if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
1916 genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
1919 /* initialisation/exit functions */
1921 int nl80211_init(void)
1925 err = genl_register_family(&nl80211_fam);
1929 for (i = 0; i < ARRAY_SIZE(nl80211_ops); i++) {
1930 err = genl_register_ops(&nl80211_fam, &nl80211_ops[i]);
1935 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
1941 genl_unregister_family(&nl80211_fam);
1945 void nl80211_exit(void)
1947 genl_unregister_family(&nl80211_fam);