X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FNetdeviceController.test.cc;h=784ea5cadce7fdab41c31feb1dad947e8e5ec1a1;hb=8475937b6551f73a1cddd8fa830b7128d4c8ebf7;hp=f3accd970321b1c05a9f4dc1b779694673070853;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Socket/NetdeviceController.test.cc b/Socket/NetdeviceController.test.cc index f3accd9..784ea5c 100644 --- a/Socket/NetdeviceController.test.cc +++ b/Socket/NetdeviceController.test.cc @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Thorsten Horstmann // // This program is free software; you can redistribute it and/or modify @@ -27,6 +27,7 @@ // Custom includes #include "NetdeviceController.hh" +#include "Protocols/Raw/MACAddress.hh" #include "../Utils/auto_unit_test.hh" #include @@ -34,10 +35,30 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(NetdeviceController) -{ -// senf::NetdeviceController ctrl ("eth0"); -// std::cout << ctrl.hardwareAddress() << "\n"; +BOOST_AUTO_UNIT_TEST(NetdeviceController) { + + senf::NetdeviceController ctrl ("lo"); + std::cout << "name: " << ctrl.interfaceName() << "\n"; + + senf::MACAddress oldAddr(ctrl.hardwareAddress()); + int oldMTU = ctrl.mtu(); + + std::cout << "hw addr: " << oldAddr << "\n"; + std::cout << "mtu: " << oldMTU << "\n"; + + if (getuid() != 0) { + BOOST_WARN_MESSAGE(false, "Cannot run some tests of senf::NetdeviceController as non-root user"); + return; + } + + ctrl.mtu(oldMTU - 16); + std::cout << "new mtu: " << ctrl.mtu() << "\n"; + ctrl.mtu(oldMTU); + + senf::MACAddress newAddr(senf::MACAddress::from_string("00:18:de:2e:ec:00")); + ctrl.hardwareAddress(newAddr); + std::cout << "new hw addr: " << ctrl.hardwareAddress() << "\n"; + ctrl.hardwareAddress(oldAddr); } ///////////////////////////////cc.e////////////////////////////////////////