Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58b423fe00 | ||
|
|
e72ce81d2b |
No files matched your search
+69
-6
@@ -22,6 +22,7 @@
|
|||||||
#include "ndn-cxx/data.hpp"
|
#include "ndn-cxx/data.hpp"
|
||||||
#include "ndn-cxx/signature.hpp"
|
#include "ndn-cxx/signature.hpp"
|
||||||
#include "ndn-cxx/util/sha256.hpp"
|
#include "ndn-cxx/util/sha256.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace ndn {
|
namespace ndn {
|
||||||
|
|
||||||
@@ -50,6 +51,8 @@ Data::wireEncode(EncodingImpl<TAG>& encoder, bool wantUnsignedPortionOnly) const
|
|||||||
// Name
|
// Name
|
||||||
// [MetaInfo]
|
// [MetaInfo]
|
||||||
// [Content]
|
// [Content]
|
||||||
|
// [ServiceClass]
|
||||||
|
// [TargetRate]
|
||||||
// SignatureInfo
|
// SignatureInfo
|
||||||
// SignatureValue
|
// SignatureValue
|
||||||
// (elements are encoded in reverse order)
|
// (elements are encoded in reverse order)
|
||||||
@@ -67,6 +70,18 @@ Data::wireEncode(EncodingImpl<TAG>& encoder, bool wantUnsignedPortionOnly) const
|
|||||||
// SignatureInfo
|
// SignatureInfo
|
||||||
totalLength += m_signatureInfo.wireEncode(encoder, SignatureInfo::Type::Data);
|
totalLength += m_signatureInfo.wireEncode(encoder, SignatureInfo::Type::Data);
|
||||||
|
|
||||||
|
// TargetRate
|
||||||
|
if (getTargetRate()) {
|
||||||
|
uint64_t targetRate = *getTargetRate();
|
||||||
|
totalLength += encoder.prependByteArrayBlock(tlv::TargetRate, reinterpret_cast<uint8_t*>(&targetRate), sizeof(targetRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceClass
|
||||||
|
if (getServiceClass()) {
|
||||||
|
uint8_t serviceClass = *getServiceClass();
|
||||||
|
totalLength += encoder.prependByteArrayBlock(tlv::ServiceClass, reinterpret_cast<uint8_t*>(&serviceClass), sizeof(serviceClass));
|
||||||
|
}
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
if (hasContent()) {
|
if (hasContent()) {
|
||||||
totalLength += encoder.prependBlock(m_content);
|
totalLength += encoder.prependBlock(m_content);
|
||||||
@@ -133,6 +148,8 @@ Data::wireDecode(const Block& wire)
|
|||||||
// Name
|
// Name
|
||||||
// [MetaInfo]
|
// [MetaInfo]
|
||||||
// [Content]
|
// [Content]
|
||||||
|
// [ServiceClass]
|
||||||
|
// [TargetRate]
|
||||||
// SignatureInfo
|
// SignatureInfo
|
||||||
// SignatureValue
|
// SignatureValue
|
||||||
|
|
||||||
@@ -150,6 +167,7 @@ Data::wireDecode(const Block& wire)
|
|||||||
|
|
||||||
int lastElement = 1; // last recognized element index, in spec order
|
int lastElement = 1; // last recognized element index, in spec order
|
||||||
for (++element; element != m_wire.elements_end(); ++element) {
|
for (++element; element != m_wire.elements_end(); ++element) {
|
||||||
|
// std::cout << "element: " << element->type() << std::endl;
|
||||||
switch (element->type()) {
|
switch (element->type()) {
|
||||||
case tlv::MetaInfo: {
|
case tlv::MetaInfo: {
|
||||||
if (lastElement >= 2) {
|
if (lastElement >= 2) {
|
||||||
@@ -167,22 +185,47 @@ Data::wireDecode(const Block& wire)
|
|||||||
lastElement = 3;
|
lastElement = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tlv::SignatureInfo: {
|
case tlv::ServiceClass: {
|
||||||
if (lastElement >= 4) {
|
if (lastElement >= 4) {
|
||||||
NDN_THROW(Error("SignatureInfo element is out of order"));
|
break; // ServiceClass is non-critical, ignore out-of-order appearance
|
||||||
}
|
}
|
||||||
m_signatureInfo.wireDecode(*element);
|
if (element->value_size() != 1) {
|
||||||
|
NDN_THROW(Error("ServiceClass element is malformed"));
|
||||||
|
}
|
||||||
|
m_serviceClass = *element->value();
|
||||||
lastElement = 4;
|
lastElement = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tlv::SignatureValue: {
|
case tlv::TargetRate: {
|
||||||
if (lastElement >= 5) {
|
if (lastElement >= 5) {
|
||||||
NDN_THROW(Error("SignatureValue element is out of order"));
|
break; // TargetRate is non-critical, ignore out-of-order appearance
|
||||||
}
|
}
|
||||||
m_signatureValue = *element;
|
uint64_t targetRate = 0;
|
||||||
|
if (element->value_size() != 8) {
|
||||||
|
NDN_THROW(Error("TargetRate element is malformed"));
|
||||||
|
}
|
||||||
|
std::memcpy(&targetRate, element->value(), sizeof(targetRate));
|
||||||
|
m_targetRate = targetRate;
|
||||||
lastElement = 5;
|
lastElement = 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case tlv::SignatureInfo: {
|
||||||
|
if (lastElement >= 6) {
|
||||||
|
NDN_THROW(Error("SignatureInfo element is out of order"));
|
||||||
|
}
|
||||||
|
m_signatureInfo.wireDecode(*element);
|
||||||
|
lastElement = 6;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case tlv::SignatureValue: {
|
||||||
|
if (lastElement >= 7) {
|
||||||
|
NDN_THROW(Error("SignatureValue element is out of order"));
|
||||||
|
}
|
||||||
|
m_signatureValue = *element;
|
||||||
|
lastElement = 7;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: { // unrecognized element
|
default: { // unrecognized element
|
||||||
// if the TLV-TYPE is critical, abort decoding
|
// if the TLV-TYPE is critical, abort decoding
|
||||||
if (tlv::isCriticalType(element->type())) {
|
if (tlv::isCriticalType(element->type())) {
|
||||||
@@ -339,6 +382,26 @@ Data::extractSignedRanges() const
|
|||||||
return bufs;
|
return bufs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Data&
|
||||||
|
Data::setServiceClass(optional<uint8_t> serviceClass) const
|
||||||
|
{
|
||||||
|
if (m_serviceClass != serviceClass) {
|
||||||
|
m_serviceClass = serviceClass;
|
||||||
|
m_wire.reset();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Data&
|
||||||
|
Data::setTargetRate(optional<uint64_t> targetRate) const
|
||||||
|
{
|
||||||
|
if (m_targetRate != targetRate) {
|
||||||
|
m_targetRate = targetRate;
|
||||||
|
m_wire.reset();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Data&
|
Data&
|
||||||
Data::setContentType(uint32_t type)
|
Data::setContentType(uint32_t type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -272,6 +272,22 @@ public: // Data fields
|
|||||||
InputBuffers
|
InputBuffers
|
||||||
extractSignedRanges() const;
|
extractSignedRanges() const;
|
||||||
|
|
||||||
|
|
||||||
|
optional<uint8_t>
|
||||||
|
getServiceClass() const noexcept
|
||||||
|
{
|
||||||
|
return m_serviceClass;
|
||||||
|
}
|
||||||
|
const Data&
|
||||||
|
setServiceClass(optional<uint8_t> serviceClass) const;
|
||||||
|
optional<uint64_t>
|
||||||
|
getTargetRate() const noexcept
|
||||||
|
{
|
||||||
|
return m_targetRate;
|
||||||
|
}
|
||||||
|
const Data&
|
||||||
|
setTargetRate(optional<uint64_t> targetRate) const;
|
||||||
|
|
||||||
public: // MetaInfo fields
|
public: // MetaInfo fields
|
||||||
uint32_t
|
uint32_t
|
||||||
getContentType() const
|
getContentType() const
|
||||||
@@ -331,6 +347,9 @@ private:
|
|||||||
Block m_content;
|
Block m_content;
|
||||||
SignatureInfo m_signatureInfo;
|
SignatureInfo m_signatureInfo;
|
||||||
Block m_signatureValue;
|
Block m_signatureValue;
|
||||||
|
// Add for QSCCP
|
||||||
|
mutable optional<uint8_t> m_serviceClass;
|
||||||
|
mutable optional<uint64_t> m_targetRate;
|
||||||
|
|
||||||
mutable Block m_wire;
|
mutable Block m_wire;
|
||||||
mutable Name m_fullName; ///< cached FullName computed from m_wire
|
mutable Name m_fullName; ///< cached FullName computed from m_wire
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ enum {
|
|||||||
BaseCongestionMarkingInterval = 135,
|
BaseCongestionMarkingInterval = 135,
|
||||||
DefaultCongestionThreshold = 136,
|
DefaultCongestionThreshold = 136,
|
||||||
Mtu = 137,
|
Mtu = 137,
|
||||||
|
Bandwidth = 138,
|
||||||
FaceQueryFilter = 150,
|
FaceQueryFilter = 150,
|
||||||
FaceEventNotification = 192,
|
FaceEventNotification = 192,
|
||||||
FaceEventKind = 193,
|
FaceEventKind = 193,
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ enum : uint32_t {
|
|||||||
Nonce = 10,
|
Nonce = 10,
|
||||||
InterestLifetime = 12,
|
InterestLifetime = 12,
|
||||||
HopLimit = 34,
|
HopLimit = 34,
|
||||||
|
ServiceClass = 129,
|
||||||
|
DownstreamRate = 130,
|
||||||
|
TargetRate = 131,
|
||||||
|
Dsz = 132,
|
||||||
ApplicationParameters = 36,
|
ApplicationParameters = 36,
|
||||||
InterestSignatureInfo = 44,
|
InterestSignatureInfo = 44,
|
||||||
InterestSignatureValue = 46,
|
InterestSignatureValue = 46,
|
||||||
|
|||||||
+97
-2
@@ -105,6 +105,9 @@ Interest::wireEncode(EncodingImpl<TAG>& encoder) const
|
|||||||
// [Nonce]
|
// [Nonce]
|
||||||
// [InterestLifetime]
|
// [InterestLifetime]
|
||||||
// [HopLimit]
|
// [HopLimit]
|
||||||
|
// [Dsz]
|
||||||
|
// [ServiceClass]
|
||||||
|
// [DownstreamRate]
|
||||||
// [ApplicationParameters [InterestSignature]]
|
// [ApplicationParameters [InterestSignature]]
|
||||||
// (elements are encoded in reverse order)
|
// (elements are encoded in reverse order)
|
||||||
|
|
||||||
@@ -126,6 +129,24 @@ Interest::wireEncode(EncodingImpl<TAG>& encoder) const
|
|||||||
totalLength += encoder.prependBlock(block);
|
totalLength += encoder.prependBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DownstreamRate
|
||||||
|
if (getDownstreamRate()) {
|
||||||
|
uint64_t downstreamRate = *getDownstreamRate();
|
||||||
|
totalLength += encoder.prependByteArrayBlock(tlv::DownstreamRate, reinterpret_cast<uint8_t*>(&downstreamRate), sizeof(downstreamRate));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceClass
|
||||||
|
if (getServiceClass()) {
|
||||||
|
uint8_t serviceClass = *getServiceClass();
|
||||||
|
totalLength += encoder.prependByteArrayBlock(tlv::ServiceClass, reinterpret_cast<uint8_t*>(&serviceClass), sizeof(serviceClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dsz
|
||||||
|
if (getDsz()) {
|
||||||
|
uint16_t dsz = *getDsz();
|
||||||
|
totalLength += encoder.prependByteArrayBlock(tlv::Dsz, reinterpret_cast<uint8_t*>(&dsz), sizeof(dsz));
|
||||||
|
}
|
||||||
|
|
||||||
// HopLimit
|
// HopLimit
|
||||||
if (getHopLimit()) {
|
if (getHopLimit()) {
|
||||||
totalLength += encoder.prependByteArrayBlock(tlv::HopLimit, &*m_hopLimit, 1);
|
totalLength += encoder.prependByteArrayBlock(tlv::HopLimit, &*m_hopLimit, 1);
|
||||||
@@ -200,6 +221,9 @@ Interest::wireDecode(const Block& wire)
|
|||||||
// [Nonce]
|
// [Nonce]
|
||||||
// [InterestLifetime]
|
// [InterestLifetime]
|
||||||
// [HopLimit]
|
// [HopLimit]
|
||||||
|
// [Dsz]
|
||||||
|
// [ServiceClass]
|
||||||
|
// [DownstreamRate]
|
||||||
// [ApplicationParameters [InterestSignature]]
|
// [ApplicationParameters [InterestSignature]]
|
||||||
|
|
||||||
auto element = m_wire.elements_begin();
|
auto element = m_wire.elements_begin();
|
||||||
@@ -224,6 +248,9 @@ Interest::wireDecode(const Block& wire)
|
|||||||
m_nonce.reset();
|
m_nonce.reset();
|
||||||
m_interestLifetime = DEFAULT_INTEREST_LIFETIME;
|
m_interestLifetime = DEFAULT_INTEREST_LIFETIME;
|
||||||
m_hopLimit.reset();
|
m_hopLimit.reset();
|
||||||
|
m_serviceClass.reset();
|
||||||
|
m_downstreamRate.reset();
|
||||||
|
m_dsz.reset();
|
||||||
m_parameters.clear();
|
m_parameters.clear();
|
||||||
|
|
||||||
int lastElement = 1; // last recognized element index, in spec order
|
int lastElement = 1; // last recognized element index, in spec order
|
||||||
@@ -290,13 +317,50 @@ Interest::wireDecode(const Block& wire)
|
|||||||
lastElement = 7;
|
lastElement = 7;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tlv::ApplicationParameters: {
|
case tlv::Dsz: {
|
||||||
if (lastElement >= 8) {
|
if (lastElement >= 8) {
|
||||||
|
break; // Dsz is non-critical, ignore out-of-order appearance
|
||||||
|
}
|
||||||
|
if (element->value_size() != 2) {
|
||||||
|
NDN_THROW(Error("Dsz element is malformed"));
|
||||||
|
}
|
||||||
|
uint16_t dsz = 0;
|
||||||
|
std::memcpy(&dsz, element->value(), sizeof(dsz));
|
||||||
|
m_dsz = dsz;
|
||||||
|
lastElement = 8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case tlv::ServiceClass: {
|
||||||
|
if (lastElement >= 9) {
|
||||||
|
break; // ServiceClass is non-critical, ignore out-of-order appearance
|
||||||
|
}
|
||||||
|
if (element->value_size() != 1) {
|
||||||
|
NDN_THROW(Error("ServiceClass element is malformed" + std::to_string(element->value_size())));
|
||||||
|
}
|
||||||
|
m_serviceClass = *element->value();
|
||||||
|
lastElement = 9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case tlv::DownstreamRate: {
|
||||||
|
if (lastElement >= 10) {
|
||||||
|
break; // DownstreamRate is non-critical, ignore out-of-order appearance
|
||||||
|
}
|
||||||
|
uint64_t downstreamRate = 0;
|
||||||
|
if (element->value_size() != 8) {
|
||||||
|
NDN_THROW(Error("DownstreamRate element is malformed"));
|
||||||
|
}
|
||||||
|
std::memcpy(&downstreamRate, element->value(), sizeof(downstreamRate));
|
||||||
|
m_downstreamRate = downstreamRate;
|
||||||
|
lastElement = 10;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case tlv::ApplicationParameters: {
|
||||||
|
if (lastElement >= 11) {
|
||||||
break; // ApplicationParameters is non-critical, ignore out-of-order appearance
|
break; // ApplicationParameters is non-critical, ignore out-of-order appearance
|
||||||
}
|
}
|
||||||
BOOST_ASSERT(!hasApplicationParameters());
|
BOOST_ASSERT(!hasApplicationParameters());
|
||||||
m_parameters.push_back(*element);
|
m_parameters.push_back(*element);
|
||||||
lastElement = 8;
|
lastElement = 11;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: { // unrecognized element
|
default: { // unrecognized element
|
||||||
@@ -406,6 +470,37 @@ generateNonce()
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Interest&
|
||||||
|
Interest::setServiceClass(optional<uint8_t> serviceClass) const
|
||||||
|
{
|
||||||
|
if (m_serviceClass != serviceClass) {
|
||||||
|
m_serviceClass = serviceClass;
|
||||||
|
m_wire.reset();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Interest&
|
||||||
|
Interest::setDownstreamRate(optional<uint64_t> downstreamRate) const
|
||||||
|
{
|
||||||
|
if (m_downstreamRate != downstreamRate) {
|
||||||
|
m_downstreamRate = downstreamRate;
|
||||||
|
m_wire.reset();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Interest&
|
||||||
|
Interest::setDsz(optional<uint16_t> dsz) const
|
||||||
|
{
|
||||||
|
if (m_dsz != dsz) {
|
||||||
|
m_dsz = dsz;
|
||||||
|
m_wire.reset();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Interest::Nonce
|
Interest::Nonce
|
||||||
Interest::getNonce() const
|
Interest::getNonce() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -291,6 +291,32 @@ public: // element access
|
|||||||
Interest&
|
Interest&
|
||||||
setNonce(optional<Nonce> nonce);
|
setNonce(optional<Nonce> nonce);
|
||||||
|
|
||||||
|
optional<uint8_t>
|
||||||
|
getServiceClass() const noexcept
|
||||||
|
{
|
||||||
|
return m_serviceClass;
|
||||||
|
}
|
||||||
|
const Interest&
|
||||||
|
setServiceClass(optional<uint8_t> serviceClass) const;
|
||||||
|
|
||||||
|
optional<uint64_t>
|
||||||
|
getDownstreamRate() const noexcept
|
||||||
|
{
|
||||||
|
return m_downstreamRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Interest&
|
||||||
|
setDownstreamRate(optional<uint64_t> downstreamRate) const;
|
||||||
|
|
||||||
|
optional<uint16_t>
|
||||||
|
getDsz() const noexcept
|
||||||
|
{
|
||||||
|
return m_dsz;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Interest&
|
||||||
|
setDsz(optional<uint16_t> dsz) const;
|
||||||
|
|
||||||
/** @brief Change nonce value.
|
/** @brief Change nonce value.
|
||||||
*
|
*
|
||||||
* If the Nonce element is present, the new nonce value will differ from the old value.
|
* If the Nonce element is present, the new nonce value will differ from the old value.
|
||||||
@@ -508,6 +534,10 @@ private:
|
|||||||
Name m_name;
|
Name m_name;
|
||||||
DelegationList m_forwardingHint;
|
DelegationList m_forwardingHint;
|
||||||
mutable optional<Nonce> m_nonce;
|
mutable optional<Nonce> m_nonce;
|
||||||
|
// Add for QSCCP
|
||||||
|
mutable optional<uint8_t> m_serviceClass;
|
||||||
|
mutable optional<uint64_t> m_downstreamRate;
|
||||||
|
mutable optional<uint16_t> m_dsz;
|
||||||
time::milliseconds m_interestLifetime;
|
time::milliseconds m_interestLifetime;
|
||||||
optional<uint8_t> m_hopLimit;
|
optional<uint8_t> m_hopLimit;
|
||||||
mutable bool m_isCanBePrefixSet = false;
|
mutable bool m_isCanBePrefixSet = false;
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ FaceCreateCommand::FaceCreateCommand()
|
|||||||
.optional(CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL)
|
.optional(CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL)
|
||||||
.optional(CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD)
|
.optional(CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD)
|
||||||
.optional(CONTROL_PARAMETER_MTU)
|
.optional(CONTROL_PARAMETER_MTU)
|
||||||
|
.optional(CONTROL_PARAMETER_BANDWIDTH)
|
||||||
.optional(CONTROL_PARAMETER_FLAGS)
|
.optional(CONTROL_PARAMETER_FLAGS)
|
||||||
.optional(CONTROL_PARAMETER_MASK);
|
.optional(CONTROL_PARAMETER_MASK);
|
||||||
m_responseValidator
|
m_responseValidator
|
||||||
@@ -116,6 +117,7 @@ FaceCreateCommand::FaceCreateCommand()
|
|||||||
.optional(CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL)
|
.optional(CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL)
|
||||||
.optional(CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD)
|
.optional(CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD)
|
||||||
.optional(CONTROL_PARAMETER_MTU)
|
.optional(CONTROL_PARAMETER_MTU)
|
||||||
|
.optional(CONTROL_PARAMETER_BANDWIDTH)
|
||||||
.required(CONTROL_PARAMETER_FLAGS);
|
.required(CONTROL_PARAMETER_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "ndn-cxx/encoding/tlv-nfd.hpp"
|
#include "ndn-cxx/encoding/tlv-nfd.hpp"
|
||||||
#include "ndn-cxx/util/concepts.hpp"
|
#include "ndn-cxx/util/concepts.hpp"
|
||||||
#include "ndn-cxx/util/string-helper.hpp"
|
#include "ndn-cxx/util/string-helper.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace ndn {
|
namespace ndn {
|
||||||
namespace nfd {
|
namespace nfd {
|
||||||
@@ -51,6 +52,9 @@ ControlParameters::wireEncode(EncodingImpl<TAG>& encoder) const
|
|||||||
{
|
{
|
||||||
size_t totalLength = 0;
|
size_t totalLength = 0;
|
||||||
|
|
||||||
|
if (this->hasBandwidth()) {
|
||||||
|
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Bandwidth, m_bandwidth);
|
||||||
|
}
|
||||||
if (this->hasMtu()) {
|
if (this->hasMtu()) {
|
||||||
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Mtu, m_mtu);
|
totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Mtu, m_mtu);
|
||||||
}
|
}
|
||||||
@@ -238,6 +242,12 @@ ControlParameters::wireDecode(const Block& block)
|
|||||||
if (this->hasMtu()) {
|
if (this->hasMtu()) {
|
||||||
m_mtu = readNonNegativeInteger(*val);
|
m_mtu = readNonNegativeInteger(*val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = m_wire.find(tlv::nfd::Bandwidth);
|
||||||
|
m_hasFields[CONTROL_PARAMETER_BANDWIDTH] = val != m_wire.elements_end();
|
||||||
|
if (this->hasBandwidth()) {
|
||||||
|
m_bandwidth = readNonNegativeInteger(*val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -382,6 +392,10 @@ operator<<(std::ostream& os, const ControlParameters& parameters)
|
|||||||
os << "Mtu: " << parameters.getMtu() << ", ";
|
os << "Mtu: " << parameters.getMtu() << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parameters.hasBandwidth()) {
|
||||||
|
os << "Bandwidth: " << parameters.getBandwidth() << ", ";
|
||||||
|
}
|
||||||
|
|
||||||
os << ")";
|
os << ")";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ enum ControlParameterField {
|
|||||||
CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL,
|
CONTROL_PARAMETER_BASE_CONGESTION_MARKING_INTERVAL,
|
||||||
CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD,
|
CONTROL_PARAMETER_DEFAULT_CONGESTION_THRESHOLD,
|
||||||
CONTROL_PARAMETER_MTU,
|
CONTROL_PARAMETER_MTU,
|
||||||
|
CONTROL_PARAMETER_BANDWIDTH,
|
||||||
CONTROL_PARAMETER_UBOUND
|
CONTROL_PARAMETER_UBOUND
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +70,8 @@ const std::string CONTROL_PARAMETER_FIELD[CONTROL_PARAMETER_UBOUND] = {
|
|||||||
"FacePersistency",
|
"FacePersistency",
|
||||||
"BaseCongestionMarkingInterval",
|
"BaseCongestionMarkingInterval",
|
||||||
"DefaultCongestionThreshold",
|
"DefaultCongestionThreshold",
|
||||||
"Mtu"
|
"Mtu",
|
||||||
|
"Bandwidth",
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,6 +597,43 @@ public: // getters & setters
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasBandwidth() const
|
||||||
|
{
|
||||||
|
return m_hasFields[CONTROL_PARAMETER_BANDWIDTH];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief get bandwidth (measured in bps)
|
||||||
|
*
|
||||||
|
* This value is capped at MAX_NDN_BITRATE, even if the bandwidth of the face is unlimited.
|
||||||
|
*/
|
||||||
|
uint64_t
|
||||||
|
getBandwidth() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(this->hasBandwidth());
|
||||||
|
return m_bandwidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief set bandwidth (measured in bps)
|
||||||
|
*
|
||||||
|
* This value is capped at MAX_NDN_BITRATE, even if the bandwidth of the face is unlimited.
|
||||||
|
*/
|
||||||
|
ControlParameters&
|
||||||
|
setBandwidth(uint64_t bandwidth)
|
||||||
|
{
|
||||||
|
m_wire.reset();
|
||||||
|
m_bandwidth = bandwidth;
|
||||||
|
m_hasFields[CONTROL_PARAMETER_BANDWIDTH] = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlParameters&
|
||||||
|
unsetBandwidth()
|
||||||
|
{
|
||||||
|
m_wire.reset();
|
||||||
|
m_hasFields[CONTROL_PARAMETER_BANDWIDTH] = false;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<bool>&
|
const std::vector<bool>&
|
||||||
getPresentFields() const
|
getPresentFields() const
|
||||||
{
|
{
|
||||||
@@ -652,6 +691,7 @@ private: // fields
|
|||||||
time::nanoseconds m_baseCongestionMarkingInterval;
|
time::nanoseconds m_baseCongestionMarkingInterval;
|
||||||
uint64_t m_defaultCongestionThreshold;
|
uint64_t m_defaultCongestionThreshold;
|
||||||
uint64_t m_mtu;
|
uint64_t m_mtu;
|
||||||
|
uint64_t m_bandwidth;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable Block m_wire;
|
mutable Block m_wire;
|
||||||
|
|||||||
Reference in new issue
Block a user