mirror of
https://github.com/mfontanini/libtins
synced 2026-01-28 20:44:26 +01:00
Rolled the BaseSniffer changes since that was OK.
This commit is contained in:
@@ -76,7 +76,7 @@ namespace Tins {
|
||||
* This constructor is available only in C++11.
|
||||
*/
|
||||
BaseSniffer(BaseSniffer &&rhs) noexcept
|
||||
: handle(nullptr), mask(), prog()
|
||||
: handle(nullptr), mask()
|
||||
{
|
||||
*this = std::move(rhs);
|
||||
}
|
||||
@@ -90,7 +90,6 @@ namespace Tins {
|
||||
using std::swap;
|
||||
swap(handle, rhs.handle);
|
||||
swap(mask, rhs.mask);
|
||||
swap(prog, rhs.prog);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@@ -242,7 +241,6 @@ namespace Tins {
|
||||
|
||||
pcap_t *handle;
|
||||
bpf_u_int32 mask;
|
||||
bpf_program prog;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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