1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fixed Sniffer::sniff_loop argument types.

This commit is contained in:
Matias Fontanini
2012-08-15 08:36:37 -03:00
parent 4cf00d7682
commit 6fd0c14b45

View File

@@ -91,7 +91,7 @@ namespace Tins {
* \param max_packets The maximum amount of packets to sniff. 0 == infinite.
*/
template<class Functor>
void sniff_loop(const Functor &function, uint32_t max_packets = 0);
void sniff_loop(Functor function, uint32_t max_packets = 0);
/**
* \brief Sets a filter on this sniffer.
@@ -130,7 +130,7 @@ namespace Tins {
};
template<class Functor>
void Tins::Sniffer::sniff_loop(const Functor &function, uint32_t max_packets) {
void Tins::Sniffer::sniff_loop(Functor function, uint32_t max_packets) {
LoopData<Functor> data(handle, function, wired);
pcap_loop(handle, max_packets, &Sniffer::callback_handler<Functor>, (u_char*)&data);
}
@@ -153,6 +153,29 @@ namespace Tins {
}
}
template<class T>
class HandlerProxy {
public:
typedef T* ptr_type;
typedef bool (T::*fun_type)(PDU*) ;
HandlerProxy(ptr_type ptr, fun_type function)
: object(ptr), fun(function) {}
bool operator()(PDU *pdu) {
return (object->*fun)(pdu);
}
private:
ptr_type object;
fun_type fun;
};
template<class T>
HandlerProxy<T> make_sniffer_handler(T *ptr, typename HandlerProxy<T>::fun_type function)
{
return HandlerProxy<T>(ptr, function);
}
};
#endif // TINS_SNIFFER_H