Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / net80211 / ieee80211.h @ 13

History | View | Annotate | Download (21.8 KB)

1 13 up20180614
/*        $NetBSD: ieee80211.h,v 1.26 2013/03/30 14:14:31 christos Exp $        */
2
/*-
3
 * Copyright (c) 2001 Atsushi Onoe
4
 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. The name of the author may not be used to endorse or promote products
16
 *    derived from this software without specific prior written permission.
17
 *
18
 * Alternatively, this software may be distributed under the terms of the
19
 * GNU General Public License ("GPL") version 2 as published by the Free
20
 * Software Foundation.
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
 *
33
 * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $
34
 */
35
#ifndef _NET80211_IEEE80211_H_
36
#define _NET80211_IEEE80211_H_
37
38
/*
39
 * 802.11 protocol definitions.
40
 */
41
42
#define        IEEE80211_ADDR_LEN        6                /* size of 802.11 address */
43
/* is 802.11 address multicast/broadcast? */
44
#define        IEEE80211_IS_MULTICAST(_a)        (*(_a) & 0x01)
45
46
/* IEEE 802.11 PLCP header */
47
struct ieee80211_plcp_hdr {
48
        u_int16_t        i_sfd;
49
        u_int8_t        i_signal;
50
        u_int8_t        i_service;
51
        u_int16_t        i_length;
52
        u_int16_t        i_crc;
53
} __packed;
54
55
#define IEEE80211_PLCP_SFD      0xF3A0
56
#define IEEE80211_PLCP_SERVICE  0x00
57
58
/*
59
 * generic definitions for IEEE 802.11 frames
60
 */
