NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
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 <boost/range/adaptor/transformed.hpp>
33 
34 namespace nfd {
35 
36 namespace measurements {
37 class Entry;
38 } // namespace measurements
39 namespace pit {
40 class Entry;
41 } // namespace pit
42 
43 namespace fib {
44 
47 class Fib : noncopyable
48 {
49 public:
50  explicit
51  Fib(NameTree& nameTree);
52 
53  size_t
54  size() const
55  {
56  return m_nItems;
57  }
58 
59 public: // lookup
62  const Entry&
63  findLongestPrefixMatch(const Name& prefix) const;
64 
69  const Entry&
70  findLongestPrefixMatch(const pit::Entry& pitEntry) const;
71 
76  const Entry&
77  findLongestPrefixMatch(const measurements::Entry& measurementsEntry) const;
78 
81  Entry*
82  findExactMatch(const Name& prefix);
83 
84 public: // mutation
90  std::pair<Entry*, bool>
91  insert(const Name& prefix);
92 
93  void
94  erase(const Name& prefix);
95 
96  void
97  erase(const Entry& entry);
98 
101  void
102  removeNextHop(Entry& entry, const Face& face);
103 
104 public: // enumeration
105  typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
106  typedef boost::range_iterator<Range>::type const_iterator;
107 
113  const_iterator
114  begin() const
115  {
116  return this->getRange().begin();
117  }
118 
122  const_iterator
123  end() const
124  {
125  return this->getRange().end();
126  }
127 
128 private:
131  template<typename K>
132  const Entry&
133  findLongestPrefixMatchImpl(const K& key) const;
134 
135  void
136  erase(name_tree::Entry* nte, bool canDeleteNte = true);
137 
138  Range
139  getRange() const;
140 
141 private:
142  NameTree& m_nameTree;
143  size_t m_nItems;
144 
150  static const unique_ptr<Entry> s_emptyEntry;
151 };
152 
153 } // namespace fib
154 
155 using fib::Fib;
156 
157 } // namespace nfd
158 
159 #endif // NFD_DAEMON_TABLE_FIB_HPP
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:123
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:47
const_iterator begin() const
Definition: fib.hpp:114
Name abstraction to represent an absolute name.
Definition: name.hpp:46
boost::range_iterator< Range >::type const_iterator
Definition: fib.hpp:106
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:36
boost::iterator_range< Iterator > Range
a Forward Range of name tree entries
size_t size() const
Definition: fib.hpp:54
boost::transformed_range< name_tree::GetTableEntry< Entry >, const name_tree::Range > Range
Definition: fib.hpp:105
an entry in the name tree