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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user