资源简介
基于MFC的网络数据包的捕获与分析,能够捕获tcp,udp,icmp,igmp数据包
代码片段和文件信息
// AdapaterSelection.cpp : implementation file
//
#include “stdafx.h“
#include “CapturePacket.h“
#include “AdapaterSelection.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdapaterSelection dialog
CAdapaterSelection::CAdapaterSelection(CWnd* pParent /*=NULL*/)
: CDialog(CAdapaterSelection::IDD pParent)
{
//{{AFX_DATA_INIT(CAdapaterSelection)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAdapaterSelection::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdapaterSelection)
DDX_Control(pDX IDC_TREE_NETWORKADAPTERS m_treeAdapater);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAdapaterSelection CDialog)
//{{AFX_MSG_MAP(CAdapaterSelection)
ON_NOTIFY(NM_DBLCLK IDC_TREE_NETWORKADAPTERS OnDblclkTreeNetworkadapters)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdapaterSelection message handlers
BOOL CAdapaterSelection::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//初始化树形选择
HTREEITEM root = m_treeAdapater.InsertItem(_T(“网络适配器“));
if(pcap_findalldevs(&m_pAllDevs m_strErrorBuf) == -1)
return FALSE;
for(m_pDev = m_pAllDevs;m_pDev != NULL;m_pDev = m_pDev->next)
{
char temp[400];
CString strText;
HTREEITEM hSubItem = m_treeAdapater.InsertItem(m_pDev->nameroot);
if(m_pDev->description != NULL)
{
strText.Format(“网卡描述信息 : %s“m_pDev->description);
m_treeAdapater.InsertItem(strTexthSubItem);
}
else
{
m_treeAdapater.InsertItem(“网卡描述信息 : 空“hSubItem);
}
if(m_pDev->addresses != NULL && m_pDev->addresses->addr != NULL)
{
iptos(((struct sockaddr_in *)m_pDev->addresses->addr)->sin_addr.s_addrtemp);
strText.Format(“IP地址 : %s“temp);
m_treeAdapater.InsertItem(strTexthSubItem);
}
else
{
m_treeAdapater.InsertItem(“IP地址 : 空“hSubItem);
}
if(m_pDev->addresses != NULL && m_pDev->addresses->broadaddr != NULL)
{
iptos(((struct sockaddr_in *)m_pDev->addresses->broadaddr)->sin_addr.s_addrtemp);
strText.Format(“广播地址 : %s“temp);
m_treeAdapater.InsertItem(strTexthSubItem);
}
else
{
m_treeAdapater.InsertItem(“广播地址 : 无“hSubItem);
}
if(m_pDev->addresses!=NULL && m_pDev->addresses->netmask!=NULL)
{
iptos(((struct sockaddr_in *)m_pDev->addresses->netmask)->sin_addr.s_addrtemp);
strText.Format(“子网掩码 : %s“temp);
m_treeAdapater.InsertItem(strTexthSubItem);
}
else
{
m_treeAdapater.InsertItem(“子网掩码 : 空“hSubItem);
}
if(m_pDev->addresses!=NULL && m_pDev->addresses->dstaddr!=NULL)
{
iptos(((struct sockaddr_in *)m_pDev->addresses->dstaddr)->sin_addr.s_addrtemp);
strText.Format(“目地地址 : %s“tem
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4552 2007-10-04 17:34 mfc network capture tool\AdapaterSelection.cpp
文件 1553 2007-10-04 17:34 mfc network capture tool\AdapaterSelection.h
文件 860 2007-10-23 00:36 mfc network capture tool\app.manifest
文件 13541 2004-12-21 23:03 mfc network capture tool\appface.h
文件 2532 2004-12-20 14:16 mfc network capture tool\appface.lib
文件 2507 2007-10-09 01:46 mfc network capture tool\ARPPacket.cpp
文件 1336 2013-01-05 16:45 mfc network capture tool\ARPPacket.h
文件 86264 2013-03-05 22:26 mfc network capture tool\CapturePacket.aps
文件 3992 2013-03-05 22:38 mfc network capture tool\CapturePacket.clw
文件 2288 2007-10-11 01:06 mfc network capture tool\CapturePacket.cpp
文件 4978 2012-06-02 20:45 mfc network capture tool\CapturePacket.dsp
文件 551 2007-10-04 10:56 mfc network capture tool\CapturePacket.dsw
文件 1403 2007-10-11 01:06 mfc network capture tool\CapturePacket.h
文件 623616 2013-03-05 22:38 mfc network capture tool\CapturePacket.ncb
文件 57856 2013-03-05 22:38 mfc network capture tool\CapturePacket.opt
文件 262 2013-03-05 22:37 mfc network capture tool\CapturePacket.plg
文件 5362 2013-03-05 22:38 mfc network capture tool\CapturePacket.positions
文件 10658 2013-03-05 22:26 mfc network capture tool\CapturePacket.rc
文件 28858 2013-01-08 21:13 mfc network capture tool\CapturePacketDlg.cpp
文件 3274 2007-10-16 00:58 mfc network capture tool\CapturePacketDlg.h
文件 17 2013-01-09 09:07 mfc network capture tool\configuration\filter.cp
文件 106496 2013-03-05 22:27 mfc network capture tool\Debug\CapturePacket.exe
文件 3707 2007-10-09 11:44 mfc network capture tool\DirDialog.cpp
文件 669 2007-10-09 11:41 mfc network capture tool\DirDialog.h
文件 1773 2007-10-23 01:00 mfc network capture tool\FilterDl.cpp
文件 1284 2007-10-23 00:56 mfc network capture tool\FilterDl.h
文件 1809 2007-10-14 23:25 mfc network capture tool\fr
文件 886 2013-01-05 16:45 mfc network capture tool\fr
文件 320834 2012-05-18 17:33 mfc network capture tool\help.chm
文件 566 2007-10-05 10:49 mfc network capture tool\ICMPPacket.cpp
............此处省略51个文件信息
- 上一篇:USB视频设备采集图像VisualC++程序
- 下一篇:图像的K均值分类
评论
共有 条评论