diff --git a/include/sniffer.h b/include/sniffer.h index f822da0..39125fb 100644 --- a/include/sniffer.h +++ b/include/sniffer.h @@ -159,6 +159,11 @@ namespace Tins { * \brief Stops sniffing loops. */ void stop_sniff(); + + /** + * \brief Gets the file descriptor associated with the sniffer. + */ + int get_fd(); protected: /** * Default constructor. diff --git a/src/sniffer.cpp b/src/sniffer.cpp index 6b7bc9f..eb0293e 100644 --- a/src/sniffer.cpp +++ b/src/sniffer.cpp @@ -105,6 +105,10 @@ void BaseSniffer::stop_sniff() { pcap_breakloop(handle); } +int BaseSniffer::get_fd() { + return pcap_get_selectable_fd(handle); +} + bool BaseSniffer::set_filter(const std::string &filter) { if(actual_filter.bf_insns) pcap_freecode(&actual_filter);