NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
rib-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef NFD_DAEMON_RIB_RIB_ENTRY_HPP
27 #define NFD_DAEMON_RIB_RIB_ENTRY_HPP
28 
29 #include "route.hpp"
30 
31 #include <list>
32 
33 namespace nfd {
34 namespace rib {
35 
38 class RibEntry : public std::enable_shared_from_this<RibEntry>
39 {
40 public:
41  typedef std::list<Route> RouteList;
42  typedef RouteList::iterator iterator;
43  typedef RouteList::const_iterator const_iterator;
44 
46  : m_nRoutesWithCaptureSet(0)
47  {
48  }
49 
50  void
51  setName(const Name& prefix);
52 
53  const Name&
54  getName() const;
55 
56  shared_ptr<RibEntry>
57  getParent() const;
58 
59  bool
60  hasParent() const;
61 
62  void
63  addChild(shared_ptr<RibEntry> child);
64 
65  void
66  removeChild(shared_ptr<RibEntry> child);
67 
68  const std::list<shared_ptr<RibEntry>>&
69  getChildren() const;
70 
71  bool
72  hasChildren() const;
73 
82  std::pair<RibEntry::iterator, bool>
83  insertRoute(const Route& route);
84 
87  void
88  eraseRoute(const Route& route);
89 
93  iterator
94  eraseRoute(RouteList::iterator route);
95 
96  bool
97  hasFaceId(const uint64_t faceId) const;
98 
99  const RouteList&
100  getRoutes() const;
101 
102  size_t
103  getNRoutes() const;
104 
105  iterator
106  findRoute(const Route& route);
107 
109  findRoute(const Route& route) const;
110 
111  bool
112  hasRoute(const Route& route);
113 
114  void
115  addInheritedRoute(const Route& route);
116 
117  void
118  removeInheritedRoute(const Route& route);
119 
124  const RouteList&
125  getInheritedRoutes() const;
126 
132  RouteList::const_iterator
133  findInheritedRoute(const Route& route) const;
134 
138  bool
139  hasInheritedRoute(const Route& route) const;
140 
141  bool
142  hasCapture() const;
143 
148  bool
149  hasChildInheritOnFaceId(uint64_t faceId) const;
150 
154  const Route*
155  getRouteWithLowestCostByFaceId(uint64_t faceId) const;
156 
157  const Route*
158  getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const;
159 
165  const Route*
166  getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const;
167 
181  getPrefixAnnouncement(time::milliseconds minExpiration = 15_s,
182  time::milliseconds maxExpiration = 1_h) const;
183 
185  begin() const;
186 
188  end() const;
189 
190  iterator
191  begin();
192 
193  iterator
194  end();
195 
196 private:
197  void
198  setParent(shared_ptr<RibEntry> parent);
199 
200 private:
201  Name m_name;
202  std::list<shared_ptr<RibEntry>> m_children;
203  shared_ptr<RibEntry> m_parent;
204  RouteList m_routes;
205  RouteList m_inheritedRoutes;
206 
213  uint64_t m_nRoutesWithCaptureSet;
214 };
215 
216 inline void
217 RibEntry::setName(const Name& prefix)
218 {
219  m_name = prefix;
220 }
221 
222 inline const Name&
224 {
225  return m_name;
226 }
227 
228 inline void
229 RibEntry::setParent(shared_ptr<RibEntry> parent)
230 {
231  m_parent = parent;
232 }
233 
234 inline shared_ptr<RibEntry>
236 {
237  return m_parent;
238 }
239 
240 inline const std::list<shared_ptr<RibEntry>>&
242 {
243  return m_children;
244 }
245 
246 inline const RibEntry::RouteList&
248 {
249  return m_routes;
250 }
251 
252 inline const RibEntry::RouteList&
254 {
255  return m_inheritedRoutes;
256 }
257 
260 {
261  return m_routes.begin();
262 }
263 
266 {
267  return m_routes.end();
268 }
269 
270 inline RibEntry::iterator
272 {
273  return m_routes.begin();
274 }
275 
276 inline RibEntry::iterator
278 {
279  return m_routes.end();
280 }
281 
282 std::ostream&
283 operator<<(std::ostream& os, const RibEntry& entry);
284 
285 } // namespace rib
286 } // namespace nfd
287 
288 #endif // NFD_DAEMON_RIB_RIB_ENTRY_HPP
nfd::rib::RibEntry::getChildren
const std::list< shared_ptr< RibEntry > > & getChildren() const
Definition: rib-entry.hpp:241
nfd::rib::RibEntry::findRoute
iterator findRoute(const Route &route)
Definition: rib-entry.cpp:37
nfd::rib::RibEntry::hasRoute
bool hasRoute(const Route &route)
Definition: rib-entry.cpp:73
nfd::rib::RibEntry::getName
const Name & getName() const
Definition: rib-entry.hpp:223
nfd::rib::RibEntry::getNRoutes
size_t getNRoutes() const
Definition: rib-entry.cpp:89
nfd::rib::RibEntry
Represents a RIB entry, which contains one or more Routes with the same prefix.
Definition: rib-entry.hpp:39
nfd::rib::RibEntry::RibEntry
RibEntry()
Definition: rib-entry.hpp:45
nfd::rib::RibEntry::hasChildren
bool hasChildren() const
nfd::rib::RibEntry::getRouteWithSecondLowestCostByFaceId
const Route * getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const
Definition: rib-entry.cpp:194
nfd::rib::RibEntry::eraseRoute
void eraseRoute(const Route &route)
erases a Route with the same faceId and origin
Definition: rib-entry.cpp:66
ndn::PrefixAnnouncement
A prefix announcement object that represents an application's intent of registering a prefix toward i...
Definition: prefix-announcement.hpp:34
nfd::rib::RibEntry::getRouteWithLowestCostAndChildInheritByFaceId
const Route * getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID and its child inherit flag set.
Definition: rib-entry.cpp:218
nfd::rib::RibEntry::getRouteWithLowestCostByFaceId
const Route * getRouteWithLowestCostByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID.
Definition: rib-entry.cpp:172
nfd::rib::RibEntry::hasChildInheritOnFaceId
bool hasChildInheritOnFaceId(uint64_t faceId) const
Determines if the entry has an inherited route with the passed face ID and its child inherit flag set...
Definition: rib-entry.cpp:160
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
route.hpp
nfd::rib::RibEntry::getRoutes
const RouteList & getRoutes() const
Definition: rib-entry.hpp:247
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::rib::RibEntry::const_iterator
RouteList::const_iterator const_iterator
Definition: rib-entry.hpp:43
nfd::rib::RibEntry::iterator
RouteList::iterator iterator
Definition: rib-entry.hpp:42
nfd::rib::operator<<
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
Definition: fib-update.hpp:74
nfd::rib::RibEntry::RouteList
std::list< Route > RouteList
Definition: rib-entry.hpp:41
nfd::rib::RibEntry::addInheritedRoute
void addInheritedRoute(const Route &route)
Definition: rib-entry.cpp:129
nfd::rib::RibEntry::getPrefixAnnouncement
ndn::PrefixAnnouncement getPrefixAnnouncement(time::milliseconds minExpiration=15_s, time::milliseconds maxExpiration=1_h) const
Retrieve a prefix announcement suitable for readvertising this route.
Definition: rib-entry.cpp:242
nfd::rib::RibEntry::hasFaceId
bool hasFaceId(const uint64_t faceId) const
Definition: rib-entry.cpp:81
nfd::rib::RibEntry::hasInheritedRoute
bool hasInheritedRoute(const Route &route) const
Determines if the entry has an inherited route with a matching face ID.
Definition: rib-entry.cpp:148
nfd::rib::RibEntry::addChild
void addChild(shared_ptr< RibEntry > child)
Definition: rib-entry.cpp:95
nfd::rib::RibEntry::hasCapture
bool hasCapture() const
Definition: rib-entry.cpp:154
nfd::rib::RibEntry::findInheritedRoute
RouteList::const_iterator findInheritedRoute(const Route &route) const
Finds an inherited route with a matching face ID.
Definition: rib-entry.cpp:141
nfd::rib::RibEntry::getParent
shared_ptr< RibEntry > getParent() const
Definition: rib-entry.hpp:235
nfd::rib::RibEntry::end
const_iterator end() const
Definition: rib-entry.hpp:265
nfd::rib::RibEntry::removeChild
void removeChild(shared_ptr< RibEntry > child)
Definition: rib-entry.cpp:103
nfd::rib::RibEntry::getInheritedRoutes
const RouteList & getInheritedRoutes() const
Returns the routes this namespace has inherited.
Definition: rib-entry.hpp:253
nfd::rib::RibEntry::hasParent
bool hasParent() const
nfd::rib::Route
represents a route for a name prefix
Definition: route.hpp:44
nfd::rib::RibEntry::setName
void setName(const Name &prefix)
Definition: rib-entry.hpp:217
nfd::rib::RibEntry::begin
const_iterator begin() const
Definition: rib-entry.hpp:259
nfd::rib::RibEntry::insertRoute
std::pair< RibEntry::iterator, bool > insertRoute(const Route &route)
inserts a new route into the entry's route list If another route already exists with the same faceId ...
Definition: rib-entry.cpp:49
nfd::rib::RibEntry::removeInheritedRoute
void removeInheritedRoute(const Route &route)
Definition: rib-entry.cpp:135