libtins
4.0
|
Abstraction of a network interface. More...
#include <network_interface.h>
Classes | |
struct | Info |
Struct that holds an interface's addresses. More... | |
struct | IPv6Prefix |
Public Types | |
typedef uint32_t | id_type |
The type used to store the interface's identifier. | |
typedef HWAddress< 6 > | address_type |
The type of this interface's address. | |
Public Member Functions | |
NetworkInterface () | |
NetworkInterface (const std::string &name) | |
Constructor from std::string. More... | |
NetworkInterface (const char *name) | |
Constructor from const char*. More... | |
NetworkInterface (IPv4Address ip) | |
Constructs a NetworkInterface from an ip address. More... | |
NetworkInterface (IPv6Address ipv6) | |
Constructs a NetworkInterface from an ipv6 address. More... | |
id_type | id () const |
Getter for this interface's identifier. More... | |
std::string | name () const |
Retrieves this interface's name. More... | |
std::wstring | friendly_name () const |
Retrieves this interface's friendly name. More... | |
Info | addresses () const |
Retrieve this interface's addresses. More... | |
Info | info () const |
Retrieve this interface's information. More... | |
operator bool () const | |
Tests whether this is a valid interface;. More... | |
bool | is_loopback () const |
Indicates whether this is a loopback device. More... | |
bool | is_up () const |
Indicates whether this interface is up. More... | |
address_type | hw_address () const |
Retrieves the hardware address for this interface. | |
IPv4Address | ipv4_address () const |
Retrieves the IPv4 address for this interface. | |
IPv4Address | ipv4_mask () const |
Retrieves the IPv4 netmask for this interface. | |
IPv4Address | ipv4_broadcast () const |
Retrieves the broadcast IPv4 address for this interface. | |
std::vector< IPv6Prefix > | ipv6_addresses () const |
Retrieves the IPv6 addresses for this interface. | |
bool | operator== (const NetworkInterface &rhs) const |
Compares this interface for equality. More... | |
bool | operator!= (const NetworkInterface &rhs) const |
Compares this interface for inequality. More... | |
Static Public Member Functions | |
static NetworkInterface | default_interface () |
static std::vector< NetworkInterface > | all () |
static NetworkInterface | from_index (id_type identifier) |
Abstraction of a network interface.
Tins::NetworkInterface::NetworkInterface | ( | ) |
Default constructor.
Tins::NetworkInterface::NetworkInterface | ( | const std::string & | name | ) |
Constructor from std::string.
name | The name of the interface this object will abstract. |
Tins::NetworkInterface::NetworkInterface | ( | const char * | name | ) |
Constructor from const char*.
name | The name of the interface this object will abstract. |
Tins::NetworkInterface::NetworkInterface | ( | IPv4Address | ip | ) |
Constructs a NetworkInterface from an ip address.
This abstracted interface will be the one that would be the gateway when sending a packet to the given ip.
ip | The ip address being looked up. |
Tins::NetworkInterface::NetworkInterface | ( | IPv6Address | ipv6 | ) |
Constructs a NetworkInterface from an ipv6 address.
This abstracted interface will be the one that would be the gateway when sending a packet to the given ip.
ip | The ipv6 address being looked up. |
NetworkInterface::Info Tins::NetworkInterface::addresses | ( | ) | const |
Retrieve this interface's addresses.
This method is deprecated. You should use NetworkInterface::info (this is just a naming deprecation, NetworkInterface::info is equivalent).
|
static |
Returns all available network interfaces.
|
static |
Returns a NetworkInterface object associated with the default interface.
wstring Tins::NetworkInterface::friendly_name | ( | ) | const |
Retrieves this interface's friendly name.
The name returned by this method can be more human-friendly than the one returned by NetworkInterface::name, depending on the platform in which it's used.
On GNU/Linux and OSX/FreeBSD, this returns the same string as NetworkInterface::name.
On Windows, this method returns a name such as "Local Area Connection 1".
Note thaat this returns a wstring rather than a string, to comply with Window's adapter's FriendlyName type.
|
static |
Returns a network interface for the given index.
|
inline |
Getter for this interface's identifier.
NetworkInterface::Info Tins::NetworkInterface::info | ( | ) | const |
Retrieve this interface's information.
This method iterates through all the interface's until the correct one is found. Therefore it's O(N), being N the amount of interfaces in the system.
bool Tins::NetworkInterface::is_loopback | ( | ) | const |
Indicates whether this is a loopback device.
bool Tins::NetworkInterface::is_up | ( | ) | const |
Indicates whether this interface is up.
This is equivalent to getting the interface info and checking for the is_up attribute.
string Tins::NetworkInterface::name | ( | ) | const |
Retrieves this interface's name.
This name can be used as the interface name provided to the Sniffer class when starting a sniffing session.
|
inline |
Tests whether this is a valid interface;.
An interface will not be valid iff it was created using the default constructor.
|
inline |
Compares this interface for inequality.
rhs | The interface being compared. |
|
inline |
Compares this interface for equality.
rhs | The interface being compared. |