Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

fltdefs.h source, used by Russell (rllibby)

Avatar of systan
systanFlag for Philippines asked on
CDelphiProject Management
19 Comments1 Solution869 ViewsLast Modified:
http://www.ndis.com/papers/winpktfilter.htm#W2KPktFilterInterface
The source was remove in ndis papers link;
Where could I find it?  The link.

And I'm also asking;
What <header> shall I convert to run a firewall in vista or 7 from delphi7/9?
Where is the source <?.h>  The link.

Thanks.
//This was the delphi convertion of fltdefs.h, but where is the source?

unit fltdefs;
////////////////////////////////////////////////////////////////////////////////
//
//   Delphi conversion of fltdefs.h for use with the IPHLPAPI.DLL
//
////////////////////////////////////////////////////////////////////////////////
interface

uses
  Windows;

const
  IPHLPAPI          =  'IPHLPAPI.DLL';

// Byte array
type
  TByteArray        =  Array [0..Pred(MaxInt)] of Byte;
  PByteArray        =  ^TByteArray;

// Data types
type
  FILTER_HANDLE     =  Pointer;
  PFILTER_HANDLE    =  ^FILTER_HANDLE;
  INTERFACE_HANDLE  =  Pointer;
  PINTERFACE_HANDLE =  ^INTERFACE_HANDLE;

// GlobalFilter enumeration
const
  GF_FRAGMENTS      =  2;
  GF_STRONGHOST     =  8;
  GF_FRAGCACHE      =  9;

type
  GLOBAL_FILTER     =  Integer;
  PGLOBAL_FILTER    =  ^GLOBAL_FILTER;

// PFAddressType enumeration
const
  PF_IPV4           =  0;
  PF_IPV6           =  1;

type
  PFADDRESSTYPE     =  Integer;
  PPFADDRESSTYPE    =  ^PFADDRESSTYPE;

// PFForwardAction enumeration
const
  PF_ACTION_FORWARD =  0;
  PF_ACTION_DROP    =  1;

type
  PFFORWARD_ACTION  =  Integer;
  PPFFORWARD_ACTION =  ^PPFFORWARD_ACTION;

// PFFrameType enumeration
const
  PFFT_FILTER       =  1;
  PFFT_FRAG         =  2;
  PFFT_SPOOF        =  3;

type
  PFFRAMETYPE       =  Integer;
  PPFFRAMETYPE      =  ^PFFRAMETYPE;

type
  _PF_FILTER_DESCRIPTOR   =  packed record
     dwFilterFlags:       DWORD;
     dwRule:              DWORD;
     pfatType:            PFADDRESSTYPE;
     SrcAddr:             PByteArray;
     SrcMask:             PByteArray;
     DstAddr:             PByteArray;
     DstMask:             PByteArray;
     dwProtocol:          DWORD;
     fLateBound:          DWORD;
     wSrcPort:            Word;
     wDstPort:            Word;
     wSrcPortHighRange:   Word;
     wDstPortHighRange:   Word;
  end;
  PF_FILTER_DESCRIPTOR    =  _PF_FILTER_DESCRIPTOR;
  PPF_FILTER_DESCRIPTOR   =  ^PF_FILTER_DESCRIPTOR;

type
  _PF_FILTER_STATS        =  packed record
     dwNumPacketsFiltered:DWORD;
     info:                PF_FILTER_DESCRIPTOR;
  end;
  PF_FILTER_STATS         =  _PF_FILTER_STATS;
  PPF_FILTER_STATS        =  ^PF_FILTER_STATS;

type
  _PF_INTERFACE_STATS     =  packed record
     pvDriverContext:     Pointer;
     dwFlags:             DWORD;
     dwInDrops:           DWORD;
     dwOutDrops:          DWORD;
     eaInAction:          PFFORWARD_ACTION;
     eaOutAction:         PFFORWARD_ACTION;
     dwNumInFilters:      DWORD;
     dwNumOutFilters:     DWORD;
     dwFrag:              DWORD;
     dwSpoof:             DWORD;
     dwReserved1:         DWORD;
     dwReserved2:         DWORD;
     liSyn:               LARGE_INTEGER;
     liTotalLogged:       LARGE_INTEGER;
     dwLostLogEntries:    DWORD;
     FilterInfo:          Array [0..0] of PF_FILTER_STATS;
  end;
  PF_INTERFACE_STATS      =  _PF_INTERFACE_STATS;
  PPF_INTERFACE_STATS     =  ^PF_INTERFACE_STATS;

