Updated git wrapper exe
[msysgit.git] / mingw / include / ddk / xfilter.h
blob3940b44f2cf54132ebe87e5caffc1a4b6b254571
1 /*
2 * xfilter.h
4 * Address filtering for NDIS MACs
6 * This file is part of the w32api package.
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 #ifndef __XFILTER_H
24 #define __XFILTER_H
26 #if __GNUC__ >=3
27 #pragma GCC system_header
28 #endif
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include "ntddk.h"
37 #define ETH_LENGTH_OF_ADDRESS 6
39 #define ETH_IS_BROADCAST(Address) \
40 ((((PUCHAR)(Address))[0] == ((UCHAR)0xff)) && (((PUCHAR)(Address))[1] == ((UCHAR)0xff)))
42 #define ETH_IS_MULTICAST(Address) \
43 (BOOLEAN)(((PUCHAR)(Address))[0] & ((UCHAR)0x01))
45 #define ETH_COMPARE_NETWORK_ADDRESSES(_A, _B, _Result) \
46 { \
47 if (*(ULONG UNALIGNED *)&(_A)[2] > *(ULONG UNALIGNED *)&(_B)[2]) \
48 { \
49 *(_Result) = 1; \
50 } \
51 else if (*(ULONG UNALIGNED *)&(_A)[2] < *(ULONG UNALIGNED *)&(_B)[2]) \
52 { \
53 *(_Result) = (UINT)-1; \
54 } \
55 else if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
56 { \
57 *(_Result) = 1; \
58 } \
59 else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
60 { \
61 *(_Result) = (UINT)-1; \
62 } \
63 else \
64 { \
65 *(_Result) = 0; \
66 } \
69 #define ETH_COMPARE_NETWORK_ADDRESSES_EQ(_A,_B, _Result) \
70 { \
71 if ((*(ULONG UNALIGNED *)&(_A)[2] == *(ULONG UNALIGNED *)&(_B)[2]) && \
72 (*(USHORT UNALIGNED *)(_A) == *(USHORT UNALIGNED *)(_B))) \
73 { \
74 *(_Result) = 0; \
75 } \
76 else \
77 { \
78 *(_Result) = 1; \
79 } \
82 #define ETH_COPY_NETWORK_ADDRESS(_D, _S) \
83 { \
84 *((ULONG UNALIGNED *)(_D)) = *((ULONG UNALIGNED *)(_S)); \
85 *((USHORT UNALIGNED *)((UCHAR *)(_D) + 4)) = *((USHORT UNALIGNED *)((UCHAR *)(_S) + 4)); \
88 #define FDDI_LENGTH_OF_LONG_ADDRESS 6
89 #define FDDI_LENGTH_OF_SHORT_ADDRESS 2
91 #define FDDI_IS_BROADCAST(Address, AddressLength, Result) \
92 *Result = ((*(PUCHAR)(Address) == (UCHAR)0xFF) && \
93 (*((PUCHAR)(Address) + 1) == (UCHAR)0xFF))
95 #define FDDI_IS_MULTICAST(Address, AddressLength, Result) \
96 *Result = (BOOLEAN)(*(UCHAR *)(Address) & (UCHAR)0x01)
98 #define FDDI_IS_SMT(FcByte, Result) \
99 { \
100 *Result = ((FcByte & ((UCHAR)0xf0)) == 0x40); \
104 #define FDDI_COMPARE_NETWORK_ADDRESSES(_A, _B, _Length, _Result) \
106 if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
108 *(_Result) = 1; \
110 else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
112 *(_Result) = (UINT)-1; \
114 else if (_Length == 2) \
116 *(_Result) = 0; \
118 else if (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) > *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)) \
120 *(_Result) = 1; \
122 else if (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) < *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)) \
124 *(_Result) = (UINT)-1; \
126 else \
128 *(_Result) = 0; \
132 #define FDDI_COMPARE_NETWORK_ADDRESSES_EQ(_A, _B, _Length, _Result) \
134 if ((*(USHORT UNALIGNED *)(_A) == *(USHORT UNALIGNED *)(_B)) && \
135 (((_Length) == 2) || \
136 (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) == *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)))) \
138 *(_Result) = 0; \
140 else \
142 *(_Result) = 1; \
146 #define FDDI_COPY_NETWORK_ADDRESS(D, S, AddressLength) \
148 PCHAR _D = (D); \
149 PCHAR _S = (S); \
150 UINT _C = (AddressLength); \
151 for ( ; _C > 0 ; _D++, _S++, _C--) \
153 *_D = *_S; \
157 #define TR_LENGTH_OF_FUNCTIONAL 4
158 #define TR_LENGTH_OF_ADDRESS 6
160 typedef ULONG TR_FUNCTIONAL_ADDRESS;
161 typedef ULONG TR_GROUP_ADDRESS;
163 #define TR_IS_NOT_DIRECTED(_Address, _Result) \
165 *(_Result) = (BOOLEAN)((_Address)[0] & 0x80); \
168 #define TR_IS_FUNCTIONAL(_Address, _Result) \
170 *(_Result) = (BOOLEAN)(((_Address)[0] & 0x80) && !((_Address)[2] & 0x80)); \
173 #define TR_IS_GROUP(_Address, _Result) \
175 *(_Result) = (BOOLEAN)((_Address)[0] & (_Address)[2] & 0x80); \
178 #define TR_IS_SOURCE_ROUTING(_Address, _Result) \
180 *(_Result) = (BOOLEAN)((_Address)[0] & 0x80); \
183 #define TR_IS_MAC_FRAME(_PacketHeader) ((((PUCHAR)_PacketHeader)[1] & 0xFC) == 0)
185 #define TR_IS_BROADCAST(_Address, _Result) \
187 *(_Result) = (BOOLEAN)(((*(UNALIGNED USHORT *)&(_Address)[0] == 0xFFFF) || \
188 (*(UNALIGNED USHORT *)&(_Address)[0] == 0x00C0)) && \
189 (*(UNALIGNED ULONG *)&(_Address)[2] == 0xFFFFFFFF)); \
192 #define TR_COMPARE_NETWORK_ADDRESSES(_A, _B, _Result) \
194 if (*(ULONG UNALIGNED *)&(_A)[2] > *(ULONG UNALIGNED *)&(_B)[2]) \
196 *(_Result) = 1; \
198 else if (*(ULONG UNALIGNED *)&(_A)[2] < *(ULONG UNALIGNED *)&(_B)[2]) \
200 *(_Result) = (UINT)-1; \
202 else if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
204 *(_Result) = 1; \
206 else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
208 *(_Result) = (UINT)-1; \
210 else \
212 *(_Result) = 0; \
216 #define TR_COPY_NETWORK_ADDRESS(_D, _S) \
218 *((ULONG UNALIGNED *)(_D)) = *((ULONG UNALIGNED *)(_S)); \
219 *((USHORT UNALIGNED *)((UCHAR *)(_D)+4)) = *((USHORT UNALIGNED *)((UCHAR *)(_S) + 4)); \
222 #define TR_COMPARE_NETWORK_ADDRESSES_EQ(_A, _B, _Result) \
224 if ((*(ULONG UNALIGNED *)&(_A)[2] == *(ULONG UNALIGNED *)&(_B)[2]) && \
225 (*(USHORT UNALIGNED *)&(_A)[0] == *(USHORT UNALIGNED *)&(_B)[0])) \
227 *(_Result) = 0; \
229 else \
231 *(_Result) = 1; \
235 #ifdef __cplusplus
237 #endif
239 #endif /* __XFILTER_H */