mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 02:17:47 +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,
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel);
|
||||
SuccessOrExit(error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel));
|
||||
aInstance->mThreadNetif.GetActiveDataset().Clear();
|
||||
aInstance->mThreadNetif.GetPendingDataset().Clear();
|
||||
|
||||
|
||||
@@ -475,7 +475,12 @@ otError Mac::SetShortAddress(ShortAddress aShortAddress)
|
||||
|
||||
otError Mac::SetChannel(uint8_t aChannel)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otLogFuncEntryMsg("%d", aChannel);
|
||||
|
||||
VerifyOrExit(OT_RADIO_CHANNEL_MIN <= aChannel && aChannel <= OT_RADIO_CHANNEL_MAX, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
mChannel = aChannel;
|
||||
|
||||
if (mState == kStateIdle)
|
||||
@@ -483,8 +488,9 @@ otError Mac::SetChannel(uint8_t aChannel)
|
||||
NextOperation();
|
||||
}
|
||||
|
||||
exit:
|
||||
otLogFuncExit();
|
||||
return OT_ERROR_NONE;
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Mac::SetNetworkName(const char *aNetworkName)
|
||||
|
||||
Reference in New Issue
Block a user