SoftEtherVPN / Win10Pcap

Win10Pcap: WinPcap for Windows 10 (NDIS 6.x driver model)
Other
337 stars 122 forks source link

pcap_open_live is not thread safe #26

Open omarekik opened 3 years ago

omarekik commented 3 years ago

pcap_open_live is thread safe in winpcap 4.1.3 but not in win10pcap.

omarekik commented 3 years ago

As workaround for capturing packets of all interfaces, we need to open adapter devices sequencely in the main program and then for each opened adapter device we can create a thread to read the packets from the device and dump them to a pcap file.

main program { fp= pcap_open_live(adapterName.c_str(), 65535, 0, 500, errorBuffer)}

Thread: while (!stopDumping) { pcap_next_ex( fp, &header, &pkt_data); pcap_dump((u_char*)dumpfile, header, pkt_data); }