summaryrefslogtreecommitdiff
path: root/libopie2/opienet/802_11_user.h
Unidiff
Diffstat (limited to 'libopie2/opienet/802_11_user.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/802_11_user.h419
1 files changed, 419 insertions, 0 deletions
diff --git a/libopie2/opienet/802_11_user.h b/libopie2/opienet/802_11_user.h
new file mode 100644
index 0000000..0b3f198
--- a/dev/null
+++ b/libopie2/opienet/802_11_user.h
@@ -0,0 +1,419 @@
1#ifndef IEEE_802_11
2#define IEEE_802_11
3
4enum ieee_802_11_link_status_failure_reason {
5 reserved0, Unspecified=1, Previous_not_valid,
6 Sender_Quits_ESS_or_IBSS,
7 Due_Inactivity, AP_Overload,
8 Class_2_from_NonAuth,
9 Class_3_from_NonAuth,
10 Sender_Quits_BSS,
11 Association_requester_not_authenticated,
12 Reserved10
13};
14
15
16#define IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS \
17 {\
18 {reserved0, 0xff," Reserved reason "},\
19 {Unspecified, 0xff," Unspecified Reason "},\
20 {Previous_not_valid,0xff," Previous Authentication no longer valid "},\
21 {Sender_Quits_ESS_or_IBSS,0xff," Deauthenticated because sending station is leaving (has left) IBSS or ESS "},\
22 {Due_Inactivity,0xff," Disassociated due to inactivity "},\
23 {AP_Overload, 0xff," Disassociated because AP is unable to handle all currently associated stations "},\
24 {Class_2_from_NonAuth,0xff," Class 2 frame received from non-Authenticated station"},\
25 {Class_3_from_NonAuth,0xff," Class 3 frame received from non­Associated station"},\
26 {Sender_Quits_BSS,0xff," Disassociated because sending station is leaving (has left) BSS"},\
27 {Association_requester_not_authenticated,0xff," Station requesting (Re)Association is not Authenticated with responding station"},\
28 {Reserved10, 0xff," Reserved"},\
29 {0,0,NULL}\
30};
31
32
33
34struct ieee_802_11_header {
35 u_int16_tframe_control;// needs to be subtyped
36 u_int16_tduration;
37 u_int8_tmac1[6];
38 u_int8_tmac2[6];
39 u_int8_tmac3[6];
40 u_int16_tSeqCtl;
41 u_int8_tmac4[6];
42 // u_int16_tgapLen;
43 // u_int8_tgap[8];
44};
45
46
47struct ieee_802_3_header {
48
49 u_int16_tstatus;
50 u_int16_tpayload_length;
51 u_int8_tdst_mac[6];
52 u_int8_tsrc_mac[6];
53
54};
55
56#define P80211_OUI_LEN 3
57
58struct ieee_802_11_snap_header {
59
60 u_int8_t dsap; /* always 0xAA */
61 u_int8_t ssap; /* always 0xAA */
62 u_int8_t ctrl; /* always 0x03 */
63 u_int8_t oui[P80211_OUI_LEN]; /* organizational universal id */
64
65} __attribute__ ((packed));
66
67#define P80211_LLC_OUI_LEN 3
68
69struct ieee_802_11_802_1H_header {
70
71 u_int8_t dsap;
72 u_int8_t ssap; /* always 0xAA */
73 u_int8_t ctrl; /* always 0x03 */
74 u_int8_t oui[P80211_OUI_LEN]; /* organizational universal id */
75 u_int16_t unknown1; /* packet type ID fields */
76 u_int16_t unknown2; /* here is something like length in some cases */
77} __attribute__ ((packed));
78
79struct ieee_802_11_802_2_header {
80
81 u_int8_t dsap;
82 u_int8_t ssap; /* always 0xAA */
83 u_int8_t ctrl; /* always 0x03 */
84 u_int8_t oui[P80211_OUI_LEN]; /* organizational universal id */
85 u_int16_t type; /* packet type ID field */
86
87} __attribute__ ((packed));
88
89
90
91// following is incoplete and may be incorrect and need reorganization
92
93 #define ieee_802_11_frame_type_Management0x00
94 #define ieee_802_11_frame_type_Control 0x01
95 #define ieee_802_11_frame_type_Data 0x10
96 #define ieee_802_11_frame_type_Reserved 0x11
97
98 #define ieee_802_11_frame_subtype_Association_Req0x0 // Association Request
99 #define ieee_802_11_frame_subtype_Association_Resp0x1 // Association Response
100 #define ieee_802_11_frame_subtype_Reassociation_Req0x2 // Reassociation Request
101 #define ieee_802_11_frame_subtype_Reassociation_Resp0x3 // Reassociation Response
102 #define ieee_802_11_frame_subtype_Probe_Req 0x4 // Probe Request
103 #define ieee_802_11_frame_subtype_Probe_Resp 0x5 // Probe Response
104 #define ieee_802_11_frame_subtype_Beacon 0x8 // Beacon
105 #define ieee_802_11_frame_subtype_ATIM 0x9 // ATIM
106 #define ieee_802_11_frame_subtype_Disassociation 0xA // Disassociation
107 #define ieee_802_11_frame_subtype_Authentication 0xB // Authentication
108 #define ieee_802_11_frame_subtype_Deauthentication 0xC // Deauthentication
109 #define ieee_802_11_frame_subtype_PS_Poll 0xA // PS-Poll
110 #define ieee_802_11_frame_subtype_RTS 0xB // RTS
111 #define ieee_802_11_frame_subtype_CTS 0xC // CTS
112 #define ieee_802_11_frame_subtype_ACK 0xD // ACK
113 #define ieee_802_11_frame_subtype_CFEnd 0xE // CF-End
114 #define ieee_802_11_frame_subtype_CFEnd_CFAck 0xF // CF-End + CF-Ack
115 #define ieee_802_11_frame_subtype_Data 0x0 // Data
116 #define ieee_802_11_frame_subtype_Data_CFAck 0x1 // Data + CF-Ack
117 #define ieee_802_11_frame_subtype_Data_CF_Poll 0x2 // Data + CF-Poll
118 #define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll 0x3 // Data + CF-Ack + CF-Poll
119 #define ieee_802_11_frame_subtype_NullFunction 0x4 // Null Function (no data)
120 #define ieee_802_11_frame_subtype_CF_Ack 0x5 // CF-Ack (no data)
121 #define ieee_802_11_frame_subtype_CF_Poll 0x6 // CF-Poll (no data)
122 #define ieee_802_11_frame_subtype_CF_AckCF_Poll 0x7 // CF-Ack + CF-Poll (no data)
123
124
125#define ieee_802_11_frame_subtype_strings {\
126 { ieee_802_11_frame_subtype_Association_Req,0xF,"f Association Request"},\
127 { ieee_802_11_frame_subtype_Association_Resp,0xF,"1 Association Response"},\
128 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,"2 Reassociation Request"},\
129 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,"3 Reassociation Response"},\
130 { ieee_802_11_frame_subtype_Probe_Req ,0xF,"4 Probe Request"},\
131 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,"5 Probe Response"},\
132 { ieee_802_11_frame_subtype_Beacon ,0xF,"8 Beacon"},\
133 { ieee_802_11_frame_subtype_ATIM ,0xF,"9 ATIM"},\
134 { ieee_802_11_frame_subtype_Disassociation,0xF,"A Disassociation"},\
135 { ieee_802_11_frame_subtype_Authentication,0xF,"B Authentication"},\
136 { ieee_802_11_frame_subtype_Deauthentication,0xF,"C Deauthentication"},\
137 { ieee_802_11_frame_subtype_PS_Poll ,0xF,"A PS-Poll"},\
138 { ieee_802_11_frame_subtype_RTS ,0xF,"B RTS"},\
139 { ieee_802_11_frame_subtype_CTS ,0xF,"C CTS"},\
140 { ieee_802_11_frame_subtype_ACK ,0xF,"D ACK"},\
141 { ieee_802_11_frame_subtype_CFEnd ,0xF,"E CF-End"},\
142 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,"F CF-End + CF-Ack"},\
143 { ieee_802_11_frame_subtype_Data ,0xF,"0 Data"},\
144 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,"1 Data + CF-Ack"},\
145 { ieee_802_11_frame_subtype_Data_CFPoll ,0xF,"2 Data + CF-Poll"},\
146 { ieee_802_11_frame_subtype_Data_CFAck_CFPoll,0xF,"3 Data + CF-Ack + CF-Poll"},\
147 { ieee_802_11_frame_subtype_Null_Function ,0xF,"4 Null Function (no data)"},\
148 { ieee_802_11_frame_subtype_CFAck , 0xF,"5 CF-Ack (no data)"},\
149 { ieee_802_11_frame_subtype_CFPoll , 0xF,"6 CF-Poll (no data)"},\
150 { ieee_802_11_frame_subtype_CFAck_CFPoll,0xF,"y7 CF-Ack + CF-Poll (no data)"},\
151 { 0,0,NULL}\
152}
153struct ieee_802_11_frame_subtype_class {
154 u_int8_tsubtype;
155 u_int8_tmask;
156 u_int8_tklass;
157 u_int8_ttype;
158};
159#define ieee_802_11_frame_subtype_classes {\
160 { ieee_802_11_frame_subtype_Association_Req,0xF,2,ieee_802_11_frame_type_Management},\
161 { ieee_802_11_frame_subtype_Association_Resp,0xF,2,ieee_802_11_frame_type_Management},\
162 { ieee_802_11_frame_subtype_Reassociation_Req,0xF,2,ieee_802_11_frame_type_Management},\
163 { ieee_802_11_frame_subtype_Reassociation_Resp,0xF,2,ieee_802_11_frame_type_Management},\
164 { ieee_802_11_frame_subtype_Probe_Req ,0xF,1,ieee_802_11_frame_type_Management},\
165 { ieee_802_11_frame_subtype_Probe_Resp ,0xF,1,ieee_802_11_frame_type_Management},\
166 { ieee_802_11_frame_subtype_Beacon ,0xF,1,ieee_802_11_frame_type_Management},\
167 { ieee_802_11_frame_subtype_ATIM ,0xF,1,ieee_802_11_frame_type_Management},\
168 { ieee_802_11_frame_subtype_Disassociation,0xF,2,ieee_802_11_frame_type_Management},\
169 { ieee_802_11_frame_subtype_Authentication,0xF,1,ieee_802_11_frame_type_Management},\
170 { ieee_802_11_frame_subtype_Deauthentication,0xF,3,ieee_802_11_frame_type_Management},\
171 { ieee_802_11_frame_subtype_PS-Poll ,0xF,3,ieee_802_11_frame_type_Control},\
172 { ieee_802_11_frame_subtype_RTS ,0xF,1,ieee_802_11_frame_type_Control},\
173 { ieee_802_11_frame_subtype_CTS ,0xF,1,ieee_802_11_frame_type_Control},\
174 { ieee_802_11_frame_subtype_ACK ,0xF,1,ieee_802_11_frame_type_Control},\
175 { ieee_802_11_frame_subtype_CFEnd ,0xF,1,ieee_802_11_frame_type_Control},\
176 { ieee_802_11_frame_subtype_CFEnd_CFAck ,0xF,1,ieee_802_11_frame_type_Control},\
177 { ieee_802_11_frame_subtype_Data ,0xF,3,ieee_802_11_frame_type_Data},\
178 { ieee_802_11_frame_subtype_Data_CFAck ,0xF,3,ieee_802_11_frame_type_Data},\
179 { ieee_802_11_frame_subtype_Data_CF_Poll 0xF,3,ieee_802_11_frame_type_Data},\
180 { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll,0xF,3,ieee_802_11_frame_type_Data},\
181 { ieee_802_11_frame_subtype_NullFunction 0xF,1,ieee_802_11_frame_type_Data},\
182 { ieee_802_11_frame_subtype_CF_Ack , 0xF,1,ieee_802_11_frame_type_Data},\
183 { ieee_802_11_frame_subtype_CF_Poll , 0xF,1,ieee_802_11_frame_type_Data},\
184 { ieee_802_11_frame_subtype_CF_AckCF_Poll,0xF,1,ieee_802_11_frame_type_Data},\
185 { 0,0,NULL}\
186}
187
188 #define IEEE802_11_FC_LEN2
189
190#define T_MGMT 0x0 /* management */
191#define T_CTRL 0x1 /* control */
192#define T_DATA 0x2 /* data */
193#define T_RESV 0x3 /* reserved */
194
195 #define ST_ASSOC_REQUEST 0x0
196 #define ST_ASSOC_RESPONSE 0x1
197 #define ST_REASSOC_REQUEST 0x2
198 #define ST_REASSOC_RESPONSE 0x3
199 #define ST_PROBE_REQUEST 0x4
200 #define ST_PROBE_RESPONSE 0x5
201 /* RESERVED 0x6 */
202 /* RESERVED 0x7 */
203 #define ST_BEACON 0x8
204 #define ST_ATIM 0x9
205 #define ST_DISASSOC 0xA
206 #define ST_AUTH 0xB
207 #define ST_DEAUTH 0xC
208 /* RESERVED 0xD */
209 /* RESERVED 0xE */
210 /* RESERVED 0xF */
211
212
213 #define CTRL_PS_POLL0xA
214 #define CTRL_RTS0xB
215 #define CTRL_CTS0xC
216 #define CTRL_ACK0xD
217 #define CTRL_CF_END0xE
218 #define CTRL_END_ACK0xF
219
220/*
221 * Bits in the frame control field.
222 */
223 #define FC_VERSION(fc) ((fc) & 0x3)
224 #define FC_TYPE(fc) (((fc) >> 2) & 0x3)
225 #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
226 #define FC_TO_DS(fc) ((fc) & 0x0100)
227 #define FC_FROM_DS(fc) ((fc) & 0x0200)
228 #define FC_MORE_FLAG(fc)((fc) & 0x0400)
229 #define FC_RETRY(fc) ((fc) & 0x0800)
230 #define FC_POWER_MGMT(fc)((fc) & 0x1000)
231 #define FC_MORE_DATA(fc)((fc) & 0x2000)
232 #define FC_WEP(fc) ((fc) & 0x4000)
233 #define FC_ORDER(fc) ((fc) & 0x8000)
234
235
236struct ieee_802_11_mgmt_header {
237 u_int16_t fc;
238 u_int16_t duration;
239 u_int8_t da[6];
240 u_int8_t sa[6];
241 u_int8_t bssid[6];
242 u_int16_t seq_ctrl;
243};
244
245
246struct ieee_802_11_data_header {
247 u_int16_tframe_control;
248 u_int16_tduration;
249 u_int8_tmac1[6];
250 u_int8_tmac2[6];
251 u_int8_tmac3[6];
252 u_int16_tSeqCtl;
253 u_int8_tmac4[6];
254 // u_int16_tgapLen;
255 // u_int8_tgap[8];
256};
257
258 #define CAPABILITY_ESS(cap)((cap) & 0x0001)
259 #define CAPABILITY_IBSS(cap)((cap) & 0x0002)
260 #define CAPABILITY_CFP(cap)((cap) & 0x0004)
261 #define CAPABILITY_CFP_REQ(cap)((cap) & 0x0008)
262 #define CAPABILITY_PRIVACY(cap)((cap) & 0x0010)
263
264struct ssid_t {
265 u_int8_telement_id;
266 u_int8_tlength;
267 u_char ssid[33]; /* 32 + 1 for null */
268};
269
270
271struct rates_t {
272 u_int8_telement_id;
273 u_int8_tlength;
274 u_int8_trate[8];
275};
276
277
278struct challenge_t {
279 u_int8_telement_id;
280 u_int8_tlength;
281 u_int8_ttext[254]; /* 1-253 + 1 for null */
282};
283
284
285struct fh_t {
286 u_int8_telement_id;
287 u_int8_tlength;
288 u_int16_tdwell_time;
289 u_int8_thop_set;
290 u_int8_t hop_pattern;
291 u_int8_thop_index;
292};
293
294
295struct ds_t {
296 u_int8_telement_id;
297 u_int8_tlength;
298 u_int8_tchannel;
299};
300
301
302struct cf_t {
303 u_int8_telement_id;
304 u_int8_tlength;
305 u_int8_tcount;
306 u_int8_tperiod;
307 u_int16_tmax_duration;
308 u_int16_tdur_remaing;
309};
310
311
312struct tim_t {
313 u_int8_telement_id;
314 u_int8_tlength;
315 u_int8_tcount;
316 u_int8_tperiod;
317 u_int8_tbitmap_control;
318 u_int8_tbitmap[251];
319};
320
321 #define E_SSID 0
322 #define E_RATES 1
323 #define E_FH 2
324 #define E_DS 3
325 #define E_CF 4
326 #define E_TIM 5
327 #define E_IBSS 6
328 #define E_CHALLENGE 16
329 #define E_CISCO 133
330
331
332struct ieee_802_11_mgmt_body {
333 u_int8_t timestamp[8];
334 u_int16_t beacon_interval;
335 // u_int16_t listen_interval;
336 // u_int16_t status_code;
337 // u_int16_t aid;
338 // u_char ap[6];
339 // u_int16_treason_code;
340 // u_int16_tauth_alg;
341 // u_int16_tauth_trans_seq_num;
342// struct challenge_t challenge;
343 u_int16_tcapability_info;
344 struct ssid_tssid;
345 struct rates_t rates;
346 struct ds_tds;
347 struct cf_tcf;
348 struct fh_tfh;
349 struct tim_ttim;
350};
351
352
353struct ieee_802_11_data_body {
354//FIXME
355};
356
357struct ctrl_rts_t {
358 u_int16_tfc;
359 u_int16_tduration;
360 u_int8_tra[6];
361 u_int8_tta[6];
362 u_int8_tfcs[4];
363};
364
365 #define CTRL_RTS_LEN(2+2+6+6+4)
366
367struct ctrl_cts_t {
368 u_int16_tfc;
369 u_int16_tduration;
370 u_int8_tra[6];
371 u_int8_tfcs[4];
372};
373
374 #define CTRL_CTS_LEN(2+2+6+4)
375
376struct ctrl_ack_t {
377 u_int16_tfc;
378 u_int16_tduration;
379 u_int8_tra[6];
380 u_int8_tfcs[4];
381};
382
383 #define CTRL_ACK_LEN(2+2+6+4)
384
385struct ctrl_ps_poll_t {
386 u_int16_tfc;
387 u_int16_taid;
388 u_int8_tbssid[6];
389 u_int8_tta[6];
390 u_int8_tfcs[4];
391};
392
393 #define CTRL_PS_POLL_LEN(2+2+6+6+4)
394
395struct ctrl_end_t {
396 u_int16_tfc;
397 u_int16_tduration;
398 u_int8_tra[6];
399 u_int8_tbssid[6];
400 u_int8_tfcs[4];
401};
402
403 #define CTRL_END_LEN(2+2+6+6+4)
404
405struct ctrl_end_ack_t {
406 u_int16_tfc;
407 u_int16_tduration;
408 u_int8_tra[6];
409 u_int8_tbssid[6];
410 u_int8_tfcs[4];
411};
412
413 #define CTRL_END_ACK_LEN(2+2+6+6+4)
414
415 #define IV_IV(iv)((iv) & 0xFFFFFF)
416 #define IV_PAD(iv)(((iv) >> 24) & 0x3F)
417 #define IV_KEYID(iv)(((iv) >> 30) & 0x03)
418
419#endif