select mesh local address (#1734)

This commit is contained in:
Buke Po
2017-05-09 22:00:48 -07:00
committed by Jonathan Hui
parent ff5c068a5a
commit 9c141d798f
+24
View File
@@ -1021,6 +1021,30 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
rvalPrefixMatched = candidatePrefixMatched;
}
}
else if (rvalAddr->GetScope() == Address::kRealmLocalScope)
{
// Additional rule: Prefer appropriate realm local address
if (overrideScope > Address::kRealmLocalScope)
{
if (rvalAddr->GetAddress().IsRoutingLocator())
{
// Prefer EID if destination is not realm local.
rvalAddr = addr;
rvalIface = candidateId;
rvalPrefixMatched = candidatePrefixMatched;
}
}
else
{
if (candidateAddr->IsRoutingLocator())
{
// Prefer RLOC if destination is realm local.
rvalAddr = addr;
rvalIface = candidateId;
rvalPrefixMatched = candidatePrefixMatched;
}
}
}
else if (addr->mPreferred && !rvalAddr->mPreferred)
{
// Rule 3: Avoid deprecated addresses