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