2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
35 #if !defined(__TTYPE_H__)
42 /*--------------------- Export Definitions -------------------------*/
46 #define U_ETHER_ADDR_LEN 6 // Ethernet address length
47 #define U_TYPE_LEN 2 //
48 #define U_CRC_LEN 4 //
49 #define U_HEADER_LEN (U_ETHER_ADDR_LEN * 2 + U_TYPE_LEN)
50 #define U_ETHER_ADDR_STR_LEN (U_ETHER_ADDR_LEN * 2 + 1)
51 // Ethernet address string length
53 #define MIN_DATA_LEN 46 // min data length
54 #define MAX_DATA_LEN 1500 // max data length
56 #define MIN_PACKET_LEN (MIN_DATA_LEN + U_HEADER_LEN)
58 // min total packet length (tx)
59 #define MAX_PACKET_LEN (MAX_DATA_LEN + U_HEADER_LEN)
61 // max total packet length (tx)
63 #define MAX_LOOKAHEAD_SIZE MAX_PACKET_LEN
65 #define U_MULTI_ADDR_LEN 8 // multicast address length
70 #define TYPE_PKT_IP 0x0800 //
71 #define TYPE_PKT_ARP 0x0806 //
72 #define TYPE_PKT_RARP 0x8035 //
73 #define TYPE_PKT_IPX 0x8137 //
74 #define TYPE_PKT_802_1x 0x888e
75 #define TYPE_PKT_PreAuth 0x88C7
77 #define TYPE_PKT_PING_M_REQ 0x8011 // master reguest
78 #define TYPE_PKT_PING_S_GNT 0x8022 // slave grant
79 #define TYPE_PKT_PING_M 0x8077 // pingpong master packet
80 #define TYPE_PKT_PING_S 0x8088 // pingpong slave packet
81 #define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request
82 #define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant
83 #define TYPE_MGMT_PROBE_RSP 0x5000
84 #define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt
85 #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
87 // wFrameCtl field in the S802_11Header
90 // in network byte order, high byte is going first
91 #define FC_TODS 0x0001
92 #define FC_FROMDS 0x0002
93 #define FC_MOREFRAG 0x0004
94 #define FC_RETRY 0x0008
95 #define FC_POWERMGT 0x0010
96 #define FC_MOREDATA 0x0020
98 #define TYPE_802_11_ATIM 0x9000
100 #define TYPE_802_11_DATA 0x0800
101 #define TYPE_802_11_CTL 0x0400
102 #define TYPE_802_11_MGMT 0x0000
103 #define TYPE_802_11_MASK 0x0C00
104 #define TYPE_SUBTYPE_MASK 0xFC00
105 #define TYPE_802_11_NODATA 0x4000
106 #define TYPE_DATE_NULL 0x4800
108 #define TYPE_CTL_PSPOLL 0xa400
109 #define TYPE_CTL_RTS 0xb400
110 #define TYPE_CTL_CTS 0xc400
111 #define TYPE_CTL_ACK 0xd400
114 //#define WEP_IV_MASK 0xFFFFFF00
116 #else //if LITTLE_ENDIAN
118 // wType field in the SEthernetHeader
121 // in network byte order, high byte is going first
122 #define TYPE_PKT_IP 0x0008 //
123 #define TYPE_PKT_ARP 0x0608 //
124 #define TYPE_PKT_RARP 0x3580 //
125 #define TYPE_PKT_IPX 0x3781 //
127 #define TYPE_PKT_802_1x 0x8e88
128 #define TYPE_PKT_PreAuth 0xC788
130 #define TYPE_PKT_PING_M_REQ 0x1180 // master reguest
131 #define TYPE_PKT_PING_S_GNT 0x2280 // slave grant
132 #define TYPE_PKT_PING_M 0x7780 // pingpong master packet
133 #define TYPE_PKT_PING_S 0x8880 // pingpong slave packet
134 #define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request
135 #define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant
136 #define TYPE_MGMT_PROBE_RSP 0x0050
137 #define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt
138 #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
140 // wFrameCtl field in the S802_11Header
143 // in network byte order, high byte is going first
144 #define FC_TODS 0x0100
145 #define FC_FROMDS 0x0200
146 #define FC_MOREFRAG 0x0400
147 #define FC_RETRY 0x0800
148 #define FC_POWERMGT 0x1000
149 #define FC_MOREDATA 0x2000
150 #define FC_WEP 0x4000
151 #define TYPE_802_11_ATIM 0x0090
153 #define TYPE_802_11_DATA 0x0008
154 #define TYPE_802_11_CTL 0x0004
155 #define TYPE_802_11_MGMT 0x0000
156 #define TYPE_802_11_MASK 0x000C
157 #define TYPE_SUBTYPE_MASK 0x00FC
158 #define TYPE_802_11_NODATA 0x0040
159 #define TYPE_DATE_NULL 0x0048
161 #define TYPE_CTL_PSPOLL 0x00a4
162 #define TYPE_CTL_RTS 0x00b4
163 #define TYPE_CTL_CTS 0x00c4
164 #define TYPE_CTL_ACK 0x00d4
167 //#define WEP_IV_MASK 0x00FFFFFF
169 #endif //#ifdef __BIG_ENDIAN
171 #define WEP_IV_MASK 0x00FFFFFF
173 /*--------------------- Export Types ------------------------------*/
177 typedef struct tagSEthernetHeader {
178 BYTE abyDstAddr[U_ETHER_ADDR_LEN];
179 BYTE abySrcAddr[U_ETHER_ADDR_LEN];
181 }__attribute__ ((__packed__))
182 SEthernetHeader, DEF* PSEthernetHeader;
188 typedef struct tagS802_3Header {
189 BYTE abyDstAddr[U_ETHER_ADDR_LEN];
190 BYTE abySrcAddr[U_ETHER_ADDR_LEN];
192 }__attribute__ ((__packed__))
193 S802_3Header, DEF* PS802_3Header;
198 typedef struct tagS802_11Header {
201 BYTE abyAddr1[U_ETHER_ADDR_LEN];
202 BYTE abyAddr2[U_ETHER_ADDR_LEN];
203 BYTE abyAddr3[U_ETHER_ADDR_LEN];
205 BYTE abyAddr4[U_ETHER_ADDR_LEN];
206 }__attribute__ ((__packed__))
207 S802_11Header, DEF* PS802_11Header;
209 /*--------------------- Export Macros ------------------------------*/
212 #define IS_MULTICAST_ADDRESS(pbyEtherAddr) \
213 ((*(PBYTE)(pbyEtherAddr) & 0x01) == 1)
215 #define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \
216 (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \
217 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \
220 #define IS_NULL_ADDRESS(pbyEtherAddr) ( \
221 (*(PDWORD)(pbyEtherAddr) == 0L) && \
222 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
225 #define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
226 (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
227 (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
228 *(PWORD)((PBYTE)(pbyAddr2) + 4)) \
231 /*--------------------- Export Classes ----------------------------*/
233 /*--------------------- Export Variables --------------------------*/
235 /*--------------------- Export Functions --------------------------*/
237 extern "C" { /* Assume C declarations for C++ */
238 #endif /* __cplusplus */
241 BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr);
242 //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
243 BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength);
247 } /* End of extern "C" { */
248 #endif /* __cplusplus */
253 #endif // __TETHER_H__