mirror of
https://github.com/espressif/openthread.git
synced 2026-08-08 11:47:46 +00:00
[ip6] limit to source prefix length in SelectSourceAddress() (#4377)
RFC 6724 Section 2.2 states: We define the common prefix length CommonPrefixLen(S, D) of a source address S and a destination address D as the length of the longest prefix (looking at the most significant, or leftmost, bits) that the two addresses have in common, up to the length of S's prefix (i.e., the portion of the address not including the interface ID). For example, CommonPrefixLen(fe80::1, fe80::2) is 64.
This commit is contained in:
+10
-1
@@ -1316,7 +1316,16 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
|
||||
}
|
||||
|
||||
candidatePrefixMatched = destination->PrefixMatch(*candidateAddr);
|
||||
overrideScope = (candidatePrefixMatched >= addr->mPrefixLength) ? addr->GetScope() : destinationScope;
|
||||
|
||||
if (candidatePrefixMatched >= addr->mPrefixLength)
|
||||
{
|
||||
candidatePrefixMatched = addr->mPrefixLength;
|
||||
overrideScope = addr->GetScope();
|
||||
}
|
||||
else
|
||||
{
|
||||
overrideScope = destinationScope;
|
||||
}
|
||||
|
||||
if (rvalAddr == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user