libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
Tins::FileSniffer Class Reference

Reads pcap files and interprets the packets in it. More...

#include <sniffer.h>

Inheritance diagram for Tins::FileSniffer:
Tins::BaseSniffer

Public Member Functions

 FileSniffer (const std::string &file_name, const SnifferConfiguration &configuration)
 Constructs an instance of FileSniffer. More...
 
 FileSniffer (const std::string &file_name, const std::string &filter="")
 Constructs an instance of FileSniffer. More...
 
- Public Member Functions inherited from Tins::BaseSniffer
 BaseSniffer (BaseSniffer &&rhs) TINS_NOEXCEPT
 Move constructor. This constructor is available only in C++11.
 
BaseSnifferoperator= (BaseSniffer &&rhs) TINS_NOEXCEPT
 Move assignment operator. This operator is available only in C++11.
 
virtual ~BaseSniffer ()
 Sniffer destructor. This frees all memory used by the pcap handle.
 
PtrPacket next_packet ()
 Compiles a filter and uses it to capture one packet. More...
 
template<typename Functor >
void sniff_loop (Functor function, uint32_t max_packets=0)
 Starts a sniffing loop, using a callback functor for every sniffed packet. More...
 
bool set_filter (const std::string &filter)
 Sets a filter on this sniffer. More...
 
void stop_sniff ()
 Stops sniffing loops. More...
 
int get_fd ()
 Gets the file descriptor associated with the sniffer.
 
bool set_direction (pcap_direction_t d)
 Sets direction for the sniffer. More...
 
void set_timeout (int ms)
 Sets the read timeout for this sniffer. More...
 
void set_extract_raw_pdus (bool value)
 Sets whether to extract RawPDUs or fully parsed packets. More...
 
int link_type () const
 Retrieves this sniffer's link type. More...
 
iterator begin ()
 
iterator end ()
 
pcap_t * get_pcap_handle ()
 
const pcap_t * get_pcap_handle () const
 

Additional Inherited Members

- Public Types inherited from Tins::BaseSniffer
typedef SnifferIterator iterator
 
- Protected Member Functions inherited from Tins::BaseSniffer
 BaseSniffer ()
 
void set_pcap_handle (pcap_t *pcap_handle)
 
void set_if_mask (bpf_u_int32 if_mask)
 
bpf_u_int32 get_if_mask () const
 

Detailed Description

Reads pcap files and interprets the packets in it.

This class acts exactly in the same way that Sniffer, but reads packets from a pcap file instead of an interface.

Constructor & Destructor Documentation

Tins::FileSniffer::FileSniffer ( const std::string &  file_name,
const SnifferConfiguration configuration 
)

Constructs an instance of FileSniffer.

Parameters
file_nameThe pcap file which will be parsed.
filterA capture filter to be used on the file.(optional);
Tins::FileSniffer::FileSniffer ( const std::string &  file_name,
const std::string &  filter = "" 
)

Constructs an instance of FileSniffer.

Deprecated:
Use the constructor that takes a SnifferConfiguration instead.
Parameters
file_nameThe pcap file which will be parsed.
filterA capture filter to be used on the file.(optional);

The documentation for this class was generated from the following file: