2014-10-02 66 views
0

我正在制作一个使用MINGW的C++程序,它使用Winpcap库将BTLE数据包保存到PCAP文件中。无法使用winpcap写入DLT_USER0捕获

我想使用DLT_USER0链接层类型打开PCAP文件。

我可以通过调用pcap_open_dead()来打开DLT_USER0,但pcap_dump_open()却抱怨说它不知道相应的链接类型。

我得到以下信息调用pcap_geterr()后:

 out-dump.pcap: link-layer type -1 isn't supported in savefiles 

这里是我下面的代码。

#define OUT_FILENAME "out-dump.pcap" 

pcap_t *pcap_dumpfile; // Descriptor of an open capture instance 
pcap_dumper_t *dumper; // libpcap savefile descriptor" 

// pcap_open_dead() creates a pcap_t structure to use when 
// calling other functions in libpacp 
pcap_dumpfile = pcap_open_dead(DLT_USER0, 128); 

// Check if pcap_dumpfile was created. If it was not it will return a NULL 
if (NULL == pcap_dumpfile) 
{ 
    cout << "\npcap_open_dead() FAILED!!!" << endl; 
} 
else 
{ 
    // Open a save file to write to! 
    dumper = pcap_dump_open(pcap_dumpfile, OUT_FILENAME); 

    pcap_dump_flush(dumper); 

    // Check if the dumper was created 
    if (NULL == dumper) 
    { 
     // Printout the FAIL status 
     cout << "\npcap_dump_open() FAILED!!!" << endl; 

     // Printout the PCAP Error 
     cout << "\n" << pcap_geterr(pcap_dumpfile) << endl; 

     // Close the pcap_dumpfile and deallocate it's resources 
     pcap_close(pcap_dumpfile); 
    } 
} 

我使用WinPcap 4.1.2 Developer Pack打造我的C++应用程序。

回答

0

不幸的是,这是WinPcap 4.1.2中的一个错误。

希望未来的WinPcap版本将基于更新后的libpcap版本,该版本修复了该bug。