name-prefix-table.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2023, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef NLSR_NAME_PREFIX_TABLE_HPP
23 #define NLSR_NAME_PREFIX_TABLE_HPP
24 
27 #include "signals.hpp"
28 #include "test-access-control.hpp"
29 #include "route/fib.hpp"
30 #include "lsdb.hpp"
31 
32 #include <list>
33 #include <unordered_map>
34 
35 namespace nlsr {
36 
38 {
39 public:
41  std::unordered_map<ndn::Name, std::shared_ptr<RoutingTablePoolEntry>>;
42  using NptEntryList = std::list<std::shared_ptr<NamePrefixTableEntry>>;
43  using const_iterator = NptEntryList::const_iterator;
44 
45  NamePrefixTable(const ndn::Name& ownRouterName, Fib& fib, RoutingTable& routingTable,
46  AfterRoutingChange& afterRoutingChangeSignal,
47  Lsdb::AfterLsdbModified& afterLsdbModifiedSignal);
48 
50 
57  void
58  updateFromLsdb(std::shared_ptr<Lsa> lsa, LsdbUpdate updateType,
59  const std::list<ndn::Name>& namesToAdd,
60  const std::list<ndn::Name>& namesToRemove);
61 
75  void
76  addEntry(const ndn::Name& name, const ndn::Name& destRouter);
77 
89  void
90  removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
91 
100  void
101  updateWithNewRoute(const std::list<RoutingTableEntry>& entries);
102 
112  std::shared_ptr<RoutingTablePoolEntry>
114 
123  void
124  deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
125 
126  void
127  writeLog();
128 
130  begin() const;
131 
133  end() const;
134 
136  RoutingTableEntryPool m_rtpool;
137 
138  NptEntryList m_table;
139 
140 private:
141  const ndn::Name& m_ownRouterName;
142  Fib& m_fib;
143  RoutingTable& m_routingTable;
144  ndn::signal::Connection m_afterRoutingChangeConnection;
145  ndn::signal::Connection m_afterLsdbModified;
146 };
147 
150 {
151  return m_table.begin();
152 }
153 
156 {
157  return m_table.end();
158 }
159 
160 std::ostream&
161 operator<<(std::ostream& os, const NamePrefixTable& table);
162 
163 } // namespace nlsr
164 
165 #endif // NLSR_NAME_PREFIX_TABLE_HPP
Maps names to lists of next hops, and exports this information to NFD.
Definition: fib.hpp:63
ndn::signal::Signal< Lsdb, std::shared_ptr< Lsa >, LsdbUpdate, std::list< ndn::Name >, std::list< ndn::Name > > AfterLsdbModified
Definition: lsdb.hpp:338
std::shared_ptr< RoutingTablePoolEntry > addRtpeToPool(RoutingTablePoolEntry &rtpe)
Adds a pool entry to the pool.
void removeEntry(const ndn::Name &name, const ndn::Name &destRouter)
Removes a destination from a name prefix table entry.
NptEntryList::const_iterator const_iterator
void updateWithNewRoute(const std::list< RoutingTableEntry > &entries)
Updates all routing information in the NPT.
std::list< std::shared_ptr< NamePrefixTableEntry > > NptEntryList
std::unordered_map< ndn::Name, std::shared_ptr< RoutingTablePoolEntry > > RoutingTableEntryPool
NamePrefixTable(const ndn::Name &ownRouterName, Fib &fib, RoutingTable &routingTable, AfterRoutingChange &afterRoutingChangeSignal, Lsdb::AfterLsdbModified &afterLsdbModifiedSignal)
void updateFromLsdb(std::shared_ptr< Lsa > lsa, LsdbUpdate updateType, const std::list< ndn::Name > &namesToAdd, const std::list< ndn::Name > &namesToRemove)
Add, update, or remove Names according to the Lsdb update.
const_iterator end() const
void addEntry(const ndn::Name &name, const ndn::Name &destRouter)
Adds a destination to the specified name prefix.
void deleteRtpeFromPool(std::shared_ptr< RoutingTablePoolEntry > rtpePtr)
Removes a pool entry from the pool.
const_iterator begin() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:176
ndn::signal::Signal< RoutingTable, std::list< RoutingTableEntry > > AfterRoutingChange
Definition: signals.hpp:35
LsdbUpdate
Definition: lsdb.hpp:53
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE