Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to immediate mode #1291

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions libnetutil/netutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4110,17 +4110,23 @@ pcap_t *my_pcap_open_live(const char *device, int snaplen, int promisc, int to_m
Strncpy(pcapdev, device, sizeof(pcapdev));
#endif
do {
pt = pcap_open_live(pcapdev, snaplen, promisc, to_ms, err0r);
pt = pcap_create(pcapdev, err0r);
if (!pt) {
failed++;
if (failed >= 3) {
return NULL;
} else {
netutil_error("pcap_open_live(%s, %d, %d, %d) FAILED. Reported error: %s. Will wait %d seconds then retry.", pcapdev, snaplen, promisc, to_ms, err0r, compute_sleep_time(failed));
netutil_error("pcap_create(%s) FAILED. Reported error: %s. Will wait %d seconds then retry.", pcapdev, err0r, compute_sleep_time(failed));
}
sleep( compute_sleep_time(failed) );
}
} while (!pt);

pcap_set_snaplen(pt, snaplen);
pcap_set_promisc(pt, promisc);
pcap_set_timeout(pt, to_ms); // Ignored in immediate mode
pcap_set_immediate_mode(pt, 1); // TODO: What if we're using the system libpcap and this function doesn't exist?
pcap_activate(pt); // TODO: Do we need to check for failure here?

#ifdef WIN32
if (wait == WAIT_ABANDONED || wait == WAIT_OBJECT_0) {
Expand Down