38template<encoding::Tag TAG>
42 size_t totalLength = 0;
45 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Mtu, m_mtu);
49 m_defaultCongestionThreshold);
53 m_baseCongestionMarkingInterval.count());
60 m_expirationPeriod.count());
66 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Mask, m_mask);
69 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Flags, m_flags);
72 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Count, m_count);
75 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Capacity, m_capacity);
78 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Cost, m_cost);
81 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::Origin, m_origin);
87 totalLength += prependStringBlock(encoder,
tlv::nfd::Uri, m_uri);
90 totalLength += prependNonNegativeIntegerBlock(encoder,
tlv::nfd::FaceId, m_faceId);
96 totalLength += encoder.prependVarNumber(totalLength);
109 EncodingEstimator estimator;
112 EncodingBuffer buffer(estimatedSize, 0);
115 m_wire = buffer.block();
130 for (
const auto& e : m_wire.
elements()) {
138 m_faceId = readNonNegativeInteger(e);
142 m_uri = readString(e);
146 m_localUri = readString(e);
150 m_origin = readNonNegativeIntegerAs<RouteOrigin>(e);
154 m_cost = readNonNegativeInteger(e);
158 m_capacity = readNonNegativeInteger(e);
162 m_count = readNonNegativeInteger(e);
166 m_flags = readNonNegativeInteger(e);
170 m_mask = readNonNegativeInteger(e);
175 if (e.elements().empty()) {
186 m_facePersistency = readNonNegativeIntegerAs<FacePersistency>(e);
194 m_defaultCongestionThreshold = readNonNegativeInteger(e);
198 m_mtu = readNonNegativeInteger(e);
211 NDN_THROW(std::out_of_range(
"bit must be within range [0, 64)"));
225 NDN_THROW(std::out_of_range(
"bit must be within range [0, 64)"));
239 NDN_THROW(std::out_of_range(
"bit must be within range [0, 64)"));
247 flags &= ~(1 << bit);
264 NDN_THROW(std::out_of_range(
"bit must be within range [0, 64)"));
283 os <<
"ControlParameters(";
286 os <<
"Name: " << parameters.
getName() <<
", ";
290 os <<
"FaceId: " << parameters.
getFaceId() <<
", ";
293 if (parameters.
hasUri()) {
294 os <<
"Uri: " << parameters.
getUri() <<
", ";
298 os <<
"LocalUri: " << parameters.
getLocalUri() <<
", ";
302 os <<
"Origin: " << parameters.
getOrigin() <<
", ";
306 os <<
"Cost: " << parameters.
getCost() <<
", ";
310 os <<
"Capacity: " << parameters.
getCapacity() <<
", ";
314 os <<
"Count: " << parameters.
getCount() <<
", ";
326 os <<
"Strategy: " << parameters.
getStrategy() <<
", ";
345 if (parameters.
hasMtu()) {
346 os <<
"Mtu: " << parameters.
getMtu() <<
", ";
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
Represents a TLV element of the NDN packet format.
const element_container & elements() const noexcept
Get container of sub-elements.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
uint32_t type() const noexcept
Return the TLV-TYPE of the Block.
void parse() const
Parse TLV-VALUE into sub-elements.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder.
void wireDecode(const Block &wire)
Decode name from wire encoding.
Represents parameters in a ControlCommand request or response.
uint64_t getFlags() const
void wireDecode(const Block &wire) final
ControlParameters & unsetFlags()
uint64_t getFaceId() const
const std::string & getUri() const
ControlParameters & setMask(uint64_t mask)
uint64_t getCapacity() const
Block wireEncode() const final
ControlParameters & unsetFlagBit(size_t bit)
Disable a bit in Mask.
uint64_t getDefaultCongestionThreshold() const
Get default congestion threshold (measured in bytes).
bool hasExpirationPeriod() const
ControlParameters & unsetMask()
bool hasBaseCongestionMarkingInterval() const
const time::milliseconds & getExpirationPeriod() const
bool hasFacePersistency() const
FacePersistency getFacePersistency() const
bool hasDefaultCongestionThreshold() const
const Name & getName() const
ControlParameters & setFlagBit(size_t bit, bool value, bool wantMask=true)
Set a bit in Flags.
uint64_t getCount() const
bool hasFlagBit(size_t bit) const
const Name & getStrategy() const
ControlParameters & setFlags(uint64_t flags)
const std::string & getLocalUri() const
bool getFlagBit(size_t bit) const
RouteOrigin getOrigin() const
time::nanoseconds getBaseCongestionMarkingInterval() const
uint64_t getMtu() const
Get MTU (measured in bytes).
#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
@ CONTROL_PARAMETER_STRATEGY
@ CONTROL_PARAMETER_FACE_PERSISTENCY
@ CONTROL_PARAMETER_UBOUND
@ CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD
@ CONTROL_PARAMETER_LOCAL_URI
@ CONTROL_PARAMETER_CAPACITY
@ CONTROL_PARAMETER_EXPIRATION_PERIOD
@ CONTROL_PARAMETER_FLAGS
@ CONTROL_PARAMETER_FACE_ID
@ CONTROL_PARAMETER_COUNT
@ CONTROL_PARAMETER_ORIGIN
@ CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL
Contains classes and functions related to the NFD Management protocol.
constexpr std::array CONTROL_PARAMETER_FIELD
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
::boost::chrono::milliseconds milliseconds
::boost::chrono::nanoseconds nanoseconds
@ BaseCongestionMarkingInterval
@ DefaultCongestionThreshold