Commit | Line | Data |
---|---|---|
92b96797 FB |
1 | /* |
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | * | |
92b96797 FB |
19 | * File: 80211hdr.h |
20 | * | |
21 | * Purpose: 802.11 MAC headers related pre-defines and macros. | |
22 | * | |
92b96797 FB |
23 | * Author: Lyndon Chen |
24 | * | |
25 | * Date: Apr 8, 2002 | |
92b96797 FB |
26 | */ |
27 | ||
92b96797 FB |
28 | #ifndef __80211HDR_H__ |
29 | #define __80211HDR_H__ | |
30 | ||
bd2de358 | 31 | /* bit type */ |
92b96797 FB |
32 | #define BIT0 0x00000001 |
33 | #define BIT1 0x00000002 | |
34 | #define BIT2 0x00000004 | |
35 | #define BIT3 0x00000008 | |
36 | #define BIT4 0x00000010 | |
37 | #define BIT5 0x00000020 | |
38 | #define BIT6 0x00000040 | |
39 | #define BIT7 0x00000080 | |
40 | #define BIT8 0x00000100 | |
41 | #define BIT9 0x00000200 | |
42 | #define BIT10 0x00000400 | |
43 | #define BIT11 0x00000800 | |
44 | #define BIT12 0x00001000 | |
45 | #define BIT13 0x00002000 | |
46 | #define BIT14 0x00004000 | |
47 | #define BIT15 0x00008000 | |
48 | #define BIT16 0x00010000 | |
49 | #define BIT17 0x00020000 | |
50 | #define BIT18 0x00040000 | |
51 | #define BIT19 0x00080000 | |
52 | #define BIT20 0x00100000 | |
53 | #define BIT21 0x00200000 | |
54 | #define BIT22 0x00400000 | |
55 | #define BIT23 0x00800000 | |
56 | #define BIT24 0x01000000 | |
57 | #define BIT25 0x02000000 | |
58 | #define BIT26 0x04000000 | |
59 | #define BIT27 0x08000000 | |
60 | #define BIT28 0x10000000 | |
61 | #define BIT29 0x20000000 | |
62 | #define BIT30 0x40000000 | |
63 | #define BIT31 0x80000000 | |
64 | ||
bd2de358 | 65 | /* 802.11 frame related, defined as 802.11 spec */ |
92b96797 FB |
66 | #define WLAN_ADDR_LEN 6 |
67 | #define WLAN_CRC_LEN 4 | |
68 | #define WLAN_CRC32_LEN 4 | |
69 | #define WLAN_FCS_LEN 4 | |
70 | #define WLAN_BSSID_LEN 6 | |
71 | #define WLAN_BSS_TS_LEN 8 | |
72 | #define WLAN_HDR_ADDR2_LEN 16 | |
73 | #define WLAN_HDR_ADDR3_LEN 24 | |
74 | #define WLAN_HDR_ADDR4_LEN 30 | |
75 | #define WLAN_IEHDR_LEN 2 | |
76 | #define WLAN_SSID_MAXLEN 32 | |
92b96797 FB |
77 | #define WLAN_RATES_MAXLEN 16 |
78 | #define WLAN_RATES_MAXLEN_11B 4 | |
79 | #define WLAN_RSN_MAXLEN 32 | |
80 | #define WLAN_DATA_MAXLEN 2312 | |
bd2de358 AM |
81 | #define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN \ |
82 | + WLAN_DATA_MAXLEN \ | |
83 | + WLAN_CRC_LEN) | |
92b96797 FB |
84 | |
85 | #define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN | |
86 | #define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0) | |
87 | #define WLAN_NULLDATA_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0) | |
88 | #define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2) | |
89 | #define WLAN_ASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN | |
90 | #define WLAN_ASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN | |
91 | #define WLAN_REASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN | |
92 | #define WLAN_REASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN | |
93 | #define WLAN_PROBEREQ_FR_MAXLEN WLAN_A3FR_MAXLEN | |
94 | #define WLAN_PROBERESP_FR_MAXLEN WLAN_A3FR_MAXLEN | |
95 | #define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN | |
96 | #define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2) | |
97 | ||
92b96797 FB |
98 | #define WLAN_WEP_NKEYS 4 |
99 | #define WLAN_WEP40_KEYLEN 5 | |
100 | #define WLAN_WEP104_KEYLEN 13 | |
101 | #define WLAN_WEP232_KEYLEN 29 | |
92b96797 FB |
102 | #define WLAN_WEPMAX_KEYLEN 32 |
103 | #define WLAN_CHALLENGE_IE_MAXLEN 255 | |
104 | #define WLAN_CHALLENGE_IE_LEN 130 | |
105 | #define WLAN_CHALLENGE_LEN 128 | |
106 | #define WLAN_WEP_IV_LEN 4 | |
107 | #define WLAN_WEP_ICV_LEN 4 | |
108 | #define WLAN_FRAGS_MAX 16 | |
109 | ||
bd2de358 | 110 | /* Frame Type */ |
92b96797 FB |
111 | #define WLAN_TYPE_MGR 0x00 |
112 | #define WLAN_TYPE_CTL 0x01 | |
113 | #define WLAN_TYPE_DATA 0x02 | |
114 | ||
115 | #define WLAN_FTYPE_MGMT 0x00 | |
116 | #define WLAN_FTYPE_CTL 0x01 | |
117 | #define WLAN_FTYPE_DATA 0x02 | |
118 | ||
bd2de358 | 119 | /* Frame Subtypes */ |
92b96797 FB |
120 | #define WLAN_FSTYPE_ASSOCREQ 0x00 |
121 | #define WLAN_FSTYPE_ASSOCRESP 0x01 | |
122 | #define WLAN_FSTYPE_REASSOCREQ 0x02 | |
123 | #define WLAN_FSTYPE_REASSOCRESP 0x03 | |
124 | #define WLAN_FSTYPE_PROBEREQ 0x04 | |
125 | #define WLAN_FSTYPE_PROBERESP 0x05 | |
126 | #define WLAN_FSTYPE_BEACON 0x08 | |
127 | #define WLAN_FSTYPE_ATIM 0x09 | |
128 | #define WLAN_FSTYPE_DISASSOC 0x0a | |
129 | #define WLAN_FSTYPE_AUTHEN 0x0b | |
130 | #define WLAN_FSTYPE_DEAUTHEN 0x0c | |
131 | #define WLAN_FSTYPE_ACTION 0x0d | |
132 | ||
bd2de358 | 133 | /* Control */ |
92b96797 FB |
134 | #define WLAN_FSTYPE_PSPOLL 0x0a |
135 | #define WLAN_FSTYPE_RTS 0x0b | |
136 | #define WLAN_FSTYPE_CTS 0x0c | |
137 | #define WLAN_FSTYPE_ACK 0x0d | |
138 | #define WLAN_FSTYPE_CFEND 0x0e | |
139 | #define WLAN_FSTYPE_CFENDCFACK 0x0f | |
140 | ||
bd2de358 | 141 | /* Data */ |
92b96797 FB |
142 | #define WLAN_FSTYPE_DATAONLY 0x00 |
143 | #define WLAN_FSTYPE_DATA_CFACK 0x01 | |
144 | #define WLAN_FSTYPE_DATA_CFPOLL 0x02 | |
145 | #define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03 | |
146 | #define WLAN_FSTYPE_NULL 0x04 | |
147 | #define WLAN_FSTYPE_CFACK 0x05 | |
148 | #define WLAN_FSTYPE_CFPOLL 0x06 | |
149 | #define WLAN_FSTYPE_CFACK_CFPOLL 0x07 | |
150 | ||
92b96797 FB |
151 | #ifdef __BIG_ENDIAN |
152 | ||
bd2de358 | 153 | /* GET & SET Frame Control bit */ |
74f161f6 | 154 | #define WLAN_GET_FC_PRVER(n) (((u16)(n) >> 8) & (BIT0 | BIT1)) |
3eaca0d2 AM |
155 | #define WLAN_GET_FC_FTYPE(n) ((((u16)(n) >> 8) & (BIT2 | BIT3)) >> 2) |
156 | #define WLAN_GET_FC_FSTYPE(n) ((((u16)(n) >> 8) \ | |
bd2de358 | 157 | & (BIT4|BIT5|BIT6|BIT7)) >> 4) |
3eaca0d2 AM |
158 | #define WLAN_GET_FC_TODS(n) ((((u16)(n) << 8) & (BIT8)) >> 8) |
159 | #define WLAN_GET_FC_FROMDS(n) ((((u16)(n) << 8) & (BIT9)) >> 9) | |
160 | #define WLAN_GET_FC_MOREFRAG(n) ((((u16)(n) << 8) & (BIT10)) >> 10) | |
161 | #define WLAN_GET_FC_RETRY(n) ((((u16)(n) << 8) & (BIT11)) >> 11) | |
162 | #define WLAN_GET_FC_PWRMGT(n) ((((u16)(n) << 8) & (BIT12)) >> 12) | |
163 | #define WLAN_GET_FC_MOREDATA(n) ((((u16)(n) << 8) & (BIT13)) >> 13) | |
164 | #define WLAN_GET_FC_ISWEP(n) ((((u16)(n) << 8) & (BIT14)) >> 14) | |
165 | #define WLAN_GET_FC_ORDER(n) ((((u16)(n) << 8) & (BIT15)) >> 15) | |
92b96797 | 166 | |
bd2de358 | 167 | /* Sequence Field bit */ |
3eaca0d2 AM |
168 | #define WLAN_GET_SEQ_FRGNUM(n) (((u16)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3)) |
169 | #define WLAN_GET_SEQ_SEQNUM(n) ((((u16)(n) >> 8) \ | |
bd2de358 | 170 | & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) |
92b96797 | 171 | |
bd2de358 | 172 | /* Capability Field bit */ |
92b96797 FB |
173 | #define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0) |
174 | #define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1) | |
175 | #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2) | |
176 | #define WLAN_GET_CAP_INFO_CFPOLLREQ(n) ((((n) >> 8) & BIT3) >> 3) | |
177 | #define WLAN_GET_CAP_INFO_PRIVACY(n) ((((n) >> 8) & BIT4) >> 4) | |
178 | #define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5) | |
179 | #define WLAN_GET_CAP_INFO_PBCC(n) ((((n) >> 8) & BIT6) >> 6) | |
180 | #define WLAN_GET_CAP_INFO_AGILITY(n) ((((n) >> 8) & BIT7) >> 7) | |
181 | #define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) ((((n)) & BIT8) >> 10) | |
182 | #define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n)) & BIT10) >> 10) | |
183 | #define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13) | |
184 | #define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14) | |
185 | ||
92b96797 FB |
186 | #else |
187 | ||
bd2de358 | 188 | /* GET & SET Frame Control bit */ |
3eaca0d2 AM |
189 | #define WLAN_GET_FC_PRVER(n) (((u16)(n)) & (BIT0 | BIT1)) |
190 | #define WLAN_GET_FC_FTYPE(n) ((((u16)(n)) & (BIT2 | BIT3)) >> 2) | |
191 | #define WLAN_GET_FC_FSTYPE(n) ((((u16)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4) | |
192 | #define WLAN_GET_FC_TODS(n) ((((u16)(n)) & (BIT8)) >> 8) | |
193 | #define WLAN_GET_FC_FROMDS(n) ((((u16)(n)) & (BIT9)) >> 9) | |
194 | #define WLAN_GET_FC_MOREFRAG(n) ((((u16)(n)) & (BIT10)) >> 10) | |
195 | #define WLAN_GET_FC_RETRY(n) ((((u16)(n)) & (BIT11)) >> 11) | |
196 | #define WLAN_GET_FC_PWRMGT(n) ((((u16)(n)) & (BIT12)) >> 12) | |
197 | #define WLAN_GET_FC_MOREDATA(n) ((((u16)(n)) & (BIT13)) >> 13) | |
198 | #define WLAN_GET_FC_ISWEP(n) ((((u16)(n)) & (BIT14)) >> 14) | |
199 | #define WLAN_GET_FC_ORDER(n) ((((u16)(n)) & (BIT15)) >> 15) | |
92b96797 | 200 | |
bd2de358 | 201 | /* Sequence Field bit */ |
3eaca0d2 AM |
202 | #define WLAN_GET_SEQ_FRGNUM(n) (((u16)(n)) & (BIT0|BIT1|BIT2|BIT3)) |
203 | #define WLAN_GET_SEQ_SEQNUM(n) ((((u16)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) | |
92b96797 | 204 | |
bd2de358 | 205 | /* Capability Field bit */ |
92b96797 FB |
206 | #define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0) |
207 | #define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1) | |
208 | #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2) | |
209 | #define WLAN_GET_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3) | |
210 | #define WLAN_GET_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4) | |
211 | #define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5) | |
212 | #define WLAN_GET_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6) | |
213 | #define WLAN_GET_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7) | |
214 | #define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) (((n) & BIT8) >> 10) | |
215 | #define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10) | |
216 | #define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13) | |
217 | #define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14) | |
218 | ||
bd2de358 | 219 | #endif /* #ifdef __BIG_ENDIAN */ |
92b96797 FB |
220 | |
221 | #define WLAN_SET_CAP_INFO_ESS(n) (n) | |
222 | #define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1) | |
223 | #define WLAN_SET_CAP_INFO_CFPOLLABLE(n) ((n) << 2) | |
224 | #define WLAN_SET_CAP_INFO_CFPOLLREQ(n) ((n) << 3) | |
225 | #define WLAN_SET_CAP_INFO_PRIVACY(n) ((n) << 4) | |
226 | #define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5) | |
227 | #define WLAN_SET_CAP_INFO_SPECTRUMMNG(n) ((n) << 8) | |
228 | #define WLAN_SET_CAP_INFO_PBCC(n) ((n) << 6) | |
229 | #define WLAN_SET_CAP_INFO_AGILITY(n) ((n) << 7) | |
230 | #define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10) | |
231 | #define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13) | |
232 | #define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14) | |
233 | ||
3eaca0d2 AM |
234 | #define WLAN_SET_FC_PRVER(n) ((u16)(n)) |
235 | #define WLAN_SET_FC_FTYPE(n) (((u16)(n)) << 2) | |
236 | #define WLAN_SET_FC_FSTYPE(n) (((u16)(n)) << 4) | |
237 | #define WLAN_SET_FC_TODS(n) (((u16)(n)) << 8) | |
238 | #define WLAN_SET_FC_FROMDS(n) (((u16)(n)) << 9) | |
239 | #define WLAN_SET_FC_MOREFRAG(n) (((u16)(n)) << 10) | |
240 | #define WLAN_SET_FC_RETRY(n) (((u16)(n)) << 11) | |
241 | #define WLAN_SET_FC_PWRMGT(n) (((u16)(n)) << 12) | |
242 | #define WLAN_SET_FC_MOREDATA(n) (((u16)(n)) << 13) | |
243 | #define WLAN_SET_FC_ISWEP(n) (((u16)(n)) << 14) | |
244 | #define WLAN_SET_FC_ORDER(n) (((u16)(n)) << 15) | |
245 | ||
246 | #define WLAN_SET_SEQ_FRGNUM(n) ((u16)(n)) | |
247 | #define WLAN_SET_SEQ_SEQNUM(n) (((u16)(n)) << 4) | |
92b96797 | 248 | |
bd2de358 | 249 | /* ERP Field bit */ |
92b96797 FB |
250 | |
251 | #define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0) | |
252 | #define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1) | |
253 | #define WLAN_GET_ERP_BARKER_MODE(n) (((n) & BIT2) >> 2) | |
254 | ||
255 | #define WLAN_SET_ERP_NONERP_PRESENT(n) (n) | |
256 | #define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1) | |
257 | #define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2) | |
258 | ||
bd2de358 | 259 | /* Support & Basic Rates field */ |
92b96797 FB |
260 | #define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7) |
261 | #define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7) | |
262 | ||
bd2de358 | 263 | /* TIM field */ |
92b96797 FB |
264 | #define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0) |
265 | #define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1) | |
266 | ||
bd2de358 | 267 | /* 3-Addr & 4-Addr */ |
b902fbfe AM |
268 | #define WLAN_HDR_A3_DATA_PTR(p) (((u8 *)(p)) + WLAN_HDR_ADDR3_LEN) |
269 | #define WLAN_HDR_A4_DATA_PTR(p) (((u8 *)(p)) + WLAN_HDR_ADDR4_LEN) | |
92b96797 | 270 | |
bd2de358 | 271 | /* IEEE ADDR */ |
92b96797 FB |
272 | #define IEEE_ADDR_UNIVERSAL 0x02 |
273 | #define IEEE_ADDR_GROUP 0x01 | |
274 | ||
275 | typedef struct { | |
b902fbfe | 276 | u8 abyAddr[6]; |
92b96797 FB |
277 | } IEEE_ADDR, *PIEEE_ADDR; |
278 | ||
bd2de358 | 279 | /* 802.11 Header Format */ |
92b96797 FB |
280 | |
281 | typedef struct tagWLAN_80211HDR_A2 { | |
282 | ||
3eaca0d2 AM |
283 | u16 wFrameCtl; |
284 | u16 wDurationID; | |
b902fbfe AM |
285 | u8 abyAddr1[WLAN_ADDR_LEN]; |
286 | u8 abyAddr2[WLAN_ADDR_LEN]; | |
92b96797 | 287 | |
bd2de358 | 288 | } __attribute__ ((__packed__)) |
92b96797 FB |
289 | WLAN_80211HDR_A2, *PWLAN_80211HDR_A2; |
290 | ||
291 | typedef struct tagWLAN_80211HDR_A3 { | |
292 | ||
3eaca0d2 AM |
293 | u16 wFrameCtl; |
294 | u16 wDurationID; | |
b902fbfe AM |
295 | u8 abyAddr1[WLAN_ADDR_LEN]; |
296 | u8 abyAddr2[WLAN_ADDR_LEN]; | |
297 | u8 abyAddr3[WLAN_ADDR_LEN]; | |
3eaca0d2 | 298 | u16 wSeqCtl; |
92b96797 | 299 | |
bd2de358 | 300 | } __attribute__ ((__packed__)) |
92b96797 FB |
301 | WLAN_80211HDR_A3, *PWLAN_80211HDR_A3; |
302 | ||
303 | typedef struct tagWLAN_80211HDR_A4 { | |
304 | ||
3eaca0d2 AM |
305 | u16 wFrameCtl; |
306 | u16 wDurationID; | |
b902fbfe AM |
307 | u8 abyAddr1[WLAN_ADDR_LEN]; |
308 | u8 abyAddr2[WLAN_ADDR_LEN]; | |
309 | u8 abyAddr3[WLAN_ADDR_LEN]; | |
3eaca0d2 | 310 | u16 wSeqCtl; |
b902fbfe | 311 | u8 abyAddr4[WLAN_ADDR_LEN]; |
92b96797 | 312 | |
bd2de358 | 313 | } __attribute__ ((__packed__)) |
92b96797 FB |
314 | WLAN_80211HDR_A4, *PWLAN_80211HDR_A4; |
315 | ||
92b96797 FB |
316 | typedef union tagUWLAN_80211HDR { |
317 | ||
318 | WLAN_80211HDR_A2 sA2; | |
319 | WLAN_80211HDR_A3 sA3; | |
320 | WLAN_80211HDR_A4 sA4; | |
321 | ||
322 | } UWLAN_80211HDR, *PUWLAN_80211HDR; | |
323 | ||
bd2de358 | 324 | #endif /* __80211HDR_H__ */ |