#include <pcap.h>
/*
枚举网络接口
1.枚举
2.读取
3.释放内存
*/
int main()
{
pcap_if_t *alldevs;
int count = 0;
char errbuf[PCAP_ERRBUF_SIZE];
if(pcap_findalldevs_ex(PCAP_SRC_IF_STRING,
NULL, &alldevs, errbuf) == -1){
fprintf(stderr, "%s\n", errbuf);
return 0;
}
for(auto d = alldevs; d != NULL; d = d->next){
printf("%d. %s", ++count, d->name);
if(d->description)
printf("(%s)\n", d->description);
else
printf("(no description available)\n");
}
if(count == 0)
printf("No interface found!\n");
pcap_freealldevs(alldevs);
return 0;
}
winpcap--枚举网络接口
最新推荐文章于 2019-12-18 19:49:41 发布