Add 'unflatten' to doxygen/dot processing
[senf.git] / Socket / NetdeviceController.hh
index db7c5cf..e969cda 100644 (file)
 
 // Custom includes
 #include <string>
-#include <net/if.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 #include "Protocols/Raw/MACAddress.hh"
 
 
 //#include "NetdeviceController.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
 
+struct ifreq;
+
 namespace senf {
 
     /** \brief Netdevice Controller
@@ -48,12 +51,10 @@ namespace senf {
     class NetdeviceController
     {
     public:
-        NetdeviceController(std::string const & interface_name);
+        explicit NetdeviceController(std::string const & interface_name);
                                         ///< Construct a new controller for the given interface name.
-        NetdeviceController(int interface_index);
+        explicit 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
@@ -84,12 +85,24 @@ namespace senf {
         bool promisc() const;           ///< return \c true if interface is in promiscuous mode
         void promisc(bool mode);        ///< enable/disable promiscuous mode of the interface
                                         /**< Note, that this is a privileged operation. */
-                
+
+        bool isUp() const;              ///< return \c true if interface is up
+        void up();                      ///< ifconfig up interface
+        void down();                    ///< ifconfig down interface
+
+        struct SockFd {
+            typedef boost::shared_ptr<SockFd> ptr;
+            int fd;
+            SockFd();
+            ~SockFd();
+        };
+
+        static SockFd::ptr sockfd();
+
     private:
-        void openSocket();
         void doIoctl(ifreq& ifr, int request) const;
         void ifrName(ifreq& ifr) const;
-        int sockfd_;
+        SockFd::ptr sockfd_;
         int ifindex_;
     };