aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/wlan-ng/p80211mgmt.h
blob: 2610824d36d7833c5b8e3c152585d4f707724827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
/* p80211mgmt.h
*
* Macros, types, and functions to handle 802.11 mgmt frames
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
*   The contents of this file are subject to the Mozilla Public
*   License Version 1.1 (the "License"); you may not use this file
*   except in compliance with the License. You may obtain a copy of
*   the License at http://www.mozilla.org/MPL/
*
*   Software distributed under the License is distributed on an "AS
*   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
*   implied. See the License for the specific language governing
*   rights and limitations under the License.
*
*   Alternatively, the contents of this file may be used under the
*   terms of the GNU Public License version 2 (the "GPL"), in which
*   case the provisions of the GPL are applicable instead of the
*   above.  If you wish to allow the use of your version of this file
*   only under the terms of the GPL and not to allow others to use
*   your version of this file under the MPL, indicate your decision
*   by deleting the provisions above and replace them with the notice
*   and other provisions required by the GPL.  If you do not delete
*   the provisions above, a recipient may use your version of this
*   file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares the constants and types used in the interface
* between a wlan driver and the user mode utilities.
*
* Notes:
*  - Constant values are always in HOST byte order.  To assign
*    values to multi-byte fields they _must_ be converted to
*    ieee byte order.  To retrieve multi-byte values from incoming
*    frames, they must be converted to host order.
*
*  - The len member of the frame structure does NOT!!! include
*    the MAC CRC.  Therefore, the len field on rx'd frames should
*    have 4 subtracted from it.
*
* All functions declared here are implemented in p80211.c
*
* The types, macros, and functions defined here are primarily
* used for encoding and decoding management frames.  They are
* designed to follow these patterns of use:
*
* DECODE:
* 1) a frame of length len is received into buffer b
* 2) using the hdr structure and macros, we determine the type
* 3) an appropriate mgmt frame structure, mf, is allocated and zeroed
* 4) mf.hdr = b
*    mf.buf = b
*    mf.len = len
* 5) call mgmt_decode( mf )
* 6) the frame field pointers in mf are now set.  Note that any
*    multi-byte frame field values accessed using the frame field
*    pointers are in ieee byte order and will have to be converted
*    to host order.
*
* ENCODE:
* 1) Library client allocates buffer space for maximum length
*    frame of the desired type
* 2) Library client allocates a mgmt frame structure, called mf,
*    of the desired type
* 3) Set the following:
*    mf.type = <desired type>
*    mf.buf = <allocated buffer address>
* 4) call mgmt_encode( mf )
* 5) all of the fixed field pointers and fixed length information element
*    pointers in mf are now set to their respective locations in the
*    allocated space (fortunately, all variable length information elements
*    fall at the end of their respective frames).
* 5a) The length field is set to include the last of the fixed and fixed
*     length fields.  It may have to be updated for optional or variable
* 	length information elements.
* 6) Optional and variable length information elements are special cases
*    and must be handled individually by the client code.
* --------------------------------------------------------------------
*/

#ifndef _P80211MGMT_H
#define _P80211MGMT_H

#ifndef _P80211HDR_H
#include "p80211hdr.h"
#endif

/*-- Information Element IDs --------------------*/
#define WLAN_EID_SSID		0
#define WLAN_EID_SUPP_RATES	1
#define WLAN_EID_FH_PARMS	2
#define WLAN_EID_DS_PARMS	3
#define WLAN_EID_CF_PARMS	4
#define WLAN_EID_TIM		5
#define WLAN_EID_IBSS_PARMS	6
/*-- values 7-15 reserved --*/
#define WLAN_EID_CHALLENGE	16
/*-- values 17-31 reserved for challenge text extension --*/
/*-- values 32-255 reserved --*/

/*-- Reason Codes -------------------------------*/
#define WLAN_MGMT_REASON_RSVD			0
#define WLAN_MGMT_REASON_UNSPEC			1
#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID	2
#define WLAN_MGMT_REASON_DEAUTH_LEAVING		3
#define WLAN_MGMT_REASON_DISASSOC_INACTIVE	4
#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY	5
#define WLAN_MGMT_REASON_CLASS2_NONAUTH		6
#define WLAN_MGMT_REASON_CLASS3_NONASSOC	7
#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT	8
#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH	9

