NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_MGMT_NFD_FIB_ENTRY_HPP
23 #define NDN_MGMT_NFD_FIB_ENTRY_HPP
24 
25 #include "ndn-cxx/name.hpp"
27 
28 namespace ndn {
29 namespace nfd {
30 
35 {
36 public:
37  class Error : public tlv::Error
38  {
39  public:
40  using tlv::Error::Error;
41  };
42 
43  NextHopRecord();
44 
45  explicit
46  NextHopRecord(const Block& block);
47 
48  uint64_t
49  getFaceId() const
50  {
51  return m_faceId;
52  }
53 
55  setFaceId(uint64_t faceId);
56 
57  uint64_t
58  getCost() const
59  {
60  return m_cost;
61  }
62 
64  setCost(uint64_t cost);
65 
66  template<encoding::Tag TAG>
67  size_t
68  wireEncode(EncodingImpl<TAG>& block) const;
69 
70  const Block&
71  wireEncode() const;
72 
73  void
74  wireDecode(const Block& block);
75 
76 private:
77  uint64_t m_faceId;
78  uint64_t m_cost;
79 
80  mutable Block m_wire;
81 };
82 
84 
85 bool
86 operator==(const NextHopRecord& a, const NextHopRecord& b);
87 
88 inline bool
90 {
91  return !(a == b);
92 }
93 
94 std::ostream&
95 operator<<(std::ostream& os, const NextHopRecord& nh);
96 
97 
101 class FibEntry
102 {
103 public:
104  class Error : public tlv::Error
105  {
106  public:
107  explicit
108  Error(const std::string& what)
109  : tlv::Error(what)
110  {
111  }
112  };
113 
114  FibEntry();
115 
116  explicit
117  FibEntry(const Block& block);
118 
119  const Name&
120  getPrefix() const
121  {
122  return m_prefix;
123  }
124 
125  FibEntry&
126  setPrefix(const Name& prefix);
127 
128  const std::vector<NextHopRecord>&
130  {
131  return m_nextHopRecords;
132  }
133 
134  template<typename InputIt>
135  FibEntry&
136  setNextHopRecords(InputIt first, InputIt last)
137  {
138  m_nextHopRecords.assign(first, last);
139  m_wire.reset();
140  return *this;
141  }
142 
143  FibEntry&
144  addNextHopRecord(const NextHopRecord& nh);
145 
146  FibEntry&
148 
149  template<encoding::Tag TAG>
150  size_t
151  wireEncode(EncodingImpl<TAG>& block) const;
152 
153  const Block&
154  wireEncode() const;
155 
156  void
157  wireDecode(const Block& block);
158 
159 private:
160  Name m_prefix;
161  std::vector<NextHopRecord> m_nextHopRecords;
162 
163  mutable Block m_wire;
164 };
165 
167 
168 bool
169 operator==(const FibEntry& a, const FibEntry& b);
170 
171 inline bool
172 operator!=(const FibEntry& a, const FibEntry& b)
173 {
174  return !(a == b);
175 }
176 
177 std::ostream&
178 operator<<(std::ostream& os, const FibEntry& entry);
179 
180 } // namespace nfd
181 } // namespace ndn
182 
183 #endif // NDN_MGMT_NFD_FIB_ENTRY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
void wireDecode(const Block &block)
Definition: fib-entry.cpp:208
NextHopRecord & setFaceId(uint64_t faceId)
Definition: fib-entry.cpp:48
FibEntry & setNextHopRecords(InputIt first, InputIt last)
Definition: fib-entry.hpp:136
FibEntry & setPrefix(const Name &prefix)
Definition: fib-entry.cpp:150
const std::vector< NextHopRecord > & getNextHopRecords() const
Definition: fib-entry.hpp:129
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
void wireDecode(const Block &block)
Definition: fib-entry.cpp:96
uint64_t getCost() const
Definition: fib-entry.hpp:58
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
FibEntry & clearNextHopRecords()
Definition: fib-entry.cpp:166
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
NextHopRecord & setCost(uint64_t cost)
Definition: fib-entry.cpp:56
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
void reset()
Reset wire buffer of the element.
Definition: block.cpp:255
Represents an absolute name.
Definition: name.hpp:43
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
const Block & wireEncode() const
Definition: fib-entry.cpp:192
Error(const std::string &what)
Definition: fib-entry.hpp:108
const Name & getPrefix() const
Definition: fib-entry.hpp:120
uint64_t getFaceId() const
Definition: fib-entry.hpp:49
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52
const Block & wireEncode() const
Definition: fib-entry.cpp:80
FibEntry & addNextHopRecord(const NextHopRecord &nh)
Definition: fib-entry.cpp:158