Staging: Add pristine upstream vt6656 driver sources to drivers/staging/vt6656.
[firewire-audio.git] / drivers / staging / vt6656 / 80211hdr.h
blob84cb1d020cb7457a33718e6f4fc88cfd832e8e57
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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.
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.
20 * File: 80211hdr.h
22 * Purpose: 802.11 MAC headers related pre-defines and macros.
25 * Author: Lyndon Chen
27 * Date: Apr 8, 2002
33 #ifndef __80211HDR_H__
34 #define __80211HDR_H__
37 #if !defined(__TTYPE_H__)
38 #include "ttype.h"
39 #endif
41 /*--------------------- Export Definitions -------------------------*/
42 // bit type
43 #define BIT0 0x00000001
44 #define BIT1 0x00000002
45 #define BIT2 0x00000004
46 #define BIT3 0x00000008
47 #define BIT4 0x00000010
48 #define BIT5 0x00000020
49 #define BIT6 0x00000040
50 #define BIT7 0x00000080
51 #define BIT8 0x00000100
52 #define BIT9 0x00000200
53 #define BIT10 0x00000400
54 #define BIT11 0x00000800
55 #define BIT12 0x00001000
56 #define BIT13 0x00002000
57 #define BIT14 0x00004000
58 #define BIT15 0x00008000
59 #define BIT16 0x00010000
60 #define BIT17 0x00020000
61 #define BIT18 0x00040000
62 #define BIT19 0x00080000
63 #define BIT20 0x00100000
64 #define BIT21 0x00200000
65 #define BIT22 0x00400000
66 #define BIT23 0x00800000
67 #define BIT24 0x01000000
68 #define BIT25 0x02000000
69 #define BIT26 0x04000000
70 #define BIT27 0x08000000
71 #define BIT28 0x10000000
72 #define BIT29 0x20000000
73 #define BIT30 0x40000000
74 #define BIT31 0x80000000
76 // 802.11 frame related, defined as 802.11 spec
77 #define WLAN_ADDR_LEN 6
78 #define WLAN_CRC_LEN 4
79 #define WLAN_CRC32_LEN 4
80 #define WLAN_FCS_LEN 4
81 #define WLAN_BSSID_LEN 6
82 #define WLAN_BSS_TS_LEN 8
83 #define WLAN_HDR_ADDR2_LEN 16
84 #define WLAN_HDR_ADDR3_LEN 24
85 #define WLAN_HDR_ADDR4_LEN 30
86 #define WLAN_IEHDR_LEN 2
87 #define WLAN_SSID_MAXLEN 32
88 //#define WLAN_RATES_MAXLEN 255
89 #define WLAN_RATES_MAXLEN 16
90 #define WLAN_RATES_MAXLEN_11B 4
91 #define WLAN_RSN_MAXLEN 32
92 #define WLAN_DATA_MAXLEN 2312
93 #define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
96 #define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN
97 #define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
98 #define WLAN_NULLDATA_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0)
99 #define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
100 #define WLAN_ASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
101 #define WLAN_ASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
102 #define WLAN_REASSOCREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
103 #define WLAN_REASSOCRESP_FR_MAXLEN WLAN_A3FR_MAXLEN
104 #define WLAN_PROBEREQ_FR_MAXLEN WLAN_A3FR_MAXLEN
105 #define WLAN_PROBERESP_FR_MAXLEN WLAN_A3FR_MAXLEN
106 #define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN
107 #define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2)
110 #define WLAN_WEP_NKEYS 4
111 #define WLAN_WEP40_KEYLEN 5
112 #define WLAN_WEP104_KEYLEN 13
113 #define WLAN_WEP232_KEYLEN 29
114 //#define WLAN_WEPMAX_KEYLEN 29
115 #define WLAN_WEPMAX_KEYLEN 32
116 #define WLAN_CHALLENGE_IE_MAXLEN 255
117 #define WLAN_CHALLENGE_IE_LEN 130
118 #define WLAN_CHALLENGE_LEN 128
119 #define WLAN_WEP_IV_LEN 4
120 #define WLAN_WEP_ICV_LEN 4
121 #define WLAN_FRAGS_MAX 16
123 // Frame Type
124 #define WLAN_TYPE_MGR 0x00
125 #define WLAN_TYPE_CTL 0x01
126 #define WLAN_TYPE_DATA 0x02
128 #define WLAN_FTYPE_MGMT 0x00
129 #define WLAN_FTYPE_CTL 0x01
130 #define WLAN_FTYPE_DATA 0x02
133 // Frame Subtypes
134 #define WLAN_FSTYPE_ASSOCREQ 0x00
135 #define WLAN_FSTYPE_ASSOCRESP 0x01
136 #define WLAN_FSTYPE_REASSOCREQ 0x02
137 #define WLAN_FSTYPE_REASSOCRESP 0x03
138 #define WLAN_FSTYPE_PROBEREQ 0x04
139 #define WLAN_FSTYPE_PROBERESP 0x05
140 #define WLAN_FSTYPE_BEACON 0x08
141 #define WLAN_FSTYPE_ATIM 0x09
142 #define WLAN_FSTYPE_DISASSOC 0x0a
143 #define WLAN_FSTYPE_AUTHEN 0x0b
144 #define WLAN_FSTYPE_DEAUTHEN 0x0c
145 #define WLAN_FSTYPE_ACTION 0x0d
147 // Control
148 #define WLAN_FSTYPE_PSPOLL 0x0a
149 #define WLAN_FSTYPE_RTS 0x0b
150 #define WLAN_FSTYPE_CTS 0x0c
151 #define WLAN_FSTYPE_ACK 0x0d
152 #define WLAN_FSTYPE_CFEND 0x0e
153 #define WLAN_FSTYPE_CFENDCFACK 0x0f
155 // Data
156 #define WLAN_FSTYPE_DATAONLY 0x00
157 #define WLAN_FSTYPE_DATA_CFACK 0x01
158 #define WLAN_FSTYPE_DATA_CFPOLL 0x02
159 #define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
160 #define WLAN_FSTYPE_NULL 0x04
161 #define WLAN_FSTYPE_CFACK 0x05
162 #define WLAN_FSTYPE_CFPOLL 0x06
163 #define WLAN_FSTYPE_CFACK_CFPOLL 0x07
166 #ifdef __BIG_ENDIAN
168 // GET & SET Frame Control bit
169 #define WLAN_GET_FC_PRVER(n) ((((WORD)(n) >> 8) & (BIT0 | BIT1))
170 #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n) >> 8) & (BIT2 | BIT3)) >> 2)
171 #define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
172 #define WLAN_GET_FC_TODS(n) ((((WORD)(n) << 8) & (BIT8)) >> 8)
173 #define WLAN_GET_FC_FROMDS(n) ((((WORD)(n) << 8) & (BIT9)) >> 9)
174 #define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n) << 8) & (BIT10)) >> 10)
175 #define WLAN_GET_FC_RETRY(n) ((((WORD)(n) << 8) & (BIT11)) >> 11)
176 #define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n) << 8) & (BIT12)) >> 12)
177 #define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n) << 8) & (BIT13)) >> 13)
178 #define WLAN_GET_FC_ISWEP(n) ((((WORD)(n) << 8) & (BIT14)) >> 14)
179 #define WLAN_GET_FC_ORDER(n) ((((WORD)(n) << 8) & (BIT15)) >> 15)
181 // Sequence Field bit
182 #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3))
183 #define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
186 // Capability Field bit
187 #define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0)
188 #define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1)
189 #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2)
190 #define WLAN_GET_CAP_INFO_CFPOLLREQ(n) ((((n) >> 8) & BIT3) >> 3)
191 #define WLAN_GET_CAP_INFO_PRIVACY(n) ((((n) >> 8) & BIT4) >> 4)
192 #define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5)
193 #define WLAN_GET_CAP_INFO_PBCC(n) ((((n) >> 8) & BIT6) >> 6)
194 #define WLAN_GET_CAP_INFO_AGILITY(n) ((((n) >> 8) & BIT7) >> 7)
195 #define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) ((((n)) & BIT8) >> 10)
196 #define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n)) & BIT10) >> 10)
197 #define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13)
198 #define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14)
201 #else
203 // GET & SET Frame Control bit
204 #define WLAN_GET_FC_PRVER(n) (((WORD)(n)) & (BIT0 | BIT1))
205 #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n)) & (BIT2 | BIT3)) >> 2)
206 #define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
207 #define WLAN_GET_FC_TODS(n) ((((WORD)(n)) & (BIT8)) >> 8)
208 #define WLAN_GET_FC_FROMDS(n) ((((WORD)(n)) & (BIT9)) >> 9)
209 #define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n)) & (BIT10)) >> 10)
210 #define WLAN_GET_FC_RETRY(n) ((((WORD)(n)) & (BIT11)) >> 11)
211 #define WLAN_GET_FC_PWRMGT(n) ((((WORD)(n)) & (BIT12)) >> 12)
212 #define WLAN_GET_FC_MOREDATA(n) ((((WORD)(n)) & (BIT13)) >> 13)
213 #define WLAN_GET_FC_ISWEP(n) ((((WORD)(n)) & (BIT14)) >> 14)
214 #define WLAN_GET_FC_ORDER(n) ((((WORD)(n)) & (BIT15)) >> 15)
217 // Sequence Field bit
218 #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n)) & (BIT0|BIT1|BIT2|BIT3))
219 #define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
222 // Capability Field bit
223 #define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0)
224 #define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1)
225 #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2)
226 #define WLAN_GET_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3)
227 #define WLAN_GET_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4)
228 #define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5)
229 #define WLAN_GET_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6)
230 #define WLAN_GET_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7)
231 #define WLAN_GET_CAP_INFO_SPECTRUMMNG(n) (((n) & BIT8) >> 10)
232 #define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10)
233 #define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13)
234 #define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14)
237 #endif //#ifdef __BIG_ENDIAN
240 #define WLAN_SET_CAP_INFO_ESS(n) (n)
241 #define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1)
242 #define WLAN_SET_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
243 #define WLAN_SET_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
244 #define WLAN_SET_CAP_INFO_PRIVACY(n) ((n) << 4)
245 #define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5)
246 #define WLAN_SET_CAP_INFO_SPECTRUMMNG(n) ((n) << 8)
247 #define WLAN_SET_CAP_INFO_PBCC(n) ((n) << 6)
248 #define WLAN_SET_CAP_INFO_AGILITY(n) ((n) << 7)
249 #define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10)
250 #define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13)
251 #define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14)
254 #define WLAN_SET_FC_PRVER(n) ((WORD)(n))
255 #define WLAN_SET_FC_FTYPE(n) (((WORD)(n)) << 2)
256 #define WLAN_SET_FC_FSTYPE(n) (((WORD)(n)) << 4)
257 #define WLAN_SET_FC_TODS(n) (((WORD)(n)) << 8)
258 #define WLAN_SET_FC_FROMDS(n) (((WORD)(n)) << 9)
259 #define WLAN_SET_FC_MOREFRAG(n) (((WORD)(n)) << 10)
260 #define WLAN_SET_FC_RETRY(n) (((WORD)(n)) << 11)
261 #define WLAN_SET_FC_PWRMGT(n) (((WORD)(n)) << 12)
262 #define WLAN_SET_FC_MOREDATA(n) (((WORD)(n)) << 13)
263 #define WLAN_SET_FC_ISWEP(n) (((WORD)(n)) << 14)
264 #define WLAN_SET_FC_ORDER(n) (((WORD)(n)) << 15)
266 #define WLAN_SET_SEQ_FRGNUM(n) ((WORD)(n))
267 #define WLAN_SET_SEQ_SEQNUM(n) (((WORD)(n)) << 4)
269 // ERP Field bit
271 #define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0)
272 #define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1)
273 #define WLAN_GET_ERP_BARKER_MODE(n) (((n) & BIT2) >> 2)
275 #define WLAN_SET_ERP_NONERP_PRESENT(n) (n)
276 #define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1)
277 #define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2)
281 // Support & Basic Rates field
282 #define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7)
283 #define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7)
285 // TIM field
286 #define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0)
287 #define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1)
289 // 3-Addr & 4-Addr
290 #define WLAN_HDR_A3_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR3_LEN)
291 #define WLAN_HDR_A4_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR4_LEN)
293 // IEEE ADDR
294 #define IEEE_ADDR_UNIVERSAL 0x02
295 #define IEEE_ADDR_GROUP 0x01
297 typedef struct {
298 BYTE abyAddr[6];
299 } IEEE_ADDR, *PIEEE_ADDR;
301 // 802.11 Header Format
303 typedef struct tagWLAN_80211HDR_A2 {
305 WORD wFrameCtl;
306 WORD wDurationID;
307 BYTE abyAddr1[WLAN_ADDR_LEN];
308 BYTE abyAddr2[WLAN_ADDR_LEN];
310 }__attribute__ ((__packed__))
311 WLAN_80211HDR_A2, *PWLAN_80211HDR_A2;
313 typedef struct tagWLAN_80211HDR_A3 {
315 WORD wFrameCtl;
316 WORD wDurationID;
317 BYTE abyAddr1[WLAN_ADDR_LEN];
318 BYTE abyAddr2[WLAN_ADDR_LEN];
319 BYTE abyAddr3[WLAN_ADDR_LEN];
320 WORD wSeqCtl;
322 }__attribute__ ((__packed__))
323 WLAN_80211HDR_A3, *PWLAN_80211HDR_A3;
325 typedef struct tagWLAN_80211HDR_A4 {
327 WORD wFrameCtl;
328 WORD wDurationID;
329 BYTE abyAddr1[WLAN_ADDR_LEN];
330 BYTE abyAddr2[WLAN_ADDR_LEN];
331 BYTE abyAddr3[WLAN_ADDR_LEN];
332 WORD wSeqCtl;
333 BYTE abyAddr4[WLAN_ADDR_LEN];
335 }__attribute__ ((__packed__))
336 WLAN_80211HDR_A4, *PWLAN_80211HDR_A4;
339 typedef union tagUWLAN_80211HDR {
341 WLAN_80211HDR_A2 sA2;
342 WLAN_80211HDR_A3 sA3;
343 WLAN_80211HDR_A4 sA4;
345 } UWLAN_80211HDR, *PUWLAN_80211HDR;
348 /*--------------------- Export Classes ----------------------------*/
350 /*--------------------- Export Variables --------------------------*/
352 /*--------------------- Export Functions --------------------------*/
356 #endif // __80211HDR_H__