/*-- Status Codes -------------------------------*/
#define WLAN_MGMT_STATUS_SUCCESS		0
#define WLAN_MGMT_STATUS_UNSPEC_FAILURE		1
#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED	10
#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC	11
#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC	12
#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG	13
#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ		14
#define WLAN_MGMT_STATUS_CHALLENGE_FAIL		15
#define WLAN_MGMT_STATUS_AUTH_TIMEOUT		16
#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY	17
#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES	18
  /* p80211b additions */
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT	19
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC	20
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY	21

/*-- Auth Algorithm Field ---------------------------*/
#define WLAN_AUTH_ALG_OPENSYSTEM		0
#define WLAN_AUTH_ALG_SHAREDKEY			1

/*-- Management Frame Field Offsets -------------*/
/* Note: Not all fields are listed because of variable lengths,   */
/*       see the code in p80211.c to see how we search for fields */
/* Note: These offsets are from the start of the frame data       */

#define WLAN_BEACON_OFF_TS			0
#define WLAN_BEACON_OFF_BCN_int			8
#define WLAN_BEACON_OFF_CAPINFO			10
#define WLAN_BEACON_OFF_SSID			12

#define WLAN_DISASSOC_OFF_REASON		0

#define WLAN_ASSOCREQ_OFF_CAP_INFO		0
#define WLAN_ASSOCREQ_OFF_LISTEN_int		2
#define WLAN_ASSOCREQ_OFF_SSID			4

#define WLAN_ASSOCRESP_OFF_CAP_INFO		0
#define WLAN_ASSOCRESP_OFF_STATUS		2
#define WLAN_ASSOCRESP_OFF_AID			4
#define WLAN_ASSOCRESP_OFF_SUPP_RATES		6

#define WLAN_REASSOCREQ_OFF_CAP_INFO		0
#define WLAN_REASSOCREQ_OFF_LISTEN_int		2
#define WLAN_REASSOCREQ_OFF_CURR_AP		4
#define WLAN_REASSOCREQ_OFF_SSID		10

#define WLAN_REASSOCRESP_OFF_CAP_INFO		0
#define WLAN_REASSOCRESP_OFF_STATUS		2
#define WLAN_REASSOCRESP_OFF_AID		4
#define WLAN_REASSOCRESP_OFF_SUPP_RATES		6

#define WLAN_PROBEREQ_OFF_SSID			0

#define WLAN_PROBERESP_OFF_TS			0
#define WLAN_PROBERESP_OFF_BCN_int		8
#define WLAN_PROBERESP_OFF_CAP_INFO		10
#define WLAN_PROBERESP_OFF_SSID			12

#define WLAN_AUTHEN_OFF_AUTH_ALG		0
#define WLAN_AUTHEN_OFF_AUTH_SEQ		2
#define WLAN_AUTHEN_OFF_STATUS			4
#define WLAN_AUTHEN_OFF_CHALLENGE		6

#define WLAN_DEAUTHEN_OFF_REASON		0

/*-- Capability Field ---------------------------*/
#define WLAN_GET_MGMT_CAP_INFO_ESS(n)		((n) & BIT(0))
#define WLAN_GET_MGMT_CAP_INFO_IBSS(n)		(((n) & BIT(1)) >> 1)
#define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n)	(((n) & BIT(2)) >> 2)
#define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n)	(((n) & BIT(3)) >> 3)
#define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n)	(((n) & BIT(4)) >> 4)
  /* p80211b additions */
#define WLAN_GET_MGMT_CAP_INFO_SHORT(n)		(((n) & BIT(5)) >> 5)
#define WLAN_GET_MGMT_CAP_INFO_PBCC(n)		(((n) & BIT(6)) >> 6)
#define WLAN_GET_MGMT_CAP_INFO_AGILITY(n)	(((n) & BIT(7)) >> 7)

#define WLAN_SET_MGMT_CAP_INFO_ESS(n)		(n)
#define WLAN_SET_MGMT_CAP_INFO_IBSS(n)		((n) << 1)
#define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n)	((n) << 2)
#define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n)	((n) << 3)
#define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n)	((n) << 4)
  /* p80211b additions */
