mirror of
https://github.com/espressif/openthread.git
synced 2026-09-14 13:10:08 +00:00
[mac] validate channel in Mac::SetChannel() (#2030)
This commit is contained in:
@@ -54,7 +54,7 @@ otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
|
|||||||
VerifyOrExit(aInstance->mThreadNetif.GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
|
VerifyOrExit(aInstance->mThreadNetif.GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
|
||||||
error = OT_ERROR_INVALID_STATE);
|
error = OT_ERROR_INVALID_STATE);
|
||||||
|
|
||||||
error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel);
|
SuccessOrExit(error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel));
|
||||||
aInstance->mThreadNetif.GetActiveDataset().Clear();
|
aInstance->mThreadNetif.GetActiveDataset().Clear();
|
||||||
aInstance->mThreadNetif.GetPendingDataset().Clear();
|
aInstance->mThreadNetif.GetPendingDataset().Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -475,7 +475,12 @@ otError Mac::SetShortAddress(ShortAddress aShortAddress)
|
|||||||
|
|
||||||
otError Mac::SetChannel(uint8_t aChannel)
|
otError Mac::SetChannel(uint8_t aChannel)
|
||||||
{
|
{
|
||||||
|
otError error = OT_ERROR_NONE;
|
||||||
|
|
||||||
otLogFuncEntryMsg("%d", aChannel);
|
otLogFuncEntryMsg("%d", aChannel);
|
||||||
|
|
||||||
|
VerifyOrExit(OT_RADIO_CHANNEL_MIN <= aChannel && aChannel <= OT_RADIO_CHANNEL_MAX, error = OT_ERROR_INVALID_ARGS);
|
||||||
|
|
||||||
mChannel = aChannel;
|
mChannel = aChannel;
|
||||||
|
|
||||||
if (mState == kStateIdle)
|
if (mState == kStateIdle)
|
||||||
@@ -483,8 +488,9 @@ otError Mac::SetChannel(uint8_t aChannel)
|
|||||||
NextOperation();
|
NextOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
otLogFuncExit();
|
otLogFuncExit();
|
||||||
return OT_ERROR_NONE;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
otError Mac::SetNetworkName(const char *aNetworkName)
|
otError Mac::SetNetworkName(const char *aNetworkName)
|
||||||
|
|||||||
Reference in New Issue
Block a user