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 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
428 ifindex = dev->ifindex;
429 type = dev->ieee80211_ptr->iftype;
433 if (info->attrs[NL80211_ATTR_IFTYPE]) {
434 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
435 if (type > NL80211_IFTYPE_MAX)
439 if (!drv->ops->change_virtual_intf ||
440 !(drv->wiphy.interface_modes & (1 << type))) {
445 if (type == NL80211_IFTYPE_MESH_POINT &&
446 info->attrs[NL80211_ATTR_MESH_ID]) {
447 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
448 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
452 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
453 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
455 err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
456 type, err ? NULL : &flags, ¶ms);
458 dev = __dev_get_by_index(&init_net, ifindex);
459 WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != type));
464 cfg80211_put_dev(drv);
468 static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
470 struct cfg80211_registered_device *drv;
471 struct vif_params params;
473 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
476 memset(¶ms, 0, sizeof(params));
478 if (!info->attrs[NL80211_ATTR_IFNAME])
481 if (info->attrs[NL80211_ATTR_IFTYPE]) {
482 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
483 if (type > NL80211_IFTYPE_MAX)
487 drv = cfg80211_get_dev_from_info(info);
491 if (!drv->ops->add_virtual_intf ||
492 !(drv->wiphy.interface_modes & (1 << type))) {
497 if (type == NL80211_IFTYPE_MESH_POINT &&
498 info->attrs[NL80211_ATTR_MESH_ID]) {
499 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
500 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
504 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
505 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
507 err = drv->ops->add_virtual_intf(&drv->wiphy,
508 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
509 type, err ? NULL : &flags, ¶ms);
514 cfg80211_put_dev(drv);
518 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
520 struct cfg80211_registered_device *drv;
522 struct net_device *dev;
524 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
527 ifindex = dev->ifindex;
530 if (!drv->ops->del_virtual_intf) {
536 err = drv->ops->del_virtual_intf(&drv->wiphy, ifindex);
540 cfg80211_put_dev(drv);
544 struct get_key_cookie {
549 static void get_key_callback(void *c, struct key_params *params)
551 struct get_key_cookie *cookie = c;
554 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA,
555 params->key_len, params->key);
558 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ,
559 params->seq_len, params->seq);
562 NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER,
570 static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
572 struct cfg80211_registered_device *drv;
574 struct net_device *dev;
577 struct get_key_cookie cookie = {
583 if (info->attrs[NL80211_ATTR_KEY_IDX])
584 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
589 if (info->attrs[NL80211_ATTR_MAC])
590 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
592 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
596 if (!drv->ops->get_key) {
601 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
607 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
608 NL80211_CMD_NEW_KEY);
617 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
618 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx);
620 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
623 err = drv->ops->get_key(&drv->wiphy, dev, key_idx, mac_addr,
624 &cookie, get_key_callback);
631 goto nla_put_failure;
633 genlmsg_end(msg, hdr);
634 err = genlmsg_unicast(msg, info->snd_pid);
641 cfg80211_put_dev(drv);
646 static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
648 struct cfg80211_registered_device *drv;
650 struct net_device *dev;
653 if (!info->attrs[NL80211_ATTR_KEY_IDX])
656 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
661 /* currently only support setting default key */
662 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT])
665 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
669 if (!drv->ops->set_default_key) {
675 err = drv->ops->set_default_key(&drv->wiphy, dev, key_idx);
679 cfg80211_put_dev(drv);
684 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
686 struct cfg80211_registered_device *drv;
688 struct net_device *dev;
689 struct key_params params;
693 memset(¶ms, 0, sizeof(params));
695 if (!info->attrs[NL80211_ATTR_KEY_CIPHER])
698 if (info->attrs[NL80211_ATTR_KEY_DATA]) {
699 params.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
700 params.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
703 if (info->attrs[NL80211_ATTR_KEY_IDX])
704 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
706 params.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
708 if (info->attrs[NL80211_ATTR_MAC])
709 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
715 * Disallow pairwise keys with non-zero index unless it's WEP
716 * (because current deployments use pairwise WEP keys with
717 * non-zero indizes but 802.11i clearly specifies to use zero)
719 if (mac_addr && key_idx &&
720 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
721 params.cipher != WLAN_CIPHER_SUITE_WEP104)
724 /* TODO: add definitions for the lengths to linux/ieee80211.h */
725 switch (params.cipher) {
726 case WLAN_CIPHER_SUITE_WEP40:
727 if (params.key_len != 5)
730 case WLAN_CIPHER_SUITE_TKIP:
731 if (params.key_len != 32)
734 case WLAN_CIPHER_SUITE_CCMP:
735 if (params.key_len != 16)
738 case WLAN_CIPHER_SUITE_WEP104:
739 if (params.key_len != 13)
746 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
750 if (!drv->ops->add_key) {
756 err = drv->ops->add_key(&drv->wiphy, dev, key_idx, mac_addr, ¶ms);
760 cfg80211_put_dev(drv);
765 static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
767 struct cfg80211_registered_device *drv;
769 struct net_device *dev;
773 if (info->attrs[NL80211_ATTR_KEY_IDX])
774 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
779 if (info->attrs[NL80211_ATTR_MAC])
780 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
782 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
786 if (!drv->ops->del_key) {
792 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
796 cfg80211_put_dev(drv);
801 static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
803 int (*call)(struct wiphy *wiphy, struct net_device *dev,
804 struct beacon_parameters *info);
805 struct cfg80211_registered_device *drv;
807 struct net_device *dev;
808 struct beacon_parameters params;
811 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
815 switch (info->genlhdr->cmd) {
816 case NL80211_CMD_NEW_BEACON:
817 /* these are required for NEW_BEACON */
818 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
819 !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
820 !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
825 call = drv->ops->add_beacon;
827 case NL80211_CMD_SET_BEACON:
828 call = drv->ops->set_beacon;
841 memset(¶ms, 0, sizeof(params));
843 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
845 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
849 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
851 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
855 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
856 params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
858 nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
862 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
863 params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
865 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
875 err = call(&drv->wiphy, dev, ¶ms);
879 cfg80211_put_dev(drv);
884 static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
886 struct cfg80211_registered_device *drv;
888 struct net_device *dev;
890 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
894 if (!drv->ops->del_beacon) {
900 err = drv->ops->del_beacon(&drv->wiphy, dev);
904 cfg80211_put_dev(drv);
909 static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
910 [NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
911 [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
912 [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
915 static int parse_station_flags(struct nlattr *nla, u32 *staflags)
917 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
925 if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
926 nla, sta_flags_policy))
929 *staflags = STATION_FLAG_CHANGED;
931 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
933 *staflags |= (1<<flag);
938 static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
939 int flags, struct net_device *dev,
940 u8 *mac_addr, struct station_info *sinfo)
943 struct nlattr *sinfoattr;
945 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
949 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
950 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
952 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
954 goto nla_put_failure;
955 if (sinfo->filled & STATION_INFO_INACTIVE_TIME)
956 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME,
957 sinfo->inactive_time);
958 if (sinfo->filled & STATION_INFO_RX_BYTES)
959 NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES,
961 if (sinfo->filled & STATION_INFO_TX_BYTES)
962 NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES,
964 if (sinfo->filled & STATION_INFO_LLID)
965 NLA_PUT_U16(msg, NL80211_STA_INFO_LLID,
967 if (sinfo->filled & STATION_INFO_PLID)
968 NLA_PUT_U16(msg, NL80211_STA_INFO_PLID,
970 if (sinfo->filled & STATION_INFO_PLINK_STATE)
971 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE,
974 nla_nest_end(msg, sinfoattr);
976 return genlmsg_end(msg, hdr);
979 genlmsg_cancel(msg, hdr);
983 static int nl80211_dump_station(struct sk_buff *skb,
984 struct netlink_callback *cb)
986 struct station_info sinfo;
987 struct cfg80211_registered_device *dev;
988 struct net_device *netdev;
989 u8 mac_addr[ETH_ALEN];
990 int ifidx = cb->args[0];
991 int sta_idx = cb->args[1];
995 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
996 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1001 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1004 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1009 netdev = dev_get_by_index(&init_net, ifidx);
1013 dev = cfg80211_get_dev_from_ifindex(ifidx);
1016 goto out_put_netdev;
1019 if (!dev->ops->dump_station) {
1027 err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx,
1034 if (nl80211_send_station(skb,
1035 NETLINK_CB(cb->skb).pid,
1036 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1046 cb->args[1] = sta_idx;
1051 cfg80211_put_dev(dev);
1058 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
1060 struct cfg80211_registered_device *drv;
1062 struct net_device *dev;
1063 struct station_info sinfo;
1064 struct sk_buff *msg;
1065 u8 *mac_addr = NULL;
1067 memset(&sinfo, 0, sizeof(sinfo));
1069 if (!info->attrs[NL80211_ATTR_MAC])
1072 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1074 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1078 if (!drv->ops->get_station) {
1084 err = drv->ops->get_station(&drv->wiphy, dev, mac_addr, &sinfo);
1090 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1094 if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0,
1095 dev, mac_addr, &sinfo) < 0)
1098 err = genlmsg_unicast(msg, info->snd_pid);
1105 cfg80211_put_dev(drv);
1111 * Get vlan interface making sure it is on the right wiphy.
1113 static int get_vlan(struct nlattr *vlanattr,
1114 struct cfg80211_registered_device *rdev,
1115 struct net_device **vlan)
1120 *vlan = dev_get_by_index(&init_net, nla_get_u32(vlanattr));
1123 if (!(*vlan)->ieee80211_ptr)
1125 if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy)
1131 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
1133 struct cfg80211_registered_device *drv;
1135 struct net_device *dev;
1136 struct station_parameters params;
1137 u8 *mac_addr = NULL;
1139 memset(¶ms, 0, sizeof(params));
1141 params.listen_interval = -1;
1143 if (info->attrs[NL80211_ATTR_STA_AID])
1146 if (!info->attrs[NL80211_ATTR_MAC])
1149 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1151 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
1152 params.supported_rates =
1153 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1154 params.supported_rates_len =
1155 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1158 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1159 params.listen_interval =
1160 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1162 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1164 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1166 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1167 ¶ms.station_flags))
1170 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
1171 params.plink_action =
1172 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
1174 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1178 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1182 if (!drv->ops->change_station) {
1188 err = drv->ops->change_station(&drv->wiphy, dev, mac_addr, ¶ms);
1193 dev_put(params.vlan);
1194 cfg80211_put_dev(drv);
1199 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1201 struct cfg80211_registered_device *drv;
1203 struct net_device *dev;
1204 struct station_parameters params;
1205 u8 *mac_addr = NULL;
1207 memset(¶ms, 0, sizeof(params));
1209 if (!info->attrs[NL80211_ATTR_MAC])
1212 if (!info->attrs[NL80211_ATTR_STA_AID])
1215 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1218 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
1221 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1222 params.supported_rates =
1223 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1224 params.supported_rates_len =
1225 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1226 params.listen_interval =
1227 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1228 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
1229 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1231 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1233 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1234 ¶ms.station_flags))
1237 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1241 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1245 if (!drv->ops->add_station) {
1251 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, ¶ms);
1256 dev_put(params.vlan);
1257 cfg80211_put_dev(drv);
1262 static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
1264 struct cfg80211_registered_device *drv;
1266 struct net_device *dev;
1267 u8 *mac_addr = NULL;
1269 if (info->attrs[NL80211_ATTR_MAC])
1270 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1272 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1276 if (!drv->ops->del_station) {
1282 err = drv->ops->del_station(&drv->wiphy, dev, mac_addr);
1286 cfg80211_put_dev(drv);
1291 static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq,
1292 int flags, struct net_device *dev,
1293 u8 *dst, u8 *next_hop,
1294 struct mpath_info *pinfo)
1297 struct nlattr *pinfoattr;
1299 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
1303 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1304 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
1305 NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
1307 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO);
1309 goto nla_put_failure;
1310 if (pinfo->filled & MPATH_INFO_FRAME_QLEN)
1311 NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN,
1313 if (pinfo->filled & MPATH_INFO_DSN)
1314 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DSN,
1316 if (pinfo->filled & MPATH_INFO_METRIC)
1317 NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC,
1319 if (pinfo->filled & MPATH_INFO_EXPTIME)
1320 NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME,
1322 if (pinfo->filled & MPATH_INFO_FLAGS)
1323 NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS,
1325 if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT)
1326 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
1327 pinfo->discovery_timeout);
1328 if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES)
1329 NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES,
1330 pinfo->discovery_retries);
1332 nla_nest_end(msg, pinfoattr);
1334 return genlmsg_end(msg, hdr);
1337 genlmsg_cancel(msg, hdr);
1341 static int nl80211_dump_mpath(struct sk_buff *skb,
1342 struct netlink_callback *cb)
1344 struct mpath_info pinfo;
1345 struct cfg80211_registered_device *dev;
1346 struct net_device *netdev;
1348 u8 next_hop[ETH_ALEN];
1349 int ifidx = cb->args[0];
1350 int path_idx = cb->args[1];
1354 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1355 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1360 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1363 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1368 netdev = dev_get_by_index(&init_net, ifidx);
1372 dev = cfg80211_get_dev_from_ifindex(ifidx);
1375 goto out_put_netdev;
1378 if (!dev->ops->dump_mpath) {
1386 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
1387 dst, next_hop, &pinfo);
1393 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid,
1394 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1395 netdev, dst, next_hop,
1404 cb->args[1] = path_idx;
1409 cfg80211_put_dev(dev);
1416 static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1418 struct cfg80211_registered_device *drv;
1420 struct net_device *dev;
1421 struct mpath_info pinfo;
1422 struct sk_buff *msg;
1424 u8 next_hop[ETH_ALEN];
1426 memset(&pinfo, 0, sizeof(pinfo));
1428 if (!info->attrs[NL80211_ATTR_MAC])
1431 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1433 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1437 if (!drv->ops->get_mpath) {
1443 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo);
1449 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1453 if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0,
1454 dev, dst, next_hop, &pinfo) < 0)
1457 err = genlmsg_unicast(msg, info->snd_pid);
1464 cfg80211_put_dev(drv);
1469 static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1471 struct cfg80211_registered_device *drv;
1473 struct net_device *dev;
1475 u8 *next_hop = NULL;
1477 if (!info->attrs[NL80211_ATTR_MAC])
1480 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1483 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1484 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1486 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1490 if (!drv->ops->change_mpath) {
1496 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
1500 cfg80211_put_dev(drv);
1504 static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1506 struct cfg80211_registered_device *drv;
1508 struct net_device *dev;
1510 u8 *next_hop = NULL;
1512 if (!info->attrs[NL80211_ATTR_MAC])
1515 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1518 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1519 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1521 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1525 if (!drv->ops->add_mpath) {
1531 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
1535 cfg80211_put_dev(drv);
1540 static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
1542 struct cfg80211_registered_device *drv;
1544 struct net_device *dev;
1547 if (info->attrs[NL80211_ATTR_MAC])
1548 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1550 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1554 if (!drv->ops->del_mpath) {
1560 err = drv->ops->del_mpath(&drv->wiphy, dev, dst);
1564 cfg80211_put_dev(drv);
1569 static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1571 struct cfg80211_registered_device *drv;
1573 struct net_device *dev;
1574 struct bss_parameters params;
1576 memset(¶ms, 0, sizeof(params));
1577 /* default to not changing parameters */
1578 params.use_cts_prot = -1;
1579 params.use_short_preamble = -1;
1580 params.use_short_slot_time = -1;
1582 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
1583 params.use_cts_prot =
1584 nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);
1585 if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])
1586 params.use_short_preamble =
1587 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
1588 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
1589 params.use_short_slot_time =
1590 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
1592 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1596 if (!drv->ops->change_bss) {
1602 err = drv->ops->change_bss(&drv->wiphy, dev, ¶ms);
1606 cfg80211_put_dev(drv);
1611 static const struct nla_policy
1612 reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
1613 [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
1614 [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
1615 [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
1616 [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
1617 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
1618 [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
1621 static int parse_reg_rule(struct nlattr *tb[],
1622 struct ieee80211_reg_rule *reg_rule)
1624 struct ieee80211_freq_range *freq_range = ®_rule->freq_range;
1625 struct ieee80211_power_rule *power_rule = ®_rule->power_rule;
1627 if (!tb[NL80211_ATTR_REG_RULE_FLAGS])
1629 if (!tb[NL80211_ATTR_FREQ_RANGE_START])
1631 if (!tb[NL80211_ATTR_FREQ_RANGE_END])
1633 if (!tb[NL80211_ATTR_FREQ_RANGE_MAX_BW])
1635 if (!tb[NL80211_ATTR_POWER_RULE_MAX_EIRP])
1638 reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]);
1640 freq_range->start_freq_khz =
1641 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]);
1642 freq_range->end_freq_khz =
1643 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]);
1644 freq_range->max_bandwidth_khz =
1645 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]);
1647 power_rule->max_eirp =
1648 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]);
1650 if (tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN])
1651 power_rule->max_antenna_gain =
1652 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN]);
1657 static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1662 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1665 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1667 #ifdef CONFIG_WIRELESS_OLD_REGULATORY
1668 /* We ignore world regdom requests with the old regdom setup */
1669 if (is_world_regdom(data))
1672 mutex_lock(&cfg80211_drv_mutex);
1673 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, NULL);
1674 mutex_unlock(&cfg80211_drv_mutex);
1678 static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1680 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
1681 struct nlattr *nl_reg_rule;
1682 char *alpha2 = NULL;
1683 int rem_reg_rules = 0, r = 0;
1684 u32 num_rules = 0, rule_idx = 0, size_of_regd;
1685 struct ieee80211_regdomain *rd = NULL;
1687 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1690 if (!info->attrs[NL80211_ATTR_REG_RULES])
1693 alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1695 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1698 if (num_rules > NL80211_MAX_SUPP_REG_RULES)
1702 if (!reg_is_valid_request(alpha2))
1705 size_of_regd = sizeof(struct ieee80211_regdomain) +
1706 (num_rules * sizeof(struct ieee80211_reg_rule));
1708 rd = kzalloc(size_of_regd, GFP_KERNEL);
1712 rd->n_reg_rules = num_rules;
1713 rd->alpha2[0] = alpha2[0];
1714 rd->alpha2[1] = alpha2[1];
1716 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1718 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1719 nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1721 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
1727 if (rule_idx > NL80211_MAX_SUPP_REG_RULES)
1731 BUG_ON(rule_idx != num_rules);
1733 mutex_lock(&cfg80211_drv_mutex);
1735 mutex_unlock(&cfg80211_drv_mutex);
1746 static struct genl_ops nl80211_ops[] = {
1748 .cmd = NL80211_CMD_GET_WIPHY,
1749 .doit = nl80211_get_wiphy,
1750 .dumpit = nl80211_dump_wiphy,
1751 .policy = nl80211_policy,
1752 /* can be retrieved by unprivileged users */
1755 .cmd = NL80211_CMD_SET_WIPHY,
1756 .doit = nl80211_set_wiphy,
1757 .policy = nl80211_policy,
1758 .flags = GENL_ADMIN_PERM,
1761 .cmd = NL80211_CMD_GET_INTERFACE,
1762 .doit = nl80211_get_interface,
1763 .dumpit = nl80211_dump_interface,
1764 .policy = nl80211_policy,
1765 /* can be retrieved by unprivileged users */
1768 .cmd = NL80211_CMD_SET_INTERFACE,
1769 .doit = nl80211_set_interface,
1770 .policy = nl80211_policy,
1771 .flags = GENL_ADMIN_PERM,
1774 .cmd = NL80211_CMD_NEW_INTERFACE,
1775 .doit = nl80211_new_interface,
1776 .policy = nl80211_policy,
1777 .flags = GENL_ADMIN_PERM,
1780 .cmd = NL80211_CMD_DEL_INTERFACE,
1781 .doit = nl80211_del_interface,
1782 .policy = nl80211_policy,
1783 .flags = GENL_ADMIN_PERM,
1786 .cmd = NL80211_CMD_GET_KEY,
1787 .doit = nl80211_get_key,
1788 .policy = nl80211_policy,
1789 .flags = GENL_ADMIN_PERM,
1792 .cmd = NL80211_CMD_SET_KEY,
1793 .doit = nl80211_set_key,
1794 .policy = nl80211_policy,
1795 .flags = GENL_ADMIN_PERM,
1798 .cmd = NL80211_CMD_NEW_KEY,
1799 .doit = nl80211_new_key,
1800 .policy = nl80211_policy,
1801 .flags = GENL_ADMIN_PERM,
1804 .cmd = NL80211_CMD_DEL_KEY,
1805 .doit = nl80211_del_key,
1806 .policy = nl80211_policy,
1807 .flags = GENL_ADMIN_PERM,
1810 .cmd = NL80211_CMD_SET_BEACON,
1811 .policy = nl80211_policy,
1812 .flags = GENL_ADMIN_PERM,
1813 .doit = nl80211_addset_beacon,
1816 .cmd = NL80211_CMD_NEW_BEACON,
1817 .policy = nl80211_policy,
1818 .flags = GENL_ADMIN_PERM,
1819 .doit = nl80211_addset_beacon,
1822 .cmd = NL80211_CMD_DEL_BEACON,
1823 .policy = nl80211_policy,
1824 .flags = GENL_ADMIN_PERM,
1825 .doit = nl80211_del_beacon,
1828 .cmd = NL80211_CMD_GET_STATION,
1829 .doit = nl80211_get_station,
1830 .dumpit = nl80211_dump_station,
1831 .policy = nl80211_policy,
1832 .flags = GENL_ADMIN_PERM,
1835 .cmd = NL80211_CMD_SET_STATION,
1836 .doit = nl80211_set_station,
1837 .policy = nl80211_policy,
1838 .flags = GENL_ADMIN_PERM,
1841 .cmd = NL80211_CMD_NEW_STATION,
1842 .doit = nl80211_new_station,
1843 .policy = nl80211_policy,
1844 .flags = GENL_ADMIN_PERM,
1847 .cmd = NL80211_CMD_DEL_STATION,
1848 .doit = nl80211_del_station,
1849 .policy = nl80211_policy,
1850 .flags = GENL_ADMIN_PERM,
1853 .cmd = NL80211_CMD_GET_MPATH,
1854 .doit = nl80211_get_mpath,
1855 .dumpit = nl80211_dump_mpath,
1856 .policy = nl80211_policy,
1857 .flags = GENL_ADMIN_PERM,
1860 .cmd = NL80211_CMD_SET_MPATH,
1861 .doit = nl80211_set_mpath,
1862 .policy = nl80211_policy,
1863 .flags = GENL_ADMIN_PERM,
1866 .cmd = NL80211_CMD_NEW_MPATH,
1867 .doit = nl80211_new_mpath,
1868 .policy = nl80211_policy,
1869 .flags = GENL_ADMIN_PERM,
1872 .cmd = NL80211_CMD_DEL_MPATH,
1873 .doit = nl80211_del_mpath,
1874 .policy = nl80211_policy,
1875 .flags = GENL_ADMIN_PERM,
1878 .cmd = NL80211_CMD_SET_BSS,
1879 .doit = nl80211_set_bss,
1880 .policy = nl80211_policy,
1881 .flags = GENL_ADMIN_PERM,
1884 .cmd = NL80211_CMD_SET_REG,
1885 .doit = nl80211_set_reg,
1886 .policy = nl80211_policy,
1887 .flags = GENL_ADMIN_PERM,
1890 .cmd = NL80211_CMD_REQ_SET_REG,
1891 .doit = nl80211_req_set_reg,
1892 .policy = nl80211_policy,
1893 .flags = GENL_ADMIN_PERM,
1897 /* multicast groups */
1898 static struct genl_multicast_group nl80211_config_mcgrp = {
1902 /* notification functions */
1904 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
1906 struct sk_buff *msg;
1908 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1912 if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
1917 genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
1920 /* initialisation/exit functions */
1922 int nl80211_init(void)
1926 err = genl_register_family(&nl80211_fam);
1930 for (i = 0; i < ARRAY_SIZE(nl80211_ops); i++) {
1931 err = genl_register_ops(&nl80211_fam, &nl80211_ops[i]);
1936 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
1942 genl_unregister_family(&nl80211_fam);
1946 void nl80211_exit(void)
1948 genl_unregister_family(&nl80211_fam);