设为首页 加入收藏

TOP

VS2012编写获取ARP命令(二)
2014-11-23 17:50:22 来源: 作者: 【 】 浏览:27
Tags:VS2012 编写 获取 ARP 命令
ss.\n",
pIpNetTable->table[0].dwIndex);
return FALSE;
}
//打印出索引为dwCurrIndex的适配器上的ARP表项
for (i=0; i < pIpNetTable->dwNumEntries; ++i)
{
//不相等则说明要打印下一个适配器上的ARP表项
if (pIpNetTable->table[i].dwIndex != dwCurrIndex)
{
dwCurrIndex = pIpNetTable->table[i].dwIndex;
if (InterfaceIdxToInterfaceIp(pIpAddrTable,dwCurrIndex,dwIpAddr))
{
printf("\nInterface: %s on Interface 0x%X\n",inet_ntoa(*((in_addr*)&dwIpAddr)),dwCurrIndex);
printf(" Internet Address\tPhysical Address\tType\n");
}
else
{
printf("Error: Could not convert Interface number 0x%X to IP address.\n",
pIpNetTable->table[0].dwIndex);
return FALSE;
}
}
//打印此ARP表项中的数据

//IP地址
struct in_addr inadTmp;
inadTmp.s_addr = pIpNetTable->table[i].dwAddr;
//类型
switch(pIpNetTable->table[i].dwType)
{
case 1:
strcpy_s(szType,"other");
break;
case 2:
strcpy_s(szType,"invalidated");
break;
case 3:
strcpy_s(szType,"dynamic");
break;
case 4:
strcpy_s(szType,"invalidType");
break;
default:
break;
}
printf(" %-16s\t%02X-%02X-%02X-%02X-%02X-%02X\t%-11s\n",inet_ntoa(inadTmp),
pIpNetTable->table[i].bPhysAddr[0],pIpNetTable->table[i].bPhysAddr[1],
pIpNetTable->table[i].bPhysAddr[2],pIpNetTable->table[i].bPhysAddr[3],
pIpNetTable->table[i].bPhysAddr[4],pIpNetTable->table[i].bPhysAddr[5],
szType);
}
return TRUE;
}

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇VC编程实现运行Excel宏 Run 下一篇VC++网络编程-文件传输

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: