⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packet32winpcap.pas

📁 linux program to read packet data
💻 PAS
字号:
(*
 * $id$
 * See packet32.h from WpdPack
 *
 *)
unit Packet32Winpcap;
interface
uses Windows;

Const
  DLL  = 'packet.dll';            // Name of DLL file
  MAX_LINK_NAME_LENGTH = 64;      // Adapters symbolic names maximum length

type
  // The format of these structures could change in the future
  // see packet.h in WinPcap package
  // Works with WinPCap 2.1

  // Adapter
  Padapter = ^Tadapter;
  Tadapter = Record
    hFile        : LongWord;
    SymbolicLink : array [0..MAX_LINK_NAME_LENGTH-1] of char;
  end;


  // Packet
  Ppacket = ^Tpacket;

  Tpacket = record
    hEvent             : UINT;
    OverLapped         :TOVERLAPPED;
    Buffer             :Pointer;
    Length             :UINT;
    ulBytesReceived    :UINT;
    bIoComplete        :Boolean;
  end;


type
  TunixTimeVal = record
    tv_Sec,            // Secs since 1/1/1970
    tv_uSec: LongWord; // microseconds
  end;

  Pbpf_hdr = ^Tbpf_hdr;        //Structure prepended to each packet.
  Tbpf_hdr =record
    bh_tstamp :TunixTimeval;	// time stamp
    bh_caplen : UINT;          	// length of captured portion
    bh_datalen: UINT;	        // original length of packet
    bh_hdrlen : Word ;        	// length of bpf header (this struct plus alignment padding)
  end;


Function PacketGetAdapterNames(pStr:pchar;BufferSize:PLongWord) : LongWord; cdecl external DLL;
Function PacketOpenAdapter(AdapterName:Pchar) : PAdapter;cdecl external dll;
procedure PacketCloseAdapter(pAdapter:Padapter);cdecl external dll;
function PacketAllocatePacket : PPacket;cdecl external dll;
Procedure PacketInitPacket(pPacket:Ppacket;Buffer:Pointer;Length:UINT);cdecl external DLL;
procedure PacketFreePacket( pPacket:Ppacket);cdecl external DLL;
Function PacketReceivePacket(AdapterObject:Padapter;pPacket:PPacket;
         Sync:Boolean):Boolean;cdecl external DLL;
function PacketWaitPacket(AdapterObject:Padapter;lpPacket:Ppacket):Boolean; cdecl external dll;
Function PacketSendPacket( AdapterObject:Padapter;pPacket:PPacket;Sync:boolean) :Boolean;cdecl external dll;
Function PacketResetAdapter( AdapterObject:Padapter):Boolean; cdecl external dll;
Function PacketSetHwFilter( AdapterObject:Pointer;Filter:ULONG):Boolean; cdecl external dll;
function PacketSetBuff(AdapterObject: Padapter;dim:integer) : Boolean; cdecl external DLL;

function PacketSetMinToCopy(AdapterObject : PAdapter;nbytes : integer) : Boolean;cdecl external DLL;


function BPF_WORDALIGN(X:LongWord) : LongWord;

implementation


const
  BPF_ALIGNMENT = sizeof(Integer);

function BPF_WORDALIGN(X:LongWord) : LongWord;
begin
  result := (((X)+(BPF_ALIGNMENT-1))and not(BPF_ALIGNMENT-1));
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -