]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/ieee802_11.h
This commit was generated by cvs2svn to compensate for changes in r172668,
[FreeBSD/FreeBSD.git] / contrib / tcpdump / ieee802_11.h
1 /* $FreeBSD$ */
2 /* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9 2003/07/22 17:36:57 guy Exp $ (LBL) */
3 /*
4  * Copyright (c) 2001
5  *      Fortress Technologies
6  *      Charlie Lenahan ( clenahan@fortresstech.com )
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that: (1) source code distributions
10  * retain the above copyright notice and this paragraph in its entirety, (2)
11  * distributions including binary code include the above copyright notice and
12  * this paragraph in its entirety in the documentation or other materials
13  * provided with the distribution, and (3) all advertising materials mentioning
14  * features or use of this software display the following acknowledgement:
15  * ``This product includes software developed by the University of California,
16  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
17  * the University nor the names of its contributors may be used to endorse
18  * or promote products derived from this software without specific prior
19  * written permission.
20  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
21  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23  */
24
25 /* Lengths of 802.11 header components. */
26 #define IEEE802_11_FC_LEN               2
27 #define IEEE802_11_DUR_LEN              2
28 #define IEEE802_11_DA_LEN               6
29 #define IEEE802_11_SA_LEN               6
30 #define IEEE802_11_BSSID_LEN            6
31 #define IEEE802_11_RA_LEN               6
32 #define IEEE802_11_TA_LEN               6
33 #define IEEE802_11_SEQ_LEN              2
34 #define IEEE802_11_CTL_LEN              2
35 #define IEEE802_11_IV_LEN               3
36 #define IEEE802_11_KID_LEN              1
37
38 /* Frame check sequence length. */
39 #define IEEE802_11_FCS_LEN              4
40
41 /* Lengths of beacon components. */
42 #define IEEE802_11_TSTAMP_LEN           8
43 #define IEEE802_11_BCNINT_LEN           2
44 #define IEEE802_11_CAPINFO_LEN          2
45 #define IEEE802_11_LISTENINT_LEN        2
46
47 #define IEEE802_11_AID_LEN              2
48 #define IEEE802_11_STATUS_LEN           2
49 #define IEEE802_11_REASON_LEN           2
50
51 /* Length of previous AP in reassocation frame */
52 #define IEEE802_11_AP_LEN               6
53
54 #define T_MGMT 0x0  /* management */
55 #define T_CTRL 0x1  /* control */
56 #define T_DATA 0x2 /* data */
57 #define T_RESV 0x3  /* reserved */
58
59 #define ST_ASSOC_REQUEST        0x0
60 #define ST_ASSOC_RESPONSE       0x1
61 #define ST_REASSOC_REQUEST      0x2
62 #define ST_REASSOC_RESPONSE     0x3
63 #define ST_PROBE_REQUEST        0x4
64 #define ST_PROBE_RESPONSE       0x5
65 /* RESERVED                     0x6  */
66 /* RESERVED                     0x7  */
67 #define ST_BEACON               0x8
68 #define ST_ATIM                 0x9
69 #define ST_DISASSOC             0xA
70 #define ST_AUTH                 0xB
71 #define ST_DEAUTH               0xC
72 /* RESERVED                     0xD  */
73 /* RESERVED                     0xE  */
74 /* RESERVED                     0xF  */
75
76
77 #define CTRL_BAR        0x8
78 #define CTRL_PS_POLL    0xA
79 #define CTRL_RTS        0xB
80 #define CTRL_CTS        0xC
81 #define CTRL_ACK        0xD
82 #define CTRL_CF_END     0xE
83 #define CTRL_END_ACK    0xF
84
85 #define DATA_DATA               0x0
86 #define DATA_DATA_CF_ACK        0x1
87 #define DATA_DATA_CF_POLL       0x2
88 #define DATA_DATA_CF_ACK_POLL   0x3
89 #define DATA_NODATA             0x4
90 #define DATA_NODATA_CF_ACK      0x5
91 #define DATA_NODATA_CF_POLL     0x6
92 #define DATA_NODATA_CF_ACK_POLL 0x7
93
94 /*
95  * Bits in the frame control field.
96  */
97 #define FC_VERSION(fc)          ((fc) & 0x3)
98 #define FC_TYPE(fc)             (((fc) >> 2) & 0x3)
99 #define FC_SUBTYPE(fc)          (((fc) >> 4) & 0xF)
100 #define FC_TO_DS(fc)            ((fc) & 0x0100)
101 #define FC_FROM_DS(fc)          ((fc) & 0x0200)
102 #define FC_MORE_FLAG(fc)        ((fc) & 0x0400)
103 #define FC_RETRY(fc)            ((fc) & 0x0800)
104 #define FC_POWER_MGMT(fc)       ((fc) & 0x1000)
105 #define FC_MORE_DATA(fc)        ((fc) & 0x2000)
106 #define FC_WEP(fc)              ((fc) & 0x4000)
107 #define FC_ORDER(fc)            ((fc) & 0x8000)
108
109 struct mgmt_header_t {
110         u_int16_t       fc;
111         u_int16_t       duration;
112         u_int8_t        da[6];
113         u_int8_t        sa[6];
114         u_int8_t        bssid[6];
115         u_int16_t       seq_ctrl;
116 };
117
118 #define MGMT_HDRLEN     (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
119                          IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
120                          IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
121
122 #define CAPABILITY_ESS(cap)     ((cap) & 0x0001)
123 #define CAPABILITY_IBSS(cap)    ((cap) & 0x0002)
124 #define CAPABILITY_CFP(cap)     ((cap) & 0x0004)
125 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
126 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
127
128 struct ssid_t {
129         u_int8_t        element_id;
130         u_int8_t        length;
131         u_char          ssid[33];  /* 32 + 1 for null */
132 };
133
134 struct rates_t {
135         u_int8_t        element_id;
136         u_int8_t        length;
137         u_int8_t        rate[8];
138 };
139
140 struct challenge_t {
141         u_int8_t        element_id;
142         u_int8_t        length;
143         u_int8_t        text[254]; /* 1-253 + 1 for null */
144 };
145 struct fh_t {
146         u_int8_t        element_id;
147         u_int8_t        length;
148         u_int16_t       dwell_time;
149         u_int8_t        hop_set;
150         u_int8_t        hop_pattern;
151         u_int8_t        hop_index;
152 };
153
154 struct ds_t {
155         u_int8_t        element_id;
156         u_int8_t        length;
157         u_int8_t        channel;
158 };
159
160 struct cf_t {
161         u_int8_t        element_id;
162         u_int8_t        length;
163         u_int8_t        count;
164         u_int8_t        period;
165         u_int16_t       max_duration;
166         u_int16_t       dur_remaing;
167 };
168
169 struct tim_t {
170         u_int8_t        element_id;
171         u_int8_t        length;
172         u_int8_t        count;
173         u_int8_t        period;
174         u_int8_t        bitmap_control;
175         u_int8_t        bitmap[251];
176 };
177
178 #define E_SSID          0
179 #define E_RATES         1
180 #define E_FH            2
181 #define E_DS            3
182 #define E_CF            4
183 #define E_TIM           5
184 #define E_IBSS          6
185 /* reserved             7 */
186 /* reserved             8 */
187 /* reserved             9 */
188 /* reserved             10 */
189 /* reserved             11 */
190 /* reserved             12 */
191 /* reserved             13 */
192 /* reserved             14 */
193 /* reserved             15 */
194 /* reserved             16 */
195
196 #define E_CHALLENGE     16
197 /* reserved             17 */
198 /* reserved             18 */
199 /* reserved             19 */
200 /* reserved             16 */
201 /* reserved             16 */
202
203
204 struct mgmt_body_t {
205         u_int8_t        timestamp[8];
206         u_int16_t       beacon_interval;
207         u_int16_t       listen_interval;
208         u_int16_t       status_code;
209         u_int16_t       aid;
210         u_char          ap[6];
211         u_int16_t       reason_code;
212         u_int16_t       auth_alg;
213         u_int16_t       auth_trans_seq_num;
214         struct challenge_t  challenge;
215         u_int16_t       capability_info;
216         struct ssid_t   ssid;
217         struct rates_t  rates;
218         struct ds_t     ds;
219         struct cf_t     cf;
220         struct fh_t     fh;
221         struct tim_t    tim;
222 };
223
224 struct ctrl_rts_t {
225         u_int16_t       fc;
226         u_int16_t       duration;
227         u_int8_t        ra[6];
228         u_int8_t        ta[6];
229         u_int8_t        fcs[4];
230 };
231
232 #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
233                          IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
234
235 struct ctrl_cts_t {
236         u_int16_t       fc;
237         u_int16_t       duration;
238         u_int8_t        ra[6];
239         u_int8_t        fcs[4];
240 };
241
242 #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
243
244 struct ctrl_ack_t {
245         u_int16_t       fc;
246         u_int16_t       duration;
247         u_int8_t        ra[6];
248         u_int8_t        fcs[4];
249 };
250
251 #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
252
253 struct ctrl_ps_poll_t {
254         u_int16_t       fc;
255         u_int16_t       aid;
256         u_int8_t        bssid[6];
257         u_int8_t        ta[6];
258         u_int8_t        fcs[4];
259 };
260
261 #define CTRL_PS_POLL_HDRLEN     (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
262                                  IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
263
264 struct ctrl_end_t {
265         u_int16_t       fc;
266         u_int16_t       duration;
267         u_int8_t        ra[6];
268         u_int8_t        bssid[6];
269         u_int8_t        fcs[4];
270 };
271
272 #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
273                          IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
274
275 struct ctrl_end_ack_t {
276         u_int16_t       fc;
277         u_int16_t       duration;
278         u_int8_t        ra[6];
279         u_int8_t        bssid[6];
280         u_int8_t        fcs[4];
281 };
282
283 #define CTRL_END_ACK_HDRLEN     (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
284                                  IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
285
286 struct ctrl_bar_t {
287         u_int16_t       fc;
288         u_int16_t       dur;
289         u_int8_t        ra[6];
290         u_int8_t        ta[6];
291         u_int16_t       ctl;
292         u_int16_t       seq;
293         u_int8_t        fcs[4];
294 };
295
296 #define CTRL_BAR_HDRLEN         (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
297                                  IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
298                                  IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
299
300 #define IV_IV(iv)       ((iv) & 0xFFFFFF)
301 #define IV_PAD(iv)      (((iv) >> 24) & 0x3F)
302 #define IV_KEYID(iv)    (((iv) >> 30) & 0x03)