home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / bhfilter.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  10KB  |  271 lines

  1.  
  2. //============================================================================
  3. //  MODULE: Filter.h
  4. //
  5. //  Description:
  6. //
  7. //  Bloodhound DLL for Filtering.
  8. //
  9. //  Modification History
  10. //
  11. //  stevehi         03/22/93            Created.
  12. //  raypa           10/25/93            Changed HPROPERTYDB to HPROTOCOL.
  13. //  SteveHi         10/28/93            pull Value out of Object union
  14. //============================================================================
  15.  
  16.  
  17.  
  18. #if !defined(_FILTER_)
  19.  
  20. #define _FILTER_
  21.  
  22. //============================================================================
  23. //  types
  24. //============================================================================
  25.  
  26.  
  27. typedef HFILTER * LPHFILTER;
  28.  
  29.  
  30. typedef DWORD FILTERACTIONTYPE;
  31. typedef DWORD VALUETYPE;
  32.  
  33.  
  34. // check for protocols existing in the frame.
  35.  
  36. // ProtocolPart
  37. // this is the raw data for a Protocol based expression
  38. //
  39. // WHAT???          FIELD          DESCRIPTION                  EXAMPLE
  40. // -------          -----          -----------                  -------
  41. // Count of Protocol(nPropertyDBs) Number of protocols to pass  5
  42. // PropertyDB Table (PropertyDB)    Table of HPROTOCOL        SMB, LLC, MAC
  43. //
  44. // NOTE: the nPropertyDBs field may also be the following, which implies that
  45. // all are selected but that none have actually been put into the structure
  46.  
  47. #define PROTOCOL_NUM_ANY  (-1)
  48.  
  49. //...   Use PROTOCOLTABLE defined in BHTYPES.H
  50.  
  51. typedef PROTOCOLTABLE PROTOCOLTABLETYPE;        // array of HPROTOCOL's 
  52. typedef PROTOCOLTABLETYPE *LPPROTOCOLTABLETYPE;
  53.  
  54. // filter bits stores who passed what filter per frame to speed up
  55. //  the filter process...  This is actually an array.
  56.  
  57. typedef DWORD FILTERBITS;
  58.  
  59. typedef FILTERBITS *LPFILTERBITS;
  60.  
  61. typedef SYSTEMTIME *LPTIME;
  62. typedef SYSTEMTIME UNALIGNED * ULPTIME;
  63.  
  64.  
  65. // The Filter Object is the basic unit of the postfix stack.
  66. // I need to restart the convert property to value if the comparison does not match.
  67. // To do this, I need the original pointer to the property.  Pull the hProperty out of
  68. // the union so that the pointer to the property is saved.
  69.  
  70. typedef struct _FILTEROBJECT
  71. {
  72.     FILTERACTIONTYPE    Action;     // Object action, see codes below
  73.     HPROPERTY           hProperty;  // property key
  74.     union
  75.     {
  76.         VALUETYPE           Value;           // value of the object.
  77.         HPROTOCOL           hProtocol;       // protocol key.
  78.         LPVOID              lpArray;         // if array, length is ItemCount below.
  79.         LPPROTOCOLTABLETYPE lpProtocolTable; // list of protocols to see if exist in frame.
  80.         LPADDRESS           lpAddress;       // kernel type address, mac or ip
  81.         ULPLARGEINT         lpLargeInt;      // Double DWORD used by NT
  82.         ULPTIME             lpTime;          // pointer to SYSTEMTIME
  83.         LPOBJECT_IDENTIFIER lpOID;           // pointer to OBJECT_IDENTIFIER
  84.  
  85.     };
  86.     union
  87.     {
  88.         WORD            ByteCount;      // Number of BYTES!
  89.         WORD            ByteOffset;     // offset for array compare
  90.     };
  91.  
  92.     struct _FILTEROBJECT * pNext;   // reserved
  93. } FILTEROBJECT;
  94.  
  95. typedef FILTEROBJECT * LPFILTEROBJECT;
  96.  
  97. #define FILTERINFO_SIZE (sizeof(FILTEROBJECT) )
  98.  
  99.  
  100.  
  101. typedef struct _FILTERDESC
  102. {
  103.     WORD            NumEntries;
  104.     WORD            Flags;          // private
  105.     LPFILTEROBJECT  lpStack;
  106.     LPFILTEROBJECT  lpKeepLast;
  107.     LPVOID          UIInstanceData; // UI specific information.
  108.     LPFILTERBITS    lpFilterBits;   // cache who passed
  109.     LPFILTERBITS    lpCheckBits;    // have we looked at it yet?
  110.     
  111. } FILTERDESC;
  112.  
  113. typedef FILTERDESC * LPFILTERDESC;
  114.  
  115. #define FILTERDESC_SIZE sizeof(FILTERDESC)
  116.  
  117.  
  118. //============================================================================
  119. //  Macros.
  120. //============================================================================
  121.  
  122. #define FilterGetUIInstanceData(hfilt)         (((LPFILTERDESC)hfilt)->UIInstanceData)
  123. #define FilterSetUIInstanceData(hfilt,inst)    (((LPFILTERDESC)hfilt)->UIInstanceData = (LPVOID)inst)
  124.  
  125. //============================================================================
  126. //  defines
  127. //============================================================================
  128.  
  129. #define FILTERFREEPOOLSTART 20
  130.  
  131. #define INVALIDELEMENT -1
  132. #define INVALIDVALUE ((VALUETYPE) -9999)
  133.  
  134. // use filter failed to check the return code on FilterFrame.
  135. #define FILTER_FAIL_WITH_ERROR  -1
  136. #define FILTER_PASSED TRUE
  137. #define FILTER_FAILED FALSE
  138.  
  139. //  NOTE NOTE NOTE  If you change the values of the following constants, you
  140. //    MUST modify the TableEval table in filtloc.h.
  141.  
  142. #define FILTERACTION_INVALID            0
  143. #define FILTERACTION_PROPERTY           1
  144. #define FILTERACTION_VALUE              2
  145. #define FILTERACTION_STRING             3
  146. #define FILTERACTION_ARRAY              4
  147. #define FILTERACTION_AND                5
  148. #define FILTERACTION_OR                 6
  149. #define FILTERACTION_XOR                7
  150. #define FILTERACTION_PROPERTYEXIST      8
  151. #define FILTERACTION_CONTAINSNC         9
  152. #define FILTERACTION_CONTAINS           10
  153. #define FILTERACTION_NOT                11
  154. #define FILTERACTION_EQUALNC            12
  155. #define FILTERACTION_EQUAL              13
  156. #define FILTERACTION_NOTEQUALNC         14
  157. #define FILTERACTION_NOTEQUAL           15
  158. #define FILTERACTION_GREATERNC          16
  159. #define FILTERACTION_GREATER            17
  160. #define FILTERACTION_LESSNC             18
  161. #define FILTERACTION_LESS               19
  162. #define FILTERACTION_GREATEREQUALNC     20
  163. #define FILTERACTION_GREATEREQUAL       21
  164. #define FILTERACTION_LESSEQUALNC        22
  165. #define FILTERACTION_LESSEQUAL          23
  166. #define FILTERACTION_PLUS               24
  167. #define FILTERACTION_MINUS              25
  168. #define FILTERACTION_ADDRESS            26
  169. #define FILTERACTION_ADDRESSANY         27
  170. #define FILTERACTION_FROM               28
  171. #define FILTERACTION_TO                 29
  172. #define FILTERACTION_FROMTO             30
  173. #define FILTERACTION_AREBITSON          31
  174. #define FILTERACTION_AREBITSOFF         32
  175. #define FILTERACTION_PROTOCOLSEXIST     33
  176. #define FILTERACTION_PROTOCOLEXIST      34
  177. #define FILTERACTION_ARRAYEQUAL         35
  178. #define FILTERACTION_DEREFPROPERTY      36
  179. #define FILTERACTION_LARGEINT           37
  180. #define FILTERACTION_TIME               38
  181. #define FILTERACTION_ADDR_ETHER         39
  182. #define FILTERACTION_ADDR_TOKEN         40
  183. #define FILTERACTION_ADDR_FDDI          41
  184. #define FILTERACTION_ADDR_IPX           42
  185. #define FILTERACTION_ADDR_IP            43
  186. #define FILTERACTION_OID                44
  187. #define FILTERACTION_OID_CONTAINS       45
  188. #define FILTERACTION_OID_BEGINS_WITH    46
  189. #define FILTERACTION_OID_ENDS_WITH      47
  190. #define FILTERACTION_ADDR_VINES         48
  191.  
  192. #define FILTERACTION_EXPRESSION         97
  193. #define FILTERACTION_BOOL               98
  194. #define FILTERACTION_NOEVAL             99
  195.  
  196.  
  197. #define FILTER_NO_MORE_FRAMES   0xFFFFFFFF
  198. #define FILTER_CANCELED         0xFFFFFFFE
  199. #define FILTER_DIRECTION_NEXT   TRUE
  200. #define FILTER_DIRECTION_PREV   FALSE
  201.  
  202.  
  203.  
  204.  
  205. //============================================================================
  206. //  Helper functions.
  207. //============================================================================
  208.  
  209. typedef BOOL (WINAPI *STATUSPROC)(DWORD, HCAPTURE, HFILTER, DWORD);
  210.         // callback to show filter status:
  211.         //      DWORD nFrame
  212.         //      HCAPTURE
  213.         //      HFILTER
  214.         //      DWORD  UI Instance data (hwnd)
  215.  
  216.  
  217. //============================================================================
  218. //  Global data.
  219. //============================================================================
  220.  
  221.  
  222.  
  223. //=============================================================================
  224. //  FILTER API's.
  225. //=============================================================================
  226.  
  227. extern HFILTER  WINAPI CreateFilter(VOID);
  228.  
  229. extern DWORD    WINAPI DestroyFilter(HFILTER hFilter);
  230.  
  231. extern HFILTER  WINAPI FilterDuplicate(HFILTER hFilter);
  232.  
  233. extern DWORD    WINAPI DisableParserFilter(HFILTER hFilter, HPARSER hParser);
  234.  
  235. extern DWORD    WINAPI EnableParserFilter(HFILTER hFilter, HPARSER hParser);
  236.  
  237. extern DWORD    WINAPI FilterAddObject(HFILTER hFilter, LPFILTEROBJECT lpFilterObject );
  238.  
  239. extern VOID     WINAPI FilterFlushBits(HFILTER hFilter);
  240.  
  241. extern DWORD    WINAPI FilterFrame(HFRAME hFrame, HFILTER hFilter, HCAPTURE hCapture);
  242.     // returns -1 == check BH set last error
  243.     //          0 == FALSE
  244.     //          1 == TRUE
  245.  
  246. DWORD WINAPI FilterFindFrame (  HFILTER     hFilter,
  247.                                 HCAPTURE    hCapture,
  248.                                 DWORD       nFrame,
  249.                                 STATUSPROC  StatusProc,
  250.                                 DWORD       UIInstance,
  251.                                 DWORD       TimeDelta,
  252.                                 BOOL        FilterDirection );
  253.  
  254. HFRAME FilterFindPropertyInstance ( HFRAME          hFrame, 
  255.                                     HFILTER         hMasterFilter, 
  256.                                     HCAPTURE        hCapture,
  257.                                     HFILTER         hInstanceFilter,
  258.                                     LPPROPERTYINST    *lpPropRestartKey,
  259.                                     STATUSPROC      StatusProc,
  260.                                     DWORD           UIInstance,
  261.                                     DWORD           TimeDelta,
  262.                                     BOOL            FilterForward );
  263.  
  264.  
  265. extern VOID WINAPI SetCurrentFilter(HFILTER);
  266. extern HFILTER  WINAPI GetCurrentFilter(VOID);
  267.  
  268.  
  269.  
  270. #endif
  271.