1 /*
2  *
3  *
4  *  Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5  *  Copyright (C) 2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6  *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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 as published by
10  *  the Free Software Foundation; either version 2 of the License
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 
23 #if !defined(_ISL_OID_H)
24 #define _ISL_OID_H
25 
26 /*
27  * MIB related constant and structure definitions for communicating
28  * with the device firmware
29  */
30 
31 struct obj_ssid {
32 	u8 length;
33 	char octets[33];
34 } __attribute__ ((packed));
35 
36 struct obj_key {
37 	u8 type;		/* dot11_priv_t */
38 	u8 length;
39 	char key[32];
40 } __attribute__ ((packed));
41 
42 struct obj_mlme {
43 	u8 address[6];
44 	u16 id;
45 	u16 state;
46 	u16 code;
47 } __attribute__ ((packed));
48 
49 struct obj_mlmeex {
50 	u8 address[6];
51 	u16 id;
52 	u16 state;
53 	u16 code;
54 	u16 size;
55 	u8 data[0];
56 } __attribute__ ((packed));
57 
58 struct obj_buffer {
59 	u32 size;
60 	u32 addr;		/* 32bit bus address */
61 } __attribute__ ((packed));
62 
63 struct obj_bss {
64 	u8 address[6];
65 	int:16;			/* padding */
66 
67 	char state;
68 	char reserved;
69 	short age;
70 
71 	char quality;
72 	char rssi;
73 
74 	struct obj_ssid ssid;
75 	short channel;
76 	char beacon_period;
77 	char dtim_period;
78 	short capinfo;
79 	short rates;
80 	short basic_rates;
81 	int:16;			/* padding */
82 } __attribute__ ((packed));
83 
84 struct obj_bsslist {
85 	u32 nr;
86 	struct obj_bss bsslist[0];
87 } __attribute__ ((packed));
88 
89 struct obj_frequencies {
90 	u16 nr;
91 	u16 mhz[0];
92 } __attribute__ ((packed));
93 
94 struct obj_attachment {
95 	char type;
96 	char reserved;
97 	short id;
98 	short size;
99 	char data[0];
100 } __attribute__((packed));
101 
102 /*
103  * in case everything's ok, the inlined function below will be
104  * optimized away by the compiler...
105  */
106 static inline void
__bug_on_wrong_struct_sizes(void)107 __bug_on_wrong_struct_sizes(void)
108 {
109 	BUG_ON(sizeof (struct obj_ssid) != 34);
110 	BUG_ON(sizeof (struct obj_key) != 34);
111 	BUG_ON(sizeof (struct obj_mlme) != 12);
112 	BUG_ON(sizeof (struct obj_mlmeex) != 14);
113 	BUG_ON(sizeof (struct obj_buffer) != 8);
114 	BUG_ON(sizeof (struct obj_bss) != 60);
115 	BUG_ON(sizeof (struct obj_bsslist) != 4);
116 	BUG_ON(sizeof (struct obj_frequencies) != 2);
117 }
118 
119 enum dot11_state_t {
120 	DOT11_STATE_NONE = 0,
121 	DOT11_STATE_AUTHING = 1,
122 	DOT11_STATE_AUTH = 2,
123 	DOT11_STATE_ASSOCING = 3,
124 
125 	DOT11_STATE_ASSOC = 5,
126 	DOT11_STATE_IBSS = 6,
127 	DOT11_STATE_WDS = 7
128 };
129 
130 enum dot11_bsstype_t {
131 	DOT11_BSSTYPE_NONE = 0,
132 	DOT11_BSSTYPE_INFRA = 1,
133 	DOT11_BSSTYPE_IBSS = 2,
134 	DOT11_BSSTYPE_ANY = 3
135 };
136 
137 enum dot11_auth_t {
138 	DOT11_AUTH_NONE = 0,
139 	DOT11_AUTH_OS = 1,
140 	DOT11_AUTH_SK = 2,
141 	DOT11_AUTH_BOTH = 3
142 };
143 
144 enum dot11_mlme_t {
145 	DOT11_MLME_AUTO = 0,
146 	DOT11_MLME_INTERMEDIATE = 1,
147 	DOT11_MLME_EXTENDED = 2
148 };
149 
150 enum dot11_priv_t {
151 	DOT11_PRIV_WEP = 0,
152 	DOT11_PRIV_TKIP = 1
153 };
154 
155 /* Prism "Nitro" / Frameburst / "Packet Frame Grouping"
156  * Value is in microseconds. Represents the # microseconds
157  * the firmware will take to group frames before sending out then out
158  * together with a CSMA contention. Without this all frames are
159  * sent with a CSMA contention.
160  * Bibliography:
161  * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
162  */
163 enum dot11_maxframeburst_t {
164 	/* Values for DOT11_OID_MAXFRAMEBURST */
165 	DOT11_MAXFRAMEBURST_OFF = 0, /* Card firmware default */
166 	DOT11_MAXFRAMEBURST_MIXED_SAFE = 650, /* 802.11 a,b,g safe */
167 	DOT11_MAXFRAMEBURST_IDEAL = 1300, /* Theoretical ideal level */
168 	DOT11_MAXFRAMEBURST_MAX = 5000, /* Use this as max,
169 		* Note: firmware allows for greater values. This is a
170 		* recommended max. I'll update this as I find
171 		* out what the real MAX is. Also note that you don't necessarily
172 		* get better results with a greater value here.
173 		*/
174 };
175 
176 /* Support for 802.11 long and short frame preambles.
177  * Long	 preamble uses 128-bit sync field, 8-bit  CRC
178  * Short preamble uses 56-bit  sync field, 16-bit CRC
179  *
180  * 802.11a -- not sure, both optionally ?
181  * 802.11b supports long and optionally short
182  * 802.11g supports both */
183 enum dot11_preamblesettings_t {
184 	DOT11_PREAMBLESETTING_LONG = 0,
185 		/* Allows *only* long 802.11 preambles */
186 	DOT11_PREAMBLESETTING_SHORT = 1,
187 		/* Allows *only* short 802.11 preambles */
188 	DOT11_PREAMBLESETTING_DYNAMIC = 2
189 		/* AutomatiGically set */
190 };
191 
192 /* Support for 802.11 slot timing (time between packets).
193  *
194  * Long uses 802.11a slot timing  (9 usec ?)
195  * Short uses 802.11b slot timing (20 use ?) */
196 enum dot11_slotsettings_t {
197 	DOT11_SLOTSETTINGS_LONG = 0,
198 		/* Allows *only* long 802.11b slot timing */
199 	DOT11_SLOTSETTINGS_SHORT = 1,
200 		/* Allows *only* long 802.11a slot timing */
201 	DOT11_SLOTSETTINGS_DYNAMIC = 2
202 		/* AutomatiGically set */
203 };
204 
205 /* All you need to know, ERP is "Extended Rate PHY".
206  * An Extended Rate PHY (ERP) STA or AP shall support three different
207  * preamble and header formats:
208  * Long  preamble (refer to above)
209  * Short preamble (refer to above)
210  * OFDM  preamble ( ? )
211  *
212  * I'm assuming here Protection tells the AP
213  * to be careful, a STA which cannot handle the long pre-amble
214  * has joined.
215  */
216 enum do11_nonerpstatus_t {
217 	DOT11_ERPSTAT_NONEPRESENT = 0,
218 	DOT11_ERPSTAT_USEPROTECTION = 1
219 };
220 
221 /* (ERP is "Extended Rate PHY") Way to read NONERP is NON-ERP-*
222  * The key here is DOT11 NON ERP NEVER protects against
223  * NON ERP STA's. You *don't* want this unless
224  * you know what you are doing. It means you will only
225  * get Extended Rate capabilities */
226 enum dot11_nonerpprotection_t {
227 	DOT11_NONERP_NEVER = 0,
228 	DOT11_NONERP_ALWAYS = 1,
229 	DOT11_NONERP_DYNAMIC = 2
230 };
231 
232 /* Preset OID configuration for 802.11 modes
233  * Note: DOT11_OID_CW[MIN|MAX] hold the values of the
234  * DCS MIN|MAX backoff used */
235 enum dot11_profile_t { /* And set/allowed values */
236 	/* Allowed values for DOT11_OID_PROFILES */
237 	DOT11_PROFILE_B_ONLY = 0,
238 		/* DOT11_OID_RATES: 1, 2, 5.5, 11Mbps
239 		 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC
240 		 * DOT11_OID_CWMIN: 31
241 		 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC
242 		 * DOT11_OID_SLOTSETTINGS: DOT11_SLOTSETTINGS_LONG
243 		 */
244 	DOT11_PROFILE_MIXED_G_WIFI = 1,
245 		/* DOT11_OID_RATES: 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54Mbs
246 		 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC
247 		 * DOT11_OID_CWMIN: 15
248 		 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC
249 		 * DOT11_OID_SLOTSETTINGS: DOT11_SLOTSETTINGS_DYNAMIC
250 		 */
251 	DOT11_PROFILE_MIXED_LONG = 2, /* "Long range" */
252 		/* Same as Profile MIXED_G_WIFI */
253 	DOT11_PROFILE_G_ONLY = 3,
254 		/* Same as Profile MIXED_G_WIFI */
255 	DOT11_PROFILE_TEST = 4,
256 		/* Same as Profile MIXED_G_WIFI except:
257 		 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_SHORT
258 		 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_NEVER
259 		 * DOT11_OID_SLOTSETTINGS: DOT11_SLOTSETTINGS_SHORT
260 		 */
261 	DOT11_PROFILE_B_WIFI = 5,
262 		/* Same as Profile B_ONLY */
263 	DOT11_PROFILE_A_ONLY = 6,
264 		/* Same as Profile MIXED_G_WIFI except:
265 		 * DOT11_OID_RATES: 6, 9, 12, 18, 24, 36, 48, 54Mbs
266 		 */
267 	DOT11_PROFILE_MIXED_SHORT = 7
268 		/* Same as MIXED_G_WIFI */
269 };
270 
271 
272 /* The dot11d conformance level configures the 802.11d conformance levels.
273  * The following conformance levels exist:*/
274 enum oid_inl_conformance_t {
275 	OID_INL_CONFORMANCE_NONE = 0,	/* Perform active scanning */
276 	OID_INL_CONFORMANCE_STRICT = 1,	/* Strictly adhere to 802.11d */
277 	OID_INL_CONFORMANCE_FLEXIBLE = 2,	/* Use passed 802.11d info to
278 		* determine channel AND/OR just make assumption that active
279 		* channels are valid  channels */
280 };
281 
282 enum oid_inl_mode_t {
283 	INL_MODE_NONE = -1,
284 	INL_MODE_PROMISCUOUS = 0,
285 	INL_MODE_CLIENT = 1,
286 	INL_MODE_AP = 2,
287 	INL_MODE_SNIFFER = 3
288 };
289 
290 enum oid_inl_config_t {
291 	INL_CONFIG_NOTHING = 0x00,
292 	INL_CONFIG_MANUALRUN = 0x01,
293 	INL_CONFIG_FRAMETRAP = 0x02,
294 	INL_CONFIG_RXANNEX = 0x04,
295 	INL_CONFIG_TXANNEX = 0x08,
296 	INL_CONFIG_WDS = 0x10
297 };
298 
299 enum oid_inl_phycap_t {
300 	INL_PHYCAP_2400MHZ = 1,
301 	INL_PHYCAP_5000MHZ = 2,
302 	INL_PHYCAP_FAA = 0x80000000,	/* Means card supports the FAA switch */
303 };
304 
305 
306 enum oid_num_t {
307 	GEN_OID_MACADDRESS = 0,
308 	GEN_OID_LINKSTATE,
309 	GEN_OID_WATCHDOG,
310 	GEN_OID_MIBOP,
311 	GEN_OID_OPTIONS,
312 	GEN_OID_LEDCONFIG,
313 
314 	/* 802.11 */
315 	DOT11_OID_BSSTYPE,
316 	DOT11_OID_BSSID,
317 	DOT11_OID_SSID,
318 	DOT11_OID_STATE,
319 	DOT11_OID_AID,
320 	DOT11_OID_COUNTRYSTRING,
321 	DOT11_OID_SSIDOVERRIDE,
322 
323 	DOT11_OID_MEDIUMLIMIT,
324 	DOT11_OID_BEACONPERIOD,
325 	DOT11_OID_DTIMPERIOD,
326 	DOT11_OID_ATIMWINDOW,
327 	DOT11_OID_LISTENINTERVAL,
328 	DOT11_OID_CFPPERIOD,
329 	DOT11_OID_CFPDURATION,
330 
331 	DOT11_OID_AUTHENABLE,
332 	DOT11_OID_PRIVACYINVOKED,
333 	DOT11_OID_EXUNENCRYPTED,
334 	DOT11_OID_DEFKEYID,
335 	DOT11_OID_DEFKEYX,	/* DOT11_OID_DEFKEY1,...DOT11_OID_DEFKEY4 */
336 	DOT11_OID_STAKEY,
337 	DOT11_OID_REKEYTHRESHOLD,
338 	DOT11_OID_STASC,
339 
340 	DOT11_OID_PRIVTXREJECTED,
341 	DOT11_OID_PRIVRXPLAIN,
342 	DOT11_OID_PRIVRXFAILED,
343 	DOT11_OID_PRIVRXNOKEY,
344 
345 	DOT11_OID_RTSTHRESH,
346 	DOT11_OID_FRAGTHRESH,
347 	DOT11_OID_SHORTRETRIES,
348 	DOT11_OID_LONGRETRIES,
349 	DOT11_OID_MAXTXLIFETIME,
350 	DOT11_OID_MAXRXLIFETIME,
351 	DOT11_OID_AUTHRESPTIMEOUT,
352 	DOT11_OID_ASSOCRESPTIMEOUT,
353 
354 	DOT11_OID_ALOFT_TABLE,
355 	DOT11_OID_ALOFT_CTRL_TABLE,
356 	DOT11_OID_ALOFT_RETREAT,
357 	DOT11_OID_ALOFT_PROGRESS,
358 	DOT11_OID_ALOFT_FIXEDRATE,
359 	DOT11_OID_ALOFT_RSSIGRAPH,
360 	DOT11_OID_ALOFT_CONFIG,
361 
362 	DOT11_OID_VDCFX,
363 	DOT11_OID_MAXFRAMEBURST,
364 
365 	DOT11_OID_PSM,
366 	DOT11_OID_CAMTIMEOUT,
367 	DOT11_OID_RECEIVEDTIMS,
368 	DOT11_OID_ROAMPREFERENCE,
369 
370 	DOT11_OID_BRIDGELOCAL,
371 	DOT11_OID_CLIENTS,
372 	DOT11_OID_CLIENTSASSOCIATED,
373 	DOT11_OID_CLIENTX,	/* DOT11_OID_CLIENTX,...DOT11_OID_CLIENT2007 */
374 
375 	DOT11_OID_CLIENTFIND,
376 	DOT11_OID_WDSLINKADD,
377 	DOT11_OID_WDSLINKREMOVE,
378 	DOT11_OID_EAPAUTHSTA,
379 	DOT11_OID_EAPUNAUTHSTA,
380 	DOT11_OID_DOT1XENABLE,
381 	DOT11_OID_MICFAILURE,
382 	DOT11_OID_REKEYINDICATE,
383 
384 	DOT11_OID_MPDUTXSUCCESSFUL,
385 	DOT11_OID_MPDUTXONERETRY,
386 	DOT11_OID_MPDUTXMULTIPLERETRIES,
387 	DOT11_OID_MPDUTXFAILED,
388 	DOT11_OID_MPDURXSUCCESSFUL,
389 	DOT11_OID_MPDURXDUPS,
390 	DOT11_OID_RTSSUCCESSFUL,
391 	DOT11_OID_RTSFAILED,
392 	DOT11_OID_ACKFAILED,
393 	DOT11_OID_FRAMERECEIVES,
394 	DOT11_OID_FRAMEERRORS,
395 	DOT11_OID_FRAMEABORTS,
396 	DOT11_OID_FRAMEABORTSPHY,
397 
398 	DOT11_OID_SLOTTIME,
399 	DOT11_OID_CWMIN, /* MIN DCS backoff */
400 	DOT11_OID_CWMAX, /* MAX DCS backoff */
401 	DOT11_OID_ACKWINDOW,
402 	DOT11_OID_ANTENNARX,
403 	DOT11_OID_ANTENNATX,
404 	DOT11_OID_ANTENNADIVERSITY,
405 	DOT11_OID_CHANNEL,
406 	DOT11_OID_EDTHRESHOLD,
407 	DOT11_OID_PREAMBLESETTINGS,
408 	DOT11_OID_RATES,
409 	DOT11_OID_CCAMODESUPPORTED,
410 	DOT11_OID_CCAMODE,
411 	DOT11_OID_RSSIVECTOR,
412 	DOT11_OID_OUTPUTPOWERTABLE,
413 	DOT11_OID_OUTPUTPOWER,
414 	DOT11_OID_SUPPORTEDRATES,
415 	DOT11_OID_FREQUENCY,
416 	DOT11_OID_SUPPORTEDFREQUENCIES,
417 	DOT11_OID_NOISEFLOOR,
418 	DOT11_OID_FREQUENCYACTIVITY,
419 	DOT11_OID_IQCALIBRATIONTABLE,
420 	DOT11_OID_NONERPPROTECTION,
421 	DOT11_OID_SLOTSETTINGS,
422 	DOT11_OID_NONERPTIMEOUT,
423 	DOT11_OID_PROFILES,
424 	DOT11_OID_EXTENDEDRATES,
425 
426 	DOT11_OID_DEAUTHENTICATE,
427 	DOT11_OID_AUTHENTICATE,
428 	DOT11_OID_DISASSOCIATE,
429 	DOT11_OID_ASSOCIATE,
430 	DOT11_OID_SCAN,
431 	DOT11_OID_BEACON,
432 	DOT11_OID_PROBE,
433 	DOT11_OID_DEAUTHENTICATEEX,
434 	DOT11_OID_AUTHENTICATEEX,
435 	DOT11_OID_DISASSOCIATEEX,
436 	DOT11_OID_ASSOCIATEEX,
437 	DOT11_OID_REASSOCIATE,
438 	DOT11_OID_REASSOCIATEEX,
439 
440 	DOT11_OID_NONERPSTATUS,
441 
442 	DOT11_OID_STATIMEOUT,
443 	DOT11_OID_MLMEAUTOLEVEL,
444 	DOT11_OID_BSSTIMEOUT,
445 	DOT11_OID_ATTACHMENT,
446 	DOT11_OID_PSMBUFFER,
447 
448 	DOT11_OID_BSSS,
449 	DOT11_OID_BSSX,		/*DOT11_OID_BSS1,...,DOT11_OID_BSS64 */
450 	DOT11_OID_BSSFIND,
451 	DOT11_OID_BSSLIST,
452 
453 	OID_INL_TUNNEL,
454 	OID_INL_MEMADDR,
455 	OID_INL_MEMORY,
456 	OID_INL_MODE,
457 	OID_INL_COMPONENT_NR,
458 	OID_INL_VERSION,
459 	OID_INL_INTERFACE_ID,
460 	OID_INL_COMPONENT_ID,
461 	OID_INL_CONFIG,
462 	OID_INL_DOT11D_CONFORMANCE,
463 	OID_INL_PHYCAPABILITIES,
464 	OID_INL_OUTPUTPOWER,
465 
466 	OID_NUM_LAST
467 };
468 
469 #define OID_FLAG_CACHED		0x80
470 #define OID_FLAG_TYPE		0x7f
471 
472 #define OID_TYPE_U32		0x01
473 #define OID_TYPE_SSID		0x02
474 #define OID_TYPE_KEY		0x03
475 #define OID_TYPE_BUFFER		0x04
476 #define OID_TYPE_BSS		0x05
477 #define OID_TYPE_BSSLIST	0x06
478 #define OID_TYPE_FREQUENCIES	0x07
479 #define OID_TYPE_MLME		0x08
480 #define OID_TYPE_MLMEEX		0x09
481 #define OID_TYPE_ADDR		0x0A
482 #define OID_TYPE_RAW		0x0B
483 #define OID_TYPE_ATTACH		0x0C
484 
485 /* OID_TYPE_MLMEEX is special because of a variable size field when sending.
486  * Not yet implemented (not used in driver anyway).
487  */
488 
489 struct oid_t {
490 	enum oid_num_t oid;
491 	short range;		/* to define a range of oid */
492 	short size;		/* max size of the associated data */
493 	char flags;
494 };
495 
496 union oid_res_t {
497 	void *ptr;
498 	u32 u;
499 };
500 
501 #define	IWMAX_BITRATES	20
502 #define	IWMAX_BSS	24
503 #define IWMAX_FREQ	30
504 #define PRIV_STR_SIZE	1024
505 
506 #endif				/* !defined(_ISL_OID_H) */
507 /* EOF */
508