mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Driver: PCAP: Properly handle RX timeout
If res == 0 the header and data will not be populated because no message was RXed.
This commit is contained in:
@@ -140,6 +140,8 @@ void PCAP::Find(std::vector<FoundDevice>& found) {
|
|||||||
struct pcap_pkthdr* header;
|
struct pcap_pkthdr* header;
|
||||||
const uint8_t* data;
|
const uint8_t* data;
|
||||||
auto res = pcap_next_ex(iface.fp, &header, &data);
|
auto res = pcap_next_ex(iface.fp, &header, &data);
|
||||||
|
if(res == 0)
|
||||||
|
continue;
|
||||||
if(res < 0 || !header || !data) {
|
if(res < 0 || !header || !data) {
|
||||||
if (!warned) {
|
if (!warned) {
|
||||||
warned = true;
|
warned = true;
|
||||||
@@ -148,8 +150,6 @@ void PCAP::Find(std::vector<FoundDevice>& found) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(res == 0)
|
|
||||||
continue; // Keep waiting for that packet
|
|
||||||
|
|
||||||
EthernetPacketizer ethPacketizer([](APIEvent::Type, APIEvent::Severity) {});
|
EthernetPacketizer ethPacketizer([](APIEvent::Type, APIEvent::Severity) {});
|
||||||
memcpy(ethPacketizer.hostMAC, iface.macAddress, sizeof(ethPacketizer.hostMAC));
|
memcpy(ethPacketizer.hostMAC, iface.macAddress, sizeof(ethPacketizer.hostMAC));
|
||||||
|
|||||||
Reference in New Issue
Block a user