00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00109
00110
00111
00112
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 }
00140
00141 }
00142
00143 # include "virtualinterfaceinfo.hxx"
00144
00145 # endif // ! QOLYESTER_DAEMON_SYS_VIRTUALINTERFACEINFO_HH
00146
00147 #endif // QOLYESTER_ENABLE_VIRTUAL