From: tho Date: Fri, 21 Nov 2008 14:40:15 +0000 (+0000) Subject: added some documentation for NetdeviceController. X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=ef0be4d0484ff659d17e02a421ad5beaaa76e646;p=senf.git added some documentation for NetdeviceController. git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@970 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/NetdeviceController.cc b/Socket/NetdeviceController.cc index 07466c6..37c255f 100644 --- a/Socket/NetdeviceController.cc +++ b/Socket/NetdeviceController.cc @@ -86,7 +86,6 @@ prefix_ int senf::NetdeviceController::mtu() } prefix_ void senf::NetdeviceController::mtu(int new_mtu) - const { struct ifreq ifr; ifrName( ifr); @@ -133,7 +132,7 @@ prefix_ void senf::NetdeviceController::doIoctl(ifreq& ifr, int request) #undef prefix_ //#include "NetdeviceController.mpp" - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Socket/NetdeviceController.hh b/Socket/NetdeviceController.hh index 56afdac..babe980 100644 --- a/Socket/NetdeviceController.hh +++ b/Socket/NetdeviceController.hh @@ -38,29 +38,41 @@ namespace senf { - /** \brief NetdeviceController - - \todo document me + /** \brief Netdevice Controller + + This controller provides an interface which can be used to configure network + devices. Note, that some setting members are privileged operations. + + \see manual page netdevice(7) for more informations. + \todo Add 'promisc' member to enable/disable promiscuous mode */ class NetdeviceController { public: NetdeviceController(std::string const & interface_name); + ///< Construct a new controller for the given interface name. NetdeviceController(int interface_index); + ///< Construct a new controller for the given interface index. virtual ~NetdeviceController(); - - int interfaceIndex() const; ///< return the interface index - - MACAddress hardwareAddress() const; ///< return hardware address - void hardwareAddress(const MACAddress &newAddress); ///< set hardware address - - std::string interfaceName() const; ///< return interface name - void interfaceName(const std::string &newName) const; ///< set interface name - - int mtu() const; ///< return the Maximum Transmission Unit - void mtu(int new_mtu) const; //< set the Maximum Transmission Unit + int interfaceIndex() const; ///< return the interface index + MACAddress hardwareAddress() const; + ///< return hardware address + void hardwareAddress(const MACAddress &newAddress); + ///< set hardware address + /**< Note, that setting the hardware address is a privileged operation. */ + std::string interfaceName() const; + ///< return interface name + void interfaceName(const std::string &newName); + ///< set interface name + /**< Changes the name of the interface. Note, that this is a + privileged operation. It is only allowed when the interface is not up. */ + int mtu() const; ///< return the Maximum Transmission Unit + void 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. */ private: void openSocket(); void doIoctl(ifreq& ifr, int request) const; @@ -78,7 +90,7 @@ namespace senf { //#include "NetdeviceController.mpp" #endif - + // Local Variables: // mode: c++ // fill-column: 100 diff --git a/Socket/NetdeviceController.test.cc b/Socket/NetdeviceController.test.cc index 784ea5c..649cb02 100644 --- a/Socket/NetdeviceController.test.cc +++ b/Socket/NetdeviceController.test.cc @@ -38,33 +38,26 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) { senf::NetdeviceController ctrl ("lo"); - std::cout << "name: " << ctrl.interfaceName() << "\n"; + BOOST_CHECK_EQUAL( ctrl.interfaceName(), "lo"); - senf::MACAddress oldAddr(ctrl.hardwareAddress()); - int oldMTU = ctrl.mtu(); - - std::cout << "hw addr: " << oldAddr << "\n"; - std::cout << "mtu: " << oldMTU << "\n"; + int oldMTU; + BOOST_CHECK_NO_THROW( oldMTU = ctrl.mtu()); 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); + BOOST_CHECK_NO_THROW( ctrl.mtu(oldMTU-16)); + BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU-16); + BOOST_CHECK_NO_THROW( ctrl.mtu(oldMTU)); + BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU); } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ - + // Local Variables: // mode: c++ // fill-column: 100