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

linux/interfacedesc.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 
00019 #include "config.hh"
00020 
00021 #ifndef QOLYESTER_ENABLE_VIRTUAL
00022 
00023 # ifndef QOLYESTER_DAEMON_SYS_LINUX_INTERFACEDESC_HH
00024 #  define QOLYESTER_DAEMON_SYS_LINUX_INTERFACEDESC_HH 1
00025 
00026 #  include <ostream>
00027 #  include <string>
00028 #  include <set>
00029 
00030 #  include "net/ipaddress.hh"
00031 #  include "sys/linux/netlink.hh"
00032 
00033 namespace olsr {
00034 
00035   namespace sys {
00036 
00037     namespace internal {
00038 
00039       class InterfaceAddress {
00040         typedef InterfaceAddress        This;
00041         InterfaceAddress();
00042       public:
00043         InterfaceAddress(unsigned p,
00044                          unsigned char s,
00045                          const address_t& a,
00046                          const address_t& b);
00047 
00048         unsigned                prefix()    const { return _prefix;    }
00049         unsigned char           scope()     const { return _scope;     }
00050         const address_t&        address()   const { return _address;   }
00051         const address_t&        broadcast() const { return _broadcast; }
00052 
00053         bool                    operator<(const This& rhs) const;
00054 
00055         static This             make_key(const address_t& a);
00056       private:
00057         unsigned                _prefix;
00058         unsigned char           _scope;
00059         const address_t         _address;
00060         const address_t         _broadcast;
00061 
00062         static This     _dummy_for_find;
00063       };
00064 
00065     } // namespace internal
00066 
00067     namespace netlink {
00068 
00069 #  ifdef DEBUG
00070       class DebugVisitor : public DefaultVisitor {
00071         typedef DebugVisitor                    This;
00072       public:
00073         DebugVisitor(std::ostream& os);
00074         virtual ~DebugVisitor();
00075 
00076         virtual void visit(const NLError& e);
00077         virtual void visit(const NLNewLink& e);
00078         virtual void visit(const NLLinkAttrName& e);
00079         virtual void visit(const NLLinkAttrMTU& e);
00080         virtual void visit(const NLNewAddr& e);
00081         virtual void visit(const NLAddrAttrAddress& e);
00082         virtual void visit(const NLAddrAttrBroadcast& e);
00083       private:
00084         std::ostream& _os;
00085       };
00086 #  endif // !DEBUG
00087 
00088       class InitVisitor : public DefaultVisitor {
00089         typedef InitVisitor                     This;
00090         typedef internal::InterfaceAddress      addr_t;
00091         typedef std::set<addr_t>                addrs_t;
00092       public:
00093         InitVisitor(std::string& name, unsigned& index,
00094                     unsigned& mtu, addrs_t& addrs);
00095 
00096         virtual void visit(const NLError& e);
00097         virtual void visit(const NLNewLink& e);
00098         virtual void visit(const NLLinkAttrName& e);
00099         virtual void visit(const NLLinkAttrMTU& e);
00100         virtual void visit(const NLNewAddr& e);
00101         virtual void visit(const NLAddrAttrAddress& e);
00102         virtual void visit(const NLAddrAttrBroadcast& e);
00103       private:
00104         std::string&    _name;
00105         unsigned&       _index;
00106         unsigned&       _mtu;
00107         addrs_t&        _addrs;
00108 
00109         unsigned        _prefix;
00110         unsigned char   _scope;
00111         address_t       _address;
00112         address_t       _broadcast;
00113       };
00114 
00115     } // namespace netlink
00116 
00117     namespace internal {
00118 
00119       class InterfaceInfo {
00120         typedef InterfaceInfo           This;
00121         typedef InterfaceAddress        addr_t;
00122       public:
00123         typedef std::set<addr_t>        addrs_t;
00124 
00125         InterfaceInfo(const std::string& name);
00126 
00127         const std::string&      name()  const { return _name; }
00128         unsigned                index() const { return _index; }
00129         unsigned                mtu()   const { return _mtu;   }
00130         const addrs_t&          addrs() const { return _addrs; }
00131 
00132         bool            operator<(const This& rhs) const;
00133 
00134 
00135       private:
00136         std::string     _name;
00137         unsigned        _index;
00138         unsigned        _mtu;
00139         addrs_t         _addrs;
00140       };
00141 
00142     } // namespace internal
00143 
00144   } // namespace sys
00145 
00146 } // namespace olsr
00147 
00148 #  include "interfacedesc.hxx"
00149 
00150 # endif // ! QOLYESTER_DAEMON_SYS_LINUX_INTERFACEDESC_HH
00151 
00152 #endif // ! QOLYESTER_ENABLE_VIRTUAL

Generated on Thu Jul 28 21:21:47 2005 for Qolyester daemon by  doxygen 1.4.1