4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief NetdeviceController public header
32 #ifndef HH_SENF_Socket_NetdeviceController_
33 #define HH_SENF_Socket_NetdeviceController_ 1
37 #include <boost/shared_ptr.hpp>
39 //#include "NetdeviceController.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 /** \brief Netdevice Controller
51 This controller provides an interface which can be used to configure network
52 devices. Note, that some setting members are privileged operations.
54 \see manual page netdevice(7) for more informations.
56 class NetdeviceController
59 explicit NetdeviceController(std::string const & interface_name);
60 ///< Construct a new controller for the given interface name.
61 explicit NetdeviceController(int interface_index);
62 ///< Construct a new controller for the given interface index.
63 int interfaceIndex() const; ///< return the interface index
64 MACAddress hardwareAddress() const;
65 ///< return hardware address
66 void hardwareAddress(MACAddress const & newAddress);
67 ///< set hardware address
68 /**< Changes the hardware address of the interface.
69 Note, that setting the hardware address is a privileged
70 operation. It is only allowed when the interface is not
71 up. If the interface is up, this call will cause an
72 SystemException to be thrown. */
73 std::string interfaceName() const;
74 ///< return interface name
75 void interfaceName(std::string const & newName);
76 ///< set interface name
77 /**< Changes the name of the interface.
78 Note, that setting the name is a privileged operation.
79 It is only allowed when the interface is not up. If
80 the interface is up, this call will cause an
81 SystemException to be thrown. */
83 int mtu() const; ///< return the Maximum Transmission Unit
84 void mtu(int new_mtu); ///< set the Maximum Transmission Unit
85 /**< Set the MTU (Maximum Transfer Unit) of the device.
86 Note, that this is a privileged operation.
87 Setting the MTU to too small values may cause kernel
90 int txqueuelen() const; ///< return the Tx Queue Length
91 void txqueuelen(int new_mtu); ///< set the Tx Queue Length
92 /**< Set the Tx Queue Length (in Packets) MTU of the device.
93 Note, that this is a privileged operation. */
96 bool promisc() const; ///< return \c true if interface is in promiscuous mode
97 void promisc(bool mode); ///< enable/disable promiscuous mode of the interface
98 /**< Note, that this is a privileged operation. */
100 bool isUp() const; ///< return \c true if interface is up
101 void up(); ///< ifconfig up interface
102 void down(); ///< ifconfig down interface
105 typedef boost::shared_ptr<SockFd> ptr;
111 static SockFd::ptr sockfd();
114 void ifrName(ifreq & ifr) const;
121 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122 //#include "NetdeviceController.cci"
123 //#include "NetdeviceController.ct"
124 //#include "NetdeviceController.cti"
125 //#include "NetdeviceController.mpp"
132 // c-file-style: "senf"
133 // indent-tabs-mode: nil
134 // ispell-local-dictionary: "american"
135 // compile-command: "scons -u test"
136 // comment-column: 40