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

route.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 
00026 
00027 // This include is out of protection to resolve dependency cycles.
00028 # include "sys/interfaceinfo.hh"
00029 
00030 #ifndef QOLYESTER_DAEMON_NET_ROUTE_HH
00031 # define QOLYESTER_DAEMON_NET_ROUTE_HH 1
00032 
00033 # include <ext/hash_set>
00034 # include "net/ipaddress.hh"
00035 
00036 namespace olsr {
00037 
00038   namespace net {
00039 
00047     class LocalRoute {
00048       typedef LocalRoute        This;
00056       explicit LocalRoute();
00057     public:
00064       LocalRoute(const address_t& d, unsigned p, const ifaceinfo_t& i);
00065 
00066       LocalRoute(const This& other);
00071       const address_t&  dest_addr() const { return _d_addr; }
00072 
00077       unsigned          prefix() const { return _prefix; }
00078 
00083       const ifaceinfo_t&        interface_info() const { return _info; }
00084 
00090       bool                      operator==(const This& rhs) const {
00091         return _d_addr == rhs._d_addr &&
00092           _prefix == rhs._prefix &&
00093           (_info.index() == rhs._info.index() ||
00094            _info.index() == 0 ||
00095            rhs._info.index() == 0);
00096       }
00097 
00106       static const This&        make_key(const address_t& d, unsigned p);
00107     private:
00108       const address_t           _d_addr; 
00109       const unsigned            _prefix; 
00110       const ifaceinfo_t         _info;  
00111 
00112       static This               _dummy_for_find; 
00113     };
00114 
00118     class RemoteRoute {
00119       typedef RemoteRoute       This;
00120       explicit RemoteRoute();
00121     public:
00122       RemoteRoute(const address_t& d, unsigned p, const address_t& n);
00123       RemoteRoute(const This& other);
00124 
00125       const address_t&  dest_addr() const { return _d_addr; }
00126       unsigned          prefix() const { return _prefix; }
00127       const address_t&  next_addr() const { return _n_addr; }
00128 
00129       bool                      operator==(const This& rhs) const {
00130         return _d_addr == rhs._d_addr &&
00131           _prefix == rhs._prefix &&
00132           (_n_addr == rhs._n_addr ||
00133            _n_addr == address_t() ||
00134            rhs._n_addr == address_t());
00135       }
00136 
00137       static const This&        make_key(const address_t& d, unsigned p);
00138     private:
00139       const address_t   _d_addr;
00140       const unsigned    _prefix;
00141       const address_t   _n_addr;
00142 
00143       static This       _dummy_for_find;
00144     };
00145 
00146     struct hash_LocalRoute {
00147       ::size_t operator()(const LocalRoute& r) const {
00148         return std::hash<address_t>()(r.dest_addr());
00149       }
00150     };
00151 
00152     struct hash_RemoteRoute {
00153       ::size_t operator()(const RemoteRoute& r) const {
00154         return std::hash<address_t>()(r.dest_addr());
00155       }
00156     };
00157 
00158   } // namespace net;
00159 
00160 } // namespace olsr
00161 
00162 # ifndef QOLYESTER_DONTINCLUDE_HXX
00163 #  include "route.hxx"
00164 # endif
00165 
00166 #endif // ! QOLYESTER_DAEMON_NET_ROUTE_HH

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