ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

xfilter.h
Go to the documentation of this file.
00001 /*
00002  * xfilter.h
00003  *
00004  * Address filtering for NDIS MACs
00005  *
00006  * This file is part of the w32api package.
00007  *
00008  * Contributors:
00009  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
00010  *
00011  * THIS SOFTWARE IS NOT COPYRIGHTED
00012  *
00013  * This source code is offered for use in the public domain. You may
00014  * use, modify or distribute it freely.
00015  *
00016  * This code is distributed in the hope that it will be useful but
00017  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00018  * DISCLAIMED. This includes but is not limited to warranties of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00020  *
00021  */
00022 
00023 #ifndef _X_FILTER_DEFS_
00024 #define _X_FILTER_DEFS_
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 #define ETH_LENGTH_OF_ADDRESS             6
00031 
00032 #define ETH_IS_BROADCAST(Address) \
00033   ((((PUCHAR)(Address))[0] == ((UCHAR)0xff)) && (((PUCHAR)(Address))[1] == ((UCHAR)0xff)))
00034 
00035 #define ETH_IS_MULTICAST(Address) \
00036   (BOOLEAN)(((PUCHAR)(Address))[0] & ((UCHAR)0x01))
00037 
00038 #define ETH_COMPARE_NETWORK_ADDRESSES(_A, _B, _Result) \
00039 { \
00040     if (*(ULONG UNALIGNED *)&(_A)[2] > *(ULONG UNALIGNED *)&(_B)[2]) \
00041     { \
00042     *(_Result) = 1; \
00043     } \
00044     else if (*(ULONG UNALIGNED *)&(_A)[2] < *(ULONG UNALIGNED *)&(_B)[2]) \
00045     { \
00046     *(_Result) = (UINT)-1; \
00047     } \
00048     else if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
00049     { \
00050     *(_Result) = 1; \
00051     } \
00052     else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
00053     { \
00054       *(_Result) = (UINT)-1; \
00055     } \
00056     else \
00057     { \
00058       *(_Result) = 0; \
00059     } \
00060 }
00061 
00062 #define ETH_COMPARE_NETWORK_ADDRESSES_EQ(_A,_B, _Result) \
00063 { \
00064     if ((*(ULONG UNALIGNED *)&(_A)[2] == *(ULONG UNALIGNED *)&(_B)[2]) && \
00065     (*(USHORT UNALIGNED *)(_A) == *(USHORT UNALIGNED *)(_B))) \
00066     { \
00067     *(_Result) = 0; \
00068     } \
00069     else \
00070     { \
00071     *(_Result) = 1; \
00072     } \
00073 }
00074 
00075 #define ETH_COPY_NETWORK_ADDRESS(_D, _S) \
00076 { \
00077     *((ULONG UNALIGNED *)(_D)) = *((ULONG UNALIGNED *)(_S)); \
00078     *((USHORT UNALIGNED *)((UCHAR *)(_D) + 4)) = *((USHORT UNALIGNED *)((UCHAR *)(_S) + 4)); \
00079 }
00080 
00081 #define FDDI_LENGTH_OF_LONG_ADDRESS       6
00082 #define FDDI_LENGTH_OF_SHORT_ADDRESS      2
00083 
00084 #define FDDI_IS_BROADCAST(Address, AddressLength, Result)   \
00085   *Result = ((*(PUCHAR)(Address) == (UCHAR)0xFF) && \
00086   (*((PUCHAR)(Address) + 1) == (UCHAR)0xFF))
00087 
00088 #define FDDI_IS_MULTICAST(Address, AddressLength, Result) \
00089   *Result = (BOOLEAN)(*(UCHAR *)(Address) & (UCHAR)0x01)
00090 
00091 #define FDDI_IS_SMT(FcByte, Result) \
00092 { \
00093   *Result = ((FcByte & ((UCHAR)0xf0)) == 0x40); \
00094 }
00095 
00096 
00097 #define FDDI_COMPARE_NETWORK_ADDRESSES(_A, _B, _Length, _Result) \
00098 { \
00099     if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
00100     { \
00101       *(_Result) = 1; \
00102     } \
00103     else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
00104     { \
00105       *(_Result) = (UINT)-1; \
00106     } \
00107     else if (_Length == 2) \
00108     { \
00109       *(_Result) = 0; \
00110     } \
00111     else if (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) > *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)) \
00112     { \
00113       *(_Result) = 1; \
00114     } \
00115     else if (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) < *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)) \
00116     { \
00117       *(_Result) = (UINT)-1; \
00118     } \
00119     else \
00120     { \
00121       *(_Result) = 0; \
00122     } \
00123 }
00124 
00125 #define FDDI_COMPARE_NETWORK_ADDRESSES_EQ(_A, _B, _Length, _Result) \
00126 {                                                                   \
00127     if ((*(USHORT UNALIGNED *)(_A) == *(USHORT UNALIGNED *)(_B)) && \
00128       (((_Length) == 2) || \
00129         (*(ULONG UNALIGNED *)((PUCHAR)(_A) + 2) == *(ULONG UNALIGNED *)((PUCHAR)(_B) + 2)))) \
00130     { \
00131       *(_Result) = 0; \
00132     } \
00133     else \
00134     { \
00135       *(_Result) = 1; \
00136     } \
00137 }
00138 
00139 #define FDDI_COPY_NETWORK_ADDRESS(D, S, AddressLength) \
00140 { \
00141     PCHAR _D = (D); \
00142     PCHAR _S = (S); \
00143     UINT _C = (AddressLength); \
00144     for ( ; _C > 0 ; _D++, _S++, _C--) \
00145     { \
00146       *_D = *_S; \
00147     } \
00148 }
00149 
00150 #define TR_LENGTH_OF_FUNCTIONAL           4
00151 #define TR_LENGTH_OF_ADDRESS              6
00152 
00153 typedef ULONG TR_FUNCTIONAL_ADDRESS;
00154 typedef ULONG TR_GROUP_ADDRESS;
00155 
00156 #define TR_IS_NOT_DIRECTED(_Address, _Result) \
00157 { \
00158   *(_Result) = (BOOLEAN)((_Address)[0] & 0x80); \
00159 }
00160 
00161 #define TR_IS_FUNCTIONAL(_Address, _Result) \
00162 { \
00163     *(_Result) = (BOOLEAN)(((_Address)[0] & 0x80) && !((_Address)[2] & 0x80)); \
00164 }
00165 
00166 #define TR_IS_GROUP(_Address, _Result) \
00167 { \
00168   *(_Result) = (BOOLEAN)((_Address)[0] & (_Address)[2] & 0x80); \
00169 }
00170 
00171 #define TR_IS_SOURCE_ROUTING(_Address, _Result) \
00172 { \
00173   *(_Result) = (BOOLEAN)((_Address)[0] & 0x80); \
00174 }
00175 
00176 #define TR_IS_MAC_FRAME(_PacketHeader) ((((PUCHAR)_PacketHeader)[1] & 0xFC) == 0)
00177 
00178 #define TR_IS_BROADCAST(_Address, _Result) \
00179 { \
00180     *(_Result) = (BOOLEAN)(((*(UNALIGNED USHORT *)&(_Address)[0] == 0xFFFF) || \
00181         (*(UNALIGNED USHORT *)&(_Address)[0] == 0x00C0)) && \
00182         (*(UNALIGNED ULONG  *)&(_Address)[2] == 0xFFFFFFFF)); \
00183 }
00184 
00185 #define TR_COMPARE_NETWORK_ADDRESSES(_A, _B, _Result) \
00186 { \
00187     if (*(ULONG UNALIGNED *)&(_A)[2] > *(ULONG UNALIGNED *)&(_B)[2]) \
00188     { \
00189       *(_Result) = 1; \
00190     } \
00191     else if (*(ULONG UNALIGNED *)&(_A)[2] < *(ULONG UNALIGNED *)&(_B)[2]) \
00192     { \
00193       *(_Result) = (UINT)-1; \
00194     } \
00195     else if (*(USHORT UNALIGNED *)(_A) > *(USHORT UNALIGNED *)(_B)) \
00196     { \
00197       *(_Result) = 1; \
00198     } \
00199     else if (*(USHORT UNALIGNED *)(_A) < *(USHORT UNALIGNED *)(_B)) \
00200     { \
00201       *(_Result) = (UINT)-1; \
00202     } \
00203     else \
00204     { \
00205       *(_Result) = 0; \
00206     } \
00207 }
00208 
00209 #define TR_COPY_NETWORK_ADDRESS(_D, _S) \
00210 { \
00211     *((ULONG UNALIGNED *)(_D)) = *((ULONG UNALIGNED *)(_S)); \
00212     *((USHORT UNALIGNED *)((UCHAR *)(_D)+4)) = *((USHORT UNALIGNED *)((UCHAR *)(_S) + 4)); \
00213 }
00214 
00215 #define TR_COMPARE_NETWORK_ADDRESSES_EQ(_A, _B, _Result) \
00216 { \
00217     if ((*(ULONG UNALIGNED  *)&(_A)[2] == *(ULONG UNALIGNED  *)&(_B)[2]) && \
00218         (*(USHORT UNALIGNED *)&(_A)[0] == *(USHORT UNALIGNED *)&(_B)[0])) \
00219     { \
00220     *(_Result) = 0; \
00221     } \
00222     else \
00223     { \
00224     *(_Result) = 1; \
00225     } \
00226 }
00227 
00228 #ifdef __cplusplus
00229 }
00230 #endif
00231 
00232 #endif /* _X_FILTER_DEFS_ */

Generated on Sat May 26 2012 04:29:12 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.