 |
|
Packet Sniffer SDK DLL Edition
HNAdapter wrapper for C++ | | Previous Next |
File: HNAdapter.h /****************************************************************************
** **
** PSSDK HNAdapter module **
** Copyright (c) 1997 - 2007 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** Header File **
** **
****************************************************************************/
//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_ADAPTER_H__
#define __HN_PSSDK_ADAPTER_H__
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Class CHNAdapter
//---------------------------------------------------------------------------
class CHNAdapter
{
private:
HANDLE hAdp;
public:
//###########################################################################
// Create & Destroy
//###########################################################################
//---------------------------------------------------------------------------
// AdpCreate - Creates an HNAdapter object.
CHNAdapter() { hAdp = AdpCreate(); }
//---------------------------------------------------------------------------
// AdpDestroy - Destroys an HNAdapter object.
~CHNAdapter() {AdpDestroy(hAdp); }
public:
//###########################################################################
// Additionals methods
//###########################################################################
BOOL IsValid() { return (BOOL)(hAdp != NULL); }
HANDLE Get_Handle() { return hAdp; }
operator HANDLE() { return hAdp; }
public:
//###########################################################################
// Methods of redirect
//###########################################################################
//---------------------------------------------------------------------------
// AdpOpenAdapter - Opens the network adapter.
DWORD OpenAdapter()
{ return AdpOpenAdapter(hAdp); }
//---------------------------------------------------------------------------
// AdpCloseAdapter - Closes the network adapter.
DWORD CloseAdapter()
{ return AdpCloseAdapter(hAdp);}
//---------------------------------------------------------------------------
// AdpGetOpenTime - Returns last network adapter open time
#ifdef _WIN64
LONGLONG Get_OpenTime()
{ return AdpGetOpenTime(hAdp); }
#else
DWORD Get_OpenTime(DWORD *pHiValue)
{ return AdpGetOpenTime(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpIsOpened - Shows HNAdapter working status.
BOOL IsOpened()
{ return AdpIsOpened(hAdp); }
//---------------------------------------------------------------------------
// AdpGetConfig - Returns the handle of the HNAdapterConfig object.
HANDLE Get_Config()
{ return AdpGetConfig(hAdp); }
//---------------------------------------------------------------------------
// AdpSetConfig - Sets the handle of the HNAdapterConfig object.
HANDLE Set_Config(HANDLE hCfg)
{ return AdpSetConfig(hAdp,hCfg);}
//---------------------------------------------------------------------------
// AdpGetMacFilter - Returns the MAC filter for the network adapter.
DWORD Get_MacFilter()
{ return AdpGetMacFilter(hAdp); }
//---------------------------------------------------------------------------
// AdpSetMacFilter - Sets the MAC filter for the network adapter.
DWORD Set_MacFilter(DWORD MacFilter)
{ return AdpSetMacFilter(hAdp,MacFilter); }
//---------------------------------------------------------------------------
// AdpGetUserFilter - Returns the handle of the HNUserFilter object.
HANDLE Get_UserFilter()
{ return AdpGetUserFilter(hAdp); }
//---------------------------------------------------------------------------
// AdpSetUserFilter - Sets the handle of the HNUserFilter object.
HANDLE Set_UserFilter(HANDLE hUserFilter)
{ return AdpSetUserFilter(hAdp, hUserFilter); }
//---------------------------------------------------------------------------
// AdpGetUserFilterActive - Returns the status flag of the user-settable packet filter using.
BOOL Get_UserFilterActive()
{ return AdpGetUserFilterActive(hAdp); }
//---------------------------------------------------------------------------
// AdpSetUserFilterActive - Sets the status flag of the user-settable packet filter using.
BOOL Set_UserFilterActive(BOOL bActiveBpf)
{ return AdpSetUserFilterActive(hAdp,bActiveBpf); }
//---------------------------------------------------------------------------
// AdpGetUseFastUserFilter - Returns the status flag of the FastBPF using.
BOOL Get_UseFastUserFilter()
{ return AdpGetUseFastUserFilter(hAdp); }
//---------------------------------------------------------------------------
// AdpSetUseFastUserFilter - Sets the status flag of the FastBPF using.
BOOL Set_UseFastUserFilter(BOOL bUseFastBpf)
{ return AdpSetUseFastUserFilter(hAdp,bUseFastBpf); }
//---------------------------------------------------------------------------
// AdpGetLinkSpeed - Returns the network adapter maximum speed in 100 bps.
DWORD Get_LinkSpeed()
{ return AdpGetLinkSpeed(hAdp); }
//---------------------------------------------------------------------------
// AdpGetConnectStatus - Returns the status of the physical connection with the network.
BOOL Get_ConnectStatus()
{ return AdpGetConnectStatus(hAdp); }
//---------------------------------------------------------------------------
// AdpGetMaxThreadCount - Returns the maximal number of the threads allowed to be created for work with the network adapter.
DWORD Get_MaxThreadCount()
{ return AdpGetMaxThreadCount(hAdp); }
//---------------------------------------------------------------------------
// AdpGetThreadCount - Returns the number of threads created for work with the network adapter.
DWORD Get_ThreadCount()
{ return AdpGetThreadCount(hAdp); }
//---------------------------------------------------------------------------
// AdpSetThreadCount - Sets the number of threads created for work with the network adapter.
DWORD Set_ThreadCount(DWORD ThreadCount)
{ return AdpSetThreadCount(hAdp,ThreadCount); }
//---------------------------------------------------------------------------
// AdpGetRecvCount - Returns the number of the packets received by the Packet Sniffer SDK internal driver from OS.
#ifdef _WIN64
ULONGLONG Get_RecvCount()
{ return AdpGetRecvCount(hAdp); }
#else
DWORD Get_RecvCount(DWORD *pHiValue)
{ return AdpGetRecvCount(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetAcceptCount - Returns the number of the packets passed by the user-settable packet filter.
#ifdef _WIN64
ULONGLONG Get_AcceptCount()
{ return AdpGetAcceptCount(hAdp); }
#else
DWORD Get_AcceptCount(DWORD *pHiValue)
{ return AdpGetAcceptCount(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetRejectCount - Returns the number of packets rejected by the user-settable packet filter.
#ifdef _WIN64
ULONGLONG Get_RejectCount()
{ return AdpGetRejectCount(hAdp); }
#else
DWORD Get_RejectCount(DWORD *pHiValue)
{ return AdpGetRejectCount(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetProcessCount - Returns the number of the packets transferred to the application.
#ifdef _WIN64
ULONGLONG Get_ProcessCount()
{ return AdpGetProcessCount(hAdp); }
#else
DWORD Get_ProcessCount(DWORD *pHiValue)
{ return AdpGetProcessCount(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetTranWithoutErr - Returns the number of the packets transferred by the network adapter without errors.
#ifdef _WIN64
ULONGLONG Get_TranWithoutErr()
{ return AdpGetTranWithoutErr(hAdp); }
#else
DWORD Get_TranWithoutErr(DWORD *pHiValue)
{ return AdpGetTranWithoutErr(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetRecvWithoutErr - Returns the number of the packets received by the network adapter without errors.
#ifdef _WIN64
ULONGLONG Get_RecvWithoutErr()
{ return AdpGetRecvWithoutErr(hAdp); }
#else
DWORD Get_RecvWithoutErr(DWORD *pHiValue)
{ return AdpGetRecvWithoutErr(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetTranWithErr - Returns the number of the packets transferred by the network adapter with errors.
#ifdef _WIN64
ULONGLONG Get_TranWithErr()
{ return AdpGetTranWithErr(hAdp); }
#else
DWORD Get_TranWithErr(DWORD *pHiValue)
{ return AdpGetTranWithErr(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetRecvWithErr - Returns the number of the packets received by the network adapter with errors.
#ifdef _WIN64
ULONGLONG Get_RecvWithErr()
{ return AdpGetRecvWithErr(hAdp); }
#else
DWORD Get_RecvWithErr(DWORD *pHiValue)
{ return AdpGetRecvWithErr(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpGetMissed - Returns the number of the packets lost by the network adapter.
#ifdef _WIN64
ULONGLONG Get_Missed()
{ return AdpGetMissed(hAdp); }
#else
DWORD Get_Missed(DWORD *pHiValue)
{ return AdpGetMissed(hAdp,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// AdpSyncSend - Sends a packet synchronously.
DWORD SyncSend(LPVOID pPacket, DWORD PacketSize)
{ return AdpSyncSend(hAdp,pPacket,PacketSize); }
//---------------------------------------------------------------------------
// AdpAsyncSend - Sends a packet asynchronously.
DWORD AsyncSend(LPVOID pPacket, DWORD PacketSize, DWORD Count, DWORD_PTR Key)
{ return AdpAsyncSend(hAdp,pPacket,PacketSize,Count,Key); }
//---------------------------------------------------------------------------
// AdpUpdateUserStatistics - Updates the user-settable filter statistics synchronously.
DWORD UpdateUserStatistics()
{ return AdpUpdateUserStatistics(hAdp); }
//---------------------------------------------------------------------------
// AdpUpdateAdapterStatistics - Updates the network adapter statistics synchronously.
DWORD UpdateAdapterStatistics()
{ return AdpUpdateAdapterStatistics(hAdp); }
//---------------------------------------------------------------------------
// AdpGetAsyncStatistics - Updates network adapter statistics synchronously.
DWORD Get_AsyncStatistics(DWORD StatisticsType)
{ return AdpGetAsyncStatistics(hAdp,StatisticsType); }
//---------------------------------------------------------------------------
// AdpSetOnPacketRecv - Sets the OnPacketReceive event.
FARPROC Set_OnPacketRecv(FARPROC pfOnPacketReceive, DWORD_PTR Param)
{ return AdpSetOnPacketRecv(hAdp,pfOnPacketReceive,Param); }
//---------------------------------------------------------------------------
// AdpSetOnAsyncSend - Sets the OnAsyncSend event.
FARPROC Set_OnAsyncSend(FARPROC pfOnAsyncSend, DWORD_PTR Param)
{ return AdpSetOnAsyncSend(hAdp,pfOnAsyncSend,Param); }
//---------------------------------------------------------------------------
// AdpSetOnStateChange - Sets the OnStateChange event.
FARPROC Set_OnStateChange(FARPROC pfOnStateChange, DWORD_PTR Param)
{ return AdpSetOnStateChange(hAdp,pfOnStateChange,Param); }
// AdpSetOnStatistics - Sets the OnStatistics event.
FARPROC Set_OnStatistics(FARPROC pfOnStatistics, DWORD_PTR Param)
{ return AdpSetOnStatistics(hAdp,pfOnStatistics,Param); }
//###########################################################################
// Add in v2.2
//---------------------------------------------------------------------------
// v2.2 - AdpSyncSendEx - Sends a packet synchronously.
DWORD SyncSendEx(HANDLE hPkt)
{ return AdpSyncSendEx(hAdp,hPkt); }
//---------------------------------------------------------------------------
// v2.2 - AdpAsyncSendEx - Sends a packet asynchronously.
DWORD AsyncSendEx(HANDLE hPkt, DWORD Count, DWORD_PTR Key)
{ return AdpAsyncSendEx(hAdp,hPkt,Count,Key); }
//---------------------------------------------------------------------------
// v2.2 - AdpGetReceiveQueue - Returns the handle of the HNQueue object.
HANDLE Get_ReceiveQueue()
{ return AdpGetReceiveQueue(hAdp); }
//---------------------------------------------------------------------------
// v2.2 - AdpSetReceiveQueue - Sets the handle of the HNQueue object.
HANDLE Set_ReceiveQueue(HANDLE hQue)
{ return AdpSetReceiveQueue(hAdp,hQue); }
//###########################################################################
// Add in v2.3
//---------------------------------------------------------------------------
// v2.3 - AdpSetOnThreadBegin - Sets the OnThreadBegin event.
FARPROC Set_OnThreadBegin(FARPROC pfOnThreadBegin, DWORD_PTR Param)
{ return AdpSetOnThreadBegin(hAdp,pfOnThreadBegin,Param); }
//---------------------------------------------------------------------------
// v2.3 - AdpSetOnThreadEnd - Sets the OnThreadEnd event.
FARPROC Set_OnThreadEnd(FARPROC pfOnThreadEnd, DWORD_PTR Param)
{ return AdpSetOnThreadEnd(hAdp,pfOnThreadEnd,Param); }
//###########################################################################
// Add in v2.4
//---------------------------------------------------------------------------
// v2.4 - AdpGetUseHighPrecisionTime - Returns flag status of using High Precision Time.
BOOL Get_UseHighPrecisionTime()
{ return AdpGetUseHighPrecisionTime(hAdp); }
//---------------------------------------------------------------------------
// v2.4 - AdpSetUseHighPrecisionTime - Sets flag status of using High Precision Time.
BOOL Set_UseHighPrecisionTime(BOOL bUseHighPrecision)
{ return AdpSetUseHighPrecisionTime(hAdp,bUseHighPrecision); }
//---------------------------------------------------------------------------
// v2.4 - AdpGetUseDontLoopBack - Returns flag status of using Dont Loop Back.
BOOL Get_UseDontLoopBack()
{ return AdpGetUseDontLoopBack(hAdp); }
//---------------------------------------------------------------------------
// v2.4 - AdpSetUseDontLoopBack - Sets flag status of using Dont Loop Back.
BOOL Set_UseDontLoopBack(BOOL bUseDontLoopBack)
{ return AdpSetUseDontLoopBack(hAdp,bUseDontLoopBack); }
//---------------------------------------------------------------------------
// v2.4 - AdpSyncRequest - Execute synchronous NDIS request.
DWORD SyncRequest(DWORD RequestType, DWORD Oid, LPVOID pBuffer, DWORD BufferSize,
DWORD *pBytesUsed, DWORD *pBytesNeeded, DWORD *pNdisStatus)
{ return AdpSyncRequest(hAdp,RequestType,Oid,pBuffer,BufferSize,pBytesUsed,pBytesNeeded,pNdisStatus); }
//---------------------------------------------------------------------------
// v2.4 - AdpAsyncRequest - Execute asynchronous NDIS request.
DWORD AsyncRequest(DWORD RequestType, DWORD Oid, LPVOID pBuffer, DWORD BufferSize, DWORD_PTR Key)
{ return AdpAsyncRequest(hAdp,RequestType,Oid,pBuffer,BufferSize,Key); }
//---------------------------------------------------------------------------
// v2.4 - AdpSetOnAsyncRequest - Sets the OnAsyncRequest event.
FARPROC Set_OnAsyncRequest(FARPROC pfOnAsyncRequest, DWORD_PTR Param)
{ return AdpSetOnAsyncRequest(hAdp,pfOnAsyncRequest,Param); }
//---------------------------------------------------------------------------
// v3.2 - AdpGetLostCount - Returns the number of the packets lost by the PSSDK internal driver.
#ifdef _WIN64
ULONGLONG Get_LostCount()
{ return AdpGetLostCount(hAdp); }
#else
DWORD Get_LostCount(DWORD *pHiValue)
{ return AdpGetLostCount(hAdp, pHiValue); }
#endif
//---------------------------------------------------------------------------
// v3.2 - AdpGetSendQueue - Returns the handle of HNQueue object for packets sending.
HANDLE Get_SendQueue()
{ return AdpGetSendQueue(hAdp); }
//---------------------------------------------------------------------------
// v3.2 - AdpSetSendQueue - Sets the handle of HNQueue object for packets sending.
HANDLE Set_SendQueue(HANDLE hQue)
{ return AdpSetSendQueue(hAdp,hQue); }
//---------------------------------------------------------------------------
// v3.2 - AdpGetPacketPool - Return the size of the packets pool which is used by PSSDK for transfering captured packets from the internal driver to application and back.
DWORD Get_PacketPool()
{ return AdpGetPacketPool(hAdp); }
//---------------------------------------------------------------------------
// v3.2 - AdpSetPacketPool - Set the size of the packets pool which is used by PSSDK for transfering captured packets from the internal driver to application and back.
DWORD Set_PacketPool(DWORD dwPacketPool)
{ return AdpSetPacketPool(hAdp,dwPacketPool); }
};
//---------------------------------------------------------------------------
#endif // __HN_PSSDK_ADAPTER_H__
//---------------------------------------------------------------------------
|