• 大小: 353.97 KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-09-28
  • 语言: 其他
  • 标签: VC++  

资源简介

本程序可以探测网络上某特定路由器的相邻路由器连接拓扑图,并在用户界面是一图状结构显示;同时提供显示路由器详细信息,获得路由器所在子网全部主机信息等相关功能。

资源截图

代码片段和文件信息

#include “stdafx.h“

#include “APCPingFunction.h“

#pragma comment (lib“ws2_32“)



void ApcFunc(void *i)
{
IcmpThreadStruct* PIcmpThreadStruct=((ApcParament*)i)->PIcmpThreadStruct;
if(*PIcmpThreadStruct->Stop==false)
{
ICMP_ECHO_REPLY* P_Icmp_Echo_Option=(ICMP_ECHO_REPLY*)i;
ULONG DestIP=(ULONG)P_Icmp_Echo_Option->Address;
hostent *HostInfo=NULL;
if(P_Icmp_Echo_Option->RoundTripTime<100000)
{
sprintf((char*)PIcmpThreadStruct->Buffer“host Address: %-15s; Time Spend: %d ms\r\n“NetIpToString((ULONG)P_Icmp_Echo_Option->Address)P_Icmp_Echo_Option->RoundTripTime);
}
else
{
sprintf((char*)PIcmpThreadStruct->Buffer“host Address: %-15s; Time Out\r\n“NetIpToString((ULONG)P_Icmp_Echo_Option->Address));
}

PIcmpThreadStruct->MessageHandler->SendMessage(WM_PINGPIcmpThreadStruct->wpPIcmpThreadStruct->lp);
}
}
int SearchTheLan(ULONG DestIPULONG NetMaskIcmpThreadStruct* PIcmpThreadStruct)
{
PIcmpThreadStruct->ApcRoutine=(FARPROC)&ApcFunc;
WSADATA tmp;
if(WSAStartup(MAKEWORD(21)&tmp)!=0)
{
return -1;

}
HMODULE hInst=LoadLibrary(“iphlpapi.dll“);
if(!hInst)
{
return -1;
}
//依次获得所需的三个函数指针
PIcmpThreadStruct->IcmpCreateFile=(PIcmpCreateFile)GetProcAddress(hInst“IcmpCreateFile“);
PIcmpThreadStruct->IcmpSendEcho2=(PIcmpSendEcho2)GetProcAddress(hInst“IcmpSendEcho2“);
PIcmpThreadStruct->IcmpCloseHandle=(PIcmpCloseHandle)GetProcAddress(hInst“IcmpCloseHandle“);
if(PIcmpThreadStruct->IcmpCreateFile==NULL||PIcmpThreadStruct->IcmpSendEcho2==NULL||PIcmpThreadStruct->IcmpCloseHandle==NULL)
{
return -1;
}
HANDLE IcmpHandle=0;
IcmpHandle=PIcmpThreadStruct->IcmpCreateFile();//打开ICMP句柄 
if(IcmpHandle==0)
{
return -1;
}
else
{

IP_OPTION_INFORMATION IpOption;//该结构用来控制所发ICMP数据包的IP头的相应字段值 
IpOption.Flags=0;
IpOption.OptionsData=NULL;
IpOption.OptionsSize=0;
IpOption.Tos=0;
IpOption.Ttl=123;
char *SendData = “DF is the best!“; 
ApcParament *ReplyBuffer=new  ApcParament[~ntohl(NetMask)];
ULONG DestAddress=ntohl(NetMask&DestIP);
int NumberOfIP=((~(ntohl(NetMask)))-1);
for(int i=0;i {
ReplyBuffer[i].PIcmpThreadStruct=PIcmpThreadStruct;
DestAddress++;
int Res=0;
Res=PIcmpThreadStruct->IcmpSendEcho2(IcmpHandleNULLPIcmpThreadStruct->ApcRoutine(void*)(&ReplyBuffer[i])htonl(DestAddress)SendData(WORD)strlen(SendData)&IpOptionReplyBuffer[i].Buffer51235000);
SleepEx(1true);
if(*PIcmpThreadStruct->Stop)
{
break;
}
}//end of while
}
while((*PIcmpThreadStruct->Stop)==false&&SleepEx(5000true)==WAIT_IO_COMPLETION );
PIcmpThreadStruct->IcmpCloseHandle(IcmpHandle);
WSACleanup();
if(*PIcmpThreadStruct->Stop!=true)
{
PIcmpThreadStruct->MessageHandler->SendMessage(WM_PING_FINISHPIcmpThreadStruct->wpPIcmpThreadStruct->lp);
}
return 0;
}

UINT MyPingProc( LPVOID pParam )
{
IcmpThreadStruct* PIcmpThreadStruct=new IcmpThreadStruct;
IcmpThre

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3467  2006-12-27 16:00  路由器拓扑发现程序\Code\APCPingFunction.cpp

     文件       1321  2006-12-19 16:00  路由器拓扑发现程序\Code\APCPingFunction.h

     文件       1172  2006-12-04 16:00  路由器拓扑发现程序\Code\DataSupport.h

     文件       6180  2006-12-04 16:00  路由器拓扑发现程序\Code\ExplorerThread.cpp

     文件        729  2006-12-19 16:00  路由器拓扑发现程序\Code\ExplorerThread.h

     文件        320  2006-12-04 16:00  路由器拓扑发现程序\Code\FucntionGetRouterInfo.h

     文件       2669  2006-12-19 16:00  路由器拓扑发现程序\Code\FunctionGetRouterInfo.cpp

     文件       3484  2006-12-27 16:00  路由器拓扑发现程序\Code\LeftView.cpp

     文件       1901  2005-12-21 16:00  路由器拓扑发现程序\Code\LeftView.h

     文件       2687  2005-12-20 16:00  路由器拓扑发现程序\Code\MainFrm.cpp

     文件        875  2005-12-18 16:00  路由器拓扑发现程序\Code\MainFrm.h

     文件     147080  2006-12-19 16:00  路由器拓扑发现程序\Code\NetExplorer.aps

     文件       3781  2005-12-19 16:00  路由器拓扑发现程序\Code\NetExplorer.cpp

     文件        500  2005-12-19 16:00  路由器拓扑发现程序\Code\NetExplorer.h

     文件     855040  2007-05-08 23:29  路由器拓扑发现程序\Code\NetExplorer.ncb

     文件        911  2005-10-20 16:00  路由器拓扑发现程序\Code\NetExplorer.sln

     文件       8192  2007-05-08 23:29  路由器拓扑发现程序\Code\NetExplorer.suo

     文件       6962  2006-12-19 16:00  路由器拓扑发现程序\Code\NetExplorer.vcproj

     文件       1213  2005-12-19 16:00  路由器拓扑发现程序\Code\NetExplorerDoc.cpp

     文件        962  2006-12-19 16:00  路由器拓扑发现程序\Code\NetExplorerDoc.h

     文件      12346  2006-12-27 16:00  路由器拓扑发现程序\Code\NetExplorerView.cpp

     文件       1781  2006-12-19 16:00  路由器拓扑发现程序\Code\NetExplorerView.h

     文件       1466  2005-12-20 16:00  路由器拓扑发现程序\Code\PropertyDialog.cpp

     文件        646  2005-10-27 16:00  路由器拓扑发现程序\Code\PropertyDialog.h

     文件       3319  2005-10-20 16:00  路由器拓扑发现程序\Code\ReadMe.txt

     文件        869  2005-10-29 16:00  路由器拓扑发现程序\Code\ReExplorerDialog.cpp

     文件        462  2005-10-29 16:00  路由器拓扑发现程序\Code\ReExplorerDialog.h

     文件       2250  2006-12-19 16:00  路由器拓扑发现程序\Code\resource.h

     文件       3762  2006-12-19 16:00  路由器拓扑发现程序\Code\ResultOfPingDlg.cpp

     文件       1162  2006-12-19 16:00  路由器拓扑发现程序\Code\ResultOfPingDlg.h

............此处省略17个文件信息

评论

共有 条评论