type
  _PF_LATEBIND_INFO       =  packed record
     SrcAddr:             PByteArray;
     DstAddr:             PByteArray;
     Mask:                PByteArray;
  end;
  PF_LATEBIND_INFO        =  _PF_LATEBIND_INFO;
  PPF_LATEBIND_INFO       =  ^PF_LATEBIND_INFO;

type
  _PFLOGFRAME             =  packed record
     Timestamp:           LARGE_INTEGER;
     pfeTypeOfFrame:      PFFRAMETYPE;
     dwTotalSizeUsed:     DWORD;
     dwFilterRule:        DWORD;
     wSizeOfAdditionalData:Word;
     wSizeOfIpHeader:     Word;
     dwInterfaceName:     DWORD;
     dwIPIndex:           DWORD;
     bPacketData:         Array [0..0] of Byte;
  end;
  PFLOGFRAME              =  _PFLOGFRAME;
  PPFLOGFRAME             =  ^PFLOGFRAME;

const
  FILTER_PROTO_ANY        =  $00;
  FILTER_PROTO_ICMP       =  $01;
  FILTER_PROTO_TCP        =  $06;
  FILTER_PROTO_UDP        =  $11;
  FILTER_TCPUDP_PORT_ANY  =  $00;

const
  FILTER_ICMP_TYPE_ANY    =  $FF;
  FILTER_ICMP_CODE_ANY    =  $FF;

const
  FD_FLAGS_NOSYN          =  $01;
  FD_FLAGS_ALLFLAGS       =  FD_FLAGS_NOSYN;

const
  LB_SRC_ADDR_USE_SRCADDR_FLAG  =  $00000001;
  LB_SRC_ADDR_USE_DSTADDR_FLAG  =  $00000002;
  LB_DST_ADDR_USE_SRCADDR_FLAG  =  $00000004;
  LB_DST_ADDR_USE_DSTADDR_FLAG  =  $00000008;
  LB_SRC_MASK_LATE_FLAG         =  $00000010;
  LB_DST_MASK_LATE_FLAG         =  $00000020;

const
  ERROR_BASE                    =  23000;
  PFERROR_NO_PF_INTERFACE       =  (ERROR_BASE + 0); // never returned.
  PFERROR_NO_FILTERS_GIVEN      =  (ERROR_BASE + 1);
  PFERROR_BUFFER_TOO_SMALL      =  (ERROR_BASE + 2);
  ERROR_IPV6_NOT_IMPLEMENTED    =  (ERROR_BASE + 3);

