mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Added promisc flag on Sniffer to start the put interfaces into promiscuous mode.
This commit is contained in:
@@ -66,10 +66,10 @@ namespace Tins {
|
||||
* \brief Creates an instance of sniffer.
|
||||
* \param device The device which will be sniffed.
|
||||
* \param max_packet_size The maximum packet size to be read.
|
||||
* \param timeout The time in seconds to wait for a packet.
|
||||
* \param promisc bool indicating wether to put the interface in promiscuous mode.
|
||||
* \param filter A capture filter to compile and use for sniffing sessions.(optional);
|
||||
*/
|
||||
Sniffer(const std::string &device, unsigned max_packet_size, unsigned timeout = 0, const std::string &filter = "") throw(std::runtime_error);
|
||||
Sniffer(const std::string &device, unsigned max_packet_size, bool promisc = false, const std::string &filter = "") throw(std::runtime_error);
|
||||
|
||||
/**
|
||||
* \brief Sniffer destructor.
|
||||
|
||||
@@ -40,13 +40,13 @@ struct LoopData {
|
||||
/** \endcond */
|
||||
|
||||
|
||||
Tins::Sniffer::Sniffer(const string &device, unsigned max_packet_size, unsigned timeout, const string &filter) throw(std::runtime_error) {
|
||||
Tins::Sniffer::Sniffer(const string &device, unsigned max_packet_size, bool promisc, const string &filter) throw(std::runtime_error) {
|
||||
char error[PCAP_ERRBUF_SIZE];
|
||||
if (pcap_lookupnet(device.c_str(), &ip, &mask, error) == -1) {
|
||||
ip = 0;
|
||||
mask = 0;
|
||||
}
|
||||
handle = pcap_open_live(device.c_str(), max_packet_size, 0, timeout, error);
|
||||
handle = pcap_open_live(device.c_str(), max_packet_size, promisc, 0, error);
|
||||
if(!handle)
|
||||
throw runtime_error(error);
|
||||
wired = (pcap_datalink (handle) != DLT_IEEE802_11_RADIO); //better plx
|
||||
|
||||
Reference in New Issue
Block a user