Wireshark 未打开 pcap_dump 文件

发布于 2024-09-13 19:16:12 字数 692 浏览 2 评论 0原文

我试图以 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追我者格杀勿论 2024-09-20 19:16:12

您对 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. Use pcap_dump_fopen for a FILE pointer. Or continue using pcap_dump_open but simply pass the file name to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文