mirror of
https://github.com/espressif/openthread.git
synced 2026-07-09 13:50:28 +00:00
Apply realm-local scope to mesh-local addresses for source address selection. (#1000)
This commit is contained in:
@@ -897,11 +897,13 @@ typedef struct otBufferInfo
|
||||
*/
|
||||
typedef struct otNetifAddress
|
||||
{
|
||||
otIp6Address mAddress; ///< The IPv6 unicast address.
|
||||
uint32_t mPreferredLifetime; ///< The Preferred Lifetime.
|
||||
uint32_t mValidLifetime; ///< The Valid lifetime.
|
||||
uint8_t mPrefixLength; ///< The Prefix length.
|
||||
struct otNetifAddress *mNext; ///< A pointer to the next network interface address.
|
||||
otIp6Address mAddress; ///< The IPv6 unicast address.
|
||||
uint32_t mPreferredLifetime; ///< The Preferred Lifetime.
|
||||
uint32_t mValidLifetime; ///< The Valid lifetime.
|
||||
uint8_t mPrefixLength; ///< The Prefix length.
|
||||
unsigned int mScopeOverride : 4; ///< The IPv6 scope of this address.
|
||||
bool mScopeOverrideValid : 1; ///< TRUE if the mScopeOverride value is valid, FALSE othewrise.
|
||||
struct otNetifAddress *mNext; ///< A pointer to the next network interface address.
|
||||
} otNetifAddress;
|
||||
|
||||
/**
|
||||
|
||||
@@ -993,18 +993,18 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
|
||||
rvalIface = candidateId;
|
||||
goto exit;
|
||||
}
|
||||
else if (candidateAddr->GetScope() < rvalAddr->GetAddress().GetScope())
|
||||
else if (addr->GetScope() < rvalAddr->GetScope())
|
||||
{
|
||||
// Rule 2: Prefer appropriate scope
|
||||
if (candidateAddr->GetScope() >= destination->GetScope())
|
||||
if (addr->GetScope() >= destination->GetScope())
|
||||
{
|
||||
rvalAddr = addr;
|
||||
rvalIface = candidateId;
|
||||
}
|
||||
}
|
||||
else if (candidateAddr->GetScope() > rvalAddr->GetAddress().GetScope())
|
||||
else if (addr->GetScope() > rvalAddr->GetScope())
|
||||
{
|
||||
if (rvalAddr->GetAddress().GetScope() < destination->GetScope())
|
||||
if (rvalAddr->GetScope() < destination->GetScope())
|
||||
{
|
||||
rvalAddr = addr;
|
||||
rvalIface = candidateId;
|
||||
|
||||
@@ -100,6 +100,16 @@ public:
|
||||
*/
|
||||
Address &GetAddress(void) { return *static_cast<Address *>(&mAddress); }
|
||||
|
||||
/**
|
||||
* This method returns the IPv6 scope value.
|
||||
*
|
||||
* @returns The IPv6 scope value.
|
||||
*
|
||||
*/
|
||||
uint8_t GetScope(void) const {
|
||||
return mScopeOverrideValid ? static_cast<uint8_t>(mScopeOverride) : GetAddress().GetScope();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the next unicast address assigned to the interface.
|
||||
*
|
||||
|
||||
@@ -105,12 +105,16 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mLeaderAloc.mPrefixLength = 128;
|
||||
mLeaderAloc.mPreferredLifetime = 0xffffffff;
|
||||
mLeaderAloc.mValidLifetime = 0xffffffff;
|
||||
mLeaderAloc.mScopeOverride = Ip6::Address::kRealmLocalScope;
|
||||
mLeaderAloc.mScopeOverrideValid = true;
|
||||
|
||||
// initialize Mesh Local Prefix
|
||||
mMeshLocal64.GetAddress().mFields.m8[0] = 0xfd;
|
||||
memcpy(mMeshLocal64.GetAddress().mFields.m8 + 1, mMac.GetExtendedPanId(), 5);
|
||||
mMeshLocal64.GetAddress().mFields.m8[6] = 0x00;
|
||||
mMeshLocal64.GetAddress().mFields.m8[7] = 0x00;
|
||||
mMeshLocal64.mScopeOverride = Ip6::Address::kRealmLocalScope;
|
||||
mMeshLocal64.mScopeOverrideValid = true;
|
||||
|
||||
// mesh-local 64
|
||||
for (int i = 8; i < 16; i++)
|
||||
@@ -130,6 +134,8 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
|
||||
mMeshLocal16.mPrefixLength = 64;
|
||||
mMeshLocal16.mPreferredLifetime = 0xffffffff;
|
||||
mMeshLocal16.mValidLifetime = 0xffffffff;
|
||||
mMeshLocal16.mScopeOverride = Ip6::Address::kRealmLocalScope;
|
||||
mMeshLocal16.mScopeOverrideValid = true;
|
||||
|
||||
// Store RLOC address reference in MPL module.
|
||||
mNetif.GetIp6().mMpl.SetMatchingAddress(mMeshLocal16.GetAddress());
|
||||
|
||||
Reference in New Issue
Block a user