]> The Tcpdump Group git mirrors - tcpdump/blob - ieee802_11.h
whitespace cleanup
[tcpdump] / ieee802_11.h
1 /* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.4 2002-06-11 17:08:38 itojun Exp $ (LBL) */
2 /*
3 * Copyright (c) 2001
4 * Fortress Technologies
5 * Charlie Lenahan ( clenahan@fortresstech.com )
6 *
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.
22 */
23
24 #define IEEE802_11_FC_LEN 2
25
26 #define T_MGMT 0x0 /* management */
27 #define T_CTRL 0x1 /* control */
28 #define T_DATA 0x2 /* data */
29 #define T_RESV 0x3 /* reserved */
30
31 #define ST_ASSOC_REQUEST 0x0
32 #define ST_ASSOC_RESPONSE 0x1
33 #define ST_REASSOC_REQUEST 0x2
34 #define ST_REASSOC_RESPONSE 0x3
35 #define ST_PROBE_REQUEST 0x4
36 #define ST_PROBE_RESPONSE 0x5
37 /* RESERVED 0x6 */
38 /* RESERVED 0x7 */
39 #define ST_BEACON 0x8
40 #define ST_ATIM 0x9
41 #define ST_DISASSOC 0xA
42 #define ST_AUTH 0xB
43 #define ST_DEAUTH 0xC
44 /* RESERVED 0xD */
45 /* RESERVED 0xE */
46 /* RESERVED 0xF */
47
48
49 #define CTRL_PS_POLL 0xA
50 #define CTRL_RTS 0xB
51 #define CTRL_CTS 0xC
52 #define CTRL_ACK 0xD
53 #define CTRL_CF_END 0xE
54 #define CTRL_END_ACK 0xF
55
56 /*
57 * Bits in the frame control field.
58 */
59 #define FC_VERSION(fc) ((fc) & 0x3)
60 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
61 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
62 #define FC_TO_DS(fc) ((fc) & 0x0100)
63 #define FC_FROM_DS(fc) ((fc) & 0x0200)
64 #define FC_MORE_FLAG(fc) ((fc) & 0x0400)
65 #define FC_RETRY(fc) ((fc) & 0x0800)
66 #define FC_POWER_MGMT(fc) ((fc) & 0x1000)
67 #define FC_MORE_DATA(fc) ((fc) & 0x2000)
68 #define FC_WEP(fc) ((fc) & 0x4000)
69 #define FC_ORDER(fc) ((fc) & 0x8000)
70
71 struct mgmt_header_t {
72 u_int16_t fc;
73 u_int16_t duration;
74 u_int8_t da[6];
75 u_int8_t sa[6];
76 u_int8_t bssid[6];
77 u_int16_t seq_ctrl;
78 };
79
80 #define MGMT_HEADER_LEN (2+2+6+6+6+2)
81
82 #define CAPABILITY_ESS(cap) ((cap) & 0x0001)
83 #define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
84 #define CAPABILITY_CFP(cap) ((cap) & 0x0004)
85 #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
86 #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
87
88 struct ssid_t {
89 u_int8_t element_id;
90 u_int8_t length;
91 u_char ssid[33]; /* 32 + 1 for null */
92 } ;
93
94 struct rates_t {
95 u_int8_t element_id;
96 u_int8_t length;
97 u_int8_t rate[8];
98 };
99
100 struct challenge_t {
101 u_int8_t element_id;
102 u_int8_t length;
103 u_int8_t text[254]; /* 1-253 + 1 for null */
104 };
105 struct fh_t {
106 u_int8_t element_id;
107 u_int8_t length;
108 u_int16_t dwell_time;
109 u_int8_t hop_set;
110 u_int8_t hop_pattern;
111 u_int8_t hop_index;
112 };
113
114 struct ds_t {
115 u_int8_t element_id;
116 u_int8_t length;
117 u_int8_t channel;
118 };
119
120 struct cf_t {
121 u_int8_t element_id;
122 u_int8_t length;
123 u_int8_t count;
124 u_int8_t period;
125 u_int16_t max_duration;
126 u_int16_t dur_remaing;
127 };
128
129 struct tim_t {
130 u_int8_t element_id;
131 u_int8_t length;
132 u_int8_t count;
133 u_int8_t period;
134 u_int8_t bitmap_control;
135 u_int8_t bitmap[251];
136 };
137
138 #define E_SSID 0
139 #define E_RATES 1
140 #define E_FH 2
141 #define E_DS 3
142 #define E_CF 4
143 #define E_TIM 5
144 #define E_IBSS 6
145 /* reserved 7 */
146 /* reserved 8 */
147 /* reserved 9 */
148 /* reserved 10 */
149 /* reserved 11 */
150 /* reserved 12 */
151 /* reserved 13 */
152 /* reserved 14 */
153 /* reserved 15 */
154 /* reserved 16 */
155
156 #define E_CHALLENGE 16
157 /* reserved 17 */
158 /* reserved 18 */
159 /* reserved 19 */
160 /* reserved 16 */
161 /* reserved 16 */
162
163
164 struct mgmt_body_t {
165 u_int8_t timestamp[8];
166 u_int16_t beacon_interval;
167 u_int16_t listen_interval;
168 u_int16_t status_code;
169 u_int16_t aid;
170 u_char ap[6];
171 u_int16_t reason_code;
172 u_int16_t auth_alg;
173 u_int16_t auth_trans_seq_num;
174 struct challenge_t challenge;
175 u_int16_t capability_info;
176 struct ssid_t ssid;
177 struct rates_t rates;
178 struct ds_t ds;
179 struct cf_t cf;
180 struct fh_t fh;
181 struct tim_t tim;
182 };
183
184 struct ctrl_rts_t {
185 u_int16_t fc;
186 u_int16_t duration;
187 u_int8_t ra[6];
188 u_int8_t ta[6];
189 u_int8_t fcs[4];
190 };
191
192 #define CTRL_RTS_LEN (2+2+6+6+4)
193
194 struct ctrl_cts_t {
195 u_int16_t fc;
196 u_int16_t duration;
197 u_int8_t ra[6];
198 u_int8_t fcs[4];
199 };
200
201 #define CTRL_CTS_LEN (2+2+6+4)
202
203 struct ctrl_ack_t {
204 u_int16_t fc;
205 u_int16_t duration;
206 u_int8_t ra[6];
207 u_int8_t fcs[4];
208 };
209
210 #define CTRL_ACK_LEN (2+2+6+4)
211
212 struct ctrl_ps_poll_t {
213 u_int16_t fc;
214 u_int16_t aid;
215 u_int8_t bssid[6];
216 u_int8_t ta[6];
217 u_int8_t fcs[4];
218 };
219
220 #define CTRL_PS_POLL_LEN (2+2+6+6+4)
221
222 struct ctrl_end_t {
223 u_int16_t fc;
224 u_int16_t duration;
225 u_int8_t ra[6];
226 u_int8_t bssid[6];
227 u_int8_t fcs[4];
228 };
229
230 #define CTRL_END_LEN (2+2+6+6+4)
231
232 struct ctrl_end_ack_t {
233 u_int16_t fc;
234 u_int16_t duration;
235 u_int8_t ra[6];
236 u_int8_t bssid[6];
237 u_int8_t fcs[4];
238 };
239
240 #define CTRL_END_ACK_LEN (2+2+6+6+4)
241
242 #define IV_IV(iv) ((iv) & 0xFFFFFF)
243 #define IV_PAD(iv) (((iv) >> 24) & 0x3F)
244 #define IV_KEYID(iv) (((iv) >> 30) & 0x03)