1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 12:44:25 +01:00

Rolled the BaseSniffer changes since that was OK.

This commit is contained in:
Matias Fontanini
2013-09-20 12:37:21 -03:00
parent 96ecd054ab
commit 1b4efc1520
2 changed files with 4 additions and 6 deletions

View File

@@ -36,14 +36,12 @@ using std::runtime_error;
namespace Tins {
BaseSniffer::BaseSniffer()
: handle(0), mask(0), prog()
: handle(0), mask(0)
{
}
BaseSniffer::~BaseSniffer() {
if(prog.bf_insns)
pcap_freecode(&prog);
if(handle)
pcap_close(handle);
}
@@ -114,9 +112,11 @@ BaseSniffer::iterator BaseSniffer::end() {
}
bool BaseSniffer::set_filter(const std::string &filter) {
bpf_program prog;
if(pcap_compile(handle, &prog, filter.c_str(), 0, mask) == -1)
return false;
bool result = pcap_setfilter(handle, &prog) != -1;
pcap_freecode(&prog);
return result;
}