500分..求C程序转DELPHI... (300分)

  • 主题发起人 主题发起人 sim_might
  • 开始时间 开始时间
S

sim_might

Unregistered / Unconfirmed
GUEST, unregistred user!
以下就是Fltdefs.h,405行,除去注释不足100行,谁能把它转成.pas我就发了不要说什么.ftp://delphi-jedi.org/api/IPHlpAPI.zip他们根本就没转这个....<br>/*++<br><br>Copyright (c) 1995-1999 &nbsp;Microsoft Corporation<br><br>Module Name:<br><br>&nbsp; &nbsp;fltdefs.h<br><br>Abstract:<br><br>&nbsp; &nbsp; Definitions for the WIN32 filter APIs<br><br>Author:<br><br>&nbsp; &nbsp; Arnold Miller (arnoldm) 24-Sept-1997<br><br>Revision History:<br><br>--*/<br><br>#ifndef _FLTDEFS_H<br>#define _FLTDEFS_H<br><br>#if _MSC_VER &gt; 1000<br>#pragma once<br>#endif<br><br>typedef PVOID &nbsp;FILTER_HANDLE, *PFILTER_HANDLE;<br>typedef PVOID &nbsp;INTERFACE_HANDLE, *PINTERFACE_HANDLE;<br><br>#define PFEXPORT _declspec(dllexport)<br><br>#ifdef __cplusplus<br>#define EXTERNCDECL EXTERN_C<br>#else<br>#define EXTERNCDECL<br>#endif<br><br>#define PFAPIENTRY EXTERNCDECL DWORD PFEXPORT WINAPI<br><br>typedef enum _GlobalFilter<br>{<br>&nbsp; &nbsp; GF_FRAGMENTS = 2, &nbsp; &nbsp; &nbsp; &nbsp;// check consistency of fragments<br>&nbsp; &nbsp; GF_STRONGHOST = 8, &nbsp; &nbsp; &nbsp; // check destination address of input frames<br>&nbsp; &nbsp; GF_FRAGCACHE = 9 &nbsp; &nbsp; &nbsp; &nbsp; // check fragments from cache<br>} GLOBAL_FILTER, *PGLOBAL_FILTER;<br><br>typedef enum _PfForwardAction<br>{<br>&nbsp; &nbsp; PF_ACTION_FORWARD = 0,<br>&nbsp; &nbsp; PF_ACTION_DROP<br>} PFFORWARD_ACTION, *PPFFORWARD_ACTION;<br><br>typedef enum _PfAddresType<br>{<br>&nbsp; &nbsp; PF_IPV4,<br>&nbsp; &nbsp; PF_IPV6<br>} PFADDRESSTYPE, *PPFADDRESSTYPE;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The constants that should be used to set up the FILTER_INFO_STRUCTURE &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTER_PROTO(ProtoId) &nbsp; MAKELONG(MAKEWORD((ProtoId),0x00),0x00000)<br><br>#define FILTER_PROTO_ANY &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x00)<br>#define FILTER_PROTO_ICMP &nbsp; &nbsp; &nbsp; FILTER_PROTO(0x01)<br>#define FILTER_PROTO_TCP &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x06)<br>#define FILTER_PROTO_UDP &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x11)<br><br>#define FILTER_TCPUDP_PORT_ANY &nbsp;(WORD)0x0000<br><br>#define FILTER_ICMP_TYPE_ANY &nbsp; &nbsp;(BYTE)0xff<br>#define FILTER_ICMP_CODE_ANY &nbsp; &nbsp;(BYTE)0xff<br><br>typedef struct _PF_FILTER_DESCRIPTOR<br>{<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFilterFlags; &nbsp; &nbsp;// see below<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwRule; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // copied into the log when appropriate<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; pfatType;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcMask;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DstAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DstMask;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwProtocol;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fLateBound;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wSrcPort;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDstPort;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wSrcPortHighRange;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDstPortHighRange;<br>}PF_FILTER_DESCRIPTOR, *PPF_FILTER_DESCRIPTOR;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Structure for PfGetInterfaceStatistics &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef struct _PF_FILTER_STATS<br>{<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; dwNumPacketsFiltered;<br>&nbsp; &nbsp; PF_FILTER_DESCRIPTOR info;<br>}PF_FILTER_STATS, *PPF_FILTER_STATS;<br><br>typedef struct _PF_INTERFACE_STATS<br>{<br>&nbsp; &nbsp; PVOID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pvDriverContext;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFlags; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// none as yet (28-Sept-1997)<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwInDrops;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwOutDrops;<br>&nbsp; &nbsp; PFFORWARD_ACTION &nbsp; &nbsp;eaInAction;<br>&nbsp; &nbsp; PFFORWARD_ACTION &nbsp; &nbsp;eaOutAction;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwNumInFilters;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwNumOutFilters;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFrag;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwSpoof;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwReserved1;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwReserved2;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; liSYN;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; liTotalLogged;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwLostLogEntries;<br>&nbsp; &nbsp; PF_FILTER_STATS &nbsp; &nbsp; FilterInfo[1];<br>} PF_INTERFACE_STATS, *PPF_INTERFACE_STATS;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The number of bytes starting at SrcAddr. If you add something to the &nbsp; &nbsp; //<br>// structure make sure this remains valid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTERSIZE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/<br>&nbsp; &nbsp; (sizeof(PF_FILTER_DESCRIPTOR) - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /<br>&nbsp; &nbsp; &nbsp;(DWORD)(&amp;((PPF_FILTER_DESCRIPTOR)0)-&gt;SrcAddr))<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Flags for PF_FILTER_DESCRIPTOR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>//<br>// Disallows incoming SYN<br>//<br><br>#define FD_FLAGS_NOSYN &nbsp; &nbsp; &nbsp;0x1<br><br>//<br>// All legal flags<br>//<br><br>#define FD_FLAGS_ALLFLAGS &nbsp; FD_FLAGS_NOSYN<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Late bound defs. Go in fLateBound in a PF_FILTER_DESCRIPTOR and &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// describe which other fields of the filter are affected &nbsp;by a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// PfRebindFilters call. In general such filters are on &nbsp;WAN interfaces &nbsp; &nbsp; //<br>// where one or the other address may change as the connection is &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// reconnected. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// The assumption is that such interfaces HAVE ONLY ONE ADDRESS. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define LB_SRC_ADDR_USE_SRCADDR_FLAG &nbsp; &nbsp; 0x00000001<br>#define LB_SRC_ADDR_USE_DSTADDR_FLAG &nbsp; &nbsp; 0x00000002<br>#define LB_DST_ADDR_USE_SRCADDR_FLAG &nbsp; &nbsp; 0x00000004<br>#define LB_DST_ADDR_USE_DSTADDR_FLAG &nbsp; &nbsp; 0x00000008<br>#define LB_SRC_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x00000010<br>#define LB_DST_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x00000020<br><br>typedef struct _PF_LATEBIND_INFO<br>{<br>&nbsp; &nbsp; PBYTE &nbsp; SrcAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; DstAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; Mask;<br>}PF_LATEBIND_INFO, *PPF_LATEBIND_INFO;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The format of a logged frame and defs for it. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef enum _PfFrameType<br>{<br>&nbsp; &nbsp; PFFT_FILTER = 1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// a filter violation<br>&nbsp; &nbsp; PFFT_FRAG &nbsp; = 2, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// bad fragment<br>&nbsp; &nbsp; PFFT_SPOOF &nbsp; = 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// strong host failure<br>} PFFRAMETYPE, *PPFFRAMETYPE;<br><br>typedef struct _pfLogFrame<br>{<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp;Timestamp;<br>&nbsp; &nbsp; PFFRAMETYPE &nbsp; &nbsp;pfeTypeOfFrame;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwTotalSizeUsed; &nbsp; &nbsp; &nbsp;// used to find the next frame<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwFilterRule; &nbsp; &nbsp; &nbsp; &nbsp; // from the filter<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wSizeOfAdditionalData;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wSizeOfIpHeader;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwInterfaceName; &nbsp; &nbsp; &nbsp;// the name of the interface<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwIPIndex;<br>&nbsp; &nbsp; BYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bPacketData[1]; &nbsp; &nbsp; &nbsp; // the frame. wsizeOfIpHeader<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// and wsizeOfAdditionalData<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// describe this<br>} PFLOGFRAME, *PPFLOGFRAME;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Error codes. These extend the WIN32 errors by having errors specific to &nbsp;//<br>// these APIs. Besides these errors, the APIs may return any of the WIN32 &nbsp; //<br>// errors. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define ERROR_BASE &nbsp;23000<br><br>#define PFERROR_NO_PF_INTERFACE &nbsp; &nbsp;(ERROR_BASE + 0) &nbsp; // never returned.<br>#define PFERROR_NO_FILTERS_GIVEN &nbsp; (ERROR_BASE + 1)<br>#define PFERROR_BUFFER_TOO_SMALL &nbsp; (ERROR_BASE + 2)<br>#define ERROR_IPV6_NOT_IMPLEMENTED (ERROR_BASE + 3)<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The API prototypes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfCreateInterface(<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwName,<br>&nbsp; &nbsp; PFFORWARD_ACTION inAction,<br>&nbsp; &nbsp; PFFORWARD_ACTION outAction,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bUseLog,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bMustBeUnique,<br>&nbsp; &nbsp; INTERFACE_HANDLE *ppInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfDeleteInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE pInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfAddFiltersToInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp; &nbsp;ih,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cInFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltIn,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cOutFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltOut,<br>&nbsp; &nbsp; PFILTER_HANDLE &nbsp; &nbsp; &nbsp; &nbsp;pfHandle<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveFiltersFromInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp; &nbsp;ih,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cInFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltIn,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cOutFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltOut<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveFilterHandles(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cFilters,<br>&nbsp; &nbsp; PFILTER_HANDLE &nbsp; &nbsp; pvHandles<br>&nbsp; &nbsp; );<br><br><br>PFAPIENTRY<br>PfUnBindInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfBindInterfaceToIndex(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwIndex,<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; &nbsp; &nbsp; pfatLinkType,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LinkIPAddress<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfBindInterfaceToIPAddress(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; &nbsp; &nbsp; pfatType,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IPAddress<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRebindFilters(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PPF_LATEBIND_INFO &nbsp; pLateBindInfo<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfAddGlobalFilterToInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; GLOBAL_FILTER &nbsp; &nbsp; &nbsp;gfFilter<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveGlobalFilterFromInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; GLOBAL_FILTER &nbsp; &nbsp; &nbsp;gfFilter<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Log APIs. Note that there is at most one log and it must be created &nbsp; &nbsp; &nbsp;//<br>// before any interface needing it is created. There is no way to set a &nbsp; &nbsp; //<br>// log onto an existing interface. The log can be applied to any or all of &nbsp;//<br>// the interfaces. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfMakeLog(<br>&nbsp; &nbsp; HANDLE &nbsp;hEvent<br>&nbsp; &nbsp; );<br><br>//<br>// Provide a buffer, and notification parameters, and get back<br>// the old buffer and status.<br>//<br><br>PFAPIENTRY<br>PfSetLogBuffer(<br>&nbsp; &nbsp; PBYTE &nbsp; pbBuffer,<br>&nbsp; &nbsp; DWORD &nbsp; dwSize,<br>&nbsp; &nbsp; DWORD &nbsp; dwThreshold,<br>&nbsp; &nbsp; DWORD &nbsp; dwEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwLoggedEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwLostEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwSizeUsed<br>&nbsp; &nbsp; );<br><br>//<br>// Doing this will disable the log on any of the interfaces. But if<br>// an interface was created with the log, the actual log will not be<br>// completely deleted until that interface is deleted. This is a small<br>// point, but it might explain a mystery or two.<br>//<br><br>PFAPIENTRY<br>PfDeleteLog(<br>&nbsp; &nbsp; VOID<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Get statistics. Note pdwBufferSize in an IN/OUT parameter. If &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// ERROR_INSUFFICIENT_BUFFER is returned, the common statistics are &nbsp; &nbsp; &nbsp; &nbsp; //<br>// available and the correct byte count is in *pdwBufferSize. If only the &nbsp; //<br>// interface statistics are needed, provide a buffer of size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// PF_INTERFACE_STATS only. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// If the filter descriptions are also needed, then supply a large buffer, &nbsp;//<br>// or use the returned count from the first call to allocate a buffer of &nbsp; &nbsp;//<br>// sufficient size. Note that for a shared interface, this second call may &nbsp;//<br>// fail with ERROR_INSUFFICIENT_BUFFER. This can happen if the other &nbsp; &nbsp; &nbsp; &nbsp;//<br>// sharers add filters in the interim. This should not happen for a UNIQUE &nbsp;//<br>// interface. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>PFAPIENTRY<br>PfGetInterfaceStatistics(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PPF_INTERFACE_STATS ppfStats,<br>&nbsp; &nbsp; PDWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwBufferSize,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fResetCounters<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Test a packet. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// This call will evaluate the packet against the given interfaces &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// and return the filtering action. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfTestPacket(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInInterface &nbsp;OPTIONAL,<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pOutInterface OPTIONAL,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cBytes,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pbPacket,<br>&nbsp; &nbsp; PPFFORWARD_ACTION &nbsp;ppAction<br>&nbsp; &nbsp; );<br><br><br>#endif &nbsp;
 
