7 #ifndef NDN_MANAGEMENT_NFD_FIB_ENTRY_HPP
8 #define NDN_MANAGEMENT_NFD_FIB_ENTRY_HPP
10 #include "../encoding/block.hpp"
11 #include "../encoding/encoding-buffer.hpp"
12 #include "../encoding/tlv-nfd.hpp"
13 #include "../name.hpp"
32 : m_faceId(std::numeric_limits<uint64_t>::max())
75 size_t totalLength = 0;
84 totalLength += block.prependVarNumber(totalLength);
103 m_wire = buffer.block();
110 m_faceId = std::numeric_limits<uint64_t>::max();
117 std::stringstream error;
118 error <<
"Requested decoding of NextHopRecord, but Block is of a different type: #"
120 throw Error(error.str());
127 throw Error(
"Unexpected end of NextHopRecord");
131 std::stringstream error;
132 error <<
"Expected FaceId, but Block is of a different type: #"
134 throw Error(error.str());
141 throw Error(
"Unexpected end of NextHopRecord");
145 std::stringstream error;
146 error <<
"Expected Cost, but Block is of a different type: #"
148 throw Error(error.str());
158 mutable Block m_wire;
201 const std::list<NextHopRecord>&
204 return m_nextHopRecords;
210 m_nextHopRecords.push_back(nextHopRecord);
219 m_nextHopRecords.clear();
220 m_nextHopRecords.assign(begin, end);
229 size_t totalLength = 0;
231 for (std::list<NextHopRecord>::const_reverse_iterator i = m_nextHopRecords.rbegin();
232 i != m_nextHopRecords.rend();
235 totalLength += i->wireEncode(block);
239 totalLength += block.prependVarNumber(totalLength);
259 m_wire = buffer.block();
268 m_nextHopRecords.clear();
274 std::stringstream error;
275 error <<
"Requested decoding of FibEntry, but Block is of a different type: #"
277 throw Error(error.str());
285 throw Error(
"Unexpected end of FibEntry");
289 std::stringstream error;
290 error <<
"Expected Name, but Block is of a different type: #"
292 throw Error(error.str());
301 std::stringstream error;
302 error <<
"Expected NextHopRecords, but Block is of a different type: #"
304 throw Error(error.str());
312 std::list<NextHopRecord> m_nextHopRecords;
314 mutable Block m_wire;
320 #endif // NDN_MANAGEMENT_NFD_FIB_ENTRY_HPP
FibEntry & setPrefix(const Name &prefix)
void wireDecode(const Block &wire)
const Block & wireEncode() const
Class representing wire element of the NDN packet.
NextHopRecord & setCost(uint64_t cost)
size_t wireEncode(EncodingImpl< T > &block) const
size_t wireEncode(EncodingImpl< T > &block) const
uint64_t readNonNegativeInteger(const Block &block)
NextHopRecord & setFaceId(uint64_t faceId)
element_const_iterator elements_end() const
element_const_iterator elements_begin() const
const Name & getPrefix() const
void wireDecode(const Block &wire)
Error(const std::string &what)
const std::list< NextHopRecord > & getNextHopRecords() const
const Block & wireEncode() const
element_container::const_iterator element_const_iterator
void reset()
Reset wire buffer of the element.
A Name holds an array of Name::Component and represents an NDN name.
size_t wireEncode(EncodingImpl< T > &block) const
Fast encoding or block size estimation.
void parse() const
Parse wire buffer into subblocks.
FibEntry & addNextHopRecord(const NextHopRecord &nextHopRecord)
bool hasWire() const
Check if the Block has fully encoded wire.
size_t prependNonNegativeIntegerBlock(EncodingImpl< P > &encoder, uint32_t type, uint64_t number)
helper methods
FibEntry(const Block &block)
Error(const std::string &what)
uint64_t getFaceId() const
void wireDecode(const Block &wire)
void clear()
Clear all the components.
FibEntry & setNextHopRecords(const T &begin, const T &end)
NextHopRecord(const Block &block)
Class representing wire element of the NDN packet.