Netdevice Controller. More...

#include <senf/Socket/NetdeviceController.hh>

Classes

struct  SockFd
 

Public Member Functions

 NetdeviceController (std::string const &interface_name)
 Construct a new controller for the given interface name. More...
 
 NetdeviceController (int interface_index)
 Construct a new controller for the given interface index. More...
 
void reset (std::string const &interface_name)
 reset the ifindex_ from the given iface_name (i.e. after USB Ethernet unplug/plug More...
 
int interfaceIndex () const
 return the interface index More...
 
MACAddress hardwareAddress () const
 return hardware address More...
 
void hardwareAddress (MACAddress const &newAddress)
 set hardware address More...
 
std::string interfaceName () const
 return interface name More...
 
void interfaceName (std::string const &newName)
 set interface name More...
 
int mtu () const
 return the Maximum Transmission Unit More...
 
void mtu (int new_mtu)
 set the Maximum Transmission Unit More...
 
int txqueuelen () const
 return the Tx Queue Length More...
 
void txqueuelen (int new_mtu)
 set the Tx Queue Length More...
 
bool promisc () const
 return true if interface is in promiscuous mode More...
 
void promisc (bool mode)
 enable/disable promiscuous mode of the interface More...
 
void addVLAN (std::uint16_t vlanId)
 add a VLAN interface More...
 
void delVLAN (std::uint16_t vlanId)
 delete a VLAN interface More...
 
void timestamping (int txType, int rxFilter)
 configures hw timestamping for RX and/or TX More...
 
bool isUp () const
 return true if interface is up More...
 
void up ()
 ifconfig up interface More...
 
void down ()
 ifconfig down interface More...
 

Static Public Member Functions

static SockFd::ptr sockfd ()
 
static std::string macToName (MACAddress const &mac)
 
static MACAddress readMACAddressFromFile (boost::filesystem::path const &path)
 

Protected Member Functions

void ifrName (ifreq &ifr) const
 

Protected Attributes

SockFd::ptr sockfd_
 
int ifindex_
 

Detailed Description

Netdevice Controller.

This controller provides an interface which can be used to configure network devices. Note, that some setting members are privileged operations.

See also
manual page netdevice(7) for more informations.

Definition at line 44 of file NetdeviceController.hh.

Constructor & Destructor Documentation

◆ NetdeviceController() [1/2]

senf::NetdeviceController::NetdeviceController ( std::string const &  interface_name)
explicit

Construct a new controller for the given interface name.

Definition at line 42 of file NetdeviceController.cc.

◆ NetdeviceController() [2/2]

senf::NetdeviceController::NetdeviceController ( int  interface_index)
explicit

Construct a new controller for the given interface index.

Definition at line 48 of file NetdeviceController.cc.

Member Function Documentation

◆ addVLAN()

void senf::NetdeviceController::addVLAN ( std::uint16_t  vlanId)

add a VLAN interface

Note, that this is a privileged operation.

Definition at line 187 of file NetdeviceController.cc.

◆ delVLAN()

void senf::NetdeviceController::delVLAN ( std::uint16_t  vlanId)

delete a VLAN interface

Note, that this is a privileged operation.

Definition at line 197 of file NetdeviceController.cc.

◆ down()

void senf::NetdeviceController::down ( )

ifconfig down interface

Definition at line 178 of file NetdeviceController.cc.

◆ hardwareAddress() [1/2]

senf::MACAddress senf::NetdeviceController::hardwareAddress ( ) const

return hardware address

Definition at line 87 of file NetdeviceController.cc.

◆ hardwareAddress() [2/2]

void senf::NetdeviceController::hardwareAddress ( MACAddress const &  newAddress)

set hardware address

Changes the hardware address of the interface. Note, that setting the hardware address is a privileged operation. It is only allowed when the interface is not up. If the interface is up, this call will cause an SystemException to be thrown.

Definition at line 96 of file NetdeviceController.cc.

◆ ifrName()

void senf::NetdeviceController::ifrName ( ifreq &  ifr) const
protected

Definition at line 221 of file NetdeviceController.cc.

◆ interfaceIndex()

int senf::NetdeviceController::interfaceIndex ( ) const

return the interface index

Definition at line 215 of file NetdeviceController.cc.

◆ interfaceName() [1/2]

std::string senf::NetdeviceController::interfaceName ( ) const

return interface name

Definition at line 63 of file NetdeviceController.cc.

◆ interfaceName() [2/2]

void senf::NetdeviceController::interfaceName ( std::string const &  newName)

set interface name

Changes the name of the interface. Note, that setting the name is a privileged operation. It is only allowed when the interface is not up. If the interface is up, this call will cause an SystemException to be thrown.

Definition at line 76 of file NetdeviceController.cc.

◆ isUp()

bool senf::NetdeviceController::isUp ( ) const

return true if interface is up

Definition at line 160 of file NetdeviceController.cc.

◆ macToName()

std::string senf::NetdeviceController::macToName ( senf::MACAddress const &  mac)
static

Definition at line 273 of file NetdeviceController.cc.

◆ mtu() [1/2]

int senf::NetdeviceController::mtu ( ) const

return the Maximum Transmission Unit

Definition at line 104 of file NetdeviceController.cc.

◆ mtu() [2/2]

void senf::NetdeviceController::mtu ( int  new_mtu)

set the Maximum Transmission Unit

Set the MTU (Maximum Transfer Unit) of the device. Note, that this is a privileged operation. Setting the MTU to too small values may cause kernel crashes.

Definition at line 113 of file NetdeviceController.cc.

◆ promisc() [1/2]

bool senf::NetdeviceController::promisc ( ) const

return true if interface is in promiscuous mode

Definition at line 139 of file NetdeviceController.cc.

◆ promisc() [2/2]

void senf::NetdeviceController::promisc ( bool  mode)

enable/disable promiscuous mode of the interface

Note, that this is a privileged operation.

Definition at line 148 of file NetdeviceController.cc.

◆ readMACAddressFromFile()

senf::MACAddress senf::NetdeviceController::readMACAddressFromFile ( boost::filesystem::path const &  path)
static

Definition at line 262 of file NetdeviceController.cc.

◆ reset()

void senf::NetdeviceController::reset ( std::string const &  interface_name)

reset the ifindex_ from the given iface_name (i.e. after USB Ethernet unplug/plug

Definition at line 54 of file NetdeviceController.cc.

◆ sockfd()

senf::NetdeviceController::SockFd::ptr senf::NetdeviceController::sockfd ( )
static

Definition at line 249 of file NetdeviceController.cc.

◆ timestamping()

void senf::NetdeviceController::timestamping ( int  txType,
int  rxFilter 
)

configures hw timestamping for RX and/or TX

Note, that this is a privileged operation.

Definition at line 206 of file NetdeviceController.cc.

◆ txqueuelen() [1/2]

int senf::NetdeviceController::txqueuelen ( ) const

return the Tx Queue Length

Definition at line 121 of file NetdeviceController.cc.

◆ txqueuelen() [2/2]

void senf::NetdeviceController::txqueuelen ( int  new_mtu)

set the Tx Queue Length

Set the Tx Queue Length (in Packets) MTU of the device. Note, that this is a privileged operation.

Definition at line 130 of file NetdeviceController.cc.

◆ up()

void senf::NetdeviceController::up ( )

ifconfig up interface

Definition at line 169 of file NetdeviceController.cc.

Member Data Documentation

◆ ifindex_

int senf::NetdeviceController::ifindex_
protected

Definition at line 121 of file NetdeviceController.hh.

◆ sockfd_

SockFd::ptr senf::NetdeviceController::sockfd_
protected

Definition at line 120 of file NetdeviceController.hh.


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