34 static_assert(std::is_base_of<tlv::Error, NextHopRecord::Error>::value,
35 "NextHopRecord::Error must inherit from tlv::Error");
40 static_assert(std::is_base_of<tlv::Error, FibEntry::Error>::value,
41 "FibEntry::Error must inherit from tlv::Error");
48 : m_faceId(
std::numeric_limits<uint64_t>::max())
74 template<encoding::Tag TAG>
78 size_t totalLength = 0;
87 totalLength += block.prependVarNumber(totalLength);
93 NextHopRecord::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block)
const;
96 NextHopRecord::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block)
const;
111 m_wire = buffer.block();
118 m_faceId = std::numeric_limits<uint64_t>::max();
124 std::stringstream error;
125 error <<
"Requested decoding of NextHopRecord, but Block is of a different type: #" 127 BOOST_THROW_EXCEPTION(
Error(error.str()));
133 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of NextHopRecord"));
136 std::stringstream error;
137 error <<
"Expected FaceId, but Block is of a different type: #" 139 BOOST_THROW_EXCEPTION(
Error(error.str()));
145 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of NextHopRecord"));
148 std::stringstream error;
149 error <<
"Expected Cost, but Block is of a different type: #" 151 BOOST_THROW_EXCEPTION(
Error(error.str()));
180 m_nextHopRecords.push_back(nextHopRecord);
185 template<encoding::Tag TAG>
189 size_t totalLength = 0;
191 for (
auto i = m_nextHopRecords.rbegin(); i != m_nextHopRecords.rend(); ++i) {
192 totalLength += i->wireEncode(block);
195 totalLength += m_prefix.wireEncode(block);
196 totalLength += block.prependVarNumber(totalLength);
203 FibEntry::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block)
const;
206 FibEntry::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block)
const;
221 m_wire = buffer.block();
230 m_nextHopRecords.clear();
235 std::stringstream error;
236 error <<
"Requested decoding of FibEntry, but Block is of a different type: #" 238 BOOST_THROW_EXCEPTION(
Error(error.str()));
245 BOOST_THROW_EXCEPTION(
Error(
"Unexpected end of FibEntry"));
248 std::stringstream error;
249 error <<
"Expected Name, but Block is of a different type: #" 251 BOOST_THROW_EXCEPTION(
Error(error.str()));
253 m_prefix.wireDecode(*val);
258 std::stringstream error;
259 error <<
"Expected NextHopRecords, but Block is of a different type: #" 261 BOOST_THROW_EXCEPTION(
Error(error.str()));
Copyright (c) 2011-2015 Regents of the University of California.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Helper to prepend TLV block type type containing non-negative integer value.
void wireDecode(const Block &wire)
NextHopRecord & setFaceId(uint64_t faceId)
const Block & wireEncode() const
FibEntry & setPrefix(const Name &prefix)
EncodingImpl< EstimatorTag > EncodingEstimator
Class representing a wire element of NDN-TLV packet format.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
element_const_iterator elements_end() const
const Block & wireEncode() const
element_const_iterator elements_begin() const
void wireDecode(const Block &wire)
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
element_container::const_iterator element_const_iterator
NextHopRecord & setCost(uint64_t cost)
void reset()
Reset wire buffer of the element.
Name abstraction to represent an absolute name.
FibEntry & addNextHopRecord(const NextHopRecord &nextHopRecord)
void parse() const
Parse wire buffer into subblocks.
bool hasWire() const
Check if the Block has fully encoded wire.
a concept check for TLV abstraction with .wireEncode method
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...