⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rarpgram.cpp

📁 这是一个嗅探器
💻 CPP
字号:
// RARPGram.cpp: implementation of the RARPGram class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "snifferpro.h"
#include "RARPGram.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

RARPGram::RARPGram()
{

}

RARPGram::RARPGram(const unsigned char *buf,unsigned int buflen)
{
	unsigned char *pos=(unsigned char *)buf;
	hdwaddrtype=(*pos)*0x100+(*(pos+1));

	pos+=2;
	prtaddrtype=(*pos)*0x100+(*(pos+1));

	pos+=2;
	hdwaddrlen=(*pos);

	pos++;
	prtaddrlen=(*pos);

	pos++;
	operation=(*pos)*0x100+(*(pos+1));

	pos+=2;
	for(int i=0;i<6;i++){		
		srchdwaddr[i]=BYTE(*pos);
		pos++;
	}

	srcprtaddr=(*pos)*0x1000000+(*(pos+1))*0x10000+(*(pos+2))*0x100+(*(pos+3));

	pos+=4;
	for(i=0;i<6;i++){
		desthdwaddr[i]=BYTE(*pos);
		pos++;
	}

	destprtaddr=(*pos)*0x1000000+(*(pos+1))*0x10000+(*(pos+2))*0x100+(*(pos+3));

}

RARPGram::~RARPGram()
{

}

CString RARPGram::GetSrcHdwAddr()
{
	CString str;
	str.Format("%02X:%02X:%02X:%02X:%02X:%02X",srchdwaddr[0],srchdwaddr[1],srchdwaddr[2],srchdwaddr[3],srchdwaddr[4],srchdwaddr[5]);
	return str;
}

CString RARPGram::GetSrcPrtAddr()
{
	CString str;
	unsigned char *p;

	p=(unsigned char *)&srcprtaddr;
	str.Format("%003u.%003u.%003u.%003u",p[3],p[2],p[1],p[0]);
	return str;
}

CString RARPGram::GetDestHdwAddr()
{
	CString str;
	str.Format("%02X:%02X:%02X:%02X:%02X:%02X",desthdwaddr[0],desthdwaddr[1],desthdwaddr[2],desthdwaddr[3],desthdwaddr[4],desthdwaddr[5]);
	return str;
}

CString RARPGram::GetDestPrtAddr()
{
	CString str;
	unsigned char *p;

	p=(unsigned char *)&destprtaddr;
	str.Format("%003u.%003u.%003u.%003u",p[3],p[2],p[1],p[0]);
	return str;
}

CString RARPGram::GetOperation()
{
	CString str;
	switch(this->operation){
	case 3:
		str.Format("RARP Request");
		break;
	case 4:
		str.Format("RARP Reply");
		break;
	default:
		str.Format("");
	}
	return str;
}

CString RARPGram::GetPrtType()
{
	CString str;
	switch(prtaddrtype){
	case 0x0800:
		str.Format("IP");
		break;
	default:
		str.Format("");
	}
	return str;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -