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 nlattr
**attrs
,
33 struct cfg80211_registered_device
**drv
,
34 struct net_device
**dev
)
38 if (!attrs
[NL80211_ATTR_IFINDEX
])
41 ifindex
= nla_get_u32(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_PLINK_ACTION
] = { .type
= NLA_U8
},
85 [NL80211_ATTR_STA_VLAN
] = { .type
= NLA_U32
},
86 [NL80211_ATTR_MNTR_FLAGS
] = { .type
= NLA_NESTED
},
87 [NL80211_ATTR_MESH_ID
] = { .type
= NLA_BINARY
,
88 .len
= IEEE80211_MAX_MESH_ID_LEN
},
89 [NL80211_ATTR_MPATH_NEXT_HOP
] = { .type
= NLA_U32
},
92 /* message building helper */
93 static inline void *nl80211hdr_put(struct sk_buff
*skb
, u32 pid
, u32 seq
,
96 /* since there is no private header just add the generic one */
97 return genlmsg_put(skb
, pid
, seq
, &nl80211_fam
, flags
, cmd
);
100 /* netlink command implementations */
102 static int nl80211_send_wiphy(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
103 struct cfg80211_registered_device
*dev
)
106 struct nlattr
*nl_bands
, *nl_band
;
107 struct nlattr
*nl_freqs
, *nl_freq
;
108 struct nlattr
*nl_rates
, *nl_rate
;
109 enum ieee80211_band band
;
110 struct ieee80211_channel
*chan
;
111 struct ieee80211_rate
*rate
;
114 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_WIPHY
);
118 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY
, dev
->idx
);
119 NLA_PUT_STRING(msg
, NL80211_ATTR_WIPHY_NAME
, wiphy_name(&dev
->wiphy
));
121 nl_bands
= nla_nest_start(msg
, NL80211_ATTR_WIPHY_BANDS
);
123 goto nla_put_failure
;
125 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
126 if (!dev
->wiphy
.bands
[band
])
129 nl_band
= nla_nest_start(msg
, band
);
131 goto nla_put_failure
;
133 /* add frequencies */
134 nl_freqs
= nla_nest_start(msg
, NL80211_BAND_ATTR_FREQS
);
136 goto nla_put_failure
;
138 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_channels
; i
++) {
139 nl_freq
= nla_nest_start(msg
, i
);
141 goto nla_put_failure
;
143 chan
= &dev
->wiphy
.bands
[band
]->channels
[i
];
144 NLA_PUT_U32(msg
, NL80211_FREQUENCY_ATTR_FREQ
,
147 if (chan
->flags
& IEEE80211_CHAN_DISABLED
)
148 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_DISABLED
);
149 if (chan
->flags
& IEEE80211_CHAN_PASSIVE_SCAN
)
150 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
);
151 if (chan
->flags
& IEEE80211_CHAN_NO_IBSS
)
152 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_NO_IBSS
);
153 if (chan
->flags
& IEEE80211_CHAN_RADAR
)
154 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_RADAR
);
156 nla_nest_end(msg
, nl_freq
);
159 nla_nest_end(msg
, nl_freqs
);
162 nl_rates
= nla_nest_start(msg
, NL80211_BAND_ATTR_RATES
);
164 goto nla_put_failure
;
166 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_bitrates
; i
++) {
167 nl_rate
= nla_nest_start(msg
, i
);
169 goto nla_put_failure
;
171 rate
= &dev
->wiphy
.bands
[band
]->bitrates
[i
];
172 NLA_PUT_U32(msg
, NL80211_BITRATE_ATTR_RATE
,
174 if (rate
->flags
& IEEE80211_RATE_SHORT_PREAMBLE
)
176 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
);
178 nla_nest_end(msg
, nl_rate
);
181 nla_nest_end(msg
, nl_rates
);
183 nla_nest_end(msg
, nl_band
);
185 nla_nest_end(msg
, nl_bands
);
187 return genlmsg_end(msg
, hdr
);
190 genlmsg_cancel(msg
, hdr
);
194 static int nl80211_dump_wiphy(struct sk_buff
*skb
, struct netlink_callback
*cb
)
197 int start
= cb
->args
[0];
198 struct cfg80211_registered_device
*dev
;
200 mutex_lock(&cfg80211_drv_mutex
);
201 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
204 if (nl80211_send_wiphy(skb
, NETLINK_CB(cb
->skb
).pid
,
205 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
211 mutex_unlock(&cfg80211_drv_mutex
);
218 static int nl80211_get_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
221 struct cfg80211_registered_device
*dev
;
223 dev
= cfg80211_get_dev_from_info(info
);
227 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
231 if (nl80211_send_wiphy(msg
, info
->snd_pid
, info
->snd_seq
, 0, dev
) < 0)
234 cfg80211_put_dev(dev
);
236 return genlmsg_unicast(msg
, info
->snd_pid
);
241 cfg80211_put_dev(dev
);
245 static int nl80211_set_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
247 struct cfg80211_registered_device
*rdev
;
250 if (!info
->attrs
[NL80211_ATTR_WIPHY_NAME
])
253 rdev
= cfg80211_get_dev_from_info(info
);
255 return PTR_ERR(rdev
);
257 result
= cfg80211_dev_rename(rdev
, nla_data(info
->attrs
[NL80211_ATTR_WIPHY_NAME
]));
259 cfg80211_put_dev(rdev
);
264 static int nl80211_send_iface(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
265 struct net_device
*dev
)
269 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_INTERFACE
);
273 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
274 NLA_PUT_STRING(msg
, NL80211_ATTR_IFNAME
, dev
->name
);
275 /* TODO: interface type */
276 return genlmsg_end(msg
, hdr
);
279 genlmsg_cancel(msg
, hdr
);
283 static int nl80211_dump_interface(struct sk_buff
*skb
, struct netlink_callback
*cb
)
287 int wp_start
= cb
->args
[0];
288 int if_start
= cb
->args
[1];
289 struct cfg80211_registered_device
*dev
;
290 struct wireless_dev
*wdev
;
292 mutex_lock(&cfg80211_drv_mutex
);
293 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
294 if (wp_idx
< wp_start
) {
300 mutex_lock(&dev
->devlist_mtx
);
301 list_for_each_entry(wdev
, &dev
->netdev_list
, list
) {
302 if (if_idx
< if_start
) {
306 if (nl80211_send_iface(skb
, NETLINK_CB(cb
->skb
).pid
,
307 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
309 mutex_unlock(&dev
->devlist_mtx
);
314 mutex_unlock(&dev
->devlist_mtx
);
319 mutex_unlock(&cfg80211_drv_mutex
);
321 cb
->args
[0] = wp_idx
;
322 cb
->args
[1] = if_idx
;
327 static int nl80211_get_interface(struct sk_buff
*skb
, struct genl_info
*info
)
330 struct cfg80211_registered_device
*dev
;
331 struct net_device
*netdev
;
334 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &dev
, &netdev
);
338 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
342 if (nl80211_send_iface(msg
, info
->snd_pid
, info
->snd_seq
, 0, netdev
) < 0)
346 cfg80211_put_dev(dev
);
348 return genlmsg_unicast(msg
, info
->snd_pid
);
354 cfg80211_put_dev(dev
);
358 static const struct nla_policy mntr_flags_policy
[NL80211_MNTR_FLAG_MAX
+ 1] = {
359 [NL80211_MNTR_FLAG_FCSFAIL
] = { .type
= NLA_FLAG
},
360 [NL80211_MNTR_FLAG_PLCPFAIL
] = { .type
= NLA_FLAG
},
361 [NL80211_MNTR_FLAG_CONTROL
] = { .type
= NLA_FLAG
},
362 [NL80211_MNTR_FLAG_OTHER_BSS
] = { .type
= NLA_FLAG
},
363 [NL80211_MNTR_FLAG_COOK_FRAMES
] = { .type
= NLA_FLAG
},
366 static int parse_monitor_flags(struct nlattr
*nla
, u32
*mntrflags
)
368 struct nlattr
*flags
[NL80211_MNTR_FLAG_MAX
+ 1];
376 if (nla_parse_nested(flags
, NL80211_MNTR_FLAG_MAX
,
377 nla
, mntr_flags_policy
))
380 for (flag
= 1; flag
<= NL80211_MNTR_FLAG_MAX
; flag
++)
382 *mntrflags
|= (1<<flag
);
387 static int nl80211_set_interface(struct sk_buff
*skb
, struct genl_info
*info
)
389 struct cfg80211_registered_device
*drv
;
390 struct vif_params params
;
392 enum nl80211_iftype type
;
393 struct net_device
*dev
;
396 memset(¶ms
, 0, sizeof(params
));
398 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
399 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
400 if (type
> NL80211_IFTYPE_MAX
)
405 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
408 ifindex
= dev
->ifindex
;
411 if (!drv
->ops
->change_virtual_intf
) {
416 if (type
== NL80211_IFTYPE_MESH_POINT
&&
417 info
->attrs
[NL80211_ATTR_MESH_ID
]) {
418 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
419 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
423 err
= parse_monitor_flags(type
== NL80211_IFTYPE_MONITOR
?
424 info
->attrs
[NL80211_ATTR_MNTR_FLAGS
] : NULL
,
426 err
= drv
->ops
->change_virtual_intf(&drv
->wiphy
, ifindex
,
427 type
, err
? NULL
: &flags
, ¶ms
);
431 cfg80211_put_dev(drv
);
435 static int nl80211_new_interface(struct sk_buff
*skb
, struct genl_info
*info
)
437 struct cfg80211_registered_device
*drv
;
438 struct vif_params params
;
440 enum nl80211_iftype type
= NL80211_IFTYPE_UNSPECIFIED
;
443 memset(¶ms
, 0, sizeof(params
));
445 if (!info
->attrs
[NL80211_ATTR_IFNAME
])
448 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
449 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
450 if (type
> NL80211_IFTYPE_MAX
)
454 drv
= cfg80211_get_dev_from_info(info
);
458 if (!drv
->ops
->add_virtual_intf
) {
463 if (type
== NL80211_IFTYPE_MESH_POINT
&&
464 info
->attrs
[NL80211_ATTR_MESH_ID
]) {
465 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
466 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
470 err
= parse_monitor_flags(type
== NL80211_IFTYPE_MONITOR
?
471 info
->attrs
[NL80211_ATTR_MNTR_FLAGS
] : NULL
,
473 err
= drv
->ops
->add_virtual_intf(&drv
->wiphy
,
474 nla_data(info
->attrs
[NL80211_ATTR_IFNAME
]),
475 type
, err
? NULL
: &flags
, ¶ms
);
480 cfg80211_put_dev(drv
);
484 static int nl80211_del_interface(struct sk_buff
*skb
, struct genl_info
*info
)
486 struct cfg80211_registered_device
*drv
;
488 struct net_device
*dev
;
490 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
493 ifindex
= dev
->ifindex
;
496 if (!drv
->ops
->del_virtual_intf
) {
502 err
= drv
->ops
->del_virtual_intf(&drv
->wiphy
, ifindex
);
506 cfg80211_put_dev(drv
);
510 struct get_key_cookie
{
515 static void get_key_callback(void *c
, struct key_params
*params
)
517 struct get_key_cookie
*cookie
= c
;
520 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_DATA
,
521 params
->key_len
, params
->key
);
524 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_SEQ
,
525 params
->seq_len
, params
->seq
);
528 NLA_PUT_U32(cookie
->msg
, NL80211_ATTR_KEY_CIPHER
,
536 static int nl80211_get_key(struct sk_buff
*skb
, struct genl_info
*info
)
538 struct cfg80211_registered_device
*drv
;
540 struct net_device
*dev
;
543 struct get_key_cookie cookie
= {
549 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
550 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
555 if (info
->attrs
[NL80211_ATTR_MAC
])
556 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
558 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
562 if (!drv
->ops
->get_key
) {
567 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
573 hdr
= nl80211hdr_put(msg
, info
->snd_pid
, info
->snd_seq
, 0,
574 NL80211_CMD_NEW_KEY
);
583 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
584 NLA_PUT_U8(msg
, NL80211_ATTR_KEY_IDX
, key_idx
);
586 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
589 err
= drv
->ops
->get_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
,
590 &cookie
, get_key_callback
);
597 goto nla_put_failure
;
599 genlmsg_end(msg
, hdr
);
600 err
= genlmsg_unicast(msg
, info
->snd_pid
);
607 cfg80211_put_dev(drv
);
612 static int nl80211_set_key(struct sk_buff
*skb
, struct genl_info
*info
)
614 struct cfg80211_registered_device
*drv
;
616 struct net_device
*dev
;
619 if (!info
->attrs
[NL80211_ATTR_KEY_IDX
])
622 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
627 /* currently only support setting default key */
628 if (!info
->attrs
[NL80211_ATTR_KEY_DEFAULT
])
631 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
635 if (!drv
->ops
->set_default_key
) {
641 err
= drv
->ops
->set_default_key(&drv
->wiphy
, dev
, key_idx
);
645 cfg80211_put_dev(drv
);
650 static int nl80211_new_key(struct sk_buff
*skb
, struct genl_info
*info
)
652 struct cfg80211_registered_device
*drv
;
654 struct net_device
*dev
;
655 struct key_params params
;
659 memset(¶ms
, 0, sizeof(params
));
661 if (!info
->attrs
[NL80211_ATTR_KEY_CIPHER
])
664 if (info
->attrs
[NL80211_ATTR_KEY_DATA
]) {
665 params
.key
= nla_data(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
666 params
.key_len
= nla_len(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
669 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
670 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
672 params
.cipher
= nla_get_u32(info
->attrs
[NL80211_ATTR_KEY_CIPHER
]);
674 if (info
->attrs
[NL80211_ATTR_MAC
])
675 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
681 * Disallow pairwise keys with non-zero index unless it's WEP
682 * (because current deployments use pairwise WEP keys with
683 * non-zero indizes but 802.11i clearly specifies to use zero)
685 if (mac_addr
&& key_idx
&&
686 params
.cipher
!= WLAN_CIPHER_SUITE_WEP40
&&
687 params
.cipher
!= WLAN_CIPHER_SUITE_WEP104
)
690 /* TODO: add definitions for the lengths to linux/ieee80211.h */
691 switch (params
.cipher
) {
692 case WLAN_CIPHER_SUITE_WEP40
:
693 if (params
.key_len
!= 5)
696 case WLAN_CIPHER_SUITE_TKIP
:
697 if (params
.key_len
!= 32)
700 case WLAN_CIPHER_SUITE_CCMP
:
701 if (params
.key_len
!= 16)
704 case WLAN_CIPHER_SUITE_WEP104
:
705 if (params
.key_len
!= 13)
712 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
716 if (!drv
->ops
->add_key
) {
722 err
= drv
->ops
->add_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
, ¶ms
);
726 cfg80211_put_dev(drv
);
731 static int nl80211_del_key(struct sk_buff
*skb
, struct genl_info
*info
)
733 struct cfg80211_registered_device
*drv
;
735 struct net_device
*dev
;
739 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
740 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
745 if (info
->attrs
[NL80211_ATTR_MAC
])
746 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
748 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
752 if (!drv
->ops
->del_key
) {
758 err
= drv
->ops
->del_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
);
762 cfg80211_put_dev(drv
);
767 static int nl80211_addset_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
769 int (*call
)(struct wiphy
*wiphy
, struct net_device
*dev
,
770 struct beacon_parameters
*info
);
771 struct cfg80211_registered_device
*drv
;
773 struct net_device
*dev
;
774 struct beacon_parameters params
;
777 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
781 switch (info
->genlhdr
->cmd
) {
782 case NL80211_CMD_NEW_BEACON
:
783 /* these are required for NEW_BEACON */
784 if (!info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
] ||
785 !info
->attrs
[NL80211_ATTR_DTIM_PERIOD
] ||
786 !info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
791 call
= drv
->ops
->add_beacon
;
793 case NL80211_CMD_SET_BEACON
:
794 call
= drv
->ops
->set_beacon
;
807 memset(¶ms
, 0, sizeof(params
));
809 if (info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]) {
811 nla_get_u32(info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]);
815 if (info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]) {
817 nla_get_u32(info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]);
821 if (info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
822 params
.head
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
824 nla_len(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
828 if (info
->attrs
[NL80211_ATTR_BEACON_TAIL
]) {
829 params
.tail
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
831 nla_len(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
841 err
= call(&drv
->wiphy
, dev
, ¶ms
);
845 cfg80211_put_dev(drv
);
850 static int nl80211_del_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
852 struct cfg80211_registered_device
*drv
;
854 struct net_device
*dev
;
856 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
860 if (!drv
->ops
->del_beacon
) {
866 err
= drv
->ops
->del_beacon(&drv
->wiphy
, dev
);
870 cfg80211_put_dev(drv
);
875 static const struct nla_policy sta_flags_policy
[NL80211_STA_FLAG_MAX
+ 1] = {
876 [NL80211_STA_FLAG_AUTHORIZED
] = { .type
= NLA_FLAG
},
877 [NL80211_STA_FLAG_SHORT_PREAMBLE
] = { .type
= NLA_FLAG
},
878 [NL80211_STA_FLAG_WME
] = { .type
= NLA_FLAG
},
881 static int parse_station_flags(struct nlattr
*nla
, u32
*staflags
)
883 struct nlattr
*flags
[NL80211_STA_FLAG_MAX
+ 1];
891 if (nla_parse_nested(flags
, NL80211_STA_FLAG_MAX
,
892 nla
, sta_flags_policy
))
895 *staflags
= STATION_FLAG_CHANGED
;
897 for (flag
= 1; flag
<= NL80211_STA_FLAG_MAX
; flag
++)
899 *staflags
|= (1<<flag
);
904 static int nl80211_send_station(struct sk_buff
*msg
, u32 pid
, u32 seq
,
905 int flags
, struct net_device
*dev
,
906 u8
*mac_addr
, struct station_info
*sinfo
)
909 struct nlattr
*sinfoattr
;
911 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
915 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
916 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
918 sinfoattr
= nla_nest_start(msg
, NL80211_ATTR_STA_INFO
);
920 goto nla_put_failure
;
921 if (sinfo
->filled
& STATION_INFO_INACTIVE_TIME
)
922 NLA_PUT_U32(msg
, NL80211_STA_INFO_INACTIVE_TIME
,
923 sinfo
->inactive_time
);
924 if (sinfo
->filled
& STATION_INFO_RX_BYTES
)
925 NLA_PUT_U32(msg
, NL80211_STA_INFO_RX_BYTES
,
927 if (sinfo
->filled
& STATION_INFO_TX_BYTES
)
928 NLA_PUT_U32(msg
, NL80211_STA_INFO_TX_BYTES
,
930 if (sinfo
->filled
& STATION_INFO_LLID
)
931 NLA_PUT_U16(msg
, NL80211_STA_INFO_LLID
,
933 if (sinfo
->filled
& STATION_INFO_PLID
)
934 NLA_PUT_U16(msg
, NL80211_STA_INFO_PLID
,
936 if (sinfo
->filled
& STATION_INFO_PLINK_STATE
)
937 NLA_PUT_U8(msg
, NL80211_STA_INFO_PLINK_STATE
,
940 nla_nest_end(msg
, sinfoattr
);
942 return genlmsg_end(msg
, hdr
);
945 genlmsg_cancel(msg
, hdr
);
949 static int nl80211_dump_station(struct sk_buff
*skb
,
950 struct netlink_callback
*cb
)
952 struct station_info sinfo
;
953 struct cfg80211_registered_device
*dev
;
954 struct net_device
*netdev
;
955 u8 mac_addr
[ETH_ALEN
];
956 int ifidx
= cb
->args
[0];
957 int sta_idx
= cb
->args
[1];
961 err
= nlmsg_parse(cb
->nlh
, GENL_HDRLEN
+ nl80211_fam
.hdrsize
,
962 nl80211_fam
.attrbuf
, nl80211_fam
.maxattr
,
967 if (!nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
])
970 ifidx
= nla_get_u32(nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
]);
975 netdev
= dev_get_by_index(&init_net
, ifidx
);
979 dev
= cfg80211_get_dev_from_ifindex(ifidx
);
985 if (!dev
->ops
->dump_station
) {
993 err
= dev
->ops
->dump_station(&dev
->wiphy
, netdev
, sta_idx
,
1000 if (nl80211_send_station(skb
,
1001 NETLINK_CB(cb
->skb
).pid
,
1002 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
1012 cb
->args
[1] = sta_idx
;
1017 cfg80211_put_dev(dev
);
1024 static int nl80211_get_station(struct sk_buff
*skb
, struct genl_info
*info
)
1026 struct cfg80211_registered_device
*drv
;
1028 struct net_device
*dev
;
1029 struct station_info sinfo
;
1030 struct sk_buff
*msg
;
1031 u8
*mac_addr
= NULL
;
1033 memset(&sinfo
, 0, sizeof(sinfo
));
1035 if (!info
->attrs
[NL80211_ATTR_MAC
])
1038 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1040 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1044 if (!drv
->ops
->get_station
) {
1050 err
= drv
->ops
->get_station(&drv
->wiphy
, dev
, mac_addr
, &sinfo
);
1056 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1060 if (nl80211_send_station(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1061 dev
, mac_addr
, &sinfo
) < 0)
1064 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1071 cfg80211_put_dev(drv
);
1077 * Get vlan interface making sure it is on the right wiphy.
1079 static int get_vlan(struct nlattr
*vlanattr
,
1080 struct cfg80211_registered_device
*rdev
,
1081 struct net_device
**vlan
)
1086 *vlan
= dev_get_by_index(&init_net
, nla_get_u32(vlanattr
));
1089 if (!(*vlan
)->ieee80211_ptr
)
1091 if ((*vlan
)->ieee80211_ptr
->wiphy
!= &rdev
->wiphy
)
1097 static int nl80211_set_station(struct sk_buff
*skb
, struct genl_info
*info
)
1099 struct cfg80211_registered_device
*drv
;
1101 struct net_device
*dev
;
1102 struct station_parameters params
;
1103 u8
*mac_addr
= NULL
;
1105 memset(¶ms
, 0, sizeof(params
));
1107 params
.listen_interval
= -1;
1109 if (info
->attrs
[NL80211_ATTR_STA_AID
])
1112 if (!info
->attrs
[NL80211_ATTR_MAC
])
1115 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1117 if (info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]) {
1118 params
.supported_rates
=
1119 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1120 params
.supported_rates_len
=
1121 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1124 if (info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1125 params
.listen_interval
=
1126 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1128 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1129 ¶ms
.station_flags
))
1132 if (info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
])
1133 params
.plink_action
=
1134 nla_get_u8(info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
]);
1136 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1140 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1144 if (!drv
->ops
->change_station
) {
1150 err
= drv
->ops
->change_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1155 dev_put(params
.vlan
);
1156 cfg80211_put_dev(drv
);
1161 static int nl80211_new_station(struct sk_buff
*skb
, struct genl_info
*info
)
1163 struct cfg80211_registered_device
*drv
;
1165 struct net_device
*dev
;
1166 struct station_parameters params
;
1167 u8
*mac_addr
= NULL
;
1169 memset(¶ms
, 0, sizeof(params
));
1171 if (!info
->attrs
[NL80211_ATTR_MAC
])
1174 if (!info
->attrs
[NL80211_ATTR_STA_AID
])
1177 if (!info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1180 if (!info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
])
1183 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1184 params
.supported_rates
=
1185 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1186 params
.supported_rates_len
=
1187 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1188 params
.listen_interval
=
1189 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1190 params
.aid
= nla_get_u16(info
->attrs
[NL80211_ATTR_STA_AID
]);
1192 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1193 ¶ms
.station_flags
))
1196 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1200 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1204 if (!drv
->ops
->add_station
) {
1210 err
= drv
->ops
->add_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1215 dev_put(params
.vlan
);
1216 cfg80211_put_dev(drv
);
1221 static int nl80211_del_station(struct sk_buff
*skb
, struct genl_info
*info
)
1223 struct cfg80211_registered_device
*drv
;
1225 struct net_device
*dev
;
1226 u8
*mac_addr
= NULL
;
1228 if (info
->attrs
[NL80211_ATTR_MAC
])
1229 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1231 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1235 if (!drv
->ops
->del_station
) {
1241 err
= drv
->ops
->del_station(&drv
->wiphy
, dev
, mac_addr
);
1245 cfg80211_put_dev(drv
);
1250 static int nl80211_send_mpath(struct sk_buff
*msg
, u32 pid
, u32 seq
,
1251 int flags
, struct net_device
*dev
,
1252 u8
*dst
, u8
*next_hop
,
1253 struct mpath_info
*pinfo
)
1256 struct nlattr
*pinfoattr
;
1258 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
1262 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
1263 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, dst
);
1264 NLA_PUT(msg
, NL80211_ATTR_MPATH_NEXT_HOP
, ETH_ALEN
, next_hop
);
1266 pinfoattr
= nla_nest_start(msg
, NL80211_ATTR_MPATH_INFO
);
1268 goto nla_put_failure
;
1269 if (pinfo
->filled
& MPATH_INFO_FRAME_QLEN
)
1270 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_FRAME_QLEN
,
1272 if (pinfo
->filled
& MPATH_INFO_DSN
)
1273 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DSN
,
1275 if (pinfo
->filled
& MPATH_INFO_METRIC
)
1276 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_METRIC
,
1278 if (pinfo
->filled
& MPATH_INFO_EXPTIME
)
1279 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_EXPTIME
,
1281 if (pinfo
->filled
& MPATH_INFO_FLAGS
)
1282 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_FLAGS
,
1284 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_TIMEOUT
)
1285 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT
,
1286 pinfo
->discovery_timeout
);
1287 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_RETRIES
)
1288 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_DISCOVERY_RETRIES
,
1289 pinfo
->discovery_retries
);
1291 nla_nest_end(msg
, pinfoattr
);
1293 return genlmsg_end(msg
, hdr
);
1296 genlmsg_cancel(msg
, hdr
);
1300 static int nl80211_dump_mpath(struct sk_buff
*skb
,
1301 struct netlink_callback
*cb
)
1303 struct mpath_info pinfo
;
1304 struct cfg80211_registered_device
*dev
;
1305 struct net_device
*netdev
;
1307 u8 next_hop
[ETH_ALEN
];
1308 int ifidx
= cb
->args
[0];
1309 int path_idx
= cb
->args
[1];
1313 err
= nlmsg_parse(cb
->nlh
, GENL_HDRLEN
+ nl80211_fam
.hdrsize
,
1314 nl80211_fam
.attrbuf
, nl80211_fam
.maxattr
,
1319 if (!nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
])
1322 ifidx
= nla_get_u32(nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
]);
1327 netdev
= dev_get_by_index(&init_net
, ifidx
);
1331 dev
= cfg80211_get_dev_from_ifindex(ifidx
);
1334 goto out_put_netdev
;
1337 if (!dev
->ops
->dump_mpath
) {
1345 err
= dev
->ops
->dump_mpath(&dev
->wiphy
, netdev
, path_idx
,
1346 dst
, next_hop
, &pinfo
);
1352 if (nl80211_send_mpath(skb
, NETLINK_CB(cb
->skb
).pid
,
1353 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
1354 netdev
, dst
, next_hop
,
1363 cb
->args
[1] = path_idx
;
1368 cfg80211_put_dev(dev
);
1375 static int nl80211_get_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1377 struct cfg80211_registered_device
*drv
;
1379 struct net_device
*dev
;
1380 struct mpath_info pinfo
;
1381 struct sk_buff
*msg
;
1383 u8 next_hop
[ETH_ALEN
];
1385 memset(&pinfo
, 0, sizeof(pinfo
));
1387 if (!info
->attrs
[NL80211_ATTR_MAC
])
1390 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1392 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1396 if (!drv
->ops
->get_mpath
) {
1402 err
= drv
->ops
->get_mpath(&drv
->wiphy
, dev
, dst
, next_hop
, &pinfo
);
1408 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1412 if (nl80211_send_mpath(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1413 dev
, dst
, next_hop
, &pinfo
) < 0)
1416 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1423 cfg80211_put_dev(drv
);
1428 static int nl80211_set_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1430 struct cfg80211_registered_device
*drv
;
1432 struct net_device
*dev
;
1434 u8
*next_hop
= NULL
;
1436 if (!info
->attrs
[NL80211_ATTR_MAC
])
1439 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1442 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1443 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1445 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1449 if (!drv
->ops
->change_mpath
) {
1455 err
= drv
->ops
->change_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1459 cfg80211_put_dev(drv
);
1463 static int nl80211_new_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1465 struct cfg80211_registered_device
*drv
;
1467 struct net_device
*dev
;
1469 u8
*next_hop
= NULL
;
1471 if (!info
->attrs
[NL80211_ATTR_MAC
])
1474 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1477 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1478 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1480 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1484 if (!drv
->ops
->add_mpath
) {
1490 err
= drv
->ops
->add_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1494 cfg80211_put_dev(drv
);
1499 static int nl80211_del_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1501 struct cfg80211_registered_device
*drv
;
1503 struct net_device
*dev
;
1506 if (info
->attrs
[NL80211_ATTR_MAC
])
1507 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1509 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1513 if (!drv
->ops
->del_mpath
) {
1519 err
= drv
->ops
->del_mpath(&drv
->wiphy
, dev
, dst
);
1523 cfg80211_put_dev(drv
);
1528 static struct genl_ops nl80211_ops
[] = {
1530 .cmd
= NL80211_CMD_GET_WIPHY
,
1531 .doit
= nl80211_get_wiphy
,
1532 .dumpit
= nl80211_dump_wiphy
,
1533 .policy
= nl80211_policy
,
1534 /* can be retrieved by unprivileged users */
1537 .cmd
= NL80211_CMD_SET_WIPHY
,
1538 .doit
= nl80211_set_wiphy
,
1539 .policy
= nl80211_policy
,
1540 .flags
= GENL_ADMIN_PERM
,
1543 .cmd
= NL80211_CMD_GET_INTERFACE
,
1544 .doit
= nl80211_get_interface
,
1545 .dumpit
= nl80211_dump_interface
,
1546 .policy
= nl80211_policy
,
1547 /* can be retrieved by unprivileged users */
1550 .cmd
= NL80211_CMD_SET_INTERFACE
,
1551 .doit
= nl80211_set_interface
,
1552 .policy
= nl80211_policy
,
1553 .flags
= GENL_ADMIN_PERM
,
1556 .cmd
= NL80211_CMD_NEW_INTERFACE
,
1557 .doit
= nl80211_new_interface
,
1558 .policy
= nl80211_policy
,
1559 .flags
= GENL_ADMIN_PERM
,
1562 .cmd
= NL80211_CMD_DEL_INTERFACE
,
1563 .doit
= nl80211_del_interface
,
1564 .policy
= nl80211_policy
,
1565 .flags
= GENL_ADMIN_PERM
,
1568 .cmd
= NL80211_CMD_GET_KEY
,
1569 .doit
= nl80211_get_key
,
1570 .policy
= nl80211_policy
,
1571 .flags
= GENL_ADMIN_PERM
,
1574 .cmd
= NL80211_CMD_SET_KEY
,
1575 .doit
= nl80211_set_key
,
1576 .policy
= nl80211_policy
,
1577 .flags
= GENL_ADMIN_PERM
,
1580 .cmd
= NL80211_CMD_NEW_KEY
,
1581 .doit
= nl80211_new_key
,
1582 .policy
= nl80211_policy
,
1583 .flags
= GENL_ADMIN_PERM
,
1586 .cmd
= NL80211_CMD_DEL_KEY
,
1587 .doit
= nl80211_del_key
,
1588 .policy
= nl80211_policy
,
1589 .flags
= GENL_ADMIN_PERM
,
1592 .cmd
= NL80211_CMD_SET_BEACON
,
1593 .policy
= nl80211_policy
,
1594 .flags
= GENL_ADMIN_PERM
,
1595 .doit
= nl80211_addset_beacon
,
1598 .cmd
= NL80211_CMD_NEW_BEACON
,
1599 .policy
= nl80211_policy
,
1600 .flags
= GENL_ADMIN_PERM
,
1601 .doit
= nl80211_addset_beacon
,
1604 .cmd
= NL80211_CMD_DEL_BEACON
,
1605 .policy
= nl80211_policy
,
1606 .flags
= GENL_ADMIN_PERM
,
1607 .doit
= nl80211_del_beacon
,
1610 .cmd
= NL80211_CMD_GET_STATION
,
1611 .doit
= nl80211_get_station
,
1612 .dumpit
= nl80211_dump_station
,
1613 .policy
= nl80211_policy
,
1614 .flags
= GENL_ADMIN_PERM
,
1617 .cmd
= NL80211_CMD_SET_STATION
,
1618 .doit
= nl80211_set_station
,
1619 .policy
= nl80211_policy
,
1620 .flags
= GENL_ADMIN_PERM
,
1623 .cmd
= NL80211_CMD_NEW_STATION
,
1624 .doit
= nl80211_new_station
,
1625 .policy
= nl80211_policy
,
1626 .flags
= GENL_ADMIN_PERM
,
1629 .cmd
= NL80211_CMD_DEL_STATION
,
1630 .doit
= nl80211_del_station
,
1631 .policy
= nl80211_policy
,
1632 .flags
= GENL_ADMIN_PERM
,
1635 .cmd
= NL80211_CMD_GET_MPATH
,
1636 .doit
= nl80211_get_mpath
,
1637 .dumpit
= nl80211_dump_mpath
,
1638 .policy
= nl80211_policy
,
1639 .flags
= GENL_ADMIN_PERM
,
1642 .cmd
= NL80211_CMD_SET_MPATH
,
1643 .doit
= nl80211_set_mpath
,
1644 .policy
= nl80211_policy
,
1645 .flags
= GENL_ADMIN_PERM
,
1648 .cmd
= NL80211_CMD_NEW_MPATH
,
1649 .doit
= nl80211_new_mpath
,
1650 .policy
= nl80211_policy
,
1651 .flags
= GENL_ADMIN_PERM
,
1654 .cmd
= NL80211_CMD_DEL_MPATH
,
1655 .doit
= nl80211_del_mpath
,
1656 .policy
= nl80211_policy
,
1657 .flags
= GENL_ADMIN_PERM
,
1661 /* multicast groups */
1662 static struct genl_multicast_group nl80211_config_mcgrp
= {
1666 /* notification functions */
1668 void nl80211_notify_dev_rename(struct cfg80211_registered_device
*rdev
)
1670 struct sk_buff
*msg
;
1672 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1676 if (nl80211_send_wiphy(msg
, 0, 0, 0, rdev
) < 0) {
1681 genlmsg_multicast(msg
, 0, nl80211_config_mcgrp
.id
, GFP_KERNEL
);
1684 /* initialisation/exit functions */
1686 int nl80211_init(void)
1690 err
= genl_register_family(&nl80211_fam
);
1694 for (i
= 0; i
< ARRAY_SIZE(nl80211_ops
); i
++) {
1695 err
= genl_register_ops(&nl80211_fam
, &nl80211_ops
[i
]);
1700 err
= genl_register_mc_group(&nl80211_fam
, &nl80211_config_mcgrp
);
1706 genl_unregister_family(&nl80211_fam
);
1710 void nl80211_exit(void)
1712 genl_unregister_family(&nl80211_fam
);