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