34 static_assert(std::is_base_of<tlv::Error, ControlParameters::Error>::value,
35 "ControlParameters::Error must inherit from tlv::Error");
48 template<encoding::Tag TAG>
52 size_t totalLength = 0;
56 m_defaultCongestionThreshold);
60 m_baseCongestionMarkingInterval.count());
67 m_expirationPeriod.count());
103 totalLength += encoder.prependVarNumber(totalLength);
122 m_wire = buffer.block();
130 BOOST_THROW_EXCEPTION(
Error(
"Expecting TLV-TYPE ControlParameters"));
163 m_origin = readNonNegativeIntegerAs<RouteOrigin>(*val);
200 if (val->elements().empty()) {
201 BOOST_THROW_EXCEPTION(
Error(
"Expecting Strategy/Name"));
204 m_strategy.
wireDecode(*val->elements_begin());
217 m_facePersistency = readNonNegativeIntegerAs<FacePersistency>(*val);
237 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
251 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
265 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
273 flags &= ~(1 << bit);
290 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
309 os <<
"ControlParameters(";
312 os <<
"Name: " << parameters.
getName() <<
", ";
316 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
319 if (parameters.
hasUri()) {
320 os <<
"Uri: " << parameters.
getUri() <<
", ";
324 os <<
"LocalUri: " << parameters.
getLocalUri() <<
", ";
328 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
332 os <<
"Cost: " << parameters.
getCost() <<
", ";
336 os <<
"Capacity: " << parameters.
getCapacity() <<
", ";
340 os <<
"Count: " << parameters.
getCount() <<
", ";
352 os <<
"Strategy: " << parameters.
getStrategy() <<
", ";
uint64_t getFlags() const
bool hasWire() const
Check if the Block has fully encoded wire.
void wireDecode(const Block &wire) final
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.
represents parameters in a ControlCommand request or response
time::nanoseconds getBaseCongestionMarkingInterval() const
element_container::const_iterator element_const_iterator
Helper class to convert a number to hexadecimal format, for use with stream insertion operators...
size_t prependNestedBlock(EncodingImpl< TAG > &encoder, uint32_t type, const U &value)
Prepend a TLV element containing a nested TLV element.
void parse() const
Parse TLV-VALUE into sub elements.
ControlParameters & setFlags(uint64_t flags)
ControlParameters & unsetMask()
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
Represents a TLV element of NDN packet format.
size_t prependStringBlock(EncodingImpl< TAG > &encoder, uint32_t type, const std::string &value)
Prepend a TLV element containing a string.
std::string readString(const Block &block)
Read TLV-VALUE of a TLV element as a string.
ControlParameters & unsetFlags()
bool hasBaseCongestionMarkingInterval() const
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
ControlParameters & unsetFlagBit(size_t bit)
disable a bit in Mask
uint64_t getCapacity() const
FacePersistency getFacePersistency() const
const Name & getName() const
element_const_iterator elements_end() const
Equivalent to elements().end()
uint64_t getCount() const
Block wireEncode() const final
Copyright (c) 2011-2015 Regents of the University of California.
element_const_iterator find(uint32_t type) const
Find the first sub element of specified TLV-TYPE.
const std::string & getLocalUri() const
uint64_t getDefaultCongestionThreshold() const
get default congestion threshold (measured in bytes)
bool hasExpirationPeriod() const
RouteOrigin getOrigin() const
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
bool hasFlagBit(size_t bit) const
uint64_t getFaceId() const
const std::string & getUri() const
bool hasFacePersistency() const
const time::milliseconds & getExpirationPeriod() const
bool hasDefaultCongestionThreshold() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
bool getFlagBit(size_t bit) const
void wireDecode(const Block &wire)
Decode name from wire encoding.
a concept check for TLV abstraction with .wireEncode method
const Name & getStrategy() const
ControlParameters & setMask(uint64_t mask)
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
ControlParameters & setFlagBit(size_t bit, bool value, bool wantMask=true)
set a bit in Flags
EncodingImpl< EncoderTag > EncodingBuffer
uint32_t type() const
Get TLV-TYPE.
EncodingImpl< EstimatorTag > EncodingEstimator