Wireshark 未打开 pcap_dump 文件
我试图以 libpcap 格式保存该文件的输出,尽管该文件确实已保存并且正确的数据已写入其中,但 Wireshark 无法打开它。有人看到我在这里缺少什么吗?谢谢。
// opening the device here to listen
handle = pcap_open_live( dev, BUFSIZ, 1, 1000, errbuf );
unsigned int dlt = DLT_EN10MB;
pcap_set_datalink(handle,dlt );
FILE *filename;
filename = fopen("/workarea/capture","a+");
pcap_dumper_t * dump = NULL;
// opens the file
dump = pcap_dump_open( handle, (const char *)filename );
pcap_loop(handle,-1,my_callback,(unsigned char *)filename);
return (0);
}
void my_callback(u_char *dump,const struct pcap_pkthdr* pkthdr,const u_char *packet)
{
unsigned int i=0;
pcap_dump(dump,pkthdr,packet);
}
I am trying to save the output of this file in libpcap format and although the file does get saved and the right data is written into it, Wireshark is unable to open it. Anyone see what I am missing here ? Thanks.
// opening the device here to listen
handle = pcap_open_live( dev, BUFSIZ, 1, 1000, errbuf );
unsigned int dlt = DLT_EN10MB;
pcap_set_datalink(handle,dlt );
FILE *filename;
filename = fopen("/workarea/capture","a+");
pcap_dumper_t * dump = NULL;
// opens the file
dump = pcap_dump_open( handle, (const char *)filename );
pcap_loop(handle,-1,my_callback,(unsigned char *)filename);
return (0);
}
void my_callback(u_char *dump,const struct pcap_pkthdr* pkthdr,const u_char *packet)
{
unsigned int i=0;
pcap_dump(dump,pkthdr,packet);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对
pcap_dump_open
的调用似乎不正确。它正在传递 FILE* 指针,但应该传递文件名。使用 pcap_dump_fopen 作为 FILE 指针。或者继续使用 pcap_dump_open 但只需将文件名传递给它。Your call to
pcap_dump_open
does not seem correct. It is passing a FILE* pointer but should be passing a file name. Usepcap_dump_fopen
for a FILE pointer. Or continue using pcap_dump_open but simply pass the file name to it.