[api] check on prefix length when slaac is enabled (#5530)

This commit is contained in:
Jiacheng Guo
2020-10-23 10:40:03 -07:00
committed by GitHub
parent 96fa787d05
commit 7a2ce9e93d
2 changed files with 6 additions and 2 deletions
+4
View File
@@ -62,6 +62,10 @@ otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRoute
// Thread 1.1 Specification 5.13.2 says
// "A valid prefix MUST NOT allow both DHCPv6 and SLAAC for address configuration"
VerifyOrExit(!aConfig->mDhcp || !aConfig->mSlaac, error = OT_ERROR_INVALID_ARGS);
// RFC 4944 Section 6 says:
// An IPv6 address prefix used for stateless autoconfiguration [RFC4862]
// of an IEEE 802.15.4 interface MUST have a length of 64 bits.
VerifyOrExit(!aConfig->mSlaac || aConfig->mPrefix.mLength == OT_IP6_PREFIX_BITSIZE, error = OT_ERROR_INVALID_ARGS);
error = instance.Get<NetworkData::Local>().AddOnMeshPrefix(*config);
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
@@ -249,7 +249,7 @@ wpan.verify_within(check_prefix4_removed_from_r1, WAIT_TIME)
r1.add_prefix(
prefix4,
48,
64,
priority="-1",
stable=True,
on_mesh=False,
@@ -262,7 +262,7 @@ r1.add_prefix(
verify_prefix(
[r1],
prefix4,
48,
64,
priority="low",
stable=True,
on_mesh=False,