1
0
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:
Matias Fontanini
2013-09-08 19:20:52 -03:00
parent e21e34e194
commit d393c1fbfc
2 changed files with 14 additions and 2 deletions

View File

@@ -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>

View File

@@ -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,