#ifndef SNIFFER_H #define SNIFFER_H #include /** * @class Sniffer * * Sniffs the network. * * Sniffer class which will sniff on a network interface. It is supposed to forward the packets to an analyzer or * modifyer so we can hide data in the traffic. */ class Sniffer { public: /** * Creates a Sniffer. * * Creates a Sniffer and sets the network interface for sniffing. * * @param interface name of the interface for sniffing */ Sniffer(std::string interfaceName); /** * Destroys the Sniffer. * * Destructor of the Sniffer. */ ~Sniffer(); /** * Start sniffing on the interface. * * Starts a sniffing loop which calls handle. The loop will only be stopped if handle returns false. */ void startSniffing(); /** * Sets a filter for the sniffer. * * Sets the filter for a sniffer with a pcap filter string. E.g. "ip dst 8.8.8.8". * * @param filterString pcap filter string */ void setFilter(std::string filterString); private: /** * Handler for sniffed packets. * * Handles incoming connections and provides data for the package analyzer and modifyer. * * @param pdu sniffed packet * * @return false = stop loop | true = continue loop */ bool handle(Tins::PDU& pdu); /** * Tins sniffer object. */ Tins::Sniffer sniffer; }; #endif