bhfilter.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:9k
源码类别:

模拟服务器

开发平台:

C/C++

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