Skip to content

Commit

Permalink
Reduce CPU usage when waiting for packet arrives
Browse files Browse the repository at this point in the history
set pcap timeout to 1ms
  • Loading branch information
xfangfang committed May 14, 2024
1 parent bd43849 commit fce12fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/exploit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ LcpEchoHandler::LcpEchoHandler(const std::string &iface) {
}

if (!dev->setFilter("pppoes && !ip")) {
std::cerr << "[-] LcpEchoHandler cannot set bfp filter" << std::endl;
std::cerr << "[-] LcpEchoHandler cannot set filter" << std::endl;
}
}

Expand Down Expand Up @@ -179,14 +179,15 @@ int Exploit::setInterface(const std::string &iface) {
// open the device before start capturing/sending packets
pcpp::PcapLiveDevice::DeviceConfiguration config;
config.direction = pcpp::PcapLiveDevice::PCPP_IN;
config.packetBufferTimeoutMs = 1;
if (!dev->open(config)) {
std::cerr << "[-] Cannot open device" << std::endl;
dev = nullptr;
return 1;
}

if (!dev->setFilter(BPF_FILTER)) {
std::cerr << "[-] Cannot set bfp filter" << std::endl;
std::cerr << "[-] Cannot set filter" << std::endl;
}
return 0;
}
Expand Down

0 comments on commit fce12fe

Please sign in to comment.