你的問題<br>需要把Fltdefs.h 轉成pascal的宣告檔<br>我沒記錯的話<br>你可以直接去google查找 IP Helper api delphi<br>就會有你要的宣告檔轉換了<br>ftp://delphi-jedi.org/api/IPHlpAPI.zip<br>這就是一個轉換好的API
 
CB地代码 DELPHI中好像不需要修改 就可以用
 
以下就是Fltdefs.h,405行,除去注释不足100行,谁能把它转成.pas我就发了不要说什么.ftp://delphi-jedi.org/api/IPHlpAPI.zip他们根本就没转这个....<br>/*++<br><br>Copyright (c) 1995-1999 &nbsp;Microsoft Corporation<br><br>Module Name:<br><br>&nbsp; &nbsp;fltdefs.h<br><br>Abstract:<br><br>&nbsp; &nbsp; Definitions for the WIN32 filter APIs<br><br>Author:<br><br>&nbsp; &nbsp; Arnold Miller (arnoldm) 24-Sept-1997<br><br>Revision History:<br><br>--*/<br><br>#ifndef _FLTDEFS_H<br>#define _FLTDEFS_H<br><br>#if _MSC_VER &gt; 1000<br>#pragma once<br>#endif<br><br>typedef PVOID &nbsp;FILTER_HANDLE, *PFILTER_HANDLE;<br>typedef PVOID &nbsp;INTERFACE_HANDLE, *PINTERFACE_HANDLE;<br><br>#define PFEXPORT _declspec(dllexport)<br><br>#ifdef __cplusplus<br>#define EXTERNCDECL EXTERN_C<br>#else<br>#define EXTERNCDECL<br>#endif<br><br>#define PFAPIENTRY EXTERNCDECL DWORD PFEXPORT WINAPI<br><br>typedef enum _GlobalFilter<br>{<br>&nbsp; &nbsp; GF_FRAGMENTS = 2, &nbsp; &nbsp; &nbsp; &nbsp;// check consistency of fragments<br>&nbsp; &nbsp; GF_STRONGHOST = 8, &nbsp; &nbsp; &nbsp; // check destination address of input frames<br>&nbsp; &nbsp; GF_FRAGCACHE = 9 &nbsp; &nbsp; &nbsp; &nbsp; // check fragments from cache<br>} GLOBAL_FILTER, *PGLOBAL_FILTER;<br><br>typedef enum _PfForwardAction<br>{<br>&nbsp; &nbsp; PF_ACTION_FORWARD = 0,<br>&nbsp; &nbsp; PF_ACTION_DROP<br>} PFFORWARD_ACTION, *PPFFORWARD_ACTION;<br><br>typedef enum _PfAddresType<br>{<br>&nbsp; &nbsp; PF_IPV4,<br>&nbsp; &nbsp; PF_IPV6<br>} PFADDRESSTYPE, *PPFADDRESSTYPE;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The constants that should be used to set up the FILTER_INFO_STRUCTURE &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTER_PROTO(ProtoId) &nbsp; MAKELONG(MAKEWORD((ProtoId),0x00),0x00000)<br><br>#define FILTER_PROTO_ANY &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x00)<br>#define FILTER_PROTO_ICMP &nbsp; &nbsp; &nbsp; FILTER_PROTO(0x01)<br>#define FILTER_PROTO_TCP &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x06)<br>#define FILTER_PROTO_UDP &nbsp; &nbsp; &nbsp; &nbsp;FILTER_PROTO(0x11)<br><br>#define FILTER_TCPUDP_PORT_ANY &nbsp;(WORD)0x0000<br><br>#define FILTER_ICMP_TYPE_ANY &nbsp; &nbsp;(BYTE)0xff<br>#define FILTER_ICMP_CODE_ANY &nbsp; &nbsp;(BYTE)0xff<br><br>typedef struct _PF_FILTER_DESCRIPTOR<br>{<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFilterFlags; &nbsp; &nbsp;// see below<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwRule; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // copied into the log when appropriate<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; pfatType;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SrcMask;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DstAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DstMask;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwProtocol;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fLateBound;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wSrcPort;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDstPort;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wSrcPortHighRange;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDstPortHighRange;<br>}PF_FILTER_DESCRIPTOR, *PPF_FILTER_DESCRIPTOR;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Structure for PfGetInterfaceStatistics &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef struct _PF_FILTER_STATS<br>{<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; dwNumPacketsFiltered;<br>&nbsp; &nbsp; PF_FILTER_DESCRIPTOR info;<br>}PF_FILTER_STATS, *PPF_FILTER_STATS;<br><br>typedef struct _PF_INTERFACE_STATS<br>{<br>&nbsp; &nbsp; PVOID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pvDriverContext;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFlags; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// none as yet (28-Sept-1997)<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwInDrops;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwOutDrops;<br>&nbsp; &nbsp; PFFORWARD_ACTION &nbsp; &nbsp;eaInAction;<br>&nbsp; &nbsp; PFFORWARD_ACTION &nbsp; &nbsp;eaOutAction;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwNumInFilters;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwNumOutFilters;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwFrag;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwSpoof;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwReserved1;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwReserved2;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; liSYN;<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp; &nbsp; &nbsp; liTotalLogged;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwLostLogEntries;<br>&nbsp; &nbsp; PF_FILTER_STATS &nbsp; &nbsp; FilterInfo[1];<br>} PF_INTERFACE_STATS, *PPF_INTERFACE_STATS;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The number of bytes starting at SrcAddr. If you add something to the &nbsp; &nbsp; //<br>// structure make sure this remains valid &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTERSIZE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/<br>&nbsp; &nbsp; (sizeof(PF_FILTER_DESCRIPTOR) - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /<br>&nbsp; &nbsp; &nbsp;(DWORD)(&amp;((PPF_FILTER_DESCRIPTOR)0)-&gt;SrcAddr))<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Flags for PF_FILTER_DESCRIPTOR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>//<br>// Disallows incoming SYN<br>//<br><br>#define FD_FLAGS_NOSYN &nbsp; &nbsp; &nbsp;0x1<br><br>//<br>// All legal flags<br>//<br><br>#define FD_FLAGS_ALLFLAGS &nbsp; FD_FLAGS_NOSYN<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Late bound defs. Go in fLateBound in a PF_FILTER_DESCRIPTOR and &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// describe which other fields of the filter are affected &nbsp;by a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// PfRebindFilters call. In general such filters are on &nbsp;WAN interfaces &nbsp; &nbsp; //<br>// where one or the other address may change as the connection is &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// reconnected. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// The assumption is that such interfaces HAVE ONLY ONE ADDRESS. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define LB_SRC_ADDR_USE_SRCADDR_FLAG &nbsp; &nbsp; 0x00000001<br>#define LB_SRC_ADDR_USE_DSTADDR_FLAG &nbsp; &nbsp; 0x00000002<br>#define LB_DST_ADDR_USE_SRCADDR_FLAG &nbsp; &nbsp; 0x00000004<br>#define LB_DST_ADDR_USE_DSTADDR_FLAG &nbsp; &nbsp; 0x00000008<br>#define LB_SRC_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x00000010<br>#define LB_DST_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x00000020<br><br>typedef struct _PF_LATEBIND_INFO<br>{<br>&nbsp; &nbsp; PBYTE &nbsp; SrcAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; DstAddr;<br>&nbsp; &nbsp; PBYTE &nbsp; Mask;<br>}PF_LATEBIND_INFO, *PPF_LATEBIND_INFO;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The format of a logged frame and defs for it. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef enum _PfFrameType<br>{<br>&nbsp; &nbsp; PFFT_FILTER = 1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// a filter violation<br>&nbsp; &nbsp; PFFT_FRAG &nbsp; = 2, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// bad fragment<br>&nbsp; &nbsp; PFFT_SPOOF &nbsp; = 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// strong host failure<br>} PFFRAMETYPE, *PPFFRAMETYPE;<br><br>typedef struct _pfLogFrame<br>{<br>&nbsp; &nbsp; LARGE_INTEGER &nbsp;Timestamp;<br>&nbsp; &nbsp; PFFRAMETYPE &nbsp; &nbsp;pfeTypeOfFrame;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwTotalSizeUsed; &nbsp; &nbsp; &nbsp;// used to find the next frame<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwFilterRule; &nbsp; &nbsp; &nbsp; &nbsp; // from the filter<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wSizeOfAdditionalData;<br>&nbsp; &nbsp; WORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wSizeOfIpHeader;<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwInterfaceName; &nbsp; &nbsp; &nbsp;// the name of the interface<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwIPIndex;<br>&nbsp; &nbsp; BYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bPacketData[1]; &nbsp; &nbsp; &nbsp; // the frame. wsizeOfIpHeader<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// and wsizeOfAdditionalData<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// describe this<br>} PFLOGFRAME, *PPFLOGFRAME;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Error codes. These extend the WIN32 errors by having errors specific to &nbsp;//<br>// these APIs. Besides these errors, the APIs may return any of the WIN32 &nbsp; //<br>// errors. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define ERROR_BASE &nbsp;23000<br><br>#define PFERROR_NO_PF_INTERFACE &nbsp; &nbsp;(ERROR_BASE + 0) &nbsp; // never returned.<br>#define PFERROR_NO_FILTERS_GIVEN &nbsp; (ERROR_BASE + 1)<br>#define PFERROR_BUFFER_TOO_SMALL &nbsp; (ERROR_BASE + 2)<br>#define ERROR_IPV6_NOT_IMPLEMENTED (ERROR_BASE + 3)<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// The API prototypes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfCreateInterface(<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwName,<br>&nbsp; &nbsp; PFFORWARD_ACTION inAction,<br>&nbsp; &nbsp; PFFORWARD_ACTION outAction,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bUseLog,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bMustBeUnique,<br>&nbsp; &nbsp; INTERFACE_HANDLE *ppInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfDeleteInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE pInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfAddFiltersToInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp; &nbsp;ih,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cInFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltIn,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cOutFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltOut,<br>&nbsp; &nbsp; PFILTER_HANDLE &nbsp; &nbsp; &nbsp; &nbsp;pfHandle<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveFiltersFromInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp; &nbsp;ih,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cInFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltIn,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cOutFilters,<br>&nbsp; &nbsp; PPF_FILTER_DESCRIPTOR pfiltOut<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveFilterHandles(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cFilters,<br>&nbsp; &nbsp; PFILTER_HANDLE &nbsp; &nbsp; pvHandles<br>&nbsp; &nbsp; );<br><br><br>PFAPIENTRY<br>PfUnBindInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfBindInterfaceToIndex(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dwIndex,<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; &nbsp; &nbsp; pfatLinkType,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LinkIPAddress<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfBindInterfaceToIPAddress(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PFADDRESSTYPE &nbsp; &nbsp; &nbsp; pfatType,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IPAddress<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRebindFilters(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PPF_LATEBIND_INFO &nbsp; pLateBindInfo<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfAddGlobalFilterToInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; GLOBAL_FILTER &nbsp; &nbsp; &nbsp;gfFilter<br>&nbsp; &nbsp; );<br><br>PFAPIENTRY<br>PfRemoveGlobalFilterFromInterface(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInterface,<br>&nbsp; &nbsp; GLOBAL_FILTER &nbsp; &nbsp; &nbsp;gfFilter<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Log APIs. Note that there is at most one log and it must be created &nbsp; &nbsp; &nbsp;//<br>// before any interface needing it is created. There is no way to set a &nbsp; &nbsp; //<br>// log onto an existing interface. The log can be applied to any or all of &nbsp;//<br>// the interfaces. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfMakeLog(<br>&nbsp; &nbsp; HANDLE &nbsp;hEvent<br>&nbsp; &nbsp; );<br><br>//<br>// Provide a buffer, and notification parameters, and get back<br>// the old buffer and status.<br>//<br><br>PFAPIENTRY<br>PfSetLogBuffer(<br>&nbsp; &nbsp; PBYTE &nbsp; pbBuffer,<br>&nbsp; &nbsp; DWORD &nbsp; dwSize,<br>&nbsp; &nbsp; DWORD &nbsp; dwThreshold,<br>&nbsp; &nbsp; DWORD &nbsp; dwEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwLoggedEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwLostEntries,<br>&nbsp; &nbsp; PDWORD &nbsp;pdwSizeUsed<br>&nbsp; &nbsp; );<br><br>//<br>// Doing this will disable the log on any of the interfaces. But if<br>// an interface was created with the log, the actual log will not be<br>// completely deleted until that interface is deleted. This is a small<br>// point, but it might explain a mystery or two.<br>//<br><br>PFAPIENTRY<br>PfDeleteLog(<br>&nbsp; &nbsp; VOID<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Get statistics. Note pdwBufferSize in an IN/OUT parameter. If &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// ERROR_INSUFFICIENT_BUFFER is returned, the common statistics are &nbsp; &nbsp; &nbsp; &nbsp; //<br>// available and the correct byte count is in *pdwBufferSize. If only the &nbsp; //<br>// interface statistics are needed, provide a buffer of size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// PF_INTERFACE_STATS only. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// If the filter descriptions are also needed, then supply a large buffer, &nbsp;//<br>// or use the returned count from the first call to allocate a buffer of &nbsp; &nbsp;//<br>// sufficient size. Note that for a shared interface, this second call may &nbsp;//<br>// fail with ERROR_INSUFFICIENT_BUFFER. This can happen if the other &nbsp; &nbsp; &nbsp; &nbsp;//<br>// sharers add filters in the interim. This should not happen for a UNIQUE &nbsp;//<br>// interface. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>PFAPIENTRY<br>PfGetInterfaceStatistics(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; &nbsp;pInterface,<br>&nbsp; &nbsp; PPF_INTERFACE_STATS ppfStats,<br>&nbsp; &nbsp; PDWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwBufferSize,<br>&nbsp; &nbsp; BOOL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fResetCounters<br>&nbsp; &nbsp; );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// Test a packet. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// This call will evaluate the packet against the given interfaces &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>// and return the filtering action. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br>// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfTestPacket(<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pInInterface &nbsp;OPTIONAL,<br>&nbsp; &nbsp; INTERFACE_HANDLE &nbsp; pOutInterface OPTIONAL,<br>&nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cBytes,<br>&nbsp; &nbsp; PBYTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pbPacket,<br>&nbsp; &nbsp; PPFFORWARD_ACTION &nbsp;ppAction<br>&nbsp; &nbsp; );<br><br><br>#endif
 
