mirror of
https://github.com/mfontanini/libtins
synced 2026-01-26 03:51:35 +01:00
Moved calls to pcap_loop and pcap_breakloop to sniffer.cpp.
This commit is contained in:
@@ -231,17 +231,21 @@ namespace Tins {
|
||||
bool &went_well;
|
||||
pcap_t *handle;
|
||||
|
||||
void proxy_pcap_breakloop(pcap_t *);
|
||||
|
||||
PCapLoopBreaker(bool &went_well, pcap_t *handle)
|
||||
: went_well(went_well), handle(handle) { }
|
||||
|
||||
~PCapLoopBreaker() {
|
||||
if(!went_well)
|
||||
pcap_breakloop(handle);
|
||||
proxy_pcap_breakloop(handle);
|
||||
}
|
||||
};
|
||||
|
||||
BaseSniffer(const BaseSniffer&);
|
||||
BaseSniffer &operator=(const BaseSniffer&);
|
||||
|
||||
int proxy_pcap_loop(pcap_t *, int, pcap_handler, u_char *);
|
||||
|
||||
|
||||
template<class ConcretePDU, class Functor>
|
||||
@@ -301,7 +305,7 @@ namespace Tins {
|
||||
template<class Functor>
|
||||
void Tins::BaseSniffer::sniff_loop(Functor function, uint32_t max_packets) {
|
||||
LoopData<Functor> data(handle, function, iface_type);
|
||||
pcap_loop(handle, max_packets, &BaseSniffer::callback_handler<Functor>, (u_char*)&data);
|
||||
proxy_pcap_loop(handle, max_packets, &BaseSniffer::callback_handler<Functor>, (u_char*)&data);
|
||||
}
|
||||
|
||||
template<class ConcretePDU, class Functor>
|
||||
|
||||
@@ -119,6 +119,14 @@ bool BaseSniffer::set_filter(const std::string &filter) {
|
||||
return compile_set_filter(filter, actual_filter);
|
||||
}
|
||||
|
||||
int BaseSniffer::proxy_pcap_loop(pcap_t *p1, int p2, pcap_handler p3, u_char *p4) {
|
||||
return pcap_loop(p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
void BaseSniffer::PCapLoopBreaker::proxy_pcap_breakloop(pcap_t *p1) {
|
||||
pcap_breakloop(p1);
|
||||
}
|
||||
|
||||
// ****************************** Sniffer ******************************
|
||||
|
||||
Sniffer::Sniffer(const string &device, unsigned max_packet_size,
|
||||
|
||||
Reference in New Issue
Block a user