61
struct ieee80211_frame {
62
        u_int8_t        i_fc[2];
63
        u_int8_t        i_dur[2];
64
        u_int8_t        i_addr1[IEEE80211_ADDR_LEN];
65
        u_int8_t        i_addr2[IEEE80211_ADDR_LEN];
66
        u_int8_t        i_addr3[IEEE80211_ADDR_LEN];
67
        u_int8_t        i_seq[2];
68
        /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
69
        /* see below */
70
} __packed;
71
72
struct ieee80211_qosframe {
73
        u_int8_t        i_fc[2];
74
        u_int8_t        i_dur[2];
75
        u_int8_t        i_addr1[IEEE80211_ADDR_LEN];
76
        u_int8_t        i_addr2[IEEE80211_ADDR_LEN];
77
        u_int8_t        i_addr3[IEEE80211_ADDR_LEN];
78
        u_int8_t        i_seq[2];
79
        u_int8_t        i_qos[2];
80
        /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
81
        /* see below */
82
} __packed;
83
84
struct ieee80211_qoscntl {
85
        u_int8_t        i_qos[2];
86
};
87
88
struct ieee80211_frame_addr4 {
89
        u_int8_t        i_fc[2];
90
        u_int8_t        i_dur[2];
91
        u_int8_t        i_addr1[IEEE80211_ADDR_LEN];
92
        u_int8_t        i_addr2[IEEE80211_ADDR_LEN];
93
        u_int8_t        i_addr3[IEEE80211_ADDR_LEN];
94
        u_int8_t        i_seq[2];
95
        u_int8_t        i_addr4[IEEE80211_ADDR_LEN];
96
} __packed;
97
98
99
struct ieee80211_qosframe_addr4 {
100
        u_int8_t        i_fc[2];
101
        u_int8_t        i_dur[2];
102
        u_int8_t        i_addr1[IEEE80211_ADDR_LEN];
103
        u_int8_t        i_addr2[IEEE80211_ADDR_LEN];
104
        u_int8_t        i_addr3[IEEE80211_ADDR_LEN];
105
        u_int8_t        i_seq[2];
106
        u_int8_t        i_addr4[IEEE80211_ADDR_LEN];
107
        u_int8_t        i_qos[2];
108
} __packed;
109
110
#define        IEEE80211_FC0_VERSION_MASK                0x03
111
#define        IEEE80211_FC0_VERSION_SHIFT                0
112
#define        IEEE80211_FC0_VERSION_0                        0x00
113
#define        IEEE80211_FC0_TYPE_MASK                        0x0c
114
#define        IEEE80211_FC0_TYPE_SHIFT                2
115
#define        IEEE80211_FC0_TYPE_MGT                        0x00
116
#define        IEEE80211_FC0_TYPE_CTL                        0x04
117
#define        IEEE80211_FC0_TYPE_DATA                        0x08
118
119
#define        IEEE80211_FC0_SUBTYPE_MASK                0xf0
120
#define        IEEE80211_FC0_SUBTYPE_SHIFT                4
121
/* for TYPE_MGT */
122
#define        IEEE80211_FC0_SUBTYPE_ASSOC_REQ                0x00
123
#define        IEEE80211_FC0_SUBTYPE_ASSOC_RESP        0x10
124
#define        IEEE80211_FC0_SUBTYPE_REASSOC_REQ        0x20
125
#define        IEEE80211_FC0_SUBTYPE_REASSOC_RESP        0x30
126
#define        IEEE80211_FC0_SUBTYPE_PROBE_REQ                0x40
127
#define        IEEE80211_FC0_SUBTYPE_PROBE_RESP        0x50
128
#define        IEEE80211_FC0_SUBTYPE_BEACON                0x80
129
#define        IEEE80211_FC0_SUBTYPE_ATIM                0x90
130
#define        IEEE80211_FC0_SUBTYPE_DISASSOC                0xa0
131
#define        IEEE80211_FC0_SUBTYPE_AUTH                0xb0
132
#define        IEEE80211_FC0_SUBTYPE_DEAUTH                0xc0
133
/* for TYPE_CTL */
134
#define        IEEE80211_FC0_SUBTYPE_PS_POLL                0xa0
135
#define        IEEE80211_FC0_SUBTYPE_RTS                0xb0
136
#define        IEEE80211_FC0_SUBTYPE_CTS                0xc0
137
#define        IEEE80211_FC0_SUBTYPE_ACK                0xd0
138
#define        IEEE80211_FC0_SUBTYPE_CF_END                0xe0
139
#define        IEEE80211_FC0_SUBTYPE_CF_END_ACK        0xf0
140
/* for TYPE_DATA (bit combination) */
141
#define        IEEE80211_FC0_SUBTYPE_DATA                0x00
142
#define        IEEE80211_FC0_SUBTYPE_CF_ACK                0x10
143
#define        IEEE80211_FC0_SUBTYPE_CF_POLL                0x20
144
#define        IEEE80211_FC0_SUBTYPE_CF_ACPL                0x30
145
#define        IEEE80211_FC0_SUBTYPE_NODATA                0x40
146
#define        IEEE80211_FC0_SUBTYPE_CFACK                0x50
147
#define        IEEE80211_FC0_SUBTYPE_CFPOLL                0x60
148
#define        IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK        0x70
149
#define        IEEE80211_FC0_SUBTYPE_QOS                0x80
150
#define        IEEE80211_FC0_SUBTYPE_QOS_NULL                0xc0
151
152
/*
153
 * DS bit usage
154
 *
155
 * TA = transmitter address
156
 * RA = receiver address
157
 * DA = destination address
158
 * SA = source address
159
 *
160
 * ToDS    FromDS  A1(RA)  A2(TA)  A3      A4      Use
161
 * -----------------------------------------------------------------
162
 *  0       0       DA      SA      BSSID   -       IBSS/DLS
163
 *  0       1       DA      BSSID   SA      -       AP -> STA
164
 *  1       0       BSSID   SA      DA      -       AP <- STA
165
 *  1       1       RA      TA      DA      SA      unspecified (WDS)
166
 */
167
#define        IEEE80211_FC1_DIR_MASK                        0x03
168
#define        IEEE80211_FC1_DIR_NODS                        0x00        /* STA->STA */
169
#define        IEEE80211_FC1_DIR_TODS                        0x01        /* STA->AP  */
170
#define        IEEE80211_FC1_DIR_FROMDS                0x02        /* AP ->STA */
171
#define        IEEE80211_FC1_DIR_DSTODS                0x03        /* AP ->AP  */
172
173
#define        IEEE80211_FC1_MORE_FRAG                        0x04
174
#define        IEEE80211_FC1_RETRY                        0x08
175
#define        IEEE80211_FC1_PWR_MGT                        0x10
176
#define        IEEE80211_FC1_MORE_DATA                        0x20
177
#define        IEEE80211_FC1_PROTECTED                        0x40
178
#define        IEEE80211_FC1_WEP                        0x40        /* pre-RSNA compat */
179
#define        IEEE80211_FC1_ORDER                        0x80
180
181
#define        IEEE80211_SEQ_FRAG_MASK                        0x000f
182
#define        IEEE80211_SEQ_FRAG_SHIFT                0
183
#define        IEEE80211_SEQ_SEQ_MASK                        0xfff0
184
#define        IEEE80211_SEQ_SEQ_SHIFT                        4
185
186
#define        IEEE80211_NWID_LEN                        32
187
188
/*
189
 * QoS Control field (see 7.1.3.5).
190
 */
