Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / vt6655 / tether.h
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 *
19 * File: tether.h
20 *
21 * Purpose:
22 *
23 * Author: Tevin Chen
24 *
25 * Date: Jan. 28, 1997
26 *
27 */
28
29 #ifndef __TETHER_H__
30 #define __TETHER_H__
31
32 #include <linux/if_ether.h>
33 #include "ttype.h"
34
35 /*--------------------- Export Definitions -------------------------*/
36 //
37 // constants
38 //
39 #define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1)
40 // Ethernet address string length
41
42 #define MIN_DATA_LEN 46 // min data length
43
44 #define MIN_PACKET_LEN (MIN_DATA_LEN + ETH_HLEN)
45 // 60
46 // min total packet length (tx)
47
48 #define MAX_LOOKAHEAD_SIZE ETH_FRAME_LEN
49
50 #define U_MULTI_ADDR_LEN 8 // multicast address length
51
52
53 #ifdef __BIG_ENDIAN
54
55 #define TYPE_PKT_IP 0x0800 //
56 #define TYPE_PKT_ARP 0x0806 //
57 #define TYPE_PKT_RARP 0x8035 //
58 #define TYPE_PKT_IPX 0x8137 //
59 #define TYPE_PKT_802_1x 0x888e
60 #define TYPE_PKT_PreAuth 0x88C7
61
62 #define TYPE_PKT_PING_M_REQ 0x8011 // master reguest
63 #define TYPE_PKT_PING_S_GNT 0x8022 // slave grant
64 #define TYPE_PKT_PING_M 0x8077 // pingpong master packet
65 #define TYPE_PKT_PING_S 0x8088 // pingpong slave packet
66 #define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request
67 #define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant
68 #define TYPE_MGMT_PROBE_RSP 0x5000
69 #define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt
70 #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
71 //
72 // wFrameCtl field in the S802_11Header
73 //
74 // NOTE....
75 // in network byte order, high byte is going first
76 #define FC_TODS 0x0001
77 #define FC_FROMDS 0x0002
78 #define FC_MOREFRAG 0x0004
79 #define FC_RETRY 0x0008
80 #define FC_POWERMGT 0x0010
81 #define FC_MOREDATA 0x0020
82 #define FC_WEP 0x0040
83 #define TYPE_802_11_ATIM 0x9000
84
85 #define TYPE_802_11_DATA 0x0800
86 #define TYPE_802_11_CTL 0x0400
87 #define TYPE_802_11_MGMT 0x0000
88 #define TYPE_802_11_MASK 0x0C00
89 #define TYPE_SUBTYPE_MASK 0xFC00
90 #define TYPE_802_11_NODATA 0x4000
91 #define TYPE_DATE_NULL 0x4800
92
93 #define TYPE_CTL_PSPOLL 0xa400
94 #define TYPE_CTL_RTS 0xb400
95 #define TYPE_CTL_CTS 0xc400
96 #define TYPE_CTL_ACK 0xd400
97
98
99 //#define WEP_IV_MASK 0xFFFFFF00
100
101 #else //if LITTLE_ENDIAN
102 //
103 // wType field in the SEthernetHeader
104 //
105 // NOTE....
106 // in network byte order, high byte is going first
107 #define TYPE_PKT_IP 0x0008 //
108 #define TYPE_PKT_ARP 0x0608 //
109 #define TYPE_PKT_RARP 0x3580 //
110 #define TYPE_PKT_IPX 0x3781 //
111
112 #define TYPE_PKT_802_1x 0x8e88
113 #define TYPE_PKT_PreAuth 0xC788
114
115 #define TYPE_PKT_PING_M_REQ 0x1180 // master reguest
116 #define TYPE_PKT_PING_S_GNT 0x2280 // slave grant
117 #define TYPE_PKT_PING_M 0x7780 // pingpong master packet
118 #define TYPE_PKT_PING_S 0x8880 // pingpong slave packet
119 #define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request
120 #define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant
121 #define TYPE_MGMT_PROBE_RSP 0x0050
122 #define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt
123 #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
124 //
125 // wFrameCtl field in the S802_11Header
126 //
127 // NOTE....
128 // in network byte order, high byte is going first
129 #define FC_TODS 0x0100
130 #define FC_FROMDS 0x0200
131 #define FC_MOREFRAG 0x0400
132 #define FC_RETRY 0x0800
133 #define FC_POWERMGT 0x1000
134 #define FC_MOREDATA 0x2000
135 #define FC_WEP 0x4000
136 #define TYPE_802_11_ATIM 0x0090
137
138 #define TYPE_802_11_DATA 0x0008
139 #define TYPE_802_11_CTL 0x0004
140 #define TYPE_802_11_MGMT 0x0000
141 #define TYPE_802_11_MASK 0x000C
142 #define TYPE_SUBTYPE_MASK 0x00FC
143 #define TYPE_802_11_NODATA 0x0040
144 #define TYPE_DATE_NULL 0x0048
145
146 #define TYPE_CTL_PSPOLL 0x00a4
147 #define TYPE_CTL_RTS 0x00b4
148 #define TYPE_CTL_CTS 0x00c4
149 #define TYPE_CTL_ACK 0x00d4
150
151
152 //#define WEP_IV_MASK 0x00FFFFFF
153
154 #endif //#ifdef __BIG_ENDIAN
155
156 #define WEP_IV_MASK 0x00FFFFFF
157
158 /*--------------------- Export Types ------------------------------*/
159 //
160 // Ethernet packet
161 //
162 typedef struct tagSEthernetHeader {
163 BYTE abyDstAddr[ETH_ALEN];
164 BYTE abySrcAddr[ETH_ALEN];
165 WORD wType;
166 }__attribute__ ((__packed__))
167 SEthernetHeader, *PSEthernetHeader;
168
169
170 //
171 // 802_3 packet
172 //
173 typedef struct tagS802_3Header {
174 BYTE abyDstAddr[ETH_ALEN];
175 BYTE abySrcAddr[ETH_ALEN];
176 WORD wLen;
177 }__attribute__ ((__packed__))
178 S802_3Header, *PS802_3Header;
179
180 //
181 // 802_11 packet
182 //
183 typedef struct tagS802_11Header {
184 WORD wFrameCtl;
185 WORD wDurationID;
186 BYTE abyAddr1[ETH_ALEN];
187 BYTE abyAddr2[ETH_ALEN];
188 BYTE abyAddr3[ETH_ALEN];
189 WORD wSeqCtl;
190 BYTE abyAddr4[ETH_ALEN];
191 }__attribute__ ((__packed__))
192 S802_11Header, *PS802_11Header;
193
194 /*--------------------- Export Macros ------------------------------*/
195 // Frame type macro
196
197 #define IS_MULTICAST_ADDRESS(pbyEtherAddr) \
198 ((*(PBYTE)(pbyEtherAddr) & 0x01) == 1)
199
200 #define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \
201 (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \
202 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \
203 )
204
205 #define IS_NULL_ADDRESS(pbyEtherAddr) ( \
206 (*(PDWORD)(pbyEtherAddr) == 0L) && \
207 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
208 )
209
210 #define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
211 (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
212 (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
213 *(PWORD)((PBYTE)(pbyAddr2) + 4)) \
214 )
215
216 /*--------------------- Export Classes ----------------------------*/
217
218 /*--------------------- Export Variables --------------------------*/
219
220 /*--------------------- Export Functions --------------------------*/
221
222 BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr);
223 //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
224 BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength);
225
226 #endif // __TETHER_H__
227
228
229