libtins  3.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
Tins::SnifferConfiguration Class Reference

Represents the configuration of a BaseSniffer object. More...

#include <sniffer.h>

Public Member Functions

 SnifferConfiguration ()
 
void set_snap_len (unsigned snap_len)
 
void set_buffer_size (unsigned buffer_size)
 
void set_promisc_mode (bool enabled)
 
void set_filter (const std::string &filter)
 
void set_rfmon (bool enabled)
 
void set_timeout (unsigned timeout)
 
void set_direction (pcap_direction_t direction)
 
void set_immediate_mode (bool enabled)
 

Static Public Attributes

static const unsigned DEFAULT_SNAP_LEN = 65535
 The default snapshot length. More...
 
static const unsigned DEFAULT_TIMEOUT = 1000
 The default timeout. More...
 

Protected Types

enum  Flags {
  BUFFER_SIZE = 1, PROMISCUOUS = 2, RFMON = 4, PACKET_FILTER = 8,
  IMMEDIATE_MODE = 16, DIRECTION = 32
}
 

Protected Member Functions

void configure_sniffer_pre_activation (Sniffer &sniffer) const
 
void configure_sniffer_pre_activation (FileSniffer &sniffer) const
 
void configure_sniffer_post_activation (Sniffer &sniffer) const
 

Protected Attributes

uint32_t flags_
 
unsigned snap_len_
 
unsigned buffer_size_
 
std::string filter_
 
unsigned timeout_
 
bool promisc_
 
bool rfmon_
 
bool immediate_mode_
 
pcap_direction_t direction_
 

Friends

class Sniffer
 
class FileSniffer
 

Detailed Description

Represents the configuration of a BaseSniffer object.

This class can be used as an easy way to configure a Sniffer or FileSniffer object.

It can be used by constructing an object of this type, setting the desired values and then passing it to the Sniffer or FileSniffer object's constructor. This sets default values for some attributes:

For any of the attributes not listed above, the associated pcap function which is used to set them on a pcap handle won't be called at all.

This class can be used to configure a Sniffer object, like this:

// Initialize the configuration.
config.set_filter("ip and port 80");
config.set_promisc_mode(true);
// Use it on a Sniffer object.
Sniffer sniffer("eth0", config);

Constructor & Destructor Documentation

Tins::SnifferConfiguration::SnifferConfiguration ( )

Default constructs a SnifferConfiguration.

Member Function Documentation

void Tins::SnifferConfiguration::set_buffer_size ( unsigned  buffer_size)

Sets the buffer size option.

Parameters
buffer_sizeThe buffer size to be set.
void Tins::SnifferConfiguration::set_direction ( pcap_direction_t  direction)

Sets the direction option.

Parameters
directionThe direction to be set.
void Tins::SnifferConfiguration::set_filter ( const std::string &  filter)

Sets a pcap filter to use on the sniffer.

Parameters
filterThe pcap filter to be used.
void Tins::SnifferConfiguration::set_immediate_mode ( bool  enabled)

Sets the immediate mode option.

Parameters
enabledThe immediate mode option value.
void Tins::SnifferConfiguration::set_promisc_mode ( bool  enabled)

Sets the promiscuous mode option.

Parameters
enabledThe promiscuous mode value.
void Tins::SnifferConfiguration::set_rfmon ( bool  enabled)

Sets the rfmon option.

Parameters
enabledThe rfmon option value.
void Tins::SnifferConfiguration::set_snap_len ( unsigned  snap_len)

Sets the snapshot length option.

Parameters
snap_lenThe snapshot length to be set.
void Tins::SnifferConfiguration::set_timeout ( unsigned  timeout)

Sets the timeout option.

Parameters
timeoutThe timeout to be set.

Member Data Documentation

const unsigned Tins::SnifferConfiguration::DEFAULT_SNAP_LEN = 65535
static

The default snapshot length.

This is 65535 by default.

const unsigned Tins::SnifferConfiguration::DEFAULT_TIMEOUT = 1000
static

The default timeout.

This is 1000 by default.


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