routing-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-2021, The University of Memphis,
4  * Regents of the University of California
5  *
6  * This file is part of NLSR (Named-data Link State Routing).
7  * See AUTHORS.md for complete list of NLSR authors and contributors.
8  *
9  * NLSR is free software: you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License as published by the Free Software Foundation,
11  * either version 3 of the License, or (at your option) any later version.
12  *
13  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef NLSR_ROUTING_TABLE_HPP
22 #define NLSR_ROUTING_TABLE_HPP
23 
24 #include "conf-parameter.hpp"
25 #include "routing-table-entry.hpp"
26 #include "signals.hpp"
27 #include "lsdb.hpp"
28 #include "route/fib.hpp"
29 #include "test-access-control.hpp"
31 
32 #include <ndn-cxx/util/scheduler.hpp>
33 
34 namespace nlsr {
35 
36 class NextHop;
37 
46 {
47 public:
49 
50  RoutingTableStatus() = default;
51 
52  RoutingTableStatus(const ndn::Block& block)
53  {
54  wireDecode(block);
55  }
56 
57  const std::list<RoutingTableEntry>&
59  {
60  return m_rTable;
61  }
62 
63  const std::list<RoutingTableEntry>&
65  {
66  return m_dryTable;
67  }
68 
69  const ndn::Block&
70  wireEncode() const;
71 
72 private:
73  void
74  wireDecode(const ndn::Block& wire);
75 
76  template<ndn::encoding::Tag TAG>
77  size_t
78  wireEncode(ndn::EncodingImpl<TAG>& block) const;
79 
81  std::list<RoutingTableEntry> m_dryTable;
82  std::list<RoutingTableEntry> m_rTable;
83  mutable ndn::Block m_wire;
84 };
85 
86 std::ostream&
87 operator<<(std::ostream& os, const RoutingTableStatus& rts);
88 
90 {
91 public:
92  explicit
93  RoutingTable(ndn::Scheduler& scheduler, Lsdb& lsdb, ConfParameter& confParam);
94 
96  {
97  m_afterLsdbModified.disconnect();
98  }
99 
104  void
105  calculate();
106 
111  void
112  addNextHop(const ndn::Name& destRouter, NextHop& nh);
113 
118  void
119  addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
120 
122  findRoutingTableEntry(const ndn::Name& destRouter);
123 
127  void
128  scheduleRoutingTableCalculation();
129 
130 private:
132  void
133  calculateLsRoutingTable();
134 
136  void
137  calculateHypRoutingTable(bool isDryRun);
138 
139  void
140  clearRoutingTable();
141 
142  void
143  clearDryRoutingTable();
144 
145 public:
147 
148 private:
149  ndn::Scheduler& m_scheduler;
150  Lsdb& m_lsdb;
151 
153  ndn::time::seconds m_routingCalcInterval;
154  bool m_isRoutingTableCalculating;
155  bool m_isRouteCalculationScheduled;
156 
157  ConfParameter& m_confParam;
158  ndn::util::signal::Connection m_afterLsdbModified;
159  int32_t m_hyperbolicState;
160  bool m_ownAdjLsaExist = false;
161 };
162 
163 } // namespace nlsr
164 
165 #endif // NLSR_ROUTING_TABLE_HPP
A class to house all the configuration parameters for NLSR.
RoutingTableStatus(const ndn::Block &block)
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:179
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
const std::list< RoutingTableEntry > & getDryRoutingTableEntry() const
const ndn::Block & wireEncode() const
std::list< RoutingTableEntry > m_dryTable
std::list< RoutingTableEntry > m_rTable
AfterRoutingChange afterRoutingChange
Data abstraction for Nexthop.
Definition: nexthop.hpp:43
const std::list< RoutingTableEntry > & getRoutingTableEntry() const
Data abstraction for RouteTableInfo.
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for routing table status.
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
ndn::util::Signal< RoutingTable, const std::list< RoutingTableEntry > & > AfterRoutingChange
Definition: signals.hpp:35