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.
34 /*--------------------- Export Definitions -------------------------*/
38 #define U_ETHER_ADDR_LEN 6 // Ethernet address length
39 #define U_TYPE_LEN 2 //
40 #define U_CRC_LEN 4 //
41 #define U_HEADER_LEN (U_ETHER_ADDR_LEN * 2 + U_TYPE_LEN)
42 #define U_ETHER_ADDR_STR_LEN (U_ETHER_ADDR_LEN * 2 + 1)
43 // Ethernet address string length
45 #define MIN_DATA_LEN 46 // min data length
46 #define MAX_DATA_LEN 1500 // max data length
48 #define MIN_PACKET_LEN (MIN_DATA_LEN + U_HEADER_LEN)
50 // min total packet length (tx)
51 #define MAX_PACKET_LEN (MAX_DATA_LEN + U_HEADER_LEN)
53 // max total packet length (tx)
55 #define MAX_LOOKAHEAD_SIZE MAX_PACKET_LEN
57 #define U_MULTI_ADDR_LEN 8 // multicast address length
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
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
79 // wFrameCtl field in the S802_11Header
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
90 #define TYPE_802_11_ATIM 0x9000
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
100 #define TYPE_CTL_PSPOLL 0xa400
101 #define TYPE_CTL_RTS 0xb400
102 #define TYPE_CTL_CTS 0xc400
103 #define TYPE_CTL_ACK 0xd400
106 //#define WEP_IV_MASK 0xFFFFFF00
108 #else //if LITTLE_ENDIAN
110 // wType field in the SEthernetHeader
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 //
119 #define TYPE_PKT_802_1x 0x8e88
120 #define TYPE_PKT_PreAuth 0xC788
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
132 // wFrameCtl field in the S802_11Header
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
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
153 #define TYPE_CTL_PSPOLL 0x00a4
154 #define TYPE_CTL_RTS 0x00b4
155 #define TYPE_CTL_CTS 0x00c4
156 #define TYPE_CTL_ACK 0x00d4
159 //#define WEP_IV_MASK 0x00FFFFFF
161 #endif //#ifdef __BIG_ENDIAN
163 #define WEP_IV_MASK 0x00FFFFFF
165 /*--------------------- Export Types ------------------------------*/
169 typedef struct tagSEthernetHeader
{
170 BYTE abyDstAddr
[U_ETHER_ADDR_LEN
];
171 BYTE abySrcAddr
[U_ETHER_ADDR_LEN
];
173 }__attribute__ ((__packed__
))
174 SEthernetHeader
, *PSEthernetHeader
;
180 typedef struct tagS802_3Header
{
181 BYTE abyDstAddr
[U_ETHER_ADDR_LEN
];
182 BYTE abySrcAddr
[U_ETHER_ADDR_LEN
];
184 }__attribute__ ((__packed__
))
185 S802_3Header
, *PS802_3Header
;
190 typedef struct tagS802_11Header
{
193 BYTE abyAddr1
[U_ETHER_ADDR_LEN
];
194 BYTE abyAddr2
[U_ETHER_ADDR_LEN
];
195 BYTE abyAddr3
[U_ETHER_ADDR_LEN
];
197 BYTE abyAddr4
[U_ETHER_ADDR_LEN
];
198 }__attribute__ ((__packed__
))
199 S802_11Header
, *PS802_11Header
;
201 /*--------------------- Export Macros ------------------------------*/
204 #define IS_MULTICAST_ADDRESS(pbyEtherAddr) \
205 ((*(PBYTE)(pbyEtherAddr) & 0x01) == 1)
207 #define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \
208 (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \
209 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \
212 #define IS_NULL_ADDRESS(pbyEtherAddr) ( \
213 (*(PDWORD)(pbyEtherAddr) == 0L) && \
214 (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \
217 #define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \
218 (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \
219 (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \
220 *(PWORD)((PBYTE)(pbyAddr2) + 4)) \
223 /*--------------------- Export Classes ----------------------------*/
225 /*--------------------- Export Variables --------------------------*/
227 /*--------------------- Export Functions --------------------------*/
229 BYTE
ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr
);
230 //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
231 BOOL
ETHbIsBufferCrc32Ok(PBYTE pbyBuffer
, UINT cbFrameLength
);
233 #endif // __TETHER_H__