#include <tins/tins.h>
using namespace Tins;
bool doo(PDU&) {
return false;
}
struct foo {
void bar() {
Sniffer sniffer("wlan1", 1000, true);
/* Uses the helper function to create a proxy object that
* will call this->handle. If you're using boost or C++11,
* you could use boost::bind or std::bind, that will also
* work.
*/
sniffer.sniff_loop(make_sniffer_handler(this, &foo::handle));
// Also valid
sniffer.sniff_loop(doo);
}
bool handle(PDU&) {
// Don't process anything
return false;
}
};
int main() {
foo f;
f.bar();
}g++ cprobe.cpp -o cprobe
/tmp/ccwVIHs7.o: In function `Tins::SnifferIterator::advance()':
cprobe.cpp:(.text._ZN4Tins15SnifferIterator7advanceEv[_ZN4Tins15SnifferIterator7advanceEv]+0x1f): undefined reference to `Tins::BaseSniffer::next_packet()'
/tmp/ccwVIHs7.o: In function `foo::bar()':
cprobe.cpp:(.text._ZN3foo3barEv[_ZN3foo3barEv]+0x72): undefined reference to `Tins::Sniffer::Sniffer(std::string const&, unsigned int, bool, std::string const&)'
/tmp/ccwVIHs7.o: In function `void Tins::BaseSniffer::sniff_loop<Tins::HandlerProxy<foo> >(Tins::HandlerProxy<foo>, unsigned int)':
cprobe.cpp:(.text._ZN4Tins11BaseSniffer10sniff_loopINS_12HandlerProxyI3fooEEEEvT_j[_ZN4Tins11BaseSniffer10sniff_loopINS_12HandlerProxyI3fooEEEEvT_j]+0x1f): undefined reference to `Tins::BaseSniffer::begin()'
cprobe.cpp:(.text._ZN4Tins11BaseSniffer10sniff_loopINS_12HandlerProxyI3fooEEEEvT_j[_ZN4Tins11BaseSniffer10sniff_loopINS_12HandlerProxyI3fooEEEEvT_j]+0x8d): undefined reference to `Tins::BaseSniffer::end()'
/tmp/ccwVIHs7.o: In function `void Tins::BaseSniffer::sniff_loop<bool (*)(Tins::PDU&)>(bool (*)(Tins::PDU&), unsigned int)':
cprobe.cpp:(.text._ZN4Tins11BaseSniffer10sniff_loopIPFbRNS_3PDUEEEEvT_j[_ZN4Tins11BaseSniffer10sniff_loopIPFbRNS_3PDUEEEEvT_j]+0x23): undefined reference to `Tins::BaseSniffer::begin()'
cprobe.cpp:(.text._ZN4Tins11BaseSniffer10sniff_loopIPFbRNS_3PDUEEEEvT_j[_ZN4Tins11BaseSniffer10sniff_loopIPFbRNS_3PDUEEEEvT_j]+0x91): undefined reference to `Tins::BaseSniffer::end()'
/tmp/ccwVIHs7.o: In function `Tins::Sniffer::~Sniffer()':
cprobe.cpp:(.text._ZN4Tins7SnifferD2Ev[_ZN4Tins7SnifferD5Ev]+0x1f): undefined reference to `Tins::BaseSniffer::~BaseSniffer()'
/tmp/ccwVIHs7.o:(.rodata._ZTIN4Tins7SnifferE[_ZTIN4Tins7SnifferE]+0x10): undefined reference to `typeinfo for Tins::BaseSniffer'
collect2: error: ld returned 1 exit status