simple-socket library 1.9.0
Loading...
Searching...
No Matches
NET::NetworkInterface Class Reference

#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.

Detailed Description

Examples
mini_ifconfig.cpp.

Definition at line 46 of file NetworkInterface.h.

Constructor & Destructor Documentation

◆ NetworkInterface()

NET::NetworkInterface::NetworkInterface ( std::string_view interface)

Member Function Documentation

◆ getBroadcastAddress()

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.

Returns
the broadcast address formatted as an ip address

◆ getDestinationAddress()

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)

◆ getHardwareAddress()

std::string NET::NetworkInterface::getHardwareAddress ( ) const

Return the MAC address of the given network interfaces.

Returns empty string on failure.

◆ getInterfaceAddress()

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.

◆ getMTU()

int NET::NetworkInterface::getMTU ( ) const

Return the MTU (Maximum Transmission Unit) of the given network interface in bytes.

Returns 0 on error.

◆ getNetmask()

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)

◆ name()

std::string NET::NetworkInterface::name ( ) const
inline

Definition at line 51 of file NetworkInterface.h.

◆ setBroadcastAddress()

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.

Parameters
addressIPV4 address to configure the interface to

◆ setDestinationAddress()

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.

Parameters
addressIPV4 address to set the netmask to

◆ setInterfaceAddress()

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.)

◆ setMTU()

void NET::NetworkInterface::setMTU ( int mtu)

Set the MTU (Maximum Transmission Unit) of the given network interface in bytes.

This call may throw.

Parameters
mtunew mtu in bytes

◆ setNetmask()

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.

Parameters
addressIPV4 address to set the netmask to

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