我正在尝试以 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);
}