X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FNetdeviceController.cc;h=7ce1f953bff4aa0a0582d09098f753442d64fadf;hb=92f8630b75f3ef50e73c48cde58645dcd1534e27;hp=37c255f68a79edcbf0ffdf8af83607a392ac5b2d;hpb=ef0be4d0484ff659d17e02a421ad5beaaa76e646;p=senf.git diff --git a/Socket/NetdeviceController.cc b/Socket/NetdeviceController.cc index 37c255f..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()