#define HAVE_REMOTE
#include "pcap.h"
void main()
{
pcap_if_t *alldevs;// 适配器列表,它是一个链表的数据结构
pcap_if_t *d; // 保存某个适配器
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
//获取本地设备列表
/* Retrieve the device list from the local machine */
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
exit(1);
}
/* Print the list */
for(d= alldevs; d != NULL; d= d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}
if (i == 0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return;
}
/* We don't need any more the device list. Free it */
pcap_freealldevs(alldevs);
}pcap_if_t *alldevs;// 适配器列表,它是一个链表的数据结构 //查找网络适配器,并把结果保存在 alldevs 里 pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) // 用完之后要释放 pcap_freealldevs(alldevs);
版权声明:本文为博主原创文章,未经博主允许不得转载。
ARP协议(3)ARP编程--winpcap&vs2012配置
原文地址:http://blog.csdn.net/xiongxianhe/article/details/46862815