Packet Sniffer SDK DLL Edition

HNLBAdapter wrapper for C++

 Previous Next

File: HNLBAdapter.h

/****************************************************************************
**                                                                         **
**                         PSSDK HNLBAdapter module                        **
**            Copyright (c) 1997 - 2007 microOLAP Technologies LTD,        **
**                       Khalturin A.P., Naumov D.A.                       **
**                               Header File                               **
**                                                                         **
****************************************************************************/

//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_LBADAPTER_H__
#define __HN_PSSDK_LBADAPTER_H__ 
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Class CHNLBAdapter
//---------------------------------------------------------------------------
class CHNLBAdapter
{
private:
    HANDLE hLbAdp;

public:
    //###########################################################################
    //    Create & Destroy
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpCreate - Creates an HNLBAdapter object.
    CHNLBAdapter() { hLbAdp = LbAdpCreate(); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpDestroy - Destroys the HNLBAdapter object.
    ~CHNLBAdapter() { LbAdpDestroy(hLbAdp); }

public:
    //###########################################################################
    //    Additionals methods
    //###########################################################################
    BOOL     IsValid() { return (BOOL)(hLbAdp != NULL); }
    HANDLE   Get_Handle() { return hLbAdp; }
    operator HANDLE() { return hLbAdp; }

public:
    //###########################################################################
    //    Methods of redirect
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpOpenAdapter - Opens loopback adapter for TCP/UDP traffic capturing and tracking of TCP sessions.
    DWORD OpenAdapter() 
    { return LbAdpOpenAdapter(hLbAdp); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpCloseAdapter - Closes the loopback adapter, stops receiving of the local traffic and sessions tracking.
    DWORD CloseAdapter() 
    { return LbAdpCloseAdapter(hLbAdp);} 

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpGetOpenTime - Returns the time of the latest opening of the loopback adapter.
#ifdef _WIN64
    LONGLONG GetOpenTime() 
    { return LbAdpGetOpenTime(hLbAdp); }
#else
    DWORD GetOpenTime(DWORD *pHiValue) 
    { return LbAdpGetOpenTime(hLbAdp,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpGetProcessNameByID - Returns the process name by the process identifier (PID).
    DWORD GetProcessNameByID(DWORD ProcessID, LPTSTR Name, DWORD Size) 
    { return LbAdpGetProcessNameByID(ProcessID,Name,Size); } 

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpGetProcessFileByID - Returns the exefile name by the process identifier (PID).
    DWORD GetProcessFileByID(DWORD ProcessID, LPTSTR Name, DWORD Size) 
    { return LbAdpGetProcessFileByID(ProcessID,Name,Size); } 

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnTcpPacketRecv - Sets the OnTcpPacketReceive event.
    FARPROC SetOnTcpPacketRecv(FARPROC pfOnTcpPacketReceive, DWORD_PTR Param) 
    { return LbAdpSetOnTcpPacketRecv(hLbAdp,pfOnTcpPacketReceive,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnUdpPacketRecv - Sets the OnUdpPacketReceive event.
    FARPROC SetOnUdpPacketRecv(FARPROC pfOnUdpPacketReceive, DWORD_PTR Param) 
    { return LbAdpSetOnUdpPacketRecv(hLbAdp,pfOnUdpPacketReceive,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnThreadBegin - Sets the OnThreadBegin event.
    FARPROC SetOnThreadBegin(FARPROC pfOnThreadBegin, DWORD_PTR Param) 
    { return LbAdpSetOnThreadBegin(hLbAdp,pfOnThreadBegin,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnThreadEnd - Sets the OnThreadEnd event.
    FARPROC SetOnThreadEnd(FARPROC pfOnThreadEnd, DWORD_PTR Param) 
    { return LbAdpSetOnThreadEnd(hLbAdp,pfOnThreadEnd,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnConnect - Sets the OnConnect event.
    FARPROC SetOnConnect(FARPROC pfOnConnect, DWORD_PTR Param) 
    { return LbAdpSetOnConnect(hLbAdp,pfOnConnect,Param); }

    //---------------------------------------------------------------------------
    // v2.3 - LbAdpSetOnDisconnect - Sets the OnDisconnect event.
    FARPROC SetOnDisconnect(FARPROC pfOnDisconnect, DWORD_PTR Param) 
    { return LbAdpSetOnDisconnect(hLbAdp,pfOnDisconnect,Param); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpGetCaptureTcp - Get TCP traffic capture flag
    BOOL Get_CaptureTcp()
    { return LbAdpGetCaptureTcp(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpSetCaptureTcp - Change TCP traffic capture flag
    BOOL Set_CaptureTcp(BOOL bCaptureTcp)
    { return LbAdpSetCaptureTcp(hLbAdp,bCaptureTcp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpGetCaptureUdp - Get UDP traffic capture flag
    BOOL Get_CaptureUdp(HANDLE hLbAdp)
    { return LbAdpGetCaptureUdp(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpSetCaptureUdp - Change UDP traffic capture flag
    BOOL Set_CaptureUdp(BOOL bCaptureUdp)
    { return LbAdpSetCaptureUdp(hLbAdp,bCaptureUdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpGetUseTcpPortFilters - Return flag of using filters for TCP ports value
    BOOL Get_UseTcpPortFilters()
    { return LbAdpGetUseTcpPortFilters(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpSetUseTcpPortFilters - Change flag of using filters for TCP ports
    BOOL Set_UseTcpPortFilters(BOOL bUseTcpPortFilters)
    { return LbAdpSetUseTcpPortFilters(hLbAdp,bUseTcpPortFilters); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpGetUseUdpPortFilters - Return flag of using filters for UDP ports value
    BOOL Get_UseUdpPortFilters()
    { return LbAdpGetUseUdpPortFilters(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpSetUseUdpPortFilters - Change flag of using filters for UDP ports
    BOOL Set_UseUdpPortFilters(BOOL bUseUdpPortFilters)
    { return LbAdpSetUseUdpPortFilters(hLbAdp,bUseUdpPortFilters); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpAddFilterTcpPort - Add TCP port filter
    VOID AddFilterTcpPort(USHORT Port, DWORD PortType)
    { LbAdpAddFilterTcpPort(hLbAdp,Port,PortType); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpRemoveFilterTcpPort - Remove TCP port filter
    VOID RemoveFilterTcpPort(USHORT Port)
    { LbAdpRemoveFilterTcpPort(hLbAdp,Port); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpRemoveAllTcpPortFilters - Remove all TCP port filters
    VOID RemoveAllTcpPortFilters()
    { LbAdpRemoveAllTcpPortFilters(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpAddFilterUdpPort - Add UDP port filter
    VOID AddFilterUdpPort(USHORT Port, DWORD PortType)
    { LbAdpAddFilterUdpPort(hLbAdp,Port,PortType); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpRemoveFilterUdpPort - Remove UDP port filter
    VOID RemoveFilterUdpPort(USHORT Port)
    { LbAdpRemoveFilterUdpPort(hLbAdp,Port); }

    //---------------------------------------------------------------------------
    // v3.1 - LbAdpRemoveAllUdpPortFilters - Remove all UDP port filters
    VOID RemoveAllUdpPortFilters()
    { LbAdpRemoveAllUdpPortFilters(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetReceiveQueue - Returns the handle of the HNQueue object.
    HANDLE Get_ReceiveQueue()
    { return LbAdpGetReceiveQueue(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetReceiveQueue - Sets the handle of the HNQueue object.
    HANDLE Set_ReceiveQueue(HANDLE hQue)
    { return LbAdpSetReceiveQueue(hLbAdp, hQue); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetEthEmulation - Return Ethernet emulation mode using flag for HNLBAdapter object.
    BOOL Get_EthEmulation()
    { return LbAdpGetEthEmulation(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetEthEmulation - Set Ethernet emulation mode using flag for HNLBAdapter object.
    BOOL Set_EthEmulation(BOOL bEthEmulMode)
    { return LbAdpSetEthEmulation(hLbAdp, bEthEmulMode); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetUserFilter - Returns the handle of the HNUserFilter object. 
    HANDLE Get_UserFilter() 
    { return LbAdpGetUserFilter(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetUserFilter - Sets the handle of the HNUserFilter object. 
    HANDLE Set_UserFilter(HANDLE hUserFilter)
    { return LbAdpSetUserFilter(hLbAdp, hUserFilter); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetUserFilterActive - Returns the status flag of the user-settable packet filter using. 
    BOOL Get_UserFilterActive()
    { return LbAdpGetUserFilterActive(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetUserFilterActive - Sets the status flag of the user-settable packet filter using. 
    BOOL Set_UserFilterActive(BOOL bActiveBpf)
    { return LbAdpSetUserFilterActive(hLbAdp, bActiveBpf); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetUseFastUserFilter - Returns the status flag of the FastBPF using.
    BOOL Get_UseFastUserFilter()
    { return LbAdpGetUseFastUserFilter(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetUseFastUserFilter - Sets the status flag of the FastBPF using.
    BOOL Set_UseFastUserFilter(BOOL bUseFastBpf)
    { return LbAdpSetUseFastUserFilter(hLbAdp, bUseFastBpf); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpUpdateUserStatistics - Updates the user-settable filter statistics synchronously.
    DWORD UpdateUserStatistics()
    { return LbAdpUpdateUserStatistics(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetRecvCount - Returns the number of the packets received by the Packet Sniffer SDK internal driver from OS.
#ifdef _WIN64
    ULONGLONG Get_RecvCount()
    { return LbAdpGetRecvCount(hLbAdp); }
#else
    DWORD Get_RecvCount(DWORD *pHiValue)
    { return LbAdpGetRecvCount(hLbAdp, pHiValue); }
#endif

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetLostCount - Returns the number of the packets lost by the PSSDK internal driver.
#ifdef _WIN64
    ULONGLONG LbAdpGetLostCount()
    { return LbAdpGetLostCount(hLbAdp); }
#else
    DWORD Get_LostCount(DWORD *pHiValue)
    { return LbAdpGetLostCount(hLbAdp, pHiValue); }
#endif

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetAcceptCount - Returns the number of the packets passed by the user-settable packet filter.
#ifdef _WIN64
    ULONGLONG Get_AcceptCount()
    { return LbAdpGetAcceptCount(hLbAdp); }
#else
    DWORD Get_AcceptCount(DWORD *pHiValue)
    { return LbAdpGetAcceptCount(hLbAdp, pHiValue); }
#endif

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetRejectCount - Returns the number of packets rejected by the user-settable packet filter.
#ifdef _WIN64
    ULONGLONG Get_RejectCount()
    { return LbAdpGetRejectCount(hLbAdp); }
#else
    DWORD Get_RejectCount(DWORD *pHiValue)
    { return LbAdpGetRejectCount(hLbAdp, pHiValue); }
#endif

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetProcessCount - Returns the number of the packets transferred to the application.
#ifdef _WIN64
    ULONGLONG Get_ProcessCount()
    { return LbAdpGetProcessCount(hLbAdp); }
#else
    DWORD Get_ProcessCount(DWORD *pHiValue)
    { return LbAdpGetProcessCount(hLbAdp, pHiValue); }
#endif

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetUseHighPrecisionTime - Returns flag status of using High Precision Time.
    BOOL Get_UseHighPrecisionTime()
    { return LbAdpGetUseHighPrecisionTime(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetUseHighPrecisionTime - Sets flag status of using High Precision Time.
    BOOL Set_UseHighPrecisionTime(BOOL bUseHighPrecision)
    { return LbAdpSetUseHighPrecisionTime(hLbAdp, bUseHighPrecision); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetOnPacketRecv - Sets the OnPacketReceive event.
    FARPROC Set_OnPacketRecv(FARPROC pfOnPacketReceive, DWORD_PTR Param)
    { return LbAdpSetOnPacketRecv(hLbAdp, pfOnPacketReceive, Param); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetCalcCheckSum - Return IP/TCP/UDP checksums caculation flag for Ethernet emulation mode.
    BOOL Get_CalcCheckSum()
    { return LbAdpGetCalcCheckSum(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetCalcCheckSum - Set IP/TCP/UDP checksums caculation flag for Ethernet emulation mode.
    BOOL Set_CalcCheckSum(BOOL bCalcCheckSum)
    { return LbAdpSetCalcCheckSum(hLbAdp, bCalcCheckSum); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetMaxThreadCount - Returns the maximal number of the threads allowed to be created for work with the network adapter.
    DWORD Get_MaxThreadCount() 
    { return LbAdpGetMaxThreadCount(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetThreadCount - Returns the number of threads created for work with the network adapter.
    DWORD Get_ThreadCount() 
    { return LbAdpGetThreadCount(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetThreadCount - Sets the number of threads created for work with the network adapter.
    DWORD Set_ThreadCount(DWORD ThreadCount) 
    { return LbAdpSetThreadCount(hLbAdp,ThreadCount); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpGetPacketPool - 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 LbAdpGetPacketPool(hLbAdp); }

    //---------------------------------------------------------------------------
    // v3.2 - LbAdpSetPacketPool - 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 LbAdpSetPacketPool(hLbAdp,dwPacketPool); }
};

//---------------------------------------------------------------------------
#endif // __HN_PSSDK_LBADAPTER_H__ 
//---------------------------------------------------------------------------
See also:HNLBAdapter, All wrappers in one ZIP archive