1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
#ifndef _IEEE802_11_H
#define _IEEE802_11_H
#define IEEE802_11_DATA_LEN 2304
/* Actually, the standard seems to be inconsistent about what the
maximum frame size really is. Section 6.2.1.1.2 says 2304 octets,
but the figure in Section 7.1.2 says 2312 octects. */
#define IEEE802_11_HLEN 30
#define IEEE802_11_FRAME_LEN (IEEE802_11_DATA_LEN + IEEE802_11_HLEN)
struct ieee802_11_hdr {
u16 frame_ctl;
u16 duration_id;
u8 addr1[ETH_ALEN];
u8 addr2[ETH_ALEN];
u8 addr3[ETH_ALEN];
u16 seq_ctl;
u8 addr4[ETH_ALEN];
} __attribute__ ((packed));
/* defines for information element coding:
1 byte ID, 1 byte length of information field, n bytes information field
(see 7.3.2 in [1]) */
#define IE_ID_SSID 0 /* length 0 - 32 */
#define IE_ID_SUPPORTED_RATES 1
#define IE_ID_DS_PARAM_SET 3
#define IE_ID_CF_PARAM_SET 4
#define IE_ID_TIM 5
#define IE_ID_IBSS_PARAM_SET 6
#define IE_ID_CHALLENGE_TEXT 16
#if defined(__LITTLE_ENDIAN)
/* Frame control field constants */
#define IEEE802_11_FCTL_VERS 0x0002
#define IEEE802_11_FCTL_FTYPE 0x000c
#define IEEE802_11_FCTL_STYPE 0x00f0
#define IEEE802_11_FCTL_TODS 0x0100
#define IEEE802_11_FCTL_FROMDS 0x0200
#define IEEE802_11_FCTL_MOREFRAGS 0x0400
#define IEEE802_11_FCTL_RETRY 0x0800
#define IEEE802_11_FCTL_PM 0x1000
#define IEEE802_11_FCTL_MOREDATA 0x2000
#define IEEE802_11_FCTL_WEP 0x4000
#define IEEE802_11_FCTL_ORDER 0x8000
#define IEEE802_11_FTYPE_MGMT 0x0000
#define IEEE802_11_FTYPE_CTL 0x0004
#define IEEE802_11_FTYPE_DATA 0x0008
/* management */
#define IEEE802_11_STYPE_ASSOC_REQ 0x0000
#define IEEE802_11_STYPE_ASSOC_RESP 0x0010
#define IEEE802_11_STYPE_REASSOC_REQ 0x0020
#define IEEE802_11_STYPE_REASSOC_RESP 0x0030
#define IEEE802_11_STYPE_PROBE_REQ 0x0040
#define IEEE802_11_STYPE_PROBE_RESP 0x0050
#define IEEE802_11_STYPE_BEACON 0x0080
#define IEEE802_11_STYPE_ATIM 0x0090
#define IEEE802_11_STYPE_DISASSOC 0x00A0
#define IEEE802_11_STYPE_AUTH 0x00B0
#define IEEE802_11_STYPE_DEAUTH 0x00C0
/* control */
#define IEEE802_11_STYPE_PSPOLL 0x00A0
#define IEEE802_11_STYPE_RTS 0x00B0
#define IEEE802_11_STYPE_CTS 0x00C0
#define IEEE802_11_STYPE_ACK 0x00D0
#define IEEE802_11_STYPE_CFEND 0x00E0
#define IEEE802_11_STYPE_CFENDACK 0x00F0
/* data */
#define IEEE802_11_STYPE_DATA 0x0000
#define IEEE802_11_STYPE_DATA_CFACK 0x0010
#define IEEE802_11_STYPE_DATA_CFPOLL 0x0020
#define IEEE802_11_STYPE_DATA_CFACKPOLL 0x0030
#define IEEE802_11_STYPE_NULLFUNC 0x0040
#define IEEE802_11_STYPE_CFACK 0x0050
#define IEEE802_11_STYPE_CFPOLL 0x0060
#define IEEE802_11_STYPE_CFACKPOLL 0x0070
#define IEEE802_11_SCTL_FRAG 0x000F
#define IEEE802_11_SCTL_SEQ 0xFFF0
/* capability field in beacon, (re)assocReq */
#define IEEE802_11_CAPA_ESS 0x0001
#define IEEE802_11_CAPA_IBSS 0x0002
#define IEEE802_11_CAPA_CF_POLLABLE 0x0004
#define IEEE802_11_CAPA_POLL_REQ 0x0008
#define IEEE802_11_CAPA_PRIVACY 0x0010
#define IEEE802_11_CAPA_SHORT_PREAMBLE 0x0020
/* auth frame: algorithm type */
#define IEEE802_11_AUTH_ALG_OPEN_SYSTEM 0x0000
#define IEEE802_11_AUTH_ALG_SHARED_SECRET 0x0001
/* disassoc/deauth frame: reason codes (see 802.11, ch. 7.3.1.7, table 18) */
#define IEEE802_11_REASON_UNSPECIFIED 0x0001
#define IEEE802_11_REASON_PREV_AUTH_INVALID 0x0002
#define IEEE802_11_REASON_DEAUTH_LEAVING 0x0003
#define IEEE802_11_REASON_DISASS_INACTIVITY 0x0004
#define IEEE802_11_REASON_DISASS_TOO_MANY_STA 0x0005
#define IEEE802_11_REASON_CL2_FROM_NONAUTH 0x0006
#define IEEE802_11_REASON_CL3_FROM_NONASSOC 0x0007
#define IEEE802_11_REASON_DISASS_LEAVING 0x0008
#define IEEE802_11_REASON_NOT_AUTH 0x0009
/* status in some response frames (802.11, ch. 7.3.1.9, table 19) */
#define IEEE802_11_STATUS_SUCCESS 0x0000
#define IEEE802_11_STATUS_UNSPECIFIED 0x0001
#define IEEE802_11_STATUS_UNSUPP_CAPABILITIES 0x000a
#define IEEE802_11_STATUS_NO_PREV_ASSOC 0x000b
#define IEEE802_11_STATUS_ASSOC_FAILED 0x000c
#define IEEE802_11_STATUS_UNSUPP_AUTH_ALG 0x000d
#define IEEE802_11_STATUS_AUTH_INV_TRANS_SEQ 0x000e
#define IEEE802_11_STATUS_AUTH_CHALLENGE_FAIL 0x000f
#define IEEE802_11_STATUS_AUTH_TIMEOUT 0x0010
#define IEEE802_11_STATUS_ASSOC_TOO_MANY_STA 0x0011
#define IEEE802_11_STATUS_BASIC_RATE_SET 0x0012
#else /* defined(__LITTLE_ENDIAN) */
/* Frame control field constants */
#define IEEE802_11_FCTL_VERS 0x0200
#define IEEE802_11_FCTL_FTYPE 0x0c00
#define IEEE802_11_FCTL_STYPE 0xf000
#define IEEE802_11_FCTL_TODS 0x0001
#define IEEE802_11_FCTL_FROMDS 0x0002
#define IEEE802_11_FCTL_MOREFRAGS 0x0004
#define IEEE802_11_FCTL_RETRY 0x0008
#define IEEE802_11_FCTL_PM 0x0010
#define IEEE802_11_FCTL_MOREDATA 0x0020
#define IEEE802_11_FCTL_WEP 0x0040
#define IEEE802_11_FCTL_ORDER 0x0080
#define IEEE802_11_FTYPE_MGMT 0x0000
#define IEEE802_11_FTYPE_CTL 0x0400
#define IEEE802_11_FTYPE_DATA 0x0800
/* management */
#define IEEE802_11_STYPE_ASSOC_REQ 0x0000
#define IEEE802_11_STYPE_ASSOC_RESP 0x1000
#define IEEE802_11_STYPE_REASSOC_REQ 0x2000
#define IEEE802_11_STYPE_REASSOC_RESP 0x3000
#define IEEE802_11_STYPE_PROBE_REQ 0x4000
#define IEEE802_11_STYPE_PROBE_RESP 0x5000
#define IEEE802_11_STYPE_BEACON 0x8000
#define IEEE802_11_STYPE_ATIM 0x9000
#define IEEE802_11_STYPE_DISASSOC 0xA000
#define IEEE802_11_STYPE_AUTH 0xB000
#define IEEE802_11_STYPE_DEAUTH 0xC000
/* control */
#define IEEE802_11_STYPE_PSPOLL 0xA000
#define IEEE802_11_STYPE_RTS 0xB000
#define IEEE802_11_STYPE_CTS 0xC000
#define IEEE802_11_STYPE_ACK 0xD000
#define IEEE802_11_STYPE_CFEND 0xE000
#define IEEE802_11_STYPE_CFENDACK 0xF000
/* data */
#define IEEE802_11_STYPE_DATA 0x0000
#define IEEE802_11_STYPE_DATA_CFACK 0x1000
#define IEEE802_11_STYPE_DATA_CFPOLL 0x2000
#define IEEE802_11_STYPE_DATA_CFACKPOLL 0x3000
#define IEEE802_11_STYPE_NULLFUNC 0x4000
#define IEEE802_11_STYPE_CFACK 0x5000
#define IEEE802_11_STYPE_CFPOLL 0x6000
#define IEEE802_11_STYPE_CFACKPOLL 0x7000
#define IEEE802_11_SCTL_FRAG 0x0F00
#define IEEE802_11_SCTL_SEQ 0xF0FF
/* capability field in beacon, (re)assocReq */
#define IEEE802_11_CAPA_ESS 0x0100
#define IEEE802_11_CAPA_IBSS 0x0200
#define IEEE802_11_CAPA_CF_POLLABLE 0x0400
#define IEEE802_11_CAPA_POLL_REQ 0x0800
#define IEEE802_11_CAPA_PRIVACY 0x1000
#define IEEE802_11_CAPA_SHORT_PREAMBLE 0x2000
/* auth frame: algorithm type */
#define IEEE802_11_AUTH_ALG_OPEN_SYSTEM 0x0000
#define IEEE802_11_AUTH_ALG_SHARED_SECRET 0x0100
/* disassoc/deauth frame: reason codes (see 802.11, ch. 7.3.1.7, table 18) */
#define IEEE802_11_REASON_UNSPECIFIED 0x0100
#define IEEE802_11_REASON_PREV_AUTH_INVALID 0x0200
#define IEEE802_11_REASON_DEAUTH_LEAVING 0x0300
#define IEEE802_11_REASON_DISASS_INACTIVITY 0x0400
#define IEEE802_11_REASON_DISASS_TOO_MANY_STA 0x0500
#define IEEE802_11_REASON_CL2_FROM_NONAUTH 0x0600
#define IEEE802_11_REASON_CL3_FROM_NONASSOC 0x0700
#define IEEE802_11_REASON_DISASS_LEAVING 0x0800
#define IEEE802_11_REASON_NOT_AUTH 0x0900
/* status in some response frames (802.11, ch. 7.3.1.9, table 19) */
#define IEEE802_11_STATUS_SUCCESS 0x0000
#define IEEE802_11_STATUS_UNSPECIFIED 0x0100
#define IEEE802_11_STATUS_UNSUPP_CAPABILITIES 0x0a00
#define IEEE802_11_STATUS_NO_PREV_ASSOC 0x0b00
#define IEEE802_11_STATUS_ASSOC_FAILED 0x0c00
#define IEEE802_11_STATUS_UNSUPP_AUTH_ALG 0x0d00
#define IEEE802_11_STATUS_AUTH_INV_TRANS_SEQ 0x0e00
#define IEEE802_11_STATUS_AUTH_CHALLENGE_FAIL 0x0f00
#define IEEE802_11_STATUS_AUTH_TIMEOUT 0x1000
#define IEEE802_11_STATUS_ASSOC_TOO_MANY_STA 0x1100
#define IEEE802_11_STATUS_BASIC_RATE_SET 0x1200
#endif
#endif /* _IEEE802_11_H */
|