#define HAVE_REMOTE
#include "pcap.h"
#include <list>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
pcap_if_t* alldevs;
list<pcap_if_t> devices;
char errbuf[PCAP_ERRBUF_SIZE];
//枚举本地计算机的网卡
if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING,NULL,&alldevs,errbuf)==-1)
{
fprintf(stderr,"err:%s/n",errbuf);
}
//保存至链表
while (alldevs!=NULL)
{
devices.push_back(*alldevs);
alldevs=alldevs->next;
}
//打印网卡信息
for (list<pcap_if_t>::iterator iter=devices.begin();iter!=devices.end();++iter)
{
cout<<"device description:"<<iter->description<<endl;
}
//释放设备
pcap_freealldevs(alldevs);
return 0;
}