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);
651 cfg80211_put_dev(drv);
656 static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
658 struct cfg80211_registered_device *drv;
660 struct net_device *dev;
663 if (!info->attrs[NL80211_ATTR_KEY_IDX])
666 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
671 /* currently only support setting default key */
672 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT])
675 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
679 if (!drv->ops->set_default_key) {
685 err = drv->ops->set_default_key(&drv->wiphy, dev, key_idx);
689 cfg80211_put_dev(drv);
694 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
696 struct cfg80211_registered_device *drv;
698 struct net_device *dev;
699 struct key_params params;
703 memset(¶ms, 0, sizeof(params));
705 if (!info->attrs[NL80211_ATTR_KEY_CIPHER])
708 if (info->attrs[NL80211_ATTR_KEY_DATA]) {
709 params.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
710 params.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
713 if (info->attrs[NL80211_ATTR_KEY_IDX])
714 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
716 params.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
718 if (info->attrs[NL80211_ATTR_MAC])
719 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
725 * Disallow pairwise keys with non-zero index unless it's WEP
726 * (because current deployments use pairwise WEP keys with
727 * non-zero indizes but 802.11i clearly specifies to use zero)
729 if (mac_addr && key_idx &&
730 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
731 params.cipher != WLAN_CIPHER_SUITE_WEP104)
734 /* TODO: add definitions for the lengths to linux/ieee80211.h */
735 switch (params.cipher) {
736 case WLAN_CIPHER_SUITE_WEP40:
737 if (params.key_len != 5)
740 case WLAN_CIPHER_SUITE_TKIP:
741 if (params.key_len != 32)
744 case WLAN_CIPHER_SUITE_CCMP:
745 if (params.key_len != 16)
748 case WLAN_CIPHER_SUITE_WEP104:
749 if (params.key_len != 13)
756 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
760 if (!drv->ops->add_key) {
766 err = drv->ops->add_key(&drv->wiphy, dev, key_idx, mac_addr, ¶ms);
770 cfg80211_put_dev(drv);
775 static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
777 struct cfg80211_registered_device *drv;
779 struct net_device *dev;
783 if (info->attrs[NL80211_ATTR_KEY_IDX])
784 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
789 if (info->attrs[NL80211_ATTR_MAC])
790 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
792 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
796 if (!drv->ops->del_key) {
802 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
806 cfg80211_put_dev(drv);
811 static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
813 int (*call)(struct wiphy *wiphy, struct net_device *dev,
814 struct beacon_parameters *info);
815 struct cfg80211_registered_device *drv;
817 struct net_device *dev;
818 struct beacon_parameters params;
821 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
825 switch (info->genlhdr->cmd) {
826 case NL80211_CMD_NEW_BEACON:
827 /* these are required for NEW_BEACON */
828 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
829 !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
830 !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
835 call = drv->ops->add_beacon;
837 case NL80211_CMD_SET_BEACON:
838 call = drv->ops->set_beacon;
851 memset(¶ms, 0, sizeof(params));
853 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
855 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
859 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
861 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
865 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
866 params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
868 nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
872 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
873 params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
875 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
885 err = call(&drv->wiphy, dev, ¶ms);
889 cfg80211_put_dev(drv);
894 static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
896 struct cfg80211_registered_device *drv;
898 struct net_device *dev;
900 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
904 if (!drv->ops->del_beacon) {
910 err = drv->ops->del_beacon(&drv->wiphy, dev);
914 cfg80211_put_dev(drv);
919 static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
920 [NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
921 [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
922 [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
925 static int parse_station_flags(struct nlattr *nla, u32 *staflags)
927 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
935 if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
936 nla, sta_flags_policy))
939 *staflags = STATION_FLAG_CHANGED;
941 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
943 *staflags |= (1<<flag);
948 static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq,
949 int flags, struct net_device *dev,
950 u8 *mac_addr, struct station_info *sinfo)
953 struct nlattr *sinfoattr;
955 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
959 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
960 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
962 sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
964 goto nla_put_failure;
965 if (sinfo->filled & STATION_INFO_INACTIVE_TIME)
966 NLA_PUT_U32(msg, NL80211_STA_INFO_INACTIVE_TIME,
967 sinfo->inactive_time);
968 if (sinfo->filled & STATION_INFO_RX_BYTES)
969 NLA_PUT_U32(msg, NL80211_STA_INFO_RX_BYTES,
971 if (sinfo->filled & STATION_INFO_TX_BYTES)
972 NLA_PUT_U32(msg, NL80211_STA_INFO_TX_BYTES,
974 if (sinfo->filled & STATION_INFO_LLID)
975 NLA_PUT_U16(msg, NL80211_STA_INFO_LLID,
977 if (sinfo->filled & STATION_INFO_PLID)
978 NLA_PUT_U16(msg, NL80211_STA_INFO_PLID,
980 if (sinfo->filled & STATION_INFO_PLINK_STATE)
981 NLA_PUT_U8(msg, NL80211_STA_INFO_PLINK_STATE,
984 nla_nest_end(msg, sinfoattr);
986 return genlmsg_end(msg, hdr);
989 genlmsg_cancel(msg, hdr);
993 static int nl80211_dump_station(struct sk_buff *skb,
994 struct netlink_callback *cb)
996 struct station_info sinfo;
997 struct cfg80211_registered_device *dev;
998 struct net_device *netdev;
999 u8 mac_addr[ETH_ALEN];
1000 int ifidx = cb->args[0];
1001 int sta_idx = cb->args[1];
1005 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1006 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1011 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1014 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1019 netdev = dev_get_by_index(&init_net, ifidx);
1023 dev = cfg80211_get_dev_from_ifindex(ifidx);
1026 goto out_put_netdev;
1029 if (!dev->ops->dump_station) {
1037 err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx,
1044 if (nl80211_send_station(skb,
1045 NETLINK_CB(cb->skb).pid,
1046 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1056 cb->args[1] = sta_idx;
1061 cfg80211_put_dev(dev);
1068 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
1070 struct cfg80211_registered_device *drv;
1072 struct net_device *dev;
1073 struct station_info sinfo;
1074 struct sk_buff *msg;
1075 u8 *mac_addr = NULL;
1077 memset(&sinfo, 0, sizeof(sinfo));
1079 if (!info->attrs[NL80211_ATTR_MAC])
1082 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1084 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1088 if (!drv->ops->get_station) {
1094 err = drv->ops->get_station(&drv->wiphy, dev, mac_addr, &sinfo);
1100 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1104 if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0,
1105 dev, mac_addr, &sinfo) < 0)
1108 err = genlmsg_unicast(msg, info->snd_pid);
1115 cfg80211_put_dev(drv);
1121 * Get vlan interface making sure it is on the right wiphy.
1123 static int get_vlan(struct nlattr *vlanattr,
1124 struct cfg80211_registered_device *rdev,
1125 struct net_device **vlan)
1130 *vlan = dev_get_by_index(&init_net, nla_get_u32(vlanattr));
1133 if (!(*vlan)->ieee80211_ptr)
1135 if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy)
1141 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
1143 struct cfg80211_registered_device *drv;
1145 struct net_device *dev;
1146 struct station_parameters params;
1147 u8 *mac_addr = NULL;
1149 memset(¶ms, 0, sizeof(params));
1151 params.listen_interval = -1;
1153 if (info->attrs[NL80211_ATTR_STA_AID])
1156 if (!info->attrs[NL80211_ATTR_MAC])
1159 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1161 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
1162 params.supported_rates =
1163 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1164 params.supported_rates_len =
1165 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1168 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1169 params.listen_interval =
1170 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1172 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1174 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1176 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1177 ¶ms.station_flags))
1180 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
1181 params.plink_action =
1182 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
1184 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1188 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1192 if (!drv->ops->change_station) {
1198 err = drv->ops->change_station(&drv->wiphy, dev, mac_addr, ¶ms);
1203 dev_put(params.vlan);
1204 cfg80211_put_dev(drv);
1209 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
1211 struct cfg80211_registered_device *drv;
1213 struct net_device *dev;
1214 struct station_parameters params;
1215 u8 *mac_addr = NULL;
1217 memset(¶ms, 0, sizeof(params));
1219 if (!info->attrs[NL80211_ATTR_MAC])
1222 if (!info->attrs[NL80211_ATTR_STA_AID])
1225 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
1228 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
1231 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1232 params.supported_rates =
1233 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1234 params.supported_rates_len =
1235 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
1236 params.listen_interval =
1237 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
1238 params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
1239 if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
1241 nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
1243 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
1244 ¶ms.station_flags))
1247 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1251 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
1255 if (!drv->ops->add_station) {
1261 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, ¶ms);
1266 dev_put(params.vlan);
1267 cfg80211_put_dev(drv);
1272 static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
1274 struct cfg80211_registered_device *drv;
1276 struct net_device *dev;
1277 u8 *mac_addr = NULL;
1279 if (info->attrs[NL80211_ATTR_MAC])
1280 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1282 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1286 if (!drv->ops->del_station) {
1292 err = drv->ops->del_station(&drv->wiphy, dev, mac_addr);
1296 cfg80211_put_dev(drv);
1301 static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq,
1302 int flags, struct net_device *dev,
1303 u8 *dst, u8 *next_hop,
1304 struct mpath_info *pinfo)
1307 struct nlattr *pinfoattr;
1309 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_STATION);
1313 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
1314 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, dst);
1315 NLA_PUT(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop);
1317 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO);
1319 goto nla_put_failure;
1320 if (pinfo->filled & MPATH_INFO_FRAME_QLEN)
1321 NLA_PUT_U32(msg, NL80211_MPATH_INFO_FRAME_QLEN,
1323 if (pinfo->filled & MPATH_INFO_DSN)
1324 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DSN,
1326 if (pinfo->filled & MPATH_INFO_METRIC)
1327 NLA_PUT_U32(msg, NL80211_MPATH_INFO_METRIC,
1329 if (pinfo->filled & MPATH_INFO_EXPTIME)
1330 NLA_PUT_U32(msg, NL80211_MPATH_INFO_EXPTIME,
1332 if (pinfo->filled & MPATH_INFO_FLAGS)
1333 NLA_PUT_U8(msg, NL80211_MPATH_INFO_FLAGS,
1335 if (pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT)
1336 NLA_PUT_U32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
1337 pinfo->discovery_timeout);
1338 if (pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES)
1339 NLA_PUT_U8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES,
1340 pinfo->discovery_retries);
1342 nla_nest_end(msg, pinfoattr);
1344 return genlmsg_end(msg, hdr);
1347 genlmsg_cancel(msg, hdr);
1351 static int nl80211_dump_mpath(struct sk_buff *skb,
1352 struct netlink_callback *cb)
1354 struct mpath_info pinfo;
1355 struct cfg80211_registered_device *dev;
1356 struct net_device *netdev;
1358 u8 next_hop[ETH_ALEN];
1359 int ifidx = cb->args[0];
1360 int path_idx = cb->args[1];
1364 err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
1365 nl80211_fam.attrbuf, nl80211_fam.maxattr,
1370 if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
1373 ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
1378 netdev = dev_get_by_index(&init_net, ifidx);
1382 dev = cfg80211_get_dev_from_ifindex(ifidx);
1385 goto out_put_netdev;
1388 if (!dev->ops->dump_mpath) {
1396 err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
1397 dst, next_hop, &pinfo);
1403 if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid,
1404 cb->nlh->nlmsg_seq, NLM_F_MULTI,
1405 netdev, dst, next_hop,
1414 cb->args[1] = path_idx;
1419 cfg80211_put_dev(dev);
1426 static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
1428 struct cfg80211_registered_device *drv;
1430 struct net_device *dev;
1431 struct mpath_info pinfo;
1432 struct sk_buff *msg;
1434 u8 next_hop[ETH_ALEN];
1436 memset(&pinfo, 0, sizeof(pinfo));
1438 if (!info->attrs[NL80211_ATTR_MAC])
1441 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1443 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1447 if (!drv->ops->get_mpath) {
1453 err = drv->ops->get_mpath(&drv->wiphy, dev, dst, next_hop, &pinfo);
1459 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1463 if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0,
1464 dev, dst, next_hop, &pinfo) < 0)
1467 err = genlmsg_unicast(msg, info->snd_pid);
1474 cfg80211_put_dev(drv);
1479 static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
1481 struct cfg80211_registered_device *drv;
1483 struct net_device *dev;
1485 u8 *next_hop = NULL;
1487 if (!info->attrs[NL80211_ATTR_MAC])
1490 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1493 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1494 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1496 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1500 if (!drv->ops->change_mpath) {
1506 err = drv->ops->change_mpath(&drv->wiphy, dev, dst, next_hop);
1510 cfg80211_put_dev(drv);
1514 static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
1516 struct cfg80211_registered_device *drv;
1518 struct net_device *dev;
1520 u8 *next_hop = NULL;
1522 if (!info->attrs[NL80211_ATTR_MAC])
1525 if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
1528 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1529 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
1531 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1535 if (!drv->ops->add_mpath) {
1541 err = drv->ops->add_mpath(&drv->wiphy, dev, dst, next_hop);
1545 cfg80211_put_dev(drv);
1550 static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
1552 struct cfg80211_registered_device *drv;
1554 struct net_device *dev;
1557 if (info->attrs[NL80211_ATTR_MAC])
1558 dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
1560 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1564 if (!drv->ops->del_mpath) {
1570 err = drv->ops->del_mpath(&drv->wiphy, dev, dst);
1574 cfg80211_put_dev(drv);
1579 static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
1581 struct cfg80211_registered_device *drv;
1583 struct net_device *dev;
1584 struct bss_parameters params;
1586 memset(¶ms, 0, sizeof(params));
1587 /* default to not changing parameters */
1588 params.use_cts_prot = -1;
1589 params.use_short_preamble = -1;
1590 params.use_short_slot_time = -1;
1592 if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
1593 params.use_cts_prot =
1594 nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);
1595 if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])
1596 params.use_short_preamble =
1597 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
1598 if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
1599 params.use_short_slot_time =
1600 nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
1602 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
1606 if (!drv->ops->change_bss) {
1612 err = drv->ops->change_bss(&drv->wiphy, dev, ¶ms);
1616 cfg80211_put_dev(drv);
1621 static const struct nla_policy
1622 reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
1623 [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
1624 [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
1625 [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
1626 [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
1627 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
1628 [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
1631 static int parse_reg_rule(struct nlattr *tb[],
1632 struct ieee80211_reg_rule *reg_rule)
1634 struct ieee80211_freq_range *freq_range = ®_rule->freq_range;
1635 struct ieee80211_power_rule *power_rule = ®_rule->power_rule;
1637 if (!tb[NL80211_ATTR_REG_RULE_FLAGS])
1639 if (!tb[NL80211_ATTR_FREQ_RANGE_START])
1641 if (!tb[NL80211_ATTR_FREQ_RANGE_END])
1643 if (!tb[NL80211_ATTR_FREQ_RANGE_MAX_BW])
1645 if (!tb[NL80211_ATTR_POWER_RULE_MAX_EIRP])
1648 reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]);
1650 freq_range->start_freq_khz =
1651 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]);
1652 freq_range->end_freq_khz =
1653 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]);
1654 freq_range->max_bandwidth_khz =
1655 nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]);
1657 power_rule->max_eirp =
1658 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]);
1660 if (tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN])
1661 power_rule->max_antenna_gain =
1662 nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN]);
1667 static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
1672 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1675 data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1677 #ifdef CONFIG_WIRELESS_OLD_REGULATORY
1678 /* We ignore world regdom requests with the old regdom setup */
1679 if (is_world_regdom(data))
1682 mutex_lock(&cfg80211_drv_mutex);
1683 r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, NULL);
1684 mutex_unlock(&cfg80211_drv_mutex);
1688 static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
1690 struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
1691 struct nlattr *nl_reg_rule;
1692 char *alpha2 = NULL;
1693 int rem_reg_rules = 0, r = 0;
1694 u32 num_rules = 0, rule_idx = 0, size_of_regd;
1695 struct ieee80211_regdomain *rd = NULL;
1697 if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
1700 if (!info->attrs[NL80211_ATTR_REG_RULES])
1703 alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
1705 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1708 if (num_rules > NL80211_MAX_SUPP_REG_RULES)
1712 if (!reg_is_valid_request(alpha2))
1715 size_of_regd = sizeof(struct ieee80211_regdomain) +
1716 (num_rules * sizeof(struct ieee80211_reg_rule));
1718 rd = kzalloc(size_of_regd, GFP_KERNEL);
1722 rd->n_reg_rules = num_rules;
1723 rd->alpha2[0] = alpha2[0];
1724 rd->alpha2[1] = alpha2[1];
1726 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1728 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1729 nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1731 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
1737 if (rule_idx > NL80211_MAX_SUPP_REG_RULES)
1741 BUG_ON(rule_idx != num_rules);
1743 mutex_lock(&cfg80211_drv_mutex);
1745 mutex_unlock(&cfg80211_drv_mutex);
1756 static struct genl_ops nl80211_ops[] = {
1758 .cmd = NL80211_CMD_GET_WIPHY,
1759 .doit = nl80211_get_wiphy,
1760 .dumpit = nl80211_dump_wiphy,
1761 .policy = nl80211_policy,
1762 /* can be retrieved by unprivileged users */
1765 .cmd = NL80211_CMD_SET_WIPHY,
1766 .doit = nl80211_set_wiphy,
1767 .policy = nl80211_policy,
1768 .flags = GENL_ADMIN_PERM,
1771 .cmd = NL80211_CMD_GET_INTERFACE,
1772 .doit = nl80211_get_interface,
1773 .dumpit = nl80211_dump_interface,
1774 .policy = nl80211_policy,
1775 /* can be retrieved by unprivileged users */
1778 .cmd = NL80211_CMD_SET_INTERFACE,
1779 .doit = nl80211_set_interface,
1780 .policy = nl80211_policy,
1781 .flags = GENL_ADMIN_PERM,
1784 .cmd = NL80211_CMD_NEW_INTERFACE,
1785 .doit = nl80211_new_interface,
1786 .policy = nl80211_policy,
1787 .flags = GENL_ADMIN_PERM,
1790 .cmd = NL80211_CMD_DEL_INTERFACE,
1791 .doit = nl80211_del_interface,
1792 .policy = nl80211_policy,
1793 .flags = GENL_ADMIN_PERM,
1796 .cmd = NL80211_CMD_GET_KEY,
1797 .doit = nl80211_get_key,
1798 .policy = nl80211_policy,
1799 .flags = GENL_ADMIN_PERM,
1802 .cmd = NL80211_CMD_SET_KEY,
1803 .doit = nl80211_set_key,
1804 .policy = nl80211_policy,
1805 .flags = GENL_ADMIN_PERM,
1808 .cmd = NL80211_CMD_NEW_KEY,
1809 .doit = nl80211_new_key,
1810 .policy = nl80211_policy,
1811 .flags = GENL_ADMIN_PERM,
1814 .cmd = NL80211_CMD_DEL_KEY,
1815 .doit = nl80211_del_key,
1816 .policy = nl80211_policy,
1817 .flags = GENL_ADMIN_PERM,
1820 .cmd = NL80211_CMD_SET_BEACON,
1821 .policy = nl80211_policy,
1822 .flags = GENL_ADMIN_PERM,
1823 .doit = nl80211_addset_beacon,
1826 .cmd = NL80211_CMD_NEW_BEACON,
1827 .policy = nl80211_policy,
1828 .flags = GENL_ADMIN_PERM,
1829 .doit = nl80211_addset_beacon,
1832 .cmd = NL80211_CMD_DEL_BEACON,
1833 .policy = nl80211_policy,
1834 .flags = GENL_ADMIN_PERM,
1835 .doit = nl80211_del_beacon,
1838 .cmd = NL80211_CMD_GET_STATION,
1839 .doit = nl80211_get_station,
1840 .dumpit = nl80211_dump_station,
1841 .policy = nl80211_policy,
1842 .flags = GENL_ADMIN_PERM,
1845 .cmd = NL80211_CMD_SET_STATION,
1846 .doit = nl80211_set_station,
1847 .policy = nl80211_policy,
1848 .flags = GENL_ADMIN_PERM,
1851 .cmd = NL80211_CMD_NEW_STATION,
1852 .doit = nl80211_new_station,
1853 .policy = nl80211_policy,
1854 .flags = GENL_ADMIN_PERM,
1857 .cmd = NL80211_CMD_DEL_STATION,
1858 .doit = nl80211_del_station,
1859 .policy = nl80211_policy,
1860 .flags = GENL_ADMIN_PERM,
1863 .cmd = NL80211_CMD_GET_MPATH,
1864 .doit = nl80211_get_mpath,
1865 .dumpit = nl80211_dump_mpath,
1866 .policy = nl80211_policy,
1867 .flags = GENL_ADMIN_PERM,
1870 .cmd = NL80211_CMD_SET_MPATH,
1871 .doit = nl80211_set_mpath,
1872 .policy = nl80211_policy,
1873 .flags = GENL_ADMIN_PERM,
1876 .cmd = NL80211_CMD_NEW_MPATH,
1877 .doit = nl80211_new_mpath,
1878 .policy = nl80211_policy,
1879 .flags = GENL_ADMIN_PERM,
1882 .cmd = NL80211_CMD_DEL_MPATH,
1883 .doit = nl80211_del_mpath,
1884 .policy = nl80211_policy,
1885 .flags = GENL_ADMIN_PERM,
1888 .cmd = NL80211_CMD_SET_BSS,
1889 .doit = nl80211_set_bss,
1890 .policy = nl80211_policy,
1891 .flags = GENL_ADMIN_PERM,
1894 .cmd = NL80211_CMD_SET_REG,
1895 .doit = nl80211_set_reg,
1896 .policy = nl80211_policy,
1897 .flags = GENL_ADMIN_PERM,
1900 .cmd = NL80211_CMD_REQ_SET_REG,
1901 .doit = nl80211_req_set_reg,
1902 .policy = nl80211_policy,
1903 .flags = GENL_ADMIN_PERM,
1907 /* multicast groups */
1908 static struct genl_multicast_group nl80211_config_mcgrp = {
1912 /* notification functions */
1914 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
1916 struct sk_buff *msg;
1918 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1922 if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
1927 genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
1930 /* initialisation/exit functions */
1932 int nl80211_init(void)
1936 err = genl_register_family(&nl80211_fam);
1940 for (i = 0; i < ARRAY_SIZE(nl80211_ops); i++) {
1941 err = genl_register_ops(&nl80211_fam, &nl80211_ops[i]);
1946 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
1952 genl_unregister_family(&nl80211_fam);
1956 void nl80211_exit(void)
1958 genl_unregister_family(&nl80211_fam);