28 #include <boost/range/adaptor/reversed.hpp> 33 BOOST_CONCEPT_ASSERT((StatusDatasetItem<NextHopRecord>));
34 BOOST_CONCEPT_ASSERT((StatusDatasetItem<FibEntry>));
63 template<encoding::Tag TAG>
67 size_t totalLength = 0;
72 totalLength += block.prependVarNumber(totalLength);
91 m_wire = buffer.block();
99 BOOST_THROW_EXCEPTION(
Error(
"expecting NextHopRecord, but Block has type " +
to_string(block.
type())));
105 if (val == m_wire.elements_end()) {
106 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of NextHopRecord"));
109 BOOST_THROW_EXCEPTION(
Error(
"expecting FaceId, but Block has type " +
to_string(val->type())));
114 if (val == m_wire.elements_end()) {
115 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of NextHopRecord"));
118 BOOST_THROW_EXCEPTION(
Error(
"expecting Cost, but Block has type " +
to_string(val->type())));
134 return os <<
"NextHopRecord(" 160 m_nextHopRecords.push_back(nh);
168 m_nextHopRecords.clear();
173 template<encoding::Tag TAG>
177 size_t totalLength = 0;
179 for (
const auto& nh : m_nextHopRecords | boost::adaptors::reversed) {
180 totalLength += nh.wireEncode(block);
182 totalLength += m_prefix.wireEncode(block);
184 totalLength += block.prependVarNumber(totalLength);
203 m_wire = buffer.block();
211 BOOST_THROW_EXCEPTION(
Error(
"expecting FibEntry, but Block has type " +
to_string(block.
type())));
217 if (val == m_wire.elements_end()) {
218 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of FibEntry"));
221 BOOST_THROW_EXCEPTION(
Error(
"expecting Name, but Block has type " +
to_string(val->type())));
223 m_prefix.wireDecode(*val);
226 m_nextHopRecords.clear();
227 for (; val != m_wire.elements_end(); ++val) {
229 BOOST_THROW_EXCEPTION(
Error(
"expecting NextHopRecord, but Block has type " +
to_string(val->type())));
231 m_nextHopRecords.emplace_back(*val);
242 aNextHops.
size() != bNextHops.size())
245 std::vector<bool> matched(bNextHops.size(),
false);
246 return std::all_of(aNextHops.begin(), aNextHops.end(),
248 for (
size_t i = 0; i < bNextHops.size(); ++i) {
249 if (!matched[i] && bNextHops[i] == nh) {
261 os <<
"FibEntry(Prefix: " << entry.
getPrefix() <<
",\n" Copyright (c) 2013-2017 Regents of the University of California.
void wireDecode(const Block &block)
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
NextHopRecord & setFaceId(uint64_t faceId)
const Block & wireEncode() const
FibEntry & setPrefix(const Name &prefix)
element_container::const_iterator element_const_iterator
Represents a TLV element of NDN packet format.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
ostream_joiner< typename std::decay< DelimT >::type, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
void wireDecode(const Block &block)
const Block & wireEncode() const
const Name & getPrefix() const
FibEntry & clearNextHopRecords()
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
size_t size() const
Get number of components.
NextHopRecord & setCost(uint64_t cost)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
void reset()
Reset wire buffer of the element.
Represents an absolute name.
void parse() const
Parse TLV-VALUE into sub elements.
uint32_t type() const
Get TLV-TYPE.
const std::vector< NextHopRecord > & getNextHopRecords() const
bool hasWire() const
Check if the Block has fully encoded wire.
std::string to_string(const V &v)
uint64_t getFaceId() const
EncodingImpl< EncoderTag > EncodingBuffer
const uint64_t INVALID_FACE_ID
EncodingImpl< EstimatorTag > EncodingEstimator
FibEntry & addNextHopRecord(const NextHopRecord &nh)