3 /* @(#) Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.3 2007/07/22 20:01:16 guy Exp (LBL) */
6 * Fortress Technologies
7 * Charlie Lenahan ( clenahan@fortresstech.com )
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that: (1) source code distributions
11 * retain the above copyright notice and this paragraph in its entirety, (2)
12 * distributions including binary code include the above copyright notice and
13 * this paragraph in its entirety in the documentation or other materials
14 * provided with the distribution, and (3) all advertising materials mentioning
15 * features or use of this software display the following acknowledgement:
16 * ``This product includes software developed by the University of California,
17 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
18 * the University nor the names of its contributors may be used to endorse
19 * or promote products derived from this software without specific prior
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 /* Lengths of 802.11 header components. */
27 #define IEEE802_11_FC_LEN 2
28 #define IEEE802_11_DUR_LEN 2
29 #define IEEE802_11_DA_LEN 6
30 #define IEEE802_11_SA_LEN 6
31 #define IEEE802_11_BSSID_LEN 6
32 #define IEEE802_11_RA_LEN 6
33 #define IEEE802_11_TA_LEN 6
34 #define IEEE802_11_SEQ_LEN 2
35 #define IEEE802_11_IV_LEN 3
36 #define IEEE802_11_KID_LEN 1
38 /* Frame check sequence length. */
39 #define IEEE802_11_FCS_LEN 4
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
47 #define IEEE802_11_AID_LEN 2
48 #define IEEE802_11_STATUS_LEN 2
49 #define IEEE802_11_REASON_LEN 2
51 /* Length of previous AP in reassocation frame */
52 #define IEEE802_11_AP_LEN 6
54 #define T_MGMT 0x0 /* management */
55 #define T_CTRL 0x1 /* control */
56 #define T_DATA 0x2 /* data */
57 #define T_RESV 0x3 /* reserved */
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
69 #define ST_DISASSOC 0xA
77 #define CTRL_PS_POLL 0xA
81 #define CTRL_CF_END 0xE
82 #define CTRL_END_ACK 0xF
85 #define DATA_DATA_CF_ACK 0x1
86 #define DATA_DATA_CF_POLL 0x2
87 #define DATA_DATA_CF_ACK_POLL 0x3
88 #define DATA_NODATA 0x4
89 #define DATA_NODATA_CF_ACK 0x5
90 #define DATA_NODATA_CF_POLL 0x6
91 #define DATA_NODATA_CF_ACK_POLL 0x7
93 #define DATA_QOS_DATA 0x8
94 #define DATA_QOS_DATA_CF_ACK 0x9
95 #define DATA_QOS_DATA_CF_POLL 0xA
96 #define DATA_QOS_DATA_CF_ACK_POLL 0xB
97 #define DATA_QOS_NODATA 0xC
98 #define DATA_QOS_CF_POLL_NODATA 0xE
99 #define DATA_QOS_CF_ACK_POLL_NODATA 0xF
102 * The subtype field of a data frame is, in effect, composed of 4 flag
103 * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
104 * any data), and QoS.
106 #define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
107 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
108 #define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
109 #define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
112 * Bits in the frame control field.
114 #define FC_VERSION(fc) ((fc) & 0x3)
115 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
116 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
117 #define FC_TO_DS(fc) ((fc) & 0x0100)
118 #define FC_FROM_DS(fc) ((fc) & 0x0200)
119 #define FC_MORE_FLAG(fc) ((fc) & 0x0400)
120 #define FC_RETRY(fc) ((fc) & 0x0800)
121 #define FC_POWER_MGMT(fc) ((fc) & 0x1000)
122 #define FC_MORE_DATA(fc) ((fc) & 0x2000)
123 #define FC_WEP(fc) ((fc) & 0x4000)
124 #define FC_ORDER(fc) ((fc) & 0x8000)
126 struct mgmt_header_t
{
135 #define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
136 IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
137 IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
139 #define CAPABILITY_ESS(cap) ((cap) & 0x0001)
140 #define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
141 #define CAPABILITY_CFP(cap) ((cap) & 0x0004)
142 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
143 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
154 u_char ssid
[33]; /* 32 + 1 for null */
166 u_int8_t text
[254]; /* 1-253 + 1 for null */
172 u_int16_t dwell_time
;
174 u_int8_t hop_pattern
;
189 u_int16_t max_duration
;
190 u_int16_t dur_remaing
;
198 u_int8_t bitmap_control
;
199 u_int8_t bitmap
[251];
220 #define E_CHALLENGE 16
229 u_int8_t timestamp
[IEEE802_11_TSTAMP_LEN
];
230 u_int16_t beacon_interval
;
231 u_int16_t listen_interval
;
232 u_int16_t status_code
;
234 u_char ap
[IEEE802_11_AP_LEN
];
235 u_int16_t reason_code
;
237 u_int16_t auth_trans_seq_num
;
238 elem_status_t challenge_status
;
239 struct challenge_t challenge
;
240 u_int16_t capability_info
;
241 elem_status_t ssid_status
;
243 elem_status_t rates_status
;
244 struct rates_t rates
;
245 elem_status_t ds_status
;
247 elem_status_t cf_status
;
249 elem_status_t fh_status
;
251 elem_status_t tim_status
;
263 #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
264 IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
273 #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
282 #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
284 struct ctrl_ps_poll_t
{
292 #define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
293 IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
303 #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
304 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
306 struct ctrl_end_ack_t
{
314 #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
315 IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
317 #define IV_IV(iv) ((iv) & 0xFFFFFF)
318 #define IV_PAD(iv) (((iv) >> 24) & 0x3F)
319 #define IV_KEYID(iv) (((iv) >> 30) & 0x03)