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-2017 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 "../../encoding/block.hpp"
26 #include "../../name.hpp"
27 
28 namespace ndn {
29 namespace nfd {
30 
35 {
36 public:
37  class Error : public tlv::Error
38  {
39  public:
40  explicit
41  Error(const std::string& what)
42  : tlv::Error(what)
43  {
44  }
45  };
46 
47  NextHopRecord();
48 
49  explicit
50  NextHopRecord(const Block& block);
51 
52  uint64_t
53  getFaceId() const
54  {
55  return m_faceId;
56  }
57 
59  setFaceId(uint64_t faceId);
60 
61  uint64_t
62  getCost() const
63  {
64  return m_cost;
65  }
66 
68  setCost(uint64_t cost);
69 
70  template<encoding::Tag TAG>
71  size_t
72  wireEncode(EncodingImpl<TAG>& block) const;
73 
74  const Block&
75  wireEncode() const;
76 
77  void
78  wireDecode(const Block& block);
79 
80 private:
81  uint64_t m_faceId;
82  uint64_t m_cost;
83 
84  mutable Block m_wire;
85 };
86 
88 
89 bool
90 operator==(const NextHopRecord& a, const NextHopRecord& b);
91 
92 inline bool
94 {
95  return !(a == b);
96 }
97 
98 std::ostream&
99 operator<<(std::ostream& os, const NextHopRecord& nh);
100 
101 
105 class FibEntry
106 {
107 public:
108  class Error : public tlv::Error
109  {
110  public:
111  explicit
112  Error(const std::string& what)
113  : tlv::Error(what)
114  {
115  }
116  };
117 
118  FibEntry();
119 
120  explicit
121  FibEntry(const Block& block);
122 
123  const Name&
124  getPrefix() const
125  {
126  return m_prefix;
127  }
128 
129  FibEntry&
130  setPrefix(const Name& prefix);
131 
132  const std::vector<NextHopRecord>&
134  {
135  return m_nextHopRecords;
136  }
137 
138  template<typename InputIt>
139  FibEntry&
140  setNextHopRecords(InputIt first, InputIt last)
141  {
142  m_nextHopRecords.assign(first, last);
143  m_wire.reset();
144  return *this;
145  }
146 
147  FibEntry&
148  addNextHopRecord(const NextHopRecord& nh);
149 
150  FibEntry&
152 
153  template<encoding::Tag TAG>
154  size_t
155  wireEncode(EncodingImpl<TAG>& block) const;
156 
157  const Block&
158  wireEncode() const;
159 
160  void
161  wireDecode(const Block& block);
162 
163 private:
164  Name m_prefix;
165  std::vector<NextHopRecord> m_nextHopRecords;
166 
167  mutable Block m_wire;
168 };
169 
171 
172 bool
173 operator==(const FibEntry& a, const FibEntry& b);
174 
175 inline bool
176 operator!=(const FibEntry& a, const FibEntry& b)
177 {
178  return !(a == b);
179 }
180 
181 std::ostream&
182 operator<<(std::ostream& os, const FibEntry& entry);
183 
184 } // namespace nfd
185 } // namespace ndn
186 
187 #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:140
FibEntry & setPrefix(const Name &prefix)
Definition: fib-entry.cpp:150
const std::vector< NextHopRecord > & getNextHopRecords() const
Definition: fib-entry.hpp:133
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:62
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
FibEntry & clearNextHopRecords()
Definition: fib-entry.cpp:166
Error(const std::string &what)
Definition: fib-entry.hpp:41
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:258
Represents an absolute name.
Definition: name.hpp:42
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:112
const Name & getPrefix() const
Definition: fib-entry.hpp:124
uint64_t getFaceId() const
Definition: fib-entry.hpp:53
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
const Block & wireEncode() const
Definition: fib-entry.cpp:80
FibEntry & addNextHopRecord(const NextHopRecord &nh)
Definition: fib-entry.cpp:158