cfg80211: handle SIOCGIWNAME
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / net / cfg80211.h
CommitLineData
704232c2
JB
1#ifndef __NET_CFG80211_H
2#define __NET_CFG80211_H
3
4#include <linux/netlink.h>
5#include <linux/skbuff.h>
55682965 6#include <linux/nl80211.h>
704232c2 7#include <net/genetlink.h>
fee52678
JB
8/* remove once we remove the wext stuff */
9#include <net/iw_handler.h>
704232c2
JB
10
11/*
12 * 802.11 configuration in-kernel interface
13 *
55682965 14 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
704232c2
JB
15 */
16
2ec600d6
LCC
17/**
18 * struct vif_params - describes virtual interface parameters
19 * @mesh_id: mesh ID to use
20 * @mesh_id_len: length of the mesh ID
21 */
22struct vif_params {
23 u8 *mesh_id;
24 int mesh_id_len;
25};
26
179f831b
AG
27/* Radiotap header iteration
28 * implemented in net/wireless/radiotap.c
29 * docs in Documentation/networking/radiotap-headers.txt
30 */
31/**
32 * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
33 * @rtheader: pointer to the radiotap header we are walking through
34 * @max_length: length of radiotap header in cpu byte ordering
35 * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
36 * @this_arg: pointer to current radiotap arg
37 * @arg_index: internal next argument index
38 * @arg: internal next argument pointer
39 * @next_bitmap: internal pointer to next present u32
40 * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
41 */
42
43struct ieee80211_radiotap_iterator {
44 struct ieee80211_radiotap_header *rtheader;
45 int max_length;
46 int this_arg_index;
47 u8 *this_arg;
48
49 int arg_index;
50 u8 *arg;
51 __le32 *next_bitmap;
52 u32 bitmap_shifter;
53};
54
55extern int ieee80211_radiotap_iterator_init(
56 struct ieee80211_radiotap_iterator *iterator,
57 struct ieee80211_radiotap_header *radiotap_header,
58 int max_length);
59
60extern int ieee80211_radiotap_iterator_next(
61 struct ieee80211_radiotap_iterator *iterator);
62
63
41ade00f
JB
64 /**
65 * struct key_params - key information
66 *
67 * Information about a key
68 *
69 * @key: key material
70 * @key_len: length of key material
71 * @cipher: cipher suite selector
72 * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
73 * with the get_key() callback, must be in little endian,
74 * length given by @seq_len.
75 */
76struct key_params {
77 u8 *key;
78 u8 *seq;
79 int key_len;
80 int seq_len;
81 u32 cipher;
82};
83
ed1b6cc7
JB
84/**
85 * struct beacon_parameters - beacon parameters
86 *
87 * Used to configure the beacon for an interface.
88 *
89 * @head: head portion of beacon (before TIM IE)
90 * or %NULL if not changed
91 * @tail: tail portion of beacon (after TIM IE)
92 * or %NULL if not changed
93 * @interval: beacon interval or zero if not changed
94 * @dtim_period: DTIM period or zero if not changed
95 * @head_len: length of @head
96 * @tail_len: length of @tail
97 */
98struct beacon_parameters {
99 u8 *head, *tail;
100 int interval, dtim_period;
101 int head_len, tail_len;
102};
103
5727ef1b
JB
104/**
105 * enum station_flags - station flags
106 *
107 * Station capability flags. Note that these must be the bits
108 * according to the nl80211 flags.
109 *
110 * @STATION_FLAG_CHANGED: station flags were changed
111 * @STATION_FLAG_AUTHORIZED: station is authorized to send frames (802.1X)
112 * @STATION_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
113 * with short preambles
114 * @STATION_FLAG_WME: station is WME/QoS capable
115 */
116enum station_flags {
117 STATION_FLAG_CHANGED = 1<<0,
118 STATION_FLAG_AUTHORIZED = 1<<NL80211_STA_FLAG_AUTHORIZED,
119 STATION_FLAG_SHORT_PREAMBLE = 1<<NL80211_STA_FLAG_SHORT_PREAMBLE,
120 STATION_FLAG_WME = 1<<NL80211_STA_FLAG_WME,
121};
122
2ec600d6
LCC
123/**
124 * enum plink_action - actions to perform in mesh peers
125 *
126 * @PLINK_ACTION_INVALID: action 0 is reserved
127 * @PLINK_ACTION_OPEN: start mesh peer link establishment
128 * @PLINK_ACTION_BLOCL: block traffic from this mesh peer
129 */
130enum plink_actions {
131 PLINK_ACTION_INVALID,
132 PLINK_ACTION_OPEN,
133 PLINK_ACTION_BLOCK,
134};
135
5727ef1b
JB
136/**
137 * struct station_parameters - station parameters
138 *
139 * Used to change and create a new station.
140 *
141 * @vlan: vlan interface station should belong to
142 * @supported_rates: supported rates in IEEE 802.11 format
143 * (or NULL for no change)
144 * @supported_rates_len: number of supported rates
145 * @station_flags: station flags (see &enum station_flags)
146 * @listen_interval: listen interval or -1 for no change
147 * @aid: AID or zero for no change
148 */
149struct station_parameters {
150 u8 *supported_rates;
151 struct net_device *vlan;
152 u32 station_flags;
153 int listen_interval;
154 u16 aid;
155 u8 supported_rates_len;
2ec600d6 156 u8 plink_action;
36aedc90 157 struct ieee80211_ht_cap *ht_capa;
5727ef1b
JB
158};
159
fd5b74dc 160/**
2ec600d6 161 * enum station_info_flags - station information flags
fd5b74dc 162 *
2ec600d6
LCC
163 * Used by the driver to indicate which info in &struct station_info
164 * it has filled in during get_station() or dump_station().
fd5b74dc 165 *
2ec600d6
LCC
166 * @STATION_INFO_INACTIVE_TIME: @inactive_time filled
167 * @STATION_INFO_RX_BYTES: @rx_bytes filled
168 * @STATION_INFO_TX_BYTES: @tx_bytes filled
169 * @STATION_INFO_LLID: @llid filled
170 * @STATION_INFO_PLID: @plid filled
171 * @STATION_INFO_PLINK_STATE: @plink_state filled
fd5b74dc 172 */
2ec600d6
LCC
173enum station_info_flags {
174 STATION_INFO_INACTIVE_TIME = 1<<0,
175 STATION_INFO_RX_BYTES = 1<<1,
176 STATION_INFO_TX_BYTES = 1<<2,
177 STATION_INFO_LLID = 1<<3,
178 STATION_INFO_PLID = 1<<4,
179 STATION_INFO_PLINK_STATE = 1<<5,
fd5b74dc
JB
180};
181
182/**
2ec600d6 183 * struct station_info - station information
fd5b74dc 184 *
2ec600d6 185 * Station information filled by driver for get_station() and dump_station.
fd5b74dc 186 *
2ec600d6 187 * @filled: bitflag of flags from &enum station_info_flags
fd5b74dc
JB
188 * @inactive_time: time since last station activity (tx/rx) in milliseconds
189 * @rx_bytes: bytes received from this station
190 * @tx_bytes: bytes transmitted to this station
2ec600d6
LCC
191 * @llid: mesh local link id
192 * @plid: mesh peer link id
193 * @plink_state: mesh peer link state
fd5b74dc 194 */
2ec600d6 195struct station_info {
fd5b74dc
JB
196 u32 filled;
197 u32 inactive_time;
198 u32 rx_bytes;
199 u32 tx_bytes;
2ec600d6
LCC
200 u16 llid;
201 u16 plid;
202 u8 plink_state;
fd5b74dc
JB
203};
204
66f7ac50
MW
205/**
206 * enum monitor_flags - monitor flags
207 *
208 * Monitor interface configuration flags. Note that these must be the bits
209 * according to the nl80211 flags.
210 *
211 * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS
212 * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP
213 * @MONITOR_FLAG_CONTROL: pass control frames
214 * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering
215 * @MONITOR_FLAG_COOK_FRAMES: report frames after processing
216 */
217enum monitor_flags {
218 MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL,
219 MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL,
220 MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL,
221 MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS,
222 MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES,
223};
224
2ec600d6
LCC
225/**
226 * enum mpath_info_flags - mesh path information flags
227 *
228 * Used by the driver to indicate which info in &struct mpath_info it has filled
229 * in during get_station() or dump_station().
230 *
231 * MPATH_INFO_FRAME_QLEN: @frame_qlen filled
232 * MPATH_INFO_DSN: @dsn filled
233 * MPATH_INFO_METRIC: @metric filled
234 * MPATH_INFO_EXPTIME: @exptime filled
235 * MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled
236 * MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled
237 * MPATH_INFO_FLAGS: @flags filled
238 */
239enum mpath_info_flags {
240 MPATH_INFO_FRAME_QLEN = BIT(0),
241 MPATH_INFO_DSN = BIT(1),
242 MPATH_INFO_METRIC = BIT(2),
243 MPATH_INFO_EXPTIME = BIT(3),
244 MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4),
245 MPATH_INFO_DISCOVERY_RETRIES = BIT(5),
246 MPATH_INFO_FLAGS = BIT(6),
247};
248
249/**
250 * struct mpath_info - mesh path information
251 *
252 * Mesh path information filled by driver for get_mpath() and dump_mpath().
253 *
254 * @filled: bitfield of flags from &enum mpath_info_flags
255 * @frame_qlen: number of queued frames for this destination
256 * @dsn: destination sequence number
257 * @metric: metric (cost) of this mesh path
258 * @exptime: expiration time for the mesh path from now, in msecs
259 * @flags: mesh path flags
260 * @discovery_timeout: total mesh path discovery timeout, in msecs
261 * @discovery_retries: mesh path discovery retries
262 */
263struct mpath_info {
264 u32 filled;
265 u32 frame_qlen;
266 u32 dsn;
267 u32 metric;
268 u32 exptime;
269 u32 discovery_timeout;
270 u8 discovery_retries;
271 u8 flags;
272};
273
9f1ba906
JM
274/**
275 * struct bss_parameters - BSS parameters
276 *
277 * Used to change BSS parameters (mainly for AP mode).
278 *
279 * @use_cts_prot: Whether to use CTS protection
280 * (0 = no, 1 = yes, -1 = do not change)
281 * @use_short_preamble: Whether the use of short preambles is allowed
282 * (0 = no, 1 = yes, -1 = do not change)
283 * @use_short_slot_time: Whether the use of short slot time is allowed
284 * (0 = no, 1 = yes, -1 = do not change)
90c97a04
JM
285 * @basic_rates: basic rates in IEEE 802.11 format
286 * (or NULL for no change)
287 * @basic_rates_len: number of basic rates
9f1ba906
JM
288 */
289struct bss_parameters {
290 int use_cts_prot;
291 int use_short_preamble;
292 int use_short_slot_time;
90c97a04
JM
293 u8 *basic_rates;
294 u8 basic_rates_len;
9f1ba906 295};
2ec600d6 296
b2e1b302
LR
297/**
298 * enum reg_set_by - Indicates who is trying to set the regulatory domain
299 * @REGDOM_SET_BY_INIT: regulatory domain was set by initialization. We will be
300 * using a static world regulatory domain by default.
301 * @REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world regulatory domain.
302 * @REGDOM_SET_BY_USER: User asked the wireless core to set the
303 * regulatory domain.
304 * @REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the wireless core
305 * it thinks its knows the regulatory domain we should be in.
306 * @REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an 802.11 country
307 * information element with regulatory information it thinks we
308 * should consider.
309 */
310enum reg_set_by {
311 REGDOM_SET_BY_INIT,
312 REGDOM_SET_BY_CORE,
313 REGDOM_SET_BY_USER,
314 REGDOM_SET_BY_DRIVER,
315 REGDOM_SET_BY_COUNTRY_IE,
316};
317
318struct ieee80211_freq_range {
319 u32 start_freq_khz;
320 u32 end_freq_khz;
321 u32 max_bandwidth_khz;
322};
323
324struct ieee80211_power_rule {
325 u32 max_antenna_gain;
326 u32 max_eirp;
327};
328
329struct ieee80211_reg_rule {
330 struct ieee80211_freq_range freq_range;
331 struct ieee80211_power_rule power_rule;
332 u32 flags;
333};
334
335struct ieee80211_regdomain {
336 u32 n_reg_rules;
337 char alpha2[2];
338 struct ieee80211_reg_rule reg_rules[];
339};
340
b219cee1
LR
341#define MHZ_TO_KHZ(freq) ((freq) * 1000)
342#define KHZ_TO_MHZ(freq) ((freq) / 1000)
343#define DBI_TO_MBI(gain) ((gain) * 100)
344#define MBI_TO_DBI(gain) ((gain) / 100)
345#define DBM_TO_MBM(gain) ((gain) * 100)
346#define MBM_TO_DBM(gain) ((gain) / 100)
b2e1b302
LR
347
348#define REG_RULE(start, end, bw, gain, eirp, reg_flags) { \
b219cee1
LR
349 .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \
350 .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \
351 .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \
352 .power_rule.max_antenna_gain = DBI_TO_MBI(gain), \
353 .power_rule.max_eirp = DBM_TO_MBM(eirp), \
b2e1b302
LR
354 .flags = reg_flags, \
355 }
356
93da9cc1 357struct mesh_config {
358 /* Timeouts in ms */
359 /* Mesh plink management parameters */
360 u16 dot11MeshRetryTimeout;
361 u16 dot11MeshConfirmTimeout;
362 u16 dot11MeshHoldingTimeout;
363 u16 dot11MeshMaxPeerLinks;
364 u8 dot11MeshMaxRetries;
365 u8 dot11MeshTTL;
366 bool auto_open_plinks;
367 /* HWMP parameters */
368 u8 dot11MeshHWMPmaxPREQretries;
369 u32 path_refresh_time;
370 u16 min_discovery_timeout;
371 u32 dot11MeshHWMPactivePathTimeout;
372 u16 dot11MeshHWMPpreqMinInterval;
373 u16 dot11MeshHWMPnetDiameterTraversalTime;
374};
375
31888487
JM
376/**
377 * struct ieee80211_txq_params - TX queue parameters
378 * @queue: TX queue identifier (NL80211_TXQ_Q_*)
379 * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled
380 * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range
381 * 1..32767]
382 * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range
383 * 1..32767]
384 * @aifs: Arbitration interframe space [0..255]
385 */
386struct ieee80211_txq_params {
387 enum nl80211_txq_q queue;
388 u16 txop;
389 u16 cwmin;
390 u16 cwmax;
391 u8 aifs;
392};
393
704232c2
JB
394/* from net/wireless.h */
395struct wiphy;
396
72bdcf34
JM
397/* from net/ieee80211.h */
398struct ieee80211_channel;
399
704232c2
JB
400/**
401 * struct cfg80211_ops - backend description for wireless configuration
402 *
403 * This struct is registered by fullmac card drivers and/or wireless stacks
404 * in order to handle configuration requests on their interfaces.
405 *
406 * All callbacks except where otherwise noted should return 0
407 * on success or a negative error code.
408 *
43fb45cb
JB
409 * All operations are currently invoked under rtnl for consistency with the
410 * wireless extensions but this is subject to reevaluation as soon as this
411 * code is used more widely and we have a first user without wext.
412 *
60719ffd
JB
413 * @add_virtual_intf: create a new virtual interface with the given name,
414 * must set the struct wireless_dev's iftype.
704232c2
JB
415 *
416 * @del_virtual_intf: remove the virtual interface determined by ifindex.
55682965 417 *
60719ffd
JB
418 * @change_virtual_intf: change type/configuration of virtual interface,
419 * keep the struct wireless_dev's iftype updated.
55682965 420 *
41ade00f
JB
421 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
422 * when adding a group key.
423 *
424 * @get_key: get information about the key with the given parameters.
425 * @mac_addr will be %NULL when requesting information for a group
426 * key. All pointers given to the @callback function need not be valid
427 * after it returns.
428 *
429 * @del_key: remove a key given the @mac_addr (%NULL for a group key)
430 * and @key_index
431 *
432 * @set_default_key: set the default key on an interface
ed1b6cc7
JB
433 *
434 * @add_beacon: Add a beacon with given parameters, @head, @interval
435 * and @dtim_period will be valid, @tail is optional.
436 * @set_beacon: Change the beacon parameters for an access point mode
437 * interface. This should reject the call when no beacon has been
438 * configured.
439 * @del_beacon: Remove beacon configuration and stop sending the beacon.
5727ef1b
JB
440 *
441 * @add_station: Add a new station.
442 *
443 * @del_station: Remove a station; @mac may be NULL to remove all stations.
444 *
445 * @change_station: Modify a given station.
2ec600d6 446 *
93da9cc1 447 * @get_mesh_params: Put the current mesh parameters into *params
448 *
449 * @set_mesh_params: Set mesh parameters.
450 * The mask is a bitfield which tells us which parameters to
451 * set, and which to leave alone.
452 *
2ec600d6 453 * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
9f1ba906
JM
454 *
455 * @change_bss: Modify parameters for a given BSS.
31888487
JM
456 *
457 * @set_txq_params: Set TX queue parameters
72bdcf34
JM
458 *
459 * @set_channel: Set channel
704232c2
JB
460 */
461struct cfg80211_ops {
462 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
2ec600d6
LCC
463 enum nl80211_iftype type, u32 *flags,
464 struct vif_params *params);
704232c2 465 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
55682965 466 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
2ec600d6
LCC
467 enum nl80211_iftype type, u32 *flags,
468 struct vif_params *params);
41ade00f
JB
469
470 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
471 u8 key_index, u8 *mac_addr,
472 struct key_params *params);
473 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
474 u8 key_index, u8 *mac_addr, void *cookie,
475 void (*callback)(void *cookie, struct key_params*));
476 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
477 u8 key_index, u8 *mac_addr);
478 int (*set_default_key)(struct wiphy *wiphy,
479 struct net_device *netdev,
480 u8 key_index);
ed1b6cc7
JB
481
482 int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
483 struct beacon_parameters *info);
484 int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
485 struct beacon_parameters *info);
486 int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
5727ef1b
JB
487
488
489 int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
490 u8 *mac, struct station_parameters *params);
491 int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
492 u8 *mac);
493 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
494 u8 *mac, struct station_parameters *params);
fd5b74dc 495 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
2ec600d6
LCC
496 u8 *mac, struct station_info *sinfo);
497 int (*dump_station)(struct wiphy *wiphy, struct net_device *dev,
498 int idx, u8 *mac, struct station_info *sinfo);
499
500 int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev,
501 u8 *dst, u8 *next_hop);
502 int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev,
503 u8 *dst);
504 int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev,
505 u8 *dst, u8 *next_hop);
506 int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev,
507 u8 *dst, u8 *next_hop,
508 struct mpath_info *pinfo);
509 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
510 int idx, u8 *dst, u8 *next_hop,
511 struct mpath_info *pinfo);
93da9cc1 512 int (*get_mesh_params)(struct wiphy *wiphy,
513 struct net_device *dev,
514 struct mesh_config *conf);
515 int (*set_mesh_params)(struct wiphy *wiphy,
516 struct net_device *dev,
517 const struct mesh_config *nconf, u32 mask);
9f1ba906
JM
518 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
519 struct bss_parameters *params);
31888487
JM
520
521 int (*set_txq_params)(struct wiphy *wiphy,
522 struct ieee80211_txq_params *params);
72bdcf34
JM
523
524 int (*set_channel)(struct wiphy *wiphy,
525 struct ieee80211_channel *chan,
526 enum nl80211_sec_chan_offset);
704232c2
JB
527};
528
fee52678
JB
529/* temporary wext handlers */
530int cfg80211_wext_giwname(struct net_device *dev,
531 struct iw_request_info *info,
532 char *name, char *extra);
533
704232c2 534#endif /* __NET_CFG80211_H */