Driver: PCAP: Properly handle RX timeout

If res == 0 the header and data will not be populated because no message
was RXed.
pull/56/head
Kyle Schwarz 2023-03-29 00:51:38 -04:00
parent d9cdd03618
commit cd7b0b0a7b
1 changed files with 2 additions and 2 deletions

View File

@ -140,6 +140,8 @@ void PCAP::Find(std::vector<FoundDevice>& found) {
struct pcap_pkthdr* header;
const uint8_t* data;
auto res = pcap_next_ex(iface.fp, &header, &data);
if(res == 0)
continue;
if(res < 0 || !header || !data) {
if (!warned) {
warned = true;
@ -148,8 +150,6 @@ void PCAP::Find(std::vector<FoundDevice>& found) {
}
break;
}
if(res == 0)
continue; // Keep waiting for that packet
EthernetPacketizer ethPacketizer([](APIEvent::Type, APIEvent::Severity) {});
memcpy(ethPacketizer.hostMAC, iface.macAddress, sizeof(ethPacketizer.hostMAC));