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;
421 u32 _flags, *flags = NULL;
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 (info->attrs[NL80211_ATTR_MESH_ID]) {
446 if (type != NL80211_IFTYPE_MESH_POINT) {
450 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
451 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
454 if (info->attrs[NL80211_ATTR_MNTR_FLAGS]) {
455 if (type != NL80211_IFTYPE_MONITOR) {
459 err = parse_monitor_flags(info->attrs[NL80211_ATTR_MNTR_FLAGS],
465 err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
466 type, flags, ¶ms);
468 dev = __dev_get_by_index(&init_net, ifindex);
469 WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != type));
474 cfg80211_put_dev(drv);
478 static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
480 struct cfg80211_registered_device *drv;
481 struct vif_params params;
483 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
486 memset(¶ms, 0, sizeof(params));
488 if (!info->attrs[NL80211_ATTR_IFNAME])
491 if (info->attrs[NL80211_ATTR_IFTYPE]) {
492 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
493 if (type > NL80211_IFTYPE_MAX)
497 drv = cfg80211_get_dev_from_info(info);
501 if (!drv->ops->add_virtual_intf ||
502 !(drv->wiphy.interface_modes & (1 << type))) {
507 if (type == NL80211_IFTYPE_MESH_POINT &&
508 info->attrs[NL80211_ATTR_MESH_ID]) {
509 params.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
510 params.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
514 err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
515 info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
517 err = drv->ops->add_virtual_intf(&drv->wiphy,
518 nla_data(info->attrs[NL80211_ATTR_IFNAME]),
519 type, err ? NULL : &flags, ¶ms);
524 cfg80211_put_dev(drv);
528 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
530 struct cfg80211_registered_device *drv;
532 struct net_device *dev;
534 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
537 ifindex = dev->ifindex;
540 if (!drv->ops->del_virtual_intf) {
546 err = drv->ops->del_virtual_intf(&drv->wiphy, ifindex);
550 cfg80211_put_dev(drv);
554 struct get_key_cookie {
559 static void get_key_callback(void *c, struct key_params *params)
561 struct get_key_cookie *cookie = c;
564 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA,
565 params->key_len, params->key);
568 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ,
569 params->seq_len, params->seq);
572 NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER,
580 static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
582 struct cfg80211_registered_device *drv;
584 struct net_device *dev;
587 struct get_key_cookie cookie = {
593 if (info->attrs[NL80211_ATTR_KEY_IDX])
594 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
599 if (info->attrs[NL80211_ATTR_MAC])
600 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
602 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
606 if (!drv->ops->get_key) {
611 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
617 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
618 NL80211_CMD_NEW_KEY);
627 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
628 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx);
630 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
633 err = drv->ops->get_key(&drv->wiphy, dev, key_idx, mac_addr,
634 &cookie, get_key_callback);
641 goto nla_put_failure;
643 genlmsg_end(msg, hdr);
644 err = genlmsg_unicast(msg, info->snd_pid);
652 cfg80211_put_dev(drv);
657 static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
659 struct cfg80211_registered_device *drv;
661 struct net_device *dev;
664 if (!info->attrs[NL80211_ATTR_KEY_IDX])
667 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
672 /* currently only support setting default key */
673 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT])
676 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
680 if (!drv->ops->set_default_key) {
686 err = drv->ops->set_default_key(&drv->wiphy, dev, key_idx);
690 cfg80211_put_dev(drv);
695 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
697 struct cfg80211_registered_device *drv;
699 struct net_device *dev;
700 struct key_params params;
704 memset(¶ms, 0, sizeof(params));
706 if (!info->attrs[NL80211_ATTR_KEY_CIPHER])
709 if (info->attrs[NL80211_ATTR_KEY_DATA]) {
710 params.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
711 params.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
714 if (info->attrs[NL80211_ATTR_KEY_IDX])
715 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
717 params.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
719 if (info->attrs[NL80211_ATTR_MAC])
720 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
726 * Disallow pairwise keys with non-zero index unless it's WEP
727 * (because current deployments use pairwise WEP keys with
728 * non-zero indizes but 802.11i clearly specifies to use zero)
730 if (mac_addr && key_idx &&
731 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
732 params.cipher != WLAN_CIPHER_SUITE_WEP104)
735 /* TODO: add definitions for the lengths to linux/ieee80211.h */
736 switch (params.cipher) {
737 case WLAN_CIPHER_SUITE_WEP40:
738 if (params.key_len != 5)
741 case WLAN_CIPHER_SUITE_TKIP:
742 if (params.key_len != 32)
745 case WLAN_CIPHER_SUITE_CCMP:
746 if (params.key_len != 16)
749 case WLAN_CIPHER_SUITE_WEP104:
750 if (params.key_len != 13)
757 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
761 if (!drv->ops->add_key) {
767 err = drv->ops->add_key(&drv->wiphy, dev, key_idx, mac_addr, ¶ms);
771 cfg80211_put_dev(drv);
776 static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
778 struct cfg80211_registered_device *drv;
780 struct net_device *dev;
784 if (info->attrs[NL80211_ATTR_KEY_IDX])
785 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
790 if (info->attrs[NL80211_ATTR_MAC])
791 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
793 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
797 if (!drv->ops->del_key) {
803 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
807 cfg80211_put_dev(drv);
812 static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
814 int (*call)(struct wiphy *wiphy, struct net_device *dev,
815 struct beacon_parameters *info);
816 struct cfg80211_registered_device *drv;
818 struct net_device *dev;
819 struct beacon_parameters params;
822 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
826 switch (info->genlhdr->cmd) {
827 case NL80211_CMD_NEW_BEACON:
828 /* these are required for NEW_BEACON */
829 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
830 !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
831 !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
836 call = drv->ops->add_beacon;
838 case NL80211_CMD_SET_BEACON:
839 call = drv->ops->set_beacon;
852 memset(¶ms, 0, sizeof(params));
854 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
856 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
860 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
862 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
866 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
867 params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
869 nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
873 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
874 params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
876 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
886 err = call(&drv->wiphy, dev, ¶ms);
890 cfg80211_put_dev(drv);
895 static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
897 struct cfg80211_registered_device *drv;
899 struct net_device *dev;
901 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
905 if (!drv->ops->del_beacon) {
911 err = drv->ops->del_beacon(&drv->wiphy, dev);
915 cfg80211_put_dev(drv);
920 static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
921 [NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
922 [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
923 [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
926 static int parse_station_flags(struct nlattr *nla, u32 *staflags)
928 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
936 if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
937 nla, sta_flags_policy))
940 *staflags = STATION_FLAG_CHANGED;
942 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
944 *staflags |= (1<<flag);
949 static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
950 int flags, struct net_device *dev,
951 u8 *mac_addr, struct station_info *sinfo)
954 struct nlattr *sinfoattr;
956 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
960 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
961 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
963 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
965 goto nla_put_failure;
966 if (sinfo->filled & STATION_INFO_INACTIVE_TIME)
967 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME,
968 sinfo->inactive_time);
969 if (sinfo->filled & STATION_INFO_RX_BYTES)
970 NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES,
972 if (sinfo->filled & STATION_INFO_TX_BYTES)
973 NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES,
975 if (sinfo->filled & STATION_INFO_LLID)
976 NLA_PUT_U16(msg, NL80211_STA_INFO_LLID,
978 if (sinfo->filled & STATION_INFO_PLID)
979 NLA_PUT_U16(msg, NL80211_STA_INFO_PLID,
981 if (sinfo->filled & STATION_INFO_PLINK_STATE)
982 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE,
985 nla_nest_end(msg, sinfoattr);
987 return genlmsg_end(msg, hdr);
990 genlmsg_cancel(msg, hdr);
994 static int nl80211_dump_station(struct sk_buff *skb,
995 struct netlink_callback *cb)
997 struct station_info sinfo;
998 struct cfg80211_registered_device *dev;
999 struct net_device *netdev;
1000 u8 mac_addr[ETH_ALEN];
1001 int ifidx = cb->args[0];
1002 int sta_idx = cb->args[1];
1006 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1007 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1012 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1015 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1020 netdev = dev_get_by_index(&init_net, ifidx);
1024 dev = cfg80211_get_dev_from_ifindex(ifidx);
1027 goto out_put_netdev;
1030 if (!dev->ops->dump_station) {
1038 err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx,
1045 if (nl80211_send_station(skb,
1046 NETLINK_CB(cb->skb).pid,
1047 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1057 cb->args[1] = sta_idx;
1062 cfg80211_put_dev(dev);
1069 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
1071 struct cfg80211_registered_device *drv;
1073 struct net_device *dev;
1074 struct station_info sinfo;
1075 struct sk_buff *msg;
1076 u8 *mac_addr = NULL;
1078 memset(&sinfo, 0, sizeof(sinfo));
1080 if (!info->attrs[NL80211_ATTR_MAC])
1083 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1085 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1089 if (!drv->ops->get_station) {
1095 err = drv->ops->get_station(&drv->wiphy, dev, mac_addr, &sinfo);
1101 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1105 if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0,
1106 dev, mac_addr, &sinfo) < 0)
1109 err = genlmsg_unicast(msg, info->snd_pid);
1116 cfg80211_put_dev(drv);
1122 * Get vlan interface making sure it is on the right wiphy.
1124 static int get_vlan(struct nlattr *vlanattr,
1125 struct cfg80211_registered_device *rdev,
1126 struct net_device **vlan)
1131 *vlan = dev_get_by_index(&init_net, nla_get_u32(vlanattr));
1134 if (!(*vlan)->ieee80211_ptr)
1136 if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy)
1142 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
1144 struct cfg80211_registered_device *drv;
1146 struct net_device *dev;
1147 struct station_parameters params;
1148 u8 *mac_addr = NULL;
1150 memset(¶ms, 0, sizeof(params));
1152 params.listen_interval = -1;
1154 if (info->attrs[NL80211_ATTR_STA_AID])
1157 if (!info->attrs[NL80211_ATTR_MAC])
1160 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1162 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
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]);
1169 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1170 params.listen_interval =
1171 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1173 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1175 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1177 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1178 ¶ms.station_flags))
1181 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
1182 params.plink_action =
1183 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
1185 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1189 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1193 if (!drv->ops->change_station) {
1199 err = drv->ops->change_station(&drv->wiphy, dev, mac_addr, ¶ms);
1204 dev_put(params.vlan);
1205 cfg80211_put_dev(drv);
1210 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1212 struct cfg80211_registered_device *drv;
1214 struct net_device *dev;
1215 struct station_parameters params;
1216 u8 *mac_addr = NULL;
1218 memset(¶ms, 0, sizeof(params));
1220 if (!info->attrs[NL80211_ATTR_MAC])
1223 if (!info->attrs[NL80211_ATTR_STA_AID])
1226 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1229 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
1232 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1233 params.supported_rates =
1234 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1235 params.supported_rates_len =
1236 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1237 params.listen_interval =
1238 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1239 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
1240 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1242 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1244 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1245 ¶ms.station_flags))
1248 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1252 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1256 if (!drv->ops->add_station) {
1262 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, ¶ms);
1267 dev_put(params.vlan);
1268 cfg80211_put_dev(drv);
1273 static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
1275 struct cfg80211_registered_device *drv;
1277 struct net_device *dev;
1278 u8 *mac_addr = NULL;
1280 if (info->attrs[NL80211_ATTR_MAC])
1281 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1283 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1287 if (!drv->ops->del_station) {
1293 err = drv->ops->del_station(&drv->wiphy, dev, mac_addr);
1297 cfg80211_put_dev(drv);
1302 static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq,
1303 int flags, struct net_device *dev,
1304 u8 *dst, u8 *next_hop,
1305 struct mpath_info *pinfo)
1308 struct nlattr *pinfoattr;
1310 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
1314 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1315 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
1316 NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
1318 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO);
1320 goto nla_put_failure;
1321 if (pinfo->filled & MPATH_INFO_FRAME_QLEN)
1322 NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN,
1324 if (pinfo->filled & MPATH_INFO_DSN)
1325 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DSN,
1327 if (pinfo->filled & MPATH_INFO_METRIC)
1328 NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC,
1330 if (pinfo->filled & MPATH_INFO_EXPTIME)
1331 NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME,
1333 if (pinfo->filled & MPATH_INFO_FLAGS)
1334 NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS,
1336 if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT)
1337 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
1338 pinfo->discovery_timeout);
1339 if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES)
1340 NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES,
1341 pinfo->discovery_retries);
1343 nla_nest_end(msg, pinfoattr);
1345 return genlmsg_end(msg, hdr);
1348 genlmsg_cancel(msg, hdr);
1352 static int nl80211_dump_mpath(struct sk_buff *skb,
1353 struct netlink_callback *cb)
1355 struct mpath_info pinfo;
1356 struct cfg80211_registered_device *dev;
1357 struct net_device *netdev;
1359 u8 next_hop[ETH_ALEN];
1360 int ifidx = cb->args[0];
1361 int path_idx = cb->args[1];
1365 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1366 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1371 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1374 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1379 netdev = dev_get_by_index(&init_net, ifidx);
1383 dev = cfg80211_get_dev_from_ifindex(ifidx);
1386 goto out_put_netdev;
1389 if (!dev->ops->dump_mpath) {
1397 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
1398 dst, next_hop, &pinfo);
1404 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid,
1405 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1406 netdev, dst, next_hop,
1415 cb->args[1] = path_idx;
1420 cfg80211_put_dev(dev);
1427 static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1429 struct cfg80211_registered_device *drv;
1431 struct net_device *dev;
1432 struct mpath_info pinfo;
1433 struct sk_buff *msg;
1435 u8 next_hop[ETH_ALEN];
1437 memset(&pinfo, 0, sizeof(pinfo));
1439 if (!info->attrs[NL80211_ATTR_MAC])
1442 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1444 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1448 if (!drv->ops->get_mpath) {
1454 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo);
1460 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1464 if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0,
1465 dev, dst, next_hop, &pinfo) < 0)
1468 err = genlmsg_unicast(msg, info->snd_pid);
1475 cfg80211_put_dev(drv);
1480 static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1482 struct cfg80211_registered_device *drv;
1484 struct net_device *dev;
1486 u8 *next_hop = NULL;
1488 if (!info->attrs[NL80211_ATTR_MAC])
1491 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1494 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1495 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1497 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1501 if (!drv->ops->change_mpath) {
1507 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
1511 cfg80211_put_dev(drv);
1515 static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1517 struct cfg80211_registered_device *drv;
1519 struct net_device *dev;
1521 u8 *next_hop = NULL;
1523 if (!info->attrs[NL80211_ATTR_MAC])
1526 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1529 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1530 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1532 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1536 if (!drv->ops->add_mpath) {
1542 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
1546 cfg80211_put_dev(drv);
1551 static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
1553 struct cfg80211_registered_device *drv;
1555 struct net_device *dev;
1558 if (info->attrs[NL80211_ATTR_MAC])
1559 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1561 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1565 if (!drv->ops->del_mpath) {
1571 err = drv->ops->del_mpath(&drv->wiphy, dev, dst);
1575 cfg80211_put_dev(drv);
1580 static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1582 struct cfg80211_registered_device *drv;
1584 struct net_device *dev;
1585 struct bss_parameters params;
1587 memset(¶ms, 0, sizeof(params));
1588 /* default to not changing parameters */
1589 params.use_cts_prot = -1;
1590 params.use_short_preamble = -1;
1591 params.use_short_slot_time = -1;
1593 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
1594 params.use_cts_prot =
1595 nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);
1596 if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])
1597 params.use_short_preamble =
1598 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
1599 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
1600 params.use_short_slot_time =
1601 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
1603 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1607 if (!drv->ops->change_bss) {
1613 err = drv->ops->change_bss(&drv->wiphy, dev, ¶ms);
1617 cfg80211_put_dev(drv);
1622 static const struct nla_policy
1623 reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
1624 [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
1625 [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
1626 [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
1627 [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
1628 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
1629 [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
1632 static int parse_reg_rule(struct nlattr *tb[],
1633 struct ieee80211_reg_rule *reg_rule)
1635 struct ieee80211_freq_range *freq_range = ®_rule->freq_range;
1636 struct ieee80211_power_rule *power_rule = ®_rule->power_rule;
1638 if (!tb[NL80211_ATTR_REG_RULE_FLAGS])
1640 if (!tb[NL80211_ATTR_FREQ_RANGE_START])
1642 if (!tb[NL80211_ATTR_FREQ_RANGE_END])
1644 if (!tb[NL80211_ATTR_FREQ_RANGE_MAX_BW])
1646 if (!tb[NL80211_ATTR_POWER_RULE_MAX_EIRP])
1649 reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]);
1651 freq_range->start_freq_khz =
1652 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]);
1653 freq_range->end_freq_khz =
1654 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]);
1655 freq_range->max_bandwidth_khz =
1656 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]);
1658 power_rule->max_eirp =
1659 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]);
1661 if (tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN])
1662 power_rule->max_antenna_gain =
1663 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN]);
1668 static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1673 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1676 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1678 #ifdef CONFIG_WIRELESS_OLD_REGULATORY
1679 /* We ignore world regdom requests with the old regdom setup */
1680 if (is_world_regdom(data))
1683 mutex_lock(&cfg80211_drv_mutex);
1684 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, NULL);
1685 mutex_unlock(&cfg80211_drv_mutex);
1689 static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1691 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
1692 struct nlattr *nl_reg_rule;
1693 char *alpha2 = NULL;
1694 int rem_reg_rules = 0, r = 0;
1695 u32 num_rules = 0, rule_idx = 0, size_of_regd;
1696 struct ieee80211_regdomain *rd = NULL;
1698 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1701 if (!info->attrs[NL80211_ATTR_REG_RULES])
1704 alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1706 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1709 if (num_rules > NL80211_MAX_SUPP_REG_RULES)
1713 if (!reg_is_valid_request(alpha2))
1716 size_of_regd = sizeof(struct ieee80211_regdomain) +
1717 (num_rules * sizeof(struct ieee80211_reg_rule));
1719 rd = kzalloc(size_of_regd, GFP_KERNEL);
1723 rd->n_reg_rules = num_rules;
1724 rd->alpha2[0] = alpha2[0];
1725 rd->alpha2[1] = alpha2[1];
1727 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1729 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1730 nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1732 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
1738 if (rule_idx > NL80211_MAX_SUPP_REG_RULES)
1742 BUG_ON(rule_idx != num_rules);
1744 mutex_lock(&cfg80211_drv_mutex);
1746 mutex_unlock(&cfg80211_drv_mutex);
1757 static struct genl_ops nl80211_ops[] = {
1759 .cmd = NL80211_CMD_GET_WIPHY,
1760 .doit = nl80211_get_wiphy,
1761 .dumpit = nl80211_dump_wiphy,
1762 .policy = nl80211_policy,
1763 /* can be retrieved by unprivileged users */
1766 .cmd = NL80211_CMD_SET_WIPHY,
1767 .doit = nl80211_set_wiphy,
1768 .policy = nl80211_policy,
1769 .flags = GENL_ADMIN_PERM,
1772 .cmd = NL80211_CMD_GET_INTERFACE,
1773 .doit = nl80211_get_interface,
1774 .dumpit = nl80211_dump_interface,
1775 .policy = nl80211_policy,
1776 /* can be retrieved by unprivileged users */
1779 .cmd = NL80211_CMD_SET_INTERFACE,
1780 .doit = nl80211_set_interface,
1781 .policy = nl80211_policy,
1782 .flags = GENL_ADMIN_PERM,
1785 .cmd = NL80211_CMD_NEW_INTERFACE,
1786 .doit = nl80211_new_interface,
1787 .policy = nl80211_policy,
1788 .flags = GENL_ADMIN_PERM,
1791 .cmd = NL80211_CMD_DEL_INTERFACE,
1792 .doit = nl80211_del_interface,
1793 .policy = nl80211_policy,
1794 .flags = GENL_ADMIN_PERM,
1797 .cmd = NL80211_CMD_GET_KEY,
1798 .doit = nl80211_get_key,
1799 .policy = nl80211_policy,
1800 .flags = GENL_ADMIN_PERM,
1803 .cmd = NL80211_CMD_SET_KEY,
1804 .doit = nl80211_set_key,
1805 .policy = nl80211_policy,
1806 .flags = GENL_ADMIN_PERM,
1809 .cmd = NL80211_CMD_NEW_KEY,
1810 .doit = nl80211_new_key,
1811 .policy = nl80211_policy,
1812 .flags = GENL_ADMIN_PERM,
1815 .cmd = NL80211_CMD_DEL_KEY,
1816 .doit = nl80211_del_key,
1817 .policy = nl80211_policy,
1818 .flags = GENL_ADMIN_PERM,
1821 .cmd = NL80211_CMD_SET_BEACON,
1822 .policy = nl80211_policy,
1823 .flags = GENL_ADMIN_PERM,
1824 .doit = nl80211_addset_beacon,
1827 .cmd = NL80211_CMD_NEW_BEACON,
1828 .policy = nl80211_policy,
1829 .flags = GENL_ADMIN_PERM,
1830 .doit = nl80211_addset_beacon,
1833 .cmd = NL80211_CMD_DEL_BEACON,
1834 .policy = nl80211_policy,
1835 .flags = GENL_ADMIN_PERM,
1836 .doit = nl80211_del_beacon,
1839 .cmd = NL80211_CMD_GET_STATION,
1840 .doit = nl80211_get_station,
1841 .dumpit = nl80211_dump_station,
1842 .policy = nl80211_policy,
1843 .flags = GENL_ADMIN_PERM,
1846 .cmd = NL80211_CMD_SET_STATION,
1847 .doit = nl80211_set_station,
1848 .policy = nl80211_policy,
1849 .flags = GENL_ADMIN_PERM,
1852 .cmd = NL80211_CMD_NEW_STATION,
1853 .doit = nl80211_new_station,
1854 .policy = nl80211_policy,
1855 .flags = GENL_ADMIN_PERM,
1858 .cmd = NL80211_CMD_DEL_STATION,
1859 .doit = nl80211_del_station,
1860 .policy = nl80211_policy,
1861 .flags = GENL_ADMIN_PERM,
1864 .cmd = NL80211_CMD_GET_MPATH,
1865 .doit = nl80211_get_mpath,
1866 .dumpit = nl80211_dump_mpath,
1867 .policy = nl80211_policy,
1868 .flags = GENL_ADMIN_PERM,
1871 .cmd = NL80211_CMD_SET_MPATH,
1872 .doit = nl80211_set_mpath,
1873 .policy = nl80211_policy,
1874 .flags = GENL_ADMIN_PERM,
1877 .cmd = NL80211_CMD_NEW_MPATH,
1878 .doit = nl80211_new_mpath,
1879 .policy = nl80211_policy,
1880 .flags = GENL_ADMIN_PERM,
1883 .cmd = NL80211_CMD_DEL_MPATH,
1884 .doit = nl80211_del_mpath,
1885 .policy = nl80211_policy,
1886 .flags = GENL_ADMIN_PERM,
1889 .cmd = NL80211_CMD_SET_BSS,
1890 .doit = nl80211_set_bss,
1891 .policy = nl80211_policy,
1892 .flags = GENL_ADMIN_PERM,
1895 .cmd = NL80211_CMD_SET_REG,
1896 .doit = nl80211_set_reg,
1897 .policy = nl80211_policy,
1898 .flags = GENL_ADMIN_PERM,
1901 .cmd = NL80211_CMD_REQ_SET_REG,
1902 .doit = nl80211_req_set_reg,
1903 .policy = nl80211_policy,
1904 .flags = GENL_ADMIN_PERM,
1908 /* multicast groups */
1909 static struct genl_multicast_group nl80211_config_mcgrp = {
1913 /* notification functions */
1915 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
1917 struct sk_buff *msg;
1919 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1923 if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
1928 genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
1931 /* initialisation/exit functions */
1933 int nl80211_init(void)
1937 err = genl_register_family(&nl80211_fam);
1941 for (i = 0; i < ARRAY_SIZE(nl80211_ops); i++) {
1942 err = genl_register_ops(&nl80211_fam, &nl80211_ops[i]);
1947 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
1953 genl_unregister_family(&nl80211_fam);
1957 void nl80211_exit(void)
1959 genl_unregister_family(&nl80211_fam);