Loading...
Searching...
No Matches
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-2025, 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"
29#include "route/fib.hpp"
30#include "lsdb.hpp"
31
32#include <list>
33#include <unordered_map>
34
35namespace nlsr {
36
38{
39public:
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 using DestNameKey = std::tuple<ndn::Name, ndn::Name>;
45
46 NamePrefixTable(const ndn::Name& ownRouterName, Fib& fib, RoutingTable& routingTable,
47 AfterRoutingChange& afterRoutingChangeSignal,
48 Lsdb::AfterLsdbModified& afterLsdbModifiedSignal);
49
51
53 adjustNexthopCosts(const NexthopList& nhlist, const ndn::Name& nameToCheck, const ndn::Name& destRouterName);
54
61 void
62 updateFromLsdb(std::shared_ptr<Lsa> lsa, LsdbUpdate updateType,
63 const std::list<nlsr::PrefixInfo>& namesToAdd,
64 const std::list<nlsr::PrefixInfo>& namesToRemove);
65
80 void
81 addEntry(const ndn::Name& name, const ndn::Name& destRouter, uint64_t routeFlags = ndn::nfd::ROUTE_FLAG_CAPTURE);
82
94 void
95 removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
96
105 void
106 updateWithNewRoute(const std::list<RoutingTableEntry>& entries);
107
117 std::shared_ptr<RoutingTablePoolEntry>
119
128 void
129 deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
130
131 void
132 writeLog();
133
135 begin() const;
136
138 end() const;
139
141 RoutingTableEntryPool m_rtpool;
142
143 NptEntryList m_table;
144
145private:
146 const ndn::Name& m_ownRouterName;
147 Fib& m_fib;
148 RoutingTable& m_routingTable;
149 ndn::signal::Connection m_afterRoutingChangeConnection;
150 ndn::signal::Connection m_afterLsdbModified;
151 std::map<std::tuple<ndn::Name, ndn::Name>, double> m_nexthopCost;
152};
153
156{
157 return m_table.begin();
158}
159
162{
163 return m_table.end();
164}
165
166std::ostream&
167operator<<(std::ostream& os, const NamePrefixTable& table);
168
169} // namespace nlsr
170
171#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< nlsr::PrefixInfo >, std::list< nlsr::PrefixInfo > > AfterLsdbModified
Definition lsdb.hpp:338
std::shared_ptr< RoutingTablePoolEntry > addRtpeToPool(RoutingTablePoolEntry &rtpe)
Adds a pool entry to the pool.
void addEntry(const ndn::Name &name, const ndn::Name &destRouter, uint64_t routeFlags=ndn::nfd::ROUTE_FLAG_CAPTURE)
Adds a destination to the specified name prefix.
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 updateFromLsdb(std::shared_ptr< Lsa > lsa, LsdbUpdate updateType, const std::list< nlsr::PrefixInfo > &namesToAdd, const std::list< nlsr::PrefixInfo > &namesToRemove)
Add, update, or remove Names according to the Lsdb update.
void updateWithNewRoute(const std::list< RoutingTableEntry > &entries)
Updates all routing information in the NPT.
std::list< std::shared_ptr< NamePrefixTableEntry > > NptEntryList
std::tuple< ndn::Name, ndn::Name > DestNameKey
NexthopList adjustNexthopCosts(const NexthopList &nhlist, const ndn::Name &nameToCheck, const ndn::Name &destRouterName)
std::unordered_map< ndn::Name, std::shared_ptr< RoutingTablePoolEntry > > RoutingTableEntryPool
const_iterator end() const
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