udpgram.cpp
来自「这是一个嗅探器」· C++ 代码 · 共 59 行
CPP
59 行
// UDPGram.cpp: implementation of the UDPGram class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "snifferpro.h"
#include "UDPGram.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
UDPGram::UDPGram()
{
}
UDPGram::UDPGram(const unsigned char *buf,const int buflen)
{
//char *buf=new char[bufferlen];
//int len=bufferlen;
unsigned char *pos;
//memcpy(buf,buffer,bufferlen);
pos=(unsigned char *)buf;
srcport=(*pos)*0x100+(*(pos+1));
pos+=2;
destport=(*pos)*0x100+(*(pos+1));
pos+=2;
totallen=(*pos)*0x100+(*(pos+1));
pos+=2;
checksum=(*pos)*0x100+(*(pos+1));
datalen=buflen-8;
if(datalen>0){
data=new char[datalen];
memcpy(data,buf+8,datalen);
}
else
data=NULL;
//delete[] buf;
}
UDPGram::~UDPGram()
{
if(data!=NULL)
delete[] data;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?