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