Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / drivers / staging / wlan-ng / p80211types.h
1 /* p80211types.h
2 *
3 * Macros, constants, types, and funcs for p80211 data types
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 *
47 * This file declares some of the constants and types used in various
48 * parts of the linux-wlan system.
49 *
50 * Notes:
51 *   - Constant values are always in HOST byte order.
52 *
53 * All functions and statics declared here are implemented in p80211types.c
54 *   --------------------------------------------------------------------
55 */
56
57 #ifndef _P80211TYPES_H
58 #define _P80211TYPES_H
59
60 /*================================================================*/
61 /* Project Includes */
62 /*================================================================*/
63
64
65 /*----------------------------------------------------------------*/
66 /* The following constants are indexes into the Mib Category List */
67 /* and the Message Category List */
68
69 /* Mib Category List */
70 #define P80211_MIB_CAT_DOT11SMT         1
71 #define P80211_MIB_CAT_DOT11MAC         2
72 #define P80211_MIB_CAT_DOT11PHY         3
73
74 #define P80211SEC_DOT11SMT              P80211_MIB_CAT_DOT11SMT
75 #define P80211SEC_DOT11MAC              P80211_MIB_CAT_DOT11MAC
76 #define P80211SEC_DOT11PHY              P80211_MIB_CAT_DOT11PHY
77
78 /* Message Category List */
79 #define P80211_MSG_CAT_DOT11REQ         1
80 #define P80211_MSG_CAT_DOT11IND         2
81
82 /*----------------------------------------------------------------*/
83 /* p80211 enumeration constants.  The value to text mappings for */
84 /*  these is in p80211types.c.  These defines were generated */
85 /*  from the mappings. */
86
87 /* error codes for lookups */
88
89 #define P80211ENUM_truth_false                  0
90 #define P80211ENUM_truth_true                   1
91 #define P80211ENUM_ifstate_disable              0
92 #define P80211ENUM_ifstate_fwload               1
93 #define P80211ENUM_ifstate_enable               2
94 #define P80211ENUM_bsstype_infrastructure       1
95 #define P80211ENUM_bsstype_independent          2
96 #define P80211ENUM_bsstype_any                  3
97 #define P80211ENUM_authalg_opensystem           1
98 #define P80211ENUM_authalg_sharedkey            2
99 #define P80211ENUM_scantype_active              1
100 #define P80211ENUM_resultcode_success           1
101 #define P80211ENUM_resultcode_invalid_parameters        2
102 #define P80211ENUM_resultcode_not_supported     3
103 #define P80211ENUM_resultcode_refused           6
104 #define P80211ENUM_resultcode_cant_set_readonly_mib     10
105 #define P80211ENUM_resultcode_implementation_failure    11
106 #define P80211ENUM_resultcode_cant_get_writeonly_mib    12
107 #define P80211ENUM_status_successful            0
108 #define P80211ENUM_status_unspec_failure        1
109 #define P80211ENUM_status_ap_full               17
110 #define P80211ENUM_msgitem_status_data_ok               0
111 #define P80211ENUM_msgitem_status_no_value              1
112
113 /*----------------------------------------------------------------*/
114 /* p80211 max length constants for the different pascal strings. */
115
116 #define MAXLEN_PSTR6            (6)     /* pascal array of 6 bytes */
117 #define MAXLEN_PSTR14           (14)    /* pascal array of 14 bytes */
118 #define MAXLEN_PSTR32           (32)    /* pascal array of 32 bytes */
119 #define MAXLEN_PSTR255          (255)   /* pascal array of 255 bytes */
120 #define MAXLEN_MIBATTRIBUTE     (392)   /* maximum mibattribute */
121                                         /* where the size of the DATA itself */
122                                         /* is a DID-LEN-DATA triple */
123                                         /* with a max size of 4+4+384 */
124
125 /*----------------------------------------------------------------*/
126 /* The following macro creates a name for an enum */
127
128 #define MKENUMNAME(name) p80211enum_ ## name
129
130 /*----------------------------------------------------------------
131 * The following constants and macros are used to construct and
132 * deconstruct the Data ID codes.  The coding is as follows:
133 *
134 *     ...rwtnnnnnnnniiiiiiggggggssssss      s - Section
135 *                                           g - Group
136 *                                           i - Item
137 *                                           n - Index
138 *                                           t - Table flag
139 *                                           w - Write flag
140 *                                           r - Read flag
141 *                                           . - Unused
142 */
143
144 #define P80211DID_LSB_SECTION           (0)
145 #define P80211DID_LSB_GROUP             (6)
146 #define P80211DID_LSB_ITEM              (12)
147 #define P80211DID_LSB_INDEX             (18)
148 #define P80211DID_LSB_ISTABLE           (26)
149 #define P80211DID_LSB_ACCESS            (27)
150
151 #define P80211DID_MASK_SECTION          (0x0000003fUL)
152 #define P80211DID_MASK_GROUP            (0x0000003fUL)
153 #define P80211DID_MASK_ITEM             (0x0000003fUL)
154 #define P80211DID_MASK_INDEX            (0x000000ffUL)
155 #define P80211DID_MASK_ISTABLE          (0x00000001UL)
156 #define P80211DID_MASK_ACCESS           (0x00000003UL)
157
158 #define P80211DID_MK(a, m, l)   ((((u32)(a)) & (m)) << (l))
159
160 #define P80211DID_MKSECTION(a)  P80211DID_MK(a, \
161                                         P80211DID_MASK_SECTION, \
162                                         P80211DID_LSB_SECTION)
163 #define P80211DID_MKGROUP(a)    P80211DID_MK(a, \
164                                         P80211DID_MASK_GROUP, \
165                                         P80211DID_LSB_GROUP)
166 #define P80211DID_MKITEM(a)     P80211DID_MK(a, \
167                                         P80211DID_MASK_ITEM, \
168                                         P80211DID_LSB_ITEM)
169 #define P80211DID_MKINDEX(a)    P80211DID_MK(a, \
170                                         P80211DID_MASK_INDEX, \
171                                         P80211DID_LSB_INDEX)
172 #define P80211DID_MKISTABLE(a)  P80211DID_MK(a, \
173                                         P80211DID_MASK_ISTABLE, \
174                                         P80211DID_LSB_ISTABLE)
175
176 #define P80211DID_MKID(s,g,i,n,t,a)     (P80211DID_MKSECTION(s) | \
177                                                 P80211DID_MKGROUP(g) | \
178                                                 P80211DID_MKITEM(i) | \
179                                                 P80211DID_MKINDEX(n) | \
180                                                 P80211DID_MKISTABLE(t) | \
181                                                 (a))
182
183 #define P80211DID_GET(a, m, l)  ((((u32)(a)) >> (l)) & (m))
184
185 #define P80211DID_SECTION(a)    P80211DID_GET(a, \
186                                         P80211DID_MASK_SECTION, \
187                                         P80211DID_LSB_SECTION)
188 #define P80211DID_GROUP(a)      P80211DID_GET(a, \
189                                         P80211DID_MASK_GROUP, \
190                                         P80211DID_LSB_GROUP)
191 #define P80211DID_ITEM(a)       P80211DID_GET(a, \
192                                         P80211DID_MASK_ITEM, \
193                                         P80211DID_LSB_ITEM)
194 #define P80211DID_INDEX(a)      P80211DID_GET(a, \
195                                         P80211DID_MASK_INDEX, \
196                                         P80211DID_LSB_INDEX)
197 #define P80211DID_ISTABLE(a)    P80211DID_GET(a, \
198                                         P80211DID_MASK_ISTABLE, \
199                                         P80211DID_LSB_ISTABLE)
200 #define P80211DID_ACCESS(a)     P80211DID_GET(a, \
201                                         P80211DID_MASK_ACCESS, \
202                                         P80211DID_LSB_ACCESS)
203
204 /*----------------------------------------------------------------*/
205 /* The following structure types are used for the represenation */
206 /*  of ENUMint type metadata. */
207
208 typedef struct p80211enumpair {
209         u32 val;
210         char *name;
211 } p80211enumpair_t;
212
213 typedef struct p80211enum {
214         int nitems;
215         p80211enumpair_t *list;
216 } p80211enum_t;
217
218 /*----------------------------------------------------------------*/
219 /* The following structure types are used to store data items in */
220 /*  messages. */
221
222 /* Template pascal string */
223 typedef struct p80211pstr {
224         u8 len;
225 } __attribute__ ((packed)) p80211pstr_t;
226
227 typedef struct p80211pstrd {
228         u8 len;
229         u8 data[0];
230 } __attribute__ ((packed)) p80211pstrd_t;
231
232 /* Maximum pascal string */
233 typedef struct p80211pstr255 {
234         u8 len;
235         u8 data[MAXLEN_PSTR255];
236 } __attribute__ ((packed)) p80211pstr255_t;
237
238 /* pascal string for macaddress and bssid */
239 typedef struct p80211pstr6 {
240         u8 len;
241         u8 data[MAXLEN_PSTR6];
242 } __attribute__ ((packed)) p80211pstr6_t;
243
244 /* pascal string for channel list */
245 typedef struct p80211pstr14 {
246         u8 len;
247         u8 data[MAXLEN_PSTR14];
248 } __attribute__ ((packed)) p80211pstr14_t;
249
250 /* pascal string for ssid */
251 typedef struct p80211pstr32 {
252         u8 len;
253         u8 data[MAXLEN_PSTR32];
254 } __attribute__ ((packed)) p80211pstr32_t;
255
256 /* MAC address array */
257 typedef struct p80211macarray {
258         u32 cnt;
259         u8 data[1][MAXLEN_PSTR6];
260 } __attribute__ ((packed)) p80211macarray_t;
261
262 /* prototype template */
263 typedef struct p80211item {
264         u32 did;
265         u16 status;
266         u16 len;
267 } __attribute__ ((packed)) p80211item_t;
268
269 /* prototype template w/ data item */
270 typedef struct p80211itemd {
271         u32 did;
272         u16 status;
273         u16 len;
274         u8 data[0];
275 } __attribute__ ((packed)) p80211itemd_t;
276
277 /* message data item for int, BOUNDEDINT, ENUMINT */
278 typedef struct p80211item_uint32 {
279         u32 did;
280         u16 status;
281         u16 len;
282         u32 data;
283 } __attribute__ ((packed)) p80211item_uint32_t;
284
285 /* message data item for OCTETSTR, DISPLAYSTR */
286 typedef struct p80211item_pstr6 {
287         u32 did;
288         u16 status;
289         u16 len;
290         p80211pstr6_t data;
291 } __attribute__ ((packed)) p80211item_pstr6_t;
292
293 /* message data item for OCTETSTR, DISPLAYSTR */
294 typedef struct p80211item_pstr14 {
295         u32 did;
296         u16 status;
297         u16 len;
298         p80211pstr14_t data;
299 } __attribute__ ((packed)) p80211item_pstr14_t;
300
301 /* message data item for OCTETSTR, DISPLAYSTR */
302 typedef struct p80211item_pstr32 {
303         u32 did;
304         u16 status;
305         u16 len;
306         p80211pstr32_t data;
307 } __attribute__ ((packed)) p80211item_pstr32_t;
308
309 /* message data item for OCTETSTR, DISPLAYSTR */
310 typedef struct p80211item_pstr255 {
311         u32 did;
312         u16 status;
313         u16 len;
314         p80211pstr255_t data;
315 } __attribute__ ((packed)) p80211item_pstr255_t;
316
317 /* message data item for UNK 392, namely mib items */
318 typedef struct p80211item_unk392 {
319         u32 did;
320         u16 status;
321         u16 len;
322         u8 data[MAXLEN_MIBATTRIBUTE];
323 } __attribute__ ((packed)) p80211item_unk392_t;
324
325 /* message data item for UNK 1025, namely p2 pdas */
326 typedef struct p80211item_unk1024 {
327         u32 did;
328         u16 status;
329         u16 len;
330         u8 data[1024];
331 } __attribute__ ((packed)) p80211item_unk1024_t;
332
333 /* message data item for UNK 4096, namely p2 download chunks */
334 typedef struct p80211item_unk4096 {
335         u32 did;
336         u16 status;
337         u16 len;
338         u8 data[4096];
339 } __attribute__ ((packed)) p80211item_unk4096_t;
340
341 struct catlistitem;
342
343 /*----------------------------------------------------------------*/
344 /* The following structure type is used to represent all of the */
345 /*  metadata items.  Some components may choose to use more, */
346 /*  less or different metadata items. */
347
348 typedef void (*p80211_totext_t) (struct catlistitem *, u32 did, u8 *itembuf,
349                                  char *textbuf);
350 typedef void (*p80211_fromtext_t) (struct catlistitem *, u32 did, u8 *itembuf,
351                                    char *textbuf);
352 typedef u32(*p80211_valid_t) (struct catlistitem *, u32 did, u8 *itembuf);
353
354 /*----------------------------------------------------------------*/
355 /* Enumeration Lists */
356 /*  The following are the external declarations */
357 /*  for all enumerations  */
358
359 extern p80211enum_t MKENUMNAME(truth);
360 extern p80211enum_t MKENUMNAME(ifstate);
361 extern p80211enum_t MKENUMNAME(powermgmt);
362 extern p80211enum_t MKENUMNAME(bsstype);
363 extern p80211enum_t MKENUMNAME(authalg);
364 extern p80211enum_t MKENUMNAME(phytype);
365 extern p80211enum_t MKENUMNAME(temptype);
366 extern p80211enum_t MKENUMNAME(regdomain);
367 extern p80211enum_t MKENUMNAME(ccamode);
368 extern p80211enum_t MKENUMNAME(diversity);
369 extern p80211enum_t MKENUMNAME(scantype);
370 extern p80211enum_t MKENUMNAME(resultcode);
371 extern p80211enum_t MKENUMNAME(reason);
372 extern p80211enum_t MKENUMNAME(status);
373 extern p80211enum_t MKENUMNAME(msgcode);
374 extern p80211enum_t MKENUMNAME(msgitem_status);
375
376 extern p80211enum_t MKENUMNAME(lnxroam_reason);
377
378 extern p80211enum_t MKENUMNAME(p2preamble);
379
380 #endif /* _P80211TYPES_H */