环境:ubuntu12.04
过程:
1.下载libpcap
2.sudo apt-get install flex
3.sudo apt-get install bison
4.sudo apt-get install libpcap-dev
5.tar -zxv -f 下载的.gz文件
6.cd到相应目录下,./configure; make; sudo make install
7.下面是一个测试程序
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <unistd.h>
-
#include <pcap/pcap.h>
-
int main(int argc,char *argv[]){
-
char *dev, errbuf[PCAP_ERRBUF_SIZE];
-
dev=pcap_lookupdev(errbuf);
-
if(dev==NULL){
-
fprintf(stderr,"couldn't find default device: %s\n",errbuf);
-
return(2);
-
}
-
printf("Device: %s\n",dev);
-
return(0);
-
}
http://blog.csdn.net/fengyun1989/article/details/7384899
8. gcc -test.c -lpcap
9. sudo ./a.out
阅读(9897) | 评论(0) | 转发(0) |