mirror of
https://github.com/espressif/openthread.git
synced 2026-10-19 22:18:17 +00:00
[ip6-address] move more complex Prefix methods to cpp file (#8011)
This commit moves more complex methods of `Ip6::Prefix` class to the `cpp` file. It also simplifies the `IsLinkLocal()` implementation. It also updates unit test `test_ip_address` to validate `IsLinkLocal()`, `IsMulticast()`, and `IsUniqueLocal()` methods.
This commit is contained in:
@@ -432,6 +432,30 @@ void TestIp6Prefix(void)
|
||||
VerifyOrQuit(!(testCase.mPrefixB < testCase.mPrefixA));
|
||||
}
|
||||
}
|
||||
|
||||
// `IsLinkLocal()` - should contain `fe80::/10`.
|
||||
VerifyOrQuit(PrefixFrom("fe80::", 10).IsLinkLocal());
|
||||
VerifyOrQuit(PrefixFrom("fe80::", 11).IsLinkLocal());
|
||||
VerifyOrQuit(PrefixFrom("fea0::", 16).IsLinkLocal());
|
||||
VerifyOrQuit(!PrefixFrom("fe80::", 9).IsLinkLocal());
|
||||
VerifyOrQuit(!PrefixFrom("ff80::", 10).IsLinkLocal());
|
||||
VerifyOrQuit(!PrefixFrom("fe00::", 10).IsLinkLocal());
|
||||
VerifyOrQuit(!PrefixFrom("fec0::", 10).IsLinkLocal());
|
||||
|
||||
// `IsMulticast()` - should contain `ff00::/8`.
|
||||
VerifyOrQuit(PrefixFrom("ff00::", 8).IsMulticast());
|
||||
VerifyOrQuit(PrefixFrom("ff80::", 9).IsMulticast());
|
||||
VerifyOrQuit(PrefixFrom("ffff::", 16).IsMulticast());
|
||||
VerifyOrQuit(!PrefixFrom("ff00::", 7).IsMulticast());
|
||||
VerifyOrQuit(!PrefixFrom("fe00::", 8).IsMulticast());
|
||||
|
||||
// `IsUniqueLocal()` - should contain `fc00::/7`.
|
||||
VerifyOrQuit(PrefixFrom("fc00::", 7).IsUniqueLocal());
|
||||
VerifyOrQuit(PrefixFrom("fd00::", 8).IsUniqueLocal());
|
||||
VerifyOrQuit(PrefixFrom("fc10::", 16).IsUniqueLocal());
|
||||
VerifyOrQuit(!PrefixFrom("fc00::", 6).IsUniqueLocal());
|
||||
VerifyOrQuit(!PrefixFrom("f800::", 7).IsUniqueLocal());
|
||||
VerifyOrQuit(!PrefixFrom("fe00::", 7).IsUniqueLocal());
|
||||
}
|
||||
|
||||
void TestIp4Ip6Translation(void)
|
||||
|
||||
Reference in New Issue
Block a user