libpcap抓包程序执行时出现Segmentation fault (core dumped)

下边是我的程序
#include
#include
#include

void packet_handler(u_char *user,const struct pcap_pkthdr *pkt_header,const u_char *pkt_data)
{
pcap_dump(user,pkt_header,pkt_data);
printf("....%d",pkt_header->len);
}
int main(int argc,char *argv[])
{
pcap_t *handle;

char errbuf[PCAP_ERRBUF_SIZE];

bpf_u_int32 mask;
bpf_u_int32 net;

//guo lv gui ze
struct bpf_program filter;
char filter_app[]="port 3306";

char *dev;
dev=pcap_lookupdev(errbuf);
pcap_lookupnet(dev,&net,&mask,errbuf);

handle=pcap_open_live(dev,BUFSIZ,1,0,errbuf);

pcap_compile(handle,&filter,filter_app,0,net);
pcap_setfilter(handle,&filter);

pcap_dumper_t* out_pcap;
out_pcap=pcap_dump_open(handle,"/home/qqs/pcak.pcap");

pcap_loop(handle,30,packet_handler,(u_char *)out_pcap);

pcap_dump_flush(out_pcap);

pcap_close(handle);
pcap_dump_close(out_pcap);

return (0);

}

1个回答

qqs1402654893
qqs1402654893 谢谢
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