2 * This is the new netlink-based wireless configuration interface.
4 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
8 #include <linux/module.h>
10 #include <linux/mutex.h>
11 #include <linux/list.h>
12 #include <linux/if_ether.h>
13 #include <linux/ieee80211.h>
14 #include <linux/nl80211.h>
15 #include <linux/rtnetlink.h>
16 #include <linux/netlink.h>
17 #include <net/genetlink.h>
18 #include <net/cfg80211.h>
22 /* the netlink family */
23 static struct genl_family nl80211_fam = {
24 .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
25 .name = "nl80211", /* have users key off the name instead */
26 .hdrsize = 0, /* no private header */
27 .version = 1, /* no particular meaning now */
28 .maxattr = NL80211_ATTR_MAX,
31 /* internal helper: get drv and dev */
32 static int get_drv_dev_by_info_ifindex(struct genl_info *info,
33 struct cfg80211_registered_device **drv,
34 struct net_device **dev)
38 if (!info->attrs[NL80211_ATTR_IFINDEX])
41 ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]);
42 *dev = dev_get_by_index(&init_net, ifindex);
46 *drv = cfg80211_get_dev_from_ifindex(ifindex);
55 /* policy for the attributes */
56 static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
57 [NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
58 [NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
59 .len = BUS_ID_SIZE-1 },
61 [NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
62 [NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
63 [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
65 [NL80211_ATTR_MAC] = { .type = NLA_BINARY, .len = ETH_ALEN },
67 [NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
68 .len = WLAN_MAX_KEY_LEN },
69 [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
70 [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
71 [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG },
73 [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 },
74 [NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
75 [NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY,
76 .len = IEEE80211_MAX_DATA_LEN },
77 [NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
78 .len = IEEE80211_MAX_DATA_LEN },
79 [NL80211_ATTR_STA_AID] = { .type = NLA_U16 },
80 [NL80211_ATTR_STA_FLAGS] = { .type = NLA_NESTED },
81 [NL80211_ATTR_STA_LISTEN_INTERVAL] = { .type = NLA_U16 },
82 [NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY,
83 .len = NL80211_MAX_SUPP_RATES },
84 [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 },
87 /* message building helper */
88 static inline void *nl80211hdr_put(struct sk_buff *skb, u32 pid, u32 seq,
91 /* since there is no private header just add the generic one */
92 return genlmsg_put(skb, pid, seq, &nl80211_fam, flags, cmd);
95 /* netlink command implementations */
97 static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
98 struct cfg80211_registered_device *dev)
102 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY);
106 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx);
107 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy));
108 return genlmsg_end(msg, hdr);
111 return genlmsg_cancel(msg, hdr);
114 static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
117 int start = cb->args[0];
118 struct cfg80211_registered_device *dev;
120 mutex_lock(&cfg80211_drv_mutex);
121 list_for_each_entry(dev, &cfg80211_drv_list, list) {
124 if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid,
125 cb->nlh->nlmsg_seq, NLM_F_MULTI,
129 mutex_unlock(&cfg80211_drv_mutex);
136 static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
139 struct cfg80211_registered_device *dev;
141 dev = cfg80211_get_dev_from_info(info);
145 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
149 if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0)
152 cfg80211_put_dev(dev);
154 return genlmsg_unicast(msg, info->snd_pid);
159 cfg80211_put_dev(dev);
163 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
165 struct cfg80211_registered_device *rdev;
168 if (!info->attrs[NL80211_ATTR_WIPHY_NAME])
171 rdev = cfg80211_get_dev_from_info(info);
173 return PTR_ERR(rdev);
175 result = cfg80211_dev_rename(rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
177 cfg80211_put_dev(rdev);
182 static int nl80211_send_iface(struct sk_buff *msg, u32 pid, u32 seq, int flags,
183 struct net_device *dev)
187 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_INTERFACE);
191 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
192 NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name);
193 /* TODO: interface type */
194 return genlmsg_end(msg, hdr);
197 return genlmsg_cancel(msg, hdr);
200 static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *cb)
204 int wp_start = cb->args[0];
205 int if_start = cb->args[1];
206 struct cfg80211_registered_device *dev;
207 struct wireless_dev *wdev;
209 mutex_lock(&cfg80211_drv_mutex);
210 list_for_each_entry(dev, &cfg80211_drv_list, list) {
211 if (++wp_idx < wp_start)
215 mutex_lock(&dev->devlist_mtx);
216 list_for_each_entry(wdev, &dev->netdev_list, list) {
217 if (++if_idx < if_start)
219 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid,
220 cb->nlh->nlmsg_seq, NLM_F_MULTI,
224 mutex_unlock(&dev->devlist_mtx);
226 mutex_unlock(&cfg80211_drv_mutex);
228 cb->args[0] = wp_idx;
229 cb->args[1] = if_idx;
234 static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
237 struct cfg80211_registered_device *dev;
238 struct net_device *netdev;
241 err = get_drv_dev_by_info_ifindex(info, &dev, &netdev);
245 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
249 if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0, netdev) < 0)
253 cfg80211_put_dev(dev);
255 return genlmsg_unicast(msg, info->snd_pid);
261 cfg80211_put_dev(dev);
265 static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
267 struct cfg80211_registered_device *drv;
269 enum nl80211_iftype type;
270 struct net_device *dev;
272 if (info->attrs[NL80211_ATTR_IFTYPE]) {
273 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
274 if (type > NL80211_IFTYPE_MAX)
279 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
282 ifindex = dev->ifindex;
285 if (!drv->ops->change_virtual_intf) {
291 err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex, type);
295 cfg80211_put_dev(drv);
299 static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
301 struct cfg80211_registered_device *drv;
303 enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
305 if (!info->attrs[NL80211_ATTR_IFNAME])
308 if (info->attrs[NL80211_ATTR_IFTYPE]) {
309 type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
310 if (type > NL80211_IFTYPE_MAX)
314 drv = cfg80211_get_dev_from_info(info);
318 if (!drv->ops->add_virtual_intf) {
324 err = drv->ops->add_virtual_intf(&drv->wiphy,
325 nla_data(info->attrs[NL80211_ATTR_IFNAME]), type);
329 cfg80211_put_dev(drv);
333 static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
335 struct cfg80211_registered_device *drv;
337 struct net_device *dev;
339 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
342 ifindex = dev->ifindex;
345 if (!drv->ops->del_virtual_intf) {
351 err = drv->ops->del_virtual_intf(&drv->wiphy, ifindex);
355 cfg80211_put_dev(drv);
359 struct get_key_cookie {
364 static void get_key_callback(void *c, struct key_params *params)
366 struct get_key_cookie *cookie = c;
369 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_DATA,
370 params->key_len, params->key);
373 NLA_PUT(cookie->msg, NL80211_ATTR_KEY_SEQ,
374 params->seq_len, params->seq);
377 NLA_PUT_U32(cookie->msg, NL80211_ATTR_KEY_CIPHER,
385 static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
387 struct cfg80211_registered_device *drv;
389 struct net_device *dev;
392 struct get_key_cookie cookie = {
398 if (info->attrs[NL80211_ATTR_KEY_IDX])
399 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
404 if (info->attrs[NL80211_ATTR_MAC])
405 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
407 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
411 if (!drv->ops->get_key) {
416 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
422 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
423 NL80211_CMD_NEW_KEY);
432 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
433 NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_idx);
435 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
438 err = drv->ops->get_key(&drv->wiphy, dev, key_idx, mac_addr,
439 &cookie, get_key_callback);
446 goto nla_put_failure;
448 genlmsg_end(msg, hdr);
449 err = genlmsg_unicast(msg, info->snd_pid);
456 cfg80211_put_dev(drv);
461 static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
463 struct cfg80211_registered_device *drv;
465 struct net_device *dev;
468 if (!info->attrs[NL80211_ATTR_KEY_IDX])
471 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
476 /* currently only support setting default key */
477 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT])
480 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
484 if (!drv->ops->set_default_key) {
490 err = drv->ops->set_default_key(&drv->wiphy, dev, key_idx);
494 cfg80211_put_dev(drv);
499 static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
501 struct cfg80211_registered_device *drv;
503 struct net_device *dev;
504 struct key_params params;
508 memset(¶ms, 0, sizeof(params));
510 if (!info->attrs[NL80211_ATTR_KEY_CIPHER])
513 if (info->attrs[NL80211_ATTR_KEY_DATA]) {
514 params.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
515 params.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
518 if (info->attrs[NL80211_ATTR_KEY_IDX])
519 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
521 params.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
523 if (info->attrs[NL80211_ATTR_MAC])
524 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
530 * Disallow pairwise keys with non-zero index unless it's WEP
531 * (because current deployments use pairwise WEP keys with
532 * non-zero indizes but 802.11i clearly specifies to use zero)
534 if (mac_addr && key_idx &&
535 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
536 params.cipher != WLAN_CIPHER_SUITE_WEP104)
539 /* TODO: add definitions for the lengths to linux/ieee80211.h */
540 switch (params.cipher) {
541 case WLAN_CIPHER_SUITE_WEP40:
542 if (params.key_len != 5)
545 case WLAN_CIPHER_SUITE_TKIP:
546 if (params.key_len != 32)
549 case WLAN_CIPHER_SUITE_CCMP:
550 if (params.key_len != 16)
553 case WLAN_CIPHER_SUITE_WEP104:
554 if (params.key_len != 13)
561 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
565 if (!drv->ops->add_key) {
571 err = drv->ops->add_key(&drv->wiphy, dev, key_idx, mac_addr, ¶ms);
575 cfg80211_put_dev(drv);
580 static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
582 struct cfg80211_registered_device *drv;
584 struct net_device *dev;
588 if (info->attrs[NL80211_ATTR_KEY_IDX])
589 key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
594 if (info->attrs[NL80211_ATTR_MAC])
595 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
597 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
601 if (!drv->ops->del_key) {
607 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
611 cfg80211_put_dev(drv);
616 static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info)
618 int (*call)(struct wiphy *wiphy, struct net_device *dev,
619 struct beacon_parameters *info);
620 struct cfg80211_registered_device *drv;
622 struct net_device *dev;
623 struct beacon_parameters params;
626 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
630 switch (info->genlhdr->cmd) {
631 case NL80211_CMD_NEW_BEACON:
632 /* these are required for NEW_BEACON */
633 if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
634 !info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
635 !info->attrs[NL80211_ATTR_BEACON_HEAD]) {
640 call = drv->ops->add_beacon;
642 case NL80211_CMD_SET_BEACON:
643 call = drv->ops->set_beacon;
656 memset(¶ms, 0, sizeof(params));
658 if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
660 nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
664 if (info->attrs[NL80211_ATTR_DTIM_PERIOD]) {
666 nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
670 if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
671 params.head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
673 nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
677 if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
678 params.tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
680 nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
690 err = call(&drv->wiphy, dev, ¶ms);
694 cfg80211_put_dev(drv);
699 static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info)
701 struct cfg80211_registered_device *drv;
703 struct net_device *dev;
705 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
709 if (!drv->ops->del_beacon) {
715 err = drv->ops->del_beacon(&drv->wiphy, dev);
719 cfg80211_put_dev(drv);
724 static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
725 [NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
726 [NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
727 [NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
730 static int parse_station_flags(struct nlattr *nla, u32 *staflags)
732 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
740 if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
741 nla, sta_flags_policy))
744 *staflags = STATION_FLAG_CHANGED;
746 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
748 *staflags |= (1<<flag);
753 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
759 * Get vlan interface making sure it is on the right wiphy.
761 static int get_vlan(struct nlattr *vlanattr,
762 struct cfg80211_registered_device *rdev,
763 struct net_device **vlan)
768 *vlan = dev_get_by_index(&init_net, nla_get_u32(vlanattr));
771 if (!(*vlan)->ieee80211_ptr)
773 if ((*vlan)->ieee80211_ptr->wiphy != &rdev->wiphy)
779 static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
781 struct cfg80211_registered_device *drv;
783 struct net_device *dev;
784 struct station_parameters params;
787 memset(¶ms, 0, sizeof(params));
789 params.listen_interval = -1;
791 if (info->attrs[NL80211_ATTR_STA_AID])
794 if (!info->attrs[NL80211_ATTR_MAC])
797 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
799 if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
800 params.supported_rates =
801 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
802 params.supported_rates_len =
803 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
806 if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
807 params.listen_interval =
808 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
810 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
811 ¶ms.station_flags))
814 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
818 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
822 if (!drv->ops->change_station) {
828 err = drv->ops->change_station(&drv->wiphy, dev, mac_addr, ¶ms);
833 dev_put(params.vlan);
834 cfg80211_put_dev(drv);
839 static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
841 struct cfg80211_registered_device *drv;
843 struct net_device *dev;
844 struct station_parameters params;
847 memset(¶ms, 0, sizeof(params));
849 if (!info->attrs[NL80211_ATTR_MAC])
852 if (!info->attrs[NL80211_ATTR_STA_AID])
855 if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
858 if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
861 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
862 params.supported_rates =
863 nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
864 params.supported_rates_len =
865 nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
866 params.listen_interval =
867 nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
868 params.listen_interval = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
870 if (parse_station_flags(info->attrs[NL80211_ATTR_STA_FLAGS],
871 ¶ms.station_flags))
874 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
878 err = get_vlan(info->attrs[NL80211_ATTR_STA_VLAN], drv, ¶ms.vlan);
882 if (!drv->ops->add_station) {
888 err = drv->ops->add_station(&drv->wiphy, dev, mac_addr, ¶ms);
893 dev_put(params.vlan);
894 cfg80211_put_dev(drv);
899 static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
901 struct cfg80211_registered_device *drv;
903 struct net_device *dev;
906 if (info->attrs[NL80211_ATTR_MAC])
907 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
909 err = get_drv_dev_by_info_ifindex(info, &drv, &dev);
913 if (!drv->ops->del_station) {
919 err = drv->ops->del_station(&drv->wiphy, dev, mac_addr);
923 cfg80211_put_dev(drv);
928 static struct genl_ops nl80211_ops[] = {
930 .cmd = NL80211_CMD_GET_WIPHY,
931 .doit = nl80211_get_wiphy,
932 .dumpit = nl80211_dump_wiphy,
933 .policy = nl80211_policy,
934 /* can be retrieved by unprivileged users */
937 .cmd = NL80211_CMD_SET_WIPHY,
938 .doit = nl80211_set_wiphy,
939 .policy = nl80211_policy,
940 .flags = GENL_ADMIN_PERM,
943 .cmd = NL80211_CMD_GET_INTERFACE,
944 .doit = nl80211_get_interface,
945 .dumpit = nl80211_dump_interface,
946 .policy = nl80211_policy,
947 /* can be retrieved by unprivileged users */
950 .cmd = NL80211_CMD_SET_INTERFACE,
951 .doit = nl80211_set_interface,
952 .policy = nl80211_policy,
953 .flags = GENL_ADMIN_PERM,
956 .cmd = NL80211_CMD_NEW_INTERFACE,
957 .doit = nl80211_new_interface,
958 .policy = nl80211_policy,
959 .flags = GENL_ADMIN_PERM,
962 .cmd = NL80211_CMD_DEL_INTERFACE,
963 .doit = nl80211_del_interface,
964 .policy = nl80211_policy,
965 .flags = GENL_ADMIN_PERM,
968 .cmd = NL80211_CMD_GET_KEY,
969 .doit = nl80211_get_key,
970 .policy = nl80211_policy,
971 .flags = GENL_ADMIN_PERM,
974 .cmd = NL80211_CMD_SET_KEY,
975 .doit = nl80211_set_key,
976 .policy = nl80211_policy,
977 .flags = GENL_ADMIN_PERM,
980 .cmd = NL80211_CMD_NEW_KEY,
981 .doit = nl80211_new_key,
982 .policy = nl80211_policy,
983 .flags = GENL_ADMIN_PERM,
986 .cmd = NL80211_CMD_DEL_KEY,
987 .doit = nl80211_del_key,
988 .policy = nl80211_policy,
989 .flags = GENL_ADMIN_PERM,
992 .cmd = NL80211_CMD_SET_BEACON,
993 .policy = nl80211_policy,
994 .flags = GENL_ADMIN_PERM,
995 .doit = nl80211_addset_beacon,
998 .cmd = NL80211_CMD_NEW_BEACON,
999 .policy = nl80211_policy,
1000 .flags = GENL_ADMIN_PERM,
1001 .doit = nl80211_addset_beacon,
1004 .cmd = NL80211_CMD_DEL_BEACON,
1005 .policy = nl80211_policy,
1006 .flags = GENL_ADMIN_PERM,
1007 .doit = nl80211_del_beacon,
1010 .cmd = NL80211_CMD_GET_STATION,
1011 .doit = nl80211_get_station,
1012 /* TODO: implement dumpit */
1013 .policy = nl80211_policy,
1014 .flags = GENL_ADMIN_PERM,
1017 .cmd = NL80211_CMD_SET_STATION,
1018 .doit = nl80211_set_station,
1019 .policy = nl80211_policy,
1020 .flags = GENL_ADMIN_PERM,
1023 .cmd = NL80211_CMD_NEW_STATION,
1024 .doit = nl80211_new_station,
1025 .policy = nl80211_policy,
1026 .flags = GENL_ADMIN_PERM,
1029 .cmd = NL80211_CMD_DEL_STATION,
1030 .doit = nl80211_del_station,
1031 .policy = nl80211_policy,
1032 .flags = GENL_ADMIN_PERM,
1036 /* multicast groups */
1037 static struct genl_multicast_group nl80211_config_mcgrp = {
1041 /* notification functions */
1043 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
1045 struct sk_buff *msg;
1047 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1051 if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
1056 genlmsg_multicast(msg, 0, nl80211_config_mcgrp.id, GFP_KERNEL);
1059 /* initialisation/exit functions */
1061 int nl80211_init(void)
1065 err = genl_register_family(&nl80211_fam);
1069 for (i = 0; i < ARRAY_SIZE(nl80211_ops); i++) {
1070 err = genl_register_ops(&nl80211_fam, &nl80211_ops[i]);
1075 err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
1081 genl_unregister_family(&nl80211_fam);
1085 void nl80211_exit(void)
1087 genl_unregister_family(&nl80211_fam);