191
/* bit 8 is reserved */
192
#define        IEEE80211_QOS_TXOP                        0xff00
193
#define        IEEE80211_QOS_AMSDU                        0x0080  /* 11n */
194
#define        IEEE80211_QOS_ACKPOLICY_NORMAL          0x0000
195
#define        IEEE80211_QOS_ACKPOLICY_NOACK           0x0020
196
#define        IEEE80211_QOS_ACKPOLICY_NOEXPLACK       0x0040
197
#define        IEEE80211_QOS_ACKPOLICY                        0x0060
198
#define        IEEE80211_QOS_ACKPOLICY_S                5
199
#define        IEEE80211_QOS_ACKPOLICY_MASK                0x0060
200
#define        IEEE80211_QOS_ACKPOLICY_BA                0x0060
201
#define        IEEE80211_QOS_ESOP                        0x0010
202
#define        IEEE80211_QOS_ESOP_S                        4
203
#define        IEEE80211_QOS_TID                        0x000f
204
205
/*
206
 * WME/802.11e information element.
207
 */
208
struct ieee80211_wme_info {
209
        u_int8_t        wme_id;                /* IEEE80211_ELEMID_VENDOR */
210
        u_int8_t        wme_len;        /* length in bytes */
211
        u_int8_t        wme_oui[3];        /* 0x00, 0x50, 0xf2 */
212
        u_int8_t        wme_type;        /* OUI type */
213
        u_int8_t        wme_subtype;        /* OUI subtype */
214
        u_int8_t        wme_version;        /* spec revision */
215
        u_int8_t        wme_info;        /* QoS info */
216
} __packed;
217
218
/*
219
 * WME/802.11e Tspec Element
220
 */
221
struct ieee80211_wme_tspec {
222
        u_int8_t        ts_id;
223
        u_int8_t        ts_len;
224
        u_int8_t        ts_oui[3];
225
        u_int8_t        ts_oui_type;
226
        u_int8_t        ts_oui_subtype;
227
        u_int8_t        ts_version;
228
        u_int8_t        ts_tsinfo[3];
229
        u_int8_t        ts_nom_msdu[2];
230
        u_int8_t        ts_max_msdu[2];
231
        u_int8_t        ts_min_svc[4];
232
        u_int8_t        ts_max_svc[4];
233
        u_int8_t        ts_inactv_intv[4];
234
        u_int8_t        ts_susp_intv[4];
235
        u_int8_t        ts_start_svc[4];
236
        u_int8_t        ts_min_rate[4];
237
        u_int8_t        ts_mean_rate[4];
238
        u_int8_t        ts_max_burst[4];
239
        u_int8_t        ts_min_phy[4];
240
        u_int8_t        ts_peak_rate[4];
241
        u_int8_t        ts_delay[4];
242
        u_int8_t        ts_surplus[2];
243
        u_int8_t        ts_medium_time[2];
244
} __packed;
245
246
/*
247
 * WME AC parameter field
248
 */
249
struct ieee80211_wme_acparams {
250
        u_int8_t        acp_aci_aifsn;
251
        u_int8_t        acp_logcwminmax;
252
        u_int16_t        acp_txop;
253
} __packed;
254
255
/* WME stream classes */
256
enum ieee80211_wme_ac {
257
        WME_AC_BE        = 0,                /* best effort */
258
        WME_AC_BK        = 1,                /* background */
259
        WME_AC_VI        = 2,                /* video */
260
        WME_AC_VO        = 3,                /* voice */
261
};
262
#define WME_NUM_AC        4                /* 4 AC categories */
263
264
#define WME_PARAM_ACI                0x60        /* Mask for ACI field */
265
#define WME_PARAM_ACI_S                5        /* Shift for ACI field */
266
#define WME_PARAM_ACM                0x10        /* Mask for ACM bit */
267
#define WME_PARAM_ACM_S                4        /* Shift for ACM bit */
268
#define WME_PARAM_AIFSN                0x0f        /* Mask for aifsn field */
269
#define WME_PARAM_AIFSN_S        0        /* Shift for aifsn field */
270
#define WME_PARAM_LOGCWMIN        0x0f        /* Mask for CwMin field (in log) */
271
#define WME_PARAM_LOGCWMIN_S        0        /* Shift for CwMin field */
272
#define WME_PARAM_LOGCWMAX        0xf0        /* Mask for CwMax field (in log) */
273
#define WME_PARAM_LOGCWMAX_S        4        /* Shift for CwMax field */
274
275
#define WME_AC_TO_TID(_ac) (       \
276
        ((_ac) == WME_AC_VO) ? 6 : \
277
        ((_ac) == WME_AC_VI) ? 5 : \
278
        ((_ac) == WME_AC_BK) ? 1 : \
279
        0)
280
281
#define TID_TO_WME_AC(_tid) (      \
282
        ((_tid) < 1) ? WME_AC_BE : \
283
        ((_tid) < 3) ? WME_AC_BK : \
284
        ((_tid) < 6) ? WME_AC_VI : \
285
        WME_AC_VO)
286
287
/*
288
 * WME Parameter Element
289
 */
290
struct ieee80211_wme_param {
291
        u_int8_t        param_id;
292
        u_int8_t        param_len;
293
        u_int8_t        param_oui[3];
294
        u_int8_t        param_oui_type;
295
        u_int8_t        param_oui_sybtype;
296
        u_int8_t        param_version;
297
        u_int8_t        param_qosInfo;
298
#define        WME_QOSINFO_COUNT        0x0f        /* Mask for param count field */
299
        u_int8_t        param_reserved;
300
        struct ieee80211_wme_acparams        params_acParams[WME_NUM_AC];
301
} __packed;
302
303
/*
304
 * Management Notification Frame
305
 */
306
struct ieee80211_mnf {
307
        u_int8_t        mnf_category;
308
        u_int8_t        mnf_action;
309
        u_int8_t        mnf_dialog;
310
        u_int8_t        mnf_status;
311
} __packed;
312
#define        MNF_SETUP_REQ        0
313
#define        MNF_SETUP_RESP        1
314
#define        MNF_TEARDOWN        2
315
316
/*
317
 * Control frames.
318
 */
319
struct ieee80211_frame_min {
320
        u_int8_t        i_fc[2];
321
        u_int8_t        i_dur[2];
322
        u_int8_t        i_addr1[IEEE80211_ADDR_LEN];
323
        u_int8_t        i_addr2[IEEE80211_ADDR_LEN];
324
        /* FCS */
325
} __packed;
326
327
struct ieee80211_frame_rts {
328
        u_int8_t        i_fc[2];
329
        u_int8_t        i_dur[2];
330
        u_int8_t        i_ra[IEEE80211_ADDR_LEN];
331
        u_int8_t        i_ta[IEEE80211_ADDR_LEN];
332
        /* FCS */
333
} __packed;
334
335
struct ieee80211_frame_cts {
336
        u_int8_t        i_fc[2];
337
        u_int8_t        i_dur[2];
338
        u_int8_t        i_ra[IEEE80211_ADDR_LEN];
339
        /* FCS */
340
} __packed;
341
342
struct ieee80211_frame_ack {
343
        u_int8_t        i_fc[2];
344
        u_int8_t        i_dur[2];
345
        u_int8_t        i_ra[IEEE80211_ADDR_LEN];
346
        /* FCS */
347
} __packed;
348
349
struct ieee80211_frame_pspoll {
350
        u_int8_t        i_fc[2];
351
        u_int8_t        i_aid[2];
352
        u_int8_t        i_bssid[IEEE80211_ADDR_LEN];
353
        u_int8_t        i_ta[IEEE80211_ADDR_LEN];
354
        /* FCS */
355
} __packed;
356
357
struct ieee80211_frame_cfend {                /* NB: also CF-End+CF-Ack */
358
        u_int8_t        i_fc[2];
359
        u_int8_t        i_dur[2];        /* should be zero */
360
        u_int8_t        i_ra[IEEE80211_ADDR_LEN];
361
        u_int8_t        i_bssid[IEEE80211_ADDR_LEN];
362
        /* FCS */
363
} __packed;
364
365
static __inline int
366
ieee80211_has_seq(const struct ieee80211_frame *wh)
367
{
368
        return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) !=
369
            IEEE80211_FC0_TYPE_CTL;
370
}
371
372
static __inline int
373
ieee80211_has_addr4(const struct ieee80211_frame *wh)
374
{
375
        return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) ==
376
            IEEE80211_FC1_DIR_DSTODS;
