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;
59 m_defaultCongestionThreshold);
63 m_baseCongestionMarkingInterval.count());
70 m_expirationPeriod.count());
106 totalLength += encoder.prependVarNumber(totalLength);
125 m_wire = buffer.block();
133 BOOST_THROW_EXCEPTION(
Error(
"Expecting TLV-TYPE ControlParameters"));
166 m_origin = readNonNegativeIntegerAs<RouteOrigin>(*val);
203 if (val->elements().empty()) {
204 BOOST_THROW_EXCEPTION(
Error(
"Expecting Strategy/Name"));
207 m_strategy.
wireDecode(*val->elements_begin());
220 m_facePersistency = readNonNegativeIntegerAs<FacePersistency>(*val);
246 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
260 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
274 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
282 flags &= ~(1 << bit);
299 BOOST_THROW_EXCEPTION(std::out_of_range(
"bit must be within range [0, 64)"));
318 os <<
"ControlParameters(";
321 os <<
"Name: " << parameters.
getName() <<
", ";
325 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
328 if (parameters.
hasUri()) {
329 os <<
"Uri: " << parameters.
getUri() <<
", ";
333 os <<
"LocalUri: " << parameters.
getLocalUri() <<
", ";
337 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
341 os <<
"Cost: " << parameters.
getCost() <<
", ";
345 os <<
"Capacity: " << parameters.
getCapacity() <<
", ";
349 os <<
"Count: " << parameters.
getCount() <<
", ";
361 os <<
"Strategy: " << parameters.
getStrategy() <<
", ";
380 if (parameters.
hasMtu()) {
381 os <<
"Mtu: " << parameters.
getMtu() <<
", ";
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
uint64_t getMtu() const
get MTU (measured in bytes)
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