add common functions for the new config file format
[openwrt/svn-archive/archive.git] / openwrt / target / linux / package / ieee80211-dscape / src / hostapd_ioctl.h
1 /*
2 * Host AP (software wireless LAN access point) user space daemon for
3 * Host AP kernel driver
4 * Copyright 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
5 * Copyright 2002-2004, Instant802 Networks, Inc.
6 * Copyright 2005, Devicescape Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13 #ifndef HOSTAPD_IOCTL_H
14 #define HOSTAPD_IOCTL_H
15
16 #ifndef __KERNEL__
17 #include "ieee80211_shared.h"
18 #endif /* __KERNEL__ */
19
20 #define PRISM2_IOCTL_PRISM2_PARAM (SIOCIWFIRSTPRIV + 0)
21 #define PRISM2_IOCTL_GET_PRISM2_PARAM (SIOCIWFIRSTPRIV + 1)
22 #define PRISM2_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 3)
23 #define PRISM2_IOCTL_TEST_PARAM (SIOCIWFIRSTPRIV + 4)
24
25 /* PRISM2_IOCTL_PRISM2_PARAM ioctl() subtypes: */
26 enum {
27 PRISM2_PARAM_PTYPE = 1,
28 PRISM2_PARAM_TXRATECTRL = 2,
29 PRISM2_PARAM_BEACON_INT = 3,
30 PRISM2_PARAM_PSEUDO_IBSS = 4,
31 PRISM2_PARAM_ALC = 5,
32 PRISM2_PARAM_TXPOWER = 6,
33 PRISM2_PARAM_DUMP = 7,
34 PRISM2_PARAM_OTHER_AP_POLICY = 8,
35 PRISM2_PARAM_AP_MAX_INACTIVITY = 9,
36 PRISM2_PARAM_AP_BRIDGE_PACKETS = 10,
37 PRISM2_PARAM_DTIM_PERIOD = 11,
38 PRISM2_PARAM_AP_NULLFUNC_ACK = 12,
39 PRISM2_PARAM_MAX_WDS = 13,
40 PRISM2_PARAM_AP_AUTOM_AP_WDS = 14,
41 PRISM2_PARAM_AP_AUTH_ALGS = 15,
42 PRISM2_PARAM_MONITOR_ALLOW_FCSERR = 16,
43 PRISM2_PARAM_HOST_ENCRYPT = 17,
44 PRISM2_PARAM_HOST_DECRYPT = 18,
45 PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX = 19,
46 PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX = 20,
47 PRISM2_PARAM_HOST_ROAMING = 21,
48 PRISM2_PARAM_BCRX_STA_KEY = 22,
49 PRISM2_PARAM_IEEE_802_1X = 23,
50 PRISM2_PARAM_ANTSEL_TX = 24,
51 PRISM2_PARAM_ANTSEL_RX = 25,
52 PRISM2_PARAM_MONITOR_TYPE = 26,
53 PRISM2_PARAM_WDS_TYPE = 27,
54 PRISM2_PARAM_HOSTSCAN = 28,
55 PRISM2_PARAM_AP_SCAN = 29,
56
57 /* Instant802 additions */
58 PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES = 1001,
59 PRISM2_PARAM_DROP_UNENCRYPTED = 1002,
60 PRISM2_PARAM_PREAMBLE = 1003,
61 PRISM2_PARAM_RATE_LIMIT = 1004,
62 PRISM2_PARAM_RATE_LIMIT_BURST = 1005,
63 PRISM2_PARAM_SHORT_SLOT_TIME = 1006,
64 PRISM2_PARAM_TEST_MODE = 1007,
65 PRISM2_PARAM_NEXT_MODE = 1008,
66 PRISM2_PARAM_CLEAR_KEYS = 1009,
67 PRISM2_PARAM_ADM_STATUS = 1010,
68 PRISM2_PARAM_ANTENNA_SEL = 1011,
69 PRISM2_PARAM_CALIB_INT = 1012,
70 PRISM2_PARAM_ANTENNA_MODE = 1013,
71 PRISM2_PARAM_PRIVACY_INVOKED = 1014,
72 PRISM2_PARAM_BROADCAST_SSID = 1015,
73 PRISM2_PARAM_STAT_TIME = 1016,
74 PRISM2_PARAM_STA_ANTENNA_SEL = 1017,
75 PRISM2_PARAM_FORCE_UNICAST_RATE = 1018,
76 PRISM2_PARAM_RATE_CTRL_NUM_UP = 1019,
77 PRISM2_PARAM_RATE_CTRL_NUM_DOWN = 1020,
78 PRISM2_PARAM_MAX_RATECTRL_RATE = 1021,
79 PRISM2_PARAM_TX_POWER_REDUCTION = 1022,
80 PRISM2_PARAM_EAPOL = 1023,
81 PRISM2_PARAM_KEY_TX_RX_THRESHOLD = 1024,
82 PRISM2_PARAM_KEY_INDEX = 1025,
83 PRISM2_PARAM_DEFAULT_WEP_ONLY = 1026,
84 PRISM2_PARAM_WIFI_WME_NOACK_TEST = 1033,
85 PRISM2_PARAM_ALLOW_BROADCAST_ALWAYS = 1034,
86 PRISM2_PARAM_SCAN_FLAGS = 1035,
87 PRISM2_PARAM_HW_MODES = 1036,
88 PRISM2_PARAM_CREATE_IBSS = 1037,
89 PRISM2_PARAM_WMM_ENABLED = 1038,
90 PRISM2_PARAM_MIXED_CELL = 1039,
91 PRISM2_PARAM_KEY_MGMT = 1040,
92 PRISM2_PARAM_RADAR_DETECT = 1043,
93 PRISM2_PARAM_SPECTRUM_MGMT = 1044,
94 /* NOTE: Please try to coordinate with other active development
95 * branches before allocating new param numbers so that each new param
96 * will be unique within all branches and the allocated number will not
97 * need to be changed when merging new features. Existing numbers in
98 * the mainline (or main devel branch) must not be changed when merging
99 * in new features. */
100 };
101
102 /* PRISM2_IOCTL_HOSTAPD ioctl() cmd: */
103 enum {
104 PRISM2_HOSTAPD_FLUSH = 1,
105 PRISM2_HOSTAPD_ADD_STA = 2,
106 PRISM2_HOSTAPD_REMOVE_STA = 3,
107 PRISM2_HOSTAPD_GET_INFO_STA = 4,
108 /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
109 PRISM2_SET_ENCRYPTION = 6,
110 PRISM2_GET_ENCRYPTION = 7,
111 PRISM2_HOSTAPD_SET_FLAGS_STA = 8,
112 PRISM2_HOSTAPD_GET_RID = 9,
113 PRISM2_HOSTAPD_SET_RID = 10,
114 PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
115 PRISM2_HOSTAPD_MLME = 13,
116
117 /* Instant802 additions */
118 PRISM2_HOSTAPD_SET_BEACON = 1001,
119 PRISM2_HOSTAPD_GET_HW_FEATURES = 1002,
120 PRISM2_HOSTAPD_SCAN = 1003,
121 PRISM2_HOSTAPD_WPA_TRIGGER = 1004,
122 PRISM2_HOSTAPD_SET_RATE_SETS = 1005,
123 PRISM2_HOSTAPD_ADD_IF = 1006,
124 PRISM2_HOSTAPD_REMOVE_IF = 1007,
125 PRISM2_HOSTAPD_GET_DOT11COUNTERSTABLE = 1008,
126 PRISM2_HOSTAPD_GET_LOAD_STATS = 1009,
127 PRISM2_HOSTAPD_SET_STA_VLAN = 1010,
128 PRISM2_HOSTAPD_SET_GENERIC_INFO_ELEM = 1011,
129 PRISM2_HOSTAPD_SET_CHANNEL_FLAG = 1012,
130 PRISM2_HOSTAPD_SET_REGULATORY_DOMAIN = 1013,
131 PRISM2_HOSTAPD_SET_TX_QUEUE_PARAMS = 1014,
132 PRISM2_HOSTAPD_SET_BSS = 1015,
133 PRISM2_HOSTAPD_GET_TX_STATS = 1016,
134 PRISM2_HOSTAPD_UPDATE_IF = 1017,
135 PRISM2_HOSTAPD_SCAN_REQ = 1019,
136 PRISM2_STA_GET_STATE = 1020,
137 PRISM2_HOSTAPD_FLUSH_IFS = 1021,
138 PRISM2_HOSTAPD_SET_RADAR_PARAMS = 1023,
139 PRISM2_HOSTAPD_SET_QUIET_PARAMS = 1024,
140 PRISM2_HOSTAPD_GET_TX_POWER = 1025,
141 /* NOTE: Please try to coordinate with other active development
142 * branches before allocating new param numbers so that each new param
143 * will be unique within all branches and the allocated number will not
144 * need to be changed when merging new features. Existing numbers in
145 * the mainline (or main devel branch) must not be changed when merging
146 * in new features. */
147 };
148
149 /* these definitions mirror the ieee80211_i.h
150 * IEEE80211_DISABLED, ... IEEE80211_ASSOCIATED enumeration */
151 enum {
152 PRISM2_PARAM_STA_DISABLED,
153 PRISM2_PARAM_STA_AUTHENTICATE,
154 PRISM2_PARAM_STA_ASSOCIATE,
155 PRISM2_PARAM_STA_ASSOCIATED,
156 };
157
158 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 2048
159 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
160
161 /* Use this to make sure that structure elements are correctly aligned
162 * for access as other types. Most commonly, this affects the placeholder
163 * types used for data at the end of a structure in this union.
164 */
165 #ifdef __GNUC__
166 #undef ALIGNED
167 #define ALIGNED __attribute__ ((aligned))
168 #else
169 /* Check if it has been defined elsewhere */
170 #ifndef ALIGNED
171 #error "Must define ALIGNED to generate aligned structure elements"
172 #endif
173 #endif
174
175 struct prism2_hostapd_param {
176 u32 cmd;
177 u8 sta_addr[ETH_ALEN];
178 u8 pad[2];
179 union {
180 struct {
181 u16 aid;
182 u16 capability;
183 u8 supp_rates[32];
184 /* atheros_super_ag and enc_flags are only used with
185 * IEEE80211_ATHEROS_SUPER_AG
186 */
187 u8 atheros_super_ag;
188 u8 atheros_xr_mode;
189 u8 wds_flags;
190 #define IEEE80211_STA_DYNAMIC_ENC BIT(0)
191 u8 enc_flags;
192 } add_sta;
193 struct {
194 u32 inactive_msec;
195 u32 rx_packets;
196 u32 tx_packets;
197 u32 rx_bytes;
198 u32 tx_bytes;
199 u32 current_tx_rate; /* in 100 kbps */
200 u32 channel_use;
201 u32 flags;
202 u32 num_ps_buf_frames;
203 u32 tx_retry_failed;
204 u32 tx_retry_count;
205 u32 last_rssi;
206 u32 last_ack_rssi;
207 } get_info_sta;
208 struct {
209 u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
210 u32 flags;
211 u32 err;
212 u8 idx;
213 #define HOSTAP_SEQ_COUNTER_SIZE 8
214 u8 seq_counter[HOSTAP_SEQ_COUNTER_SIZE];
215 u16 key_len;
216 u8 key[0] ALIGNED;
217 } crypt;
218 struct {
219 u32 flags_and;
220 u32 flags_or;
221 } set_flags_sta;
222 struct {
223 u16 rid;
224 u16 len;
225 u8 data[0] ALIGNED;
226 } rid;
227 struct {
228 u16 head_len;
229 u16 tail_len;
230 u8 data[0] ALIGNED; /* head_len + tail_len bytes */
231 } beacon;
232 struct {
233 u16 num_modes;
234 u16 flags;
235 u8 data[0] ALIGNED; /* num_modes * feature data */
236 } hw_features;
237 struct {
238 u8 now;
239 s8 our_mode_only;
240 s16 last_rx;
241 u16 channel;
242 s16 interval; /* seconds */
243 s32 listen; /* microseconds */
244 } scan;
245 struct {
246 #define WPA_TRIGGER_FAIL_TX_MIC BIT(0)
247 #define WPA_TRIGGER_FAIL_TX_ICV BIT(1)
248 #define WPA_TRIGGER_FAIL_RX_MIC BIT(2)
249 #define WPA_TRIGGER_FAIL_RX_ICV BIT(3)
250 #define WPA_TRIGGER_TX_REPLAY BIT(4)
251 #define WPA_TRIGGER_TX_REPLAY_FRAG BIT(5)
252 #define WPA_TRIGGER_TX_SKIP_SEQ BIT(6)
253 u32 trigger;
254 } wpa_trigger;
255 struct {
256 u16 mode; /* MODE_* */
257 u16 num_supported_rates;
258 u16 num_basic_rates;
259 u8 data[0] ALIGNED; /* num_supported_rates * u16 +
260 * num_basic_rates * u16 */
261 } set_rate_sets;
262 struct {
263 u8 type; /* WDS, VLAN, etc */
264 u8 name[IFNAMSIZ];
265 u8 data[0] ALIGNED;
266 } if_info;
267 struct dot11_counters {
268 u32 dot11TransmittedFragmentCount;
269 u32 dot11MulticastTransmittedFrameCount;
270 u32 dot11FailedCount;
271 u32 dot11ReceivedFragmentCount;
272 u32 dot11MulticastReceivedFrameCount;
273 u32 dot11FCSErrorCount;
274 u32 dot11TransmittedFrameCount;
275 u32 dot11WEPUndecryptableCount;
276 u32 dot11ACKFailureCount;
277 u32 dot11RTSFailureCount;
278 u32 dot11RTSSuccessCount;
279 } dot11CountersTable;
280 struct {
281 #define LOAD_STATS_CLEAR BIT(1)
282 u32 flags;
283 u32 channel_use;
284 } get_load_stats;
285 struct {
286 char vlan_name[IFNAMSIZ];
287 int vlan_id;
288 } set_sta_vlan;
289 struct {
290 u8 len;
291 u8 data[0] ALIGNED;
292 } set_generic_info_elem;
293 struct {
294 u16 mode; /* MODE_* */
295 u16 chan;
296 u32 flag;
297 u8 power_level; /* regulatory limit in dBm */
298 u8 antenna_max;
299 } set_channel_flag;
300 struct {
301 u32 rd;
302 } set_regulatory_domain;
303 struct {
304 u32 queue;
305 s32 aifs;
306 u32 cw_min;
307 u32 cw_max;
308 u32 burst_time; /* maximum burst time in 0.1 ms, i.e.,
309 * 10 = 1 ms */
310 } tx_queue_params;
311 struct {
312 u32 bss_count;
313 u8 bssid_mask[ETH_ALEN];
314 } set_bss;
315 struct ieee80211_tx_stats {
316 struct {
317 unsigned int len; /* num packets in queue */
318 unsigned int limit; /* queue len (soft) limit
319 */
320 unsigned int count; /* total num frames sent */
321 } data[4];
322 } get_tx_stats;
323 struct {
324 u8 ssid_len;
325 u8 ssid[0] ALIGNED;
326 } scan_req;
327 struct {
328 u32 state;
329 } sta_get_state;
330 struct {
331 #define MLME_STA_DEAUTH 0
332 #define MLME_STA_DISASSOC 1
333 u16 cmd;
334 u16 reason_code;
335 } mlme;
336 struct {
337 unsigned int value;
338 /* TODO
339 int pulse_width;
340 int num_pulse;
341 int period;
342 */
343 }radar;
344 struct {
345 unsigned int period;
346 unsigned int offset;
347 unsigned int duration;
348 }quiet;
349 struct {
350 unsigned int tx_power_min;
351 unsigned int tx_power_max;
352 }tx_power;
353 struct {
354 u8 dummy[80]; /* Make sizeof() this struct large enough
355 * with some compiler versions. */
356 } dummy;
357 } u;
358 };
359
360
361 #ifndef IEEE80211_TX_QUEUE_NUMS
362 #define IEEE80211_TX_QUEUE_NUMS
363 /* TODO: these need to be synchronized with ieee80211.h; make a shared header
364 * file that can be included into low-level drivers, 80211.o, and hostapd */
365 /* tx_queue_params - queue */
366 enum {
367 IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */
368 IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */
369 IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */
370 IEEE80211_TX_QUEUE_DATA3 = 3, /* used for EDCA AC_BK data */
371 IEEE80211_TX_QUEUE_DATA4 = 4,
372 IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
373 IEEE80211_TX_QUEUE_BEACON = 7
374 };
375 #endif /* IEEE80211_TX_QUEUE_NUMS */
376
377
378 #define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT(0)
379 #define HOSTAP_CRYPT_FLAG_PERMANENT BIT(1)
380
381 #define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
382 #define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
383 #define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
384 #define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
385 #define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
386 #define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
387
388 #define HOSTAP_HW_FLAG_NULLFUNC_OK BIT(0)
389
390 enum {
391 IEEE80211_KEY_MGMT_NONE = 0,
392 IEEE80211_KEY_MGMT_IEEE8021X = 1,
393 IEEE80211_KEY_MGMT_WPA_PSK = 2,
394 IEEE80211_KEY_MGMT_WPA_EAP = 3,
395 };
396
397
398 /* Data structures used for get_hw_features ioctl */
399 struct hostapd_ioctl_hw_modes_hdr {
400 int mode;
401 int num_channels;
402 int num_rates;
403 };
404
405 struct ieee80211_channel_data {
406 short chan; /* channel number (IEEE 802.11) */
407 short freq; /* frequency in MHz */
408 int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
409 };
410
411 struct ieee80211_rate_data {
412 int rate; /* rate in 100 kbps */
413 int flags; /* IEEE80211_RATE_ flags */
414 };
415
416
417 /* ADD_IF, REMOVE_IF, and UPDATE_IF 'type' argument */
418 enum {
419 HOSTAP_IF_WDS = 1, HOSTAP_IF_VLAN = 2, HOSTAP_IF_BSS = 3,
420 HOSTAP_IF_STA = 4
421 };
422
423 struct hostapd_if_wds {
424 u8 remote_addr[ETH_ALEN];
425 };
426
427 struct hostapd_if_vlan {
428 u8 id;
429 };
430
431 struct hostapd_if_bss {
432 u8 bssid[ETH_ALEN];
433 };
434
435 struct hostapd_if_sta {
436 };
437
438 #endif /* HOSTAPD_IOCTL_H */