📄 packethandle.h
字号:
#ifndef _PacketHandle_H_
#define _PacketHandle_H_
/****************Type Defination************************/
//Packet Data.
typedef struct tagSavedPacketData{
// struct tagSavePacketData *prev;
struct tagSavedPacketData *next;
ULONG uPacketLength;
U8 *pPacketData;
//Only to Tcp protocol;
U32 identity;//Identity the Data Packet.
//The member of Tcp 's .
//To sort the Tcp packet.
}SavedPacketData;
//Data Packet.
typedef struct tagSavedDataPacket{
//struct tagSavedDataPacket *prev;
//struct tagSavedDataPacket *next;
SavedPacketData *pSavedData;//Point to the packet link.
U16 uFilterFlag;//Indicate whether has packet to saved,
//if has ,The flag will be NoZero,
//else will be Zero.
//Only to Tcp packet.
U16 uTcpFilterFlag;//Indicate whether the save data's protocol is TCP.
//if Is ,The flag will be NoZero,
//else will be Zero.
}SavedPacketEntry;
/****************Variable Declaration*******************/
//Default number of saved packet.
#define iDefSavedPacketNum 10
extern int iCurSavedPacketNum;//current number of saved packet.
extern SavedPacketEntry *pSavedPacketEntry;//The Entry link of packet saved.
//Spin lock of saved packet entry.
extern KSPIN_LOCK SavedPacketEntryLock;
extern KIRQL SavedPacketEntryIrql;
/***************Function Declaration(External)*************/
//Initialize the buffer of saved packet.
//mainly allocate some buffer and initialize it.
//If Success,return zero,
//else return NoZero.
int InitPacketBuffer(void);
//Free the buffer of saved packet.
//No return value.
void FreePacketBuffer(void);
//Zap the buffer of saved packet.
//Zero it!!
//You can call it when you Create and Close the Gui device.
void ZapPacketBuffer(void);
//ReAllocate the Buffer Size of saved packet.
//If success,return Zero;
//else return NoZero.
int ReAllocatePacketBuffer(int iInputReAllocSize);
/*External Function*/
//Read the data from packet buffer.
//Called by MyDeviceRead().
void ReadPacketBuffer(
ULONG uInputReadLen,
ULONG *uOutputReadLen,
void *pOutputDataBuffer
);
/*External Function*/
//copy the data from ndis packet.
// If the Variables:iInputCopyFlag(Input) == NoZero,
// allocate a new buffer and copy all data to it.
// Else copy bytes equare Or less uInputNumOfBytesToRead(Input) .
//(The Function Copy And Modified from http://www.pcausa.com)
//If Success return Zero,else return NoZero.
int CopyDataFromPacket(
PNDIS_PACKET pInputPacket,
ULONG uInputNumOfBytesToRead,
U8 **ppOutputBuffer,
ULONG *puOutputNumOfBytesRead,
int iInputCopyFlag
);
//Get Identify from Ip Packet.
#define GetIdentifyFromIpPacket(pInputIpPacket) \
( ( (PIpPacketHeader)(pInputIpPacket) )->identify )
//Little Endian to Big Endian.(Type : Short)
//Some data handle want to call it.
//(such as Special Code Function .
// After Translated ,The value 's comparion will be smart.
#define LittleToBigEndianShort(iInputValue) \
{ \
(iInputValue) = ( (( (iInputValue) & 0xff00)>>8) \
| (( (iInputValue) & 0x00ff)<<8) ); \
}
//Big Endian to Little Endian.(Type : Short)
//Some data handle want to call it.
//(such as Ip packet header's (total length) and (offset).
#define BigToLittleEndianShort(iInputValue) \
{ \
(iInputValue) = ( (( (iInputValue) & 0xff00)>>8) \
| (( (iInputValue) & 0x00ff)<<8) ); \
}
//Big Endian to Little Endian.(Type : Ulong)
//Some data handle want to call it.
//(such as Ip packet header's (total length) and (offset).
#define BigToLittleEndianUlong(iInputValue) \
{ \
(iInputValue) = ( ( ( (iInputValue) & 0xff000000) >>24) \
| ( (iInputValue) & 0x00ff0000) >>8) \
| ( (iInputValue) & 0x0000ff00) <<8) \
| ( (iInputValue) & 0x000000ff) <<24) ); \
}
#endif//_PacketHandle_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -