#include <simple_socket/NetworkInterface.h>
Public Member Functions | |
| NetworkInterface (std::string_view interface) | |
| std::string | name () const |
| std::string | getInterfaceAddress () const |
| Return the IPv4 address of the given network interface. | |
| void | setInterfaceAddress (std::string_view address) |
| Set the IPv4 address of the given network interface. | |
| std::string | getBroadcastAddress () const |
| Return the IPv4 broadcast address of the given network interface. | |
| void | setBroadcastAddress (std::string_view address) |
| Set the IPv4 broadcast address of the given network interface. | |
| std::string | getNetmask () const |
| Return the IPv4 netmask of the given network interface. | |
| void | setNetmask (std::string_view address) |
| Set the IPv4 netmask of the given network interface. | |
| std::string | getDestinationAddress () const |
| Return the IPv4 destination address of the given network interface. | |
| void | setDestinationAddress (std::string_view address) |
| Set the IPv4 destination address of the given network interface. | |
| int | getMTU () const |
| Return the MTU (Maximum Transmission Unit) of the given network interface in bytes. | |
| void | setMTU (int mtu) |
| Set the MTU (Maximum Transmission Unit) of the given network interface in bytes. | |
| std::string | getHardwareAddress () const |
| Return the MAC address of the given network interfaces. | |
Definition at line 46 of file NetworkInterface.h.
| NET::NetworkInterface::NetworkInterface | ( | std::string_view | interface | ) |
| std::string NET::NetworkInterface::getBroadcastAddress | ( | ) | const |
Return the IPv4 broadcast address of the given network interface.
The IOCTL call SIOCGIFBRDADDR is used on the specified interface. This method only works on AF_INET interfaces. Returns empty string on failure.
| std::string NET::NetworkInterface::getDestinationAddress | ( | ) | const |
Return the IPv4 destination address of the given network interface.
Returns empty string if the interface has no destination address configured (if interface is down) or can't have one (bluetooth)
| std::string NET::NetworkInterface::getHardwareAddress | ( | ) | const |
Return the MAC address of the given network interfaces.
Returns empty string on failure.
| std::string NET::NetworkInterface::getInterfaceAddress | ( | ) | const |
Return the IPv4 address of the given network interface.
Returns empty string if the interface it not up or not with an IP address.
| int NET::NetworkInterface::getMTU | ( | ) | const |
Return the MTU (Maximum Transmission Unit) of the given network interface in bytes.
Returns 0 on error.
| std::string NET::NetworkInterface::getNetmask | ( | ) | const |
Return the IPv4 netmask of the given network interface.
Returns empty string if the interface has no netmask configured (if interface is down) or can't have one (bluetooth)
|
inline |
Definition at line 51 of file NetworkInterface.h.
| void NET::NetworkInterface::setBroadcastAddress | ( | std::string_view | address | ) |
Set the IPv4 broadcast address of the given network interface.
This call my throw if used on an interface that can not have a broadcast address.
| address | IPV4 address to configure the interface to |
| void NET::NetworkInterface::setDestinationAddress | ( | std::string_view | address | ) |
Set the IPv4 destination address of the given network interface.
This call may throw if the interface can not have a destination address, is down, etc.
| address | IPV4 address to set the netmask to |
| void NET::NetworkInterface::setInterfaceAddress | ( | std::string_view | address | ) |
Set the IPv4 address of the given network interface.
Call may throw if unable to set IP address (non Ethernet interface, etc.)
| void NET::NetworkInterface::setMTU | ( | int | mtu | ) |
Set the MTU (Maximum Transmission Unit) of the given network interface in bytes.
This call may throw.
| mtu | new mtu in bytes |
| void NET::NetworkInterface::setNetmask | ( | std::string_view | address | ) |
Set the IPv4 netmask of the given network interface.
This call may throw if the interface can not have a broadcast address, is down, etc.
| address | IPV4 address to set the netmask to |