377
}
378
379
static __inline int
380
ieee80211_has_qos(const struct ieee80211_frame *wh)
381
{
382
        return (wh->i_fc[0] &
383
            (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) ==
384
            (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS);
385
}
386
387
static __inline int
388
ieee80211_has_htc(const struct ieee80211_frame *wh)
389
{
390
        return (wh->i_fc[1] & IEEE80211_FC1_ORDER) &&
391
            (ieee80211_has_qos(wh) ||
392
             (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
393
             IEEE80211_FC0_TYPE_MGT);
394
}
395
396
static __inline u_int16_t
397
ieee80211_get_qos(const struct ieee80211_frame *wh)
398
{
399
        const u_int8_t *frm;
400
401
        if (ieee80211_has_addr4(wh))
402
                frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos;
403
        else
404
                frm = ((const struct ieee80211_qosframe *)wh)->i_qos;
405
406
        return le16toh(*(const u_int16_t *)frm);
407
}
408
409
/*
410
 * BEACON management packets
411
 *
412
 *        octet timestamp[8]
413
 *        octet beacon interval[2]
414
 *        octet capability information[2]
415
 *        information element
416
 *                octet elemid
417
 *                octet length
418
 *                octet information[length]
419
 */
420
421
typedef u_int8_t *ieee80211_mgt_beacon_t;
422
423
#define        IEEE80211_BEACON_INTERVAL(beacon) \
424
        ((beacon)[8] | ((beacon)[9] << 8))
425
#define        IEEE80211_BEACON_CAPABILITY(beacon) \
426
        ((beacon)[10] | ((beacon)[11] << 8))
427
428
#define        IEEE80211_CAPINFO_ESS                        0x0001
429
#define        IEEE80211_CAPINFO_IBSS                        0x0002
430
#define        IEEE80211_CAPINFO_CF_POLLABLE                0x0004
431
#define        IEEE80211_CAPINFO_CF_POLLREQ                0x0008
432
#define        IEEE80211_CAPINFO_PRIVACY                0x0010
433
#define        IEEE80211_CAPINFO_SHORT_PREAMBLE        0x0020
434
#define        IEEE80211_CAPINFO_PBCC                        0x0040
435
#define        IEEE80211_CAPINFO_CHNL_AGILITY                0x0080
436
/* bits 8-9 are reserved */
437
#define        IEEE80211_CAPINFO_SHORT_SLOTTIME        0x0400
438
#define        IEEE80211_CAPINFO_RSN                        0x0800
439
/* bit 12 is reserved */
440
#define        IEEE80211_CAPINFO_DSSSOFDM                0x2000
441
/* bits 14-15 are reserved */
442
443
/*
444
 * 802.11i/WPA information element (maximally sized).
445
 */
446
struct ieee80211_ie_wpa {
447
        u_int8_t        wpa_id;                /* IEEE80211_ELEMID_VENDOR */
448
        u_int8_t        wpa_len;        /* length in bytes */
449
        u_int8_t        wpa_oui[3];        /* 0x00, 0x50, 0xf2 */
450
        u_int8_t        wpa_type;        /* OUI type */
451
        u_int16_t        wpa_version;        /* spec revision */
452
        u_int32_t        wpa_mcipher[1];        /* multicast/group key cipher */
453
        u_int16_t        wpa_uciphercnt;        /* # pairwise key ciphers */
454
        u_int32_t        wpa_uciphers[8];/* ciphers */
455
        u_int16_t        wpa_authselcnt;        /* authentication selector cnt*/
456
        u_int32_t        wpa_authsels[8];/* selectors */
457
        u_int16_t        wpa_caps;        /* 802.11i capabilities */
458
        u_int16_t        wpa_pmkidcnt;        /* 802.11i pmkid count */
459
        u_int16_t        wpa_pmkids[8];        /* 802.11i pmkids */
460
} __packed;
461
462
/*
463
 * Management information element payloads.
464
 */
465
466
enum {
467
        IEEE80211_ELEMID_SSID                = 0,
468
        IEEE80211_ELEMID_RATES                = 1,
469
        IEEE80211_ELEMID_FHPARMS        = 2,
470
        IEEE80211_ELEMID_DSPARMS        = 3,
471
        IEEE80211_ELEMID_CFPARMS        = 4,
472
        IEEE80211_ELEMID_TIM                = 5,
473
        IEEE80211_ELEMID_IBSSPARMS        = 6,
474
        IEEE80211_ELEMID_COUNTRY        = 7,
475
        IEEE80211_ELEMID_EDCAPARMS        = 12,
476
        IEEE80211_ELEMID_CHALLENGE        = 16,
477
        /* 17-31 reserved for challenge text extension */
478
        IEEE80211_ELEMID_PWRCNSTR        = 32,
479
        IEEE80211_ELEMID_PWRCAP                = 33,
480
        IEEE80211_ELEMID_TPCREQ                = 34,
481
        IEEE80211_ELEMID_TPCREP                = 35,
482
        IEEE80211_ELEMID_SUPPCHAN        = 36,
483
        IEEE80211_ELEMID_CHANSWITCHANN        = 37,
484
        IEEE80211_ELEMID_MEASREQ        = 38,
485
        IEEE80211_ELEMID_MEASREP        = 39,
486
        IEEE80211_ELEMID_QUIET                = 40,
487
        IEEE80211_ELEMID_IBSSDFS        = 41,
488
        IEEE80211_ELEMID_ERP                = 42,
489
        IEEE80211_ELEMID_HTCAP                = 45,        /* 11n */
490
        IEEE80211_ELEMID_QOS_CAP        = 46,
491
        IEEE80211_ELEMID_RSN                = 48,
492
        IEEE80211_ELEMID_XRATES                = 50,
493
        IEEE80211_ELEMID_TIE                = 56,        /* 11r */
494
        IEEE80211_ELEMID_HTINFO                = 61,        /* 11n */
495
        IEEE80211_ELEMID_MMIE                = 76,        /* 11w */
496
        IEEE80211_ELEMID_TPC                = 150,
497
        IEEE80211_ELEMID_CCKM                = 156,
498
        IEEE80211_ELEMID_VENDOR                = 221        /* vendor private */
499
};
500
501
struct ieee80211_tim_ie {
502
        u_int8_t        tim_ie;                        /* IEEE80211_ELEMID_TIM */
503
        u_int8_t        tim_len;
504
        u_int8_t        tim_count;                /* DTIM count */
505
        u_int8_t        tim_period;                /* DTIM period */
506
        u_int8_t        tim_bitctl;                /* bitmap control */
507
        u_int8_t        tim_bitmap[1];                /* variable-length bitmap */
508
} __packed;
509
510
struct ieee80211_band {
511
        u_int8_t schan;                        /* starting channel */
512
        u_int8_t nchan;                        /* number channels */
513
        u_int8_t maxtxpwr;                /* tx power cap */
514
} __packed;
515
516
struct ieee80211_country_ie {
517
        u_int8_t        ie;                        /* IEEE80211_ELEMID_COUNTRY */
518
        u_int8_t        len;
519
        u_int8_t        cc[3];                        /* ISO CC+(I)ndoor/(O)utdoor */
520
        struct ieee80211_band band[4];                /* up to 4 sub bands */
521
} __packed;
522
523
#define IEEE80211_CHALLENGE_LEN                128
524
525
#define        IEEE80211_RATE_BASIC                0x80
526
#define        IEEE80211_RATE_VAL                0x7f
527
528
/* EPR information element flags */
529
#define        IEEE80211_ERP_NON_ERP_PRESENT        0x01
530
#define        IEEE80211_ERP_USE_PROTECTION        0x02
531
#define        IEEE80211_ERP_LONG_PREAMBLE        0x04
532
533
/* Atheros private advanced capabilities info */
534
#define        ATHEROS_CAP_TURBO_PRIME                0x01
535
#define        ATHEROS_CAP_COMPRESSION                0x02
536
#define        ATHEROS_CAP_FAST_FRAME                0x04
537
/* bits 3-6 reserved */
538
#define        ATHEROS_CAP_BOOST                0x80
539
540
#define        ATH_OUI                        0x7f0300                /* Atheros OUI */
541
#define        ATH_OUI_TYPE                0x01
542
#define        ATH_OUI_VERSION                0x01
543
544
#define        WPA_OUI                        0xf25000
545
#define        WPA_OUI_TYPE                0x01
546
#define        WPA_VERSION                1                /* current supported version */
547
548
#define        WPA_CSE_NULL                0x00
549
#define        WPA_CSE_WEP40                0x01
550
#define        WPA_CSE_TKIP                0x02
551
#define        WPA_CSE_CCMP                0x04
552
#define        WPA_CSE_WEP104                0x05
553
554
#define        WPA_ASE_NONE                0x00
555
#define        WPA_ASE_8021X_UNSPEC        0x01
556
#define        WPA_ASE_8021X_PSK        0x02
557
558
#define        RSN_OUI                        0xac0f00
559
#define        RSN_VERSION                1                /* current supported version */
560
561
#define        RSN_CSE_NULL                0x00
562
#define        RSN_CSE_WEP40                0x01
563
#define        RSN_CSE_TKIP                0x02
564
#define        RSN_CSE_WRAP                0x03
565
#define        RSN_CSE_CCMP                0x04
566
#define        RSN_CSE_WEP104                0x05
567
568
#define        RSN_ASE_NONE                0x00
569
#define        RSN_ASE_8021X_UNSPEC        0x01
570
#define        RSN_ASE_8021X_PSK        0x02
571
572
#define        RSN_CAP_PREAUTH                0x01
573
574
#define        WME_OUI                        0xf25000
575
#define        WME_OUI_TYPE                0x02
576
#define        WME_INFO_OUI_SUBTYPE        0x00
577
#define        WME_PARAM_OUI_SUBTYPE        0x01
578
#define        WME_VERSION                1
579
580
/*
581
 * AUTH management packets
582
 *
583
 *        octet algo[2]
584
 *        octet seq[2]
585
 *        octet status[2]
586
 *        octet chal.id
587
 *        octet chal.length
588
 *        octet chal.text[253]
589
 */
590
591
typedef u_int8_t *ieee80211_mgt_auth_t;
592
593
#define        IEEE80211_AUTH_ALGORITHM(auth) \
594
        ((auth)[0] | ((auth)[1] << 8))
595
#define        IEEE80211_AUTH_TRANSACTION(auth) \
596
        ((auth)[2] | ((auth)[3] << 8))
597
#define        IEEE80211_AUTH_STATUS(auth) \
598
        ((auth)[4] | ((auth)[5] << 8))
599
600
#define        IEEE80211_AUTH_ALG_OPEN                0x0000
601
#define        IEEE80211_AUTH_ALG_SHARED        0x0001
602
#define        IEEE80211_AUTH_ALG_LEAP                0x0080
603
604
enum {
605
        IEEE80211_AUTH_OPEN_REQUEST                = 1,
606
        IEEE80211_AUTH_OPEN_RESPONSE                = 2
607
};
608
609
enum {
610
        IEEE80211_AUTH_SHARED_REQUEST                = 1,
611
        IEEE80211_AUTH_SHARED_CHALLENGE                = 2,
612
        IEEE80211_AUTH_SHARED_RESPONSE                = 3,
613
        IEEE80211_AUTH_SHARED_PASS                = 4
614
};
615
616
/*
617
 * Reason codes
618
 *
619
 * Unlisted codes are reserved
620
 */
621
622
enum {
623
        IEEE80211_REASON_UNSPECIFIED                = 1,
624
        IEEE80211_REASON_AUTH_EXPIRE                = 2,
625
        IEEE80211_REASON_AUTH_LEAVE                = 3,
626
        IEEE80211_REASON_ASSOC_EXPIRE                = 4,
627
        IEEE80211_REASON_ASSOC_TOOMANY                = 5,
628
        IEEE80211_REASON_NOT_AUTHED                = 6,
629
        IEEE80211_REASON_NOT_ASSOCED                = 7,
630
        IEEE80211_REASON_ASSOC_LEAVE                = 8,
631
        IEEE80211_REASON_ASSOC_NOT_AUTHED        = 9,
632
633
        IEEE80211_REASON_RSN_REQUIRED                = 11,
634
        IEEE80211_REASON_RSN_INCONSISTENT        = 12,
635
        IEEE80211_REASON_IE_INVALID                = 13,
636
        IEEE80211_REASON_MIC_FAILURE                = 14,
637
638
        IEEE80211_STATUS_SUCCESS                = 0,
639
        IEEE80211_STATUS_UNSPECIFIED                = 1,
640
        IEEE80211_STATUS_CAPINFO                = 10,
641
        IEEE80211_STATUS_NOT_ASSOCED                = 11,
642
        IEEE80211_STATUS_OTHER                        = 12,
643
        IEEE80211_STATUS_ALG                        = 13,
644
        IEEE80211_STATUS_SEQUENCE                = 14,
645
        IEEE80211_STATUS_CHALLENGE                = 15,
646
        IEEE80211_STATUS_TIMEOUT                = 16,
647
        IEEE80211_STATUS_TOOMANY                = 17,
648
        IEEE80211_STATUS_BASIC_RATE                = 18,
649
        IEEE80211_STATUS_SP_REQUIRED                = 19,
650
        IEEE80211_STATUS_PBCC_REQUIRED                = 20,
651
        IEEE80211_STATUS_CA_REQUIRED                = 21,
652
        IEEE80211_STATUS_TOO_MANY_STATIONS        = 22,
653
        IEEE80211_STATUS_RATES                        = 23,
654
        IEEE80211_STATUS_SHORTSLOT_REQUIRED        = 25,
655
        IEEE80211_STATUS_DSSSOFDM_REQUIRED        = 26
656
};
657
658
#define        IEEE80211_WEP_KEYLEN                5        /* 40bit */
659
#define        IEEE80211_WEP_IVLEN                3        /* 24bit */
660
#define        IEEE80211_WEP_KIDLEN                1        /* 1 octet */
661
#define        IEEE80211_WEP_CRCLEN                4        /* CRC-32 */
662
#define        IEEE80211_WEP_TOTLEN                (IEEE80211_WEP_IVLEN + \
663
                                         IEEE80211_WEP_KIDLEN + \
664
                                         IEEE80211_WEP_CRCLEN)
665
#define        IEEE80211_WEP_NKID                4        /* number of key ids */
666
667
/*
668
 * 802.11i defines an extended IV for use with non-WEP ciphers.
669
 * When the EXTIV bit is set in the key id byte an additional
670
 * 4 bytes immediately follow the IV for TKIP.  For CCMP the
671
 * EXTIV bit is likewise set but the 8 bytes represent the
672
 * CCMP header rather than IV+extended-IV.
673
 */
674
#define        IEEE80211_WEP_EXTIV                0x20
675
#define        IEEE80211_WEP_EXTIVLEN                4        /* extended IV length */
676
#define        IEEE80211_WEP_MICLEN                8        /* trailing MIC */
677
678
#define        IEEE80211_CRC_LEN                4
679
680
/*
681
 * Maximum acceptable MTU is:
682
 *        IEEE80211_MAX_LEN - WEP overhead - CRC -
683
 *                QoS overhead - RSN/WPA overhead
684
 * Min is arbitrarily chosen > IEEE80211_MIN_LEN.  The default
685
 * mtu is Ethernet-compatible; it's set by ether_ifattach.
686
 */
687
#define        IEEE80211_MTU_MAX                2290
688
#define        IEEE80211_MTU_MIN                32
689
690
#define        IEEE80211_MAX_LEN                (2300 + IEEE80211_CRC_LEN + \
691
    (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN))
