mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 14:27:47 +00:00
[bbr] move BBR constants to related source files (#9129)
This commit moves BBR and DUA related constants to the related source files (from `mle_types.hpp`). Additionally, unused constant variables are removed. Some of the constants are renamed to make the definition more clear.
This commit is contained in:
@@ -166,7 +166,7 @@ otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6A
|
||||
aTimeout = config.mMlrTimeout;
|
||||
}
|
||||
|
||||
aTimeout = Min(aTimeout, Mle::kMlrTimeoutMax);
|
||||
aTimeout = Min(aTimeout, BackboneRouter::kMaxMlrTimeout);
|
||||
aTimeout = Time::SecToMsec(aTimeout);
|
||||
|
||||
return AsCoreType(aInstance).Get<BackboneRouter::MulticastListenersTable>().Add(AsCoreType(aAddress),
|
||||
|
||||
@@ -196,7 +196,7 @@ void Leader::UpdateBackboneRouterPrimary(void)
|
||||
{
|
||||
uint32_t origTimeout = config.mMlrTimeout;
|
||||
|
||||
config.mMlrTimeout = Clamp(config.mMlrTimeout, Mle::kMlrTimeoutMin, Mle::kMlrTimeoutMax);
|
||||
config.mMlrTimeout = Clamp(config.mMlrTimeout, kMinMlrTimeout, kMaxMlrTimeout);
|
||||
|
||||
if (config.mMlrTimeout != origTimeout)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,18 @@ namespace BackboneRouter {
|
||||
|
||||
typedef otBackboneRouterConfig Config;
|
||||
|
||||
constexpr uint16_t kDefaultRegistrationDelay = 5; ///< Default registration delay (in sec).
|
||||
constexpr uint32_t kDefaultMlrTimeout = 3600; ///< Default MLR Timeout (in sec).
|
||||
constexpr uint32_t kMinMlrTimeout = 300; ///< Minimum MLR Timeout (in sec).
|
||||
constexpr uint32_t kMaxMlrTimeout = 0x7fffffff / 1000; ///< Max MLR Timeout (in sec ~ about 24 days.
|
||||
constexpr uint8_t kDefaultRegistrationJitter = 5; ///< Default registration jitter (in sec).
|
||||
constexpr uint8_t kParentAggregateDelay = 5; ///< Parent Aggregate Delay (in sec).
|
||||
|
||||
static_assert(kDefaultMlrTimeout >= kMinMlrTimeout && kDefaultMlrTimeout <= kMaxMlrTimeout,
|
||||
"kDefaultMlrTimeout is not in valid range");
|
||||
static_assert(kMaxMlrTimeout * 1000 > kMaxMlrTimeout, "SecToMsec(kMaxMlrTimeout) will overflow");
|
||||
static_assert(kParentAggregateDelay > 1, "kParentAggregateDelay should be larger than 1 second");
|
||||
|
||||
/**
|
||||
* Implements the basic Primary Backbone Router service operations.
|
||||
*
|
||||
|
||||
@@ -52,10 +52,10 @@ RegisterLogModule("BbrLocal");
|
||||
Local::Local(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mState(kStateDisabled)
|
||||
, mMlrTimeout(Mle::kMlrTimeoutDefault)
|
||||
, mReregistrationDelay(Mle::kRegistrationDelayDefault)
|
||||
, mMlrTimeout(kDefaultMlrTimeout)
|
||||
, mReregistrationDelay(kDefaultRegistrationDelay)
|
||||
, mSequenceNumber(Random::NonCrypto::GetUint8() % 127)
|
||||
, mRegistrationJitter(Mle::kBackboneRouterRegistrationJitter)
|
||||
, mRegistrationJitter(kDefaultRegistrationJitter)
|
||||
, mIsServiceAdded(false)
|
||||
{
|
||||
mDomainPrefixConfig.GetPrefix().SetLength(0);
|
||||
@@ -131,7 +131,7 @@ Error Local::SetConfig(const Config &aConfig)
|
||||
bool update = false;
|
||||
|
||||
#if !OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
VerifyOrExit(aConfig.mMlrTimeout >= Mle::kMlrTimeoutMin && aConfig.mMlrTimeout <= Mle::kMlrTimeoutMax,
|
||||
VerifyOrExit(aConfig.mMlrTimeout >= kMinMlrTimeout && aConfig.mMlrTimeout <= kMaxMlrTimeout,
|
||||
error = kErrorInvalidArgs);
|
||||
#endif
|
||||
// Validate configuration according to Thread 1.2.1 Specification 5.21.3.3:
|
||||
|
||||
@@ -209,7 +209,7 @@ void Manager::HandleMulticastListenerRegistration(const Coap::Message &aMessage,
|
||||
{
|
||||
uint32_t origTimeout = timeout;
|
||||
|
||||
timeout = Min(timeout, Mle::kMlrTimeoutMax);
|
||||
timeout = Min(timeout, kMaxMlrTimeout);
|
||||
|
||||
if (timeout != origTimeout)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ void Manager::SendBackboneMulticastListenerRegistration(const Ip6::Address *aAdd
|
||||
messageInfo.SetPeerAddr(Get<Local>().GetAllNetworkBackboneRoutersAddress());
|
||||
messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort); // TODO: Provide API for configuring Backbone COAP port.
|
||||
|
||||
messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit);
|
||||
messageInfo.SetHopLimit(kDefaultHoplimit);
|
||||
messageInfo.SetIsHostInterface(true);
|
||||
|
||||
SuccessOrExit(error = backboneTmf.SendMessage(*message, messageInfo));
|
||||
@@ -535,7 +535,7 @@ Error Manager::SendBackboneQuery(const Ip6::Address &aDua, uint16_t aRloc16)
|
||||
messageInfo.SetPeerAddr(Get<Local>().GetAllDomainBackboneRoutersAddress());
|
||||
messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort);
|
||||
|
||||
messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit);
|
||||
messageInfo.SetHopLimit(kDefaultHoplimit);
|
||||
messageInfo.SetIsHostInterface(true);
|
||||
|
||||
error = mBackboneTmfAgent.SendMessage(*message, messageInfo);
|
||||
@@ -672,7 +672,7 @@ Error Manager::SendBackboneAnswer(const Ip6::Address &aDstAddr,
|
||||
messageInfo.SetPeerAddr(aDstAddr);
|
||||
messageInfo.SetPeerPort(BackboneRouter::kBackboneUdpPort);
|
||||
|
||||
messageInfo.SetHopLimit(Mle::kDefaultBackboneHoplimit);
|
||||
messageInfo.SetHopLimit(kDefaultHoplimit);
|
||||
messageInfo.SetIsHostInterface(true);
|
||||
|
||||
error = mBackboneTmfAgent.SendMessage(*message, messageInfo);
|
||||
|
||||
@@ -172,7 +172,8 @@ public:
|
||||
uint32_t aTimeSinceLastTransaction);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t kTimerInterval = 1000;
|
||||
static constexpr uint8_t kDefaultHoplimit = 1;
|
||||
static constexpr uint32_t kTimerInterval = 1000;
|
||||
|
||||
template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void NdProxyTable::NdProxy::Update(uint16_t aRloc16, uint32_t aTimeSinceLastTran
|
||||
OT_ASSERT(mValid);
|
||||
|
||||
mRloc16 = aRloc16;
|
||||
aTimeSinceLastTransaction = Min(aTimeSinceLastTransaction, Mle::kTimeSinceLastTransactionMax);
|
||||
aTimeSinceLastTransaction = Min(aTimeSinceLastTransaction, kMaxTimeSinceLastTransaction);
|
||||
mLastRegistrationTime = TimerMilli::GetNow() - TimeMilli::SecToMsec(aTimeSinceLastTransaction);
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void NdProxyTable::NotifyDadComplete(NdProxyTable::NdProxy &aNdProxy, bool aDupl
|
||||
}
|
||||
else
|
||||
{
|
||||
aNdProxy.mDadAttempts = Mle::kDuaDadRepeats;
|
||||
aNdProxy.mDadAttempts = kDuaDadRepeats;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace BackboneRouter {
|
||||
class NdProxyTable : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
public:
|
||||
static constexpr uint8_t kDuaDadRepeats = 3; ///< Number multicast DAD queries by BBR
|
||||
|
||||
/**
|
||||
* Represents a ND Proxy instance.
|
||||
*
|
||||
@@ -120,6 +122,8 @@ public:
|
||||
bool GetDadFlag(void) const { return mDadFlag; }
|
||||
|
||||
private:
|
||||
static constexpr uint32_t kMaxTimeSinceLastTransaction = 10 * 86400; // In seconds (10 days).
|
||||
|
||||
NdProxy(void) { Clear(); }
|
||||
|
||||
void Init(const Ip6::InterfaceIdentifier &aAddressIid,
|
||||
@@ -129,7 +133,7 @@ public:
|
||||
|
||||
void Update(uint16_t aRloc16, uint32_t aTimeSinceLastTransaction);
|
||||
void IncreaseDadAttempts(void) { mDadAttempts++; }
|
||||
bool IsDadAttemptsComplete() const { return mDadAttempts == Mle::kDuaDadRepeats; }
|
||||
bool IsDadAttemptsComplete(void) const { return mDadAttempts == kDuaDadRepeats; }
|
||||
|
||||
Ip6::InterfaceIdentifier mAddressIid;
|
||||
Ip6::InterfaceIdentifier mMeshLocalIid;
|
||||
@@ -139,7 +143,7 @@ public:
|
||||
bool mDadFlag : 1;
|
||||
bool mValid : 1;
|
||||
|
||||
static_assert(Mle::kDuaDadRepeats < 4, "Mle::kDuaDadRepeats does not fit in mDadAttempts field as 2-bit value");
|
||||
static_assert(kDuaDadRepeats < 4, "kDuaDadRepeats does not fit in mDadAttempts field as 2-bit value");
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -376,7 +376,7 @@ void DuaManager::HandleTimeTick(void)
|
||||
mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
|
||||
|
||||
if ((mDuaState != kNotExist) &&
|
||||
(TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(Mle::kDuaDadPeriod))))
|
||||
(TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(kDuaDadPeriod))))
|
||||
{
|
||||
mDomainUnicastAddress.mPreferred = true;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ void DuaManager::PerformNextRegistration(void)
|
||||
exit:
|
||||
if (error == kErrorNoBufs)
|
||||
{
|
||||
UpdateCheckDelay(Mle::kNoBufDelay);
|
||||
UpdateCheckDelay(kNoBufDelay);
|
||||
}
|
||||
|
||||
LogInfo("PerformNextRegistration: %s", ErrorToString(error));
|
||||
@@ -574,7 +574,7 @@ void DuaManager::HandleDuaResponse(Coap::Message *aMessage, const Ip6::MessageIn
|
||||
|
||||
if (aResult == kErrorResponseTimeout)
|
||||
{
|
||||
UpdateCheckDelay(Mle::KResponseTimeoutDelay);
|
||||
UpdateCheckDelay(KResponseTimeoutDelay);
|
||||
ExitNow(error = aResult);
|
||||
}
|
||||
|
||||
@@ -780,7 +780,7 @@ void DuaManager::UpdateChildDomainUnicastAddress(const Child &aChild, Mle::Child
|
||||
{
|
||||
if (mChildDuaMask == mChildDuaRegisteredMask)
|
||||
{
|
||||
UpdateCheckDelay(Random::NonCrypto::GetUint8InRange(1, Mle::kParentAggregateDelay));
|
||||
UpdateCheckDelay(Random::NonCrypto::GetUint8InRange(1, BackboneRouter::kParentAggregateDelay));
|
||||
}
|
||||
|
||||
mChildDuaMask.Set(childIndex, true);
|
||||
|
||||
@@ -175,8 +175,11 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
static constexpr uint8_t kNewRouterRegistrationDelay = 3; ///< Delay (in sec) to establish link for a new router.
|
||||
static constexpr uint8_t kNewDuaRegistrationDelay = 1; ///< Delay (in sec) for newly added DUA.
|
||||
static constexpr uint32_t kDuaDadPeriod = 100; // DAD wait time to become "Preferred" (in sec).
|
||||
static constexpr uint8_t kNoBufDelay = 5; // In sec.
|
||||
static constexpr uint8_t KResponseTimeoutDelay = 30; // In sec.
|
||||
static constexpr uint8_t kNewRouterRegistrationDelay = 3; // Delay (in sec) to establish link for a new router.
|
||||
static constexpr uint8_t kNewDuaRegistrationDelay = 1; // Delay (in sec) for newly added DUA.
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
Error GenerateDomainUnicastAddressIid(void);
|
||||
|
||||
@@ -234,50 +234,6 @@ enum LeaderStartMode : uint8_t
|
||||
|
||||
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
|
||||
|
||||
/*
|
||||
* Backbone Router / DUA / MLR constants
|
||||
*
|
||||
*/
|
||||
constexpr uint16_t kRegistrationDelayDefault = 5; ///< In seconds.
|
||||
constexpr uint32_t kMlrTimeoutDefault = 3600; ///< In seconds.
|
||||
constexpr uint32_t kMlrTimeoutMin = 300; ///< In seconds.
|
||||
constexpr uint32_t kMlrTimeoutMax = 0x7fffffff / 1000; ///< In seconds (about 24 days).
|
||||
constexpr uint8_t kBackboneRouterRegistrationJitter = 5; ///< In seconds.
|
||||
constexpr uint8_t kParentAggregateDelay = 5; ///< In seconds.
|
||||
constexpr uint8_t kNoBufDelay = 5; ///< In seconds.
|
||||
constexpr uint8_t kImmediateReRegisterDelay = 1; ///< In seconds.
|
||||
constexpr uint8_t KResponseTimeoutDelay = 30; ///< In seconds.
|
||||
|
||||
/**
|
||||
* Time period after which the address becomes "Preferred" if no duplicate address error (in seconds).
|
||||
*
|
||||
*/
|
||||
constexpr uint32_t kDuaDadPeriod = 100;
|
||||
|
||||
/**
|
||||
* Maximum number of times the multicast DAD query and wait time DUA_DAD_QUERY_TIMEOUT are repeated by the BBR, as
|
||||
* part of the DAD process.
|
||||
*
|
||||
*/
|
||||
constexpr uint8_t kDuaDadRepeats = 3;
|
||||
|
||||
/**
|
||||
* Time period (in seconds) during which a DUA registration is considered 'recent' at a BBR.
|
||||
*
|
||||
*/
|
||||
constexpr uint32_t kDuaRecentTime = 20;
|
||||
constexpr uint32_t kTimeSinceLastTransactionMax = 10 * 86400; ///< In seconds (10 days).
|
||||
constexpr uint8_t kDefaultBackboneHoplimit = 1; ///< default hoplimit for Backbone Link Protocol messages
|
||||
|
||||
static_assert(kMlrTimeoutDefault >= kMlrTimeoutMin && kMlrTimeoutDefault <= kMlrTimeoutMax,
|
||||
"kMlrTimeoutDefault must be larger than or equal to kMlrTimeoutMin");
|
||||
|
||||
static_assert(Mle::kParentAggregateDelay > 1, "kParentAggregateDelay should be larger than 1 second");
|
||||
static_assert(kMlrTimeoutMax * 1000 > kMlrTimeoutMax, "SecToMsec(kMlrTimeoutMax) will overflow");
|
||||
|
||||
static_assert(kTimeSinceLastTransactionMax * 1000 > kTimeSinceLastTransactionMax,
|
||||
"SecToMsec(kTimeSinceLastTransactionMax) will overflow");
|
||||
|
||||
/**
|
||||
* State change of Child's DUA
|
||||
*
|
||||
|
||||
@@ -183,7 +183,7 @@ exit:
|
||||
|
||||
if (aChild.HasAnyMlrToRegisterAddress())
|
||||
{
|
||||
ScheduleSend(Random::NonCrypto::GetUint16InRange(1, Mle::kParentAggregateDelay));
|
||||
ScheduleSend(Random::NonCrypto::GetUint16InRange(1, BackboneRouter::kParentAggregateDelay));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,7 +648,7 @@ void MlrManager::UpdateReregistrationDelay(bool aRereg)
|
||||
{
|
||||
// Calculate renewing period according to Thread Spec. 5.24.2.3.2
|
||||
// The random time t SHOULD be chosen such that (0.5* MLR-Timeout) < t < (MLR-Timeout – 9 seconds).
|
||||
effectiveMlrTimeout = Max(config.mMlrTimeout, Mle::kMlrTimeoutMin);
|
||||
effectiveMlrTimeout = Max(config.mMlrTimeout, BackboneRouter::kMinMlrTimeout);
|
||||
reregDelay = Random::NonCrypto::GetUint32InRange((effectiveMlrTimeout >> 1u) + 1, effectiveMlrTimeout - 9);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user