Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

virtualinterfaceinfo.hh

Go to the documentation of this file.
00001 // Copyright (C) 2003, 2004, 2005 Laboratoire de Recherche en Informatique
00002 
00003 // This file is part of Qolyester.
00004 
00005 // Qolyester is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 // Qolyester is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00027 
00028 #include "config.hh"
00029 
00030 #ifdef QOLYESTER_ENABLE_VIRTUAL
00031 
00032 # ifndef QOLYESTER_DAEMON_SYS_VIRTUALINTERFACEINFO_HH
00033 #  define QOLYESTER_DAEMON_SYS_VIRTUALINTERFACEINFO_HH 1
00034 
00035 #  include <string>
00036 #  include <map>
00037 
00038 #  include "cst/constants.hh"
00039 #  include "net/ipaddress.hh"
00040 #  include "sys/unixsocket.hh"
00041 
00042 namespace olsr {
00043 
00044   namespace sys {
00045 
00052 
00053     class VirtualInterfaceInfo {
00054       typedef VirtualInterfaceInfo      This;
00055     public:
00059       VirtualInterfaceInfo();
00066       VirtualInterfaceInfo(const std::string& name,
00067                            const address_t& addr,
00068                            const std::string& dname);
00069 
00070       VirtualInterfaceInfo(const This& other);
00071 
00072       ~VirtualInterfaceInfo();
00073 
00074       This&     operator=(const This& other);
00075 
00080       const std::string&        name() const { return _name; }
00085       const address_t&          addr() const { return _addr; }
00090       unsigned                  mtu() const { return VIRTUAL_MTU; }
00095       unsigned                  prefix() const { return _prefix; }
00100       unsigned                  index() const { return _index; }
00105       const UnixSocket&         socket() const { return *_sock; }
00106 
00107 //       ///
00108 //       /// Sets socket's filename of the switch
00109 //       /// @arg f     Switch socket filename.
00110 //       ///
00111 //       static void            set_sock_filename(const std::string& f)
00112 //              { _swsockfname = f; _sockfname_is_set = true; }
00113 
00114     private:
00115       void use() {
00116         ++*_usecount;
00117       }
00118       void unuse() {
00119         assert(*_usecount > 0);
00120         --*_usecount;
00121       }
00122       const std::string _name;          
00123       const address_t   _addr;          
00124       const unsigned    _prefix;        
00125       const unsigned    _index;         
00126       unsigned*         _usecount;
00127       UnixSocket*       _sock;          
00128 
00129       typedef std::map<unsigned, std::string>   namemap_t;
00130       typedef std::map<std::string, unsigned>   indexmap_t;
00131 
00132       static namemap_t  _name_map;
00133       static indexmap_t _index_map;
00134     };
00135 
00136     VirtualInterfaceInfo::namemap_t     VirtualInterfaceInfo::_name_map;
00137     VirtualInterfaceInfo::indexmap_t    VirtualInterfaceInfo::_index_map;
00138 
00139   } // namespace sys
00140 
00141 } // namespace olsr
00142 
00143 #  include "virtualinterfaceinfo.hxx"
00144 
00145 # endif // ! QOLYESTER_DAEMON_SYS_VIRTUALINTERFACEINFO_HH
00146 
00147 #endif // QOLYESTER_ENABLE_VIRTUAL

Generated on Thu Dec 8 01:24:38 2005 for Qolyester daemon by  doxygen 1.4.3-20050530