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

mainaddrof.hxx

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 #ifndef QOLYESTER_DAEMON_ALG_MAINADDROF_HXX
00020 # define QOLYESTER_DAEMON_ALG_MAINADDROF_HXX 1
00021 
00022 # include "set/mid.hh"
00023 # include "set/interfaces.hh"
00024 
00025 # include "mainaddrof.hh"
00026 
00027 namespace olsr {
00028 
00029   extern midset_t       mid_set;
00030   extern ifaceset_t     iface_set;
00031 
00032   namespace alg {
00033 
00034     // Find the main address given any node's address.
00035     const address_t& main_addr_of(const address_t& addr) {
00036 # ifdef QOLYESTER_ENABLE_MID
00037       midset_t::midset_t::iterator      m =
00038         mid_set.midset().find(set::MIDEntry::make_key(addr));
00039 
00040       if (m != mid_set.midset().end())
00041         return m->main_addr();
00042 
00043       // If the address belongs to no declared interface, look if it's
00044       // not ours.
00045       if (iface_set.find(addr) != iface_set.end())
00046         return main_addr;
00047 
00048       // If everything else fails, consider the address as being the
00049       // main address of the node.
00050 # endif // ! QOLYESTER_ENABLE_MID
00051       return addr;
00052     }
00053 
00054   } // namespace alg
00055 
00056 } // namespace olsr
00057 
00058 #endif // !QOLYESTER_DAEMON_ALG_MAINADDROF_HXX

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