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 },
61 [NL80211_ATTR_WIPHY_TXQ_PARAMS
] = { .type
= NLA_NESTED
},
62 [NL80211_ATTR_WIPHY_FREQ
] = { .type
= NLA_U32
},
63 [NL80211_ATTR_WIPHY_CHANNEL_TYPE
] = { .type
= NLA_U32
},
65 [NL80211_ATTR_IFTYPE
] = { .type
= NLA_U32
},
66 [NL80211_ATTR_IFINDEX
] = { .type
= NLA_U32
},
67 [NL80211_ATTR_IFNAME
] = { .type
= NLA_NUL_STRING
, .len
= IFNAMSIZ
-1 },
69 [NL80211_ATTR_MAC
] = { .type
= NLA_BINARY
, .len
= ETH_ALEN
},
71 [NL80211_ATTR_KEY_DATA
] = { .type
= NLA_BINARY
,
72 .len
= WLAN_MAX_KEY_LEN
},
73 [NL80211_ATTR_KEY_IDX
] = { .type
= NLA_U8
},
74 [NL80211_ATTR_KEY_CIPHER
] = { .type
= NLA_U32
},
75 [NL80211_ATTR_KEY_DEFAULT
] = { .type
= NLA_FLAG
},
77 [NL80211_ATTR_BEACON_INTERVAL
] = { .type
= NLA_U32
},
78 [NL80211_ATTR_DTIM_PERIOD
] = { .type
= NLA_U32
},
79 [NL80211_ATTR_BEACON_HEAD
] = { .type
= NLA_BINARY
,
80 .len
= IEEE80211_MAX_DATA_LEN
},
81 [NL80211_ATTR_BEACON_TAIL
] = { .type
= NLA_BINARY
,
82 .len
= IEEE80211_MAX_DATA_LEN
},
83 [NL80211_ATTR_STA_AID
] = { .type
= NLA_U16
},
84 [NL80211_ATTR_STA_FLAGS
] = { .type
= NLA_NESTED
},
85 [NL80211_ATTR_STA_LISTEN_INTERVAL
] = { .type
= NLA_U16
},
86 [NL80211_ATTR_STA_SUPPORTED_RATES
] = { .type
= NLA_BINARY
,
87 .len
= NL80211_MAX_SUPP_RATES
},
88 [NL80211_ATTR_STA_PLINK_ACTION
] = { .type
= NLA_U8
},
89 [NL80211_ATTR_STA_VLAN
] = { .type
= NLA_U32
},
90 [NL80211_ATTR_MNTR_FLAGS
] = { /* NLA_NESTED can't be empty */ },
91 [NL80211_ATTR_MESH_ID
] = { .type
= NLA_BINARY
,
92 .len
= IEEE80211_MAX_MESH_ID_LEN
},
93 [NL80211_ATTR_MPATH_NEXT_HOP
] = { .type
= NLA_U32
},
95 [NL80211_ATTR_REG_ALPHA2
] = { .type
= NLA_STRING
, .len
= 2 },
96 [NL80211_ATTR_REG_RULES
] = { .type
= NLA_NESTED
},
98 [NL80211_ATTR_BSS_CTS_PROT
] = { .type
= NLA_U8
},
99 [NL80211_ATTR_BSS_SHORT_PREAMBLE
] = { .type
= NLA_U8
},
100 [NL80211_ATTR_BSS_SHORT_SLOT_TIME
] = { .type
= NLA_U8
},
101 [NL80211_ATTR_BSS_BASIC_RATES
] = { .type
= NLA_BINARY
,
102 .len
= NL80211_MAX_SUPP_RATES
},
104 [NL80211_ATTR_MESH_PARAMS
] = { .type
= NLA_NESTED
},
106 [NL80211_ATTR_HT_CAPABILITY
] = { .type
= NLA_BINARY
,
107 .len
= NL80211_HT_CAPABILITY_LEN
},
110 /* message building helper */
111 static inline void *nl80211hdr_put(struct sk_buff
*skb
, u32 pid
, u32 seq
,
114 /* since there is no private header just add the generic one */
115 return genlmsg_put(skb
, pid
, seq
, &nl80211_fam
, flags
, cmd
);
118 /* netlink command implementations */
120 static int nl80211_send_wiphy(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
121 struct cfg80211_registered_device
*dev
)
124 struct nlattr
*nl_bands
, *nl_band
;
125 struct nlattr
*nl_freqs
, *nl_freq
;
126 struct nlattr
*nl_rates
, *nl_rate
;
127 struct nlattr
*nl_modes
;
128 enum ieee80211_band band
;
129 struct ieee80211_channel
*chan
;
130 struct ieee80211_rate
*rate
;
132 u16 ifmodes
= dev
->wiphy
.interface_modes
;
134 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_WIPHY
);
138 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY
, dev
->idx
);
139 NLA_PUT_STRING(msg
, NL80211_ATTR_WIPHY_NAME
, wiphy_name(&dev
->wiphy
));
141 nl_modes
= nla_nest_start(msg
, NL80211_ATTR_SUPPORTED_IFTYPES
);
143 goto nla_put_failure
;
148 NLA_PUT_FLAG(msg
, i
);
153 nla_nest_end(msg
, nl_modes
);
155 nl_bands
= nla_nest_start(msg
, NL80211_ATTR_WIPHY_BANDS
);
157 goto nla_put_failure
;
159 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
160 if (!dev
->wiphy
.bands
[band
])
163 nl_band
= nla_nest_start(msg
, band
);
165 goto nla_put_failure
;
168 if (dev
->wiphy
.bands
[band
]->ht_cap
.ht_supported
) {
169 NLA_PUT(msg
, NL80211_BAND_ATTR_HT_MCS_SET
,
170 sizeof(dev
->wiphy
.bands
[band
]->ht_cap
.mcs
),
171 &dev
->wiphy
.bands
[band
]->ht_cap
.mcs
);
172 NLA_PUT_U16(msg
, NL80211_BAND_ATTR_HT_CAPA
,
173 dev
->wiphy
.bands
[band
]->ht_cap
.cap
);
174 NLA_PUT_U8(msg
, NL80211_BAND_ATTR_HT_AMPDU_FACTOR
,
175 dev
->wiphy
.bands
[band
]->ht_cap
.ampdu_factor
);
176 NLA_PUT_U8(msg
, NL80211_BAND_ATTR_HT_AMPDU_DENSITY
,
177 dev
->wiphy
.bands
[band
]->ht_cap
.ampdu_density
);
180 /* add frequencies */
181 nl_freqs
= nla_nest_start(msg
, NL80211_BAND_ATTR_FREQS
);
183 goto nla_put_failure
;
185 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_channels
; i
++) {
186 nl_freq
= nla_nest_start(msg
, i
);
188 goto nla_put_failure
;
190 chan
= &dev
->wiphy
.bands
[band
]->channels
[i
];
191 NLA_PUT_U32(msg
, NL80211_FREQUENCY_ATTR_FREQ
,
194 if (chan
->flags
& IEEE80211_CHAN_DISABLED
)
195 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_DISABLED
);
196 if (chan
->flags
& IEEE80211_CHAN_PASSIVE_SCAN
)
197 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN
);
198 if (chan
->flags
& IEEE80211_CHAN_NO_IBSS
)
199 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_NO_IBSS
);
200 if (chan
->flags
& IEEE80211_CHAN_RADAR
)
201 NLA_PUT_FLAG(msg
, NL80211_FREQUENCY_ATTR_RADAR
);
203 NLA_PUT_U32(msg
, NL80211_FREQUENCY_ATTR_MAX_TX_POWER
,
204 DBM_TO_MBM(chan
->max_power
));
206 nla_nest_end(msg
, nl_freq
);
209 nla_nest_end(msg
, nl_freqs
);
212 nl_rates
= nla_nest_start(msg
, NL80211_BAND_ATTR_RATES
);
214 goto nla_put_failure
;
216 for (i
= 0; i
< dev
->wiphy
.bands
[band
]->n_bitrates
; i
++) {
217 nl_rate
= nla_nest_start(msg
, i
);
219 goto nla_put_failure
;
221 rate
= &dev
->wiphy
.bands
[band
]->bitrates
[i
];
222 NLA_PUT_U32(msg
, NL80211_BITRATE_ATTR_RATE
,
224 if (rate
->flags
& IEEE80211_RATE_SHORT_PREAMBLE
)
226 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE
);
228 nla_nest_end(msg
, nl_rate
);
231 nla_nest_end(msg
, nl_rates
);
233 nla_nest_end(msg
, nl_band
);
235 nla_nest_end(msg
, nl_bands
);
237 return genlmsg_end(msg
, hdr
);
240 genlmsg_cancel(msg
, hdr
);
244 static int nl80211_dump_wiphy(struct sk_buff
*skb
, struct netlink_callback
*cb
)
247 int start
= cb
->args
[0];
248 struct cfg80211_registered_device
*dev
;
250 mutex_lock(&cfg80211_drv_mutex
);
251 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
254 if (nl80211_send_wiphy(skb
, NETLINK_CB(cb
->skb
).pid
,
255 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
261 mutex_unlock(&cfg80211_drv_mutex
);
268 static int nl80211_get_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
271 struct cfg80211_registered_device
*dev
;
273 dev
= cfg80211_get_dev_from_info(info
);
277 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
281 if (nl80211_send_wiphy(msg
, info
->snd_pid
, info
->snd_seq
, 0, dev
) < 0)
284 cfg80211_put_dev(dev
);
286 return genlmsg_unicast(msg
, info
->snd_pid
);
291 cfg80211_put_dev(dev
);
295 static const struct nla_policy txq_params_policy
[NL80211_TXQ_ATTR_MAX
+ 1] = {
296 [NL80211_TXQ_ATTR_QUEUE
] = { .type
= NLA_U8
},
297 [NL80211_TXQ_ATTR_TXOP
] = { .type
= NLA_U16
},
298 [NL80211_TXQ_ATTR_CWMIN
] = { .type
= NLA_U16
},
299 [NL80211_TXQ_ATTR_CWMAX
] = { .type
= NLA_U16
},
300 [NL80211_TXQ_ATTR_AIFS
] = { .type
= NLA_U8
},
303 static int parse_txq_params(struct nlattr
*tb
[],
304 struct ieee80211_txq_params
*txq_params
)
306 if (!tb
[NL80211_TXQ_ATTR_QUEUE
] || !tb
[NL80211_TXQ_ATTR_TXOP
] ||
307 !tb
[NL80211_TXQ_ATTR_CWMIN
] || !tb
[NL80211_TXQ_ATTR_CWMAX
] ||
308 !tb
[NL80211_TXQ_ATTR_AIFS
])
311 txq_params
->queue
= nla_get_u8(tb
[NL80211_TXQ_ATTR_QUEUE
]);
312 txq_params
->txop
= nla_get_u16(tb
[NL80211_TXQ_ATTR_TXOP
]);
313 txq_params
->cwmin
= nla_get_u16(tb
[NL80211_TXQ_ATTR_CWMIN
]);
314 txq_params
->cwmax
= nla_get_u16(tb
[NL80211_TXQ_ATTR_CWMAX
]);
315 txq_params
->aifs
= nla_get_u8(tb
[NL80211_TXQ_ATTR_AIFS
]);
320 static int nl80211_set_wiphy(struct sk_buff
*skb
, struct genl_info
*info
)
322 struct cfg80211_registered_device
*rdev
;
323 int result
= 0, rem_txq_params
= 0;
324 struct nlattr
*nl_txq_params
;
326 rdev
= cfg80211_get_dev_from_info(info
);
328 return PTR_ERR(rdev
);
330 if (info
->attrs
[NL80211_ATTR_WIPHY_NAME
]) {
331 result
= cfg80211_dev_rename(
332 rdev
, nla_data(info
->attrs
[NL80211_ATTR_WIPHY_NAME
]));
337 if (info
->attrs
[NL80211_ATTR_WIPHY_TXQ_PARAMS
]) {
338 struct ieee80211_txq_params txq_params
;
339 struct nlattr
*tb
[NL80211_TXQ_ATTR_MAX
+ 1];
341 if (!rdev
->ops
->set_txq_params
) {
342 result
= -EOPNOTSUPP
;
346 nla_for_each_nested(nl_txq_params
,
347 info
->attrs
[NL80211_ATTR_WIPHY_TXQ_PARAMS
],
349 nla_parse(tb
, NL80211_TXQ_ATTR_MAX
,
350 nla_data(nl_txq_params
),
351 nla_len(nl_txq_params
),
353 result
= parse_txq_params(tb
, &txq_params
);
357 result
= rdev
->ops
->set_txq_params(&rdev
->wiphy
,
364 if (info
->attrs
[NL80211_ATTR_WIPHY_FREQ
]) {
365 enum nl80211_channel_type channel_type
= NL80211_CHAN_NO_HT
;
366 struct ieee80211_channel
*chan
;
367 struct ieee80211_sta_ht_cap
*ht_cap
;
370 if (!rdev
->ops
->set_channel
) {
371 result
= -EOPNOTSUPP
;
377 if (info
->attrs
[NL80211_ATTR_WIPHY_CHANNEL_TYPE
]) {
378 channel_type
= nla_get_u32(info
->attrs
[
379 NL80211_ATTR_WIPHY_CHANNEL_TYPE
]);
380 if (channel_type
!= NL80211_CHAN_NO_HT
&&
381 channel_type
!= NL80211_CHAN_HT20
&&
382 channel_type
!= NL80211_CHAN_HT40PLUS
&&
383 channel_type
!= NL80211_CHAN_HT40MINUS
)
387 freq
= nla_get_u32(info
->attrs
[NL80211_ATTR_WIPHY_FREQ
]);
388 chan
= ieee80211_get_channel(&rdev
->wiphy
, freq
);
390 /* Primary channel not allowed */
391 if (!chan
|| chan
->flags
& IEEE80211_CHAN_DISABLED
)
394 if (channel_type
== NL80211_CHAN_HT40MINUS
)
395 sec_freq
= freq
- 20;
396 else if (channel_type
== NL80211_CHAN_HT40PLUS
)
397 sec_freq
= freq
+ 20;
401 ht_cap
= &rdev
->wiphy
.bands
[chan
->band
]->ht_cap
;
403 /* no HT capabilities */
404 if (channel_type
!= NL80211_CHAN_NO_HT
&&
405 !ht_cap
->ht_supported
)
409 struct ieee80211_channel
*schan
;
411 /* no 40 MHz capabilities */
412 if (!(ht_cap
->cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
) ||
413 (ht_cap
->cap
& IEEE80211_HT_CAP_40MHZ_INTOLERANT
))
416 schan
= ieee80211_get_channel(&rdev
->wiphy
, sec_freq
);
418 /* Secondary channel not allowed */
419 if (!schan
|| schan
->flags
& IEEE80211_CHAN_DISABLED
)
423 result
= rdev
->ops
->set_channel(&rdev
->wiphy
, chan
,
431 cfg80211_put_dev(rdev
);
436 static int nl80211_send_iface(struct sk_buff
*msg
, u32 pid
, u32 seq
, int flags
,
437 struct net_device
*dev
)
441 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_INTERFACE
);
445 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
446 NLA_PUT_STRING(msg
, NL80211_ATTR_IFNAME
, dev
->name
);
447 NLA_PUT_U32(msg
, NL80211_ATTR_IFTYPE
, dev
->ieee80211_ptr
->iftype
);
448 return genlmsg_end(msg
, hdr
);
451 genlmsg_cancel(msg
, hdr
);
455 static int nl80211_dump_interface(struct sk_buff
*skb
, struct netlink_callback
*cb
)
459 int wp_start
= cb
->args
[0];
460 int if_start
= cb
->args
[1];
461 struct cfg80211_registered_device
*dev
;
462 struct wireless_dev
*wdev
;
464 mutex_lock(&cfg80211_drv_mutex
);
465 list_for_each_entry(dev
, &cfg80211_drv_list
, list
) {
466 if (wp_idx
< wp_start
) {
472 mutex_lock(&dev
->devlist_mtx
);
473 list_for_each_entry(wdev
, &dev
->netdev_list
, list
) {
474 if (if_idx
< if_start
) {
478 if (nl80211_send_iface(skb
, NETLINK_CB(cb
->skb
).pid
,
479 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
481 mutex_unlock(&dev
->devlist_mtx
);
486 mutex_unlock(&dev
->devlist_mtx
);
491 mutex_unlock(&cfg80211_drv_mutex
);
493 cb
->args
[0] = wp_idx
;
494 cb
->args
[1] = if_idx
;
499 static int nl80211_get_interface(struct sk_buff
*skb
, struct genl_info
*info
)
502 struct cfg80211_registered_device
*dev
;
503 struct net_device
*netdev
;
506 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &dev
, &netdev
);
510 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
514 if (nl80211_send_iface(msg
, info
->snd_pid
, info
->snd_seq
, 0, netdev
) < 0)
518 cfg80211_put_dev(dev
);
520 return genlmsg_unicast(msg
, info
->snd_pid
);
526 cfg80211_put_dev(dev
);
530 static const struct nla_policy mntr_flags_policy
[NL80211_MNTR_FLAG_MAX
+ 1] = {
531 [NL80211_MNTR_FLAG_FCSFAIL
] = { .type
= NLA_FLAG
},
532 [NL80211_MNTR_FLAG_PLCPFAIL
] = { .type
= NLA_FLAG
},
533 [NL80211_MNTR_FLAG_CONTROL
] = { .type
= NLA_FLAG
},
534 [NL80211_MNTR_FLAG_OTHER_BSS
] = { .type
= NLA_FLAG
},
535 [NL80211_MNTR_FLAG_COOK_FRAMES
] = { .type
= NLA_FLAG
},
538 static int parse_monitor_flags(struct nlattr
*nla
, u32
*mntrflags
)
540 struct nlattr
*flags
[NL80211_MNTR_FLAG_MAX
+ 1];
548 if (nla_parse_nested(flags
, NL80211_MNTR_FLAG_MAX
,
549 nla
, mntr_flags_policy
))
552 for (flag
= 1; flag
<= NL80211_MNTR_FLAG_MAX
; flag
++)
554 *mntrflags
|= (1<<flag
);
559 static int nl80211_set_interface(struct sk_buff
*skb
, struct genl_info
*info
)
561 struct cfg80211_registered_device
*drv
;
562 struct vif_params params
;
564 enum nl80211_iftype type
;
565 struct net_device
*dev
;
566 u32 _flags
, *flags
= NULL
;
568 memset(¶ms
, 0, sizeof(params
));
570 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
573 ifindex
= dev
->ifindex
;
574 type
= dev
->ieee80211_ptr
->iftype
;
578 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
579 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
580 if (type
> NL80211_IFTYPE_MAX
)
584 if (!drv
->ops
->change_virtual_intf
||
585 !(drv
->wiphy
.interface_modes
& (1 << type
))) {
590 if (info
->attrs
[NL80211_ATTR_MESH_ID
]) {
591 if (type
!= NL80211_IFTYPE_MESH_POINT
) {
595 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
596 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
599 if (info
->attrs
[NL80211_ATTR_MNTR_FLAGS
]) {
600 if (type
!= NL80211_IFTYPE_MONITOR
) {
604 err
= parse_monitor_flags(info
->attrs
[NL80211_ATTR_MNTR_FLAGS
],
610 err
= drv
->ops
->change_virtual_intf(&drv
->wiphy
, ifindex
,
611 type
, flags
, ¶ms
);
613 dev
= __dev_get_by_index(&init_net
, ifindex
);
614 WARN_ON(!dev
|| (!err
&& dev
->ieee80211_ptr
->iftype
!= type
));
619 cfg80211_put_dev(drv
);
623 static int nl80211_new_interface(struct sk_buff
*skb
, struct genl_info
*info
)
625 struct cfg80211_registered_device
*drv
;
626 struct vif_params params
;
628 enum nl80211_iftype type
= NL80211_IFTYPE_UNSPECIFIED
;
631 memset(¶ms
, 0, sizeof(params
));
633 if (!info
->attrs
[NL80211_ATTR_IFNAME
])
636 if (info
->attrs
[NL80211_ATTR_IFTYPE
]) {
637 type
= nla_get_u32(info
->attrs
[NL80211_ATTR_IFTYPE
]);
638 if (type
> NL80211_IFTYPE_MAX
)
642 drv
= cfg80211_get_dev_from_info(info
);
646 if (!drv
->ops
->add_virtual_intf
||
647 !(drv
->wiphy
.interface_modes
& (1 << type
))) {
652 if (type
== NL80211_IFTYPE_MESH_POINT
&&
653 info
->attrs
[NL80211_ATTR_MESH_ID
]) {
654 params
.mesh_id
= nla_data(info
->attrs
[NL80211_ATTR_MESH_ID
]);
655 params
.mesh_id_len
= nla_len(info
->attrs
[NL80211_ATTR_MESH_ID
]);
659 err
= parse_monitor_flags(type
== NL80211_IFTYPE_MONITOR
?
660 info
->attrs
[NL80211_ATTR_MNTR_FLAGS
] : NULL
,
662 err
= drv
->ops
->add_virtual_intf(&drv
->wiphy
,
663 nla_data(info
->attrs
[NL80211_ATTR_IFNAME
]),
664 type
, err
? NULL
: &flags
, ¶ms
);
669 cfg80211_put_dev(drv
);
673 static int nl80211_del_interface(struct sk_buff
*skb
, struct genl_info
*info
)
675 struct cfg80211_registered_device
*drv
;
677 struct net_device
*dev
;
679 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
682 ifindex
= dev
->ifindex
;
685 if (!drv
->ops
->del_virtual_intf
) {
691 err
= drv
->ops
->del_virtual_intf(&drv
->wiphy
, ifindex
);
695 cfg80211_put_dev(drv
);
699 struct get_key_cookie
{
704 static void get_key_callback(void *c
, struct key_params
*params
)
706 struct get_key_cookie
*cookie
= c
;
709 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_DATA
,
710 params
->key_len
, params
->key
);
713 NLA_PUT(cookie
->msg
, NL80211_ATTR_KEY_SEQ
,
714 params
->seq_len
, params
->seq
);
717 NLA_PUT_U32(cookie
->msg
, NL80211_ATTR_KEY_CIPHER
,
725 static int nl80211_get_key(struct sk_buff
*skb
, struct genl_info
*info
)
727 struct cfg80211_registered_device
*drv
;
729 struct net_device
*dev
;
732 struct get_key_cookie cookie
= {
738 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
739 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
744 if (info
->attrs
[NL80211_ATTR_MAC
])
745 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
747 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
751 if (!drv
->ops
->get_key
) {
756 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
762 hdr
= nl80211hdr_put(msg
, info
->snd_pid
, info
->snd_seq
, 0,
763 NL80211_CMD_NEW_KEY
);
772 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
773 NLA_PUT_U8(msg
, NL80211_ATTR_KEY_IDX
, key_idx
);
775 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
778 err
= drv
->ops
->get_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
,
779 &cookie
, get_key_callback
);
786 goto nla_put_failure
;
788 genlmsg_end(msg
, hdr
);
789 err
= genlmsg_unicast(msg
, info
->snd_pid
);
796 cfg80211_put_dev(drv
);
801 static int nl80211_set_key(struct sk_buff
*skb
, struct genl_info
*info
)
803 struct cfg80211_registered_device
*drv
;
805 struct net_device
*dev
;
808 if (!info
->attrs
[NL80211_ATTR_KEY_IDX
])
811 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
816 /* currently only support setting default key */
817 if (!info
->attrs
[NL80211_ATTR_KEY_DEFAULT
])
820 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
824 if (!drv
->ops
->set_default_key
) {
830 err
= drv
->ops
->set_default_key(&drv
->wiphy
, dev
, key_idx
);
834 cfg80211_put_dev(drv
);
839 static int nl80211_new_key(struct sk_buff
*skb
, struct genl_info
*info
)
841 struct cfg80211_registered_device
*drv
;
843 struct net_device
*dev
;
844 struct key_params params
;
848 memset(¶ms
, 0, sizeof(params
));
850 if (!info
->attrs
[NL80211_ATTR_KEY_CIPHER
])
853 if (info
->attrs
[NL80211_ATTR_KEY_DATA
]) {
854 params
.key
= nla_data(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
855 params
.key_len
= nla_len(info
->attrs
[NL80211_ATTR_KEY_DATA
]);
858 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
859 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
861 params
.cipher
= nla_get_u32(info
->attrs
[NL80211_ATTR_KEY_CIPHER
]);
863 if (info
->attrs
[NL80211_ATTR_MAC
])
864 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
870 * Disallow pairwise keys with non-zero index unless it's WEP
871 * (because current deployments use pairwise WEP keys with
872 * non-zero indizes but 802.11i clearly specifies to use zero)
874 if (mac_addr
&& key_idx
&&
875 params
.cipher
!= WLAN_CIPHER_SUITE_WEP40
&&
876 params
.cipher
!= WLAN_CIPHER_SUITE_WEP104
)
879 /* TODO: add definitions for the lengths to linux/ieee80211.h */
880 switch (params
.cipher
) {
881 case WLAN_CIPHER_SUITE_WEP40
:
882 if (params
.key_len
!= 5)
885 case WLAN_CIPHER_SUITE_TKIP
:
886 if (params
.key_len
!= 32)
889 case WLAN_CIPHER_SUITE_CCMP
:
890 if (params
.key_len
!= 16)
893 case WLAN_CIPHER_SUITE_WEP104
:
894 if (params
.key_len
!= 13)
901 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
905 if (!drv
->ops
->add_key
) {
911 err
= drv
->ops
->add_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
, ¶ms
);
915 cfg80211_put_dev(drv
);
920 static int nl80211_del_key(struct sk_buff
*skb
, struct genl_info
*info
)
922 struct cfg80211_registered_device
*drv
;
924 struct net_device
*dev
;
928 if (info
->attrs
[NL80211_ATTR_KEY_IDX
])
929 key_idx
= nla_get_u8(info
->attrs
[NL80211_ATTR_KEY_IDX
]);
934 if (info
->attrs
[NL80211_ATTR_MAC
])
935 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
937 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
941 if (!drv
->ops
->del_key
) {
947 err
= drv
->ops
->del_key(&drv
->wiphy
, dev
, key_idx
, mac_addr
);
951 cfg80211_put_dev(drv
);
956 static int nl80211_addset_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
958 int (*call
)(struct wiphy
*wiphy
, struct net_device
*dev
,
959 struct beacon_parameters
*info
);
960 struct cfg80211_registered_device
*drv
;
962 struct net_device
*dev
;
963 struct beacon_parameters params
;
966 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
970 switch (info
->genlhdr
->cmd
) {
971 case NL80211_CMD_NEW_BEACON
:
972 /* these are required for NEW_BEACON */
973 if (!info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
] ||
974 !info
->attrs
[NL80211_ATTR_DTIM_PERIOD
] ||
975 !info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
980 call
= drv
->ops
->add_beacon
;
982 case NL80211_CMD_SET_BEACON
:
983 call
= drv
->ops
->set_beacon
;
996 memset(¶ms
, 0, sizeof(params
));
998 if (info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]) {
1000 nla_get_u32(info
->attrs
[NL80211_ATTR_BEACON_INTERVAL
]);
1004 if (info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]) {
1005 params
.dtim_period
=
1006 nla_get_u32(info
->attrs
[NL80211_ATTR_DTIM_PERIOD
]);
1010 if (info
->attrs
[NL80211_ATTR_BEACON_HEAD
]) {
1011 params
.head
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
1013 nla_len(info
->attrs
[NL80211_ATTR_BEACON_HEAD
]);
1017 if (info
->attrs
[NL80211_ATTR_BEACON_TAIL
]) {
1018 params
.tail
= nla_data(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
1020 nla_len(info
->attrs
[NL80211_ATTR_BEACON_TAIL
]);
1030 err
= call(&drv
->wiphy
, dev
, ¶ms
);
1034 cfg80211_put_dev(drv
);
1039 static int nl80211_del_beacon(struct sk_buff
*skb
, struct genl_info
*info
)
1041 struct cfg80211_registered_device
*drv
;
1043 struct net_device
*dev
;
1045 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1049 if (!drv
->ops
->del_beacon
) {
1055 err
= drv
->ops
->del_beacon(&drv
->wiphy
, dev
);
1059 cfg80211_put_dev(drv
);
1064 static const struct nla_policy sta_flags_policy
[NL80211_STA_FLAG_MAX
+ 1] = {
1065 [NL80211_STA_FLAG_AUTHORIZED
] = { .type
= NLA_FLAG
},
1066 [NL80211_STA_FLAG_SHORT_PREAMBLE
] = { .type
= NLA_FLAG
},
1067 [NL80211_STA_FLAG_WME
] = { .type
= NLA_FLAG
},
1070 static int parse_station_flags(struct nlattr
*nla
, u32
*staflags
)
1072 struct nlattr
*flags
[NL80211_STA_FLAG_MAX
+ 1];
1080 if (nla_parse_nested(flags
, NL80211_STA_FLAG_MAX
,
1081 nla
, sta_flags_policy
))
1084 *staflags
= STATION_FLAG_CHANGED
;
1086 for (flag
= 1; flag
<= NL80211_STA_FLAG_MAX
; flag
++)
1088 *staflags
|= (1<<flag
);
1093 static u16
nl80211_calculate_bitrate(struct rate_info
*rate
)
1095 int modulation
, streams
, bitrate
;
1097 if (!(rate
->flags
& RATE_INFO_FLAGS_MCS
))
1098 return rate
->legacy
;
1100 /* the formula below does only work for MCS values smaller than 32 */
1101 if (rate
->mcs
>= 32)
1104 modulation
= rate
->mcs
& 7;
1105 streams
= (rate
->mcs
>> 3) + 1;
1107 bitrate
= (rate
->flags
& RATE_INFO_FLAGS_40_MHZ_WIDTH
) ?
1111 bitrate
*= (modulation
+ 1);
1112 else if (modulation
== 4)
1113 bitrate
*= (modulation
+ 2);
1115 bitrate
*= (modulation
+ 3);
1119 if (rate
->flags
& RATE_INFO_FLAGS_SHORT_GI
)
1120 bitrate
= (bitrate
/ 9) * 10;
1122 /* do NOT round down here */
1123 return (bitrate
+ 50000) / 100000;
1126 static int nl80211_send_station(struct sk_buff
*msg
, u32 pid
, u32 seq
,
1127 int flags
, struct net_device
*dev
,
1128 u8
*mac_addr
, struct station_info
*sinfo
)
1131 struct nlattr
*sinfoattr
, *txrate
;
1134 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
1138 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
1139 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, mac_addr
);
1141 sinfoattr
= nla_nest_start(msg
, NL80211_ATTR_STA_INFO
);
1143 goto nla_put_failure
;
1144 if (sinfo
->filled
& STATION_INFO_INACTIVE_TIME
)
1145 NLA_PUT_U32(msg
, NL80211_STA_INFO_INACTIVE_TIME
,
1146 sinfo
->inactive_time
);
1147 if (sinfo
->filled
& STATION_INFO_RX_BYTES
)
1148 NLA_PUT_U32(msg
, NL80211_STA_INFO_RX_BYTES
,
1150 if (sinfo
->filled
& STATION_INFO_TX_BYTES
)
1151 NLA_PUT_U32(msg
, NL80211_STA_INFO_TX_BYTES
,
1153 if (sinfo
->filled
& STATION_INFO_LLID
)
1154 NLA_PUT_U16(msg
, NL80211_STA_INFO_LLID
,
1156 if (sinfo
->filled
& STATION_INFO_PLID
)
1157 NLA_PUT_U16(msg
, NL80211_STA_INFO_PLID
,
1159 if (sinfo
->filled
& STATION_INFO_PLINK_STATE
)
1160 NLA_PUT_U8(msg
, NL80211_STA_INFO_PLINK_STATE
,
1161 sinfo
->plink_state
);
1162 if (sinfo
->filled
& STATION_INFO_SIGNAL
)
1163 NLA_PUT_U8(msg
, NL80211_STA_INFO_SIGNAL
,
1165 if (sinfo
->filled
& STATION_INFO_TX_BITRATE
) {
1166 txrate
= nla_nest_start(msg
, NL80211_STA_INFO_TX_BITRATE
);
1168 goto nla_put_failure
;
1170 /* nl80211_calculate_bitrate will return 0 for mcs >= 32 */
1171 bitrate
= nl80211_calculate_bitrate(&sinfo
->txrate
);
1173 NLA_PUT_U16(msg
, NL80211_RATE_INFO_BITRATE
, bitrate
);
1175 if (sinfo
->txrate
.flags
& RATE_INFO_FLAGS_MCS
)
1176 NLA_PUT_U8(msg
, NL80211_RATE_INFO_MCS
,
1178 if (sinfo
->txrate
.flags
& RATE_INFO_FLAGS_40_MHZ_WIDTH
)
1179 NLA_PUT_FLAG(msg
, NL80211_RATE_INFO_40_MHZ_WIDTH
);
1180 if (sinfo
->txrate
.flags
& RATE_INFO_FLAGS_SHORT_GI
)
1181 NLA_PUT_FLAG(msg
, NL80211_RATE_INFO_SHORT_GI
);
1183 nla_nest_end(msg
, txrate
);
1185 nla_nest_end(msg
, sinfoattr
);
1187 return genlmsg_end(msg
, hdr
);
1190 genlmsg_cancel(msg
, hdr
);
1194 static int nl80211_dump_station(struct sk_buff
*skb
,
1195 struct netlink_callback
*cb
)
1197 struct station_info sinfo
;
1198 struct cfg80211_registered_device
*dev
;
1199 struct net_device
*netdev
;
1200 u8 mac_addr
[ETH_ALEN
];
1201 int ifidx
= cb
->args
[0];
1202 int sta_idx
= cb
->args
[1];
1206 err
= nlmsg_parse(cb
->nlh
, GENL_HDRLEN
+ nl80211_fam
.hdrsize
,
1207 nl80211_fam
.attrbuf
, nl80211_fam
.maxattr
,
1212 if (!nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
])
1215 ifidx
= nla_get_u32(nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
]);
1220 netdev
= dev_get_by_index(&init_net
, ifidx
);
1224 dev
= cfg80211_get_dev_from_ifindex(ifidx
);
1227 goto out_put_netdev
;
1230 if (!dev
->ops
->dump_station
) {
1238 err
= dev
->ops
->dump_station(&dev
->wiphy
, netdev
, sta_idx
,
1245 if (nl80211_send_station(skb
,
1246 NETLINK_CB(cb
->skb
).pid
,
1247 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
1257 cb
->args
[1] = sta_idx
;
1262 cfg80211_put_dev(dev
);
1269 static int nl80211_get_station(struct sk_buff
*skb
, struct genl_info
*info
)
1271 struct cfg80211_registered_device
*drv
;
1273 struct net_device
*dev
;
1274 struct station_info sinfo
;
1275 struct sk_buff
*msg
;
1276 u8
*mac_addr
= NULL
;
1278 memset(&sinfo
, 0, sizeof(sinfo
));
1280 if (!info
->attrs
[NL80211_ATTR_MAC
])
1283 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1285 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1289 if (!drv
->ops
->get_station
) {
1295 err
= drv
->ops
->get_station(&drv
->wiphy
, dev
, mac_addr
, &sinfo
);
1301 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1305 if (nl80211_send_station(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1306 dev
, mac_addr
, &sinfo
) < 0)
1309 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1316 cfg80211_put_dev(drv
);
1322 * Get vlan interface making sure it is on the right wiphy.
1324 static int get_vlan(struct nlattr
*vlanattr
,
1325 struct cfg80211_registered_device
*rdev
,
1326 struct net_device
**vlan
)
1331 *vlan
= dev_get_by_index(&init_net
, nla_get_u32(vlanattr
));
1334 if (!(*vlan
)->ieee80211_ptr
)
1336 if ((*vlan
)->ieee80211_ptr
->wiphy
!= &rdev
->wiphy
)
1342 static int nl80211_set_station(struct sk_buff
*skb
, struct genl_info
*info
)
1344 struct cfg80211_registered_device
*drv
;
1346 struct net_device
*dev
;
1347 struct station_parameters params
;
1348 u8
*mac_addr
= NULL
;
1350 memset(¶ms
, 0, sizeof(params
));
1352 params
.listen_interval
= -1;
1354 if (info
->attrs
[NL80211_ATTR_STA_AID
])
1357 if (!info
->attrs
[NL80211_ATTR_MAC
])
1360 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1362 if (info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]) {
1363 params
.supported_rates
=
1364 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1365 params
.supported_rates_len
=
1366 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1369 if (info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1370 params
.listen_interval
=
1371 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1373 if (info
->attrs
[NL80211_ATTR_HT_CAPABILITY
])
1375 nla_data(info
->attrs
[NL80211_ATTR_HT_CAPABILITY
]);
1377 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1378 ¶ms
.station_flags
))
1381 if (info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
])
1382 params
.plink_action
=
1383 nla_get_u8(info
->attrs
[NL80211_ATTR_STA_PLINK_ACTION
]);
1385 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1389 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1393 if (!drv
->ops
->change_station
) {
1399 err
= drv
->ops
->change_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1404 dev_put(params
.vlan
);
1405 cfg80211_put_dev(drv
);
1410 static int nl80211_new_station(struct sk_buff
*skb
, struct genl_info
*info
)
1412 struct cfg80211_registered_device
*drv
;
1414 struct net_device
*dev
;
1415 struct station_parameters params
;
1416 u8
*mac_addr
= NULL
;
1418 memset(¶ms
, 0, sizeof(params
));
1420 if (!info
->attrs
[NL80211_ATTR_MAC
])
1423 if (!info
->attrs
[NL80211_ATTR_STA_AID
])
1426 if (!info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
])
1429 if (!info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
])
1432 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1433 params
.supported_rates
=
1434 nla_data(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1435 params
.supported_rates_len
=
1436 nla_len(info
->attrs
[NL80211_ATTR_STA_SUPPORTED_RATES
]);
1437 params
.listen_interval
=
1438 nla_get_u16(info
->attrs
[NL80211_ATTR_STA_LISTEN_INTERVAL
]);
1439 params
.aid
= nla_get_u16(info
->attrs
[NL80211_ATTR_STA_AID
]);
1440 if (info
->attrs
[NL80211_ATTR_HT_CAPABILITY
])
1442 nla_data(info
->attrs
[NL80211_ATTR_HT_CAPABILITY
]);
1444 if (parse_station_flags(info
->attrs
[NL80211_ATTR_STA_FLAGS
],
1445 ¶ms
.station_flags
))
1448 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1452 err
= get_vlan(info
->attrs
[NL80211_ATTR_STA_VLAN
], drv
, ¶ms
.vlan
);
1456 if (!drv
->ops
->add_station
) {
1462 err
= drv
->ops
->add_station(&drv
->wiphy
, dev
, mac_addr
, ¶ms
);
1467 dev_put(params
.vlan
);
1468 cfg80211_put_dev(drv
);
1473 static int nl80211_del_station(struct sk_buff
*skb
, struct genl_info
*info
)
1475 struct cfg80211_registered_device
*drv
;
1477 struct net_device
*dev
;
1478 u8
*mac_addr
= NULL
;
1480 if (info
->attrs
[NL80211_ATTR_MAC
])
1481 mac_addr
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1483 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1487 if (!drv
->ops
->del_station
) {
1493 err
= drv
->ops
->del_station(&drv
->wiphy
, dev
, mac_addr
);
1497 cfg80211_put_dev(drv
);
1502 static int nl80211_send_mpath(struct sk_buff
*msg
, u32 pid
, u32 seq
,
1503 int flags
, struct net_device
*dev
,
1504 u8
*dst
, u8
*next_hop
,
1505 struct mpath_info
*pinfo
)
1508 struct nlattr
*pinfoattr
;
1510 hdr
= nl80211hdr_put(msg
, pid
, seq
, flags
, NL80211_CMD_NEW_STATION
);
1514 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
1515 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, dst
);
1516 NLA_PUT(msg
, NL80211_ATTR_MPATH_NEXT_HOP
, ETH_ALEN
, next_hop
);
1518 pinfoattr
= nla_nest_start(msg
, NL80211_ATTR_MPATH_INFO
);
1520 goto nla_put_failure
;
1521 if (pinfo
->filled
& MPATH_INFO_FRAME_QLEN
)
1522 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_FRAME_QLEN
,
1524 if (pinfo
->filled
& MPATH_INFO_DSN
)
1525 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DSN
,
1527 if (pinfo
->filled
& MPATH_INFO_METRIC
)
1528 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_METRIC
,
1530 if (pinfo
->filled
& MPATH_INFO_EXPTIME
)
1531 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_EXPTIME
,
1533 if (pinfo
->filled
& MPATH_INFO_FLAGS
)
1534 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_FLAGS
,
1536 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_TIMEOUT
)
1537 NLA_PUT_U32(msg
, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT
,
1538 pinfo
->discovery_timeout
);
1539 if (pinfo
->filled
& MPATH_INFO_DISCOVERY_RETRIES
)
1540 NLA_PUT_U8(msg
, NL80211_MPATH_INFO_DISCOVERY_RETRIES
,
1541 pinfo
->discovery_retries
);
1543 nla_nest_end(msg
, pinfoattr
);
1545 return genlmsg_end(msg
, hdr
);
1548 genlmsg_cancel(msg
, hdr
);
1552 static int nl80211_dump_mpath(struct sk_buff
*skb
,
1553 struct netlink_callback
*cb
)
1555 struct mpath_info pinfo
;
1556 struct cfg80211_registered_device
*dev
;
1557 struct net_device
*netdev
;
1559 u8 next_hop
[ETH_ALEN
];
1560 int ifidx
= cb
->args
[0];
1561 int path_idx
= cb
->args
[1];
1565 err
= nlmsg_parse(cb
->nlh
, GENL_HDRLEN
+ nl80211_fam
.hdrsize
,
1566 nl80211_fam
.attrbuf
, nl80211_fam
.maxattr
,
1571 if (!nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
])
1574 ifidx
= nla_get_u32(nl80211_fam
.attrbuf
[NL80211_ATTR_IFINDEX
]);
1579 netdev
= dev_get_by_index(&init_net
, ifidx
);
1583 dev
= cfg80211_get_dev_from_ifindex(ifidx
);
1586 goto out_put_netdev
;
1589 if (!dev
->ops
->dump_mpath
) {
1597 err
= dev
->ops
->dump_mpath(&dev
->wiphy
, netdev
, path_idx
,
1598 dst
, next_hop
, &pinfo
);
1604 if (nl80211_send_mpath(skb
, NETLINK_CB(cb
->skb
).pid
,
1605 cb
->nlh
->nlmsg_seq
, NLM_F_MULTI
,
1606 netdev
, dst
, next_hop
,
1615 cb
->args
[1] = path_idx
;
1620 cfg80211_put_dev(dev
);
1627 static int nl80211_get_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1629 struct cfg80211_registered_device
*drv
;
1631 struct net_device
*dev
;
1632 struct mpath_info pinfo
;
1633 struct sk_buff
*msg
;
1635 u8 next_hop
[ETH_ALEN
];
1637 memset(&pinfo
, 0, sizeof(pinfo
));
1639 if (!info
->attrs
[NL80211_ATTR_MAC
])
1642 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1644 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1648 if (!drv
->ops
->get_mpath
) {
1654 err
= drv
->ops
->get_mpath(&drv
->wiphy
, dev
, dst
, next_hop
, &pinfo
);
1660 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1664 if (nl80211_send_mpath(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1665 dev
, dst
, next_hop
, &pinfo
) < 0)
1668 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1675 cfg80211_put_dev(drv
);
1680 static int nl80211_set_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1682 struct cfg80211_registered_device
*drv
;
1684 struct net_device
*dev
;
1686 u8
*next_hop
= NULL
;
1688 if (!info
->attrs
[NL80211_ATTR_MAC
])
1691 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1694 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1695 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1697 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1701 if (!drv
->ops
->change_mpath
) {
1707 err
= drv
->ops
->change_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1711 cfg80211_put_dev(drv
);
1715 static int nl80211_new_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1717 struct cfg80211_registered_device
*drv
;
1719 struct net_device
*dev
;
1721 u8
*next_hop
= NULL
;
1723 if (!info
->attrs
[NL80211_ATTR_MAC
])
1726 if (!info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
])
1729 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1730 next_hop
= nla_data(info
->attrs
[NL80211_ATTR_MPATH_NEXT_HOP
]);
1732 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1736 if (!drv
->ops
->add_mpath
) {
1742 err
= drv
->ops
->add_mpath(&drv
->wiphy
, dev
, dst
, next_hop
);
1746 cfg80211_put_dev(drv
);
1751 static int nl80211_del_mpath(struct sk_buff
*skb
, struct genl_info
*info
)
1753 struct cfg80211_registered_device
*drv
;
1755 struct net_device
*dev
;
1758 if (info
->attrs
[NL80211_ATTR_MAC
])
1759 dst
= nla_data(info
->attrs
[NL80211_ATTR_MAC
]);
1761 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1765 if (!drv
->ops
->del_mpath
) {
1771 err
= drv
->ops
->del_mpath(&drv
->wiphy
, dev
, dst
);
1775 cfg80211_put_dev(drv
);
1780 static int nl80211_set_bss(struct sk_buff
*skb
, struct genl_info
*info
)
1782 struct cfg80211_registered_device
*drv
;
1784 struct net_device
*dev
;
1785 struct bss_parameters params
;
1787 memset(¶ms
, 0, sizeof(params
));
1788 /* default to not changing parameters */
1789 params
.use_cts_prot
= -1;
1790 params
.use_short_preamble
= -1;
1791 params
.use_short_slot_time
= -1;
1793 if (info
->attrs
[NL80211_ATTR_BSS_CTS_PROT
])
1794 params
.use_cts_prot
=
1795 nla_get_u8(info
->attrs
[NL80211_ATTR_BSS_CTS_PROT
]);
1796 if (info
->attrs
[NL80211_ATTR_BSS_SHORT_PREAMBLE
])
1797 params
.use_short_preamble
=
1798 nla_get_u8(info
->attrs
[NL80211_ATTR_BSS_SHORT_PREAMBLE
]);
1799 if (info
->attrs
[NL80211_ATTR_BSS_SHORT_SLOT_TIME
])
1800 params
.use_short_slot_time
=
1801 nla_get_u8(info
->attrs
[NL80211_ATTR_BSS_SHORT_SLOT_TIME
]);
1802 if (info
->attrs
[NL80211_ATTR_BSS_BASIC_RATES
]) {
1803 params
.basic_rates
=
1804 nla_data(info
->attrs
[NL80211_ATTR_BSS_BASIC_RATES
]);
1805 params
.basic_rates_len
=
1806 nla_len(info
->attrs
[NL80211_ATTR_BSS_BASIC_RATES
]);
1809 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1813 if (!drv
->ops
->change_bss
) {
1819 err
= drv
->ops
->change_bss(&drv
->wiphy
, dev
, ¶ms
);
1823 cfg80211_put_dev(drv
);
1828 static const struct nla_policy
1829 reg_rule_policy
[NL80211_REG_RULE_ATTR_MAX
+ 1] = {
1830 [NL80211_ATTR_REG_RULE_FLAGS
] = { .type
= NLA_U32
},
1831 [NL80211_ATTR_FREQ_RANGE_START
] = { .type
= NLA_U32
},
1832 [NL80211_ATTR_FREQ_RANGE_END
] = { .type
= NLA_U32
},
1833 [NL80211_ATTR_FREQ_RANGE_MAX_BW
] = { .type
= NLA_U32
},
1834 [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN
] = { .type
= NLA_U32
},
1835 [NL80211_ATTR_POWER_RULE_MAX_EIRP
] = { .type
= NLA_U32
},
1838 static int parse_reg_rule(struct nlattr
*tb
[],
1839 struct ieee80211_reg_rule
*reg_rule
)
1841 struct ieee80211_freq_range
*freq_range
= ®_rule
->freq_range
;
1842 struct ieee80211_power_rule
*power_rule
= ®_rule
->power_rule
;
1844 if (!tb
[NL80211_ATTR_REG_RULE_FLAGS
])
1846 if (!tb
[NL80211_ATTR_FREQ_RANGE_START
])
1848 if (!tb
[NL80211_ATTR_FREQ_RANGE_END
])
1850 if (!tb
[NL80211_ATTR_FREQ_RANGE_MAX_BW
])
1852 if (!tb
[NL80211_ATTR_POWER_RULE_MAX_EIRP
])
1855 reg_rule
->flags
= nla_get_u32(tb
[NL80211_ATTR_REG_RULE_FLAGS
]);
1857 freq_range
->start_freq_khz
=
1858 nla_get_u32(tb
[NL80211_ATTR_FREQ_RANGE_START
]);
1859 freq_range
->end_freq_khz
=
1860 nla_get_u32(tb
[NL80211_ATTR_FREQ_RANGE_END
]);
1861 freq_range
->max_bandwidth_khz
=
1862 nla_get_u32(tb
[NL80211_ATTR_FREQ_RANGE_MAX_BW
]);
1864 power_rule
->max_eirp
=
1865 nla_get_u32(tb
[NL80211_ATTR_POWER_RULE_MAX_EIRP
]);
1867 if (tb
[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN
])
1868 power_rule
->max_antenna_gain
=
1869 nla_get_u32(tb
[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN
]);
1874 static int nl80211_req_set_reg(struct sk_buff
*skb
, struct genl_info
*info
)
1879 if (!info
->attrs
[NL80211_ATTR_REG_ALPHA2
])
1882 data
= nla_data(info
->attrs
[NL80211_ATTR_REG_ALPHA2
]);
1884 #ifdef CONFIG_WIRELESS_OLD_REGULATORY
1885 /* We ignore world regdom requests with the old regdom setup */
1886 if (is_world_regdom(data
))
1889 mutex_lock(&cfg80211_drv_mutex
);
1890 r
= __regulatory_hint(NULL
, REGDOM_SET_BY_USER
, data
, 0, ENVIRON_ANY
);
1891 mutex_unlock(&cfg80211_drv_mutex
);
1895 static int nl80211_get_mesh_params(struct sk_buff
*skb
,
1896 struct genl_info
*info
)
1898 struct cfg80211_registered_device
*drv
;
1899 struct mesh_config cur_params
;
1901 struct net_device
*dev
;
1903 struct nlattr
*pinfoattr
;
1904 struct sk_buff
*msg
;
1906 /* Look up our device */
1907 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
1911 if (!drv
->ops
->get_mesh_params
) {
1916 /* Get the mesh params */
1918 err
= drv
->ops
->get_mesh_params(&drv
->wiphy
, dev
, &cur_params
);
1923 /* Draw up a netlink message to send back */
1924 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
1929 hdr
= nl80211hdr_put(msg
, info
->snd_pid
, info
->snd_seq
, 0,
1930 NL80211_CMD_GET_MESH_PARAMS
);
1932 goto nla_put_failure
;
1933 pinfoattr
= nla_nest_start(msg
, NL80211_ATTR_MESH_PARAMS
);
1935 goto nla_put_failure
;
1936 NLA_PUT_U32(msg
, NL80211_ATTR_IFINDEX
, dev
->ifindex
);
1937 NLA_PUT_U16(msg
, NL80211_MESHCONF_RETRY_TIMEOUT
,
1938 cur_params
.dot11MeshRetryTimeout
);
1939 NLA_PUT_U16(msg
, NL80211_MESHCONF_CONFIRM_TIMEOUT
,
1940 cur_params
.dot11MeshConfirmTimeout
);
1941 NLA_PUT_U16(msg
, NL80211_MESHCONF_HOLDING_TIMEOUT
,
1942 cur_params
.dot11MeshHoldingTimeout
);
1943 NLA_PUT_U16(msg
, NL80211_MESHCONF_MAX_PEER_LINKS
,
1944 cur_params
.dot11MeshMaxPeerLinks
);
1945 NLA_PUT_U8(msg
, NL80211_MESHCONF_MAX_RETRIES
,
1946 cur_params
.dot11MeshMaxRetries
);
1947 NLA_PUT_U8(msg
, NL80211_MESHCONF_TTL
,
1948 cur_params
.dot11MeshTTL
);
1949 NLA_PUT_U8(msg
, NL80211_MESHCONF_AUTO_OPEN_PLINKS
,
1950 cur_params
.auto_open_plinks
);
1951 NLA_PUT_U8(msg
, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
,
1952 cur_params
.dot11MeshHWMPmaxPREQretries
);
1953 NLA_PUT_U32(msg
, NL80211_MESHCONF_PATH_REFRESH_TIME
,
1954 cur_params
.path_refresh_time
);
1955 NLA_PUT_U16(msg
, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
,
1956 cur_params
.min_discovery_timeout
);
1957 NLA_PUT_U32(msg
, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
,
1958 cur_params
.dot11MeshHWMPactivePathTimeout
);
1959 NLA_PUT_U16(msg
, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
,
1960 cur_params
.dot11MeshHWMPpreqMinInterval
);
1961 NLA_PUT_U16(msg
, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
,
1962 cur_params
.dot11MeshHWMPnetDiameterTraversalTime
);
1963 nla_nest_end(msg
, pinfoattr
);
1964 genlmsg_end(msg
, hdr
);
1965 err
= genlmsg_unicast(msg
, info
->snd_pid
);
1969 genlmsg_cancel(msg
, hdr
);
1973 cfg80211_put_dev(drv
);
1978 #define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \
1980 if (table[attr_num]) {\
1981 cfg.param = nla_fn(table[attr_num]); \
1982 mask |= (1 << (attr_num - 1)); \
1986 static struct nla_policy
1987 nl80211_meshconf_params_policy
[NL80211_MESHCONF_ATTR_MAX
+1] __read_mostly
= {
1988 [NL80211_MESHCONF_RETRY_TIMEOUT
] = { .type
= NLA_U16
},
1989 [NL80211_MESHCONF_CONFIRM_TIMEOUT
] = { .type
= NLA_U16
},
1990 [NL80211_MESHCONF_HOLDING_TIMEOUT
] = { .type
= NLA_U16
},
1991 [NL80211_MESHCONF_MAX_PEER_LINKS
] = { .type
= NLA_U16
},
1992 [NL80211_MESHCONF_MAX_RETRIES
] = { .type
= NLA_U8
},
1993 [NL80211_MESHCONF_TTL
] = { .type
= NLA_U8
},
1994 [NL80211_MESHCONF_AUTO_OPEN_PLINKS
] = { .type
= NLA_U8
},
1996 [NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
] = { .type
= NLA_U8
},
1997 [NL80211_MESHCONF_PATH_REFRESH_TIME
] = { .type
= NLA_U32
},
1998 [NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
] = { .type
= NLA_U16
},
1999 [NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
] = { .type
= NLA_U32
},
2000 [NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
] = { .type
= NLA_U16
},
2001 [NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
] = { .type
= NLA_U16
},
2004 static int nl80211_set_mesh_params(struct sk_buff
*skb
, struct genl_info
*info
)
2008 struct cfg80211_registered_device
*drv
;
2009 struct net_device
*dev
;
2010 struct mesh_config cfg
;
2011 struct nlattr
*tb
[NL80211_MESHCONF_ATTR_MAX
+ 1];
2012 struct nlattr
*parent_attr
;
2014 parent_attr
= info
->attrs
[NL80211_ATTR_MESH_PARAMS
];
2017 if (nla_parse_nested(tb
, NL80211_MESHCONF_ATTR_MAX
,
2018 parent_attr
, nl80211_meshconf_params_policy
))
2021 err
= get_drv_dev_by_info_ifindex(info
->attrs
, &drv
, &dev
);
2025 if (!drv
->ops
->set_mesh_params
) {
2030 /* This makes sure that there aren't more than 32 mesh config
2031 * parameters (otherwise our bitfield scheme would not work.) */
2032 BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX
> 32);
2034 /* Fill in the params struct */
2036 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshRetryTimeout
,
2037 mask
, NL80211_MESHCONF_RETRY_TIMEOUT
, nla_get_u16
);
2038 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshConfirmTimeout
,
2039 mask
, NL80211_MESHCONF_CONFIRM_TIMEOUT
, nla_get_u16
);
2040 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshHoldingTimeout
,
2041 mask
, NL80211_MESHCONF_HOLDING_TIMEOUT
, nla_get_u16
);
2042 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshMaxPeerLinks
,
2043 mask
, NL80211_MESHCONF_MAX_PEER_LINKS
, nla_get_u16
);
2044 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshMaxRetries
,
2045 mask
, NL80211_MESHCONF_MAX_RETRIES
, nla_get_u8
);
2046 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshTTL
,
2047 mask
, NL80211_MESHCONF_TTL
, nla_get_u8
);
2048 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, auto_open_plinks
,
2049 mask
, NL80211_MESHCONF_AUTO_OPEN_PLINKS
, nla_get_u8
);
2050 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshHWMPmaxPREQretries
,
2051 mask
, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES
,
2053 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, path_refresh_time
,
2054 mask
, NL80211_MESHCONF_PATH_REFRESH_TIME
, nla_get_u32
);
2055 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, min_discovery_timeout
,
2056 mask
, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT
,
2058 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshHWMPactivePathTimeout
,
2059 mask
, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT
,
2061 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
, dot11MeshHWMPpreqMinInterval
,
2062 mask
, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL
,
2064 FILL_IN_MESH_PARAM_IF_SET(tb
, cfg
,
2065 dot11MeshHWMPnetDiameterTraversalTime
,
2066 mask
, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME
,
2071 err
= drv
->ops
->set_mesh_params(&drv
->wiphy
, dev
, &cfg
, mask
);
2076 cfg80211_put_dev(drv
);
2081 #undef FILL_IN_MESH_PARAM_IF_SET
2083 static int nl80211_set_reg(struct sk_buff
*skb
, struct genl_info
*info
)
2085 struct nlattr
*tb
[NL80211_REG_RULE_ATTR_MAX
+ 1];
2086 struct nlattr
*nl_reg_rule
;
2087 char *alpha2
= NULL
;
2088 int rem_reg_rules
= 0, r
= 0;
2089 u32 num_rules
= 0, rule_idx
= 0, size_of_regd
;
2090 struct ieee80211_regdomain
*rd
= NULL
;
2092 if (!info
->attrs
[NL80211_ATTR_REG_ALPHA2
])
2095 if (!info
->attrs
[NL80211_ATTR_REG_RULES
])
2098 alpha2
= nla_data(info
->attrs
[NL80211_ATTR_REG_ALPHA2
]);
2100 nla_for_each_nested(nl_reg_rule
, info
->attrs
[NL80211_ATTR_REG_RULES
],
2103 if (num_rules
> NL80211_MAX_SUPP_REG_RULES
)
2107 if (!reg_is_valid_request(alpha2
))
2110 size_of_regd
= sizeof(struct ieee80211_regdomain
) +
2111 (num_rules
* sizeof(struct ieee80211_reg_rule
));
2113 rd
= kzalloc(size_of_regd
, GFP_KERNEL
);
2117 rd
->n_reg_rules
= num_rules
;
2118 rd
->alpha2
[0] = alpha2
[0];
2119 rd
->alpha2
[1] = alpha2
[1];
2121 nla_for_each_nested(nl_reg_rule
, info
->attrs
[NL80211_ATTR_REG_RULES
],
2123 nla_parse(tb
, NL80211_REG_RULE_ATTR_MAX
,
2124 nla_data(nl_reg_rule
), nla_len(nl_reg_rule
),
2126 r
= parse_reg_rule(tb
, &rd
->reg_rules
[rule_idx
]);
2132 if (rule_idx
> NL80211_MAX_SUPP_REG_RULES
)
2136 BUG_ON(rule_idx
!= num_rules
);
2138 mutex_lock(&cfg80211_drv_mutex
);
2140 mutex_unlock(&cfg80211_drv_mutex
);
2148 static struct genl_ops nl80211_ops
[] = {
2150 .cmd
= NL80211_CMD_GET_WIPHY
,
2151 .doit
= nl80211_get_wiphy
,
2152 .dumpit
= nl80211_dump_wiphy
,
2153 .policy
= nl80211_policy
,
2154 /* can be retrieved by unprivileged users */
2157 .cmd
= NL80211_CMD_SET_WIPHY
,
2158 .doit
= nl80211_set_wiphy
,
2159 .policy
= nl80211_policy
,
2160 .flags
= GENL_ADMIN_PERM
,
2163 .cmd
= NL80211_CMD_GET_INTERFACE
,
2164 .doit
= nl80211_get_interface
,
2165 .dumpit
= nl80211_dump_interface
,
2166 .policy
= nl80211_policy
,
2167 /* can be retrieved by unprivileged users */
2170 .cmd
= NL80211_CMD_SET_INTERFACE
,
2171 .doit
= nl80211_set_interface
,
2172 .policy
= nl80211_policy
,
2173 .flags
= GENL_ADMIN_PERM
,
2176 .cmd
= NL80211_CMD_NEW_INTERFACE
,
2177 .doit
= nl80211_new_interface
,
2178 .policy
= nl80211_policy
,
2179 .flags
= GENL_ADMIN_PERM
,
2182 .cmd
= NL80211_CMD_DEL_INTERFACE
,
2183 .doit
= nl80211_del_interface
,
2184 .policy
= nl80211_policy
,
2185 .flags
= GENL_ADMIN_PERM
,
2188 .cmd
= NL80211_CMD_GET_KEY
,
2189 .doit
= nl80211_get_key
,
2190 .policy
= nl80211_policy
,
2191 .flags
= GENL_ADMIN_PERM
,
2194 .cmd
= NL80211_CMD_SET_KEY
,
2195 .doit
= nl80211_set_key
,
2196 .policy
= nl80211_policy
,
2197 .flags
= GENL_ADMIN_PERM
,
2200 .cmd
= NL80211_CMD_NEW_KEY
,
2201 .doit
= nl80211_new_key
,
2202 .policy
= nl80211_policy
,
2203 .flags
= GENL_ADMIN_PERM
,
2206 .cmd
= NL80211_CMD_DEL_KEY
,
2207 .doit
= nl80211_del_key
,
2208 .policy
= nl80211_policy
,
2209 .flags
= GENL_ADMIN_PERM
,
2212 .cmd
= NL80211_CMD_SET_BEACON
,
2213 .policy
= nl80211_policy
,
2214 .flags
= GENL_ADMIN_PERM
,
2215 .doit
= nl80211_addset_beacon
,
2218 .cmd
= NL80211_CMD_NEW_BEACON
,
2219 .policy
= nl80211_policy
,
2220 .flags
= GENL_ADMIN_PERM
,
2221 .doit
= nl80211_addset_beacon
,
2224 .cmd
= NL80211_CMD_DEL_BEACON
,
2225 .policy
= nl80211_policy
,
2226 .flags
= GENL_ADMIN_PERM
,
2227 .doit
= nl80211_del_beacon
,
2230 .cmd
= NL80211_CMD_GET_STATION
,
2231 .doit
= nl80211_get_station
,
2232 .dumpit
= nl80211_dump_station
,
2233 .policy
= nl80211_policy
,
2234 .flags
= GENL_ADMIN_PERM
,
2237 .cmd
= NL80211_CMD_SET_STATION
,
2238 .doit
= nl80211_set_station
,
2239 .policy
= nl80211_policy
,
2240 .flags
= GENL_ADMIN_PERM
,
2243 .cmd
= NL80211_CMD_NEW_STATION
,
2244 .doit
= nl80211_new_station
,
2245 .policy
= nl80211_policy
,
2246 .flags
= GENL_ADMIN_PERM
,
2249 .cmd
= NL80211_CMD_DEL_STATION
,
2250 .doit
= nl80211_del_station
,
2251 .policy
= nl80211_policy
,
2252 .flags
= GENL_ADMIN_PERM
,
2255 .cmd
= NL80211_CMD_GET_MPATH
,
2256 .doit
= nl80211_get_mpath
,
2257 .dumpit
= nl80211_dump_mpath
,
2258 .policy
= nl80211_policy
,
2259 .flags
= GENL_ADMIN_PERM
,
2262 .cmd
= NL80211_CMD_SET_MPATH
,
2263 .doit
= nl80211_set_mpath
,
2264 .policy
= nl80211_policy
,
2265 .flags
= GENL_ADMIN_PERM
,
2268 .cmd
= NL80211_CMD_NEW_MPATH
,
2269 .doit
= nl80211_new_mpath
,
2270 .policy
= nl80211_policy
,
2271 .flags
= GENL_ADMIN_PERM
,
2274 .cmd
= NL80211_CMD_DEL_MPATH
,
2275 .doit
= nl80211_del_mpath
,
2276 .policy
= nl80211_policy
,
2277 .flags
= GENL_ADMIN_PERM
,
2280 .cmd
= NL80211_CMD_SET_BSS
,
2281 .doit
= nl80211_set_bss
,
2282 .policy
= nl80211_policy
,
2283 .flags
= GENL_ADMIN_PERM
,
2286 .cmd
= NL80211_CMD_SET_REG
,
2287 .doit
= nl80211_set_reg
,
2288 .policy
= nl80211_policy
,
2289 .flags
= GENL_ADMIN_PERM
,
2292 .cmd
= NL80211_CMD_REQ_SET_REG
,
2293 .doit
= nl80211_req_set_reg
,
2294 .policy
= nl80211_policy
,
2295 .flags
= GENL_ADMIN_PERM
,
2298 .cmd
= NL80211_CMD_GET_MESH_PARAMS
,
2299 .doit
= nl80211_get_mesh_params
,
2300 .policy
= nl80211_policy
,
2301 /* can be retrieved by unprivileged users */
2304 .cmd
= NL80211_CMD_SET_MESH_PARAMS
,
2305 .doit
= nl80211_set_mesh_params
,
2306 .policy
= nl80211_policy
,
2307 .flags
= GENL_ADMIN_PERM
,
2311 /* multicast groups */
2312 static struct genl_multicast_group nl80211_config_mcgrp
= {
2316 /* notification functions */
2318 void nl80211_notify_dev_rename(struct cfg80211_registered_device
*rdev
)
2320 struct sk_buff
*msg
;
2322 msg
= nlmsg_new(NLMSG_GOODSIZE
, GFP_KERNEL
);
2326 if (nl80211_send_wiphy(msg
, 0, 0, 0, rdev
) < 0) {
2331 genlmsg_multicast(msg
, 0, nl80211_config_mcgrp
.id
, GFP_KERNEL
);
2334 /* initialisation/exit functions */
2336 int nl80211_init(void)
2340 err
= genl_register_family(&nl80211_fam
);
2344 for (i
= 0; i
< ARRAY_SIZE(nl80211_ops
); i
++) {
2345 err
= genl_register_ops(&nl80211_fam
, &nl80211_ops
[i
]);
2350 err
= genl_register_mc_group(&nl80211_fam
, &nl80211_config_mcgrp
);
2356 genl_unregister_family(&nl80211_fam
);
2360 void nl80211_exit(void)
2362 genl_unregister_family(&nl80211_fam
);