[meshcop] support a zero-length network name for backwards compatibility (#8241)

Add a configuration option to support a zero-length network name
within the OT stack.
This commit is contained in:
Tom Rebbert
2022-10-11 15:22:57 -07:00
committed by GitHub
parent 04feddc458
commit 9c6b45c1dc
5 changed files with 23 additions and 5 deletions
+6
View File
@@ -202,6 +202,12 @@ otError otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName)
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
#if !OPENTHREAD_CONFIG_ALLOW_EMPTY_NETWORK_NAME
// Thread interfaces support a zero length name internally for backwards compatibility, but new names
// must be at least one valid character long.
VerifyOrExit(nullptr != aNetworkName && aNetworkName[0] != '\0', error = kErrorInvalidArgs);
#endif
error = AsCoreType(aInstance).Get<MeshCoP::NetworkNameManager>().SetNetworkName(aNetworkName);
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Clear();