NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2018, 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_TABLE_FIB_HPP
27 #define NFD_DAEMON_TABLE_FIB_HPP
28 
29 #include "fib-entry.hpp"
30 #include "name-tree.hpp"
31 
32 #include "core/fib-max-depth.hpp"
33 
34 #include <boost/range/adaptor/transformed.hpp>
35 
36 namespace nfd {
37 
38 namespace measurements {
39 class Entry;
40 } // namespace measurements
41 namespace pit {
42 class Entry;
43 } // namespace pit
44 
45 namespace fib {
46 
49 class Fib : noncopyable
50 {
51 public:
52  explicit
53  Fib(NameTree& nameTree);
54 
55  size_t
56  size() const
57  {
58  return m_nItems;
59  }
60 
61 public: // lookup
64  const Entry&
65  findLongestPrefixMatch(const Name& prefix) const;
66 
71  const Entry&
72  findLongestPrefixMatch(const pit::Entry& pitEntry) const;
73 
78  const Entry&
79  findLongestPrefixMatch(const measurements::Entry& measurementsEntry) const;
80 
83  Entry*
84  findExactMatch(const Name& prefix);
85 
86 public: // mutation
89  static constexpr size_t
91  {
92  return FIB_MAX_DEPTH;
93  }
94 
99  std::pair<Entry*, bool>
100  insert(const Name& prefix);
101 
102  void
103  erase(const Name& prefix);
104 
105  void
106  erase(const Entry& entry);
107 
110  void
111  removeNextHop(Entry& entry, const Face& face);
112 
113 public: // enumeration
114  typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
115  typedef boost::range_iterator<Range>::type const_iterator;
116 
123  begin() const
124  {
125  return this->getRange().begin();
126  }
127 
132  end() const
133  {
134  return this->getRange().end();
135  }
136 
137 private:
140  template<typename K>
141  const Entry&
142  findLongestPrefixMatchImpl(const K& key) const;
143 
144  void
145  erase(name_tree::Entry* nte, bool canDeleteNte = true);
146 
147  Range
148  getRange() const;
149 
150 private:
151  NameTree& m_nameTree;
152  size_t m_nItems;
153 
159  static const unique_ptr<Entry> s_emptyEntry;
160 };
161 
162 } // namespace fib
163 
164 using fib::Fib;
165 
166 } // namespace nfd
167 
168 #endif // NFD_DAEMON_TABLE_FIB_HPP
std::pair< Entry *, bool > insert(const Name &prefix)
find or insert a FIB entry
Definition: fib.cpp:91
Fib(NameTree &nameTree)
Definition: fib.cpp:45
Entry * findExactMatch(const Name &prefix)
performs an exact match lookup
Definition: fib.cpp:81
void erase(const Name &prefix)
Definition: fib.cpp:117
generalization of a network interface
Definition: face.hpp:67
represents a FIB entry
Definition: fib-entry.hpp:51
const_iterator end() const
Definition: fib.hpp:132
static constexpr size_t getMaxDepth()
Maximum number of components in a FIB entry prefix.
Definition: fib.hpp:90
const Entry & findLongestPrefixMatch(const Name &prefix) const
performs a longest prefix match
Definition: fib.cpp:63
represents a Measurements entry
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
represents the Forwarding Information Base (FIB)
Definition: fib.hpp:49
const_iterator begin() const
Definition: fib.hpp:123
Represents an absolute name.
Definition: name.hpp:42
boost::range_iterator< Range >::type const_iterator
Definition: fib.hpp:115
void removeNextHop(Entry &entry, const Face &face)
removes the NextHop record for face
Definition: fib.cpp:137
static const int FIB_MAX_DEPTH
Maximum number of components in a FIB entry prefix.
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:38
boost::iterator_range< Iterator > Range
a Forward Range of name tree entries
size_t size() const
Definition: fib.hpp:56
boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::Range > Range
Definition: fib.hpp:114
an entry in the name tree