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 Microsoft Corporation<br><br>Module Name:<br><br> fltdefs.h<br><br>Abstract:<br><br> Definitions for the WIN32 filter APIs<br><br>Author:<br><br> 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 > 1000<br>#pragma once<br>#endif<br><br>typedef PVOID FILTER_HANDLE, *PFILTER_HANDLE;<br>typedef PVOID 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> GF_FRAGMENTS = 2, // check consistency of fragments<br> GF_STRONGHOST = 8, // check destination address of input frames<br> GF_FRAGCACHE = 9 // check fragments from cache<br>} GLOBAL_FILTER, *PGLOBAL_FILTER;<br><br>typedef enum _PfForwardAction<br>{<br> PF_ACTION_FORWARD = 0,<br> PF_ACTION_DROP<br>} PFFORWARD_ACTION, *PPFFORWARD_ACTION;<br><br>typedef enum _PfAddresType<br>{<br> PF_IPV4,<br> PF_IPV6<br>} PFADDRESSTYPE, *PPFADDRESSTYPE;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// The constants that should be used to set up the FILTER_INFO_STRUCTURE //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTER_PROTO(ProtoId) MAKELONG(MAKEWORD((ProtoId),0x00),0x00000)<br><br>#define FILTER_PROTO_ANY FILTER_PROTO(0x00)<br>#define FILTER_PROTO_ICMP FILTER_PROTO(0x01)<br>#define FILTER_PROTO_TCP FILTER_PROTO(0x06)<br>#define FILTER_PROTO_UDP FILTER_PROTO(0x11)<br><br>#define FILTER_TCPUDP_PORT_ANY (WORD)0x0000<br><br>#define FILTER_ICMP_TYPE_ANY (BYTE)0xff<br>#define FILTER_ICMP_CODE_ANY (BYTE)0xff<br><br>typedef struct _PF_FILTER_DESCRIPTOR<br>{<br> DWORD dwFilterFlags; // see below<br> DWORD dwRule; // copied into the log when appropriate<br> PFADDRESSTYPE pfatType;<br> PBYTE SrcAddr;<br> PBYTE SrcMask;<br> PBYTE DstAddr;<br> PBYTE DstMask;<br> DWORD dwProtocol;<br> DWORD fLateBound;<br> WORD wSrcPort;<br> WORD wDstPort;<br> WORD wSrcPortHighRange;<br> WORD wDstPortHighRange;<br>}PF_FILTER_DESCRIPTOR, *PPF_FILTER_DESCRIPTOR;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// Structure for PfGetInterfaceStatistics //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef struct _PF_FILTER_STATS<br>{<br> DWORD dwNumPacketsFiltered;<br> PF_FILTER_DESCRIPTOR info;<br>}PF_FILTER_STATS, *PPF_FILTER_STATS;<br><br>typedef struct _PF_INTERFACE_STATS<br>{<br> PVOID pvDriverContext;<br> DWORD dwFlags; // none as yet (28-Sept-1997)<br> DWORD dwInDrops;<br> DWORD dwOutDrops;<br> PFFORWARD_ACTION eaInAction;<br> PFFORWARD_ACTION eaOutAction;<br> DWORD dwNumInFilters;<br> DWORD dwNumOutFilters;<br> DWORD dwFrag;<br> DWORD dwSpoof;<br> DWORD dwReserved1;<br> DWORD dwReserved2;<br> LARGE_INTEGER liSYN;<br> LARGE_INTEGER liTotalLogged;<br> DWORD dwLostLogEntries;<br> PF_FILTER_STATS FilterInfo[1];<br>} PF_INTERFACE_STATS, *PPF_INTERFACE_STATS;<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// The number of bytes starting at SrcAddr. If you add something to the //<br>// structure make sure this remains valid //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>#define FILTERSIZE /<br> (sizeof(PF_FILTER_DESCRIPTOR) - /<br> (DWORD)(&((PPF_FILTER_DESCRIPTOR)0)->SrcAddr))<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// Flags for PF_FILTER_DESCRIPTOR //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>//<br>// Disallows incoming SYN<br>//<br><br>#define FD_FLAGS_NOSYN 0x1<br><br>//<br>// All legal flags<br>//<br><br>#define FD_FLAGS_ALLFLAGS FD_FLAGS_NOSYN<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// Late bound defs. Go in fLateBound in a PF_FILTER_DESCRIPTOR and //<br>// describe which other fields of the filter are affected by a //<br>// PfRebindFilters call. In general such filters are on WAN interfaces //<br>// where one or the other address may change as the connection is //<br>// reconnected. //<br>// The assumption is that such interfaces HAVE ONLY ONE ADDRESS. //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define LB_SRC_ADDR_USE_SRCADDR_FLAG 0x00000001<br>#define LB_SRC_ADDR_USE_DSTADDR_FLAG 0x00000002<br>#define LB_DST_ADDR_USE_SRCADDR_FLAG 0x00000004<br>#define LB_DST_ADDR_USE_DSTADDR_FLAG 0x00000008<br>#define LB_SRC_MASK_LATE_FLAG 0x00000010<br>#define LB_DST_MASK_LATE_FLAG 0x00000020<br><br>typedef struct _PF_LATEBIND_INFO<br>{<br> PBYTE SrcAddr;<br> PBYTE DstAddr;<br> PBYTE Mask;<br>}PF_LATEBIND_INFO, *PPF_LATEBIND_INFO;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// The format of a logged frame and defs for it. //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>typedef enum _PfFrameType<br>{<br> PFFT_FILTER = 1, // a filter violation<br> PFFT_FRAG = 2, // bad fragment<br> PFFT_SPOOF = 3 // strong host failure<br>} PFFRAMETYPE, *PPFFRAMETYPE;<br><br>typedef struct _pfLogFrame<br>{<br> LARGE_INTEGER Timestamp;<br> PFFRAMETYPE pfeTypeOfFrame;<br> DWORD dwTotalSizeUsed; // used to find the next frame<br> DWORD dwFilterRule; // from the filter<br> WORD wSizeOfAdditionalData;<br> WORD wSizeOfIpHeader;<br> DWORD dwInterfaceName; // the name of the interface<br> DWORD dwIPIndex;<br> BYTE bPacketData[1]; // the frame. wsizeOfIpHeader<br> // and wsizeOfAdditionalData<br> // describe this<br>} PFLOGFRAME, *PPFLOGFRAME;<br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// Error codes. These extend the WIN32 errors by having errors specific to //<br>// these APIs. Besides these errors, the APIs may return any of the WIN32 //<br>// errors. //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>#define ERROR_BASE 23000<br><br>#define PFERROR_NO_PF_INTERFACE (ERROR_BASE + 0) // never returned.<br>#define PFERROR_NO_FILTERS_GIVEN (ERROR_BASE + 1)<br>#define PFERROR_BUFFER_TOO_SMALL (ERROR_BASE + 2)<br>#define ERROR_IPV6_NOT_IMPLEMENTED (ERROR_BASE + 3)<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// The API prototypes //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfCreateInterface(<br> DWORD dwName,<br> PFFORWARD_ACTION inAction,<br> PFFORWARD_ACTION outAction,<br> BOOL bUseLog,<br> BOOL bMustBeUnique,<br> INTERFACE_HANDLE *ppInterface<br> );<br><br>PFAPIENTRY<br>PfDeleteInterface(<br> INTERFACE_HANDLE pInterface<br> );<br><br>PFAPIENTRY<br>PfAddFiltersToInterface(<br> INTERFACE_HANDLE ih,<br> DWORD cInFilters,<br> PPF_FILTER_DESCRIPTOR pfiltIn,<br> DWORD cOutFilters,<br> PPF_FILTER_DESCRIPTOR pfiltOut,<br> PFILTER_HANDLE pfHandle<br> );<br><br>PFAPIENTRY<br>PfRemoveFiltersFromInterface(<br> INTERFACE_HANDLE ih,<br> DWORD cInFilters,<br> PPF_FILTER_DESCRIPTOR pfiltIn,<br> DWORD cOutFilters,<br> PPF_FILTER_DESCRIPTOR pfiltOut<br> );<br><br>PFAPIENTRY<br>PfRemoveFilterHandles(<br> INTERFACE_HANDLE pInterface,<br> DWORD cFilters,<br> PFILTER_HANDLE pvHandles<br> );<br><br><br>PFAPIENTRY<br>PfUnBindInterface(<br> INTERFACE_HANDLE pInterface<br> );<br><br>PFAPIENTRY<br>PfBindInterfaceToIndex(<br> INTERFACE_HANDLE pInterface,<br> DWORD dwIndex,<br> PFADDRESSTYPE pfatLinkType,<br> PBYTE LinkIPAddress<br> );<br><br>PFAPIENTRY<br>PfBindInterfaceToIPAddress(<br> INTERFACE_HANDLE pInterface,<br> PFADDRESSTYPE pfatType,<br> PBYTE IPAddress<br> );<br><br>PFAPIENTRY<br>PfRebindFilters(<br> INTERFACE_HANDLE pInterface,<br> PPF_LATEBIND_INFO pLateBindInfo<br> );<br><br>PFAPIENTRY<br>PfAddGlobalFilterToInterface(<br> INTERFACE_HANDLE pInterface,<br> GLOBAL_FILTER gfFilter<br> );<br><br>PFAPIENTRY<br>PfRemoveGlobalFilterFromInterface(<br> INTERFACE_HANDLE pInterface,<br> GLOBAL_FILTER gfFilter<br> );<br><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><br>PFAPIENTRY<br>PfMakeLog(<br> HANDLE hEvent<br> );<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> PBYTE pbBuffer,<br> DWORD dwSize,<br> DWORD dwThreshold,<br> DWORD dwEntries,<br> PDWORD pdwLoggedEntries,<br> PDWORD pdwLostEntries,<br> PDWORD pdwSizeUsed<br> );<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> VOID<br> );<br><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. //<br>// If the filter descriptions are also needed, then supply a large buffer, //<br>// or use the returned count from the first call to allocate a buffer of //<br>// sufficient size. Note that for a shared interface, this second call may //<br>// fail with ERROR_INSUFFICIENT_BUFFER. This can happen if the other //<br>// sharers add filters in the interim. This should not happen for a UNIQUE //<br>// interface. //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br><br>PFAPIENTRY<br>PfGetInterfaceStatistics(<br> INTERFACE_HANDLE pInterface,<br> PPF_INTERFACE_STATS ppfStats,<br> PDWORD pdwBufferSize,<br> BOOL fResetCounters<br> );<br><br><br>//////////////////////////////////////////////////////////////////////////////<br>// //<br>// Test a packet. //<br>// This call will evaluate the packet against the given interfaces //<br>// and return the filtering action. //<br>// //<br>//////////////////////////////////////////////////////////////////////////////<br><br>PFAPIENTRY<br>PfTestPacket(<br> INTERFACE_HANDLE pInInterface OPTIONAL,<br> INTERFACE_HANDLE pOutInterface OPTIONAL,<br> DWORD cBytes,<br> PBYTE pbPacket,<br> PPFFORWARD_ACTION ppAction<br> );<br><br><br>#endif