4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief NetdeviceController public header
27 #ifndef HH_SENF_Socket_NetdeviceController_
28 #define HH_SENF_Socket_NetdeviceController_ 1
32 #include <boost/shared_ptr.hpp>
33 #include <boost/weak_ptr.hpp>
34 #include "Protocols/Raw/MACAddress.hh"
37 //#include "NetdeviceController.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
44 /** \brief Netdevice Controller
46 This controller provides an interface which can be used to configure network
47 devices. Note, that some setting members are privileged operations.
49 \see manual page netdevice(7) for more informations.
51 class NetdeviceController
54 explicit NetdeviceController(std::string const & interface_name);
55 ///< Construct a new controller for the given interface name.
56 explicit NetdeviceController(int interface_index);
57 ///< Construct a new controller for the given interface index.
58 virtual ~NetdeviceController();
60 int interfaceIndex() const; ///< return the interface index
61 MACAddress hardwareAddress() const;
62 ///< return hardware address
63 void hardwareAddress(const MACAddress &newAddress);
64 ///< set hardware address
65 /**< Changes the hardware address of the interface.
66 Note, that setting the hardware address is a privileged
67 operation. It is only allowed when the interface is not
68 up. If the interface is up, this call will cause an
69 SystemException to be thrown. */
70 std::string interfaceName() const;
71 ///< return interface name
72 void interfaceName(const std::string &newName);
73 ///< set interface name
74 /**< Changes the name of the interface.
75 Note, that setting the name is a privileged operation.
76 It is only allowed when the interface is not up. If
77 the interface is up, this call will cause an
78 SystemException to be thrown. */
80 int mtu() const; ///< return the Maximum Transmission Unit
81 void mtu(int new_mtu); ///< set the Maximum Transmission Unit
82 /**< Set the MTU (Maximum Transfer Unit) of the device.
83 Note, that this is a privileged operation.
84 Setting the MTU to too small values may cause kernel
87 bool promisc() const; ///< return \c true if interface is in promiscuous mode
88 void promisc(bool mode); ///< enable/disable promiscuous mode of the interface
89 /**< Note, that this is a privileged operation. */
91 bool isUp() const; ///< return \c true if interface is up
92 void up(); ///< ifconfig up interface
93 void down(); ///< ifconfig down interface
96 typedef boost::shared_ptr<SockFd> ptr;
102 static SockFd::ptr sockfd();
105 void doIoctl(ifreq& ifr, int request) const;
106 void ifrName(ifreq& ifr) const;
113 ///////////////////////////////hh.e////////////////////////////////////////
114 //#include "NetdeviceController.cci"
115 //#include "NetdeviceController.ct"
116 //#include "NetdeviceController.cti"
117 //#include "NetdeviceController.mpp"
124 // c-file-style: "senf"
125 // indent-tabs-mode: nil
126 // ispell-local-dictionary: "american"
127 // compile-command: "scons -u test"
128 // comment-column: 40