Staging: wlan-ng: Remove dead/unused code from p80211types.h
[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 #ifndef _WLAN_COMPAT_H
65 #include "wlan_compat.h"
66 #endif
67
68 /*================================================================*/
69 /* Constants */
70 /*================================================================*/
71
72 /*----------------------------------------------------------------*/
73 /* The following constants are indexes into the Mib Category List */
74 /* and the Message Category List */
75
76 /* Mib Category List */
77 #define P80211_MIB_CAT_DOT11SMT         1
78 #define P80211_MIB_CAT_DOT11MAC         2
79 #define P80211_MIB_CAT_DOT11PHY         3
80
81 #define P80211SEC_DOT11SMT              P80211_MIB_CAT_DOT11SMT
82 #define P80211SEC_DOT11MAC              P80211_MIB_CAT_DOT11MAC
83 #define P80211SEC_DOT11PHY              P80211_MIB_CAT_DOT11PHY
84
85 /* Message Category List */
86 #define P80211_MSG_CAT_DOT11REQ         1
87 #define P80211_MSG_CAT_DOT11IND         2
88
89 /*----------------------------------------------------------------*/
90 /* p80211 enumeration constants.  The value to text mappings for */
91 /*  these is in p80211types.c.  These defines were generated */
92 /*  from the mappings. */
93
94 /* error codes for lookups */
95
96 #define P80211ENUM_truth_false                  0
97 #define P80211ENUM_truth_true                   1
98 #define P80211ENUM_ifstate_disable              0
99 #define P80211ENUM_ifstate_fwload               1
100 #define P80211ENUM_ifstate_enable               2
101 #define P80211ENUM_bsstype_infrastructure       1
102 #define P80211ENUM_bsstype_independent          2
103 #define P80211ENUM_bsstype_any                  3
104 #define P80211ENUM_authalg_opensystem           1
105 #define P80211ENUM_authalg_sharedkey            2
106 #define P80211ENUM_scantype_active              1
107 #define P80211ENUM_resultcode_success           1
108 #define P80211ENUM_resultcode_invalid_parameters        2
109 #define P80211ENUM_resultcode_not_supported     3
110 #define P80211ENUM_resultcode_refused           6
111 #define P80211ENUM_resultcode_cant_set_readonly_mib     10
112 #define P80211ENUM_resultcode_implementation_failure    11
113 #define P80211ENUM_resultcode_cant_get_writeonly_mib    12
114 #define P80211ENUM_status_successful            0
115 #define P80211ENUM_status_unspec_failure        1
116 #define P80211ENUM_status_ap_full               17
117 #define P80211ENUM_msgitem_status_data_ok               0
118 #define P80211ENUM_msgitem_status_no_value              1
119
120 /*----------------------------------------------------------------*/
121 /* p80211 max length constants for the different pascal strings. */
122
123 #define MAXLEN_PSTR6            (6)     /* pascal array of 6 bytes */
124 #define MAXLEN_PSTR14           (14)    /* pascal array of 14 bytes */
125 #define MAXLEN_PSTR32           (32)    /* pascal array of 32 bytes */
126 #define MAXLEN_PSTR255          (255)   /* pascal array of 255 bytes */
127 #define MAXLEN_MIBATTRIBUTE     (392)   /* maximum mibattribute */
128                                         /* where the size of the DATA itself */
129                                         /* is a DID-LEN-DATA triple */
130                                         /* with a max size of 4+4+384 */
131
132 /*================================================================*/
133 /* Macros */
134
135 /*----------------------------------------------------------------*/
136 /* The following macro creates a name for an enum */
137
138 #define MKENUMNAME(name) p80211enum_ ## name
139
140 /*----------------------------------------------------------------
141 * The following constants and macros are used to construct and
142 * deconstruct the Data ID codes.  The coding is as follows:
143 *
144 *     ...rwtnnnnnnnniiiiiiggggggssssss      s - Section
145 *                                           g - Group
146 *                                           i - Item
147 *                                           n - Index
148 *                                           t - Table flag
149 *                                           w - Write flag
150 *                                           r - Read flag
151 *                                           . - Unused
152 */
153
154 #define P80211DID_LSB_SECTION           (0)
155 #define P80211DID_LSB_GROUP             (6)
156 #define P80211DID_LSB_ITEM              (12)
157 #define P80211DID_LSB_INDEX             (18)
158 #define P80211DID_LSB_ISTABLE           (26)
159 #define P80211DID_LSB_ACCESS            (27)
160
161 #define P80211DID_MASK_SECTION          (0x0000003fUL)
162 #define P80211DID_MASK_GROUP            (0x0000003fUL)
163 #define P80211DID_MASK_ITEM             (0x0000003fUL)
164 #define P80211DID_MASK_INDEX            (0x000000ffUL)
165 #define P80211DID_MASK_ISTABLE          (0x00000001UL)
166 #define P80211DID_MASK_ACCESS           (0x00000003UL)
167
168
169 #define P80211DID_MK(a,m,l)     ((((u32)(a)) & (m)) << (l))
170
171 #define P80211DID_MKSECTION(a)  P80211DID_MK(a, \
172                                         P80211DID_MASK_SECTION, \
173                                         P80211DID_LSB_SECTION )
174 #define P80211DID_MKGROUP(a)    P80211DID_MK(a, \
175                                         P80211DID_MASK_GROUP, \
176                                         P80211DID_LSB_GROUP )
177 #define P80211DID_MKITEM(a)     P80211DID_MK(a, \
178                                         P80211DID_MASK_ITEM, \
179                                         P80211DID_LSB_ITEM )
180 #define P80211DID_MKINDEX(a)    P80211DID_MK(a, \
181                                         P80211DID_MASK_INDEX, \
182                                         P80211DID_LSB_INDEX )
183 #define P80211DID_MKISTABLE(a)  P80211DID_MK(a, \
184                                         P80211DID_MASK_ISTABLE, \
185                                         P80211DID_LSB_ISTABLE )
186
187
188 #define P80211DID_MKID(s,g,i,n,t,a)     (P80211DID_MKSECTION(s) | \
189                                                 P80211DID_MKGROUP(g) | \
190                                                 P80211DID_MKITEM(i) | \
191                                                 P80211DID_MKINDEX(n) | \
192                                                 P80211DID_MKISTABLE(t) | \
193                                                 (a) )
194
195
196 #define P80211DID_GET(a,m,l)    ((((u32)(a)) >> (l)) & (m))
197
198 #define P80211DID_SECTION(a)    P80211DID_GET(a, \
199                                         P80211DID_MASK_SECTION, \
200                                         P80211DID_LSB_SECTION)
201 #define P80211DID_GROUP(a)      P80211DID_GET(a, \
202                                         P80211DID_MASK_GROUP, \
203                                         P80211DID_LSB_GROUP)
204 #define P80211DID_ITEM(a)       P80211DID_GET(a, \
205                                         P80211DID_MASK_ITEM, \
206                                         P80211DID_LSB_ITEM)
207 #define P80211DID_INDEX(a)      P80211DID_GET(a, \
208                                         P80211DID_MASK_INDEX, \
209                                         P80211DID_LSB_INDEX)
210 #define P80211DID_ISTABLE(a)    P80211DID_GET(a, \
211                                         P80211DID_MASK_ISTABLE, \
212                                         P80211DID_LSB_ISTABLE)
213 #define P80211DID_ACCESS(a)     P80211DID_GET(a, \
214                                         P80211DID_MASK_ACCESS, \
215                                         P80211DID_LSB_ACCESS)
216
217 /*================================================================*/
218 /* Types */
219
220 /*----------------------------------------------------------------*/
221 /* The following structure types are used for the represenation */
222 /*  of ENUMint type metadata. */
223
224 typedef struct p80211enumpair
225 {
226         u32                     val;
227         char                    *name;
228 } p80211enumpair_t;
229
230 typedef struct p80211enum
231 {
232         int                     nitems;
233         p80211enumpair_t        *list;
234 } p80211enum_t;
235
236 /*----------------------------------------------------------------*/
237 /* The following structure types are used to store data items in */
238 /*  messages. */
239
240 /* Template pascal string */
241 typedef struct p80211pstr
242 {
243         u8              len;
244 } __attribute__((packed)) p80211pstr_t;
245
246 typedef struct p80211pstrd
247 {
248         u8              len;
249         u8              data[0];
250 } __attribute__((packed)) p80211pstrd_t;
251
252 /* Maximum pascal string */
253 typedef struct p80211pstr255
254 {
255         u8              len;
256         u8              data[MAXLEN_PSTR255];
257 } __attribute__((packed)) p80211pstr255_t;
258
259 /* pascal string for macaddress and bssid */
260 typedef struct p80211pstr6
261 {
262         u8              len;
263         u8              data[MAXLEN_PSTR6];
264 } __attribute__((packed)) p80211pstr6_t;
265
266 /* pascal string for channel list */
267 typedef struct p80211pstr14
268 {
269         u8              len;
270         u8              data[MAXLEN_PSTR14];
271 } __attribute__((packed)) p80211pstr14_t;
272
273 /* pascal string for ssid */
274 typedef struct p80211pstr32
275 {
276         u8              len;
277         u8              data[MAXLEN_PSTR32];
278 } __attribute__((packed)) p80211pstr32_t;
279
280 /* MAC address array */
281 typedef struct p80211macarray
282 {
283         u32             cnt;
284         u8              data[1][MAXLEN_PSTR6];
285 } __attribute__((packed)) p80211macarray_t;
286
287 /* prototype template */
288 typedef struct p80211item
289 {
290         u32             did;
291         u16             status;
292         u16             len;
293 } __attribute__((packed)) p80211item_t;
294
295 /* prototype template w/ data item */
296 typedef struct p80211itemd
297 {
298         u32             did;
299         u16             status;
300         u16             len;
301         u8              data[0];
302 } __attribute__((packed)) p80211itemd_t;
303
304 /* message data item for int, BOUNDEDINT, ENUMINT */
305 typedef struct p80211item_uint32
306 {
307         u32             did;
308         u16             status;
309         u16             len;
310         u32             data;
311 } __attribute__((packed)) p80211item_uint32_t;
312
313 /* message data item for OCTETSTR, DISPLAYSTR */
314 typedef struct p80211item_pstr6
315 {
316         u32             did;
317         u16             status;
318         u16             len;
319         p80211pstr6_t   data;
320 } __attribute__((packed)) p80211item_pstr6_t;
321
322 /* message data item for OCTETSTR, DISPLAYSTR */
323 typedef struct p80211item_pstr14
324 {
325         u32                     did;
326         u16                     status;
327         u16                     len;
328         p80211pstr14_t          data;
329 } __attribute__((packed)) p80211item_pstr14_t;
330
331 /* message data item for OCTETSTR, DISPLAYSTR */
332 typedef struct p80211item_pstr32
333 {
334         u32                     did;
335         u16                     status;
336         u16                     len;
337         p80211pstr32_t          data;
338 } __attribute__((packed)) p80211item_pstr32_t;
339
340 /* message data item for OCTETSTR, DISPLAYSTR */
341 typedef struct p80211item_pstr255
342 {
343         u32                     did;
344         u16                     status;
345         u16                     len;
346         p80211pstr255_t         data;
347 } __attribute__((packed)) p80211item_pstr255_t;
348
349 /* message data item for UNK 392, namely mib items */
350 typedef struct  p80211item_unk392
351 {
352         u32             did;
353         u16             status;
354         u16             len;
355         u8              data[MAXLEN_MIBATTRIBUTE];
356 } __attribute__((packed)) p80211item_unk392_t;
357
358 /* message data item for UNK 1025, namely p2 pdas */
359 typedef struct  p80211item_unk1024
360 {
361         u32             did;
362         u16             status;
363         u16             len;
364         u8              data[1024];
365 }  __attribute__((packed)) p80211item_unk1024_t;
366
367 /* message data item for UNK 4096, namely p2 download chunks */
368 typedef struct  p80211item_unk4096
369 {
370         u32             did;
371         u16             status;
372         u16             len;
373         u8              data[4096];
374 }  __attribute__((packed)) p80211item_unk4096_t;
375
376 struct catlistitem;
377
378 /*----------------------------------------------------------------*/
379 /* The following structure type is used to represent all of the */
380 /*  metadata items.  Some components may choose to use more, */
381 /*  less or different metadata items. */
382
383 typedef void (*p80211_totext_t)( struct catlistitem *, u32 did, u8* itembuf, char *textbuf);
384 typedef void (*p80211_fromtext_t)( struct catlistitem *, u32 did, u8* itembuf, char *textbuf);
385 typedef u32 (*p80211_valid_t)( struct catlistitem *, u32 did, u8* itembuf);
386
387
388 /*================================================================*/
389 /* Extern Declarations */
390
391 /*----------------------------------------------------------------*/
392 /* Enumeration Lists */
393 /*  The following are the external declarations */
394 /*  for all enumerations  */
395
396 extern p80211enum_t MKENUMNAME(truth);
397 extern p80211enum_t MKENUMNAME(ifstate);
398 extern p80211enum_t MKENUMNAME(powermgmt);
399 extern p80211enum_t MKENUMNAME(bsstype);
400 extern p80211enum_t MKENUMNAME(authalg);
401 extern p80211enum_t MKENUMNAME(phytype);
402 extern p80211enum_t MKENUMNAME(temptype);
403 extern p80211enum_t MKENUMNAME(regdomain);
404 extern p80211enum_t MKENUMNAME(ccamode);
405 extern p80211enum_t MKENUMNAME(diversity);
406 extern p80211enum_t MKENUMNAME(scantype);
407 extern p80211enum_t MKENUMNAME(resultcode);
408 extern p80211enum_t MKENUMNAME(reason);
409 extern p80211enum_t MKENUMNAME(status);
410 extern p80211enum_t MKENUMNAME(msgcode);
411 extern p80211enum_t MKENUMNAME(msgitem_status);
412
413 extern p80211enum_t MKENUMNAME(lnxroam_reason);
414
415 extern p80211enum_t MKENUMNAME(p2preamble);
416
417 /*================================================================*/
418 /* Function Declarations */
419
420 /*----------------------------------------------------------------*/
421 /* The following declare some utility functions for use with the */
422 /*  p80211enum_t type. */
423
424 u32 p80211enum_text2int(p80211enum_t *ep, char *text);
425 u32 p80211enum_int2text(p80211enum_t *ep, u32 val, char *text);
426 void p80211_error2text(int err_code, char *err_str);
427
428 /*----------------------------------------------------------------*/
429 /* The following declare some utility functions for use with the */
430 /*  p80211item_t and p80211meta_t types. */
431
432 /*----------------------------------------------------------------*/
433 /* The following declare functions that perform validation and    */
434 /* text to binary conversions based on the metadata for interface */
435 /* and MIB data items.                                            */
436 /*----------------------------------------------------------------*/
437
438 /*-- DISPLAYSTR ------------------------------------------------------*/
439 /* pstr ==> cstr */
440 void p80211_totext_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
441
442 /* cstr ==> pstr */
443 void p80211_fromtext_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
444
445 /* function that checks validity of a displaystr binary value */
446 u32 p80211_isvalid_displaystr( struct catlistitem *metalist, u32 did, u8 *itembuf );
447
448 /*-- OCTETSTR --------------------------------------------------------*/
449 /* pstr ==> "xx:xx:...." */
450 void p80211_totext_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
451
452 /* "xx:xx:...." ==> pstr */
453 void p80211_fromtext_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
454
455 /* function that checks validity of an octetstr binary value */
456 u32 p80211_isvalid_octetstr( struct catlistitem *metalist, u32 did, u8 *itembuf );
457
458 /*-- int -------------------------------------------------------------*/
459 /* u32 ==> %d */
460 void p80211_totext_int( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
461
462 /* %d ==> u32 */
463 void p80211_fromtext_int( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
464
465 /* function that checks validity of an int's binary value (always successful) */
466 u32 p80211_isvalid_int( struct catlistitem *metalist, u32 did, u8 *itembuf );
467
468 /*-- ENUMint ---------------------------------------------------------*/
469 /* u32 ==> <valuename> */
470 void p80211_totext_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
471
472 /* <valuename> ==> u32 */
473 void p80211_fromtext_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
474
475 /* function that checks validity of an enum's binary value */
476 u32 p80211_isvalid_enumint( struct catlistitem *metalist, u32 did, u8 *itembuf );
477
478 /*-- intARRAY --------------------------------------------------------*/
479 /* u32[] => %d,%d,%d,... */
480 void p80211_totext_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
481
482 /* %d,%d,%d,... ==> u32[] */
483 void p80211_fromtext_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
484
485 /* function that checks validity of an integer array's value */
486 u32 p80211_isvalid_intarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
487
488 /*-- BITARRAY --------------------------------------------------------*/
489 /* u32 ==> %d,%d,%d,... */
490 void p80211_totext_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
491
492 /* %d,%d,%d,... ==> u32 */
493 void p80211_fromtext_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
494
495 /* function that checks validity of a bit array's value */
496 u32 p80211_isvalid_bitarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
497
498 /*-- MACARRAY --------------------------------------------------------*/
499 void p80211_totext_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
500
501 void p80211_fromtext_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
502
503 /* function that checks validity of a MAC address array's value */
504 u32 p80211_isvalid_macarray( struct catlistitem *metalist, u32 did, u8 *itembuf );
505
506 /*-- MIBATTRIUBTE ------------------------------------------------------*/
507 /* <mibvalue> ==> <textual representation identified in MIB metadata> */
508 void p80211_totext_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
509 void p80211_totext_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
510
511
512 /* <textual representation identified in MIB metadata> ==> <mibvalue> */
513 void p80211_fromtext_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
514 void p80211_fromtext_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf, char *textbuf );
515
516 /* function that checks validity of a mibitem's binary value */
517 u32 p80211_isvalid_getmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf );
518 u32 p80211_isvalid_setmibattribute( struct catlistitem *metalist, u32 did, u8 *itembuf );
519
520 #endif /* _P80211TYPES_H */
521