2014-10-02 35 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。