📄 hnpacket.h
字号:
/****************************************************************************
** **
** PSSDK HNPacket module **
** Copyright (c) 1997 - 2006 microOLAP Technologies LTD, **
** Khalturin A.P., Naumov D.A. **
** Header File **
** **
****************************************************************************/
//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_PACKET_H__
#define __HN_PSSDK_PACKET_H__
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Class CHNPacket
//---------------------------------------------------------------------------
class CHNPacket
{
private:
HANDLE hPkt;
public:
//###########################################################################
// Create & Destroy
//###########################################################################
//---------------------------------------------------------------------------
// Constructor
CHNPacket() { hPkt = NULL; }
//---------------------------------------------------------------------------
// Constructor
CHNPacket(HANDLE hPkt) { this->hPkt = hPkt; }
//---------------------------------------------------------------------------
// PktDestroy
~CHNPacket() {}
public:
//###########################################################################
// Additionals methods
//###########################################################################
BOOL IsValid() { return (hPkt != NULL); }
HANDLE Get_Handle() { return hPkt; }
operator HANDLE() { return hPkt; }
HANDLE operator =(HANDLE hPkt)
{
this->hPkt = hPkt;
return this->hPkt;
}
public:
//###########################################################################
// Methods of redirect
//###########################################################################
//---------------------------------------------------------------------------
// PktCreate - Creates the HNPacket object.
HANDLE Create(DWORD MaxPacketSize)
{ return PktCreate(MaxPacketSize); }
//---------------------------------------------------------------------------
// PktDestroy - Destroys the HNPacket object.
DWORD Destroy(HANDLE hPkt)
{ return PktDestroy(hPkt); }
//---------------------------------------------------------------------------
// PktGetMediumType - Returns the network adapter type.
DWORD Get_MediumType()
{ return PktGetMediumType(hPkt); }
//---------------------------------------------------------------------------
// PktSetMediumType - Returns the network adapter type.
DWORD Set_MediumType(DWORD MediumType)
{ return PktSetMediumType(hPkt, MediumType); }
//---------------------------------------------------------------------------
// PktGetUserData - Returns the value definded by the user.
DWORD_PTR Get_UserData()
{ return PktGetUserData(hPkt); }
//---------------------------------------------------------------------------
// PktSetUserData - Sets the value definded by the user.
DWORD_PTR Set_UserData(DWORD_PTR UserData)
{ return PktSetUserData(hPkt,UserData); }
//---------------------------------------------------------------------------
// PktGetId - Returns the packet number.
#ifdef _WIN64
ULONGLONG Get_Id()
{ return PktGetId(hPkt); }
#else
DWORD Get_Id(DWORD *pHiValue)
{ return PktGetId(hPkt,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// PktSetId - Sets the packet number.
#ifdef _WIN64
ULONGLONG Set_Id(ULONGLONG Value)
{ return PktSetId(hPkt, Value); }
#else
DWORD Set_Id(DWORD LowPart, DWORD HiPart)
{ return PktSetId(hPkt, LowPart, HiPart); }
#endif //_WIN64
//---------------------------------------------------------------------------
// PktGetTimeStamp - Returns the time of the packet receiving.
#ifdef _WIN64
LONGLONG Get_TimeStamp()
{ return PktGetTimeStamp(hPkt); }
#else
DWORD Get_TimeStamp(DWORD *pHiValue)
{ return PktGetTimeStamp(hPkt,pHiValue); }
#endif //_WIN64
//---------------------------------------------------------------------------
// PktSetTimeStamp - Sets the time of the packet receiving.
#ifdef _WIN64
LONGLONG Set_TimeStamp(LONGLONG Value)
{ return PktSetTimeStamp(hPkt, Value); }
#else
DWORD Set_TimeStamp(DWORD LowPart, DWORD HiPart)
{ return PktSetTimeStamp(hPkt, LowPart, HiPart); }
#endif //_WIN64
//---------------------------------------------------------------------------
// PktGetMaxPacketSize - Returns the size of the buffer allocated for packet.
DWORD Get_MaxPacketSize()
{ return PktGetMaxPacketSize(hPkt); }
//---------------------------------------------------------------------------
// PktGetPacketSize - Returns the actual size of the packet received by PSSDK internal driver.
DWORD Get_PacketSize()
{ return PktGetPacketSize(hPkt); }
//---------------------------------------------------------------------------
// PktSetPacketSize - Sets the actual size of the packet received by PSSDK internal driver.
DWORD Set_PacketSize(DWORD PacketSize)
{ return PktSetPacketSize(hPkt,PacketSize); }
//---------------------------------------------------------------------------
// PktGetIncPacketSize - Returns the size of the packet sent by PSSDK driver to the user application.
DWORD Get_IncPacketSize()
{ return PktGetIncPacketSize(hPkt); }
//---------------------------------------------------------------------------
// PktSetIncPacketSize - Sets the size of the packet sent by PSSDK driver to the user application.
DWORD Set_IncPacketSize(DWORD IncPacketSize)
{ return PktSetIncPacketSize(hPkt,IncPacketSize); }
//---------------------------------------------------------------------------
// PktGetPacketData - Returns the pointer to the packet data.
LPVOID Get_PacketData()
{ return PktGetPacketData(hPkt); }
//---------------------------------------------------------------------------
// PktCopyPacketToPacket - Copies current packet to another one.
DWORD CopyToPacket(HANDLE hDstPkt)
{ return PktCopyPacketToPacket(hDstPkt,hPkt); }
//---------------------------------------------------------------------------
// PktCopyPacketToPacket - Copies arbitrary packet to the current one.
DWORD CopyFromPacket(HANDLE hSrcPkt)
{ return PktCopyPacketToPacket(hPkt,hSrcPkt); }
//---------------------------------------------------------------------------
// PktInetCheckSum - Counts the IP packets checksum.
WORD InetCheckSum(LPVOID pXData, DWORD Length)
{ return PktInetCheckSum(pXData,Length); }
//---------------------------------------------------------------------------
// PktTransportCheckSum - Counts the TCP and UDP packets checksums.
WORD TransportCheckSum(LPVOID pPacket, DWORD PacketLen, DWORD Proto, DWORD SrcIP, DWORD DstIP)
{ return PktTransportCheckSum(pPacket,PacketLen,Proto,SrcIP,DstIP); }
//---------------------------------------------------------------------------
// PktIPGenerate - Creates an IP packet.
DWORD IPGenerate(LPVOID pIPPacket, DWORD PacketLen, DWORD Proto, DWORD SrcIP, DWORD DstIP)
{ return PktIPGenerate(pIPPacket,PacketLen,Proto,SrcIP,DstIP); }
//---------------------------------------------------------------------------
// PktUDPGenerate - Creates a UDP packet.
DWORD UDPGenerate(LPVOID pUDPPacket, DWORD PacketLen, WORD SrcPort, WORD DstPort)
{ return PktUDPGenerate(pUDPPacket,PacketLen,SrcPort,DstPort); }
//---------------------------------------------------------------------------
// PktTCPGenerate - Creates a TCP packet.
DWORD TCPGenerate(LPVOID pTCPPacket, WORD SrcPort, WORD DstPort, DWORD Seq, DWORD Ack, WORD Win)
{ return PktTCPGenerate(pTCPPacket,SrcPort,DstPort,Seq,Ack,Win); }
};
//---------------------------------------------------------------------------
#endif // __HN_PSSDK_PACKET_H__
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -