29 #include <boost/range/adaptor/reversed.hpp> 85 if (expirationPeriod == time::milliseconds::max())
88 m_expirationPeriod = expirationPeriod;
101 template<encoding::Tag TAG>
105 size_t totalLength = 0;
107 if (m_expirationPeriod) {
109 static_cast<uint64_t>(m_expirationPeriod->count()));
116 totalLength += block.prependVarNumber(totalLength);
135 m_wire = buffer.block();
143 BOOST_THROW_EXCEPTION(
Error(
"expecting Route, but Block has type " +
to_string(block.
type())));
154 BOOST_THROW_EXCEPTION(
Error(
"missing required FaceId field"));
158 m_origin = readNonNegativeIntegerAs<RouteOrigin>(*val);
162 BOOST_THROW_EXCEPTION(
Error(
"missing required Origin field"));
170 BOOST_THROW_EXCEPTION(
Error(
"missing required Cost field"));
178 BOOST_THROW_EXCEPTION(
Error(
"missing required Flags field"));
204 <<
"FaceId: " << route.
getFaceId() <<
", " 205 <<
"Origin: " << route.
getOrigin() <<
", " 206 <<
"Cost: " << route.
getCost() <<
", " 213 os <<
"ExpirationPeriod: infinite";
239 m_routes.push_back(route);
252 template<encoding::Tag TAG>
256 size_t totalLength = 0;
258 for (
const auto& route : m_routes | boost::adaptors::reversed) {
259 totalLength += route.wireEncode(block);
263 totalLength += block.prependVarNumber(totalLength);
282 m_wire = buffer.block();
290 BOOST_THROW_EXCEPTION(
Error(
"expecting RibEntry, but Block has type " +
to_string(block.
type())));
297 BOOST_THROW_EXCEPTION(
Error(
"unexpected end of RibEntry"));
300 BOOST_THROW_EXCEPTION(
Error(
"expecting Name, but Block has type " +
to_string(val->type())));
308 BOOST_THROW_EXCEPTION(
Error(
"expecting Route, but Block has type " +
to_string(val->type())));
310 m_routes.emplace_back(*val);
321 aRoutes.
size() != bRoutes.size())
324 std::vector<bool> matched(bRoutes.size(),
false);
325 return std::all_of(aRoutes.begin(), aRoutes.end(),
326 [&] (
const Route& route) {
327 for (
size_t i = 0; i < bRoutes.size(); ++i) {
328 if (!matched[i] && bRoutes[i] == route) {
340 os <<
"RibEntry(Prefix: " << entry.
getName() <<
",\n"
bool hasWire() const
Check if the Block has fully encoded wire.
Copyright (c) 2011-2015 Regents of the University of California.
size_t prependNonNegativeIntegerBlock(EncodingImpl< TAG > &encoder, uint32_t type, uint64_t value)
Prepend a TLV element containing a non-negative integer.
Route & setFlags(uint64_t flags)
const Name & getName() const
element_container::const_iterator element_const_iterator
void wireDecode(const Block &block)
Route & setOrigin(RouteOrigin origin)
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
void parse() const
Parse TLV-VALUE into sub elements.
time::milliseconds getExpirationPeriod() const
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
Represents a TLV element of NDN packet format.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
represents a route in a RibEntry
void wireDecode(const Block &block)
Route & setCost(uint64_t cost)
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
element_const_iterator elements_end() const
Equivalent to elements().end()
Copyright (c) 2011-2015 Regents of the University of California.
const Block & wireEncode() const
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
uint64_t getFaceId() const
ostream_joiner< std::decay_t< DelimT >, CharT, Traits > make_ostream_joiner(std::basic_ostream< CharT, Traits > &os, DelimT &&delimiter)
RibEntry & addRoute(const Route &route)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
void reset()
Reset wire buffer of the element.
Represents an absolute name.
concept check for an item in a Status Dataset
size_t size() const
Get number of components.
Route & unsetExpirationPeriod()
bool hasExpirationPeriod() const
const Block & wireEncode() const
uint64_t getFlags() const
Route & setFaceId(uint64_t faceId)
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
std::string to_string(const V &v)
const std::vector< Route > & getRoutes() const
void wireDecode(const Block &wire)
Decode name from wire encoding.
Route & setExpirationPeriod(time::milliseconds expirationPeriod)
RibEntry & setName(const Name &prefix)
represents an item in NFD RIB dataset
EncodingImpl< EncoderTag > EncodingBuffer
const nullopt_t nullopt((nullopt_t::init()))
uint32_t type() const
Get TLV-TYPE.
RouteOrigin getOrigin() const
const uint64_t INVALID_FACE_ID
EncodingImpl< EstimatorTag > EncodingEstimator