{****************************************************************************
** **
** PSSDK HNAdapter module **
** Copyright (c) 1997 - 2007 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** **
****************************************************************************}
unit HNAdapter;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
HNPSManager, HNPsSdkDef;
type
TOnPacketReceive = procedure (Sender : TObject; ThParam: Pointer; hPacket: Pointer; pPacketData: Pointer; IncPacketSize: DWORD) of object;
TOnAsyncSend = procedure (Sender : TObject; Key: Pointer; Count: DWORD) of object;
TOnStateChange = procedure (Sender : TObject; State: DWORD) of object;
TOnStatistics = procedure (Sender : TObject; StatisticsType: Integer; pValue : PULargeInteger) of object;
TOnThreadBegin = procedure (Sender : TObject; Var ThParam: Pointer) of object;
TOnThreadEnd = procedure (Sender : TObject; ThParam: Pointer) of object;
TOnAsyncRequest = procedure (Sender : TObject; Key: Pointer; RequestType: DWORD; Oid: DWORD; pBuffer: Pointer; BufferSize: DWORD; BytesUsed: DWORD; BytesNeeded: DWORD; NdisStatus: DWORD) of object;
//---------------------------------------------------------------------------
// Class THNAdapter
//---------------------------------------------------------------------------
THNAdapter = class
private
hAdp : Pointer;
FOnPacketReceive: TOnPacketReceive;
FOnAsyncSend: TOnAsyncSend;
FOnStateChange: TOnStateChange;
FOnStatistics: TOnStatistics;
FOnThreadBegin: TOnThreadBegin;
FOnThreadEnd: TOnThreadEnd;
FOnAsyncRequest: TOnAsyncRequest;
procedure SetConfigHandle(Value: Pointer);
function GetConfigHandle: Pointer;
procedure SetMacFilter(Value: DWORD);
function GetMacFilter: DWORD;
procedure SetUserFilter(Value: Pointer);
function GetUserFilter: Pointer;
procedure SetUserFilterActive(Value: BOOL);
function GetUserFilterActive: BOOL;
procedure SetUseFastUserFilter(Value: BOOL);
function GetUseFastUserFilter: BOOL;
function GetLinkSpeed: DWORD;
function GetConnectStatus: BOOL;
function GetMaxThreadCount: DWORD;
procedure SetThreadCount(Value: DWORD);
function GetThreadCount: DWORD;
procedure DoOnPacketReceive(ThParam: Pointer; hPacket: Pointer; pPacketData: Pointer; IncPacketSize: Cardinal);
procedure DoOnAsyncSend(Key: Pointer; Count: DWORD);
procedure DoOnStateChange(State: DWORD);
procedure DoOnStatistics(StatisticsType: Integer; pValue: PULargeInteger);
procedure DoOnThreadBegin(Var ThParam: Pointer);
procedure DoOnThreadEnd(ThParam: Pointer);
//---------------------------------------------------------------------------
// Add in 2.2
procedure SetReceiveQueue(Value: Pointer);
function GetReceiveQueue: Pointer;
//---------------------------------------------------------------------------
// Add in 2.4
procedure DoOnAsyncRequest(Key: Pointer; RequestType: DWORD; Oid: DWORD; pBuffer: Pointer; BufferSize: DWORD;
BytesUsed: DWORD; BytesNeeded: DWORD; NdisStatus: DWORD);
function GetUseHighPrecisionTime: BOOL;
procedure SetUseHighPrecisionTime(Value: BOOL);
function GetUseDontLoopBack: BOOL;
procedure SetUseDontLoopBack(Value : BOOL);
//---------------------------------------------------------------------------
// Add in 3.2
procedure SetSendQueue(Value: Pointer);
function GetSendQueue: Pointer;
function GetPacketPool: DWORD;
procedure SetPacketPool(Value: DWORD);
protected
public
constructor Create();
destructor Destroy(); override;
function IsValid: BOOL;
function OpenAdapter: DWORD;
function CloseAdapter: DWORD;
function IsOpened: BOOL;
function Get_RecvCount(HiValue: PUINT): UINT;
function Get_AcceptCount(HiValue: PUINT): UINT;
function Get_RejectCount(HiValue: PUINT): UINT;
function Get_ProcessCount(HiValue: PUINT): UINT;
function Get_TranWithoutErr(HiValue: PUINT): UINT;
function Get_RecvWithoutErr(HiValue: PUINT): UINT;
function Get_TranWithErr(HiValue: PUINT): UINT;
function Get_RecvWithErr(HiValue: PUINT): UINT;
function Get_Missed(HiValue: PUINT): UINT;
function Get_OpenTime(HiValue: PUINT): UINT;
function SyncSend(pPacket: Pointer; PacketSize: DWORD): DWORD;
function AsyncSend(pPacket: Pointer; PacketSize: DWORD; Count: DWORD; Key: Pointer): DWORD;
function UpdateUserStatistics: DWORD;
function UpdateAdapterStatistics: DWORD;
function Get_AsyncStatistics(StatisticsType: Integer): DWORD;
property ConfigHandle: Pointer read GetConfigHandle write SetConfigHandle;
property MacFilter: DWORD read GetMacFilter write SetMacFilter;
property UserFilter: Pointer read GetUserFilter write SetUserFilter;
property LinkSpeed: DWORD read GetLinkSpeed;
property ConnectStatus: BOOL read GetConnectStatus;
property MaxThreadCount: DWORD read GetMaxThreadCount;
property ThreadCount: DWORD read GetThreadCount write SetThreadCount;
//---------------------------------------------------------------------------
// Add in 2.2
property ReceiveQueue: Pointer read GetReceiveQueue write SetReceiveQueue;
function SyncSendEx(hPacket: Pointer): DWORD;
function AsyncSendEx(hPacket: Pointer; Count: DWORD; Key: Pointer): DWORD;
//---------------------------------------------------------------------------
// Add in 2.4
function SyncRequest(RequestType: UINT; Oid: UINT; pBuffer: Pointer; BufferSize: UINT;
pBytesUsed: PUINT; pBytesNeeded: PUINT; pNdisStatus: PUINT): DWORD;
function AsyncRequest(RequestType: UINT; Oid: UINT; pBuffer: Pointer; BufferSize: UINT;
Key : Pointer) : DWORD;
//---------------------------------------------------------------------------
// Add in 3.2
function Get_LostCount(HiValue: PUINT): UINT;
property SendQueue: Pointer read GetSendQueue write SetSendQueue;
property PacketPool: DWORD read GetPacketPool write SetPacketPool;
published
property UserFilterActive: BOOL read GetUserFilterActive write SetUserFilterActive;
property UseFastUserFilter: BOOL read GetUseFastUserFilter write SetUseFastUserFilter;
property OnPacketReceive: TOnPacketReceive read FOnPacketReceive write FOnPacketReceive;
property OnAsyncSend: TOnAsyncSend read FOnAsyncSend write FOnAsyncSend;
property OnStateChange: TOnStateChange read FOnStateChange write FOnStateChange;
property OnStatistics: TOnStatistics read FOnStatistics write FOnStatistics;
property OnThreadBegin: TOnThreadBegin read FOnThreadBegin write FOnThreadBegin;
property OnThreadEnd: TOnThreadEnd read FOnThreadEnd write FOnThreadEnd;
property OnAsyncRequest: TOnAsyncRequest read FOnAsyncRequest write FOnAsyncRequest;
//---------------------------------------------------------------------------
// Add in 2.4
property UseHighPrecisionTime: BOOL read GetUseHighPrecisionTime write SetUseHighPrecisionTime;
property UseUseDontLoopBack: BOOL read GetUseDontLoopBack write SetUseDontLoopBack;
end;
implementation
{$INCLUDE 'HNPsSdkFun.pas'}
//---------------------------------------------------------------------------
// IntOnPacketReceive - OnPacketReceive event handler.
//---------------------------------------------------------------------------
procedure IntOnPacketReceive(Param: Pointer; ThParam: Pointer; hPacket: Pointer; pPacketData: Pointer; IncPacketSize: Cardinal); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnPacketReceive(ThParam,hPacket,pPacketData,IncPacketSize);
end;
//---------------------------------------------------------------------------
// IntOnAsyncSend - OnAsyncSend event handler.
//---------------------------------------------------------------------------
procedure IntOnAsyncSend(Param: Pointer; Key: Pointer; Count: DWORD); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnAsyncSend(Key,Count);
end;
//---------------------------------------------------------------------------
// IntOnStateChange - OnStateChange event handler.
//---------------------------------------------------------------------------
procedure IntOnStateChange(Param: Pointer; State: DWORD); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnStateChange(State);
end;
//---------------------------------------------------------------------------
// IntOnStatistics - OnStatistics event handler.
//---------------------------------------------------------------------------
procedure IntOnStatistics(Param: Pointer; StatisticsType: Integer; pValue : PULargeInteger); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnStatistics(StatisticsType,pValue);
end;
//---------------------------------------------------------------------------
// IntOnThreadBegin - OnThreadBegin event handler.
//---------------------------------------------------------------------------
procedure IntOnThreadBegin(Param: Pointer; Var ThParam: Pointer); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnThreadBegin(ThParam);
end;
//---------------------------------------------------------------------------
// IntOnThreadEnd - OnThreadEnd event handler.
//---------------------------------------------------------------------------
procedure IntOnThreadEnd(Param: Pointer; ThParam: Pointer); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnThreadEnd(ThParam);
end;
//---------------------------------------------------------------------------
// IntOnAsyncRequest - OnAsyncRequest event handler.
//---------------------------------------------------------------------------
procedure IntOnAsyncRequest(Param: Pointer; Key: Pointer; RequestType: DWORD; Oid: DWORD;
pBuffer: Pointer; BufferSize: DWORD; BytesUsed: DWORD; BytesNeeded: DWORD; NdisStatus: DWORD); stdcall;
var
pAdp : THNAdapter;
begin
pAdp := THNAdapter(Param);
pAdp.DoOnAsyncRequest(Key,RequestType,Oid,pBuffer,BufferSize,BytesUsed,BytesNeeded,NdisStatus);
end;
//---------------------------------------------------------------------------
// Create - Creates an HNAdapter object.
//---------------------------------------------------------------------------
constructor THNAdapter.Create();
begin
hAdp := AdpCreate();
AdpSetOnPacketRecv (hAdp,@IntOnPacketReceive,Self);
AdpSetOnAsyncSend (hAdp,@IntOnAsyncSend, Self);
AdpSetOnStateChange (hAdp,@IntOnStateChange, Self);
AdpSetOnStatistics (hAdp,@IntOnStatistics, Self);
AdpSetOnThreadBegin (hAdp,@IntOnThreadBegin, Self);
AdpSetOnThreadEnd (hAdp,@IntOnThreadEnd, Self);
AdpSetOnAsyncRequest(hAdp,@IntOnAsyncRequest, Self);
end;
//---------------------------------------------------------------------------
// Destroy - Destroys an HNAdapter object.
//---------------------------------------------------------------------------
destructor THNAdapter.Destroy();
begin
AdpSetOnPacketRecv (hAdp,nil,nil);
AdpSetOnAsyncSend (hAdp,nil,nil);
AdpSetOnStateChange (hAdp,nil,nil);
AdpSetOnStatistics (hAdp,nil,nil);
AdpSetOnThreadBegin (hAdp,nil,nil);
AdpSetOnThreadEnd (hAdp,nil,nil);
AdpSetOnAsyncRequest(hAdp,nil,nil);
AdpDestroy(hAdp);
end;
//---------------------------------------------------------------------------
// Method - IsValid - Checks if the HNAdapter object is created correctly.
//---------------------------------------------------------------------------
function THNAdapter.IsValid: BOOL;
begin
Result := (hAdp <> nil);
end;
//---------------------------------------------------------------------------
// Method - OpenAdapter - Opens the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.OpenAdapter: DWORD;
begin
Result := AdpOpenAdapter(hAdp);
end;
//---------------------------------------------------------------------------
// Method - CloseAdapter - Closes the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.CloseAdapter: DWORD;
begin
Result := AdpCloseAdapter(hAdp);
end;
//---------------------------------------------------------------------------
// Method - Get_OpenTime - Returns the time of the latest opening of the current network adapter.
//---------------------------------------------------------------------------
function THNAdapter.Get_OpenTime(HiValue: PUINT): UINT;
begin
Result := AdpGetOpenTime(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - IsOpened - Shows HNAdapter working status.
//---------------------------------------------------------------------------
function THNAdapter.IsOpened: BOOL;
begin
Result := AdpIsOpened(hAdp);
end;
//---------------------------------------------------------------------------
// v2.2 - Property - ReceiveQueue - Sets the handle of the HNQueue object.
//---------------------------------------------------------------------------
procedure THNAdapter.SetReceiveQueue(Value: Pointer);
begin
AdpSetReceiveQueue(hAdp,Value);
end;
//---------------------------------------------------------------------------
// v2.2 - Property - ReceiveQueue - Returns the handle of the HNQueue object.
//---------------------------------------------------------------------------
function THNAdapter.GetReceiveQueue: Pointer;
begin
Result := AdpGetReceiveQueue(hAdp);
end;
//---------------------------------------------------------------------------
// Property - ConfigHandle - Sets the handle of the HNAdapterConfig object.
//---------------------------------------------------------------------------
procedure THNAdapter.SetConfigHandle(Value: Pointer);
begin
AdpSetConfig(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - ConfigHandle - Returns the handle of the HNAdapterConfig object.
//---------------------------------------------------------------------------
function THNAdapter.GetConfigHandle: Pointer;
begin
Result := AdpGetConfig(hAdp);
end;
//---------------------------------------------------------------------------
// Property - MacFilter - Sets the MAC filter for the network adapter.
//---------------------------------------------------------------------------
procedure THNAdapter.SetMacFilter(Value: DWORD);
begin
AdpSetMacFilter(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - MacFilter - Returns the MAC filter for the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.GetMacFilter: DWORD;
begin
Result := AdpGetMacFilter(hAdp);
end;
//---------------------------------------------------------------------------
// Property - UserFilter - Sets the handle of the HNUserFilter object.
//---------------------------------------------------------------------------
procedure THNAdapter.SetUserFilter(Value: Pointer);
begin
AdpSetUserFilter(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - UserFilter - Returns the handle of the HNUserFilter object.
//---------------------------------------------------------------------------
function THNAdapter.GetUserFilter: Pointer;
begin
Result := AdpGetUserFilter(hAdp);
end;
//---------------------------------------------------------------------------
// Property - UserFilterActive - Sets the status flag of the user-settable packet filter using.
//---------------------------------------------------------------------------
procedure THNAdapter.SetUserFilterActive(Value: BOOL);
begin
AdpSetUserFilterActive(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - UserFilterActive - Returns the status flag of the user-settable packet filter using.
//---------------------------------------------------------------------------
function THNAdapter.GetUserFilterActive: BOOL;
begin
Result := AdpGetUserFilterActive(hAdp);
end;
//---------------------------------------------------------------------------
// Property - UseFastUserFilter - Sets the status flag of the FastBPF using.
//---------------------------------------------------------------------------
procedure THNAdapter.SetUseFastUserFilter(Value: BOOL);
begin
AdpSetUseFastUserFilter(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - UseFastUserFilter - Returns the status flag of the FastBPF using.
//---------------------------------------------------------------------------
function THNAdapter.GetUseFastUserFilter: BOOL;
begin
Result := AdpGetUseFastUserFilter(hAdp);
end;
//---------------------------------------------------------------------------
// v2.4 - Property - UseHighPrecisionTime - Sets flag status of using High Precision Time.
//---------------------------------------------------------------------------
procedure THNAdapter.SetUseHighPrecisionTime(Value: BOOL);
begin
AdpSetUseHighPrecisionTime(hAdp,Value);
end;
//---------------------------------------------------------------------------
// v2.4 - Property - UseHighPrecisionTime - Returns flag status of using High Precision Time.
//---------------------------------------------------------------------------
function THNAdapter.GetUseHighPrecisionTime: BOOL;
begin
Result := AdpGetUseHighPrecisionTime(hAdp);
end;
//---------------------------------------------------------------------------
// v2.4 - Property - UseDontLoopBack - Sets flag status of using Dont Loop Back.
//---------------------------------------------------------------------------
procedure THNAdapter.SetUseDontLoopBack(Value: BOOL);
begin
AdpSetUseDontLoopBack(hAdp,Value);
end;
//---------------------------------------------------------------------------
// v2.4 - Property - UseDontLoopBack - Returns flag status of using Dont Loop Back.
//---------------------------------------------------------------------------
function THNAdapter.GetUseDontLoopBack: BOOL;
begin
Result := AdpGetUseDontLoopBack(hAdp);
end;
//---------------------------------------------------------------------------
// Property - LinkSpeed - Returns the network adapter maximum speed in 100 bps.
//---------------------------------------------------------------------------
function THNAdapter.GetLinkSpeed: DWORD;
begin
Result := AdpGetLinkSpeed(hAdp);
end;
//---------------------------------------------------------------------------
// Property - ConnectStatus - Returns the status of the physical connection to the network.
//---------------------------------------------------------------------------
function THNAdapter.GetConnectStatus: BOOL;
begin
Result := AdpGetConnectStatus(hAdp);
end;
//---------------------------------------------------------------------------
// Property - MaxThreadCount - Returns the maximal number of the threads allowed to be created for work with the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.GetMaxThreadCount: DWORD;
begin
Result := AdpGetMaxThreadCount(hAdp);
end;
//---------------------------------------------------------------------------
// Property - ThreadCount - Sets the number of threads created for work with the network adapter.
//---------------------------------------------------------------------------
procedure THNAdapter.SetThreadCount(Value: DWORD);
begin
AdpSetThreadCount(hAdp,Value);
end;
//---------------------------------------------------------------------------
// Property - ThreadCount - Returns the number of threads created for work with the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.GetThreadCount: DWORD;
begin
Result := AdpGetThreadCount(hAdp);
end;
//---------------------------------------------------------------------------
// Method - Get_RecvCount - Returns the number of the packets received by the Packet Sniffer SDK internal driver from OS.
//---------------------------------------------------------------------------
function THNAdapter.Get_RecvCount(HiValue: PUINT): UINT;
begin
Result := AdpGetRecvCount(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_AcceptCount - Returns the number of the packets passed by the user-settable packet filter.
//---------------------------------------------------------------------------
function THNAdapter.Get_AcceptCount(HiValue: PUINT): UINT;
begin
Result := AdpGetAcceptCount(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_RejectCount - Returns the number of packets rejected by the user-settable packet filter.
//---------------------------------------------------------------------------
function THNAdapter.Get_RejectCount(HiValue: PUINT): UINT;
begin
Result := AdpGetRejectCount(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_ProcessCount - Returns the number of the packets transferred to the application.
//---------------------------------------------------------------------------
function THNAdapter.Get_ProcessCount(HiValue: PUINT): UINT;
begin
Result := AdpGetProcessCount(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_TranWithoutErr - Returns the number of the packets transferred by the network adapter without errors.
//---------------------------------------------------------------------------
function THNAdapter.Get_TranWithoutErr(HiValue: PUINT): UINT;
begin
Result := AdpGetTranWithoutErr(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_RecvWithoutErr - Returns the number of the packets received by the network adapter without errors.
//---------------------------------------------------------------------------
function THNAdapter.Get_RecvWithoutErr(HiValue: PUINT): UINT;
begin
Result := AdpGetRecvWithoutErr(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_TranWithErr - Returns the number of the packets transferred by the network adapter with errors.
//---------------------------------------------------------------------------
function THNAdapter.Get_TranWithErr(HiValue: PUINT): UINT;
begin
Result := AdpGetTranWithErr(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_RecvWithErr - Returns the number of the packets received by the network adapter with errors.
//---------------------------------------------------------------------------
function THNAdapter.Get_RecvWithErr(HiValue: PUINT): UINT;
begin
Result := AdpGetRecvWithErr(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - Get_Missed - Returns the number of the packets lost by the network adapter.
//---------------------------------------------------------------------------
function THNAdapter.Get_Missed(HiValue: PUINT): UINT;
begin
Result := AdpGetMissed(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// Method - SyncSend - Sends a packet synchronously.
//---------------------------------------------------------------------------
function THNAdapter.SyncSend(pPacket: Pointer; PacketSize: DWORD): DWORD;
begin
Result := AdpSyncSend(hAdp, pPacket,PacketSize);
end;
//---------------------------------------------------------------------------
// Method - AsyncSend - Sends a packet asynchronously.
//---------------------------------------------------------------------------
function THNAdapter.AsyncSend(pPacket: Pointer; PacketSize: DWORD; Count: DWORD; Key: Pointer): DWORD;
begin
Result := AdpAsyncSend(hAdp,pPacket,PacketSize,Count,Key);
end;
//---------------------------------------------------------------------------
// Method - UpdateUserStatistics - Updates the user-settable filter statistics synchronously.
//---------------------------------------------------------------------------
function THNAdapter.UpdateUserStatistics: DWORD;
begin
Result := AdpUpdateUserStatistics(hAdp);
end;
//---------------------------------------------------------------------------
// Method - UpdateAdapterStatistics - Updates the network adapter statistics synchronously.
//---------------------------------------------------------------------------
function THNAdapter.UpdateAdapterStatistics: DWORD;
begin
Result := AdpUpdateAdapterStatistics(hAdp);
end;
//---------------------------------------------------------------------------
// Method - Get_AsyncStatistics - Updates network adapter statistics synchronously.
//---------------------------------------------------------------------------
function THNAdapter.Get_AsyncStatistics(StatisticsType: Integer): DWORD;
begin
Result := AdpGetAsyncStatistics(hAdp,StatisticsType);
end;
//---------------------------------------------------------------------------
// DoOnPacketReceive - Occurs immediately after a packet has been received by the network adapter.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnPacketReceive(ThParam: Pointer; hPacket: Pointer; pPacketData: Pointer; IncPacketSize: Cardinal);
begin
if Assigned(FOnPacketReceive) then FOnPacketReceive(Self,ThParam,hPacket,pPacketData,IncPacketSize);
end;
//---------------------------------------------------------------------------
// DoOnAsyncSend - Occurs immediately after the asynchronous packet sending has been completed.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnAsyncSend(Key: Pointer; Count: DWORD);
begin
if Assigned(FOnAsyncSend) then FOnAsyncSend(Self,Key,Count);
end;
//---------------------------------------------------------------------------
// DoOnStateChange - Occurs when the network adapter state has been changed.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnStateChange(State: DWORD);
begin
if Assigned(FOnStateChange) then FOnStateChange(Self,State);
end;
//---------------------------------------------------------------------------
// DoOnStatistics - Occurs when network adapter statistics has been updated asynchronously.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnStatistics(StatisticsType: Integer; pValue: PULargeInteger);
begin
if Assigned(FOnStatistics) then FOnStatistics(Self,StatisticsType,pValue);
end;
//---------------------------------------------------------------------------
// v2.2 - Method - SyncSendEx - Sends a packet synchronously.
//---------------------------------------------------------------------------
function THNAdapter.SyncSendEx(hPacket: Pointer): DWORD;
begin
Result := AdpSyncSendEx(hAdp, hPacket);
end;
//---------------------------------------------------------------------------
// v2.2 - Method - AsyncSendEx - Sends a packet asynchronously.
//---------------------------------------------------------------------------
function THNAdapter.AsyncSendEx(hPacket: Pointer; Count: DWORD; Key: Pointer): DWORD;
begin
Result := AdpAsyncSendEx(hAdp,hPacket,Count,Key);
end;
//---------------------------------------------------------------------------
// v2.4 - Method - SyncRequest - Execute synchronous NDIS request.
//---------------------------------------------------------------------------
function THNAdapter.SyncRequest(RequestType: UINT; Oid: UINT; pBuffer: Pointer; BufferSize: UINT;
pBytesUsed: PUINT; pBytesNeeded: PUINT; pNdisStatus: PUINT): DWORD;
begin
Result := AdpSyncRequest(hAdp,RequestType,Oid,pBuffer,BufferSize,
PDWORD(pBytesUsed),PDWORD(pBytesNeeded),PDWORD(pNdisStatus));
end;
//---------------------------------------------------------------------------
// v2.4 - Method - AsyncRequest - Execute asynchronous NDIS request.
//---------------------------------------------------------------------------
function THNAdapter.AsyncRequest(RequestType: UINT; Oid: UINT; pBuffer: Pointer; BufferSize: UINT;
Key : Pointer) : DWORD;
begin
Result := AdpAsyncRequest(hAdp,RequestType,Oid,pBuffer,BufferSize,Key);
end;
//---------------------------------------------------------------------------
// v2.3 - DoOnThreadBegin - Tracks the creating of the internal component thread.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnThreadBegin(Var ThParam: Pointer);
begin
if Assigned(FOnThreadBegin) then FOnThreadBegin(Self,ThParam);
end;
//---------------------------------------------------------------------------
// v2.3 - DoOnThreadEnd - Tracks the closing of the internal component thread.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnThreadEnd(ThParam: Pointer);
begin
if Assigned(FOnThreadEnd) then FOnThreadEnd(Self,ThParam);
end;
//---------------------------------------------------------------------------
// v2.4 - DoOnAsyncRequest - Fires immediately after asynchronous NDIS request completed.
//---------------------------------------------------------------------------
procedure THNAdapter.DoOnAsyncRequest(Key: Pointer; RequestType: DWORD; Oid: DWORD;
pBuffer: Pointer; BufferSize: DWORD; BytesUsed: DWORD; BytesNeeded: DWORD; NdisStatus: DWORD);
begin
if Assigned(FOnAsyncRequest) then
FOnAsyncRequest(Self,Key,RequestType,Oid,pBuffer,BufferSize,BytesUsed,BytesNeeded,NdisStatus);
end;
//---------------------------------------------------------------------------
// v3.2 - Method - Get_LostCount - Returns the number of the packets lost by the PSSDK internal driver.
//---------------------------------------------------------------------------
function THNAdapter.Get_LostCount(HiValue: PUINT): UINT;
begin
Result := AdpGetLostCount(hAdp,PDWORD(HiValue));
end;
//---------------------------------------------------------------------------
// v3.2 - Property - SendQueue - Sets the handle of HNQueue object for packets sending.
//---------------------------------------------------------------------------
procedure THNAdapter.SetSendQueue(Value: Pointer);
begin
AdpSetSendQueue(hAdp,Value);
end;
//---------------------------------------------------------------------------
// v3.2 - Property - SendQueue - Returns the handle of HNQueue object for packets sending.
//---------------------------------------------------------------------------
function THNAdapter.GetSendQueue: Pointer;
begin
Result := AdpGetSendQueue(hAdp);
end;
//---------------------------------------------------------------------------
// v3.2 - Property - PacketPool - Return the size of the packets pool which is used by PSSDK for transfering captured packets from the internal driver to application and back.
//---------------------------------------------------------------------------
function THNAdapter.GetPacketPool: DWORD;
begin
Result := AdpGetPacketPool(hAdp);
end;
//---------------------------------------------------------------------------
// v3.2 - Property - PacketPool - Set the size of the packets pool which is used by PSSDK for transfering captured packets from the internal driver to application and back.
//---------------------------------------------------------------------------
procedure THNAdapter.SetPacketPool(Value: DWORD);
begin
AdpSetPacketPool(hAdp,Value);
end;
end.