unit fltdefs;<br>////////////////////////////////////////////////////////////////////////////////<br>//<br>// &nbsp; Delphi conversion of fltdefs.h for use with the IPHLPAPI.DLL<br>//<br>////////////////////////////////////////////////////////////////////////////////<br>interface<br><br>uses<br>&nbsp; Windows;<br><br>const<br>&nbsp; IPHLPAPI &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;'IPHLPAPI.DLL';<br><br>// Byte array<br>type<br>&nbsp; TByteArray &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;Array [0..Pred(MaxInt)] of Byte;<br>&nbsp; PByteArray &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;^TByteArray;<br><br>// Data types<br>type<br>&nbsp; FILTER_HANDLE &nbsp; &nbsp; = &nbsp;Pointer;<br>&nbsp; PFILTER_HANDLE &nbsp; &nbsp;= &nbsp;^FILTER_HANDLE;<br>&nbsp; INTERFACE_HANDLE &nbsp;= &nbsp;Pointer;<br>&nbsp; PINTERFACE_HANDLE = &nbsp;^INTERFACE_HANDLE;<br><br>// GlobalFilter enumeration<br>const<br>&nbsp; GF_FRAGMENTS &nbsp; &nbsp; &nbsp;= &nbsp;2;<br>&nbsp; GF_STRONGHOST &nbsp; &nbsp; = &nbsp;8;<br>&nbsp; GF_FRAGCACHE &nbsp; &nbsp; &nbsp;= &nbsp;9;<br><br>type<br>&nbsp; GLOBAL_FILTER &nbsp; &nbsp; = &nbsp;Integer;<br>&nbsp; PGLOBAL_FILTER &nbsp; &nbsp;= &nbsp;^GLOBAL_FILTER;<br><br>// PFAddressType enumeration<br>const<br>&nbsp; PF_IPV4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;0;<br>&nbsp; PF_IPV6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;1;<br><br>type<br>&nbsp; PFADDRESSTYPE &nbsp; &nbsp; = &nbsp;Integer;<br>&nbsp; PPFADDRESSTYPE &nbsp; &nbsp;= &nbsp;^PFADDRESSTYPE;<br><br>// PFForwardAction enumeration<br>const<br>&nbsp; PF_ACTION_FORWARD = &nbsp;0;<br>&nbsp; PF_ACTION_DROP &nbsp; &nbsp;= &nbsp;1;<br><br>type<br>&nbsp; PFFORWARD_ACTION &nbsp;= &nbsp;Integer;<br>&nbsp; PPFFORWARD_ACTION = &nbsp;^PPFFORWARD_ACTION;<br><br>// PFFrameType enumeration<br>const<br>&nbsp; PFFT_FILTER &nbsp; &nbsp; &nbsp; = &nbsp;1;<br>&nbsp; PFFT_FRAG &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;2;<br>&nbsp; PFFT_SPOOF &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;3;<br><br>type<br>&nbsp; PFFRAMETYPE &nbsp; &nbsp; &nbsp; = &nbsp;Integer;<br>&nbsp; PPFFRAMETYPE &nbsp; &nbsp; &nbsp;= &nbsp;^PFFRAMETYPE;<br><br>type<br>&nbsp; _PF_FILTER_DESCRIPTOR &nbsp; = &nbsp;packed record<br>&nbsp; &nbsp; &nbsp;dwFilterFlags: &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwRule: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;pfatType: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PFADDRESSTYPE;<br>&nbsp; &nbsp; &nbsp;SrcAddr: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;SrcMask: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;DstAddr: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;DstMask: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;dwProtocol: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;fLateBound: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;wSrcPort: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Word;<br>&nbsp; &nbsp; &nbsp;wDstPort: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Word;<br>&nbsp; &nbsp; &nbsp;wSrcPortHighRange: &nbsp; Word;<br>&nbsp; &nbsp; &nbsp;wDstPortHighRange: &nbsp; Word;<br>&nbsp; end;<br>&nbsp; PF_FILTER_DESCRIPTOR &nbsp; &nbsp;= &nbsp;_PF_FILTER_DESCRIPTOR;<br>&nbsp; PPF_FILTER_DESCRIPTOR &nbsp; = &nbsp;^PF_FILTER_DESCRIPTOR;<br><br>type<br>&nbsp; _PF_FILTER_STATS &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;packed record<br>&nbsp; &nbsp; &nbsp;dwNumPacketsFiltered:DWORD;<br>&nbsp; &nbsp; &nbsp;info: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PF_FILTER_DESCRIPTOR;<br>&nbsp; end;<br>&nbsp; PF_FILTER_STATS &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;_PF_FILTER_STATS;<br>&nbsp; PPF_FILTER_STATS &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;^PF_FILTER_STATS;<br><br>type<br>&nbsp; _PF_INTERFACE_STATS &nbsp; &nbsp; = &nbsp;packed record<br>&nbsp; &nbsp; &nbsp;pvDriverContext: &nbsp; &nbsp; Pointer;<br>&nbsp; &nbsp; &nbsp;dwFlags: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwInDrops: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwOutDrops: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;eaInAction: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PFFORWARD_ACTION;<br>&nbsp; &nbsp; &nbsp;eaOutAction: &nbsp; &nbsp; &nbsp; &nbsp; PFFORWARD_ACTION;<br>&nbsp; &nbsp; &nbsp;dwNumInFilters: &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;dwNumOutFilters: &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwFrag: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;dwSpoof: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwReserved1: &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwReserved2: &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;liSyn: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LARGE_INTEGER;<br>&nbsp; &nbsp; &nbsp;liTotalLogged: &nbsp; &nbsp; &nbsp; LARGE_INTEGER;<br>&nbsp; &nbsp; &nbsp;dwLostLogEntries: &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;FilterInfo: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Array [0..0] of PF_FILTER_STATS;<br>&nbsp; end;<br>&nbsp; PF_INTERFACE_STATS &nbsp; &nbsp; &nbsp;= &nbsp;_PF_INTERFACE_STATS;<br>&nbsp; PPF_INTERFACE_STATS &nbsp; &nbsp; = &nbsp;^PF_INTERFACE_STATS;<br><br>type<br>&nbsp; _PF_LATEBIND_INFO &nbsp; &nbsp; &nbsp; = &nbsp;packed record<br>&nbsp; &nbsp; &nbsp;SrcAddr: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;DstAddr: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp;Mask: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PByteArray;<br>&nbsp; end;<br>&nbsp; PF_LATEBIND_INFO &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;_PF_LATEBIND_INFO;<br>&nbsp; PPF_LATEBIND_INFO &nbsp; &nbsp; &nbsp; = &nbsp;^PF_LATEBIND_INFO;<br><br>type<br>&nbsp; _PFLOGFRAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;packed record<br>&nbsp; &nbsp; &nbsp;Timestamp: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LARGE_INTEGER;<br>&nbsp; &nbsp; &nbsp;pfeTypeOfFrame: &nbsp; &nbsp; &nbsp;PFFRAMETYPE;<br>&nbsp; &nbsp; &nbsp;dwTotalSizeUsed: &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwFilterRule: &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp;wSizeOfAdditionalData:Word;<br>&nbsp; &nbsp; &nbsp;wSizeOfIpHeader: &nbsp; &nbsp; Word;<br>&nbsp; &nbsp; &nbsp;dwInterfaceName: &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;dwIPIndex: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp;bPacketData: &nbsp; &nbsp; &nbsp; &nbsp; Array [0..0] of Byte;<br>&nbsp; end;<br>&nbsp; PFLOGFRAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;_PFLOGFRAME;<br>&nbsp; PPFLOGFRAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;^PFLOGFRAME;<br><br>const<br>&nbsp; FILTER_PROTO_ANY &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;$00;<br>&nbsp; FILTER_PROTO_ICMP &nbsp; &nbsp; &nbsp; = &nbsp;$01;<br>&nbsp; FILTER_PROTO_TCP &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;$06;<br>&nbsp; FILTER_PROTO_UDP &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;$11;<br>&nbsp; FILTER_TCPUDP_PORT_ANY &nbsp;= &nbsp;$00;<br><br>const<br>&nbsp; FILTER_ICMP_TYPE_ANY &nbsp; &nbsp;= &nbsp;$FF;<br>&nbsp; FILTER_ICMP_CODE_ANY &nbsp; &nbsp;= &nbsp;$FF;<br><br>const<br>&nbsp; FD_FLAGS_NOSYN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;$01;<br>&nbsp; FD_FLAGS_ALLFLAGS &nbsp; &nbsp; &nbsp; = &nbsp;FD_FLAGS_NOSYN;<br><br>const<br>&nbsp; LB_SRC_ADDR_USE_SRCADDR_FLAG &nbsp;= &nbsp;$00000001;<br>&nbsp; LB_SRC_ADDR_USE_DSTADDR_FLAG &nbsp;= &nbsp;$00000002;<br>&nbsp; LB_DST_ADDR_USE_SRCADDR_FLAG &nbsp;= &nbsp;$00000004;<br>&nbsp; LB_DST_ADDR_USE_DSTADDR_FLAG &nbsp;= &nbsp;$00000008;<br>&nbsp; LB_SRC_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;$00000010;<br>&nbsp; LB_DST_MASK_LATE_FLAG &nbsp; &nbsp; &nbsp; &nbsp; = &nbsp;$00000020;<br><br>const<br>&nbsp; ERROR_BASE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= &nbsp;23000;<br>&nbsp; PFERROR_NO_PF_INTERFACE &nbsp; &nbsp; &nbsp; = &nbsp;(ERROR_BASE + 0); // never returned.<br>&nbsp; PFERROR_NO_FILTERS_GIVEN &nbsp; &nbsp; &nbsp;= &nbsp;(ERROR_BASE + 1);<br>&nbsp; PFERROR_BUFFER_TOO_SMALL &nbsp; &nbsp; &nbsp;= &nbsp;(ERROR_BASE + 2);<br>&nbsp; ERROR_IPV6_NOT_IMPLEMENTED &nbsp; &nbsp;= &nbsp;(ERROR_BASE + 3);<br><br>////////////////////////////////////////////////////////////////////////////////<br>//<br>// Filter functions exported by IPHLPAPI<br>//<br>////////////////////////////////////////////////////////////////////////////////<br>function &nbsp; PfCreateInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwName: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;inAction: &nbsp; &nbsp; &nbsp; &nbsp; PFFORWARD_ACTION;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;outAction: &nbsp; &nbsp; &nbsp; &nbsp;PFFORWARD_ACTION;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bUseLog: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BOOL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bMustBeUnique: &nbsp; &nbsp;BOOL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var ppInterface: &nbsp;INTERFACE_HANDLE): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfCreateInterface@24';<br><br>function &nbsp; PfDeleteInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfDeleteInterface@4';<br><br>function &nbsp; PfAddFiltersToInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ih: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cInFilters: &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfiltIn: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PPF_FILTER_DESCRIPTOR;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cOutFilters: &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfiltOut: &nbsp; &nbsp; &nbsp; &nbsp; PPF_FILTER_DESCRIPTOR;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfHandle: &nbsp; &nbsp; &nbsp; &nbsp; PFILTER_HANDLE): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';<br><br>function &nbsp; PfRemoveFiltersFromInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ih: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cInFilters: &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfiltIn: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PPF_FILTER_DESCRIPTOR;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cOutFilters: &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfiltOut: &nbsp; &nbsp; &nbsp; &nbsp; PPF_FILTER_DESCRIPTOR): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';<br><br>function &nbsp; PfRemoveFilterHandles(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cFilters: &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pvHandles: &nbsp; &nbsp; &nbsp; &nbsp;PFILTER_HANDLE): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';<br><br>function &nbsp; PfUnBindInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfUnBindInterface@4';<br><br>function &nbsp; PfBindInterfaceToIndex(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwIndex: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfatLinkType: &nbsp; &nbsp; PFADDRESSTYPE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LinkIPAddress: &nbsp; &nbsp;PByteArray): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';<br><br>function &nbsp; PfBindInterfaceToIPAddress(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pfatLinkType: &nbsp; &nbsp; PFADDRESSTYPE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IPAddress: &nbsp; &nbsp; &nbsp; &nbsp;PByteArray): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';<br><br>function &nbsp; PfRebindFilters(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pLateBindInfo: &nbsp; &nbsp;PPF_LATEBIND_INFO): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfRebindFilters@8';<br><br>function &nbsp; PfAddGlobalFilterToInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gfFilter: &nbsp; &nbsp; &nbsp; &nbsp; GLOBAL_FILTER): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';<br><br>function &nbsp; PfRemoveGlobalFilterFromInterface(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gfFilter: &nbsp; &nbsp; &nbsp; &nbsp; GLOBAL_FILTER): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';<br><br>////////////////////////////////////////////////////////////////////////////////<br>//<br>// Log APIs. Note that there is at most one log and it must be created<br>// before any interface needing it is created. There is no way to set a<br>// log onto an existing interface. The log can be applied to any or all of<br>// the interfaces.<br>//<br>///////////////////////////////////////////////////////////////////////<br>function &nbsp; PfMakeLog(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hEvent: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; THandle): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfMakeLog@4';<br><br>function &nbsp; PfSetLogBuffer(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pbBuffer: &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwSize: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwThreshold: &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwEntries: &nbsp; &nbsp; &nbsp; &nbsp;DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwLoggedEntries: PDWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwLostEntries: &nbsp; PDWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwSizeUsed: &nbsp; &nbsp; &nbsp;PDWORD): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';<br><br>function &nbsp; PfDeleteLog(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfDeleteLog@0';<br><br>////////////////////////////////////////////////////////////////////////////////<br>//<br>// Get statistics. Note pdwBufferSize in an IN/OUT parameter. If<br>// ERROR_INSUFFICIENT_BUFFER is returned, the common statistics are<br>// available and the correct byte count is in *pdwBufferSize. If only the<br>// interface statistics are needed, provide a buffer of size<br>// PF_INTERFACE_STATS only. If the filter descriptions are also needed,<br>// then supply a large buffer, or use the returned count from the first call<br>// to allocate a buffer of sufficient size. Note that for a shared interface,<br>// this second call may fail with ERROR_INSUFFICIENT_BUFFER. This can happen<br>// if the other sharers add filters in the interim. This should not happen for<br>// a UNIQUE interface.<br>//<br>////////////////////////////////////////////////////////////////////////////////<br>function &nbsp; PfGetInterfaceStatistics(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInterface: &nbsp; &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ppfStats: &nbsp; &nbsp; &nbsp; &nbsp; PPF_INTERFACE_STATS;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pdwBufferSize: &nbsp; &nbsp;PDWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fResetCounters: &nbsp; BOOL): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';<br><br>////////////////////////////////////////////////////////////////////////////////<br>//<br>// Test a packet. This call will evaluate the packet against the given<br>// interfaces and return the filtering action.<br>//<br>////////////////////////////////////////////////////////////////////////////////<br>function &nbsp; PfTestPacket(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pInInterface: &nbsp; &nbsp; INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pOutInterface: &nbsp; &nbsp;INTERFACE_HANDLE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cBytes: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pbPacket: &nbsp; &nbsp; &nbsp; &nbsp; PByteArray;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ppAction: &nbsp; &nbsp; &nbsp; &nbsp; PPFFORWARD_ACTION): DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stdcall; external IPHLPAPI name '_PfTestPacket@20';<br><br>implementation<br><br>end.<br><br><br>(********)<br>//uses winsock, fltdefs;<br>procedure main();<br>const<br>&nbsp; localIp : array[0..3] of BYTE = (192,168,0,2);<br>&nbsp; FILTER_TCPUDP_PORT_ANY : WORD = $0000;<br>&nbsp; FD_FLAGS_NOSYN &nbsp; &nbsp; &nbsp;= $1;<br>var<br>&nbsp; hInterface : INTERFACE_HANDLE;<br>&nbsp; fHandle : FILTER_HANDLE;<br>&nbsp; inFilter : PF_FILTER_DESCRIPTOR;<br>&nbsp; FILTER_PROTO_TCP : DWORD;<br>&nbsp; dwSrcMask : DWORD;<br>begin<br>&nbsp; &nbsp; FILTER_PROTO_TCP := MAKELONG(MAKEWORD(($06),$00),$00000);<br>&nbsp; &nbsp; dwSrcMask := $FFFFFFFF;<br><br>&nbsp; &nbsp; PfCreateInterface(0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PF_ACTION_DROP,//PF_ACTION_FORWARD,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PF_ACTION_DROP,//PF_ACTION_FORWARD,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FALSE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRUE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hInterface);<br><br>&nbsp; &nbsp; PfBindInterfaceToIPAddress(hInterface, PF_IPV4, @localIp);<br><br>&nbsp; &nbsp; inFilter.dwFilterFlags := FD_FLAGS_NOSYN;<br>&nbsp; &nbsp; inFilter.dwRule := 0;<br>&nbsp; &nbsp; inFilter.pfatType := PF_IPV4;<br>&nbsp; &nbsp; inFilter.SrcAddr := @localIp;<br>&nbsp; &nbsp; inFilter.SrcMask := @dwSrcMask;<br>&nbsp; &nbsp; inFilter.wSrcPort := FILTER_TCPUDP_PORT_ANY;<br>&nbsp; &nbsp; inFilter.wSrcPortHighRange := FILTER_TCPUDP_PORT_ANY;<br>&nbsp; &nbsp; inFilter.DstAddr := nil;<br>&nbsp; &nbsp; inFilter.DstMask := nil;<br>&nbsp; &nbsp; inFilter.wDstPort := 80;<br>&nbsp; &nbsp; inFilter.wDstPortHighRange := 80;<br>&nbsp; &nbsp; inFilter.dwProtocol := FILTER_PROTO_TCP;<br>&nbsp; &nbsp; PfAddFiltersToInterface(hInterface, 1, @inFilter, 0, nil, @fHandle);<br>&nbsp; &nbsp; PfRemoveFilterHandles(hInterface, 1, @fHandle);<br>&nbsp; &nbsp; PfUnBindInterface(hInterface);<br>&nbsp; &nbsp; PfDeleteInterface(hInterface);<br>end;
 
amli到这里来接剩下的200分<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1613061<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1498753<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1101741
 

Similar threads

后退
顶部