33 static_assert(std::is_base_of<tlv::Error, Route::Error>::value,
34 "Route::Error must inherit from tlv::Error");
39 static_assert(std::is_base_of<tlv::Error, RibEntry::Error>::value,
40 "RibEntry::Error must inherit from tlv::Error");
49 , m_expirationPeriod(INFINITE_EXPIRATION_PERIOD)
50 , m_hasInfiniteExpirationPeriod(true)
59 template<encoding::Tag TAG>
63 size_t totalLength = 0;
66 if (!m_hasInfiniteExpirationPeriod) {
69 m_expirationPeriod.count());
88 totalLength += block.prependVarNumber(totalLength);
95 Route::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block)
const;
98 Route::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block)
const;
113 m_wire = buffer.block();
125 m_expirationPeriod = time::milliseconds::min();
130 std::stringstream error;
131 error <<
"Expected Route Block, but Block is of a different type: #" 133 BOOST_THROW_EXCEPTION(
Error(error.str()));
145 BOOST_THROW_EXCEPTION(
Error(
"Missing required FaceId field"));
153 BOOST_THROW_EXCEPTION(
Error(
"Missing required Origin field"));
161 BOOST_THROW_EXCEPTION(
Error(
"Missing required Cost field"));
169 BOOST_THROW_EXCEPTION(
Error(
"Missing required Flags field"));
174 m_hasInfiniteExpirationPeriod =
false;
178 m_hasInfiniteExpirationPeriod =
true;
186 <<
"FaceId: " << route.
getFaceId() <<
", " 187 <<
"Origin: " << route.
getOrigin() <<
", " 188 <<
"Cost: " << route.
getCost() <<
", " 189 <<
"Flags: " << route.
getFlags() <<
", ";
195 os <<
"ExpirationPeriod: Infinity";
219 template<encoding::Tag TAG>
223 size_t totalLength = 0;
225 for (std::list<Route>::const_reverse_iterator it = m_routes.rbegin();
226 it != m_routes.rend(); ++it)
228 totalLength += it->wireEncode(block);
231 totalLength += m_prefix.wireEncode(block);
233 totalLength += block.prependVarNumber(totalLength);
240 RibEntry::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block)
const;
243 RibEntry::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block)
const;
258 m_wire = buffer.block();
272 std::stringstream error;
273 error <<
"Expected RibEntry Block, but Block is of a different type: #" 275 BOOST_THROW_EXCEPTION(
Error(error.str()));
283 m_prefix.wireDecode(*val);
287 BOOST_THROW_EXCEPTION(
Error(
"Missing required Name field"));
293 m_routes.push_back(
Route(*val));
296 std::stringstream error;
297 error <<
"Expected Route Block, but Block is of a different type: #" 299 BOOST_THROW_EXCEPTION(
Error(error.str()));
308 <<
" Name: " << entry.
getName() <<
"\n";
311 os <<
" " << *it <<
"\n";
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.
RouteList::const_iterator iterator
EncodingImpl< EstimatorTag > EncodingEstimator
uint64_t getFaceId() const
uint64_t getOrigin() const
Class representing a wire element of NDN-TLV packet format.
Data abstraction for Route.
uint64_t readNonNegativeInteger(const Block &block)
Helper to read a non-negative integer from a block.
const Name & getName() const
element_const_iterator elements_end() const
static const time::milliseconds INFINITE_EXPIRATION_PERIOD
element_const_iterator elements_begin() const
const Block & wireEncode() const
const time::milliseconds & getExpirationPeriod() const
EncodingImpl< EncoderTag > EncodingBuffer
Copyright (c) 2011-2015 Regents of the University of California.
uint64_t getFlags() const
bool hasInfiniteExpirationPeriod() const
void wireDecode(const Block &wire)
element_container::const_iterator element_const_iterator
const Block & wireEncode() const
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
void parse() const
Parse wire buffer into subblocks.
void wireDecode(const Block &wire)
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 ...
Data abstraction for RIB entry.