X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FNetdeviceController.cc;h=7ce1f953bff4aa0a0582d09098f753442d64fadf;hb=92f8630b75f3ef50e73c48cde58645dcd1534e27;hp=07466c69fceaa352b3db4ae30c2658f2ef4a6a82;hpb=034f9bec0a66d26314fb6ebc83dedf1618a2c19d;p=senf.git diff --git a/Socket/NetdeviceController.cc b/Socket/NetdeviceController.cc index 07466c6..7ce1f95 100644 --- a/Socket/NetdeviceController.cc +++ b/Socket/NetdeviceController.cc @@ -30,6 +30,7 @@ // Custom includes #include #include +#include #include "../Utils/Exception.hh" #define prefix_ @@ -59,6 +60,22 @@ prefix_ std::string senf::NetdeviceController::interfaceName() return std::string( ifr.ifr_name); } +prefix_ void senf::NetdeviceController::interfaceName(const std::string & newname) +{ + if (sizeof(newname) <= IFNAMSIZ) { + struct ifreq ifr; + ifrName(ifr); + strncpy(ifr. ifr_newname, newname.c_str(), IFNAMSIZ); + try { + doIoctl(ifr, SIOCSIFNAME); + } catch (senf::SystemException e) { + e << "Could not change the interface name. Is the interface really down?"; + throw ; + } + } + return; +} + prefix_ senf::MACAddress senf::NetdeviceController::hardwareAddress() const { @@ -73,7 +90,12 @@ prefix_ void senf::NetdeviceController::hardwareAddress(const MACAddress &newAdd ifrName( ifr); ifr.ifr_hwaddr.sa_family = 1; // TODO: lookup named constant; PF_LOCAL ??? std::copy(newAddress.begin(), newAddress.end(), ifr.ifr_hwaddr.sa_data); - doIoctl( ifr, SIOCSIFHWADDR); + try { + doIoctl(ifr, SIOCSIFHWADDR); + } catch (senf::SystemException e) { + e << "Could not change the interface MAC address. Is the interface really down?"; + throw ; + } } prefix_ int senf::NetdeviceController::mtu() @@ -86,7 +108,6 @@ prefix_ int senf::NetdeviceController::mtu() } prefix_ void senf::NetdeviceController::mtu(int new_mtu) - const { struct ifreq ifr; ifrName( ifr); @@ -133,7 +154,7 @@ prefix_ void senf::NetdeviceController::doIoctl(ifreq& ifr, int request) #undef prefix_ //#include "NetdeviceController.mpp" - + // Local Variables: // mode: c++ // fill-column: 100