////////////////////////////////////////////////////////////////////////////////
//
// Filter functions exported by IPHLPAPI
//
////////////////////////////////////////////////////////////////////////////////
function   PfCreateInterface(
           dwName:           DWORD;
           inAction:         PFFORWARD_ACTION;
           outAction:        PFFORWARD_ACTION;
           bUseLog:          BOOL;
           bMustBeUnique:    BOOL;
           var ppInterface:  INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfCreateInterface@24';

function   PfDeleteInterface(
           pInterface:       INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfDeleteInterface@4';

function   PfAddFiltersToInterface(
           ih:               INTERFACE_HANDLE;
           cInFilters:       DWORD;
           pfiltIn:          PPF_FILTER_DESCRIPTOR;
           cOutFilters:      DWORD;
           pfiltOut:         PPF_FILTER_DESCRIPTOR;
           pfHandle:         PFILTER_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';

function   PfRemoveFiltersFromInterface(
           ih:               INTERFACE_HANDLE;
           cInFilters:       DWORD;
           pfiltIn:          PPF_FILTER_DESCRIPTOR;
           cOutFilters:      DWORD;
           pfiltOut:         PPF_FILTER_DESCRIPTOR): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';

function   PfRemoveFilterHandles(
           pInterface:       INTERFACE_HANDLE;
           cFilters:         DWORD;
           pvHandles:        PFILTER_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';

function   PfUnBindInterface(
           pInterface:       INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfUnBindInterface@4';

function   PfBindInterfaceToIndex(
           pInterface:       INTERFACE_HANDLE;
           dwIndex:          DWORD;
           pfatLinkType:     PFADDRESSTYPE;
           LinkIPAddress:    PByteArray): DWORD;
           stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';

function   PfBindInterfaceToIPAddress(
           pInterface:       INTERFACE_HANDLE;
           pfatLinkType:     PFADDRESSTYPE;
           IPAddress:        PByteArray): DWORD;
           stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';

function   PfRebindFilters(
           pInterface:       INTERFACE_HANDLE;
           pLateBindInfo:    PPF_LATEBIND_INFO): DWORD;
           stdcall; external IPHLPAPI name '_PfRebindFilters@8';

function   PfAddGlobalFilterToInterface(
           pInterface:       INTERFACE_HANDLE;
           gfFilter:         GLOBAL_FILTER): DWORD;
           stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';

function   PfRemoveGlobalFilterFromInterface(
           pInterface:       INTERFACE_HANDLE;
           gfFilter:         GLOBAL_FILTER): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';

////////////////////////////////////////////////////////////////////////////////
//
// Log APIs. Note that there is at most one log and it must be created
// before any interface needing it is created. There is no way to set a
// log onto an existing interface. The log can be applied to any or all of
// the interfaces.
//
///////////////////////////////////////////////////////////////////////
function   PfMakeLog(
           hEvent:           THandle): DWORD;
           stdcall; external IPHLPAPI name '_PfMakeLog@4';

function   PfSetLogBuffer(
           pbBuffer:         PByteArray;
           dwSize:           DWORD;
           dwThreshold:      DWORD;
           dwEntries:        DWORD;
           pdwLoggedEntries: PDWORD;
           pdwLostEntries:   PDWORD;
           pdwSizeUsed:      PDWORD): DWORD;
           stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';

function   PfDeleteLog(
           ): DWORD;
           stdcall; external IPHLPAPI name '_PfDeleteLog@0';

////////////////////////////////////////////////////////////////////////////////
//
// Get statistics. Note pdwBufferSize in an IN/OUT parameter. If
// ERROR_INSUFFICIENT_BUFFER is returned, the common statistics are
// available and the correct byte count is in *pdwBufferSize. If only the
// interface statistics are needed, provide a buffer of size
// PF_INTERFACE_STATS only. If the filter descriptions are also needed,
// then supply a large buffer, or use the returned count from the first call
// to allocate a buffer of sufficient size. Note that for a shared interface,
// this second call may fail with ERROR_INSUFFICIENT_BUFFER. This can happen
// if the other sharers add filters in the interim. This should not happen for
// a UNIQUE interface.
//
////////////////////////////////////////////////////////////////////////////////
function   PfGetInterfaceStatistics(
           pInterface:       INTERFACE_HANDLE;
           ppfStats:         PPF_INTERFACE_STATS;
           pdwBufferSize:    PDWORD;
           fResetCounters:   BOOL): DWORD;
           stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';

////////////////////////////////////////////////////////////////////////////////
//
// Test a packet. This call will evaluate the packet against the given
// interfaces and return the filtering action.
//
////////////////////////////////////////////////////////////////////////////////
function   PfTestPacket(
           pInInterface:     INTERFACE_HANDLE;
           pOutInterface:    INTERFACE_HANDLE;
           cBytes:           DWORD;
           pbPacket:         PByteArray;
           ppAction:         PPFFORWARD_ACTION): DWORD;
           stdcall; external IPHLPAPI name '_PfTestPacket@20';

implementation

end.
ASKER CERTIFIED SOLUTION
Avatar of jkr
Commented:
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answers