#define WLAN_SET_MGMT_CAP_INFO_SHORT(n)		((n) << 5)
#define WLAN_SET_MGMT_CAP_INFO_PBCC(n)		((n) << 6)
#define WLAN_SET_MGMT_CAP_INFO_AGILITY(n)	((n) << 7)

/*-- Information Element Types --------------------*/
/* prototype structure, all IEs start with these members */

typedef struct wlan_ie {
	u8 eid;
	u8 len;
} __packed wlan_ie_t;

/*-- Service Set Identity (SSID)  -----------------*/
typedef struct wlan_ie_ssid {
	u8 eid;
	u8 len;
	u8 ssid[1];		/* may be zero, ptrs may overlap */
} __packed wlan_ie_ssid_t;

/*-- Supported Rates  -----------------------------*/
typedef struct wlan_ie_supp_rates {
	u8 eid;
	u8 len;
	u8 rates[1];		/* had better be at LEAST one! */
} __packed wlan_ie_supp_rates_t;

/*-- FH Parameter Set  ----------------------------*/
typedef struct wlan_ie_fh_parms {
	u8 eid;
	u8 len;
	u16 dwell;
	u8 hopset;
	u8 hoppattern;
	u8 hopindex;
} __packed wlan_ie_fh_parms_t;

/*-- DS Parameter Set  ----------------------------*/
typedef struct wlan_ie_ds_parms {
	u8 eid;
	u8 len;
	u8 curr_ch;
} __packed wlan_ie_ds_parms_t;

/*-- CF Parameter Set  ----------------------------*/

typedef struct wlan_ie_cf_parms {
	u8 eid;
	u8 len;
	u8 cfp_cnt;
	u8 cfp_period;
	u16 cfp_maxdur;
	u16 cfp_durremaining;
} __packed wlan_ie_cf_parms_t;

/*-- TIM ------------------------------------------*/
typedef struct wlan_ie_tim {
	u8 eid;
	u8 len;
	u8 dtim_cnt;
	u8 dtim_period;
	u8 bitmap_ctl;
	u8 virt_bm[1];
} __packed wlan_ie_tim_t;

/*-- IBSS Parameter Set ---------------------------*/
typedef struct wlan_ie_ibss_parms {
	u8 eid;
	u8 len;
	u16 atim_win;
} __packed wlan_ie_ibss_parms_t;

/*-- Challenge Text  ------------------------------*/
typedef struct wlan_ie_challenge {
	u8 eid;
	u8 len;
	u8 challenge[1];
} __packed wlan_ie_challenge_t;

/*-------------------------------------------------*/
/*  Frame Types  */

/* prototype structure, all mgmt frame types will start with these members */
typedef struct wlan_fr_mgmt {
	u16 type;
	u16 len;		/* DOES NOT include CRC !!!! */
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	/*-- info elements ----------*/
} wlan_fr_mgmt_t;

/*-- Beacon ---------------------------------------*/
typedef struct wlan_fr_beacon {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u64 *ts;
	u16 *bcn_int;
	u16 *cap_info;
	/*-- info elements ----------*/
	wlan_ie_ssid_t *ssid;
	wlan_ie_supp_rates_t *supp_rates;
	wlan_ie_fh_parms_t *fh_parms;
	wlan_ie_ds_parms_t *ds_parms;
	wlan_ie_cf_parms_t *cf_parms;
	wlan_ie_ibss_parms_t *ibss_parms;
	wlan_ie_tim_t *tim;

} wlan_fr_beacon_t;

/*-- IBSS ATIM ------------------------------------*/
typedef struct wlan_fr_ibssatim {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;

	/*-- fixed fields -----------*/
	/*-- info elements ----------*/

	/* this frame type has a null body */

} wlan_fr_ibssatim_t;

/*-- Disassociation -------------------------------*/
typedef struct wlan_fr_disassoc {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *reason;

	/*-- info elements ----------*/

} wlan_fr_disassoc_t;

/*-- Association Request --------------------------*/
typedef struct wlan_fr_assocreq {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *cap_info;
	u16 *listen_int;
	/*-- info elements ----------*/
	wlan_ie_ssid_t *ssid;
	wlan_ie_supp_rates_t *supp_rates;

} wlan_fr_assocreq_t;

/*-- Association Response -------------------------*/
typedef struct wlan_fr_assocresp {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *cap_info;
	u16 *status;
	u16 *aid;
	/*-- info elements ----------*/
	wlan_ie_supp_rates_t *supp_rates;

} wlan_fr_assocresp_t;

/*-- Reassociation Request ------------------------*/
typedef struct wlan_fr_reassocreq {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *cap_info;
	u16 *listen_int;
	u8 *curr_ap;
	/*-- info elements ----------*/
	wlan_ie_ssid_t *ssid;
	wlan_ie_supp_rates_t *supp_rates;

} wlan_fr_reassocreq_t;

/*-- Reassociation Response -----------------------*/
typedef struct wlan_fr_reassocresp {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *cap_info;
	u16 *status;
	u16 *aid;
	/*-- info elements ----------*/
	wlan_ie_supp_rates_t *supp_rates;

} wlan_fr_reassocresp_t;

/*-- Probe Request --------------------------------*/
typedef struct wlan_fr_probereq {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	/*-- info elements ----------*/
	wlan_ie_ssid_t *ssid;
	wlan_ie_supp_rates_t *supp_rates;

} wlan_fr_probereq_t;

/*-- Probe Response -------------------------------*/
typedef struct wlan_fr_proberesp {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u64 *ts;
	u16 *bcn_int;
	u16 *cap_info;
	/*-- info elements ----------*/
	wlan_ie_ssid_t *ssid;
	wlan_ie_supp_rates_t *supp_rates;
	wlan_ie_fh_parms_t *fh_parms;
	wlan_ie_ds_parms_t *ds_parms;
	wlan_ie_cf_parms_t *cf_parms;
	wlan_ie_ibss_parms_t *ibss_parms;
} wlan_fr_proberesp_t;

/*-- Authentication -------------------------------*/
typedef struct wlan_fr_authen {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *auth_alg;
	u16 *auth_seq;
	u16 *status;
	/*-- info elements ----------*/
	wlan_ie_challenge_t *challenge;

} wlan_fr_authen_t;

/*-- Deauthenication -----------------------------*/
typedef struct wlan_fr_deauthen {
	u16 type;
	u16 len;
	u8 *buf;
	union p80211_hdr *hdr;
	/* used for target specific data, skb in Linux */
	void *priv;
	/*-- fixed fields -----------*/
	u16 *reason;

	/*-- info elements ----------*/

} wlan_fr_deauthen_t;

void wlan_mgmt_encode_beacon(wlan_fr_beacon_t *f);
void wlan_mgmt_decode_beacon(wlan_fr_beacon_t *f);
void wlan_mgmt_encode_disassoc(wlan_fr_disassoc_t *f);
void wlan_mgmt_decode_disassoc(wlan_fr_disassoc_t *f);
void wlan_mgmt_encode_assocreq(wlan_fr_assocreq_t *f);
void wlan_mgmt_decode_assocreq(wlan_fr_assocreq_t *f);
void wlan_mgmt_encode_assocresp(wlan_fr_assocresp_t *f);
void wlan_mgmt_decode_assocresp(wlan_fr_assocresp_t *f);
void wlan_mgmt_encode_reassocreq(wlan_fr_reassocreq_t *f);
void wlan_mgmt_decode_reassocreq(wlan_fr_reassocreq_t *f);
void wlan_mgmt_encode_reassocresp(wlan_fr_reassocresp_t *f);
void wlan_mgmt_decode_reassocresp(wlan_fr_reassocresp_t *f);
void wlan_mgmt_encode_probereq(wlan_fr_probereq_t *f);
void wlan_mgmt_decode_probereq(wlan_fr_probereq_t *f);
void wlan_mgmt_encode_proberesp(wlan_fr_proberesp_t *f);
void wlan_mgmt_decode_proberesp(wlan_fr_proberesp_t *f);
void wlan_mgmt_encode_authen(wlan_fr_authen_t *f);
void wlan_mgmt_decode_authen(wlan_fr_authen_t *f);
void wlan_mgmt_encode_deauthen(wlan_fr_deauthen_t *f);
void wlan_mgmt_decode_deauthen(wlan_fr_deauthen_t *f);

#endif /* _P80211MGMT_H */