3,881
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <pcap.h>
#include <errno.h>
int main()
{
char ebuf[PCAP_ERRBUF_SIZE];
pcap_t *pd=pcap_open_live("eth0",68,0,1000,ebuf);
struct bpf_program fcode;
pcap_compile(pd,&fcode,NULL,1,0);
pcap_setfilter(pd,&fcode);
pcap_handler eth_printer;
pcap_loop(pd,10,eth_printer,NULL);
pcap_close(pd);
return 0;
}