692
#define        IEEE80211_ACK_LEN \
693
        (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN)
694
#define        IEEE80211_MIN_LEN \
695
        (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN)
696
697
/*
698
 * The 802.11 spec says at most 2007 stations may be
699
 * associated at once.  For most AP's this is way more
700
 * than is feasible so we use a default of 128.  This
701
 * number may be overridden by the driver and/or by
702
 * user configuration.
703
 */
704
#define        IEEE80211_AID_MAX                2007
705
#define        IEEE80211_AID_DEF                128
706
707
#define        IEEE80211_AID(b)        ((b) &~ 0xc000)
708
709
/*
710
 * RTS frame length parameters.  The default is specified in
711
 * the 802.11 spec as 512; we treat it as implementation-dependent
712
 * so it's defined in ieee80211_var.h.  The max may be wrong
713
 * for jumbo frames.
714
 */
715
#define        IEEE80211_RTS_MIN                1
716
#define        IEEE80211_RTS_MAX                2346
717
718
/*
719
 * TX fragmentation parameters.  As above for RTS, we treat
720
 * default as implementation-dependent so define it elsewhere.
721
 */
722
#define        IEEE80211_FRAG_MIN                256
723
#define        IEEE80211_FRAG_MAX                2346
724
725
/*
726
 * 802.11 frame duration definitions.
727
 */
728
729
struct ieee80211_duration {
730
        uint16_t        d_rts_dur;
731
        uint16_t        d_data_dur;
732
        uint16_t        d_plcp_len;
733
        uint8_t                d_residue;        /* unused octets in time slot */
734
};
735
736
/* One Time Unit (TU) is 1Kus = 1024 microseconds. */
737
#define IEEE80211_DUR_TU                1024
738
739
/* IEEE 802.11b durations for DSSS PHY in microseconds */
740
#define IEEE80211_DUR_DS_LONG_PREAMBLE        144
741
#define IEEE80211_DUR_DS_SHORT_PREAMBLE        72
742
743
#define IEEE80211_DUR_DS_SLOW_PLCPHDR        48
744
#define IEEE80211_DUR_DS_FAST_PLCPHDR        24
745
#define IEEE80211_DUR_DS_SLOW_ACK        112
746
#define IEEE80211_DUR_DS_FAST_ACK        56
747
#define IEEE80211_DUR_DS_SLOW_CTS        112
748
#define IEEE80211_DUR_DS_FAST_CTS        56
749
750
#define IEEE80211_DUR_DS_SLOT                20
751
#define IEEE80211_DUR_DS_SIFS                10
752
#define IEEE80211_DUR_DS_PIFS        (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT)
753
#define IEEE80211_DUR_DS_DIFS        (IEEE80211_DUR_DS_SIFS + \
754
                                 2 * IEEE80211_DUR_DS_SLOT)
755
#define IEEE80211_DUR_DS_EIFS        (IEEE80211_DUR_DS_SIFS + \
756
                                 IEEE80211_DUR_DS_SLOW_ACK + \
757
                                 IEEE80211_DUR_DS_LONG_PREAMBLE + \
758
                                 IEEE80211_DUR_DS_SLOW_PLCPHDR + \
759
                                 IEEE80211_DUR_DS_DIFS)
760
761
762
#endif /* !_NET80211_IEEE80211_H_ */