When you are working with a network device, the main element of Packet Sniffer SDK at the
moment is HNAdapter component.
HNAdapter is intended for emulating the work with a
network device.
First you should create HNAdapter component:
[C++]
HANDLE hAdp = AdpCreate();
[Delphi]
hAdp : Pointer;
hAdp := AdpCreate();
To bind a network device with the HNAdapter
component please use HNAdapter.ConfigHandle
property.
Then you can open a network device by calling
AdpOpenAdapter function.
After the network adapter has been opened successfully, you can get this device statistics
(please see
AdpUpdateAdapterStatistics,
AdpGetTranWithoutErr,
AdpGetRecvWithoutErr,
AdpGetTranWithErr,
AdpGetRecvWithErr, and
AdpGetMissed),
and get this device status and link speed (please see
AdpGetLinkSpeed and
AdpGetConnectStatus).
Also, after the network device has been opened, you can send packets using
AdpSyncSend and
AdpAsyncSend functions.
Consequently HNAdapter component is a universal
component for working with the network devices. You can open any network device currently available
by setting corresponding configuration in
HNAdapterConfig.
[C++]
AdpSetConfig(hAdp,hCfg);
DWORD Err = AdpOpenAdapter(hAdp);
if (Err != HNERR_OK)
{
MessageBox(NULL,"Cannot open Network Adapter","Error !!!",MB_OK);
return;
}
DWORD LinkSpeed = AdpGetLinkSpeed(hAdp);
if(AdpGetConnectStatus(hAdp)) MessageBox(NULL,"ON LINE","Connect Status !!!",MB_OK);
else MessageBox(NULL,"OFF LINE","Connect Status !!!",MB_OK);[Delphi]
Err : DWORD;
LinkSpeed : DWORD;
AdpSetConfig(hAdp,hCfg);
Err := AdpOpenAdapter(hAdp);
if (Err <> HNERR_OK) then
begin
MessageBox(0,'Cannot open Network Adapter','Error !!!',MB_OK);
Exit;
end;
LinkSpeed := AdpGetLinkSpeed(hAdp);
if(AdpGetConnectStatus(hAdp)) then MessageBox(0,'ON LINE','Connect Status !!!',MB_OK)
else MessageBox(0,'OFF LINE','Connect Status !!!',MB_OK);Then you should make a BPF filter to capture IP traffic only (not totally low-level one).
Next step:
4: Create BPF filter