1. 安装mingw和winpcap
2. 下载winpcap developpack,将include 和lib,复制到mingw安装目录include和lib下
3. 测试代码
-
#include <stdio.h>
-
-
#include "pcap.h"
-
-
int main()
-
-
{
-
-
pcap_if_t* devlist;
-
-
pcap_if_t* cur;
-
-
char errbuf[16];
-
-
int count = 0;
-
-
pcap_findalldevs(&devlist, errbuf);
-
-
for(cur=devlist;cur;cur = cur->next,++count){
-
-
printf("%d:\n%s\n%s\n", count, cur->description, cur->name);
-
-
}
-
-
pcap_freealldevs(devlist);
-
-
return 0;
-
-
}
使用 gcc -g pcapfirst.c -o pcapfirst.exe -lwpcap -lpacket 编译
参考 http://blog.csdn.net/qwidget/article/details/5671573
阅读(1891) | 评论(0) | 转发(0) |